-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make sure sodium is not an empty object in service workers #567
Conversation
@@ -42,6 +42,10 @@ function checkFastSigningNode() { | |||
return checkFastSigningBrowser(); | |||
} | |||
|
|||
if (!Object.keys(sodium).length) { | |||
return checkFastSigningBrowser(); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this codebase determines if a user is in a node env by checking window === "undefined"
. In a node env, the node lib sodium-native
is installed to use for signing tx's
What currently happens: In a service worker, window is undefined. But, since it's not a node env, sodium-native
is not installed. So, the var sodium
is an empty object when it gets here. This cause the signing methods below to break.
What happens after the change: we do another check to make sure sodium
has the appropriate keys. If it doesn't, use checkFastSigningBrowser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm following what you're saying, but does that mean that the require('sodium-native')
line does not throw in the Service Worker case, and just silently returns {}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's right. So here is sort of another edge EDGE case - if you're compiling with Webpack and have not included sodium-native
in your package, Webpack will recognize the missing dependency and silently replace require('sodium-native')
with an empty {}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol ok awesome, thanks for clarifying! LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! But I had a clarifying question as well.
@@ -42,6 +42,10 @@ function checkFastSigningNode() { | |||
return checkFastSigningBrowser(); | |||
} | |||
|
|||
if (!Object.keys(sodium).length) { | |||
return checkFastSigningBrowser(); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm following what you're saying, but does that mean that the require('sodium-native')
line does not throw in the Service Worker case, and just silently returns {}
?
Co-authored-by: George <Shaptic@users.noreply.github.com>
* Correctly set `minAccountSequence` in `TransactionBuilder` for large values (#539) * Bump terser from 4.8.0 to 4.8.1 (#536) Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1. - [Release notes](https://github.com/terser/terser/releases) - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) - [Commits](https://github.com/terser/terser/commits) --- updated-dependencies: - dependency-name: terser dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Release v8.1.0 (#540) * Add support of CAP40 ed25519SignedPayload signer for SetOptionOp (#542) * Add TypeScript interfaces for Ed25519SignedPayload signers * Release v8.2.0 (#545) * Coalesce all xLM, Xlm, etc. => 'XLM' native asset code (#546) * Release v8.2.1 (#554) * make sure sodium is not an empty object in service workers (#567) * make sure sodium is not an empty object in service workers * Update CHANGELOG.md Co-authored-by: George <Shaptic@users.noreply.github.com> Co-authored-by: George <Shaptic@users.noreply.github.com> * use next xdr * First pass at invokeHostFunction * Fixing test & lint * Would help if we actually exported the Contract wrapper * the invokeHostFunctionOp should be useable with transaction builder * Add sandbox network passphrase * Push to the soroban tag for PRs to base branch (#547) * Fix github action to publish soroban tag (#548) * Have to update package.json to build the soroban tag (#549) * Add futurenet passphrase for soroban. (#550) * Add FUTURENET network passphrase * Bump soroban package version * Update soroban xdr (#552) * Update xdr * Missed a few hash typeof shenanigans * don't need this export * Bump soroban package version (#553) * Include standalone network passphrase (#555) * Add STANDALONE network passphrase * bump version * Default to include the contract code footprint, as that is always needed (#557) * Default to include the contract code footprint, as that is always needed * 8.0.1-soroban.4 * Update xdr to 026c9cd (#563) * Update xdr * Bump the packge version * New soroban xdr updates (#566) * Missed removing parameters from the operation builder * Fix bug in contract.call footprint * Fixing up tests * Soroban auth next updates (#570) * update xdr for auth-next * Add auth field to invokeHostFunctionOp * bump version * Needed to modify the generated code slightly * Fix lint --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Jun Luo <4catcode@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: George <Shaptic@users.noreply.github.com> Co-authored-by: OrbitLens <33724849+orbitlens@users.noreply.github.com> Co-authored-by: Piyal Basu <pbasu235@gmail.com>
* Correctly set `minAccountSequence` in `TransactionBuilder` for large values (#539) * Add support of CAP40 ed25519SignedPayload signer for SetOptionOp (#542) * Add TypeScript interfaces for Ed25519SignedPayload signers * Coalesce all xLM, Xlm, etc. => 'XLM' native asset code (#546) * make sure sodium is not an empty object in service workers (#567) * Add futurenet passphrase for soroban. (#550) * Include standalone network passphrase (#555) * Soroban auth next updates (#570) * Add strkey parsing for contracts, and Address helper for building ScAddresses (#572) * Update xdr to include HashIdPreimageContractAuth.nonce (#577) * Add Address.toBuffer method (#578) * Soroban value overhaul (#582) * Update generated XDR to latest version. (#587) * Update XDR and contract invocations to conform to the latest version (Preview 9). (#601) * added soroban transaction data as tx builder param (#604) * Add Contract support for strkey-style contract IDs (#612) * Add Contract.address() method (#614) * Add wrappers to easily deal with the myriad of `ScVal` integer types. (#620) * Upgrade `js-xdr` to v3.0.0 to support `bigint` encoding. * Add wrappers to easily convert between `ScVal` and native types. (#630) * Update XDR to support Preview 10 (#633) * Fix TypeScript definition for `invokeHostFunction` options (#635) * Add fully-qualified `Operation` type to XDR type definitions. (#591) * Adds Operation.isValidAmount jsdoc (#609) * Removes the dependency on `crc` by calculating checksum in strkey (#621) * Improve type flexibility when building `ScVal`s from native types (#638) * Fix Preview 10 contract invoke & release `v10.0.0-soroban.3` (#642) * Add GitHub Action that compares before-and-after bundle sizes. (#644) * Make opinionated judgements about string/symbol decoding (#645) * Make Node 16 the minimum version. (#651) * Add standalone/futurenet passphrases to jsdoc (#654) * Clean up unnecessary dependency entries (#652) * Add `SorobanDataBuilder` builder pattern to prepare transactions easier (#660) * Adds a way to create a `TransactionBuilder` from an existing transaction. (#656) * Add basic contract event parsing into a human-readable structure (#659) * Drop support for deprecated hex contract IDs (#658) * Add helpers method to build authorization entries. (#663) * Fix TypeScript definition for new static `TransactionBuilder` constructor (#665) * Add ability to clear out operations from the transaction builder (#670) * Add an existing method to XdrLargeInt, jsdoc/types fixup (#668) * Expand contract footprint with contract code ledger key. (#662) * Decode base64-encoded strings in new SorobanDataBuilder (#673) * Add ability to modify and retrieve the resource footprint (#680) * Fixes error messages for required amount parameters (#679) * Add `Asset.contractId()` helper to predict contract IDs (#684) * Upgrade dependencies to their latest minor/patch version (#685) * Improves `SorobanDataBuilder` construction and adds a getter (#686) * Add JSON-ification of Soroban invocation trees. (#669) * Add utilities for formatting token amounts (`formatTokenAmount` & `parseTokenAmount`) (#667) * Merges the final Protocol 20 XDR (i.e. for testnet) into `soroban` (#688) * Add support to convert strings to large integer and address `ScVal`s (#690) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Paul Bellamy <paul@stellar.org> Co-authored-by: George <Shaptic@users.noreply.github.com> Co-authored-by: Jun Luo <4catcode@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: OrbitLens <33724849+orbitlens@users.noreply.github.com> Co-authored-by: Piyal Basu <pbasu235@gmail.com> Co-authored-by: George Kudrayvtsev <george@stellar.org> Co-authored-by: shawn <sreuland@users.noreply.github.com> Co-authored-by: Silence <35656692+silence48@users.noreply.github.com> Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Co-authored-by: jeesun 지선 <jeesunikim@users.noreply.github.com>
* make sure sodium is not an empty object in service workers * Update CHANGELOG.md Co-authored-by: George <Shaptic@users.noreply.github.com> Co-authored-by: George <Shaptic@users.noreply.github.com>
No description provided.