@moon-x/core 0.3.0 → 0.4.0
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 +1 -1
- package/dist/{chunk-CDT4MC7S.mjs → chunk-6LTEG7VN.mjs} +0 -39
- package/dist/{interfaces-CYtJHALV.d.mts → interfaces-cdKh3sLA.d.mts} +23 -0
- package/dist/{interfaces-Bm7fGOAI.d.ts → interfaces-pNTEOKaK.d.ts} +23 -0
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -47
- package/dist/lib/index.mjs +3 -15
- package/dist/passkey-cache-WnDFQ-v4.d.mts +26 -0
- package/dist/passkey-cache-WnDFQ-v4.d.ts +26 -0
- package/dist/react/index.mjs +1 -1
- package/dist/sdk/index.d.mts +30 -13
- package/dist/sdk/index.d.ts +30 -13
- package/dist/sdk/index.js +196 -95
- package/dist/sdk/index.mjs +196 -73
- package/dist/types/index.d.mts +0 -9
- package/dist/types/index.d.ts +0 -9
- package/dist/web/index.d.mts +1 -1
- package/dist/web/index.d.ts +1 -1
- package/dist/web/index.js +29 -0
- package/dist/web/index.mjs +29 -0
- package/package.json +1 -1
- package/dist/passkey-cache-B9PT3AWX.d.mts +0 -47
- package/dist/passkey-cache-B9PT3AWX.d.ts +0 -47
package/dist/sdk/index.mjs
CHANGED
|
@@ -8,13 +8,9 @@ import {
|
|
|
8
8
|
broadcastEthereumRaw,
|
|
9
9
|
broadcastSolanaSigned,
|
|
10
10
|
bs58ToBytes,
|
|
11
|
-
clearParentAssertCache,
|
|
12
|
-
readParentAssertCache,
|
|
13
11
|
serializeEthereumTransaction,
|
|
14
|
-
toB64url
|
|
15
|
-
|
|
16
|
-
writeParentAssertCache
|
|
17
|
-
} from "../chunk-CDT4MC7S.mjs";
|
|
12
|
+
toB64url
|
|
13
|
+
} from "../chunk-6LTEG7VN.mjs";
|
|
18
14
|
import "../chunk-GQKIA37O.mjs";
|
|
19
15
|
|
|
20
16
|
// src/sdk/parent-passkey-assert.ts
|
|
@@ -22,13 +18,8 @@ var assertPasskeyInParent = async ({
|
|
|
22
18
|
transport,
|
|
23
19
|
passkey,
|
|
24
20
|
publishableKey,
|
|
25
|
-
requireFreshAssertion = false,
|
|
26
21
|
validateCredentialInAllowList = false
|
|
27
22
|
}) => {
|
|
28
|
-
if (!requireFreshAssertion) {
|
|
29
|
-
const cached = readParentAssertCache();
|
|
30
|
-
if (cached) return cached;
|
|
31
|
-
}
|
|
32
23
|
const dekInfo = await transport.send(
|
|
33
24
|
PostMessageType.AUTH,
|
|
34
25
|
PostMessageMethod.GET_DEK_INFO,
|
|
@@ -52,12 +43,10 @@ var assertPasskeyInParent = async ({
|
|
|
52
43
|
if (validateCredentialInAllowList && !allowList.includes(credential.rawIdB64url)) {
|
|
53
44
|
throw new Error("unknown_passkey_for_this_account");
|
|
54
45
|
}
|
|
55
|
-
|
|
46
|
+
return {
|
|
56
47
|
userHandleB64url: credential.userHandleB64url,
|
|
57
48
|
credentialIdB64url: credential.rawIdB64url
|
|
58
49
|
};
|
|
59
|
-
writeParentAssertCache(result);
|
|
60
|
-
return result;
|
|
61
50
|
};
|
|
62
51
|
|
|
63
52
|
// src/sdk/get-presence-token.ts
|
|
@@ -89,19 +78,66 @@ var getPresenceToken = async ({
|
|
|
89
78
|
};
|
|
90
79
|
};
|
|
91
80
|
|
|
81
|
+
// src/sdk/get-internal-presence-tokens.ts
|
|
82
|
+
var getInternalPresenceTokens = async ({
|
|
83
|
+
transport,
|
|
84
|
+
passkey,
|
|
85
|
+
publishableKey,
|
|
86
|
+
relyingPartyOrigin,
|
|
87
|
+
scopes
|
|
88
|
+
}) => {
|
|
89
|
+
const { token, optionsJSON } = await transport.send(
|
|
90
|
+
PostMessageType.AUTH,
|
|
91
|
+
PostMessageMethod.PASSKEY_PRESENCE_BEGIN,
|
|
92
|
+
{ publishableKey, relyingPartyOrigin }
|
|
93
|
+
);
|
|
94
|
+
const { response, userHandleB64url, credentialIdB64url } = await passkey.assertForInternalPresence({ optionsJSON });
|
|
95
|
+
const verify = await transport.send(
|
|
96
|
+
PostMessageType.AUTH,
|
|
97
|
+
PostMessageMethod.PASSKEY_PRESENCE_VERIFY,
|
|
98
|
+
{
|
|
99
|
+
publishableKey,
|
|
100
|
+
relyingPartyOrigin,
|
|
101
|
+
token,
|
|
102
|
+
response,
|
|
103
|
+
purpose: "internal",
|
|
104
|
+
scopes
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
const out = {};
|
|
108
|
+
for (const [scope, t] of Object.entries(verify.tokens ?? {})) {
|
|
109
|
+
out[scope] = { token: t.token, expiresAt: t.expires_at };
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
tokens: out,
|
|
113
|
+
userHandleB64url,
|
|
114
|
+
credentialIdB64url
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
var flattenPresenceTokens = (result) => {
|
|
118
|
+
const out = {};
|
|
119
|
+
for (const [scope, t] of Object.entries(result.tokens)) {
|
|
120
|
+
out[scope] = t.token;
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
};
|
|
124
|
+
|
|
92
125
|
// src/sdk/headless-ethereum.ts
|
|
126
|
+
var SCOPES_SIGN = ["keyshare_read", "sign"];
|
|
93
127
|
var getHeadlessEthereumMethods = ({
|
|
94
128
|
transport,
|
|
95
129
|
passkey,
|
|
96
|
-
publishableKey
|
|
130
|
+
publishableKey,
|
|
131
|
+
relyingPartyOrigin
|
|
97
132
|
}) => ({
|
|
98
|
-
signEthereumMessageHeadless: async (params) =>
|
|
133
|
+
signEthereumMessageHeadless: async (params) => {
|
|
99
134
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
100
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
135
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
101
136
|
transport,
|
|
102
137
|
passkey,
|
|
103
138
|
publishableKey,
|
|
104
|
-
|
|
139
|
+
relyingPartyOrigin,
|
|
140
|
+
scopes: SCOPES_SIGN
|
|
105
141
|
});
|
|
106
142
|
return transport.send(
|
|
107
143
|
PostMessageType.WALLET,
|
|
@@ -112,17 +148,23 @@ var getHeadlessEthereumMethods = ({
|
|
|
112
148
|
wallet: params.wallet,
|
|
113
149
|
uiOptions: params.options?.uiOptions,
|
|
114
150
|
userHandleB64url,
|
|
115
|
-
credentialIdB64url
|
|
151
|
+
credentialIdB64url,
|
|
152
|
+
presenceTokens: flattenPresenceTokens({
|
|
153
|
+
tokens,
|
|
154
|
+
userHandleB64url,
|
|
155
|
+
credentialIdB64url
|
|
156
|
+
})
|
|
116
157
|
}
|
|
117
158
|
);
|
|
118
|
-
}
|
|
119
|
-
signEthereumTransactionHeadless: async (params) =>
|
|
159
|
+
},
|
|
160
|
+
signEthereumTransactionHeadless: async (params) => {
|
|
120
161
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
121
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
162
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
122
163
|
transport,
|
|
123
164
|
passkey,
|
|
124
165
|
publishableKey,
|
|
125
|
-
|
|
166
|
+
relyingPartyOrigin,
|
|
167
|
+
scopes: SCOPES_SIGN
|
|
126
168
|
});
|
|
127
169
|
return transport.send(
|
|
128
170
|
PostMessageType.WALLET,
|
|
@@ -134,17 +176,23 @@ var getHeadlessEthereumMethods = ({
|
|
|
134
176
|
wallet: params.wallet,
|
|
135
177
|
options: params.options,
|
|
136
178
|
userHandleB64url,
|
|
137
|
-
credentialIdB64url
|
|
179
|
+
credentialIdB64url,
|
|
180
|
+
presenceTokens: flattenPresenceTokens({
|
|
181
|
+
tokens,
|
|
182
|
+
userHandleB64url,
|
|
183
|
+
credentialIdB64url
|
|
184
|
+
})
|
|
138
185
|
}
|
|
139
186
|
);
|
|
140
|
-
}
|
|
141
|
-
signEthereumTypedDataHeadless: async (params) =>
|
|
187
|
+
},
|
|
188
|
+
signEthereumTypedDataHeadless: async (params) => {
|
|
142
189
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
143
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
190
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
144
191
|
transport,
|
|
145
192
|
passkey,
|
|
146
193
|
publishableKey,
|
|
147
|
-
|
|
194
|
+
relyingPartyOrigin,
|
|
195
|
+
scopes: SCOPES_SIGN
|
|
148
196
|
});
|
|
149
197
|
return transport.send(
|
|
150
198
|
PostMessageType.WALLET,
|
|
@@ -158,17 +206,23 @@ var getHeadlessEthereumMethods = ({
|
|
|
158
206
|
wallet: params.wallet,
|
|
159
207
|
options: params.options,
|
|
160
208
|
userHandleB64url,
|
|
161
|
-
credentialIdB64url
|
|
209
|
+
credentialIdB64url,
|
|
210
|
+
presenceTokens: flattenPresenceTokens({
|
|
211
|
+
tokens,
|
|
212
|
+
userHandleB64url,
|
|
213
|
+
credentialIdB64url
|
|
214
|
+
})
|
|
162
215
|
}
|
|
163
216
|
);
|
|
164
|
-
}
|
|
165
|
-
signEthereumHashHeadless: async (params) =>
|
|
217
|
+
},
|
|
218
|
+
signEthereumHashHeadless: async (params) => {
|
|
166
219
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
167
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
220
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
168
221
|
transport,
|
|
169
222
|
passkey,
|
|
170
223
|
publishableKey,
|
|
171
|
-
|
|
224
|
+
relyingPartyOrigin,
|
|
225
|
+
scopes: SCOPES_SIGN
|
|
172
226
|
});
|
|
173
227
|
return transport.send(
|
|
174
228
|
PostMessageType.WALLET,
|
|
@@ -179,17 +233,23 @@ var getHeadlessEthereumMethods = ({
|
|
|
179
233
|
wallet: params.wallet,
|
|
180
234
|
options: params.options,
|
|
181
235
|
userHandleB64url,
|
|
182
|
-
credentialIdB64url
|
|
236
|
+
credentialIdB64url,
|
|
237
|
+
presenceTokens: flattenPresenceTokens({
|
|
238
|
+
tokens,
|
|
239
|
+
userHandleB64url,
|
|
240
|
+
credentialIdB64url
|
|
241
|
+
})
|
|
183
242
|
}
|
|
184
243
|
);
|
|
185
|
-
}
|
|
186
|
-
signEthereum7702AuthorizationHeadless: async (params) =>
|
|
244
|
+
},
|
|
245
|
+
signEthereum7702AuthorizationHeadless: async (params) => {
|
|
187
246
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
188
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
247
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
189
248
|
transport,
|
|
190
249
|
passkey,
|
|
191
250
|
publishableKey,
|
|
192
|
-
|
|
251
|
+
relyingPartyOrigin,
|
|
252
|
+
scopes: SCOPES_SIGN
|
|
193
253
|
});
|
|
194
254
|
return transport.send(
|
|
195
255
|
PostMessageType.WALLET,
|
|
@@ -203,17 +263,23 @@ var getHeadlessEthereumMethods = ({
|
|
|
203
263
|
wallet: params.wallet,
|
|
204
264
|
options: params.options,
|
|
205
265
|
userHandleB64url,
|
|
206
|
-
credentialIdB64url
|
|
266
|
+
credentialIdB64url,
|
|
267
|
+
presenceTokens: flattenPresenceTokens({
|
|
268
|
+
tokens,
|
|
269
|
+
userHandleB64url,
|
|
270
|
+
credentialIdB64url
|
|
271
|
+
})
|
|
207
272
|
}
|
|
208
273
|
);
|
|
209
|
-
}
|
|
210
|
-
sendEthereumTransactionHeadless: async (params) =>
|
|
274
|
+
},
|
|
275
|
+
sendEthereumTransactionHeadless: async (params) => {
|
|
211
276
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
212
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
277
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
213
278
|
transport,
|
|
214
279
|
passkey,
|
|
215
280
|
publishableKey,
|
|
216
|
-
|
|
281
|
+
relyingPartyOrigin,
|
|
282
|
+
scopes: SCOPES_SIGN
|
|
217
283
|
});
|
|
218
284
|
const serializedTransaction = await serializeEthereumTransaction(
|
|
219
285
|
params.transaction
|
|
@@ -227,7 +293,12 @@ var getHeadlessEthereumMethods = ({
|
|
|
227
293
|
wallet: params.wallet,
|
|
228
294
|
options: params.options,
|
|
229
295
|
userHandleB64url,
|
|
230
|
-
credentialIdB64url
|
|
296
|
+
credentialIdB64url,
|
|
297
|
+
presenceTokens: flattenPresenceTokens({
|
|
298
|
+
tokens,
|
|
299
|
+
userHandleB64url,
|
|
300
|
+
credentialIdB64url
|
|
301
|
+
})
|
|
231
302
|
}
|
|
232
303
|
);
|
|
233
304
|
if (!signed.serializedSigned) {
|
|
@@ -240,7 +311,7 @@ var getHeadlessEthereumMethods = ({
|
|
|
240
311
|
signed.serializedSigned
|
|
241
312
|
);
|
|
242
313
|
return { hash };
|
|
243
|
-
}
|
|
314
|
+
},
|
|
244
315
|
getEthereumBalance: async (params) => {
|
|
245
316
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
246
317
|
return transport.send(
|
|
@@ -276,18 +347,21 @@ var getHeadlessEthereumMethods = ({
|
|
|
276
347
|
});
|
|
277
348
|
|
|
278
349
|
// src/sdk/headless-solana.ts
|
|
350
|
+
var SCOPES_SIGN2 = ["keyshare_read", "sign"];
|
|
279
351
|
var getHeadlessSolanaMethods = ({
|
|
280
352
|
transport,
|
|
281
353
|
passkey,
|
|
282
|
-
publishableKey
|
|
354
|
+
publishableKey,
|
|
355
|
+
relyingPartyOrigin
|
|
283
356
|
}) => ({
|
|
284
|
-
signSolanaMessageHeadless: async (params) =>
|
|
357
|
+
signSolanaMessageHeadless: async (params) => {
|
|
285
358
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
286
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
359
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
287
360
|
transport,
|
|
288
361
|
passkey,
|
|
289
362
|
publishableKey,
|
|
290
|
-
|
|
363
|
+
relyingPartyOrigin,
|
|
364
|
+
scopes: SCOPES_SIGN2
|
|
291
365
|
});
|
|
292
366
|
const { signature } = await transport.send(
|
|
293
367
|
PostMessageType.WALLET,
|
|
@@ -298,18 +372,24 @@ var getHeadlessSolanaMethods = ({
|
|
|
298
372
|
wallet: params.wallet,
|
|
299
373
|
uiOptions: params.options?.uiOptions,
|
|
300
374
|
userHandleB64url,
|
|
301
|
-
credentialIdB64url
|
|
375
|
+
credentialIdB64url,
|
|
376
|
+
presenceTokens: flattenPresenceTokens({
|
|
377
|
+
tokens,
|
|
378
|
+
userHandleB64url,
|
|
379
|
+
credentialIdB64url
|
|
380
|
+
})
|
|
302
381
|
}
|
|
303
382
|
);
|
|
304
383
|
return { signature: arrayLikeToBytes(signature) };
|
|
305
|
-
}
|
|
306
|
-
signSolanaTransactionHeadless: async (params) =>
|
|
384
|
+
},
|
|
385
|
+
signSolanaTransactionHeadless: async (params) => {
|
|
307
386
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
308
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
387
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
309
388
|
transport,
|
|
310
389
|
passkey,
|
|
311
390
|
publishableKey,
|
|
312
|
-
|
|
391
|
+
relyingPartyOrigin,
|
|
392
|
+
scopes: SCOPES_SIGN2
|
|
313
393
|
});
|
|
314
394
|
const { signedTransaction } = await transport.send(
|
|
315
395
|
PostMessageType.WALLET,
|
|
@@ -320,18 +400,24 @@ var getHeadlessSolanaMethods = ({
|
|
|
320
400
|
wallet: params.wallet,
|
|
321
401
|
options: params.options,
|
|
322
402
|
userHandleB64url,
|
|
323
|
-
credentialIdB64url
|
|
403
|
+
credentialIdB64url,
|
|
404
|
+
presenceTokens: flattenPresenceTokens({
|
|
405
|
+
tokens,
|
|
406
|
+
userHandleB64url,
|
|
407
|
+
credentialIdB64url
|
|
408
|
+
})
|
|
324
409
|
}
|
|
325
410
|
);
|
|
326
411
|
return { signedTransaction: await bs58ToBytes(signedTransaction) };
|
|
327
|
-
}
|
|
328
|
-
sendSolanaTransactionHeadless: async (params) =>
|
|
412
|
+
},
|
|
413
|
+
sendSolanaTransactionHeadless: async (params) => {
|
|
329
414
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
330
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
415
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
331
416
|
transport,
|
|
332
417
|
passkey,
|
|
333
418
|
publishableKey,
|
|
334
|
-
|
|
419
|
+
relyingPartyOrigin,
|
|
420
|
+
scopes: SCOPES_SIGN2
|
|
335
421
|
});
|
|
336
422
|
const { signedTransaction } = await transport.send(
|
|
337
423
|
PostMessageType.WALLET,
|
|
@@ -342,7 +428,12 @@ var getHeadlessSolanaMethods = ({
|
|
|
342
428
|
wallet: params.wallet,
|
|
343
429
|
options: params.options,
|
|
344
430
|
userHandleB64url,
|
|
345
|
-
credentialIdB64url
|
|
431
|
+
credentialIdB64url,
|
|
432
|
+
presenceTokens: flattenPresenceTokens({
|
|
433
|
+
tokens,
|
|
434
|
+
userHandleB64url,
|
|
435
|
+
credentialIdB64url
|
|
436
|
+
})
|
|
346
437
|
}
|
|
347
438
|
);
|
|
348
439
|
const broadcastSignature = await broadcastSolanaSigned(
|
|
@@ -350,7 +441,7 @@ var getHeadlessSolanaMethods = ({
|
|
|
350
441
|
signedTransaction
|
|
351
442
|
);
|
|
352
443
|
return { signature: await bs58ToBytes(broadcastSignature) };
|
|
353
|
-
}
|
|
444
|
+
},
|
|
354
445
|
getSolanaBalance: async (params) => {
|
|
355
446
|
if (!transport.isReady()) throw new Error("SDK not ready");
|
|
356
447
|
return transport.send(
|
|
@@ -462,11 +553,15 @@ var getHeadlessAuthenticationMethods = ({
|
|
|
462
553
|
});
|
|
463
554
|
|
|
464
555
|
// src/sdk/headless-general.ts
|
|
556
|
+
var SCOPES_CREATE_WALLET = ["dek_bootstrap", "keyshare_write"];
|
|
557
|
+
var SCOPES_IMPORT_KEY = ["dek_bootstrap", "keyshare_write"];
|
|
558
|
+
var SCOPES_REMOVE_PASSKEY = ["passkey_remove"];
|
|
465
559
|
var getHeadlessGeneralMethods = ({
|
|
466
560
|
transport,
|
|
467
561
|
passkey,
|
|
468
562
|
storage,
|
|
469
563
|
publishableKey,
|
|
564
|
+
relyingPartyOrigin,
|
|
470
565
|
setIsAuthenticated,
|
|
471
566
|
setUser
|
|
472
567
|
}) => ({
|
|
@@ -476,18 +571,34 @@ var getHeadlessGeneralMethods = ({
|
|
|
476
571
|
{ publishableKey }
|
|
477
572
|
),
|
|
478
573
|
removePasskey: async (credentialIdB64url) => {
|
|
574
|
+
const { tokens, userHandleB64url, credentialIdB64url: assertedCredId } = await getInternalPresenceTokens({
|
|
575
|
+
transport,
|
|
576
|
+
passkey,
|
|
577
|
+
publishableKey,
|
|
578
|
+
relyingPartyOrigin,
|
|
579
|
+
scopes: SCOPES_REMOVE_PASSKEY
|
|
580
|
+
});
|
|
479
581
|
await transport.send(
|
|
480
582
|
PostMessageType.AUTH,
|
|
481
583
|
PostMessageMethod.REMOVE_PASSKEY,
|
|
482
|
-
{
|
|
584
|
+
{
|
|
585
|
+
publishableKey,
|
|
586
|
+
credentialIdB64url,
|
|
587
|
+
presenceTokens: flattenPresenceTokens({
|
|
588
|
+
tokens,
|
|
589
|
+
userHandleB64url,
|
|
590
|
+
credentialIdB64url: assertedCredId
|
|
591
|
+
})
|
|
592
|
+
}
|
|
483
593
|
);
|
|
484
594
|
},
|
|
485
|
-
createWallet: (walletType, options) =>
|
|
486
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
595
|
+
createWallet: async (walletType, options) => {
|
|
596
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
487
597
|
transport,
|
|
488
598
|
passkey,
|
|
489
599
|
publishableKey,
|
|
490
|
-
|
|
600
|
+
relyingPartyOrigin,
|
|
601
|
+
scopes: SCOPES_CREATE_WALLET
|
|
491
602
|
});
|
|
492
603
|
const wallet = await transport.send(
|
|
493
604
|
PostMessageType.WALLET,
|
|
@@ -497,17 +608,23 @@ var getHeadlessGeneralMethods = ({
|
|
|
497
608
|
publishableKey,
|
|
498
609
|
options,
|
|
499
610
|
userHandleB64url,
|
|
500
|
-
credentialIdB64url
|
|
611
|
+
credentialIdB64url,
|
|
612
|
+
presenceTokens: flattenPresenceTokens({
|
|
613
|
+
tokens,
|
|
614
|
+
userHandleB64url,
|
|
615
|
+
credentialIdB64url
|
|
616
|
+
})
|
|
501
617
|
}
|
|
502
618
|
);
|
|
503
619
|
return { wallet };
|
|
504
|
-
}
|
|
505
|
-
importKey: (walletType, key
|
|
506
|
-
const { userHandleB64url, credentialIdB64url } = await
|
|
620
|
+
},
|
|
621
|
+
importKey: async (walletType, key) => {
|
|
622
|
+
const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
|
|
507
623
|
transport,
|
|
508
624
|
passkey,
|
|
509
625
|
publishableKey,
|
|
510
|
-
|
|
626
|
+
relyingPartyOrigin,
|
|
627
|
+
scopes: SCOPES_IMPORT_KEY
|
|
511
628
|
});
|
|
512
629
|
const wallet = await transport.send(
|
|
513
630
|
PostMessageType.WALLET,
|
|
@@ -517,11 +634,16 @@ var getHeadlessGeneralMethods = ({
|
|
|
517
634
|
publishableKey,
|
|
518
635
|
key,
|
|
519
636
|
userHandleB64url,
|
|
520
|
-
credentialIdB64url
|
|
637
|
+
credentialIdB64url,
|
|
638
|
+
presenceTokens: flattenPresenceTokens({
|
|
639
|
+
tokens,
|
|
640
|
+
userHandleB64url,
|
|
641
|
+
credentialIdB64url
|
|
642
|
+
})
|
|
521
643
|
}
|
|
522
644
|
);
|
|
523
645
|
return { wallet };
|
|
524
|
-
}
|
|
646
|
+
},
|
|
525
647
|
getWallets: async (walletType) => {
|
|
526
648
|
const { wallets } = await transport.send(
|
|
527
649
|
PostMessageType.WALLET,
|
|
@@ -561,7 +683,6 @@ var getHeadlessGeneralMethods = ({
|
|
|
561
683
|
await transport.send(PostMessageType.AUTH, PostMessageMethod.LOGOUT, {
|
|
562
684
|
publishableKey
|
|
563
685
|
});
|
|
564
|
-
clearParentAssertCache();
|
|
565
686
|
await storage.remove("id_token");
|
|
566
687
|
if (setIsAuthenticated) setIsAuthenticated(false);
|
|
567
688
|
if (setUser) setUser(null);
|
|
@@ -609,9 +730,11 @@ var getHeadlessGeneralMethods = ({
|
|
|
609
730
|
});
|
|
610
731
|
export {
|
|
611
732
|
assertPasskeyInParent,
|
|
733
|
+
flattenPresenceTokens,
|
|
612
734
|
getHeadlessAuthenticationMethods,
|
|
613
735
|
getHeadlessEthereumMethods,
|
|
614
736
|
getHeadlessGeneralMethods,
|
|
615
737
|
getHeadlessSolanaMethods,
|
|
738
|
+
getInternalPresenceTokens,
|
|
616
739
|
getPresenceToken
|
|
617
740
|
};
|
package/dist/types/index.d.mts
CHANGED
|
@@ -280,7 +280,6 @@ type Sign7702AuthorizationResponse = Sign7702AuthorizationResult | Sign7702Autho
|
|
|
280
280
|
interface EthereumSignMessageParams {
|
|
281
281
|
message: string;
|
|
282
282
|
wallet: PublicWallet;
|
|
283
|
-
requireFreshAssertion?: boolean;
|
|
284
283
|
options?: {
|
|
285
284
|
uiOptions?: {
|
|
286
285
|
title?: string;
|
|
@@ -298,7 +297,6 @@ interface EthereumSignMessageResult {
|
|
|
298
297
|
interface EthereumSignTransactionParams {
|
|
299
298
|
transaction: string;
|
|
300
299
|
wallet: PublicWallet;
|
|
301
|
-
requireFreshAssertion?: boolean;
|
|
302
300
|
options?: {
|
|
303
301
|
preflightCommitment?: "finalized" | "confirmed" | "processed";
|
|
304
302
|
minContextSlot?: number;
|
|
@@ -324,7 +322,6 @@ interface EthereumSignTypedDataParams {
|
|
|
324
322
|
primaryType: SignTypedDataParams["primaryType"];
|
|
325
323
|
message: SignTypedDataParams["message"];
|
|
326
324
|
wallet: PublicWallet;
|
|
327
|
-
requireFreshAssertion?: boolean;
|
|
328
325
|
options?: {
|
|
329
326
|
uiOptions?: any;
|
|
330
327
|
};
|
|
@@ -335,7 +332,6 @@ interface EthereumSignTypedDataResult {
|
|
|
335
332
|
interface EthereumSignHashParams {
|
|
336
333
|
hash: `0x${string}` | string;
|
|
337
334
|
wallet: PublicWallet;
|
|
338
|
-
requireFreshAssertion?: boolean;
|
|
339
335
|
options?: {
|
|
340
336
|
uiOptions?: any;
|
|
341
337
|
};
|
|
@@ -349,7 +345,6 @@ interface EthereumSign7702AuthorizationParams {
|
|
|
349
345
|
nonce?: number;
|
|
350
346
|
executor?: "self" | `0x${string}`;
|
|
351
347
|
wallet: PublicWallet;
|
|
352
|
-
requireFreshAssertion?: boolean;
|
|
353
348
|
options?: {
|
|
354
349
|
uiOptions?: any;
|
|
355
350
|
};
|
|
@@ -378,7 +373,6 @@ interface EthereumSendTransactionParams {
|
|
|
378
373
|
};
|
|
379
374
|
wallet: PublicWallet;
|
|
380
375
|
rpcUrl: string;
|
|
381
|
-
requireFreshAssertion?: boolean;
|
|
382
376
|
options?: {
|
|
383
377
|
commitment?: TransactionCommitment;
|
|
384
378
|
skipPreflight?: boolean;
|
|
@@ -522,7 +516,6 @@ interface UseFundWalletInterface {
|
|
|
522
516
|
interface SolanaSignMessageParams {
|
|
523
517
|
message: string;
|
|
524
518
|
wallet: PublicWallet;
|
|
525
|
-
requireFreshAssertion?: boolean;
|
|
526
519
|
options?: {
|
|
527
520
|
uiOptions?: {
|
|
528
521
|
title?: string;
|
|
@@ -541,7 +534,6 @@ interface SolanaSignMessageResult {
|
|
|
541
534
|
interface SolanaSignTransactionParams {
|
|
542
535
|
transaction: string;
|
|
543
536
|
wallet: PublicWallet;
|
|
544
|
-
requireFreshAssertion?: boolean;
|
|
545
537
|
options?: {
|
|
546
538
|
preflightCommitment?: "finalized" | "confirmed" | "processed";
|
|
547
539
|
minContextSlot?: number;
|
|
@@ -564,7 +556,6 @@ interface SolanaSendTransactionParams {
|
|
|
564
556
|
transaction: string;
|
|
565
557
|
wallet: PublicWallet;
|
|
566
558
|
rpcUrl: string;
|
|
567
|
-
requireFreshAssertion?: boolean;
|
|
568
559
|
options?: {
|
|
569
560
|
commitment?: TransactionCommitment;
|
|
570
561
|
skipPreflight?: boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -280,7 +280,6 @@ type Sign7702AuthorizationResponse = Sign7702AuthorizationResult | Sign7702Autho
|
|
|
280
280
|
interface EthereumSignMessageParams {
|
|
281
281
|
message: string;
|
|
282
282
|
wallet: PublicWallet;
|
|
283
|
-
requireFreshAssertion?: boolean;
|
|
284
283
|
options?: {
|
|
285
284
|
uiOptions?: {
|
|
286
285
|
title?: string;
|
|
@@ -298,7 +297,6 @@ interface EthereumSignMessageResult {
|
|
|
298
297
|
interface EthereumSignTransactionParams {
|
|
299
298
|
transaction: string;
|
|
300
299
|
wallet: PublicWallet;
|
|
301
|
-
requireFreshAssertion?: boolean;
|
|
302
300
|
options?: {
|
|
303
301
|
preflightCommitment?: "finalized" | "confirmed" | "processed";
|
|
304
302
|
minContextSlot?: number;
|
|
@@ -324,7 +322,6 @@ interface EthereumSignTypedDataParams {
|
|
|
324
322
|
primaryType: SignTypedDataParams["primaryType"];
|
|
325
323
|
message: SignTypedDataParams["message"];
|
|
326
324
|
wallet: PublicWallet;
|
|
327
|
-
requireFreshAssertion?: boolean;
|
|
328
325
|
options?: {
|
|
329
326
|
uiOptions?: any;
|
|
330
327
|
};
|
|
@@ -335,7 +332,6 @@ interface EthereumSignTypedDataResult {
|
|
|
335
332
|
interface EthereumSignHashParams {
|
|
336
333
|
hash: `0x${string}` | string;
|
|
337
334
|
wallet: PublicWallet;
|
|
338
|
-
requireFreshAssertion?: boolean;
|
|
339
335
|
options?: {
|
|
340
336
|
uiOptions?: any;
|
|
341
337
|
};
|
|
@@ -349,7 +345,6 @@ interface EthereumSign7702AuthorizationParams {
|
|
|
349
345
|
nonce?: number;
|
|
350
346
|
executor?: "self" | `0x${string}`;
|
|
351
347
|
wallet: PublicWallet;
|
|
352
|
-
requireFreshAssertion?: boolean;
|
|
353
348
|
options?: {
|
|
354
349
|
uiOptions?: any;
|
|
355
350
|
};
|
|
@@ -378,7 +373,6 @@ interface EthereumSendTransactionParams {
|
|
|
378
373
|
};
|
|
379
374
|
wallet: PublicWallet;
|
|
380
375
|
rpcUrl: string;
|
|
381
|
-
requireFreshAssertion?: boolean;
|
|
382
376
|
options?: {
|
|
383
377
|
commitment?: TransactionCommitment;
|
|
384
378
|
skipPreflight?: boolean;
|
|
@@ -522,7 +516,6 @@ interface UseFundWalletInterface {
|
|
|
522
516
|
interface SolanaSignMessageParams {
|
|
523
517
|
message: string;
|
|
524
518
|
wallet: PublicWallet;
|
|
525
|
-
requireFreshAssertion?: boolean;
|
|
526
519
|
options?: {
|
|
527
520
|
uiOptions?: {
|
|
528
521
|
title?: string;
|
|
@@ -541,7 +534,6 @@ interface SolanaSignMessageResult {
|
|
|
541
534
|
interface SolanaSignTransactionParams {
|
|
542
535
|
transaction: string;
|
|
543
536
|
wallet: PublicWallet;
|
|
544
|
-
requireFreshAssertion?: boolean;
|
|
545
537
|
options?: {
|
|
546
538
|
preflightCommitment?: "finalized" | "confirmed" | "processed";
|
|
547
539
|
minContextSlot?: number;
|
|
@@ -564,7 +556,6 @@ interface SolanaSendTransactionParams {
|
|
|
564
556
|
transaction: string;
|
|
565
557
|
wallet: PublicWallet;
|
|
566
558
|
rpcUrl: string;
|
|
567
|
-
requireFreshAssertion?: boolean;
|
|
568
559
|
options?: {
|
|
569
560
|
commitment?: TransactionCommitment;
|
|
570
561
|
skipPreflight?: boolean;
|
package/dist/web/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { P as PostMessageClient } from '../post-message-CmgAfkOS.mjs';
|
|
2
|
-
import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-
|
|
2
|
+
import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-cdKh3sLA.mjs';
|
|
3
3
|
|
|
4
4
|
declare const getCachedPostMessageClient: (contentWindow: Window) => PostMessageClient;
|
|
5
5
|
/**
|
package/dist/web/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { P as PostMessageClient } from '../post-message-CmgAfkOS.js';
|
|
2
|
-
import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-
|
|
2
|
+
import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-pNTEOKaK.js';
|
|
3
3
|
|
|
4
4
|
declare const getCachedPostMessageClient: (contentWindow: Window) => PostMessageClient;
|
|
5
5
|
/**
|
package/dist/web/index.js
CHANGED
|
@@ -338,6 +338,35 @@ var createWebAuthnPasskey = () => ({
|
|
|
338
338
|
authenticatorAttachment: result.authenticatorAttachment
|
|
339
339
|
};
|
|
340
340
|
return sanitized;
|
|
341
|
+
},
|
|
342
|
+
assertForInternalPresence: async ({ optionsJSON }) => {
|
|
343
|
+
const result = await (0, import_browser.startAuthentication)({
|
|
344
|
+
optionsJSON: {
|
|
345
|
+
...optionsJSON,
|
|
346
|
+
allowCredentials: []
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
if (!result.response.userHandle) {
|
|
350
|
+
throw new Error("user_handle_missing");
|
|
351
|
+
}
|
|
352
|
+
const sanitized = {
|
|
353
|
+
id: result.id,
|
|
354
|
+
rawId: result.rawId,
|
|
355
|
+
type: result.type,
|
|
356
|
+
response: {
|
|
357
|
+
clientDataJSON: result.response.clientDataJSON,
|
|
358
|
+
authenticatorData: result.response.authenticatorData,
|
|
359
|
+
signature: result.response.signature,
|
|
360
|
+
userHandle: void 0
|
|
361
|
+
},
|
|
362
|
+
clientExtensionResults: result.clientExtensionResults,
|
|
363
|
+
authenticatorAttachment: result.authenticatorAttachment
|
|
364
|
+
};
|
|
365
|
+
return {
|
|
366
|
+
response: sanitized,
|
|
367
|
+
userHandleB64url: result.response.userHandle,
|
|
368
|
+
credentialIdB64url: result.rawId
|
|
369
|
+
};
|
|
341
370
|
}
|
|
342
371
|
});
|
|
343
372
|
|