@xrpl-wallet-kit/adapter-gemwallet 0.3.1 → 0.3.3
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/README.md +5 -3
- package/dist/index.d.ts +13 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -21
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ When using `@xrpl-wallet-kit/client` defaults, GemWallet is already included.
|
|
|
39
39
|
- Xahau message signing uses the provider's native `signMessage()` API. The returned compact signature is not a chain-bound authentication result; domain/network/nonce binding and verification belong to the application/backend. Account/provider state is checked before and after signing.
|
|
40
40
|
- Availability is detected with `provider.isInstalled()`.
|
|
41
41
|
- `connect()` reads the active extension address and network.
|
|
42
|
-
- `restoreSession()`
|
|
42
|
+
- `restoreSession()` reads the current extension address with `getAddress()` and restores only when that address matches the stored session address. GemWallet may open its native extension window for this read.
|
|
43
43
|
- If GemWallet cannot provide a current address during restore, the adapter returns `null` instead of reviving the stored session blindly.
|
|
44
44
|
- `signAndSubmit()` routes by `methodHint`:
|
|
45
45
|
- `payment` -> `sendPayment`
|
|
@@ -53,9 +53,11 @@ When using `@xrpl-wallet-kit/client` defaults, GemWallet is already included.
|
|
|
53
53
|
|
|
54
54
|
## Auto Reconnect
|
|
55
55
|
|
|
56
|
-
GemWallet restore
|
|
56
|
+
GemWallet declares a 15-second restore budget for cold extension startup. It never retries the getters automatically. The SDK's address/network getters can open a provider-owned window; the Kit cannot guarantee popup-free reads or close that window through the SDK. A missing address, malformed response, deadline or cancellation leaves the account disconnected, and late replies cannot activate signing state.
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
GemWallet restore is intentionally conservative. The stored dApp session is not treated as proof that the extension is still connected. On reload, the adapter must read the active GemWallet address and compare it with the stored account address.
|
|
59
|
+
|
|
60
|
+
`restoreSession(session, options?)` reads the current address and, for chain-aware adapters, the current network. Xahau restore also requires the manager's registered protocol context; cached keys and RPC URLs are not trusted. Like explicit connect, the precise `{ type: "reject", result: undefined }` network response may use this trusted preset/runtime, marked `networkSource: "configured-preset"` and `providerNetworkAvailable: false`. It does not assert the wallet's network; every signed blob must pass protocol chain/intent verification before return or broadcast. Conflicting or malformed metadata and transport errors still fail closed. Restore never calls connect, signing or submission. Normal stale or unavailable states return `null`.
|
|
59
61
|
|
|
60
62
|
## Testing
|
|
61
63
|
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface GemWalletProvider {
|
|
|
21
21
|
isInstalled?: () => Promise<GemWalletBooleanResponse>;
|
|
22
22
|
isConnected?: () => Promise<GemWalletBooleanResponse>;
|
|
23
23
|
getAddress?: () => Promise<{
|
|
24
|
+
type?: string;
|
|
24
25
|
result?: {
|
|
25
26
|
address?: string;
|
|
26
27
|
};
|
|
@@ -56,6 +57,7 @@ export interface GemWalletProvider {
|
|
|
56
57
|
}
|
|
57
58
|
export declare class GemWalletAdapter extends BaseWalletAdapter {
|
|
58
59
|
private options;
|
|
60
|
+
readonly restoreSessionTimeoutMs = 15000;
|
|
59
61
|
metadata: WalletMetadata;
|
|
60
62
|
capabilities: WalletCapabilities;
|
|
61
63
|
private account?;
|
|
@@ -81,6 +83,7 @@ export declare class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
81
83
|
} | undefined;
|
|
82
84
|
raw: {
|
|
83
85
|
address: {
|
|
86
|
+
type?: string;
|
|
84
87
|
result?: {
|
|
85
88
|
address?: string;
|
|
86
89
|
};
|
|
@@ -89,20 +92,21 @@ export declare class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
89
92
|
network: GemWalletNetworkResponse | undefined;
|
|
90
93
|
};
|
|
91
94
|
}>;
|
|
92
|
-
restoreSession(session: WalletSession): Promise<{
|
|
95
|
+
restoreSession(session: WalletSession, options?: ConnectOptions): Promise<{
|
|
93
96
|
account: {
|
|
94
|
-
address: string;
|
|
95
97
|
publicKey?: string;
|
|
96
|
-
network?: import("@xrpl-wallet-kit/core").WalletNetwork;
|
|
97
98
|
networkType?: string;
|
|
99
|
+
address: string;
|
|
100
|
+
network: import("@xrpl-wallet-kit/core").WalletNetwork | undefined;
|
|
98
101
|
activationStatus?: "active" | "unfunded" | "unknown";
|
|
99
102
|
};
|
|
100
103
|
session: {
|
|
104
|
+
metadata?: Record<string, unknown>;
|
|
101
105
|
account: {
|
|
102
|
-
address: string;
|
|
103
106
|
publicKey?: string;
|
|
104
|
-
network?: import("@xrpl-wallet-kit/core").WalletNetwork;
|
|
105
107
|
networkType?: string;
|
|
108
|
+
address: string;
|
|
109
|
+
network: import("@xrpl-wallet-kit/core").WalletNetwork | undefined;
|
|
106
110
|
activationStatus?: "active" | "unfunded" | "unknown";
|
|
107
111
|
};
|
|
108
112
|
adapterId: string;
|
|
@@ -110,9 +114,11 @@ export declare class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
110
114
|
connectedAt: number;
|
|
111
115
|
expiresAt?: number;
|
|
112
116
|
balance?: import("@xrpl-wallet-kit/core").WalletSessionBalance;
|
|
113
|
-
metadata?: Record<string, unknown>;
|
|
114
117
|
};
|
|
115
|
-
raw:
|
|
118
|
+
raw: {
|
|
119
|
+
address: unknown;
|
|
120
|
+
network: GemWalletNetworkResponse | undefined;
|
|
121
|
+
};
|
|
116
122
|
} | null>;
|
|
117
123
|
signMessage(request: SignMessageRequest): Promise<{
|
|
118
124
|
signatureKind: "signature";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAkO,MAAM,uBAAuB,CAAC;AAC1R,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAyB,MAAM,uBAAuB,CAAC;AAE1O,eAAO,MAAM,cAAc,24JAA24J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ArCD,MAAM;yBAAW;oBAAE,OAAO,CAAC,EAAE,MAAM,CAAA;iBAAE;;;;;;IAgFnE,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,GAAE,cAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgDnE,WAAW,CAAC,OAAO,EAAE,kBAAkB;;;;;;qBA5HS;gBAAE,aAAa,CAAC,EAAE,MAAM,CAAA;aAAE,GAAG,IAAI;;;IAkJjF,aAAa,CAAC,OAAO,EAAE,oBAAoB;IAuB3C,UAAU;YACF,WAAW;YAcX,mBAAmB;IAe3B,eAAe,CAAC,OAAO,EAAE,sBAAsB;;;YAGvC,sBAAsB;IAkDpC,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,2BAA2B;IAoBnC,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,SAAS;IAGjB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,mBAAmB;YAGb,iBAAiB;YAWjB,YAAY;IAc1B,OAAO,CAAC,iBAAiB;IAGzB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,WAAW;CAGpB;AACD,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,oBAA2C"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@ export class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
5
5
|
constructor(options = {}) {
|
|
6
6
|
super();
|
|
7
7
|
this.options = options;
|
|
8
|
+
// Native getters may need a cold extension popup to hydrate before returning.
|
|
9
|
+
this.restoreSessionTimeoutMs = 15000;
|
|
8
10
|
this.metadata = { id: "gemwallet", name: "GemWallet", type: "extension", group: "Extensions", icon: GEMWALLET_ICON };
|
|
9
11
|
this.capabilities = { connect: true, signMessage: true, signAndSubmit: true, nftOffers: true, payments: true };
|
|
10
12
|
this.generation = 0;
|
|
@@ -71,30 +73,60 @@ export class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
71
73
|
raw: { address, publicKey: publicKey?.raw, network }
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
|
-
async restoreSession(session) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
await this.assertProviderState(provider);
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
this.account = undefined;
|
|
76
|
+
async restoreSession(session, options = {}) {
|
|
77
|
+
const generation = ++this.generation;
|
|
78
|
+
this.account = undefined;
|
|
79
|
+
this.protocolContext = undefined;
|
|
80
|
+
const assertCurrent = () => {
|
|
81
|
+
if (generation !== this.generation || options.signal?.aborted)
|
|
82
|
+
throw createWalletError.notConnected();
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
assertCurrent();
|
|
86
|
+
const network = options.network ?? session.account.network;
|
|
87
|
+
if (network && !adapterSupportsNetwork(this, network))
|
|
90
88
|
return null;
|
|
89
|
+
const externalProtocol = network && getNetworkFamily(network) !== "xrpl";
|
|
90
|
+
const context = options.protocolContext;
|
|
91
|
+
if (externalProtocol && (!context || context.protocol.family !== getNetworkFamily(network)
|
|
92
|
+
|| context.network.id !== network.id || context.network.networkId !== network.networkId
|
|
93
|
+
|| getNetworkFamily(context.network) !== getNetworkFamily(network)
|
|
94
|
+
|| context.network.networkType !== network.networkType || context.network.rpcUrl !== network.rpcUrl))
|
|
95
|
+
return null;
|
|
96
|
+
if (!await this.withAbort(() => this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500), options.signal))
|
|
97
|
+
return null;
|
|
98
|
+
assertCurrent();
|
|
99
|
+
const provider = this.getProvider();
|
|
100
|
+
const address = await this.withAbort(() => this.getCurrentAddress(provider), options.signal);
|
|
101
|
+
assertCurrent();
|
|
102
|
+
if (!address || address.accountAddress !== session.account.address)
|
|
103
|
+
return null;
|
|
104
|
+
let reported;
|
|
105
|
+
if (this.options.supportedChains) {
|
|
106
|
+
if (!network)
|
|
107
|
+
return null;
|
|
108
|
+
// Match explicit connect: unreported metadata is allowed only with a trusted protocol that verifies every signed blob.
|
|
109
|
+
reported = await this.readNetwork(provider, options.signal, assertCurrent, Boolean(externalProtocol));
|
|
110
|
+
const hint = getProviderHint(network, "gemwallet");
|
|
111
|
+
if (reported.result && (reported.result.chain !== hint.chain || this.networkName(reported.result.network) !== hint.network))
|
|
112
|
+
return null;
|
|
91
113
|
}
|
|
114
|
+
assertCurrent();
|
|
115
|
+
const account = { ...session.account, address: address.accountAddress, network,
|
|
116
|
+
...(externalProtocol ? { publicKey: undefined, networkType: this.networkName(reported?.result?.network) } : {}) };
|
|
117
|
+
this.account = account;
|
|
118
|
+
this.protocolContext = externalProtocol ? { protocol: context.protocol, network: network } : undefined;
|
|
119
|
+
return {
|
|
120
|
+
account,
|
|
121
|
+
session: { ...session, account, ...(externalProtocol ? {
|
|
122
|
+
metadata: { ...session.metadata, networkSource: reported?.result ? "provider" : "configured-preset", providerNetworkAvailable: Boolean(reported?.result) }
|
|
123
|
+
} : {}) },
|
|
124
|
+
raw: { address: address.raw, network: reported }
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return null;
|
|
92
129
|
}
|
|
93
|
-
return {
|
|
94
|
-
account: { ...session.account, address: address.accountAddress },
|
|
95
|
-
session: { ...session, account: { ...session.account, address: address.accountAddress } },
|
|
96
|
-
raw: address.raw
|
|
97
|
-
};
|
|
98
130
|
}
|
|
99
131
|
async signMessage(request) {
|
|
100
132
|
const generation = this.generation;
|
|
@@ -349,6 +381,8 @@ export class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
349
381
|
return undefined;
|
|
350
382
|
try {
|
|
351
383
|
const raw = await provider.getAddress();
|
|
384
|
+
if (raw.type === "reject")
|
|
385
|
+
return undefined;
|
|
352
386
|
const accountAddress = raw.result?.address;
|
|
353
387
|
return accountAddress ? { accountAddress, raw } : undefined;
|
|
354
388
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xrpl-wallet-kit/adapter-gemwallet",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "GemWallet adapter for XRPL Wallet Kit.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@gemwallet/api": "^3.7.0",
|
|
25
|
-
"@xrpl-wallet-kit/core": "0.3.
|
|
25
|
+
"@xrpl-wallet-kit/core": "0.3.3"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|