diff --git a/.github/workflows/assets.yml b/.github/workflows/assets.yml new file mode 100644 index 00000000..73286942 --- /dev/null +++ b/.github/workflows/assets.yml @@ -0,0 +1,32 @@ +name: Assets + +on: + push: + branches: [dev] + paths: + - 'packages/common/assets/**' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: assets + cancel-in-progress: false + +jobs: + upload: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - name: Upload chain logos to R2 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: auto + AWS_REQUEST_CHECKSUM_CALCULATION: when_required + AWS_RESPONSE_CHECKSUM_VALIDATION: when_required + run: | + aws s3 cp packages/common/assets/chain/ s3://wharfkit/chain/ \ + --recursive --exclude '*' --include '*.png' --content-type image/png \ + --endpoint-url "https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com" diff --git a/bun.lock b/bun.lock index dd8a84f3..b35e4c24 100644 --- a/bun.lock +++ b/bun.lock @@ -32,7 +32,7 @@ }, "packages/abicache": { "name": "@wharfkit/abicache", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", "@wharfkit/signing-request": "workspace:*", @@ -44,7 +44,7 @@ }, "packages/account": { "name": "@wharfkit/account", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", "@wharfkit/common": "workspace:*", @@ -60,7 +60,7 @@ }, "packages/account-creation-plugin-anchor": { "name": "@wharfkit/account-creation-plugin-anchor", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -71,7 +71,7 @@ }, "packages/account-creation-plugin-jungle4": { "name": "@wharfkit/account-creation-plugin-jungle4", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -82,7 +82,7 @@ }, "packages/account-creation-plugin-metamask": { "name": "@wharfkit/account-creation-plugin-metamask", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@metamask/providers": "^17.0.0", "@wharfkit/session": "workspace:*", @@ -94,7 +94,7 @@ }, "packages/actionstream": { "name": "@wharfkit/actionstream", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", }, @@ -105,7 +105,7 @@ }, "packages/antelope": { "name": "@wharfkit/antelope", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@noble/curves": "^2.2.0", "@noble/hashes": "^2.2.0", @@ -115,7 +115,7 @@ }, "packages/atomicassets": { "name": "@wharfkit/atomicassets", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", "@wharfkit/common": "workspace:*", @@ -128,7 +128,7 @@ }, "packages/bundle": { "name": "@wharfkit/bundle", - "version": "4.0.1", + "version": "4.0.2", "devDependencies": { "@wharfkit/account": "workspace:*", "@wharfkit/antelope": "workspace:*", @@ -154,7 +154,7 @@ }, "packages/cli": { "name": "@wharfkit/cli", - "version": "4.0.1", + "version": "4.0.2", "bin": { "wharfkit": "./lib/cli.js", }, @@ -178,7 +178,7 @@ }, "packages/common": { "name": "@wharfkit/common", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", }, @@ -189,7 +189,7 @@ }, "packages/conformance": { "name": "@wharfkit/conformance", - "version": "4.0.1", + "version": "4.0.2", "devDependencies": { "@greymass/vert": "^3.0.0", "@types/bun": "^1.0.4", @@ -200,7 +200,7 @@ }, "packages/contract": { "name": "@wharfkit/contract", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/abicache": "workspace:*", "@wharfkit/antelope": "workspace:*", @@ -214,7 +214,7 @@ }, "packages/hyperion": { "name": "@wharfkit/hyperion", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", }, @@ -224,7 +224,7 @@ }, "packages/light-api": { "name": "@wharfkit/light-api", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", }, @@ -234,7 +234,7 @@ }, "packages/mock-data": { "name": "@wharfkit/mock-data", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", "@wharfkit/session": "workspace:*", @@ -243,7 +243,7 @@ }, "packages/msigs": { "name": "@wharfkit/msigs", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", }, @@ -253,7 +253,7 @@ }, "packages/protocol-esr": { "name": "@wharfkit/protocol-esr", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@greymass/buoy": "catalog:", "@wharfkit/sealed-messages": "workspace:*", @@ -272,7 +272,7 @@ }, "packages/protocol-scatter": { "name": "@wharfkit/protocol-scatter", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", "@wharfkit/session": "workspace:*", @@ -287,7 +287,7 @@ }, "packages/resources": { "name": "@wharfkit/resources", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", "bn.js": "catalog:", @@ -299,7 +299,7 @@ }, "packages/roborovski": { "name": "@wharfkit/roborovski", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", }, @@ -309,7 +309,7 @@ }, "packages/sealed-messages": { "name": "@wharfkit/sealed-messages", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@greymass/miniaes": "^1.0.0", "@wharfkit/antelope": "workspace:*", @@ -320,7 +320,7 @@ }, "packages/session": { "name": "@wharfkit/session", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/abicache": "workspace:*", "@wharfkit/antelope": "workspace:*", @@ -337,14 +337,14 @@ }, "packages/signing-request": { "name": "@wharfkit/signing-request", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", }, }, "packages/svelte-components": { "name": "@wharfkit/svelte-components", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@lucide/svelte": "^0.516.0", "@melt-ui/svelte": "^0.86.6", @@ -391,7 +391,7 @@ }, "packages/token": { "name": "@wharfkit/token", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", "@wharfkit/contract": "workspace:*", @@ -402,7 +402,7 @@ }, "packages/transact-plugin-autocorrect": { "name": "@wharfkit/transact-plugin-autocorrect", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/resources": "workspace:*", "@wharfkit/session": "workspace:*", @@ -415,7 +415,7 @@ }, "packages/transact-plugin-cosigner": { "name": "@wharfkit/transact-plugin-cosigner", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -427,7 +427,7 @@ }, "packages/transact-plugin-explorerlink": { "name": "@wharfkit/transact-plugin-explorerlink", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -439,7 +439,7 @@ }, "packages/transact-plugin-finality-callback": { "name": "@wharfkit/transact-plugin-finality-callback", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -450,7 +450,7 @@ }, "packages/transact-plugin-finality-checker": { "name": "@wharfkit/transact-plugin-finality-checker", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -462,7 +462,7 @@ }, "packages/transact-plugin-mock": { "name": "@wharfkit/transact-plugin-mock", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -474,7 +474,7 @@ }, "packages/transact-plugin-msig-propose": { "name": "@wharfkit/transact-plugin-msig-propose", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -486,7 +486,7 @@ }, "packages/transact-plugin-resource-provider": { "name": "@wharfkit/transact-plugin-resource-provider", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/resources": "workspace:*", "@wharfkit/session": "workspace:*", @@ -501,7 +501,7 @@ }, "packages/wallet-plugin-anchor": { "name": "@wharfkit/wallet-plugin-anchor", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@greymass/buoy": "catalog:", "@wharfkit/antelope": "workspace:*", @@ -522,7 +522,7 @@ }, "packages/wallet-plugin-cleos": { "name": "@wharfkit/wallet-plugin-cleos", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -533,7 +533,7 @@ }, "packages/wallet-plugin-cloudwallet": { "name": "@wharfkit/wallet-plugin-cloudwallet", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -544,7 +544,7 @@ }, "packages/wallet-plugin-gatewallet": { "name": "@wharfkit/wallet-plugin-gatewallet", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/protocol-scatter": "workspace:*", "@wharfkit/session": "workspace:*", @@ -557,7 +557,7 @@ }, "packages/wallet-plugin-imtoken": { "name": "@wharfkit/wallet-plugin-imtoken", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/protocol-scatter": "workspace:*", "@wharfkit/session": "workspace:*", @@ -570,7 +570,7 @@ }, "packages/wallet-plugin-metamask": { "name": "@wharfkit/wallet-plugin-metamask", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@metamask/providers": "^17.0.0", "@wharfkit/session": "workspace:*", @@ -582,7 +582,7 @@ }, "packages/wallet-plugin-mimic": { "name": "@wharfkit/wallet-plugin-mimic", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -593,7 +593,7 @@ }, "packages/wallet-plugin-mock": { "name": "@wharfkit/wallet-plugin-mock", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -605,7 +605,7 @@ }, "packages/wallet-plugin-paycash": { "name": "@wharfkit/wallet-plugin-paycash", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/protocol-esr": "workspace:*", "@wharfkit/session": "workspace:*", @@ -617,7 +617,7 @@ }, "packages/wallet-plugin-privatekey": { "name": "@wharfkit/wallet-plugin-privatekey", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -629,7 +629,7 @@ }, "packages/wallet-plugin-scatter": { "name": "@wharfkit/wallet-plugin-scatter", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/protocol-scatter": "workspace:*", "@wharfkit/session": "workspace:*", @@ -641,7 +641,7 @@ }, "packages/wallet-plugin-tacklebox": { "name": "@wharfkit/wallet-plugin-tacklebox", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@greymass/buoy": "catalog:", "@wharfkit/protocol-esr": "workspace:*", @@ -656,7 +656,7 @@ }, "packages/wallet-plugin-tokenpocket": { "name": "@wharfkit/wallet-plugin-tokenpocket", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/protocol-scatter": "workspace:*", "@wharfkit/session": "workspace:*", @@ -668,7 +668,7 @@ }, "packages/wallet-plugin-web-authenticator": { "name": "@wharfkit/wallet-plugin-web-authenticator", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@greymass/buoy": "catalog:", "@wharfkit/antelope": "workspace:*", @@ -687,7 +687,7 @@ }, "packages/web-renderer": { "name": "@wharfkit/web-renderer", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/session": "workspace:*", }, @@ -738,7 +738,7 @@ }, "packages/web-ui": { "name": "@wharfkit/web-ui", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/common": "workspace:*", "@wharfkit/session": "workspace:*", @@ -770,7 +770,7 @@ }, "packages/webauthn": { "name": "@wharfkit/webauthn", - "version": "4.0.1", + "version": "4.0.2", "dependencies": { "@wharfkit/antelope": "workspace:*", "cborg": "^4.5.8", diff --git a/package.json b/package.json index ed40c7f5..5eb31cff 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "wharfkit-js", "private": true, - "version": "4.0.1", + "version": "4.0.2", "workspaces": { "packages": [ "packages/*" diff --git a/packages/abicache/package.json b/packages/abicache/package.json index a7dcab34..ec0781f4 100644 --- a/packages/abicache/package.json +++ b/packages/abicache/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/abicache", "description": "ABI Caching Mechanism for use in Session and Contract Kits", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/account-creation-plugin-anchor/package.json b/packages/account-creation-plugin-anchor/package.json index 9bd353e0..c2781ab7 100644 --- a/packages/account-creation-plugin-anchor/package.json +++ b/packages/account-creation-plugin-anchor/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/account-creation-plugin-anchor", "description": "An account creation plugin using the Greymass account creation service", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/account-creation-plugin-anchor", "license": "BSD-3-Clause", "engines": { diff --git a/packages/account-creation-plugin-jungle4/package.json b/packages/account-creation-plugin-jungle4/package.json index 78834099..30b37410 100644 --- a/packages/account-creation-plugin-jungle4/package.json +++ b/packages/account-creation-plugin-jungle4/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/account-creation-plugin-jungle4", "description": "Plugin to create a Jungle4 Testnet acccount.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/account-creation-plugin-jungle4", "license": "BSD-3-Clause", "engines": { diff --git a/packages/account-creation-plugin-metamask/package.json b/packages/account-creation-plugin-metamask/package.json index 1eaae9ce..700715a4 100644 --- a/packages/account-creation-plugin-metamask/package.json +++ b/packages/account-creation-plugin-metamask/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/account-creation-plugin-metamask", "description": "A MetaMask plugin to create EOS accounts using Metamask public keys.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/account-creation-plugin-metamask", "license": "BSD-3-Clause", "engines": { diff --git a/packages/account/package.json b/packages/account/package.json index 12df116e..5a07ee99 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/account", "description": "Account kit for Wharf Kit", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/docs/account-kit", "license": "BSD-3-Clause", "engines": { diff --git a/packages/actionstream/package.json b/packages/actionstream/package.json index d43cfeaa..5a015d9d 100644 --- a/packages/actionstream/package.json +++ b/packages/actionstream/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/actionstream", "description": "Client library for subscribing to Roborovski action streams", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/antelope/package.json b/packages/antelope/package.json index 2044e163..6f303c10 100644 --- a/packages/antelope/package.json +++ b/packages/antelope/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/antelope", "description": "Library for working with Antelope powered blockchains.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/docs/antelope", "license": "BSD-3-Clause", "engines": { diff --git a/packages/atomicassets/package.json b/packages/atomicassets/package.json index 05878b98..7a919a15 100644 --- a/packages/atomicassets/package.json +++ b/packages/atomicassets/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/atomicassets", "description": "AtomicAsset library for Wharf", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/bundle/README.md b/packages/bundle/README.md index 432aec5f..303008bb 100644 --- a/packages/bundle/README.md +++ b/packages/bundle/README.md @@ -5,7 +5,7 @@ A prepackaged bundle of common Wharf libraries, built as a self-contained IIFE ( ## Usage ```html - + ``` @@ -30,7 +30,7 @@ Both URLs above name an exact version and the full file path. jsDelivr serves th Use `https://cdn.jsdelivr.net/npm/@wharfkit/bundle@4/dist/wharf.bundle.js` if you want patch releases without editing the page. The trade is that the bytes are no longer the package's own and no longer eligible for Subresource Integrity. -To add an `integrity` attribute, take the hash for the exact version from `https://data.jsdelivr.com/v1/packages/npm/@wharfkit/bundle@4.0.1?structure=flat`, and pair it with `crossorigin="anonymous"`, which SRI requires. An `integrity` attribute on a ` ``` -Mixing versions across imports, or adding a package still on the `1.x` line, splits it again. esm.sh takes an explicit pin against that: `?deps=@wharfkit/antelope@4.0.1` on each top-level URL rewrites the antelope import to one concrete build and propagates into every transitive `@wharfkit/*` request, so it costs one query parameter per import rather than one entry per transitive package. jsDelivr's `+esm` route has no query-parameter equivalent, and its output carries jsDelivr's own warning against pairing it with Subresource Integrity. +Mixing versions across imports, or adding a package still on the `1.x` line, splits it again. esm.sh takes an explicit pin against that: `?deps=@wharfkit/antelope@4.0.2` on each top-level URL rewrites the antelope import to one concrete build and propagates into every transitive `@wharfkit/*` request, so it costs one query parameter per import rather than one entry per transitive package. jsDelivr's `+esm` route has no query-parameter equivalent, and its output carries jsDelivr's own warning against pairing it with Subresource Integrity. The bundle stays the recommended browser artifact. It is the only one that guarantees a single antelope without a resolver. ## Examples -`public/bundle.html` and `public/esm.html` are runnable examples of both forms, loading the built files next to them. `make` copies them into `dist/`, so open them from there after a build. The same pages ship in the package, at `https://cdn.jsdelivr.net/npm/@wharfkit/bundle@4.0.1/dist/bundle.html` and `.../dist/esm.html`. +`public/bundle.html` and `public/esm.html` are runnable examples of both forms, loading the built files next to them. `make` copies them into `dist/`, so open them from there after a build. The same pages ship in the package, at `https://cdn.jsdelivr.net/npm/@wharfkit/bundle@4.0.2/dist/bundle.html` and `.../dist/esm.html`. ## Types diff --git a/packages/bundle/package.json b/packages/bundle/package.json index 894ad132..148c3e95 100644 --- a/packages/bundle/package.json +++ b/packages/bundle/package.json @@ -1,6 +1,6 @@ { "name": "@wharfkit/bundle", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "description": "A prepackaged bundle of common Wharf libraries re-exported for IIFE or ESM", "license": "BSD-3-Clause", diff --git a/packages/cli/package.json b/packages/cli/package.json index 149ecf13..1c1e30f1 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@wharfkit/cli", - "version": "4.0.1", + "version": "4.0.2", "license": "BSD-3-Clause", "homepage": "https://wharfkit.com/docs/utilities/cli", "description": "Command line utilities for Wharf", diff --git a/packages/common/assets/chain/xprnetwork.png b/packages/common/assets/chain/xprnetwork.png new file mode 100644 index 00000000..14e89dfb Binary files /dev/null and b/packages/common/assets/chain/xprnetwork.png differ diff --git a/packages/common/package.json b/packages/common/package.json index 9fd8e8ea..e077e428 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/common", "description": "Common data and functions shared across WharfKit packages", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/docs/utilities/common-library", "license": "BSD-3-Clause", "engines": { diff --git a/packages/conformance/package.json b/packages/conformance/package.json index a8917e35..51a30cfd 100644 --- a/packages/conformance/package.json +++ b/packages/conformance/package.json @@ -1,6 +1,6 @@ { "name": "@wharfkit/conformance", - "version": "4.0.1", + "version": "4.0.2", "type": "module", "license": "BSD-3-Clause", "engines": { diff --git a/packages/contract/package.json b/packages/contract/package.json index f9b05567..323825d6 100644 --- a/packages/contract/package.json +++ b/packages/contract/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/contract", "description": "ContractKit for Wharf", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/docs/contract-kit", "license": "BSD-3-Clause", "engines": { diff --git a/packages/hyperion/package.json b/packages/hyperion/package.json index 00d3e02d..29cf8423 100644 --- a/packages/hyperion/package.json +++ b/packages/hyperion/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/hyperion", "description": "API Client to access Hyperion API endpoints", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/light-api/package.json b/packages/light-api/package.json index 99792eb8..b5d32b7d 100644 --- a/packages/light-api/package.json +++ b/packages/light-api/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/light-api", "description": "API Client to access Light API endpoints", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/mock-data/package.json b/packages/mock-data/package.json index 312bfdb1..d0bf99ea 100644 --- a/packages/mock-data/package.json +++ b/packages/mock-data/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/mock-data", "description": "Sample data for usage in tests throughout @wharfkit", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/msigs/package.json b/packages/msigs/package.json index fec46193..23797cdf 100644 --- a/packages/msigs/package.json +++ b/packages/msigs/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/msigs", "description": "API Client to access Roborovski msigs API endpoints", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/protocol-esr/package.json b/packages/protocol-esr/package.json index 3ddb52b0..4ea11072 100644 --- a/packages/protocol-esr/package.json +++ b/packages/protocol-esr/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/protocol-esr", "description": "Abstract methods useful to all ESR-based wallet plugins", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/protocol-scatter/package.json b/packages/protocol-scatter/package.json index 2d0b1007..9a659935 100644 --- a/packages/protocol-scatter/package.json +++ b/packages/protocol-scatter/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/protocol-scatter", "description": "Abstract methods useful to all Scatter-based wallet plugins", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/resources/package.json b/packages/resources/package.json index 79315c7f..02cd99de 100644 --- a/packages/resources/package.json +++ b/packages/resources/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/resources", "description": "Library to assist in Antelope-blockchain resource calculations.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/roborovski/package.json b/packages/roborovski/package.json index a3aeb583..e0e01d14 100644 --- a/packages/roborovski/package.json +++ b/packages/roborovski/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/roborovski", "description": "API Client to access Roborovski API endpoints", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/sealed-messages/package.json b/packages/sealed-messages/package.json index 1576871e..d16f9bab 100644 --- a/packages/sealed-messages/package.json +++ b/packages/sealed-messages/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/sealed-messages", "description": "", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/session/package.json b/packages/session/package.json index b6849884..cf5436af 100644 --- a/packages/session/package.json +++ b/packages/session/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/session", "description": "Create account-based sessions, perform transactions, and allow users to login using Antelope-based blockchains.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/docs/session-kit", "license": "BSD-3-Clause", "engines": { diff --git a/packages/session/src/wallet.ts b/packages/session/src/wallet.ts index 217c1796..10a6330a 100644 --- a/packages/session/src/wallet.ts +++ b/packages/session/src/wallet.ts @@ -188,6 +188,7 @@ export abstract class AbstractWalletPlugin implements WalletPlugin { data: this.data, } } + /** Shallow copy with fresh data and metadata; every other field must be safe to share. */ clone(): WalletPlugin { const cloned = Object.create(Object.getPrototypeOf(this)) Object.assign(cloned, this) diff --git a/packages/signing-request/package.json b/packages/signing-request/package.json index 4be7bfa2..666b0028 100644 --- a/packages/signing-request/package.json +++ b/packages/signing-request/package.json @@ -1,6 +1,6 @@ { "name": "@wharfkit/signing-request", - "version": "4.0.1", + "version": "4.0.2", "description": "Signing Request (ESR / EEP-7) encoder and decoder for Antelope blockchains", "homepage": "https://wharfkit.com/docs/utilities/signing-request-library", "license": "BSD-3-Clause", diff --git a/packages/svelte-components/package.json b/packages/svelte-components/package.json index d1b28703..22f821eb 100644 --- a/packages/svelte-components/package.json +++ b/packages/svelte-components/package.json @@ -1,6 +1,6 @@ { "name": "@wharfkit/svelte-components", - "version": "4.0.1", + "version": "4.0.2", "description": "Svelte 5 and Tailwind v4 component library for Antelope applications", "license": "BSD-3-Clause", "repository": { diff --git a/packages/token/package.json b/packages/token/package.json index a935e90d..1e229e56 100644 --- a/packages/token/package.json +++ b/packages/token/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/token", "description": "Library to work with Antelope-blockchain system tokens.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": { diff --git a/packages/transact-plugin-autocorrect/package.json b/packages/transact-plugin-autocorrect/package.json index 59e54ffb..be19a157 100644 --- a/packages/transact-plugin-autocorrect/package.json +++ b/packages/transact-plugin-autocorrect/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/transact-plugin-autocorrect", "description": "A plugin to correct common issues users experience while performing transactions.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/transact-plugin-autocorrect", "license": "BSD-3-Clause", "engines": { diff --git a/packages/transact-plugin-cosigner/package.json b/packages/transact-plugin-cosigner/package.json index 345e2611..11c2a9fd 100644 --- a/packages/transact-plugin-cosigner/package.json +++ b/packages/transact-plugin-cosigner/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/transact-plugin-cosigner", "description": "Automatically cosign transactions to assume resource costs using a noop action.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/transact-plugin-cosigner", "license": "BSD-3-Clause", "engines": { diff --git a/packages/transact-plugin-explorerlink/package.json b/packages/transact-plugin-explorerlink/package.json index 074f18ab..5a035973 100644 --- a/packages/transact-plugin-explorerlink/package.json +++ b/packages/transact-plugin-explorerlink/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/transact-plugin-explorerlink", "description": "A transact plugin to display a link to a block explorer after a transaction is broadcast.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/transact-plugin-explorerlink", "license": "BSD-3-Clause", "engines": { diff --git a/packages/transact-plugin-finality-callback/package.json b/packages/transact-plugin-finality-callback/package.json index 086f6f97..a7202f91 100644 --- a/packages/transact-plugin-finality-callback/package.json +++ b/packages/transact-plugin-finality-callback/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/transact-plugin-finality-callback", "description": "A template to create plugins for use with @wharfkit/session transact method.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/transact-plugin-finality-callback", "license": "BSD-3-Clause", "engines": { diff --git a/packages/transact-plugin-finality-checker/package.json b/packages/transact-plugin-finality-checker/package.json index 6242a9eb..4b2abbc7 100644 --- a/packages/transact-plugin-finality-checker/package.json +++ b/packages/transact-plugin-finality-checker/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/transact-plugin-finality-checker", "description": "A template to create plugins for use with @wharfkit/session transact method.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/transact-plugin-finality-checker", "license": "BSD-3-Clause", "engines": { diff --git a/packages/transact-plugin-mock/package.json b/packages/transact-plugin-mock/package.json index f6dfac63..887726f8 100644 --- a/packages/transact-plugin-mock/package.json +++ b/packages/transact-plugin-mock/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/transact-plugin-mock", "description": "A mock TransactPlugin to simulate specific events.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/transact-plugin-mock", "license": "BSD-3-Clause", "engines": { diff --git a/packages/transact-plugin-msig-propose/package.json b/packages/transact-plugin-msig-propose/package.json index f4492c7f..6c78c81f 100644 --- a/packages/transact-plugin-msig-propose/package.json +++ b/packages/transact-plugin-msig-propose/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/transact-plugin-msig-propose", "description": "A template to create plugins for use with @wharfkit/session transact method.", - "version": "4.0.1", + "version": "4.0.2", "private": true, "license": "BSD-3-Clause", "engines": { diff --git a/packages/transact-plugin-resource-provider/package.json b/packages/transact-plugin-resource-provider/package.json index 18bab4eb..b11f2f4b 100644 --- a/packages/transact-plugin-resource-provider/package.json +++ b/packages/transact-plugin-resource-provider/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/transact-plugin-resource-provider", "description": "Plugin to automatically provide network resources for transactions using the Resource Provider implementation standard.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/transact-plugin-resource-provider", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-anchor/package.json b/packages/wallet-plugin-anchor/package.json index b0285fbd..286d3f44 100644 --- a/packages/wallet-plugin-anchor/package.json +++ b/packages/wallet-plugin-anchor/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-anchor", "description": "An Anchor plugin for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-anchor", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-anchor/src/index.ts b/packages/wallet-plugin-anchor/src/index.ts index 1e1398ce..29da1f19 100644 --- a/packages/wallet-plugin-anchor/src/index.ts +++ b/packages/wallet-plugin-anchor/src/index.ts @@ -88,13 +88,8 @@ export class WalletPluginAnchor extends AbstractWalletPlugin { this.webAuthenticatorUrls = options?.webAuthenticatorUrls || {} this.webFallbackDelayMs = options?.webFallbackDelayMs ?? DEFAULT_WEB_FALLBACK_DELAY_MS - // SessionKit.restore() reassigns `this.data`, so transports must read it live. - const currentData = () => this.data const transportOptions: TransportOptions = { id: this.id, - get data() { - return currentData() - }, buoyUrl: this.buoyUrl, buoyWs: this.buoyWs, ...options?.transport, @@ -187,7 +182,7 @@ export class WalletPluginAnchor extends AbstractWalletPlugin { // Native-only chain: the question has no second answer, so never ask it. if (!webUrl) { preopened?.close() - return await this.native.login(context, bundle, t) + return await this.native.login(this.data, context, bundle, t) } const forcedMode = perCall.mode ?? this.loginModeOverride @@ -208,7 +203,7 @@ export class WalletPluginAnchor extends AbstractWalletPlugin { writeMode(this.data, mode) if (mode === 'web') { - return await this.web.login(context, bundle, webUrl, popup) + return await this.web.login(this.data, context, bundle, webUrl, popup) } // Freshly chosen: no immediate switch link, but still recover from a silent deep link. return await this.loginWithSwitch(context, bundle, t, webUrl, 'app', false) @@ -236,8 +231,8 @@ export class WalletPluginAnchor extends AbstractWalletPlugin { try { return mode === 'web' && webUrl - ? await this.web.login(context, bundle, webUrl, popup) - : await this.native.login(context, bundle, t) + ? await this.web.login(this.data, context, bundle, webUrl, popup) + : await this.native.login(this.data, context, bundle, t) } catch (error) { if (!(error instanceof AnchorRequestCancelledError)) { throw error @@ -286,12 +281,14 @@ export class WalletPluginAnchor extends AbstractWalletPlugin { const primary = mode === 'app' - ? this.native.login(context, bundle, t, { + ? this.native.login(this.data, context, bundle, t, { immediate, delayMs: this.webFallbackDelayMs, onSelect: () => switchTo(), }) - : this.web.login(context, bundle, webUrl, preopened, {onSelect: () => switchTo()}) + : this.web.login(this.data, context, bundle, webUrl, preopened, { + onSelect: () => switchTo(), + }) // The loser of the race is abandoned; swallow its eventual rejection. primary.catch(() => undefined) @@ -304,8 +301,8 @@ export class WalletPluginAnchor extends AbstractWalletPlugin { const next: AnchorMode = mode === 'app' ? 'web' : 'app' writeMode(this.data, next) return next === 'web' - ? this.web.login(context, alternateBundle, webUrl, popup) - : this.native.login(context, alternateBundle, t) + ? this.web.login(this.data, context, alternateBundle, webUrl, popup) + : this.native.login(this.data, context, alternateBundle, t) } /** The browser popup opens inside the click handler, before this promise resolves. */ @@ -375,10 +372,10 @@ export class WalletPluginAnchor extends AbstractWalletPlugin { `This session signs in the browser, but there is no Anchor web authenticator for chain ${context.chain?.id}.` ) } - return this.web.sign(resolved, context, webUrl) + return this.web.sign(this.data, resolved, context, webUrl) } - return this.native.sign(resolved, context) + return this.native.sign(this.data, resolved, context) } } diff --git a/packages/wallet-plugin-anchor/src/transports/native.ts b/packages/wallet-plugin-anchor/src/transports/native.ts index 899c342f..bd37dedd 100644 --- a/packages/wallet-plugin-anchor/src/transports/native.ts +++ b/packages/wallet-plugin-anchor/src/transports/native.ts @@ -12,6 +12,7 @@ import { ResolvedSigningRequest, Serializer, TransactContext, + WalletPluginData, WalletPluginLoginResponse, WalletPluginSignResponse, } from '@wharfkit/session' @@ -42,6 +43,7 @@ export class NativeTransport { constructor(private options: TransportOptions) {} async login( + data: WalletPluginData, context: LoginContext, bundle: IdentityRequestBundle, t: Translator, @@ -139,18 +141,18 @@ export class NativeTransport { callbackResponse.link_key && callbackResponse.link_name ) { - this.options.data.requestKey = requestKey - this.options.data.privateKey = privateKey - this.options.data.signerKey = PublicKey.from(callbackResponse.link_key) - this.options.data.channelUrl = callbackResponse.link_ch - this.options.data.channelName = callbackResponse.link_name + data.requestKey = requestKey + data.privateKey = privateKey + data.signerKey = PublicKey.from(callbackResponse.link_key) + data.channelUrl = callbackResponse.link_ch + data.channelName = callbackResponse.link_name try { if (callbackResponse.link_meta) { const metadata = JSON.parse(callbackResponse.link_meta) - this.options.data.sameDevice = metadata.sameDevice - this.options.data.launchUrl = metadata.launchUrl - this.options.data.triggerUrl = metadata.triggerUrl + data.sameDevice = metadata.sameDevice + data.launchUrl = metadata.launchUrl + data.triggerUrl = metadata.triggerUrl } } catch { // link_meta is advisory; a malformed value must not fail the login @@ -183,6 +185,7 @@ export class NativeTransport { } async sign( + data: WalletPluginData, resolved: ResolvedSigningRequest, context: TransactContext ): Promise { @@ -190,7 +193,6 @@ export class NativeTransport { throw new Error('No UI available') } - const data = this.options.data const t = context.ui.getTranslate(this.options.id) const expiration = resolved.transaction.expiration.toDate() diff --git a/packages/wallet-plugin-anchor/src/transports/types.ts b/packages/wallet-plugin-anchor/src/transports/types.ts index be0f2982..0adcfd49 100644 --- a/packages/wallet-plugin-anchor/src/transports/types.ts +++ b/packages/wallet-plugin-anchor/src/transports/types.ts @@ -20,8 +20,6 @@ export interface IdentityRequestBundle { /** Everything a transport needs from the plugin that owns it. */ export interface TransportOptions { id: string - /** The plugin's persisted storage — shared by reference across transports. */ - data: Record buoyUrl: string buoyWs?: WebSocket // Overridable so tests can substitute them; ESM namespaces cannot be stubbed in place. diff --git a/packages/wallet-plugin-anchor/src/transports/web.ts b/packages/wallet-plugin-anchor/src/transports/web.ts index 3e531732..512fa0fb 100644 --- a/packages/wallet-plugin-anchor/src/transports/web.ts +++ b/packages/wallet-plugin-anchor/src/transports/web.ts @@ -8,6 +8,7 @@ import { ResolvedSigningRequest, TransactContext, UserInterface, + WalletPluginData, WalletPluginLoginResponse, WalletPluginSignResponse, } from '@wharfkit/session' @@ -65,6 +66,7 @@ export class WebTransport { } async login( + data: WalletPluginData, context: LoginContext, bundle: IdentityRequestBundle, baseUrl: string, @@ -82,8 +84,8 @@ export class WebTransport { switchOffer ) - this.options.data.encryptionKey = String(bundle.privateKey) - this.options.data.messageKey = payload.link_key + data.encryptionKey = String(bundle.privateKey) + data.messageKey = payload.link_key if (!payload.cid) { throw new Error('Login failed: No chain ID returned') @@ -110,11 +112,11 @@ export class WebTransport { } async sign( + data: WalletPluginData, resolved: ResolvedSigningRequest, context: TransactContext, baseUrl: string ): Promise { - const data = this.options.data if (!data.encryptionKey || !data.messageKey) { throw new Error('No request keys available - please login first') } diff --git a/packages/wallet-plugin-anchor/test/tests/handoff.ts b/packages/wallet-plugin-anchor/test/tests/handoff.ts index 3abb41ad..2e4e1aa3 100644 --- a/packages/wallet-plugin-anchor/test/tests/handoff.ts +++ b/packages/wallet-plugin-anchor/test/tests/handoff.ts @@ -35,10 +35,9 @@ function makeSameDeviceData() { } } -function makeTransport(data: Record, overrides: Record = {}) { +function makeTransport(overrides: Record = {}) { return new NativeTransport({ id: 'anchor', - data, buoyUrl: 'https://cb.anchor.link', ...overrides, }) @@ -112,8 +111,10 @@ suite('native signing handoff', function () { resolveSend = () => resolve(undefined as any) }) ) - const transport = makeTransport(makeSameDeviceData(), {send: sendStub}) - transport.sign(makeResolved(), makeTransactContext(makeMockUI())).catch(() => undefined) + const transport = makeTransport({send: sendStub}) + transport + .sign(makeSameDeviceData(), makeResolved(), makeTransactContext(makeMockUI())) + .catch(() => undefined) await settle() assert.equal(sendStub.callCount, 1, 'the sealed request was sent') @@ -134,13 +135,13 @@ suite('native signing handoff', function () { }) ) - const transport = makeTransport(makeSameDeviceData(), { + const transport = makeTransport({ send: sendStub, generateReturnUrl: returnUrlStub, waitForCallback: callbackStub, }) const signing = transport - .sign(makeResolved(), makeTransactContext(makeMockUI())) + .sign(makeSameDeviceData(), makeResolved(), makeTransactContext(makeMockUI())) .catch(() => undefined) await settle() @@ -170,12 +171,14 @@ suite('native signing handoff', function () { const returnUrlStub = sinon.stub().returns('googlechrome://') const callbackStub = sinon.stub().returns(new Promise(() => {})) - const transport = makeTransport(makeSameDeviceData(), { + const transport = makeTransport({ send: sendStub, generateReturnUrl: returnUrlStub, waitForCallback: callbackStub, }) - transport.sign(makeResolved(), makeTransactContext(makeMockUI())).catch(() => undefined) + transport + .sign(makeSameDeviceData(), makeResolved(), makeTransactContext(makeMockUI())) + .catch(() => undefined) await settle() assert.equal(callbackStub.callCount, 1, 'connects right away') @@ -187,11 +190,15 @@ suite('native signing handoff', function () { const returnUrlStub = sinon.stub().returns(RETURN_URL) const callbackStub = sinon.stub().returns(new Promise(() => {})) - const transport = makeTransport( - {...makeSameDeviceData(), sameDevice: false}, - {send: sendStub, generateReturnUrl: returnUrlStub, waitForCallback: callbackStub} - ) - transport.sign(makeResolved(), makeTransactContext(makeMockUI())).catch(() => undefined) + const data = {...makeSameDeviceData(), sameDevice: false} + const transport = makeTransport({ + send: sendStub, + generateReturnUrl: returnUrlStub, + waitForCallback: callbackStub, + }) + transport + .sign(data, makeResolved(), makeTransactContext(makeMockUI())) + .catch(() => undefined) await settle() assert.equal(callbackStub.callCount, 1, 'connects right away') @@ -214,11 +221,13 @@ suite('native signing handoff', function () { return pending }) as typeof ui.prompt - const transport = makeTransport(makeSameDeviceData(), {send: sendStub}) + const transport = makeTransport({send: sendStub}) let message = '' - await transport.sign(makeResolved(), makeTransactContext(ui)).catch((error) => { - message = error.message - }) + await transport + .sign(makeSameDeviceData(), makeResolved(), makeTransactContext(ui)) + .catch((error) => { + message = error.message + }) assert.equal(message, 'buoy unavailable', 'the delivery error surfaces') assert.equal(cancelCount, 1, 'the prompt was cancelled') diff --git a/packages/wallet-plugin-anchor/test/tests/native.ts b/packages/wallet-plugin-anchor/test/tests/native.ts index 1e9cec50..2cd5fc45 100644 --- a/packages/wallet-plugin-anchor/test/tests/native.ts +++ b/packages/wallet-plugin-anchor/test/tests/native.ts @@ -43,12 +43,11 @@ suite('native transport', function () { const ui = makeMockUI() const transport = new NativeTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) // Never resolves in this test — we only assert on what was rendered. transport - .login(makeLoginContext(ui), makeBundle(), ui.getTranslate()) + .login({}, makeLoginContext(ui), makeBundle(), ui.getTranslate()) .catch(() => undefined) const args = ui.lastPrompt() @@ -62,11 +61,10 @@ suite('native transport', function () { const ui = makeMockUI() const transport = new NativeTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) transport - .login(makeLoginContext(ui), makeBundle(), ui.getTranslate()) + .login({}, makeLoginContext(ui), makeBundle(), ui.getTranslate()) .catch(() => undefined) assert.equal(window.location.href, 'esr://same-device') }) @@ -76,11 +74,10 @@ suite('native transport', function () { let selected = false const transport = new NativeTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) transport - .login(makeLoginContext(ui), makeBundle(), ui.getTranslate(), { + .login({}, makeLoginContext(ui), makeBundle(), ui.getTranslate(), { delayMs: 10, onSelect: () => (selected = true), }) @@ -102,11 +99,10 @@ suite('native transport', function () { const ui = makeMockUI() const transport = new NativeTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) transport - .login(makeLoginContext(ui), makeBundle(), ui.getTranslate()) + .login({}, makeLoginContext(ui), makeBundle(), ui.getTranslate()) .catch(() => undefined) await new Promise((resolve) => setTimeout(resolve, 30)) assert.equal(ui.prompts.length, 1) diff --git a/packages/wallet-plugin-anchor/test/tests/router.ts b/packages/wallet-plugin-anchor/test/tests/router.ts index 37f2c62e..4cf74753 100644 --- a/packages/wallet-plugin-anchor/test/tests/router.ts +++ b/packages/wallet-plugin-anchor/test/tests/router.ts @@ -1,5 +1,5 @@ import {assert} from 'chai' -import {ChainDefinition, LoginContext} from '@wharfkit/session' +import {ChainDefinition, LoginContext, SessionKit} from '@wharfkit/session' import {ResolvedSigningRequest} from '@wharfkit/signing-request' import {APIClient, PermissionLevel, PrivateKey} from '@wharfkit/antelope' import * as buoy from '@greymass/buoy' @@ -79,6 +79,16 @@ function makeTransactContext(ui: any, chain: ChainDefinition) { const sessionKey = PrivateKey.generate('K1') const walletKey = PrivateKey.generate('K1') +/** The harness has no browser storage, so the kit persists into a map. */ +function memoryStorage() { + const store = new Map() + return { + write: async (key: string, value: string) => void store.set(key, value), + read: async (key: string) => store.get(key) ?? null, + remove: async (key: string) => void store.delete(key), + } +} + /** Let the router's `await createIdentityRequest(...)` settle before asserting. */ function settle() { return new Promise((resolve) => setTimeout(resolve, 200)) @@ -888,3 +898,94 @@ suite('caller-opened popup', function () { assert.isTrue((popup as any).closed) }) }) + +suite('restored session', function () { + this.timeout(10 * 1000) + + test('a restored web session signs with the keys assigned to the clone', async function () { + ;(window.open as any).calls.length = 0 + const ui = makeMockUI() + const registered = new WalletPluginAnchor() + const restored = registered.clone() as WalletPluginAnchor + restored.data = { + mode: 'web', + encryptionKey: String(sessionKey), + messageKey: String(walletKey.toPublic()), + } + + const resolved = await makeMockResolvedSigningRequest() + restored.sign(resolved, makeTransactContext(ui, jungle4)).catch(() => undefined) + await settle() + + assert.equal((window.open as any).calls.length, 1, 'popup opened from the clone keys') + assert.include( + (window.open as any).calls[0], + 'https://jungle4.anchorwallet.io/sign?sealed=' + ) + }) + + test('a restored native session signs over the channel assigned to the clone', async function () { + const ui = makeMockUI() + const sendStub = sinon.stub().resolves(undefined as any) + const callbackStub = sinon.stub().returns(new Promise(() => undefined)) + const registered = new WalletPluginAnchor({ + transport: {send: sendStub, waitForCallback: callbackStub}, + }) + const restored = registered.clone() as WalletPluginAnchor + restored.data = { + channelUrl: 'https://cb.anchor.link/laptop-channel', + channelName: 'laptop', + privateKey: String(sessionKey), + signerKey: String(walletKey.toPublic()), + } + + const resolved = await makeMockResolvedSigningRequest() + restored.sign(resolved, makeTransactContext(ui, jungle4)).catch(() => undefined) + await settle() + + assert.equal(sendStub.callCount, 1, 'the sealed request was sent from the clone channel') + assert.equal(sendStub.firstCall.args[1].channel, 'laptop-channel') + }) +}) + +suite('restored session through the kit', function () { + this.timeout(10 * 1000) + + test('a session the kit restores signs with its stored keys', async function () { + ;(window.open as any).calls.length = 0 + const ui = makeMockUI() + const registered = new WalletPluginAnchor() + const kit = new SessionKit( + {appName: 'unittest', chains: [jungle4], ui, walletPlugins: [registered]}, + {storage: memoryStorage()} + ) + const session = await kit.restore({ + chain: jungle4.id, + actor: 'wharfkit1131', + permission: 'test', + walletPlugin: { + id: 'anchor', + data: { + mode: 'web', + encryptionKey: String(sessionKey), + messageKey: String(walletKey.toPublic()), + }, + }, + }) + assert.isDefined(session) + assert.notStrictEqual(session!.walletPlugin, registered, 'the kit hands back a clone') + assert.deepEqual(registered.data, {}, 'the registered instance is untouched') + + const resolved = await makeMockResolvedSigningRequest() + session!.walletPlugin + .sign(resolved, makeTransactContext(ui, jungle4)) + .catch(() => undefined) + await settle() + + assert.equal((window.open as any).calls.length, 1, 'popup opened from the restored keys') + assert.include( + (window.open as any).calls[0], + 'https://jungle4.anchorwallet.io/sign?sealed=' + ) + }) +}) diff --git a/packages/wallet-plugin-anchor/test/tests/web.ts b/packages/wallet-plugin-anchor/test/tests/web.ts index a29b6fef..37f40a9b 100644 --- a/packages/wallet-plugin-anchor/test/tests/web.ts +++ b/packages/wallet-plugin-anchor/test/tests/web.ts @@ -48,7 +48,6 @@ suite('web transport', function () { const ui = makeMockUI() const transport = new WebTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) const url = transport.loginUrl( @@ -66,7 +65,6 @@ suite('web transport', function () { ;(window.open as any).calls.length = 0 const transport = new WebTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) const popup = transport.openWindow('https://jungle4.anchorwallet.io/sign?esr=x') @@ -79,14 +77,19 @@ suite('web transport', function () { const ui = makeMockUI() const transport = new WebTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) const preOpened = transport.openWindow('https://jungle4.anchorwallet.io/sign?esr=x') assert.equal((window.open as any).calls.length, 1) transport - .login(makeLoginContext(ui), makeBundle(), 'https://jungle4.anchorwallet.io', preOpened) + .login( + {}, + makeLoginContext(ui), + makeBundle(), + 'https://jungle4.anchorwallet.io', + preOpened + ) .catch(() => undefined) await new Promise((resolve) => setTimeout(resolve, 10)) @@ -101,7 +104,6 @@ suite('web transport', function () { const ui = makeMockUI() const transport = new WebTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) // A blocked popup is `null`, which is exactly what openWindow returns on failure. @@ -109,7 +111,7 @@ suite('web transport', function () { ;(window as any).open = () => null try { transport - .login(makeLoginContext(ui), makeBundle(), 'https://jungle4.anchorwallet.io') + .login({}, makeLoginContext(ui), makeBundle(), 'https://jungle4.anchorwallet.io') .catch(() => undefined) await new Promise((resolve) => setTimeout(resolve, 10)) const args = ui.lastPrompt()! @@ -132,11 +134,11 @@ suite('web transport', function () { const ui = makeMockUI() const transport = new WebTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', waitForCallback: callback, }) const response = await transport.login( + {}, makeLoginContext(ui), makeBundle(), 'https://jungle4.anchorwallet.io' @@ -152,12 +154,12 @@ suite('web transport', function () { ;(window.open as any).calls.length = 0 const dappKey = PrivateKey.generate('K1') const walletKey = PrivateKey.generate('K1') + const data = { + encryptionKey: String(dappKey), + messageKey: String(walletKey.toPublic()), + } const transport = new WebTransport({ id: 'anchor', - data: { - encryptionKey: String(dappKey), - messageKey: String(walletKey.toPublic()), - }, buoyUrl: 'https://cb.anchor.link', }) @@ -178,7 +180,7 @@ suite('web transport', function () { } as any let signError: any - transport.sign(resolved, context, 'https://jungle4.anchorwallet.io').catch((e) => { + transport.sign(data, resolved, context, 'https://jungle4.anchorwallet.io').catch((e) => { signError = e }) await new Promise((resolve) => setTimeout(resolve, 20)) @@ -199,12 +201,11 @@ suite('web transport', function () { test('sign refuses to run before a web login has stored keys', async function () { const transport = new WebTransport({ id: 'anchor', - data: {}, buoyUrl: 'https://cb.anchor.link', }) let message = '' try { - await transport.sign({} as any, {} as any, 'https://jungle4.anchorwallet.io') + await transport.sign({}, {} as any, {} as any, 'https://jungle4.anchorwallet.io') } catch (error: any) { message = error.message } diff --git a/packages/wallet-plugin-cleos/package.json b/packages/wallet-plugin-cleos/package.json index b12ac738..21a592f6 100644 --- a/packages/wallet-plugin-cleos/package.json +++ b/packages/wallet-plugin-cleos/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-cleos", "description": "A template to create wallet plugins for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-cleos", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-cloudwallet/package.json b/packages/wallet-plugin-cloudwallet/package.json index ce4de17e..173eaebc 100644 --- a/packages/wallet-plugin-cloudwallet/package.json +++ b/packages/wallet-plugin-cloudwallet/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-cloudwallet", "description": "A WalletPlugin for My Cloud Wallet for use within the @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-cloudwallet", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-gatewallet/package.json b/packages/wallet-plugin-gatewallet/package.json index b9bd9cbb..77383c0e 100644 --- a/packages/wallet-plugin-gatewallet/package.json +++ b/packages/wallet-plugin-gatewallet/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-gatewallet", "description": "A template to create wallet plugins for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-gatewallet", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-imtoken/package.json b/packages/wallet-plugin-imtoken/package.json index 4cfc8782..c09cd800 100644 --- a/packages/wallet-plugin-imtoken/package.json +++ b/packages/wallet-plugin-imtoken/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-imtoken", "description": "A template to create wallet plugins for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-imtoken", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-metamask/package.json b/packages/wallet-plugin-metamask/package.json index b3458b23..6f0934bc 100644 --- a/packages/wallet-plugin-metamask/package.json +++ b/packages/wallet-plugin-metamask/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-metamask", "description": "A MetaMask plugin for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-metamask", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-mimic/package.json b/packages/wallet-plugin-mimic/package.json index 227bfb9f..ff775fcc 100644 --- a/packages/wallet-plugin-mimic/package.json +++ b/packages/wallet-plugin-mimic/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-mimic", "description": "A template to create wallet plugins for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "private": true, "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-mock/package.json b/packages/wallet-plugin-mock/package.json index 6f0d1972..4b662b12 100644 --- a/packages/wallet-plugin-mock/package.json +++ b/packages/wallet-plugin-mock/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-mock", "description": "A mock wallet for developers to use while building web applications.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-mock", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-paycash/package.json b/packages/wallet-plugin-paycash/package.json index 777e12ab..b80592e7 100644 --- a/packages/wallet-plugin-paycash/package.json +++ b/packages/wallet-plugin-paycash/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-paycash", "description": "A Wharf wallet plugin for the PayCash wallet", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-paycash", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-privatekey/package.json b/packages/wallet-plugin-privatekey/package.json index 0be3530c..3a5de10e 100644 --- a/packages/wallet-plugin-privatekey/package.json +++ b/packages/wallet-plugin-privatekey/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-privatekey", "description": "A template to create wallet plugins for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-privatekey", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-scatter/package.json b/packages/wallet-plugin-scatter/package.json index 603188ce..cfb02b02 100644 --- a/packages/wallet-plugin-scatter/package.json +++ b/packages/wallet-plugin-scatter/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-scatter", "description": "A WalletPlugin for the Scatter wallet for use within the @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-scatter", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-tacklebox/package.json b/packages/wallet-plugin-tacklebox/package.json index c7b14f9d..f2b00c0b 100644 --- a/packages/wallet-plugin-tacklebox/package.json +++ b/packages/wallet-plugin-tacklebox/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-tacklebox", "description": "A TackleBox plugin for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-tacklebox", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-tokenpocket/package.json b/packages/wallet-plugin-tokenpocket/package.json index eabe13f7..cf091595 100644 --- a/packages/wallet-plugin-tokenpocket/package.json +++ b/packages/wallet-plugin-tokenpocket/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-tokenpocket", "description": "A WalletPlugin for the TokenPocket wallet for use within the @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-tokenpocket", "license": "BSD-3-Clause", "engines": { diff --git a/packages/wallet-plugin-web-authenticator/package.json b/packages/wallet-plugin-web-authenticator/package.json index 1d0b9b4f..c6c1855b 100644 --- a/packages/wallet-plugin-web-authenticator/package.json +++ b/packages/wallet-plugin-web-authenticator/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-web-authenticator", "description": "A Web Authenticator wallet plugin for use with @wharfkit/session.", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com/plugins/wallet-plugin-web-authenticator", "license": "BSD-3-Clause", "engines": { diff --git a/packages/web-renderer/package.json b/packages/web-renderer/package.json index ac1b6993..84e569b0 100644 --- a/packages/web-renderer/package.json +++ b/packages/web-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@wharfkit/web-renderer", - "version": "4.0.1", + "version": "4.0.2", "description": "", "license": "BSD-3-Clause", "engines": { diff --git a/packages/web-ui/package.json b/packages/web-ui/package.json index 4cd63565..083b31e1 100644 --- a/packages/web-ui/package.json +++ b/packages/web-ui/package.json @@ -1,6 +1,6 @@ { "name": "@wharfkit/web-ui", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "description": "Modern embedded UI renderer for WharfKit SessionKit", "type": "module", diff --git a/packages/webauthn/package.json b/packages/webauthn/package.json index 5e66dc39..caec2681 100644 --- a/packages/webauthn/package.json +++ b/packages/webauthn/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/webauthn", "description": "WebAuthn helpers for antelope core", - "version": "4.0.1", + "version": "4.0.2", "homepage": "https://wharfkit.com", "license": "BSD-3-Clause", "engines": {