@mysten-incubation/dev-wallet 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +5 -4
- package/dist/adapters/build-managed-account.d.mts +15 -2
- package/dist/adapters/build-managed-account.d.mts.map +1 -1
- package/dist/adapters/build-managed-account.mjs +28 -4
- package/dist/adapters/build-managed-account.mjs.map +1 -1
- package/dist/adapters/devstack-adapter.d.mts +19 -7
- package/dist/adapters/devstack-adapter.d.mts.map +1 -1
- package/dist/adapters/devstack-adapter.mjs +16 -8
- package/dist/adapters/devstack-adapter.mjs.map +1 -1
- package/dist/inject/index.d.mts +41 -16
- package/dist/inject/index.d.mts.map +1 -1
- package/dist/inject/index.mjs +43 -4
- package/dist/inject/index.mjs.map +1 -1
- package/dist/standalone/assets/{base-adapter-DET6CP7z.js → base-adapter-C5w5q7XZ.js} +1 -1
- package/dist/standalone/assets/{in-memory-adapter-CX7xym4e.js → in-memory-adapter-Ban2kRYS.js} +1 -1
- package/dist/standalone/assets/{main-CuOnBmaa.js → main-xfzarPod.js} +3 -3
- package/dist/standalone/assets/{webcrypto-adapter-CUQmbHDy.js → webcrypto-adapter-Ddqn-RAu.js} +1 -1
- package/dist/standalone/index.html +2 -2
- package/dist/ui/dev-wallet-balances.d.mts +7 -0
- package/dist/ui/dev-wallet-balances.d.mts.map +1 -1
- package/dist/ui/dev-wallet-balances.mjs +50 -3
- package/dist/ui/dev-wallet-balances.mjs.map +1 -1
- package/dist/ui/wallet-controller.mjs +2 -1
- package/dist/ui/wallet-controller.mjs.map +1 -1
- package/dist/wallet/dev-wallet.d.mts +26 -2
- package/dist/wallet/dev-wallet.d.mts.map +1 -1
- package/dist/wallet/dev-wallet.mjs +35 -6
- package/dist/wallet/dev-wallet.mjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/build-managed-account.ts +28 -2
- package/src/adapters/devstack-adapter.ts +28 -8
- package/src/inject/index.ts +127 -24
- package/src/ui/dev-wallet-balances.ts +62 -3
- package/src/ui/wallet-controller.ts +2 -1
- package/src/wallet/dev-wallet.ts +47 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @mysten-incubation/dev-wallet
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8119fac: Expose dev-wallet allowed origins to the injected adapter, reject forbidden page origins
|
|
8
|
+
with a browser-visible diagnostic, and allow same-stack routed app endpoints without allowing raw
|
|
9
|
+
loopback origins.
|
|
10
|
+
|
|
11
|
+
## 0.5.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- efa3ab6: Multi-network deployment config.
|
|
16
|
+
|
|
17
|
+
- **devstack**: renamed the persisted `id-config`/`ids` layer to `deployment`
|
|
18
|
+
(`NetworkDeployment`/`DevstackDeployment`, `loadDeployment`, `dump-deployment`). Added
|
|
19
|
+
multi-network support — per-network service buckets via `forNetwork(network)`, typed committed
|
|
20
|
+
`deployments/<net>.ts` files (`dump-deployment --network <net>`), and a deployment envelope
|
|
21
|
+
merged at the Vite layer (committed networks for a prod build, the live local stack overlaid on
|
|
22
|
+
`vite dev`). Removed the legacy `resolve*()` config-runtime shims and the
|
|
23
|
+
`@devstack-dev/generated-extras` subsystem.
|
|
24
|
+
- **dev-wallet**: the injected dev wallet now operates across the full network set — it advertises
|
|
25
|
+
every configured network as the wallet-standard chain `sui:<name>` (including fork/custom
|
|
26
|
+
names), routes a per-network faucet, and stays registered across a dApp Kit `switchNetwork`.
|
|
27
|
+
`createDevstackAdapterFromManifest` accepts an optional `networks` set so manifest-built
|
|
28
|
+
adapters advertise the same chains.
|
|
29
|
+
- **create-devstack-app**: templates reshaped around the deployment API and multi-network
|
|
30
|
+
deployments (typed `deployments/<net>.ts` authoring surface, dApp Kit wired to the generated
|
|
31
|
+
network set).
|
|
32
|
+
|
|
3
33
|
## 0.4.1
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ A development-only wallet for building and testing Sui dApps.
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
|
|
31
|
+
pnpm add @mysten-incubation/dev-wallet
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## Quick start
|
|
@@ -91,7 +91,7 @@ Run a self-contained wallet as a separate web app — signing works via popup, s
|
|
|
91
91
|
browser wallet.
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
|
|
94
|
+
pnpm dlx @mysten-incubation/dev-wallet serve
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
Register it through `walletInitializers` using `devWalletClientInitializer`:
|
|
@@ -114,7 +114,8 @@ import { DevWalletClient } from '@mysten-incubation/dev-wallet/client';
|
|
|
114
114
|
DevWalletClient.register({ origin: 'http://localhost:5174' });
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
The default port is 5174. Use `--port` to set a different port
|
|
117
|
+
The default port is 5174. Use `--port` to set a different port — the `origin` you pass to
|
|
118
|
+
`devWalletClientInitializer` / `DevWalletClient.register` must match whatever port `serve` runs on.
|
|
118
119
|
|
|
119
120
|
The standalone wallet includes WebCrypto and InMemory adapters by default. If `sui` is on your PATH,
|
|
120
121
|
the CLI adapter is also available — so you can sign with the same address you published contracts
|
|
@@ -202,7 +203,7 @@ The Remote CLI adapter connects to your local `sui` CLI over HTTP. Private keys
|
|
|
202
203
|
The easiest way is the standalone wallet:
|
|
203
204
|
|
|
204
205
|
```bash
|
|
205
|
-
|
|
206
|
+
pnpm dlx @mysten-incubation/dev-wallet serve
|
|
206
207
|
```
|
|
207
208
|
|
|
208
209
|
The terminal prints a URL with an auth token (e.g. `http://localhost:5174/?token=abc123`). Open it
|
|
@@ -4,9 +4,22 @@ import { Signer } from "@mysten/sui/cryptography";
|
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/build-managed-account.d.ts
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Resolve the wallet-standard chains to advertise for the given configured
|
|
8
|
+
* network names. Each network is advertised as `sui:<name>` so dApp Kit's
|
|
9
|
+
* chain-gated paths work for fork networks (`testnet-fork`, …) and custom
|
|
10
|
+
* names, unioned with the standard {@link SUI_CHAINS} for safety. Standard
|
|
11
|
+
* chains come first; configured-only chains are appended in the given order,
|
|
12
|
+
* de-duplicated.
|
|
8
13
|
*/
|
|
9
|
-
declare function
|
|
14
|
+
declare function chainsForNetworks(networks?: readonly string[]): `sui:${string}`[];
|
|
15
|
+
/**
|
|
16
|
+
* Build a {@link ManagedAccount} from a signer, address, label, optional
|
|
17
|
+
* feature list, and optional advertised chains. When `chains` is omitted the
|
|
18
|
+
* account advertises the standard {@link SUI_CHAINS}; pass the configured
|
|
19
|
+
* network names (via {@link chainsForNetworks}) so per-account advertised
|
|
20
|
+
* chains include fork/custom networks too.
|
|
21
|
+
*/
|
|
22
|
+
declare function buildManagedAccount(signer: Signer, address: string, label: string, features?: readonly IdentifierString[], chains?: readonly `sui:${string}`[]): ManagedAccount;
|
|
10
23
|
//#endregion
|
|
11
24
|
export { buildManagedAccount };
|
|
12
25
|
//# sourceMappingURL=build-managed-account.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-managed-account.d.mts","names":[],"sources":["../../src/adapters/build-managed-account.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"build-managed-account.d.mts","names":[],"sources":["../../src/adapters/build-managed-account.ts"],"mappings":";;;;;;;AAuBA;;;;AAA8D;AAoB9D;iBApBgB,iBAAA,CAAkB,QAA4B;;;;;;;;iBAoB9C,mBAAA,CACf,MAAA,EAAQ,MAAA,EACR,OAAA,UACA,KAAA,UACA,QAAA,YAAoB,gBAAA,IACpB,MAAA,gCACE,cAAA"}
|
|
@@ -6,9 +6,33 @@ const DEFAULT_FEATURES = [
|
|
|
6
6
|
"sui:signPersonalMessage"
|
|
7
7
|
];
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Resolve the wallet-standard chains to advertise for the given configured
|
|
10
|
+
* network names. Each network is advertised as `sui:<name>` so dApp Kit's
|
|
11
|
+
* chain-gated paths work for fork networks (`testnet-fork`, …) and custom
|
|
12
|
+
* names, unioned with the standard {@link SUI_CHAINS} for safety. Standard
|
|
13
|
+
* chains come first; configured-only chains are appended in the given order,
|
|
14
|
+
* de-duplicated.
|
|
10
15
|
*/
|
|
11
|
-
function
|
|
16
|
+
function chainsForNetworks(networks) {
|
|
17
|
+
const chains = [...SUI_CHAINS];
|
|
18
|
+
const seen = new Set(SUI_CHAINS);
|
|
19
|
+
for (const network of networks ?? []) {
|
|
20
|
+
const chain = `sui:${network}`;
|
|
21
|
+
if (!seen.has(chain)) {
|
|
22
|
+
seen.add(chain);
|
|
23
|
+
chains.push(chain);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return chains;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build a {@link ManagedAccount} from a signer, address, label, optional
|
|
30
|
+
* feature list, and optional advertised chains. When `chains` is omitted the
|
|
31
|
+
* account advertises the standard {@link SUI_CHAINS}; pass the configured
|
|
32
|
+
* network names (via {@link chainsForNetworks}) so per-account advertised
|
|
33
|
+
* chains include fork/custom networks too.
|
|
34
|
+
*/
|
|
35
|
+
function buildManagedAccount(signer, address, label, features, chains) {
|
|
12
36
|
return {
|
|
13
37
|
address,
|
|
14
38
|
label,
|
|
@@ -17,12 +41,12 @@ function buildManagedAccount(signer, address, label, features) {
|
|
|
17
41
|
address,
|
|
18
42
|
label,
|
|
19
43
|
publicKey: signer.getPublicKey().toSuiBytes(),
|
|
20
|
-
chains: [...SUI_CHAINS],
|
|
44
|
+
chains: chains !== void 0 ? [...chains] : [...SUI_CHAINS],
|
|
21
45
|
features: [...features ?? DEFAULT_FEATURES]
|
|
22
46
|
})
|
|
23
47
|
};
|
|
24
48
|
}
|
|
25
49
|
//#endregion
|
|
26
|
-
export { buildManagedAccount };
|
|
50
|
+
export { buildManagedAccount, chainsForNetworks };
|
|
27
51
|
|
|
28
52
|
//# sourceMappingURL=build-managed-account.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-managed-account.mjs","names":[],"sources":["../../src/adapters/build-managed-account.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { IdentifierString } from '@mysten/wallet-standard';\nimport { ReadonlyWalletAccount, SUI_CHAINS } from '@mysten/wallet-standard';\n\nimport type { ManagedAccount } from '../types.js';\n\nconst DEFAULT_FEATURES: IdentifierString[] = [\n\t'sui:signTransaction',\n\t'sui:signAndExecuteTransaction',\n\t'sui:signPersonalMessage',\n];\n\n/**\n * Build a {@link ManagedAccount} from a signer, address, label, and optional
|
|
1
|
+
{"version":3,"file":"build-managed-account.mjs","names":[],"sources":["../../src/adapters/build-managed-account.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { IdentifierString } from '@mysten/wallet-standard';\nimport { ReadonlyWalletAccount, SUI_CHAINS } from '@mysten/wallet-standard';\n\nimport type { ManagedAccount } from '../types.js';\n\nconst DEFAULT_FEATURES: IdentifierString[] = [\n\t'sui:signTransaction',\n\t'sui:signAndExecuteTransaction',\n\t'sui:signPersonalMessage',\n];\n\n/**\n * Resolve the wallet-standard chains to advertise for the given configured\n * network names. Each network is advertised as `sui:<name>` so dApp Kit's\n * chain-gated paths work for fork networks (`testnet-fork`, …) and custom\n * names, unioned with the standard {@link SUI_CHAINS} for safety. Standard\n * chains come first; configured-only chains are appended in the given order,\n * de-duplicated.\n */\nexport function chainsForNetworks(networks?: readonly string[]): `sui:${string}`[] {\n\tconst chains: `sui:${string}`[] = [...SUI_CHAINS];\n\tconst seen = new Set<string>(SUI_CHAINS);\n\tfor (const network of networks ?? []) {\n\t\tconst chain = `sui:${network}` as const;\n\t\tif (!seen.has(chain)) {\n\t\t\tseen.add(chain);\n\t\t\tchains.push(chain);\n\t\t}\n\t}\n\treturn chains;\n}\n\n/**\n * Build a {@link ManagedAccount} from a signer, address, label, optional\n * feature list, and optional advertised chains. When `chains` is omitted the\n * account advertises the standard {@link SUI_CHAINS}; pass the configured\n * network names (via {@link chainsForNetworks}) so per-account advertised\n * chains include fork/custom networks too.\n */\nexport function buildManagedAccount(\n\tsigner: Signer,\n\taddress: string,\n\tlabel: string,\n\tfeatures?: readonly IdentifierString[],\n\tchains?: readonly `sui:${string}`[],\n): ManagedAccount {\n\tconst walletAccount = new ReadonlyWalletAccount({\n\t\taddress,\n\t\tlabel,\n\t\tpublicKey: signer.getPublicKey().toSuiBytes(),\n\t\tchains: chains !== undefined ? [...chains] : [...SUI_CHAINS],\n\t\tfeatures: [...(features ?? DEFAULT_FEATURES)],\n\t});\n\treturn { address, label, signer, walletAccount };\n}\n"],"mappings":";;AASA,MAAM,mBAAuC;CAC5C;CACA;CACA;AACD;;;;;;;;;AAUA,SAAgB,kBAAkB,UAAiD;CAClF,MAAM,SAA4B,CAAC,GAAG,UAAU;CAChD,MAAM,OAAO,IAAI,IAAY,UAAU;CACvC,KAAK,MAAM,WAAW,YAAY,CAAC,GAAG;EACrC,MAAM,QAAQ,OAAO;EACrB,IAAI,CAAC,KAAK,IAAI,KAAK,GAAG;GACrB,KAAK,IAAI,KAAK;GACd,OAAO,KAAK,KAAK;EAClB;CACD;CACA,OAAO;AACR;;;;;;;;AASA,SAAgB,oBACf,QACA,SACA,OACA,UACA,QACiB;CAQjB,OAAO;EAAE;EAAS;EAAO;EAAQ,mBAPP,sBAAsB;GAC/C;GACA;GACA,WAAW,OAAO,aAAa,CAAC,CAAC,WAAW;GAC5C,QAAQ,WAAW,SAAY,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,UAAU;GAC3D,UAAU,CAAC,GAAI,YAAY,gBAAiB;EAC7C,CACiC;CAAc;AAChD"}
|
|
@@ -38,6 +38,11 @@ interface DevstackSignerAdapterOptions {
|
|
|
38
38
|
token?: string | null;
|
|
39
39
|
/** Override the adapter's display name. Defaults to `'Devstack'`. */
|
|
40
40
|
name?: string;
|
|
41
|
+
/** The configured network names the wallet operates on. Each is advertised
|
|
42
|
+
* on every account as the wallet-standard chain `sui:<name>` (unioned with
|
|
43
|
+
* the standard Sui chains) so fork/custom networks are signable. Defaults
|
|
44
|
+
* to the standard chains only. */
|
|
45
|
+
networks?: readonly string[];
|
|
41
46
|
}
|
|
42
47
|
/**
|
|
43
48
|
* {@link SignerAdapter} that surfaces every account resolved by `devstack up`
|
|
@@ -45,10 +50,9 @@ interface DevstackSignerAdapterOptions {
|
|
|
45
50
|
* shipping their private keys into the frontend bundle. All signing happens
|
|
46
51
|
* server-side via the `wallet()` plugin.
|
|
47
52
|
*
|
|
48
|
-
* The
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* adapter directly.
|
|
53
|
+
* The dev wallet that devstack injects at serve time registers this adapter
|
|
54
|
+
* automatically from the wallet connection devstack publishes — apps wire
|
|
55
|
+
* dapp-kit in their own `dapp-kit.ts` and never touch the adapter directly.
|
|
52
56
|
*
|
|
53
57
|
* To construct one manually (e.g. from a non-manifest source):
|
|
54
58
|
*
|
|
@@ -79,8 +83,8 @@ declare class DevstackSignerAdapter extends BaseSignerAdapter {
|
|
|
79
83
|
*/
|
|
80
84
|
declare function parseDevstackToken(pairedUrl: string | undefined): string | null;
|
|
81
85
|
/** Narrow input — the only field the adapter consumes is
|
|
82
|
-
* `app.wallet.{url, pairUrl}`. Codegen emits exactly this shape so
|
|
83
|
-
* generated
|
|
86
|
+
* `app.wallet.{url, pairUrl}`. Codegen emits exactly this shape so the
|
|
87
|
+
* generated wiring doesn't have to fabricate placeholder
|
|
84
88
|
* manifest fields (`stack.app`, `coins`, etc.) just to satisfy the
|
|
85
89
|
* full `Manifest` type. Mirrors a slice of `AppManifest` from
|
|
86
90
|
* `@mysten-incubation/devstack` without importing it (dev-wallet
|
|
@@ -104,8 +108,16 @@ interface DevstackAdapterManifest {
|
|
|
104
108
|
* {@link DevstackAdapterManifest}, so
|
|
105
109
|
* `createDevstackAdapterFromManifest(devstackManifest)` typechecks
|
|
106
110
|
* without a cast.
|
|
111
|
+
*
|
|
112
|
+
* The narrow manifest shape carries no network set, so pass
|
|
113
|
+
* `options.networks` (e.g. the generated `config.networkNames`) to advertise
|
|
114
|
+
* fork/custom networks as `sui:<name>` on every account — matching what the
|
|
115
|
+
* devstack-injected dev wallet does via the constructor. Omit it and accounts
|
|
116
|
+
* advertise the standard Sui chains only.
|
|
107
117
|
*/
|
|
108
|
-
declare function createDevstackAdapterFromManifest(manifest: DevstackAdapterManifest
|
|
118
|
+
declare function createDevstackAdapterFromManifest(manifest: DevstackAdapterManifest, options?: {
|
|
119
|
+
readonly networks?: readonly string[];
|
|
120
|
+
}): DevstackSignerAdapter | null;
|
|
109
121
|
//#endregion
|
|
110
122
|
export { DevstackAdapterManifest, DevstackProxySigner, DevstackSignerAdapter, DevstackSignerAdapterOptions, createDevstackAdapterFromManifest, parseDevstackToken };
|
|
111
123
|
//# sourceMappingURL=devstack-adapter.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devstack-adapter.d.mts","names":[],"sources":["../../src/adapters/devstack-adapter.ts"],"mappings":";;;;;AAiEA;;;;cAAa,mBAAA,SAA4B,MAAA;EAAA;cAO5B,OAAA;IACX,OAAA;IACA,SAAA,EAAW,SAAA;IACX,MAAA,EAAQ,eAAA;IACR,YAAA;IACA,SAAA;EAAA;EAUK,IAAA,CAAK,MAAA,EAAQ,UAAA,GAAa,OAAA,CAAQ,UAAA,CAAW,WAAA;EAOnD,YAAA,IAAgB,eAAA;EAIhB,YAAA,IAAgB,SAAA;EAIP,YAAA;EAIM,eAAA,CAAgB,KA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4 +1,4 @@
|
|
|
1
|
-
import { buildManagedAccount } from "./build-managed-account.mjs";
|
|
1
|
+
import { buildManagedAccount, chainsForNetworks } from "./build-managed-account.mjs";
|
|
2
2
|
import { BaseSignerAdapter } from "./base-adapter.mjs";
|
|
3
3
|
import { DEVSTACK_WALLET_HTTP_PATH } from "./devstack-paths.mjs";
|
|
4
4
|
import { fromBase64, toBase64 } from "@mysten/sui/utils";
|
|
@@ -112,10 +112,9 @@ var DevstackProxySigner = class extends Signer {
|
|
|
112
112
|
* shipping their private keys into the frontend bundle. All signing happens
|
|
113
113
|
* server-side via the `wallet()` plugin.
|
|
114
114
|
*
|
|
115
|
-
* The
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* adapter directly.
|
|
115
|
+
* The dev wallet that devstack injects at serve time registers this adapter
|
|
116
|
+
* automatically from the wallet connection devstack publishes — apps wire
|
|
117
|
+
* dapp-kit in their own `dapp-kit.ts` and never touch the adapter directly.
|
|
119
118
|
*
|
|
120
119
|
* To construct one manually (e.g. from a non-manifest source):
|
|
121
120
|
*
|
|
@@ -129,6 +128,7 @@ var DevstackProxySigner = class extends Signer {
|
|
|
129
128
|
var DevstackSignerAdapter = class extends BaseSignerAdapter {
|
|
130
129
|
#serverOrigin;
|
|
131
130
|
#authToken;
|
|
131
|
+
#chains;
|
|
132
132
|
constructor(options) {
|
|
133
133
|
super();
|
|
134
134
|
this.id = "devstack";
|
|
@@ -141,6 +141,7 @@ var DevstackSignerAdapter = class extends BaseSignerAdapter {
|
|
|
141
141
|
this.#serverOrigin = options.serverOrigin;
|
|
142
142
|
this.#authToken = options.token ?? null;
|
|
143
143
|
this.name = options.name ?? "Devstack";
|
|
144
|
+
this.#chains = chainsForNetworks(options.networks);
|
|
144
145
|
}
|
|
145
146
|
async initialize() {
|
|
146
147
|
try {
|
|
@@ -173,7 +174,7 @@ var DevstackSignerAdapter = class extends BaseSignerAdapter {
|
|
|
173
174
|
scheme: info.scheme,
|
|
174
175
|
serverOrigin: this.#serverOrigin,
|
|
175
176
|
authToken: this.#authToken
|
|
176
|
-
}), info.address, info.name, DEVSTACK_WALLET_FEATURES);
|
|
177
|
+
}), info.address, info.name, DEVSTACK_WALLET_FEATURES, this.#chains);
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
180
|
};
|
|
@@ -209,13 +210,20 @@ function parseDevstackToken(pairedUrl) {
|
|
|
209
210
|
* {@link DevstackAdapterManifest}, so
|
|
210
211
|
* `createDevstackAdapterFromManifest(devstackManifest)` typechecks
|
|
211
212
|
* without a cast.
|
|
213
|
+
*
|
|
214
|
+
* The narrow manifest shape carries no network set, so pass
|
|
215
|
+
* `options.networks` (e.g. the generated `config.networkNames`) to advertise
|
|
216
|
+
* fork/custom networks as `sui:<name>` on every account — matching what the
|
|
217
|
+
* devstack-injected dev wallet does via the constructor. Omit it and accounts
|
|
218
|
+
* advertise the standard Sui chains only.
|
|
212
219
|
*/
|
|
213
|
-
function createDevstackAdapterFromManifest(manifest) {
|
|
220
|
+
function createDevstackAdapterFromManifest(manifest, options) {
|
|
214
221
|
const wallet = manifest.app?.wallet;
|
|
215
222
|
if (wallet === void 0) return null;
|
|
216
223
|
return new DevstackSignerAdapter({
|
|
217
224
|
serverOrigin: wallet.url,
|
|
218
|
-
token: parseDevstackToken(wallet.pairUrl)
|
|
225
|
+
token: parseDevstackToken(wallet.pairUrl),
|
|
226
|
+
networks: options?.networks
|
|
219
227
|
});
|
|
220
228
|
}
|
|
221
229
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devstack-adapter.mjs","names":["#address","#publicKey","#scheme","#serverOrigin","#authToken","#fetchAccounts"],"sources":["../../src/adapters/devstack-adapter.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n//\n// Devstack signer adapter — exposes accounts resolved by `devstack up`'s\n// `wallet()` plugin to dApp Kit, signing transactions over HTTP so\n// private keys never enter the frontend bundle. Mirrors RemoteCliAdapter's\n// out-of-process model; the difference is the source of accounts (devstack\n// resolved signers vs `sui keytool list`) and the endpoint paths.\n\nimport { Signer } from '@mysten/sui/cryptography';\nimport type { PublicKey, SignatureScheme } from '@mysten/sui/cryptography';\nimport { Ed25519PublicKey } from '@mysten/sui/keypairs/ed25519';\nimport { Secp256k1PublicKey } from '@mysten/sui/keypairs/secp256k1';\nimport { Secp256r1PublicKey } from '@mysten/sui/keypairs/secp256r1';\nimport { fromBase64, toBase64 } from '@mysten/sui/utils';\n\nimport type { ManagedAccount } from '../types.js';\nimport { BaseSignerAdapter } from './base-adapter.js';\nimport { buildManagedAccount } from './build-managed-account.js';\nimport { DEVSTACK_WALLET_HTTP_PATH } from './devstack-paths.js';\n\nconst DEVSTACK_WALLET_FEATURES = [\n\t'sui:signTransaction',\n\t'sui:signAndExecuteTransaction',\n\t'sui:signPersonalMessage',\n] as const;\n\ninterface ServerAccountInfo {\n\tname: string;\n\taddress: string;\n\tscheme: SignatureScheme;\n\tpublicKey: string;\n}\n\nclass AuthError extends Error {\n\tconstructor() {\n\t\tsuper('Unauthorized');\n\t\tthis.name = 'AuthError';\n\t}\n}\n\nfunction publicKeyForScheme(base64: string, scheme: SignatureScheme | string): PublicKey {\n\tconst bytes = fromBase64(base64);\n\t// The devstack server's wallet-app endpoint surfaces the scheme in\n\t// the lowercase form it standardised at the Account boundary\n\t// (`'ed25519'`, `'secp256k1'`, `'secp256r1'`). The Sui SDK's\n\t// `SignatureScheme` union is mixed-case (`'ED25519'`, `'Secp256k1'`,\n\t// …). Normalise to lowercase before matching so either casing parses.\n\tswitch (String(scheme).toLowerCase()) {\n\t\tcase 'ed25519':\n\t\t\treturn new Ed25519PublicKey(bytes);\n\t\tcase 'secp256k1':\n\t\t\treturn new Secp256k1PublicKey(bytes);\n\t\tcase 'secp256r1':\n\t\t\treturn new Secp256r1PublicKey(bytes);\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported key scheme: ${scheme}`);\n\t}\n}\n\n/**\n * Signer that delegates transaction signing to the devstack wallet-app\n * over HTTP. Mirrors {@link CliProxySigner} but talks to the\n * `wallet()` plugin's endpoints under `/api/v1/devstack/*`.\n */\nexport class DevstackProxySigner extends Signer {\n\t#address: string;\n\t#publicKey: PublicKey;\n\t#scheme: SignatureScheme;\n\t#serverOrigin: string;\n\t#authToken: string | null;\n\n\tconstructor(options: {\n\t\taddress: string;\n\t\tpublicKey: PublicKey;\n\t\tscheme: SignatureScheme;\n\t\tserverOrigin: string;\n\t\tauthToken?: string | null;\n\t}) {\n\t\tsuper();\n\t\tthis.#address = options.address;\n\t\tthis.#publicKey = options.publicKey;\n\t\tthis.#scheme = options.scheme;\n\t\tthis.#serverOrigin = options.serverOrigin;\n\t\tthis.#authToken = options.authToken ?? null;\n\t}\n\n\tasync sign(_bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>> {\n\t\tthrow new Error(\n\t\t\t'DevstackProxySigner does not support raw digest signing. ' +\n\t\t\t\t'Use signTransaction (the wallet-app signs BCS-serialized TransactionData).',\n\t\t);\n\t}\n\n\tgetKeyScheme(): SignatureScheme {\n\t\treturn this.#scheme;\n\t}\n\n\tgetPublicKey(): PublicKey {\n\t\treturn this.#publicKey;\n\t}\n\n\toverride toSuiAddress(): string {\n\t\treturn this.#address;\n\t}\n\n\toverride async signTransaction(bytes: Uint8Array) {\n\t\tconst headers: Record<string, string> = { 'Content-Type': 'application/json' };\n\t\tif (this.#authToken !== null) {\n\t\t\theaders['Authorization'] = `Bearer ${this.#authToken}`;\n\t\t}\n\t\tconst requestBytes = toBase64(bytes);\n\t\tconst res = await fetch(`${this.#serverOrigin}${DEVSTACK_WALLET_HTTP_PATH.SIGN_TRANSACTION}`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders,\n\t\t\tbody: JSON.stringify({\n\t\t\t\taddress: this.#address,\n\t\t\t\tbytes: requestBytes,\n\t\t\t}),\n\t\t});\n\t\tif (!res.ok) {\n\t\t\tconst body = await res.json().catch(() => ({}));\n\t\t\tconst message = (body as { error?: unknown }).error;\n\t\t\tthrow new Error(\n\t\t\t\t`Devstack signing failed: ${typeof message === 'string' ? message : res.statusText}`,\n\t\t\t);\n\t\t}\n\t\tconst { bytes: responseBytes, signature } = (await res.json()) as {\n\t\t\tbytes?: string;\n\t\t\tsignature?: string;\n\t\t};\n\t\tif (typeof responseBytes !== 'string' || responseBytes.length === 0) {\n\t\t\tthrow new Error('Devstack signing failed: server returned invalid signed bytes');\n\t\t}\n\t\tif (typeof signature !== 'string' || signature.length === 0) {\n\t\t\tthrow new Error('Devstack signing failed: server returned invalid signature');\n\t\t}\n\t\treturn {\n\t\t\tbytes: responseBytes,\n\t\t\tsignature,\n\t\t};\n\t}\n\n\toverride async signPersonalMessage(bytes: Uint8Array) {\n\t\tconst headers: Record<string, string> = { 'Content-Type': 'application/json' };\n\t\tif (this.#authToken !== null) {\n\t\t\theaders['Authorization'] = `Bearer ${this.#authToken}`;\n\t\t}\n\t\tconst res = await fetch(\n\t\t\t`${this.#serverOrigin}${DEVSTACK_WALLET_HTTP_PATH.SIGN_PERSONAL_MESSAGE}`,\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders,\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\taddress: this.#address,\n\t\t\t\t\tbytes: toBase64(bytes),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t\tif (!res.ok) {\n\t\t\tconst body = await res.json().catch(() => ({}));\n\t\t\tconst message = (body as { error?: unknown }).error;\n\t\t\tthrow new Error(\n\t\t\t\t`Devstack personal-message signing failed: ${\n\t\t\t\t\ttypeof message === 'string' ? message : res.statusText\n\t\t\t\t}`,\n\t\t\t);\n\t\t}\n\t\tconst { bytes: responseBytes, signature } = (await res.json()) as {\n\t\t\tbytes?: string;\n\t\t\tsignature?: string;\n\t\t};\n\t\tif (typeof responseBytes !== 'string' || responseBytes.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t'Devstack personal-message signing failed: server returned invalid signed bytes',\n\t\t\t);\n\t\t}\n\t\tif (typeof signature !== 'string' || signature.length === 0) {\n\t\t\tthrow new Error('Devstack personal-message signing failed: server returned no signature');\n\t\t}\n\t\treturn { bytes: responseBytes, signature };\n\t}\n}\n\nexport interface DevstackSignerAdapterOptions {\n\t/** Wallet-app origin (e.g. `http://localhost:9420`). Read from the\n\t * matching endpoint entry on the active manifest. */\n\tserverOrigin: string;\n\t/** Bearer token. Parse `?token=<hex>` from the manifest entry's\n\t * `pairUrl`. Omit if the wallet-app runs without auth. */\n\ttoken?: string | null;\n\t/** Override the adapter's display name. Defaults to `'Devstack'`. */\n\tname?: string;\n}\n\n/**\n * {@link SignerAdapter} that surfaces every account resolved by `devstack up`\n * (including `cliSigner`/`envSigner`/`generatedKeypair` slots) without\n * shipping their private keys into the frontend bundle. All signing happens\n * server-side via the `wallet()` plugin.\n *\n * The simplest construction uses devstack's generated `dapp-kit-config.ts`,\n * which bakes the wallet adapter wiring at codegen time — apps spread\n * `devstackDappKitConfig` into `createDAppKit(...)` and never touch the\n * adapter directly.\n *\n * To construct one manually (e.g. from a non-manifest source):\n *\n * ```ts\n * const adapter = new DevstackSignerAdapter({\n * serverOrigin: 'http://localhost:9420',\n * token: '<bearer hex>',\n * });\n * ```\n */\nexport class DevstackSignerAdapter extends BaseSignerAdapter {\n\treadonly id = 'devstack';\n\treadonly name: string;\n\treadonly allowAutoSign = true;\n\n\t#serverOrigin: string;\n\t#authToken: string | null;\n\n\tconstructor(options: DevstackSignerAdapterOptions) {\n\t\tsuper();\n\t\ttry {\n\t\t\tnew URL(options.serverOrigin);\n\t\t} catch {\n\t\t\tthrow new Error(`DevstackSignerAdapter: invalid serverOrigin \"${options.serverOrigin}\"`);\n\t\t}\n\t\tthis.#serverOrigin = options.serverOrigin;\n\t\tthis.#authToken = options.token ?? null;\n\t\tthis.name = options.name ?? 'Devstack';\n\t}\n\n\tasync initialize(): Promise<void> {\n\t\ttry {\n\t\t\tconst accounts = await this.#fetchAccounts();\n\t\t\tthis.setInitialAccounts(accounts);\n\t\t} catch (error) {\n\t\t\tif (error instanceof AuthError) {\n\t\t\t\tconsole.warn('[dev-wallet] devstack adapter: unauthorized — skipping account import');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconsole.warn('[dev-wallet] devstack adapter: initialization failed:', error);\n\t\t}\n\t}\n\n\toverride destroy(): void {\n\t\tthis.#authToken = null;\n\t\tsuper.destroy();\n\t}\n\n\tasync #fetchAccounts(): Promise<ManagedAccount[]> {\n\t\tconst headers: Record<string, string> = { 'Content-Type': 'application/json' };\n\t\tif (this.#authToken !== null) {\n\t\t\theaders['Authorization'] = `Bearer ${this.#authToken}`;\n\t\t}\n\t\tconst res = await fetch(`${this.#serverOrigin}${DEVSTACK_WALLET_HTTP_PATH.ACCOUNTS}`, {\n\t\t\theaders,\n\t\t});\n\t\tif (res.status === 401 || res.status === 403) throw new AuthError();\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`Failed to fetch devstack accounts: ${res.statusText}`);\n\t\t}\n\t\tconst { accounts } = (await res.json()) as { accounts: ServerAccountInfo[] };\n\t\treturn accounts.map((info) => {\n\t\t\tconst publicKey = publicKeyForScheme(info.publicKey, info.scheme);\n\t\t\tconst signer = new DevstackProxySigner({\n\t\t\t\taddress: info.address,\n\t\t\t\tpublicKey,\n\t\t\t\tscheme: info.scheme,\n\t\t\t\tserverOrigin: this.#serverOrigin,\n\t\t\t\tauthToken: this.#authToken,\n\t\t\t});\n\t\t\treturn buildManagedAccount(signer, info.address, info.name, DEVSTACK_WALLET_FEATURES);\n\t\t});\n\t}\n}\n\n/**\n * Pull the bearer token off a paired URL produced by the `wallet()`\n * plugin. Returns `null` if the input is undefined, malformed, or\n * carries a `<redacted>` placeholder (the manifest's pairUrl carries\n * the redacted form; the real token lives in a sibling 0o600 file the\n * consumer reads separately).\n *\n * The token rides in the URL fragment as `#token=<hex>`.\n */\nexport function parseDevstackToken(pairedUrl: string | undefined): string | null {\n\tif (pairedUrl === undefined) return null;\n\ttry {\n\t\tconst url = new URL(pairedUrl);\n\t\tconst hash = url.hash; // e.g. \"#token=abcd\"\n\t\tif (hash.length <= 1) return null;\n\t\tconst params = new URLSearchParams(hash.slice(1));\n\t\tconst token = params.get('token');\n\t\tif (token === null || token === '<redacted>') return null;\n\t\treturn token;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** Narrow input — the only field the adapter consumes is\n * `app.wallet.{url, pairUrl}`. Codegen emits exactly this shape so\n * generated `dapp-kit-config.ts` doesn't have to fabricate placeholder\n * manifest fields (`stack.app`, `coins`, etc.) just to satisfy the\n * full `Manifest` type. Mirrors a slice of `AppManifest` from\n * `@mysten-incubation/devstack` without importing it (dev-wallet\n * doesn't depend on devstack — circular). */\nexport interface DevstackAdapterManifest {\n\tapp?: {\n\t\twallet?: {\n\t\t\turl: string;\n\t\t\tpairUrl?: string;\n\t\t};\n\t};\n}\n\n/**\n * Convenience: read the wallet-app endpoint off a devstack manifest and\n * build a configured adapter, or return `null` when the entry isn't\n * present (no `wallet(...)` in the stack, or it hasn't come up yet).\n *\n * The wallet entry's `pairUrl` carries the `#token=…` fragment used to\n * extract the bearer token. The full `Manifest` shape from\n * `@mysten-incubation/devstack` is structurally compatible with\n * {@link DevstackAdapterManifest}, so\n * `createDevstackAdapterFromManifest(devstackManifest)` typechecks\n * without a cast.\n */\nexport function createDevstackAdapterFromManifest(\n\tmanifest: DevstackAdapterManifest,\n): DevstackSignerAdapter | null {\n\tconst wallet = manifest.app?.wallet;\n\tif (wallet === undefined) return null;\n\treturn new DevstackSignerAdapter({\n\t\tserverOrigin: wallet.url,\n\t\ttoken: parseDevstackToken(wallet.pairUrl),\n\t});\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAM,2BAA2B;CAChC;CACA;CACA;AACD;AASA,IAAM,YAAN,cAAwB,MAAM;CAC7B,cAAc;EACb,MAAM,cAAc;EACpB,KAAK,OAAO;CACb;AACD;AAEA,SAAS,mBAAmB,QAAgB,QAA6C;CACxF,MAAM,QAAQ,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U,cAAc,OAAO;EACrD,OAAO;CACR,QAAQ;EACP,OAAO;CACR;AACD;;;;;;;;;;;;;AA8BA,SAAgB,kCACf,UAC+B;CAC/B,MAAM,SAAS,SAAS,KAAK;CAC7B,IAAI,WAAW,QAAW,OAAO;CACjC,OAAO,IAAI,sBAAsB;EAChC,cAAc,OAAO;EACrB,OAAO,mBAAmB,OAAO,OAAO;CACzC,CAAC;AACF"}
|
|
1
|
+
{"version":3,"file":"devstack-adapter.mjs","names":["#address","#publicKey","#scheme","#serverOrigin","#authToken","#chains","#fetchAccounts"],"sources":["../../src/adapters/devstack-adapter.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n//\n// Devstack signer adapter — exposes accounts resolved by `devstack up`'s\n// `wallet()` plugin to dApp Kit, signing transactions over HTTP so\n// private keys never enter the frontend bundle. Mirrors RemoteCliAdapter's\n// out-of-process model; the difference is the source of accounts (devstack\n// resolved signers vs `sui keytool list`) and the endpoint paths.\n\nimport { Signer } from '@mysten/sui/cryptography';\nimport type { PublicKey, SignatureScheme } from '@mysten/sui/cryptography';\nimport { Ed25519PublicKey } from '@mysten/sui/keypairs/ed25519';\nimport { Secp256k1PublicKey } from '@mysten/sui/keypairs/secp256k1';\nimport { Secp256r1PublicKey } from '@mysten/sui/keypairs/secp256r1';\nimport { fromBase64, toBase64 } from '@mysten/sui/utils';\n\nimport type { ManagedAccount } from '../types.js';\nimport { BaseSignerAdapter } from './base-adapter.js';\nimport { buildManagedAccount, chainsForNetworks } from './build-managed-account.js';\nimport { DEVSTACK_WALLET_HTTP_PATH } from './devstack-paths.js';\n\nconst DEVSTACK_WALLET_FEATURES = [\n\t'sui:signTransaction',\n\t'sui:signAndExecuteTransaction',\n\t'sui:signPersonalMessage',\n] as const;\n\ninterface ServerAccountInfo {\n\tname: string;\n\taddress: string;\n\tscheme: SignatureScheme;\n\tpublicKey: string;\n}\n\nclass AuthError extends Error {\n\tconstructor() {\n\t\tsuper('Unauthorized');\n\t\tthis.name = 'AuthError';\n\t}\n}\n\nfunction publicKeyForScheme(base64: string, scheme: SignatureScheme | string): PublicKey {\n\tconst bytes = fromBase64(base64);\n\t// The devstack server's wallet-app endpoint surfaces the scheme in\n\t// the lowercase form it standardised at the Account boundary\n\t// (`'ed25519'`, `'secp256k1'`, `'secp256r1'`). The Sui SDK's\n\t// `SignatureScheme` union is mixed-case (`'ED25519'`, `'Secp256k1'`,\n\t// …). Normalise to lowercase before matching so either casing parses.\n\tswitch (String(scheme).toLowerCase()) {\n\t\tcase 'ed25519':\n\t\t\treturn new Ed25519PublicKey(bytes);\n\t\tcase 'secp256k1':\n\t\t\treturn new Secp256k1PublicKey(bytes);\n\t\tcase 'secp256r1':\n\t\t\treturn new Secp256r1PublicKey(bytes);\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported key scheme: ${scheme}`);\n\t}\n}\n\n/**\n * Signer that delegates transaction signing to the devstack wallet-app\n * over HTTP. Mirrors {@link CliProxySigner} but talks to the\n * `wallet()` plugin's endpoints under `/api/v1/devstack/*`.\n */\nexport class DevstackProxySigner extends Signer {\n\t#address: string;\n\t#publicKey: PublicKey;\n\t#scheme: SignatureScheme;\n\t#serverOrigin: string;\n\t#authToken: string | null;\n\n\tconstructor(options: {\n\t\taddress: string;\n\t\tpublicKey: PublicKey;\n\t\tscheme: SignatureScheme;\n\t\tserverOrigin: string;\n\t\tauthToken?: string | null;\n\t}) {\n\t\tsuper();\n\t\tthis.#address = options.address;\n\t\tthis.#publicKey = options.publicKey;\n\t\tthis.#scheme = options.scheme;\n\t\tthis.#serverOrigin = options.serverOrigin;\n\t\tthis.#authToken = options.authToken ?? null;\n\t}\n\n\tasync sign(_bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>> {\n\t\tthrow new Error(\n\t\t\t'DevstackProxySigner does not support raw digest signing. ' +\n\t\t\t\t'Use signTransaction (the wallet-app signs BCS-serialized TransactionData).',\n\t\t);\n\t}\n\n\tgetKeyScheme(): SignatureScheme {\n\t\treturn this.#scheme;\n\t}\n\n\tgetPublicKey(): PublicKey {\n\t\treturn this.#publicKey;\n\t}\n\n\toverride toSuiAddress(): string {\n\t\treturn this.#address;\n\t}\n\n\toverride async signTransaction(bytes: Uint8Array) {\n\t\tconst headers: Record<string, string> = { 'Content-Type': 'application/json' };\n\t\tif (this.#authToken !== null) {\n\t\t\theaders['Authorization'] = `Bearer ${this.#authToken}`;\n\t\t}\n\t\tconst requestBytes = toBase64(bytes);\n\t\tconst res = await fetch(`${this.#serverOrigin}${DEVSTACK_WALLET_HTTP_PATH.SIGN_TRANSACTION}`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders,\n\t\t\tbody: JSON.stringify({\n\t\t\t\taddress: this.#address,\n\t\t\t\tbytes: requestBytes,\n\t\t\t}),\n\t\t});\n\t\tif (!res.ok) {\n\t\t\tconst body = await res.json().catch(() => ({}));\n\t\t\tconst message = (body as { error?: unknown }).error;\n\t\t\tthrow new Error(\n\t\t\t\t`Devstack signing failed: ${typeof message === 'string' ? message : res.statusText}`,\n\t\t\t);\n\t\t}\n\t\tconst { bytes: responseBytes, signature } = (await res.json()) as {\n\t\t\tbytes?: string;\n\t\t\tsignature?: string;\n\t\t};\n\t\tif (typeof responseBytes !== 'string' || responseBytes.length === 0) {\n\t\t\tthrow new Error('Devstack signing failed: server returned invalid signed bytes');\n\t\t}\n\t\tif (typeof signature !== 'string' || signature.length === 0) {\n\t\t\tthrow new Error('Devstack signing failed: server returned invalid signature');\n\t\t}\n\t\treturn {\n\t\t\tbytes: responseBytes,\n\t\t\tsignature,\n\t\t};\n\t}\n\n\toverride async signPersonalMessage(bytes: Uint8Array) {\n\t\tconst headers: Record<string, string> = { 'Content-Type': 'application/json' };\n\t\tif (this.#authToken !== null) {\n\t\t\theaders['Authorization'] = `Bearer ${this.#authToken}`;\n\t\t}\n\t\tconst res = await fetch(\n\t\t\t`${this.#serverOrigin}${DEVSTACK_WALLET_HTTP_PATH.SIGN_PERSONAL_MESSAGE}`,\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders,\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\taddress: this.#address,\n\t\t\t\t\tbytes: toBase64(bytes),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t\tif (!res.ok) {\n\t\t\tconst body = await res.json().catch(() => ({}));\n\t\t\tconst message = (body as { error?: unknown }).error;\n\t\t\tthrow new Error(\n\t\t\t\t`Devstack personal-message signing failed: ${\n\t\t\t\t\ttypeof message === 'string' ? message : res.statusText\n\t\t\t\t}`,\n\t\t\t);\n\t\t}\n\t\tconst { bytes: responseBytes, signature } = (await res.json()) as {\n\t\t\tbytes?: string;\n\t\t\tsignature?: string;\n\t\t};\n\t\tif (typeof responseBytes !== 'string' || responseBytes.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t'Devstack personal-message signing failed: server returned invalid signed bytes',\n\t\t\t);\n\t\t}\n\t\tif (typeof signature !== 'string' || signature.length === 0) {\n\t\t\tthrow new Error('Devstack personal-message signing failed: server returned no signature');\n\t\t}\n\t\treturn { bytes: responseBytes, signature };\n\t}\n}\n\nexport interface DevstackSignerAdapterOptions {\n\t/** Wallet-app origin (e.g. `http://localhost:9420`). Read from the\n\t * matching endpoint entry on the active manifest. */\n\tserverOrigin: string;\n\t/** Bearer token. Parse `?token=<hex>` from the manifest entry's\n\t * `pairUrl`. Omit if the wallet-app runs without auth. */\n\ttoken?: string | null;\n\t/** Override the adapter's display name. Defaults to `'Devstack'`. */\n\tname?: string;\n\t/** The configured network names the wallet operates on. Each is advertised\n\t * on every account as the wallet-standard chain `sui:<name>` (unioned with\n\t * the standard Sui chains) so fork/custom networks are signable. Defaults\n\t * to the standard chains only. */\n\tnetworks?: readonly string[];\n}\n\n/**\n * {@link SignerAdapter} that surfaces every account resolved by `devstack up`\n * (including `cliSigner`/`envSigner`/`generatedKeypair` slots) without\n * shipping their private keys into the frontend bundle. All signing happens\n * server-side via the `wallet()` plugin.\n *\n * The dev wallet that devstack injects at serve time registers this adapter\n * automatically from the wallet connection devstack publishes — apps wire\n * dapp-kit in their own `dapp-kit.ts` and never touch the adapter directly.\n *\n * To construct one manually (e.g. from a non-manifest source):\n *\n * ```ts\n * const adapter = new DevstackSignerAdapter({\n * serverOrigin: 'http://localhost:9420',\n * token: '<bearer hex>',\n * });\n * ```\n */\nexport class DevstackSignerAdapter extends BaseSignerAdapter {\n\treadonly id = 'devstack';\n\treadonly name: string;\n\treadonly allowAutoSign = true;\n\n\t#serverOrigin: string;\n\t#authToken: string | null;\n\t#chains: readonly `sui:${string}`[];\n\n\tconstructor(options: DevstackSignerAdapterOptions) {\n\t\tsuper();\n\t\ttry {\n\t\t\tnew URL(options.serverOrigin);\n\t\t} catch {\n\t\t\tthrow new Error(`DevstackSignerAdapter: invalid serverOrigin \"${options.serverOrigin}\"`);\n\t\t}\n\t\tthis.#serverOrigin = options.serverOrigin;\n\t\tthis.#authToken = options.token ?? null;\n\t\tthis.name = options.name ?? 'Devstack';\n\t\tthis.#chains = chainsForNetworks(options.networks);\n\t}\n\n\tasync initialize(): Promise<void> {\n\t\ttry {\n\t\t\tconst accounts = await this.#fetchAccounts();\n\t\t\tthis.setInitialAccounts(accounts);\n\t\t} catch (error) {\n\t\t\tif (error instanceof AuthError) {\n\t\t\t\tconsole.warn('[dev-wallet] devstack adapter: unauthorized — skipping account import');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconsole.warn('[dev-wallet] devstack adapter: initialization failed:', error);\n\t\t}\n\t}\n\n\toverride destroy(): void {\n\t\tthis.#authToken = null;\n\t\tsuper.destroy();\n\t}\n\n\tasync #fetchAccounts(): Promise<ManagedAccount[]> {\n\t\tconst headers: Record<string, string> = { 'Content-Type': 'application/json' };\n\t\tif (this.#authToken !== null) {\n\t\t\theaders['Authorization'] = `Bearer ${this.#authToken}`;\n\t\t}\n\t\tconst res = await fetch(`${this.#serverOrigin}${DEVSTACK_WALLET_HTTP_PATH.ACCOUNTS}`, {\n\t\t\theaders,\n\t\t});\n\t\tif (res.status === 401 || res.status === 403) throw new AuthError();\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`Failed to fetch devstack accounts: ${res.statusText}`);\n\t\t}\n\t\tconst { accounts } = (await res.json()) as { accounts: ServerAccountInfo[] };\n\t\treturn accounts.map((info) => {\n\t\t\tconst publicKey = publicKeyForScheme(info.publicKey, info.scheme);\n\t\t\tconst signer = new DevstackProxySigner({\n\t\t\t\taddress: info.address,\n\t\t\t\tpublicKey,\n\t\t\t\tscheme: info.scheme,\n\t\t\t\tserverOrigin: this.#serverOrigin,\n\t\t\t\tauthToken: this.#authToken,\n\t\t\t});\n\t\t\treturn buildManagedAccount(\n\t\t\t\tsigner,\n\t\t\t\tinfo.address,\n\t\t\t\tinfo.name,\n\t\t\t\tDEVSTACK_WALLET_FEATURES,\n\t\t\t\tthis.#chains,\n\t\t\t);\n\t\t});\n\t}\n}\n\n/**\n * Pull the bearer token off a paired URL produced by the `wallet()`\n * plugin. Returns `null` if the input is undefined, malformed, or\n * carries a `<redacted>` placeholder (the manifest's pairUrl carries\n * the redacted form; the real token lives in a sibling 0o600 file the\n * consumer reads separately).\n *\n * The token rides in the URL fragment as `#token=<hex>`.\n */\nexport function parseDevstackToken(pairedUrl: string | undefined): string | null {\n\tif (pairedUrl === undefined) return null;\n\ttry {\n\t\tconst url = new URL(pairedUrl);\n\t\tconst hash = url.hash; // e.g. \"#token=abcd\"\n\t\tif (hash.length <= 1) return null;\n\t\tconst params = new URLSearchParams(hash.slice(1));\n\t\tconst token = params.get('token');\n\t\tif (token === null || token === '<redacted>') return null;\n\t\treturn token;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** Narrow input — the only field the adapter consumes is\n * `app.wallet.{url, pairUrl}`. Codegen emits exactly this shape so the\n * generated wiring doesn't have to fabricate placeholder\n * manifest fields (`stack.app`, `coins`, etc.) just to satisfy the\n * full `Manifest` type. Mirrors a slice of `AppManifest` from\n * `@mysten-incubation/devstack` without importing it (dev-wallet\n * doesn't depend on devstack — circular). */\nexport interface DevstackAdapterManifest {\n\tapp?: {\n\t\twallet?: {\n\t\t\turl: string;\n\t\t\tpairUrl?: string;\n\t\t};\n\t};\n}\n\n/**\n * Convenience: read the wallet-app endpoint off a devstack manifest and\n * build a configured adapter, or return `null` when the entry isn't\n * present (no `wallet(...)` in the stack, or it hasn't come up yet).\n *\n * The wallet entry's `pairUrl` carries the `#token=…` fragment used to\n * extract the bearer token. The full `Manifest` shape from\n * `@mysten-incubation/devstack` is structurally compatible with\n * {@link DevstackAdapterManifest}, so\n * `createDevstackAdapterFromManifest(devstackManifest)` typechecks\n * without a cast.\n *\n * The narrow manifest shape carries no network set, so pass\n * `options.networks` (e.g. the generated `config.networkNames`) to advertise\n * fork/custom networks as `sui:<name>` on every account — matching what the\n * devstack-injected dev wallet does via the constructor. Omit it and accounts\n * advertise the standard Sui chains only.\n */\nexport function createDevstackAdapterFromManifest(\n\tmanifest: DevstackAdapterManifest,\n\toptions?: { readonly networks?: readonly string[] },\n): DevstackSignerAdapter | null {\n\tconst wallet = manifest.app?.wallet;\n\tif (wallet === undefined) return null;\n\treturn new DevstackSignerAdapter({\n\t\tserverOrigin: wallet.url,\n\t\ttoken: parseDevstackToken(wallet.pairUrl),\n\t\tnetworks: options?.networks,\n\t});\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAM,2BAA2B;CAChC;CACA;CACA;AACD;AASA,IAAM,YAAN,cAAwB,MAAM;CAC7B,cAAc;EACb,MAAM,cAAc;EACpB,KAAK,OAAO;CACb;AACD;AAEA,SAAS,mBAAmB,QAAgB,QAA6C;CACxF,MAAM,QAAQ,WAAW,MAAM;CAM/B,QAAQ,OAAO,MAAM,CAAC,CAAC,YAAY,GAAnC;EACC,KAAK,WACJ,OAAO,IAAI,iBAAiB,KAAK;EAClC,KAAK,aACJ,OAAO,IAAI,mBAAmB,KAAK;EACpC,KAAK,aACJ,OAAO,IAAI,mBAAmB,KAAK;EACpC,SACC,MAAM,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,OAAO;CACjC,OAAO,IAAI,sBAAsB;EAChC,cAAc,OAAO;EACrB,OAAO,mBAAmB,OAAO,OAAO;EACxC,UAAU,SAAS;CACpB,CAAC;AACF"}
|
package/dist/inject/index.d.mts
CHANGED
|
@@ -1,29 +1,54 @@
|
|
|
1
1
|
import { AutoApprovePolicy, DevWallet } from "../wallet/dev-wallet.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/inject/index.d.ts
|
|
4
|
-
/** Shape of a single entry in the
|
|
5
|
-
* (`
|
|
4
|
+
/** Shape of a single entry in the dev `accounts` map (resolved off the
|
|
5
|
+
* injected deployment envelope via `resolveAccounts()`). Only `address` is
|
|
6
|
+
* consumed here. */
|
|
6
7
|
interface DevstackAccountInfo {
|
|
7
8
|
readonly address: string;
|
|
8
9
|
readonly name?: string;
|
|
9
10
|
}
|
|
11
|
+
/** One network the dev wallet operates on — its routed RPC endpoint plus an
|
|
12
|
+
* optional faucet. The wallet advertises every key as the wallet-standard
|
|
13
|
+
* chain `sui:<name>` and routes signing/execution to whichever network dApp
|
|
14
|
+
* Kit has selected; the active network's `faucet` drives a fund flow. The
|
|
15
|
+
* `rpc` MUST be the SAME routed RPC the app's dApp Kit client uses for that
|
|
16
|
+
* network (a raw `127.0.0.1:9000` is CORS-blocked from the routed page
|
|
17
|
+
* origin). The wallet is agnostic to live-vs-local — local and live networks
|
|
18
|
+
* are passed through the same map. */
|
|
19
|
+
interface DevstackNetworkInfo {
|
|
20
|
+
/** Routed RPC endpoint for this network. */
|
|
21
|
+
readonly rpc: string;
|
|
22
|
+
/** Optional faucet endpoint for this network (absent on live mainnet /
|
|
23
|
+
* fork stacks). */
|
|
24
|
+
readonly faucet?: string | null;
|
|
25
|
+
}
|
|
10
26
|
interface RegisterDevstackDevWalletConfig {
|
|
11
|
-
/** Wallet-app origin (`
|
|
27
|
+
/** Wallet-app origin (the dev-wallet connection's `walletUrl`). */
|
|
12
28
|
readonly serverOrigin: string;
|
|
13
|
-
/**
|
|
29
|
+
/** Browser page origins accepted by the devstack wallet server. When the
|
|
30
|
+
* current page is not in this list, the HTTP adapter will be CORS-blocked;
|
|
31
|
+
* this is non-secret metadata used only for a local diagnostic. */
|
|
32
|
+
readonly allowedOrigins?: ReadonlyArray<string>;
|
|
33
|
+
/** Bearer pairing token (read by the Vite dev server from the wallet's
|
|
34
|
+
* `0o600` side-channel token file), or null. */
|
|
14
35
|
readonly token?: string | null;
|
|
15
|
-
/**
|
|
36
|
+
/** Dev name→account map (resolved off the injected deployment envelope via
|
|
37
|
+
* `resolveAccounts()`). */
|
|
16
38
|
readonly accounts: Readonly<Record<string, DevstackAccountInfo>>;
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
/** The FULL network set the app supports — `{ <name>: { rpc, faucet? } }`,
|
|
40
|
+
* covering BOTH the live local network and any live (devnet/testnet/…)
|
|
41
|
+
* networks the deployment envelope carries. The wallet advertises each as
|
|
42
|
+
* the wallet-standard chain `sui:<name>` and operates on whichever one
|
|
43
|
+
* dApp Kit has selected, so it persists across a UI `switchNetwork` (only
|
|
44
|
+
* the active chain changes — the wallet is registered once). When omitted
|
|
45
|
+
* the wallet falls back to a single localnet entry (the non-routed default
|
|
46
|
+
* — only correct for a bare localnet setup). */
|
|
47
|
+
readonly networks?: Readonly<Record<string, DevstackNetworkInfo>>;
|
|
48
|
+
/** The network the wallet opens on (its initial active network). Must be a
|
|
49
|
+
* key of `networks`; defaults to the first `networks` key (`'localnet'`
|
|
50
|
+
* when `networks` is omitted). */
|
|
51
|
+
readonly defaultNetwork?: string;
|
|
27
52
|
/** Auto-approve all signing requests (headless e2e). Defaults to false. */
|
|
28
53
|
readonly autoApprove?: AutoApprovePolicy;
|
|
29
54
|
/** Mount the floating wallet drawer UI. Defaults to true. */
|
|
@@ -57,5 +82,5 @@ declare global {
|
|
|
57
82
|
*/
|
|
58
83
|
declare function registerDevstackDevWallet(config: RegisterDevstackDevWalletConfig): Promise<RegisterDevstackDevWalletResult>;
|
|
59
84
|
//#endregion
|
|
60
|
-
export { DevstackAccountInfo, RegisterDevstackDevWalletConfig, RegisterDevstackDevWalletResult, registerDevstackDevWallet };
|
|
85
|
+
export { DevstackAccountInfo, DevstackNetworkInfo, RegisterDevstackDevWalletConfig, RegisterDevstackDevWalletResult, registerDevstackDevWallet };
|
|
61
86
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/inject/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/inject/index.ts"],"mappings":";;;;;AA8BA;UAAiB,mBAAA;EAAA,SACP,OAAA;EAAA,SACA,IAAI;AAAA;AAWd;;;;AAKgB;AAGhB;;;AARA,UAAiB,mBAAA;EAoB2B;EAAA,SAlBlC,GAAA;EAkBU;;EAAA,SAfV,MAAM;AAAA;AAAA,UAGC,+BAAA;EA2BwB;EAAA,SAzB/B,YAAA;EAAA;;;EAAA,SAIA,cAAA,GAAiB,aAAA;EAMjB;;EAAA,SAHA,KAAA;EAGkC;;EAAA,SAAlC,QAAA,EAAU,QAAA,CAAS,MAAA,SAAe,mBAAA;EASd;;;;;;;;EAAA,SAApB,QAAA,GAAW,QAAA,CAAS,MAAA,SAAe,mBAAA;EAa5B;;;EAAA,SATP,cAAA;EAUA;EAAA,SARA,WAAA,GAAc,iBAAA;EAUd;EAAA,SARA,OAAA;EAQO;EAAA,SANP,IAAA;AAAA;AAAA,UAGO,+BAAA;EAAA,SACP,MAAA,EAAQ,SAAS;EAMnB;EAAA,SAJE,OAAA;AAAA;;QAIF,MAAA;EAAA,IAEH,uBAAA;EAMkF;AAAA;AA+DvF;;EA/DuF,IAAlF,4BAAA,EAA8B,OAAO,CAAC,+BAAA;AAAA;;;;;;;;;;AAiED;iBAF1B,yBAAA,CACf,MAAA,EAAQ,+BAAA,GACN,OAAA,CAAQ,+BAAA"}
|
package/dist/inject/index.mjs
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import { mountAndRegisterDevWallet } from "../wallet/mount-and-register.mjs";
|
|
2
2
|
import { DevstackSignerAdapter } from "../adapters/devstack-adapter.mjs";
|
|
3
3
|
//#region src/inject/index.ts
|
|
4
|
+
const currentPageOrigin = () => {
|
|
5
|
+
const location = globalThis.location;
|
|
6
|
+
return typeof location?.origin === "string" && location.origin.length > 0 ? location.origin : null;
|
|
7
|
+
};
|
|
8
|
+
const originMatchesAllowed = (origin, allowed) => {
|
|
9
|
+
if (!allowed.includes("*")) return origin === allowed;
|
|
10
|
+
let originUrl;
|
|
11
|
+
let patternUrl;
|
|
12
|
+
try {
|
|
13
|
+
originUrl = new URL(origin);
|
|
14
|
+
patternUrl = new URL(allowed.replace("*", "devstack-origin-probe"));
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (originUrl.origin !== origin) return false;
|
|
19
|
+
if (originUrl.protocol !== patternUrl.protocol || originUrl.port !== patternUrl.port) return false;
|
|
20
|
+
const originLabels = originUrl.hostname.toLowerCase().split(".");
|
|
21
|
+
const patternLabels = patternUrl.hostname.toLowerCase().split(".");
|
|
22
|
+
return originLabels.length === patternLabels.length && patternLabels[0] === "devstack-origin-probe" && originLabels[0].length > 0 && originLabels.slice(1).join(".") === patternLabels.slice(1).join(".");
|
|
23
|
+
};
|
|
24
|
+
const assertPageOriginAllowed = (allowedOrigins) => {
|
|
25
|
+
if (allowedOrigins === void 0 || allowedOrigins.length === 0) return;
|
|
26
|
+
const origin = currentPageOrigin();
|
|
27
|
+
if (origin === null || origin === "null") return;
|
|
28
|
+
if (allowedOrigins.some((allowed) => originMatchesAllowed(origin, allowed))) return;
|
|
29
|
+
const recommended = allowedOrigins.find((allowed) => !allowed.includes("*")) ?? allowedOrigins[0];
|
|
30
|
+
const message = `[devstack] dev wallet is not available from page origin ${origin}. Allowed origins: ${allowedOrigins.join(", ")}.${recommended === void 0 ? "" : ` Open ${recommended}, or add wallet({ allowedOrigins: ['${origin}'] }) if this origin is intentional.`}`;
|
|
31
|
+
console.error(message);
|
|
32
|
+
throw new Error(`devstack dev wallet page origin ${origin} is not allowlisted`);
|
|
33
|
+
};
|
|
4
34
|
/**
|
|
5
35
|
* Construct + register the devstack dev wallet on the current page and wire
|
|
6
36
|
* the Playwright `connectAs` slot. Idempotent: a second call is a no-op and
|
|
@@ -25,14 +55,22 @@ function registerDevstackDevWallet(config) {
|
|
|
25
55
|
async function registerDevstackDevWalletImpl(config) {
|
|
26
56
|
const { mountUI = true, autoApprove = false } = config;
|
|
27
57
|
globalThis.__DEV_WALLET_INJECTED__ = true;
|
|
58
|
+
assertPageOriginAllowed(config.allowedOrigins);
|
|
59
|
+
const networkInfos = config.networks !== void 0 && Object.keys(config.networks).length > 0 ? config.networks : { localnet: { rpc: "http://127.0.0.1:9000" } };
|
|
60
|
+
const networkNames = Object.keys(networkInfos);
|
|
28
61
|
const adapter = new DevstackSignerAdapter({
|
|
29
62
|
serverOrigin: config.serverOrigin,
|
|
30
63
|
token: config.token ?? null,
|
|
31
|
-
name: config.name ?? "Devstack"
|
|
64
|
+
name: config.name ?? "Devstack",
|
|
65
|
+
networks: networkNames
|
|
32
66
|
});
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
67
|
+
const networks = {};
|
|
68
|
+
const faucets = {};
|
|
69
|
+
for (const [net, info] of Object.entries(networkInfos)) {
|
|
70
|
+
networks[net] = info.rpc;
|
|
71
|
+
if (info.faucet !== void 0 && info.faucet !== null && info.faucet.length > 0) faucets[net] = info.faucet;
|
|
72
|
+
}
|
|
73
|
+
const activeNetwork = config.defaultNetwork !== void 0 && networks[config.defaultNetwork] !== void 0 ? config.defaultNetwork : Object.keys(networks)[0] ?? "localnet";
|
|
36
74
|
const adapters = [adapter];
|
|
37
75
|
try {
|
|
38
76
|
const { WebCryptoSignerAdapter } = await import("../adapters/webcrypto-adapter.mjs");
|
|
@@ -46,6 +84,7 @@ async function registerDevstackDevWalletImpl(config) {
|
|
|
46
84
|
autoApprove,
|
|
47
85
|
autoConnect: Boolean(autoApprove),
|
|
48
86
|
networks,
|
|
87
|
+
faucets,
|
|
49
88
|
activeNetwork,
|
|
50
89
|
mountUI
|
|
51
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/inject/index.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n//\n// Page-register entry for the devstack dev wallet.\n//\n// This is the single function the devstack Vite plugin injects into a dev\n// page. It builds the token-based `DevstackSignerAdapter` (headless — signs\n// over HTTP, no popup) + the routed-RPC network map, then hands those to the\n// shared `mountAndRegisterDevWallet` core helper, which constructs the\n// `DevWallet`, registers it via wallet-standard (so dApp Kit auto-discovers\n// it), and mounts the floating wallet UI. The ONLY logic that lives here is\n// the devstack-integration glue: the adapter-from-config and the routed-RPC\n// network map.\n//\n// The wallet does NOT pre-connect or seed dApp Kit storage: a fresh page\n// loads disconnected, dApp Kit's own `autoConnect` only re-connects a genuine\n// prior session, and the Playwright `connectAs` helper performs an explicit\n// connection through dApp Kit's public API. That test bridge is registered\n// app-side via `@mysten-incubation/devstack/dapp-kit`'s\n// `registerDAppKitForTesting(dAppKit)` (DEV-only) — it needs the app's dApp\n// Kit instance, which the wallet has no reference to.\n\nimport type { SignerAdapter } from '../types.js';\nimport type { AutoApprovePolicy, DevWallet } from '../wallet/dev-wallet.js';\nimport { mountAndRegisterDevWallet } from '../wallet/mount-and-register.js';\nimport { DevstackSignerAdapter } from '../adapters/devstack-adapter.js';\n\n/** Shape of a single entry in the generated `accounts` map\n * (`generated-extras/accounts.ts`). Only `address` is consumed here. */\nexport interface DevstackAccountInfo {\n\treadonly address: string;\n\treadonly name?: string;\n}\n\nexport interface RegisterDevstackDevWalletConfig {\n\t/** Wallet-app origin (`devWallet.walletUrl`). */\n\treadonly serverOrigin: string;\n\t/** Bearer token (`parseDevstackToken(devWallet.pairUrl)`), or null. */\n\treadonly token?: string | null;\n\t/** Generated name→account map (`accounts` from `generated-extras/accounts.ts`). */\n\treadonly accounts: Readonly<Record<string, DevstackAccountInfo>>;\n\t/** RPC endpoint the wallet uses to execute `signAndExecuteTransaction`\n\t * (and simulate). MUST be the SAME routed RPC the app's dApp Kit client\n\t * uses (`config.networks[config.network].rpc`) — a raw `127.0.0.1:9000`\n\t * is CORS-blocked from the routed page origin. When omitted the wallet\n\t * falls back to localnet defaults (only correct for non-routed setups). */\n\treadonly rpcUrl?: string;\n\t/** Network name the wallet's accounts are scoped to (e.g. `'localnet'`\n\t * from `devWallet.network`). The wallet advertises the wallet-standard\n\t * chain `sui:<network>` derived from it; defaults to `localnet`. */\n\treadonly network?: string;\n\t/** Auto-approve all signing requests (headless e2e). Defaults to false. */\n\treadonly autoApprove?: AutoApprovePolicy;\n\t/** Mount the floating wallet drawer UI. Defaults to true. */\n\treadonly mountUI?: boolean;\n\t/** Wallet display name. Defaults to `'Devstack'`. */\n\treadonly name?: string;\n}\n\nexport interface RegisterDevstackDevWalletResult {\n\treadonly wallet: DevWallet;\n\t/** Unregister the wallet, unmount the UI, and tear down the adapter. */\n\treadonly dispose: () => void;\n}\n\n/** Global marker so tests / the plugin can assert injection happened. */\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __DEV_WALLET_INJECTED__: boolean | undefined;\n\t/** In-flight (or settled) registration promise. Published BEFORE the first\n\t * `await` so concurrent evaluations (HMR / double import) coalesce onto a\n\t * single registration instead of each constructing + registering + mounting\n\t * their own wallet. See `registerDevstackDevWallet`. */\n\t// eslint-disable-next-line no-var\n\tvar __devstackDevWalletPromise__: Promise<RegisterDevstackDevWalletResult> | undefined;\n}\n\n/**\n * Construct + register the devstack dev wallet on the current page and wire\n * the Playwright `connectAs` slot. Idempotent: a second call is a no-op and\n * returns the existing instance.\n *\n * Idempotency is enforced SYNCHRONOUSLY: an in-flight registration promise is\n * published on `globalThis.__devstackDevWalletPromise__` before the first\n * `await`, so two evaluations that race in before the first one finishes both\n * resolve to the SAME wallet instead of double-registering.\n */\nexport function registerDevstackDevWallet(\n\tconfig: RegisterDevstackDevWalletConfig,\n): Promise<RegisterDevstackDevWalletResult> {\n\tconst g = globalThis as {\n\t\t__devstackDevWallet__?: RegisterDevstackDevWalletResult;\n\t\t__devstackDevWalletPromise__?: Promise<RegisterDevstackDevWalletResult>;\n\t};\n\t// Fast path: a prior call already completed.\n\tif (g.__devstackDevWallet__ !== undefined) return Promise.resolve(g.__devstackDevWallet__);\n\t// In-flight path: a prior call is still booting — share its promise. This\n\t// guard runs before any `await`, so it closes the double-init window that a\n\t// post-registration-only marker leaves open under HMR / double import.\n\tif (g.__devstackDevWalletPromise__ !== undefined) return g.__devstackDevWalletPromise__;\n\n\tconst promise = registerDevstackDevWalletImpl(config);\n\tg.__devstackDevWalletPromise__ = promise;\n\t// On failure, clear the in-flight promise so a later call can retry instead\n\t// of being stuck awaiting a rejected registration.\n\tpromise.catch(() => {\n\t\tif (g.__devstackDevWalletPromise__ === promise) {\n\t\t\tg.__devstackDevWalletPromise__ = undefined;\n\t\t}\n\t});\n\treturn promise;\n}\n\nasync function registerDevstackDevWalletImpl(\n\tconfig: RegisterDevstackDevWalletConfig,\n): Promise<RegisterDevstackDevWalletResult> {\n\tconst { mountUI = true, autoApprove = false } = config;\n\tglobalThis.__DEV_WALLET_INJECTED__ = true;\n\n\tconst adapter = new DevstackSignerAdapter({\n\t\tserverOrigin: config.serverOrigin,\n\t\ttoken: config.token ?? null,\n\t\tname: config.name ?? 'Devstack',\n\t});\n\n\t// The wallet EXECUTES (and simulates) `signAndExecuteTransaction` with\n\t// its OWN client — adapter signing is HTTP (server-side keys), but\n\t// execution goes through the wallet's network client. That client MUST\n\t// hit the same routed RPC the app's dApp Kit uses (a raw 127.0.0.1 RPC\n\t// is CORS-blocked from the routed page origin).\n\t//\n\t// Expose a SINGLE network — the active stack's — so the wallet's network\n\t// switcher shows one entry that matches dApp Kit, not a list of unused\n\t// devnet/testnet/mainnet. `mountAndRegisterDevWallet` advertises the\n\t// wallet-standard chain `sui:<network>` derived from this key, matching the\n\t// `sui:<network>` dApp Kit forwards for signing — the `sui:` prefix lives\n\t// only here, at the wallet-standard boundary.\n\tconst rpcUrl = config.rpcUrl ?? 'http://127.0.0.1:9000';\n\tconst activeNetwork = config.network ?? 'localnet';\n\tconst networks: Record<string, string> = { [activeNetwork]: rpcUrl };\n\n\t// Delegate the construct → init-adapter → mount-UI → register → dispose\n\t// sequence to the shared dev-wallet core helper. The `DevstackSignerAdapter`\n\t// brings the stack's server-resolved accounts (alice/bob/carol — headless\n\t// HTTP signing) and is always present. The optional `WebCryptoSignerAdapter`\n\t// lets the user create their OWN accounts in the wallet UI, persisted in\n\t// IndexedDB across reloads (non-extractable WebCrypto keys, NOT in-memory) —\n\t// but it depends on the OPTIONAL `@mysten/signers` peer. Load it dynamically\n\t// and gate on its presence: an app that doesn't install `@mysten/signers`\n\t// still gets a working dev wallet (just without create-your-own-account)\n\t// instead of a hard inject crash on the unresolved peer. `createInitialAccount`\n\t// stays off — the devstack adapter already supplies accounts, so we never\n\t// fabricate a throwaway key; the WebCrypto adapter starts empty until the\n\t// user adds one.\n\tconst adapters: SignerAdapter[] = [adapter];\n\ttry {\n\t\tconst { WebCryptoSignerAdapter } = await import('../adapters/webcrypto-adapter.js');\n\t\tadapters.push(new WebCryptoSignerAdapter());\n\t} catch (error) {\n\t\tconsole.info(\n\t\t\t'[dev-wallet] @mysten/signers is not installed — WebCrypto account creation is ' +\n\t\t\t\t'disabled. Install @mysten/signers to enable creating your own accounts in the ' +\n\t\t\t\t'dev wallet.',\n\t\t\terror,\n\t\t);\n\t}\n\n\tconst { wallet, dispose: disposeWallet } = await mountAndRegisterDevWallet({\n\t\tadapters,\n\t\tname: config.name ?? 'Devstack',\n\t\tautoApprove,\n\t\t// Auto-approve `standard:connect` whenever signing is auto-approved — both\n\t\t// are the headless-e2e signal (`DEVSTACK_AUTO_APPROVE`). The test bridge's\n\t\t// explicit `connectWallet(...)` invokes the wallet's connect; without this\n\t\t// it would queue a pending request and block on UI approval that never\n\t\t// comes. In normal dev (no auto-approve) a human approves the connect.\n\t\tautoConnect: Boolean(autoApprove),\n\t\tnetworks,\n\t\tactiveNetwork,\n\t\tmountUI,\n\t});\n\n\tconst result: RegisterDevstackDevWalletResult = {\n\t\twallet,\n\t\tdispose() {\n\t\t\tdisposeWallet();\n\t\t\tglobalThis.__DEV_WALLET_INJECTED__ = false;\n\t\t\tdelete (globalThis as { __devstackDevWallet__?: unknown }).__devstackDevWallet__;\n\t\t\t// Clear the in-flight/settled registration promise too, so a\n\t\t\t// subsequent `registerDevstackDevWallet` re-initializes rather than\n\t\t\t// handing back the disposed instance.\n\t\t\tdelete (globalThis as { __devstackDevWalletPromise__?: unknown })\n\t\t\t\t.__devstackDevWalletPromise__;\n\t\t},\n\t};\n\t(\n\t\tglobalThis as { __devstackDevWallet__?: RegisterDevstackDevWalletResult }\n\t).__devstackDevWallet__ = result;\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;;;;AAuFA,SAAgB,0BACf,QAC2C;CAC3C,MAAM,IAAI;CAKV,IAAI,EAAE,0BAA0B,QAAW,OAAO,QAAQ,QAAQ,EAAE,qBAAqB;CAIzF,IAAI,EAAE,iCAAiC,QAAW,OAAO,EAAE;CAE3D,MAAM,UAAU,8BAA8B,MAAM;CACpD,EAAE,+BAA+B;CAGjC,QAAQ,YAAY;EACnB,IAAI,EAAE,iCAAiC,SACtC,EAAE,+BAA+B;CAEnC,CAAC;CACD,OAAO;AACR;AAEA,eAAe,8BACd,QAC2C;CAC3C,MAAM,EAAE,UAAU,MAAM,cAAc,UAAU;CAChD,WAAW,0BAA0B;CAErC,MAAM,UAAU,IAAI,sBAAsB;EACzC,cAAc,OAAO;EACrB,OAAO,OAAO,SAAS;EACvB,MAAM,OAAO,QAAQ;CACtB,CAAC;CAcD,MAAM,SAAS,OAAO,UAAU;CAChC,MAAM,gBAAgB,OAAO,WAAW;CACxC,MAAM,WAAmC,GAAG,gBAAgB,OAAO;CAenE,MAAM,WAA4B,CAAC,OAAO;CAC1C,IAAI;EACH,MAAM,EAAE,2BAA2B,MAAM,OAAO;EAChD,SAAS,KAAK,IAAI,uBAAuB,CAAC;CAC3C,SAAS,OAAO;EACf,QAAQ,KACP,2KAGA,KACD;CACD;CAEA,MAAM,EAAE,QAAQ,SAAS,kBAAkB,MAAM,0BAA0B;EAC1E;EACA,MAAM,OAAO,QAAQ;EACrB;EAMA,aAAa,QAAQ,WAAW;EAChC;EACA;EACA;CACD,CAAC;CAED,MAAM,SAA0C;EAC/C;EACA,UAAU;GACT,cAAc;GACd,WAAW,0BAA0B;GACrC,OAAQ,WAAmD;GAI3D,OAAQ,WACN;EACH;CACD;CACA,WAEE,wBAAwB;CAC1B,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/inject/index.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n//\n// Page-register entry for the devstack dev wallet.\n//\n// This is the single function the devstack Vite plugin injects into a dev\n// page. It builds the token-based `DevstackSignerAdapter` (headless — signs\n// over HTTP, no popup) + the routed-RPC network map, then hands those to the\n// shared `mountAndRegisterDevWallet` core helper, which constructs the\n// `DevWallet`, registers it via wallet-standard (so dApp Kit auto-discovers\n// it), and mounts the floating wallet UI. The ONLY logic that lives here is\n// the devstack-integration glue: the adapter-from-config and the routed-RPC\n// network map.\n//\n// The wallet does NOT pre-connect or seed dApp Kit storage: a fresh page\n// loads disconnected, dApp Kit's own `autoConnect` only re-connects a genuine\n// prior session, and the Playwright `connectAs` helper performs an explicit\n// connection through dApp Kit's public API. That test bridge is registered\n// app-side via `@mysten-incubation/devstack/dapp-kit`'s\n// `registerDAppKitForTesting(dAppKit)` (DEV-only) — it needs the app's dApp\n// Kit instance, which the wallet has no reference to.\n\nimport type { SignerAdapter } from '../types.js';\nimport type { AutoApprovePolicy, DevWallet } from '../wallet/dev-wallet.js';\nimport { mountAndRegisterDevWallet } from '../wallet/mount-and-register.js';\nimport { DevstackSignerAdapter } from '../adapters/devstack-adapter.js';\n\n/** Shape of a single entry in the dev `accounts` map (resolved off the\n * injected deployment envelope via `resolveAccounts()`). Only `address` is\n * consumed here. */\nexport interface DevstackAccountInfo {\n\treadonly address: string;\n\treadonly name?: string;\n}\n\n/** One network the dev wallet operates on — its routed RPC endpoint plus an\n * optional faucet. The wallet advertises every key as the wallet-standard\n * chain `sui:<name>` and routes signing/execution to whichever network dApp\n * Kit has selected; the active network's `faucet` drives a fund flow. The\n * `rpc` MUST be the SAME routed RPC the app's dApp Kit client uses for that\n * network (a raw `127.0.0.1:9000` is CORS-blocked from the routed page\n * origin). The wallet is agnostic to live-vs-local — local and live networks\n * are passed through the same map. */\nexport interface DevstackNetworkInfo {\n\t/** Routed RPC endpoint for this network. */\n\treadonly rpc: string;\n\t/** Optional faucet endpoint for this network (absent on live mainnet /\n\t * fork stacks). */\n\treadonly faucet?: string | null;\n}\n\nexport interface RegisterDevstackDevWalletConfig {\n\t/** Wallet-app origin (the dev-wallet connection's `walletUrl`). */\n\treadonly serverOrigin: string;\n\t/** Browser page origins accepted by the devstack wallet server. When the\n\t * current page is not in this list, the HTTP adapter will be CORS-blocked;\n\t * this is non-secret metadata used only for a local diagnostic. */\n\treadonly allowedOrigins?: ReadonlyArray<string>;\n\t/** Bearer pairing token (read by the Vite dev server from the wallet's\n\t * `0o600` side-channel token file), or null. */\n\treadonly token?: string | null;\n\t/** Dev name→account map (resolved off the injected deployment envelope via\n\t * `resolveAccounts()`). */\n\treadonly accounts: Readonly<Record<string, DevstackAccountInfo>>;\n\t/** The FULL network set the app supports — `{ <name>: { rpc, faucet? } }`,\n\t * covering BOTH the live local network and any live (devnet/testnet/…)\n\t * networks the deployment envelope carries. The wallet advertises each as\n\t * the wallet-standard chain `sui:<name>` and operates on whichever one\n\t * dApp Kit has selected, so it persists across a UI `switchNetwork` (only\n\t * the active chain changes — the wallet is registered once). When omitted\n\t * the wallet falls back to a single localnet entry (the non-routed default\n\t * — only correct for a bare localnet setup). */\n\treadonly networks?: Readonly<Record<string, DevstackNetworkInfo>>;\n\t/** The network the wallet opens on (its initial active network). Must be a\n\t * key of `networks`; defaults to the first `networks` key (`'localnet'`\n\t * when `networks` is omitted). */\n\treadonly defaultNetwork?: string;\n\t/** Auto-approve all signing requests (headless e2e). Defaults to false. */\n\treadonly autoApprove?: AutoApprovePolicy;\n\t/** Mount the floating wallet drawer UI. Defaults to true. */\n\treadonly mountUI?: boolean;\n\t/** Wallet display name. Defaults to `'Devstack'`. */\n\treadonly name?: string;\n}\n\nexport interface RegisterDevstackDevWalletResult {\n\treadonly wallet: DevWallet;\n\t/** Unregister the wallet, unmount the UI, and tear down the adapter. */\n\treadonly dispose: () => void;\n}\n\n/** Global marker so tests / the plugin can assert injection happened. */\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __DEV_WALLET_INJECTED__: boolean | undefined;\n\t/** In-flight (or settled) registration promise. Published BEFORE the first\n\t * `await` so concurrent evaluations (HMR / double import) coalesce onto a\n\t * single registration instead of each constructing + registering + mounting\n\t * their own wallet. See `registerDevstackDevWallet`. */\n\t// eslint-disable-next-line no-var\n\tvar __devstackDevWalletPromise__: Promise<RegisterDevstackDevWalletResult> | undefined;\n}\n\nconst currentPageOrigin = (): string | null => {\n\tconst location = (globalThis as { location?: { origin?: unknown } }).location;\n\treturn typeof location?.origin === 'string' && location.origin.length > 0\n\t\t? location.origin\n\t\t: null;\n};\n\nconst originMatchesAllowed = (origin: string, allowed: string): boolean => {\n\tif (!allowed.includes('*')) return origin === allowed;\n\tlet originUrl: URL;\n\tlet patternUrl: URL;\n\ttry {\n\t\toriginUrl = new URL(origin);\n\t\tpatternUrl = new URL(allowed.replace('*', 'devstack-origin-probe'));\n\t} catch {\n\t\treturn false;\n\t}\n\tif (originUrl.origin !== origin) return false;\n\tif (originUrl.protocol !== patternUrl.protocol || originUrl.port !== patternUrl.port) {\n\t\treturn false;\n\t}\n\tconst originLabels = originUrl.hostname.toLowerCase().split('.');\n\tconst patternLabels = patternUrl.hostname.toLowerCase().split('.');\n\treturn (\n\t\toriginLabels.length === patternLabels.length &&\n\t\tpatternLabels[0] === 'devstack-origin-probe' &&\n\t\toriginLabels[0]!.length > 0 &&\n\t\toriginLabels.slice(1).join('.') === patternLabels.slice(1).join('.')\n\t);\n};\n\nconst assertPageOriginAllowed = (allowedOrigins: ReadonlyArray<string> | undefined): void => {\n\tif (allowedOrigins === undefined || allowedOrigins.length === 0) return;\n\tconst origin = currentPageOrigin();\n\tif (origin === null || origin === 'null') return;\n\tif (allowedOrigins.some((allowed) => originMatchesAllowed(origin, allowed))) return;\n\n\tconst recommended = allowedOrigins.find((allowed) => !allowed.includes('*')) ?? allowedOrigins[0];\n\tconst allowedList = allowedOrigins.join(', ');\n\tconst guidance =\n\t\trecommended === undefined\n\t\t\t? ''\n\t\t\t: ` Open ${recommended}, or add wallet({ allowedOrigins: ['${origin}'] }) if this origin is intentional.`;\n\tconst message =\n\t\t`[devstack] dev wallet is not available from page origin ${origin}. ` +\n\t\t`Allowed origins: ${allowedList}.${guidance}`;\n\tconsole.error(message);\n\tthrow new Error(`devstack dev wallet page origin ${origin} is not allowlisted`);\n};\n\n/**\n * Construct + register the devstack dev wallet on the current page and wire\n * the Playwright `connectAs` slot. Idempotent: a second call is a no-op and\n * returns the existing instance.\n *\n * Idempotency is enforced SYNCHRONOUSLY: an in-flight registration promise is\n * published on `globalThis.__devstackDevWalletPromise__` before the first\n * `await`, so two evaluations that race in before the first one finishes both\n * resolve to the SAME wallet instead of double-registering.\n */\nexport function registerDevstackDevWallet(\n\tconfig: RegisterDevstackDevWalletConfig,\n): Promise<RegisterDevstackDevWalletResult> {\n\tconst g = globalThis as {\n\t\t__devstackDevWallet__?: RegisterDevstackDevWalletResult;\n\t\t__devstackDevWalletPromise__?: Promise<RegisterDevstackDevWalletResult>;\n\t};\n\t// Fast path: a prior call already completed.\n\tif (g.__devstackDevWallet__ !== undefined) return Promise.resolve(g.__devstackDevWallet__);\n\t// In-flight path: a prior call is still booting — share its promise. This\n\t// guard runs before any `await`, so it closes the double-init window that a\n\t// post-registration-only marker leaves open under HMR / double import.\n\tif (g.__devstackDevWalletPromise__ !== undefined) return g.__devstackDevWalletPromise__;\n\n\tconst promise = registerDevstackDevWalletImpl(config);\n\tg.__devstackDevWalletPromise__ = promise;\n\t// On failure, clear the in-flight promise so a later call can retry instead\n\t// of being stuck awaiting a rejected registration.\n\tpromise.catch(() => {\n\t\tif (g.__devstackDevWalletPromise__ === promise) {\n\t\t\tg.__devstackDevWalletPromise__ = undefined;\n\t\t}\n\t});\n\treturn promise;\n}\n\nasync function registerDevstackDevWalletImpl(\n\tconfig: RegisterDevstackDevWalletConfig,\n): Promise<RegisterDevstackDevWalletResult> {\n\tconst { mountUI = true, autoApprove = false } = config;\n\tglobalThis.__DEV_WALLET_INJECTED__ = true;\n\tassertPageOriginAllowed(config.allowedOrigins);\n\n\t// Resolve the FULL network set up front so it can be advertised both on\n\t// the wallet (its `chains`) and on every devstack account (per-account\n\t// `chains`) — fork/custom networks must be signable from both surfaces.\n\tconst networkInfos: Readonly<Record<string, DevstackNetworkInfo>> =\n\t\tconfig.networks !== undefined && Object.keys(config.networks).length > 0\n\t\t\t? config.networks\n\t\t\t: { localnet: { rpc: 'http://127.0.0.1:9000' } };\n\tconst networkNames = Object.keys(networkInfos);\n\n\tconst adapter = new DevstackSignerAdapter({\n\t\tserverOrigin: config.serverOrigin,\n\t\ttoken: config.token ?? null,\n\t\tname: config.name ?? 'Devstack',\n\t\tnetworks: networkNames,\n\t});\n\n\t// The wallet EXECUTES (and simulates) `signAndExecuteTransaction` with\n\t// its OWN client — adapter signing is HTTP (server-side keys), but\n\t// execution goes through the wallet's network client. That client MUST\n\t// hit the same routed RPC the app's dApp Kit uses (a raw 127.0.0.1 RPC\n\t// is CORS-blocked from the routed page origin).\n\t//\n\t// Expose the FULL network set the app supports (local + any live networks\n\t// from the deployment envelope) so the wallet operates on whichever\n\t// network dApp Kit has selected. The wallet is registered ONCE via\n\t// wallet-standard and advertises each key as the wallet-standard chain\n\t// `sui:<network>` (matching the `sui:<network>` dApp Kit forwards for\n\t// signing — the `sui:` prefix lives only at the wallet-standard boundary);\n\t// a UI `switchNetwork` just changes the active chain, it never\n\t// re-registers. The wallet does NOT know live-vs-local — both flow through\n\t// the same map. Omitting `networks` falls back to a single localnet entry\n\t// (the legacy non-routed default — resolved as `networkInfos` above).\n\tconst networks: Record<string, string> = {};\n\tconst faucets: Record<string, string> = {};\n\tfor (const [net, info] of Object.entries(networkInfos)) {\n\t\tnetworks[net] = info.rpc;\n\t\tif (info.faucet !== undefined && info.faucet !== null && info.faucet.length > 0) {\n\t\t\tfaucets[net] = info.faucet;\n\t\t}\n\t}\n\t// The wallet opens on the requested default (the dApp-Kit default network),\n\t// falling back to the first declared network.\n\tconst activeNetwork =\n\t\tconfig.defaultNetwork !== undefined && networks[config.defaultNetwork] !== undefined\n\t\t\t? config.defaultNetwork\n\t\t\t: (Object.keys(networks)[0] ?? 'localnet');\n\n\t// Delegate the construct → init-adapter → mount-UI → register → dispose\n\t// sequence to the shared dev-wallet core helper. The `DevstackSignerAdapter`\n\t// brings the stack's server-resolved accounts (alice/bob/carol — headless\n\t// HTTP signing) and is always present. The optional `WebCryptoSignerAdapter`\n\t// lets the user create their OWN accounts in the wallet UI, persisted in\n\t// IndexedDB across reloads (non-extractable WebCrypto keys, NOT in-memory) —\n\t// but it depends on the OPTIONAL `@mysten/signers` peer. Load it dynamically\n\t// and gate on its presence: an app that doesn't install `@mysten/signers`\n\t// still gets a working dev wallet (just without create-your-own-account)\n\t// instead of a hard inject crash on the unresolved peer. `createInitialAccount`\n\t// stays off — the devstack adapter already supplies accounts, so we never\n\t// fabricate a throwaway key; the WebCrypto adapter starts empty until the\n\t// user adds one.\n\tconst adapters: SignerAdapter[] = [adapter];\n\ttry {\n\t\tconst { WebCryptoSignerAdapter } = await import('../adapters/webcrypto-adapter.js');\n\t\tadapters.push(new WebCryptoSignerAdapter());\n\t} catch (error) {\n\t\tconsole.info(\n\t\t\t'[dev-wallet] @mysten/signers is not installed — WebCrypto account creation is ' +\n\t\t\t\t'disabled. Install @mysten/signers to enable creating your own accounts in the ' +\n\t\t\t\t'dev wallet.',\n\t\t\terror,\n\t\t);\n\t}\n\n\tconst { wallet, dispose: disposeWallet } = await mountAndRegisterDevWallet({\n\t\tadapters,\n\t\tname: config.name ?? 'Devstack',\n\t\tautoApprove,\n\t\t// Auto-approve `standard:connect` whenever signing is auto-approved — both\n\t\t// are the headless-e2e signal (`DEVSTACK_AUTO_APPROVE`). The test bridge's\n\t\t// explicit `connectWallet(...)` invokes the wallet's connect; without this\n\t\t// it would queue a pending request and block on UI approval that never\n\t\t// comes. In normal dev (no auto-approve) a human approves the connect.\n\t\tautoConnect: Boolean(autoApprove),\n\t\tnetworks,\n\t\tfaucets,\n\t\tactiveNetwork,\n\t\tmountUI,\n\t});\n\n\tconst result: RegisterDevstackDevWalletResult = {\n\t\twallet,\n\t\tdispose() {\n\t\t\tdisposeWallet();\n\t\t\tglobalThis.__DEV_WALLET_INJECTED__ = false;\n\t\t\tdelete (globalThis as { __devstackDevWallet__?: unknown }).__devstackDevWallet__;\n\t\t\t// Clear the in-flight/settled registration promise too, so a\n\t\t\t// subsequent `registerDevstackDevWallet` re-initializes rather than\n\t\t\t// handing back the disposed instance.\n\t\t\tdelete (globalThis as { __devstackDevWalletPromise__?: unknown })\n\t\t\t\t.__devstackDevWalletPromise__;\n\t\t},\n\t};\n\t(\n\t\tglobalThis as { __devstackDevWallet__?: RegisterDevstackDevWalletResult }\n\t).__devstackDevWallet__ = result;\n\treturn result;\n}\n"],"mappings":";;;AAuGA,MAAM,0BAAyC;CAC9C,MAAM,WAAY,W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