@moon-x/core 0.9.0 → 0.10.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/dist/{chunk-I56GRKAG.mjs → chunk-T3ESQWEP.mjs} +4 -4
- package/dist/{chunk-KRZVIDBQ.mjs → chunk-Z57WM6IO.mjs} +16 -9
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -9
- package/dist/index.mjs +1 -1
- package/dist/{interfaces-CF5UrEBb.d.mts → interfaces-Bt5CAMSt.d.mts} +1 -1
- package/dist/{interfaces-B5zxo2Jx.d.ts → interfaces-pGbKBjWD.d.ts} +1 -1
- package/dist/lib/index.js +4 -4
- package/dist/lib/index.mjs +1 -1
- package/dist/{post-message-2NAnU0Lf.d.mts → post-message-BR2NClJ5.d.mts} +4 -1
- package/dist/{post-message-2NAnU0Lf.d.ts → post-message-BR2NClJ5.d.ts} +4 -1
- package/dist/react/index.mjs +1 -1
- package/dist/sdk/index.d.mts +15 -5
- package/dist/sdk/index.d.ts +15 -5
- package/dist/sdk/index.js +47 -10
- package/dist/sdk/index.mjs +41 -12
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +16 -9
- package/dist/utils/index.mjs +1 -1
- package/dist/web/index.d.mts +2 -2
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.js +16 -9
- package/dist/web/index.mjs +1 -1
- package/package.json +4 -3
|
@@ -511,7 +511,7 @@ function createManualSiweMessage({
|
|
|
511
511
|
let siweMessage = `${domain} wants you to sign in with your Ethereum account:
|
|
512
512
|
`;
|
|
513
513
|
siweMessage += `${checksummedAddress}`;
|
|
514
|
-
const defaultStatement = `Sign in with Ethereum to
|
|
514
|
+
const defaultStatement = `Sign in with Ethereum to MoonX using ${walletName}.`;
|
|
515
515
|
siweMessage += `
|
|
516
516
|
|
|
517
517
|
${statement || defaultStatement}`;
|
|
@@ -1285,12 +1285,12 @@ async function getSOLTransfersFromInstructions(base64Transaction, logs, solPrice
|
|
|
1285
1285
|
// src/lib/build-url.ts
|
|
1286
1286
|
var buildUrl = (baseUrl, sdkConfig, enableCaptcha, captchaSitekey) => {
|
|
1287
1287
|
if (!sdkConfig.publishableKey) {
|
|
1288
|
-
throw new Error("
|
|
1288
|
+
throw new Error("MoonX SDK Error: Publishable Key is required");
|
|
1289
1289
|
}
|
|
1290
1290
|
if (!baseUrl || typeof baseUrl !== "string" || baseUrl === "null" || baseUrl === "undefined") {
|
|
1291
1291
|
console.error("Invalid baseUrl:", baseUrl);
|
|
1292
1292
|
throw new Error(
|
|
1293
|
-
`
|
|
1293
|
+
`MoonX SDK Error: Invalid base URL provided: "${baseUrl}"`
|
|
1294
1294
|
);
|
|
1295
1295
|
}
|
|
1296
1296
|
if (typeof window === "undefined") {
|
|
@@ -1324,7 +1324,7 @@ var buildUrl = (baseUrl, sdkConfig, enableCaptcha, captchaSitekey) => {
|
|
|
1324
1324
|
return url.toString();
|
|
1325
1325
|
} catch (error) {
|
|
1326
1326
|
throw new Error(
|
|
1327
|
-
`
|
|
1327
|
+
`MoonX SDK Error: Invalid base URL "${baseUrl}": ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1328
1328
|
);
|
|
1329
1329
|
}
|
|
1330
1330
|
};
|
|
@@ -200,12 +200,13 @@ var PostMessageServer = class {
|
|
|
200
200
|
if (queued?.length) {
|
|
201
201
|
this.pending.delete(key);
|
|
202
202
|
const now = Date.now();
|
|
203
|
-
for (const { request, reply, at } of queued) {
|
|
203
|
+
for (const { request, reply, at, ctx } of queued) {
|
|
204
204
|
if (now - at < QUEUE_TTL_MS) {
|
|
205
205
|
void this.invokeHandler(
|
|
206
206
|
handler,
|
|
207
207
|
request,
|
|
208
|
-
reply
|
|
208
|
+
reply,
|
|
209
|
+
ctx
|
|
209
210
|
);
|
|
210
211
|
}
|
|
211
212
|
}
|
|
@@ -257,7 +258,7 @@ var PostMessageServer = class {
|
|
|
257
258
|
id: request.id,
|
|
258
259
|
type: request.type,
|
|
259
260
|
success: false,
|
|
260
|
-
error: `Origin ${event.origin} is not whitelisted. Please add it to your
|
|
261
|
+
error: `Origin ${event.origin} is not whitelisted. Please add it to your MoonX dashboard.`
|
|
261
262
|
});
|
|
262
263
|
return;
|
|
263
264
|
}
|
|
@@ -274,14 +275,20 @@ var PostMessageServer = class {
|
|
|
274
275
|
const key = `${request.type}:${request.method}`;
|
|
275
276
|
const handler = this.handlers.get(key);
|
|
276
277
|
if (handler) {
|
|
277
|
-
await this.invokeHandler(handler, request, reply
|
|
278
|
+
await this.invokeHandler(handler, request, reply, {
|
|
279
|
+
origin: event.origin,
|
|
280
|
+
source: event.source
|
|
281
|
+
});
|
|
278
282
|
} else {
|
|
279
|
-
this.bufferRequest(key, request, reply
|
|
283
|
+
this.bufferRequest(key, request, reply, {
|
|
284
|
+
origin: event.origin,
|
|
285
|
+
source: event.source
|
|
286
|
+
});
|
|
280
287
|
}
|
|
281
288
|
}
|
|
282
|
-
async invokeHandler(handler, request, reply) {
|
|
289
|
+
async invokeHandler(handler, request, reply, ctx) {
|
|
283
290
|
try {
|
|
284
|
-
const data = await handler(request.payload);
|
|
291
|
+
const data = await handler(request.payload, ctx);
|
|
285
292
|
reply({
|
|
286
293
|
id: request.id,
|
|
287
294
|
type: request.type,
|
|
@@ -305,14 +312,14 @@ var PostMessageServer = class {
|
|
|
305
312
|
});
|
|
306
313
|
}
|
|
307
314
|
}
|
|
308
|
-
bufferRequest(key, request, reply) {
|
|
315
|
+
bufferRequest(key, request, reply, ctx) {
|
|
309
316
|
this.evictExpiredPending();
|
|
310
317
|
let queue = this.pending.get(key);
|
|
311
318
|
if (!queue) {
|
|
312
319
|
queue = [];
|
|
313
320
|
this.pending.set(key, queue);
|
|
314
321
|
}
|
|
315
|
-
queue.push({ request, reply, at: Date.now() });
|
|
322
|
+
queue.push({ request, reply, at: Date.now(), ctx });
|
|
316
323
|
if (queue.length > MAX_PENDING_PER_KEY) {
|
|
317
324
|
queue.splice(0, queue.length - MAX_PENDING_PER_KEY);
|
|
318
325
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { AccessTokenClaims, AppConfigRequest, AppConfigResponse, AttachOAuthTokenRequest, AttachOAuthTokenResponse, AuthAppearance, AuthFlow, AuthFlowComponent, AuthLoginMethod, AuthProviderConfig, BaseGetBalanceParams, BaseGetBalanceResult, BaseGetTokenAccountsParams, BaseSendTransactionParams, BaseSendTransactionResult, BaseSignMessageParams, BaseSignMessageResult, BaseSignTransactionParams, BaseSignTransactionResult, BaseTokenClaims, BaseUIOptions, BaseWalletHooks, BlockExplorer, Chain, ChainLikeWithId, ContractUIOptions, CreateWalletResponse, DefaultFundingMethod, DeleteSessionRequest, DeleteSessionResponse, DetachOAuthTokenRequest, DeviceFingerprint, DisplayMode, EmailOtpConfig, EmailOtpFlowState, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumChainConfig, EthereumFundingConfig, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, EthereumSendTransactionParams, EthereumSendTransactionRequest, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSwitchChainParams, ExportKeyConfig, Factor, FlexibleTheme, FundWalletConfig, FundingEvents, FundingMethod, FundingUIConfig, GetCurrentSessionRequest, GetCurrentSessionResponse, Hex, IdentityTokenClaims, IdpProvider, IsAuthenticatedRequest, IsAuthenticatedResponse, ListEphemeralSignersResult, LoginTokenBundle, LogoutRequest, LogoutResponse, MessageTypeProperty, MessageTypes, MoonKeyThemeConfig, MoonPaySignRequest, MoonPaySignResponse, MpcKeyShares, NativeCurrency, Network, OAuthRequest, OAuthResponse, OnrampFundingSettings, PasskeyEnrollConfig, PasskeySettings, PreferredCardProvider, PrefillConfig, PresenceTokenClaims, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicEthereumWallet, PublicSessionData, PublicWallet, RefreshSessionRequest, RefreshSessionResponse, RetrieveWalletKeyRequest, RetrieveWalletKeyResponse, RevokeEphemeralSignerParams, RpcConfig, RpcUrls, SdkSettings, SendEmailOtpRequest, SendEmailOtpResponse, SendTransactionConfig, SendTransactionRequest, SessionData, SessionWallet, SharesDeviceRequest, SharesDeviceResponse, Sign7702AuthorizationError, Sign7702AuthorizationParams, Sign7702AuthorizationResponse, Sign7702AuthorizationResult, SignMessageConfig, SignTransactionConfig, SignTypedDataError, SignTypedDataParams, SignTypedDataResponse, SignTypedDataResult, SmsSettings, SolanaChain, SolanaFundingConfig, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, TransactionCommitment, TransactionEncoding, TransactionUIOptions, TypedMessage, UseFundWalletInterface, UsersMePublicResponse, UsersMeRequest, UsersMeResponse, VerifiedSession, VerifyEmailOtpRequest, VerifyEmailOtpResponse, VerifyEmailOtpUser, VerifyOAuthTokenRequest, VerifyOAuthTokenResponse, VerifySiweWalletRegistrationRequest, WALLET_ERROR_CODES, Wallet, WalletChain, WalletChainType, WalletConnectConfig, WalletCreationError, WalletError, WalletErrorCode, WalletKeyRequest, WalletListEntry, WalletRegistrationNonceRequest, WalletRegistrationNonceResponse, WalletType, WalletVerifyRequest } from './types/index.mjs';
|
|
2
2
|
export { getIframeOrigin, getIframeUrl, getMoonKeyApiUrl } from './utils/index.mjs';
|
|
3
|
-
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from './post-message-
|
|
3
|
+
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from './post-message-BR2NClJ5.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { AccessTokenClaims, AppConfigRequest, AppConfigResponse, AttachOAuthTokenRequest, AttachOAuthTokenResponse, AuthAppearance, AuthFlow, AuthFlowComponent, AuthLoginMethod, AuthProviderConfig, BaseGetBalanceParams, BaseGetBalanceResult, BaseGetTokenAccountsParams, BaseSendTransactionParams, BaseSendTransactionResult, BaseSignMessageParams, BaseSignMessageResult, BaseSignTransactionParams, BaseSignTransactionResult, BaseTokenClaims, BaseUIOptions, BaseWalletHooks, BlockExplorer, Chain, ChainLikeWithId, ContractUIOptions, CreateWalletResponse, DefaultFundingMethod, DeleteSessionRequest, DeleteSessionResponse, DetachOAuthTokenRequest, DeviceFingerprint, DisplayMode, EmailOtpConfig, EmailOtpFlowState, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumChainConfig, EthereumFundingConfig, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, EthereumSendTransactionParams, EthereumSendTransactionRequest, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSwitchChainParams, ExportKeyConfig, Factor, FlexibleTheme, FundWalletConfig, FundingEvents, FundingMethod, FundingUIConfig, GetCurrentSessionRequest, GetCurrentSessionResponse, Hex, IdentityTokenClaims, IdpProvider, IsAuthenticatedRequest, IsAuthenticatedResponse, ListEphemeralSignersResult, LoginTokenBundle, LogoutRequest, LogoutResponse, MessageTypeProperty, MessageTypes, MoonKeyThemeConfig, MoonPaySignRequest, MoonPaySignResponse, MpcKeyShares, NativeCurrency, Network, OAuthRequest, OAuthResponse, OnrampFundingSettings, PasskeyEnrollConfig, PasskeySettings, PreferredCardProvider, PrefillConfig, PresenceTokenClaims, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicEthereumWallet, PublicSessionData, PublicWallet, RefreshSessionRequest, RefreshSessionResponse, RetrieveWalletKeyRequest, RetrieveWalletKeyResponse, RevokeEphemeralSignerParams, RpcConfig, RpcUrls, SdkSettings, SendEmailOtpRequest, SendEmailOtpResponse, SendTransactionConfig, SendTransactionRequest, SessionData, SessionWallet, SharesDeviceRequest, SharesDeviceResponse, Sign7702AuthorizationError, Sign7702AuthorizationParams, Sign7702AuthorizationResponse, Sign7702AuthorizationResult, SignMessageConfig, SignTransactionConfig, SignTypedDataError, SignTypedDataParams, SignTypedDataResponse, SignTypedDataResult, SmsSettings, SolanaChain, SolanaFundingConfig, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, TransactionCommitment, TransactionEncoding, TransactionUIOptions, TypedMessage, UseFundWalletInterface, UsersMePublicResponse, UsersMeRequest, UsersMeResponse, VerifiedSession, VerifyEmailOtpRequest, VerifyEmailOtpResponse, VerifyEmailOtpUser, VerifyOAuthTokenRequest, VerifyOAuthTokenResponse, VerifySiweWalletRegistrationRequest, WALLET_ERROR_CODES, Wallet, WalletChain, WalletChainType, WalletConnectConfig, WalletCreationError, WalletError, WalletErrorCode, WalletKeyRequest, WalletListEntry, WalletRegistrationNonceRequest, WalletRegistrationNonceResponse, WalletType, WalletVerifyRequest } from './types/index.js';
|
|
2
2
|
export { getIframeOrigin, getIframeUrl, getMoonKeyApiUrl } from './utils/index.js';
|
|
3
|
-
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from './post-message-
|
|
3
|
+
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from './post-message-BR2NClJ5.js';
|
package/dist/index.js
CHANGED
|
@@ -326,12 +326,13 @@ var PostMessageServer = class {
|
|
|
326
326
|
if (queued?.length) {
|
|
327
327
|
this.pending.delete(key);
|
|
328
328
|
const now = Date.now();
|
|
329
|
-
for (const { request, reply, at } of queued) {
|
|
329
|
+
for (const { request, reply, at, ctx } of queued) {
|
|
330
330
|
if (now - at < QUEUE_TTL_MS) {
|
|
331
331
|
void this.invokeHandler(
|
|
332
332
|
handler,
|
|
333
333
|
request,
|
|
334
|
-
reply
|
|
334
|
+
reply,
|
|
335
|
+
ctx
|
|
335
336
|
);
|
|
336
337
|
}
|
|
337
338
|
}
|
|
@@ -383,7 +384,7 @@ var PostMessageServer = class {
|
|
|
383
384
|
id: request.id,
|
|
384
385
|
type: request.type,
|
|
385
386
|
success: false,
|
|
386
|
-
error: `Origin ${event.origin} is not whitelisted. Please add it to your
|
|
387
|
+
error: `Origin ${event.origin} is not whitelisted. Please add it to your MoonX dashboard.`
|
|
387
388
|
});
|
|
388
389
|
return;
|
|
389
390
|
}
|
|
@@ -400,14 +401,20 @@ var PostMessageServer = class {
|
|
|
400
401
|
const key = `${request.type}:${request.method}`;
|
|
401
402
|
const handler = this.handlers.get(key);
|
|
402
403
|
if (handler) {
|
|
403
|
-
await this.invokeHandler(handler, request, reply
|
|
404
|
+
await this.invokeHandler(handler, request, reply, {
|
|
405
|
+
origin: event.origin,
|
|
406
|
+
source: event.source
|
|
407
|
+
});
|
|
404
408
|
} else {
|
|
405
|
-
this.bufferRequest(key, request, reply
|
|
409
|
+
this.bufferRequest(key, request, reply, {
|
|
410
|
+
origin: event.origin,
|
|
411
|
+
source: event.source
|
|
412
|
+
});
|
|
406
413
|
}
|
|
407
414
|
}
|
|
408
|
-
async invokeHandler(handler, request, reply) {
|
|
415
|
+
async invokeHandler(handler, request, reply, ctx) {
|
|
409
416
|
try {
|
|
410
|
-
const data = await handler(request.payload);
|
|
417
|
+
const data = await handler(request.payload, ctx);
|
|
411
418
|
reply({
|
|
412
419
|
id: request.id,
|
|
413
420
|
type: request.type,
|
|
@@ -431,14 +438,14 @@ var PostMessageServer = class {
|
|
|
431
438
|
});
|
|
432
439
|
}
|
|
433
440
|
}
|
|
434
|
-
bufferRequest(key, request, reply) {
|
|
441
|
+
bufferRequest(key, request, reply, ctx) {
|
|
435
442
|
this.evictExpiredPending();
|
|
436
443
|
let queue = this.pending.get(key);
|
|
437
444
|
if (!queue) {
|
|
438
445
|
queue = [];
|
|
439
446
|
this.pending.set(key, queue);
|
|
440
447
|
}
|
|
441
|
-
queue.push({ request, reply, at: Date.now() });
|
|
448
|
+
queue.push({ request, reply, at: Date.now(), ctx });
|
|
442
449
|
if (queue.length > MAX_PENDING_PER_KEY) {
|
|
443
450
|
queue.splice(0, queue.length - MAX_PENDING_PER_KEY);
|
|
444
451
|
}
|
package/dist/index.mjs
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -597,7 +597,7 @@ function createManualSiweMessage({
|
|
|
597
597
|
let siweMessage = `${domain} wants you to sign in with your Ethereum account:
|
|
598
598
|
`;
|
|
599
599
|
siweMessage += `${checksummedAddress}`;
|
|
600
|
-
const defaultStatement = `Sign in with Ethereum to
|
|
600
|
+
const defaultStatement = `Sign in with Ethereum to MoonX using ${walletName}.`;
|
|
601
601
|
siweMessage += `
|
|
602
602
|
|
|
603
603
|
${statement || defaultStatement}`;
|
|
@@ -1371,12 +1371,12 @@ async function getSOLTransfersFromInstructions(base64Transaction, logs, solPrice
|
|
|
1371
1371
|
// src/lib/build-url.ts
|
|
1372
1372
|
var buildUrl = (baseUrl, sdkConfig, enableCaptcha, captchaSitekey) => {
|
|
1373
1373
|
if (!sdkConfig.publishableKey) {
|
|
1374
|
-
throw new Error("
|
|
1374
|
+
throw new Error("MoonX SDK Error: Publishable Key is required");
|
|
1375
1375
|
}
|
|
1376
1376
|
if (!baseUrl || typeof baseUrl !== "string" || baseUrl === "null" || baseUrl === "undefined") {
|
|
1377
1377
|
console.error("Invalid baseUrl:", baseUrl);
|
|
1378
1378
|
throw new Error(
|
|
1379
|
-
`
|
|
1379
|
+
`MoonX SDK Error: Invalid base URL provided: "${baseUrl}"`
|
|
1380
1380
|
);
|
|
1381
1381
|
}
|
|
1382
1382
|
if (typeof window === "undefined") {
|
|
@@ -1410,7 +1410,7 @@ var buildUrl = (baseUrl, sdkConfig, enableCaptcha, captchaSitekey) => {
|
|
|
1410
1410
|
return url.toString();
|
|
1411
1411
|
} catch (error) {
|
|
1412
1412
|
throw new Error(
|
|
1413
|
-
`
|
|
1413
|
+
`MoonX SDK Error: Invalid base URL "${baseUrl}": ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1414
1414
|
);
|
|
1415
1415
|
}
|
|
1416
1416
|
};
|
package/dist/lib/index.mjs
CHANGED
|
@@ -66,7 +66,10 @@ declare class PostMessageServer {
|
|
|
66
66
|
constructor(originValidator?: (origin: string, publishableKey?: string) => Promise<boolean>);
|
|
67
67
|
addTrustedSource(source: Window): void;
|
|
68
68
|
removeTrustedSource(source: Window): void;
|
|
69
|
-
register<Payload, Response>(type: PostMessageType, method: string, handler: (payload: Payload
|
|
69
|
+
register<Payload, Response>(type: PostMessageType, method: string, handler: (payload: Payload, ctx?: {
|
|
70
|
+
origin: string;
|
|
71
|
+
source: MessageEventSource | null;
|
|
72
|
+
}) => Promise<Response | void>): void;
|
|
70
73
|
cleanup(): void;
|
|
71
74
|
private static isLocalhostOrigin;
|
|
72
75
|
private isValidPostMessageRequest;
|
|
@@ -66,7 +66,10 @@ declare class PostMessageServer {
|
|
|
66
66
|
constructor(originValidator?: (origin: string, publishableKey?: string) => Promise<boolean>);
|
|
67
67
|
addTrustedSource(source: Window): void;
|
|
68
68
|
removeTrustedSource(source: Window): void;
|
|
69
|
-
register<Payload, Response>(type: PostMessageType, method: string, handler: (payload: Payload
|
|
69
|
+
register<Payload, Response>(type: PostMessageType, method: string, handler: (payload: Payload, ctx?: {
|
|
70
|
+
origin: string;
|
|
71
|
+
source: MessageEventSource | null;
|
|
72
|
+
}) => Promise<Response | void>): void;
|
|
70
73
|
cleanup(): void;
|
|
71
74
|
private static isLocalhostOrigin;
|
|
72
75
|
private isValidPostMessageRequest;
|
package/dist/react/index.mjs
CHANGED
package/dist/sdk/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { T as Transport, P as PasskeyAssertor, R as RelyingPartyOriginInput, K as KvStorage } from '../interfaces-
|
|
2
|
-
export { O as OAuthOpener, a as PlatformImpls, W as WebAuthnAssertionResponse, b as WebAuthnRequestOptions, r as resolveRelyingPartyOrigin } from '../interfaces-
|
|
1
|
+
import { T as Transport, P as PasskeyAssertor, R as RelyingPartyOriginInput, K as KvStorage } from '../interfaces-Bt5CAMSt.mjs';
|
|
2
|
+
export { O as OAuthOpener, a as PlatformImpls, W as WebAuthnAssertionResponse, b as WebAuthnRequestOptions, r as resolveRelyingPartyOrigin } from '../interfaces-Bt5CAMSt.mjs';
|
|
3
3
|
import { C as CachedAssertion } from '../passkey-cache-WnDFQ-v4.mjs';
|
|
4
4
|
import { EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SendEmailOtpResponse, PublicWallet, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, ListEphemeralSignersResult, RevokeEphemeralSignerParams } from '../types/index.mjs';
|
|
5
|
-
import '../post-message-
|
|
5
|
+
import '../post-message-BR2NClJ5.mjs';
|
|
6
6
|
|
|
7
7
|
type AssertPasskeyInParentResult = CachedAssertion;
|
|
8
8
|
declare const assertPasskeyInParent: ({ transport, passkey, publishableKey, validateCredentialInAllowList, }: {
|
|
@@ -39,11 +39,21 @@ declare const getInternalPresenceTokens: ({ transport, passkey, publishableKey,
|
|
|
39
39
|
passkey: PasskeyAssertor;
|
|
40
40
|
publishableKey: string;
|
|
41
41
|
relyingPartyOrigin: RelyingPartyOriginInput;
|
|
42
|
-
scopes?: string[];
|
|
42
|
+
scopes?: readonly string[];
|
|
43
43
|
scopeCounts?: Record<string, number>;
|
|
44
44
|
}) => Promise<GetInternalPresenceTokensResult>;
|
|
45
45
|
declare const flattenPresenceTokens: (result: Pick<GetInternalPresenceTokensResult, "tokens"> & Partial<GetInternalPresenceTokensResult>) => Record<string, string>;
|
|
46
46
|
|
|
47
|
+
type PresenceScope = "dek_bootstrap" | "keyshare_write" | "keyshare_read" | "passkey_enroll" | "passkey_remove" | "wrap_add" | "ephemeral_signer_revoke" | "sign";
|
|
48
|
+
declare const SCOPES_CREATE_WALLET: readonly PresenceScope[];
|
|
49
|
+
declare const SCOPES_IMPORT_KEY: readonly PresenceScope[];
|
|
50
|
+
declare const SCOPES_REMOVE_PASSKEY: readonly PresenceScope[];
|
|
51
|
+
declare const SCOPES_ADD_PASSKEY: readonly PresenceScope[];
|
|
52
|
+
declare const SCOPES_PROVISION_EPHEMERAL_SIGNER: readonly PresenceScope[];
|
|
53
|
+
declare const SCOPES_REVOKE_EPHEMERAL_SIGNER: readonly PresenceScope[];
|
|
54
|
+
declare const SCOPES_SIGN: readonly PresenceScope[];
|
|
55
|
+
declare const SCOPES_EXPORT_KEY: readonly PresenceScope[];
|
|
56
|
+
|
|
47
57
|
declare const getHeadlessEthereumMethods: ({ transport, passkey, publishableKey, relyingPartyOrigin, }: {
|
|
48
58
|
transport: Transport;
|
|
49
59
|
passkey: PasskeyAssertor;
|
|
@@ -220,4 +230,4 @@ declare class EphemeralSignerSignError extends Error {
|
|
|
220
230
|
}
|
|
221
231
|
declare function signWithEphemeralSigner(input: EphemeralSignerSignInput): Promise<EphemeralSignerSignResult>;
|
|
222
232
|
|
|
223
|
-
export { type AssertPasskeyInParentResult, DEFAULT_API_BASE_URL, EphemeralSignerSignError, type EphemeralSignerSignInput, type EphemeralSignerSignResult, type GetInternalPresenceTokensResult, type GetPresenceTokenResult, KvStorage, type LoginWithCodeParams, PasskeyAssertor, RelyingPartyOriginInput, type ScopedPresenceToken, type SendCodeParams, Transport, type VerifyOAuthParams, assertPasskeyInParent, flattenPresenceTokens, getHeadlessAuthenticationMethods, getHeadlessEthereumMethods, getHeadlessGeneralMethods, getHeadlessSolanaMethods, getInternalPresenceTokens, getPresenceToken, signWithEphemeralSigner };
|
|
233
|
+
export { type AssertPasskeyInParentResult, DEFAULT_API_BASE_URL, EphemeralSignerSignError, type EphemeralSignerSignInput, type EphemeralSignerSignResult, type GetInternalPresenceTokensResult, type GetPresenceTokenResult, KvStorage, type LoginWithCodeParams, PasskeyAssertor, type PresenceScope, RelyingPartyOriginInput, SCOPES_ADD_PASSKEY, SCOPES_CREATE_WALLET, SCOPES_EXPORT_KEY, SCOPES_IMPORT_KEY, SCOPES_PROVISION_EPHEMERAL_SIGNER, SCOPES_REMOVE_PASSKEY, SCOPES_REVOKE_EPHEMERAL_SIGNER, SCOPES_SIGN, type ScopedPresenceToken, type SendCodeParams, Transport, type VerifyOAuthParams, assertPasskeyInParent, flattenPresenceTokens, getHeadlessAuthenticationMethods, getHeadlessEthereumMethods, getHeadlessGeneralMethods, getHeadlessSolanaMethods, getInternalPresenceTokens, getPresenceToken, signWithEphemeralSigner };
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { T as Transport, P as PasskeyAssertor, R as RelyingPartyOriginInput, K as KvStorage } from '../interfaces-
|
|
2
|
-
export { O as OAuthOpener, a as PlatformImpls, W as WebAuthnAssertionResponse, b as WebAuthnRequestOptions, r as resolveRelyingPartyOrigin } from '../interfaces-
|
|
1
|
+
import { T as Transport, P as PasskeyAssertor, R as RelyingPartyOriginInput, K as KvStorage } from '../interfaces-pGbKBjWD.js';
|
|
2
|
+
export { O as OAuthOpener, a as PlatformImpls, W as WebAuthnAssertionResponse, b as WebAuthnRequestOptions, r as resolveRelyingPartyOrigin } from '../interfaces-pGbKBjWD.js';
|
|
3
3
|
import { C as CachedAssertion } from '../passkey-cache-WnDFQ-v4.js';
|
|
4
4
|
import { EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SendEmailOtpResponse, PublicWallet, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, ListEphemeralSignersResult, RevokeEphemeralSignerParams } from '../types/index.js';
|
|
5
|
-
import '../post-message-
|
|
5
|
+
import '../post-message-BR2NClJ5.js';
|
|
6
6
|
|
|
7
7
|
type AssertPasskeyInParentResult = CachedAssertion;
|
|
8
8
|
declare const assertPasskeyInParent: ({ transport, passkey, publishableKey, validateCredentialInAllowList, }: {
|
|
@@ -39,11 +39,21 @@ declare const getInternalPresenceTokens: ({ transport, passkey, publishableKey,
|
|
|
39
39
|
passkey: PasskeyAssertor;
|
|
40
40
|
publishableKey: string;
|
|
41
41
|
relyingPartyOrigin: RelyingPartyOriginInput;
|
|
42
|
-
scopes?: string[];
|
|
42
|
+
scopes?: readonly string[];
|
|
43
43
|
scopeCounts?: Record<string, number>;
|
|
44
44
|
}) => Promise<GetInternalPresenceTokensResult>;
|
|
45
45
|
declare const flattenPresenceTokens: (result: Pick<GetInternalPresenceTokensResult, "tokens"> & Partial<GetInternalPresenceTokensResult>) => Record<string, string>;
|
|
46
46
|
|
|
47
|
+
type PresenceScope = "dek_bootstrap" | "keyshare_write" | "keyshare_read" | "passkey_enroll" | "passkey_remove" | "wrap_add" | "ephemeral_signer_revoke" | "sign";
|
|
48
|
+
declare const SCOPES_CREATE_WALLET: readonly PresenceScope[];
|
|
49
|
+
declare const SCOPES_IMPORT_KEY: readonly PresenceScope[];
|
|
50
|
+
declare const SCOPES_REMOVE_PASSKEY: readonly PresenceScope[];
|
|
51
|
+
declare const SCOPES_ADD_PASSKEY: readonly PresenceScope[];
|
|
52
|
+
declare const SCOPES_PROVISION_EPHEMERAL_SIGNER: readonly PresenceScope[];
|
|
53
|
+
declare const SCOPES_REVOKE_EPHEMERAL_SIGNER: readonly PresenceScope[];
|
|
54
|
+
declare const SCOPES_SIGN: readonly PresenceScope[];
|
|
55
|
+
declare const SCOPES_EXPORT_KEY: readonly PresenceScope[];
|
|
56
|
+
|
|
47
57
|
declare const getHeadlessEthereumMethods: ({ transport, passkey, publishableKey, relyingPartyOrigin, }: {
|
|
48
58
|
transport: Transport;
|
|
49
59
|
passkey: PasskeyAssertor;
|
|
@@ -220,4 +230,4 @@ declare class EphemeralSignerSignError extends Error {
|
|
|
220
230
|
}
|
|
221
231
|
declare function signWithEphemeralSigner(input: EphemeralSignerSignInput): Promise<EphemeralSignerSignResult>;
|
|
222
232
|
|
|
223
|
-
export { type AssertPasskeyInParentResult, DEFAULT_API_BASE_URL, EphemeralSignerSignError, type EphemeralSignerSignInput, type EphemeralSignerSignResult, type GetInternalPresenceTokensResult, type GetPresenceTokenResult, KvStorage, type LoginWithCodeParams, PasskeyAssertor, RelyingPartyOriginInput, type ScopedPresenceToken, type SendCodeParams, Transport, type VerifyOAuthParams, assertPasskeyInParent, flattenPresenceTokens, getHeadlessAuthenticationMethods, getHeadlessEthereumMethods, getHeadlessGeneralMethods, getHeadlessSolanaMethods, getInternalPresenceTokens, getPresenceToken, signWithEphemeralSigner };
|
|
233
|
+
export { type AssertPasskeyInParentResult, DEFAULT_API_BASE_URL, EphemeralSignerSignError, type EphemeralSignerSignInput, type EphemeralSignerSignResult, type GetInternalPresenceTokensResult, type GetPresenceTokenResult, KvStorage, type LoginWithCodeParams, PasskeyAssertor, type PresenceScope, RelyingPartyOriginInput, SCOPES_ADD_PASSKEY, SCOPES_CREATE_WALLET, SCOPES_EXPORT_KEY, SCOPES_IMPORT_KEY, SCOPES_PROVISION_EPHEMERAL_SIGNER, SCOPES_REMOVE_PASSKEY, SCOPES_REVOKE_EPHEMERAL_SIGNER, SCOPES_SIGN, type ScopedPresenceToken, type SendCodeParams, Transport, type VerifyOAuthParams, assertPasskeyInParent, flattenPresenceTokens, getHeadlessAuthenticationMethods, getHeadlessEthereumMethods, getHeadlessGeneralMethods, getHeadlessSolanaMethods, getInternalPresenceTokens, getPresenceToken, signWithEphemeralSigner };
|
package/dist/sdk/index.js
CHANGED
|
@@ -32,6 +32,14 @@ var sdk_exports = {};
|
|
|
32
32
|
__export(sdk_exports, {
|
|
33
33
|
DEFAULT_API_BASE_URL: () => DEFAULT_API_BASE_URL,
|
|
34
34
|
EphemeralSignerSignError: () => EphemeralSignerSignError,
|
|
35
|
+
SCOPES_ADD_PASSKEY: () => SCOPES_ADD_PASSKEY,
|
|
36
|
+
SCOPES_CREATE_WALLET: () => SCOPES_CREATE_WALLET,
|
|
37
|
+
SCOPES_EXPORT_KEY: () => SCOPES_EXPORT_KEY,
|
|
38
|
+
SCOPES_IMPORT_KEY: () => SCOPES_IMPORT_KEY,
|
|
39
|
+
SCOPES_PROVISION_EPHEMERAL_SIGNER: () => SCOPES_PROVISION_EPHEMERAL_SIGNER,
|
|
40
|
+
SCOPES_REMOVE_PASSKEY: () => SCOPES_REMOVE_PASSKEY,
|
|
41
|
+
SCOPES_REVOKE_EPHEMERAL_SIGNER: () => SCOPES_REVOKE_EPHEMERAL_SIGNER,
|
|
42
|
+
SCOPES_SIGN: () => SCOPES_SIGN,
|
|
35
43
|
assertPasskeyInParent: () => assertPasskeyInParent,
|
|
36
44
|
flattenPresenceTokens: () => flattenPresenceTokens,
|
|
37
45
|
getHeadlessAuthenticationMethods: () => getHeadlessAuthenticationMethods,
|
|
@@ -433,8 +441,34 @@ var flattenPresenceTokens = (result) => {
|
|
|
433
441
|
return out;
|
|
434
442
|
};
|
|
435
443
|
|
|
436
|
-
// src/sdk/
|
|
444
|
+
// src/sdk/presence-scopes.ts
|
|
445
|
+
var SCOPES_CREATE_WALLET = [
|
|
446
|
+
"dek_bootstrap",
|
|
447
|
+
"keyshare_write",
|
|
448
|
+
"sign"
|
|
449
|
+
];
|
|
450
|
+
var SCOPES_IMPORT_KEY = [
|
|
451
|
+
"dek_bootstrap",
|
|
452
|
+
"keyshare_write",
|
|
453
|
+
"sign"
|
|
454
|
+
];
|
|
455
|
+
var SCOPES_REMOVE_PASSKEY = [
|
|
456
|
+
"passkey_remove"
|
|
457
|
+
];
|
|
458
|
+
var SCOPES_ADD_PASSKEY = [
|
|
459
|
+
"passkey_enroll",
|
|
460
|
+
"wrap_add"
|
|
461
|
+
];
|
|
462
|
+
var SCOPES_PROVISION_EPHEMERAL_SIGNER = [
|
|
463
|
+
"keyshare_read"
|
|
464
|
+
];
|
|
465
|
+
var SCOPES_REVOKE_EPHEMERAL_SIGNER = [
|
|
466
|
+
"ephemeral_signer_revoke"
|
|
467
|
+
];
|
|
437
468
|
var SCOPES_SIGN = ["keyshare_read", "sign"];
|
|
469
|
+
var SCOPES_EXPORT_KEY = ["keyshare_read"];
|
|
470
|
+
|
|
471
|
+
// src/sdk/headless-ethereum.ts
|
|
438
472
|
var getHeadlessEthereumMethods = ({
|
|
439
473
|
transport,
|
|
440
474
|
passkey,
|
|
@@ -658,7 +692,6 @@ var getHeadlessEthereumMethods = ({
|
|
|
658
692
|
});
|
|
659
693
|
|
|
660
694
|
// src/sdk/headless-solana.ts
|
|
661
|
-
var SCOPES_SIGN2 = ["keyshare_read", "sign"];
|
|
662
695
|
var getHeadlessSolanaMethods = ({
|
|
663
696
|
transport,
|
|
664
697
|
passkey,
|
|
@@ -672,7 +705,7 @@ var getHeadlessSolanaMethods = ({
|
|
|
672
705
|
passkey,
|
|
673
706
|
publishableKey,
|
|
674
707
|
relyingPartyOrigin,
|
|
675
|
-
scopes:
|
|
708
|
+
scopes: SCOPES_SIGN
|
|
676
709
|
});
|
|
677
710
|
const { signature } = await transport.send(
|
|
678
711
|
PostMessageType.WALLET,
|
|
@@ -700,7 +733,7 @@ var getHeadlessSolanaMethods = ({
|
|
|
700
733
|
passkey,
|
|
701
734
|
publishableKey,
|
|
702
735
|
relyingPartyOrigin,
|
|
703
|
-
scopes:
|
|
736
|
+
scopes: SCOPES_SIGN
|
|
704
737
|
});
|
|
705
738
|
const { signedTransaction } = await transport.send(
|
|
706
739
|
PostMessageType.WALLET,
|
|
@@ -728,7 +761,7 @@ var getHeadlessSolanaMethods = ({
|
|
|
728
761
|
passkey,
|
|
729
762
|
publishableKey,
|
|
730
763
|
relyingPartyOrigin,
|
|
731
|
-
scopes:
|
|
764
|
+
scopes: SCOPES_SIGN
|
|
732
765
|
});
|
|
733
766
|
const { signedTransaction } = await transport.send(
|
|
734
767
|
PostMessageType.WALLET,
|
|
@@ -864,11 +897,6 @@ var getHeadlessAuthenticationMethods = ({
|
|
|
864
897
|
});
|
|
865
898
|
|
|
866
899
|
// src/sdk/headless-general.ts
|
|
867
|
-
var SCOPES_CREATE_WALLET = ["dek_bootstrap", "keyshare_write"];
|
|
868
|
-
var SCOPES_IMPORT_KEY = ["dek_bootstrap", "keyshare_write"];
|
|
869
|
-
var SCOPES_REMOVE_PASSKEY = ["passkey_remove"];
|
|
870
|
-
var SCOPES_PROVISION_EPHEMERAL_SIGNER = ["keyshare_read"];
|
|
871
|
-
var SCOPES_REVOKE_EPHEMERAL_SIGNER = ["ephemeral_signer_revoke"];
|
|
872
900
|
var getHeadlessGeneralMethods = ({
|
|
873
901
|
transport,
|
|
874
902
|
passkey,
|
|
@@ -1182,6 +1210,7 @@ async function resolveBinding(input) {
|
|
|
1182
1210
|
const bindings = json.wallets.map((w) => ({
|
|
1183
1211
|
walletId: w.wallet_id,
|
|
1184
1212
|
keyId: w.key_id,
|
|
1213
|
+
publicAddress: w.public_address,
|
|
1185
1214
|
derivationPath: w.derivation_path
|
|
1186
1215
|
}));
|
|
1187
1216
|
bindingsCache.set(input.apiPubHex, bindings);
|
|
@@ -1271,6 +1300,14 @@ async function signWithEphemeralSigner(input) {
|
|
|
1271
1300
|
0 && (module.exports = {
|
|
1272
1301
|
DEFAULT_API_BASE_URL,
|
|
1273
1302
|
EphemeralSignerSignError,
|
|
1303
|
+
SCOPES_ADD_PASSKEY,
|
|
1304
|
+
SCOPES_CREATE_WALLET,
|
|
1305
|
+
SCOPES_EXPORT_KEY,
|
|
1306
|
+
SCOPES_IMPORT_KEY,
|
|
1307
|
+
SCOPES_PROVISION_EPHEMERAL_SIGNER,
|
|
1308
|
+
SCOPES_REMOVE_PASSKEY,
|
|
1309
|
+
SCOPES_REVOKE_EPHEMERAL_SIGNER,
|
|
1310
|
+
SCOPES_SIGN,
|
|
1274
1311
|
assertPasskeyInParent,
|
|
1275
1312
|
flattenPresenceTokens,
|
|
1276
1313
|
getHeadlessAuthenticationMethods,
|
package/dist/sdk/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PostMessageMethod,
|
|
3
3
|
PostMessageType
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-Z57WM6IO.mjs";
|
|
5
5
|
import {
|
|
6
6
|
arrayLikeToBytes,
|
|
7
7
|
authState,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
bs58ToBytes,
|
|
11
11
|
serializeEthereumTransaction,
|
|
12
12
|
toB64url
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-T3ESQWEP.mjs";
|
|
14
14
|
import "../chunk-GQKIA37O.mjs";
|
|
15
15
|
|
|
16
16
|
// src/sdk/interfaces.ts
|
|
@@ -142,8 +142,34 @@ var flattenPresenceTokens = (result) => {
|
|
|
142
142
|
return out;
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
-
// src/sdk/
|
|
145
|
+
// src/sdk/presence-scopes.ts
|
|
146
|
+
var SCOPES_CREATE_WALLET = [
|
|
147
|
+
"dek_bootstrap",
|
|
148
|
+
"keyshare_write",
|
|
149
|
+
"sign"
|
|
150
|
+
];
|
|
151
|
+
var SCOPES_IMPORT_KEY = [
|
|
152
|
+
"dek_bootstrap",
|
|
153
|
+
"keyshare_write",
|
|
154
|
+
"sign"
|
|
155
|
+
];
|
|
156
|
+
var SCOPES_REMOVE_PASSKEY = [
|
|
157
|
+
"passkey_remove"
|
|
158
|
+
];
|
|
159
|
+
var SCOPES_ADD_PASSKEY = [
|
|
160
|
+
"passkey_enroll",
|
|
161
|
+
"wrap_add"
|
|
162
|
+
];
|
|
163
|
+
var SCOPES_PROVISION_EPHEMERAL_SIGNER = [
|
|
164
|
+
"keyshare_read"
|
|
165
|
+
];
|
|
166
|
+
var SCOPES_REVOKE_EPHEMERAL_SIGNER = [
|
|
167
|
+
"ephemeral_signer_revoke"
|
|
168
|
+
];
|
|
146
169
|
var SCOPES_SIGN = ["keyshare_read", "sign"];
|
|
170
|
+
var SCOPES_EXPORT_KEY = ["keyshare_read"];
|
|
171
|
+
|
|
172
|
+
// src/sdk/headless-ethereum.ts
|
|
147
173
|
var getHeadlessEthereumMethods = ({
|
|
148
174
|
transport,
|
|
149
175
|
passkey,
|
|
@@ -367,7 +393,6 @@ var getHeadlessEthereumMethods = ({
|
|
|
367
393
|
});
|
|
368
394
|
|
|
369
395
|
// src/sdk/headless-solana.ts
|
|
370
|
-
var SCOPES_SIGN2 = ["keyshare_read", "sign"];
|
|
371
396
|
var getHeadlessSolanaMethods = ({
|
|
372
397
|
transport,
|
|
373
398
|
passkey,
|
|
@@ -381,7 +406,7 @@ var getHeadlessSolanaMethods = ({
|
|
|
381
406
|
passkey,
|
|
382
407
|
publishableKey,
|
|
383
408
|
relyingPartyOrigin,
|
|
384
|
-
scopes:
|
|
409
|
+
scopes: SCOPES_SIGN
|
|
385
410
|
});
|
|
386
411
|
const { signature } = await transport.send(
|
|
387
412
|
PostMessageType.WALLET,
|
|
@@ -409,7 +434,7 @@ var getHeadlessSolanaMethods = ({
|
|
|
409
434
|
passkey,
|
|
410
435
|
publishableKey,
|
|
411
436
|
relyingPartyOrigin,
|
|
412
|
-
scopes:
|
|
437
|
+
scopes: SCOPES_SIGN
|
|
413
438
|
});
|
|
414
439
|
const { signedTransaction } = await transport.send(
|
|
415
440
|
PostMessageType.WALLET,
|
|
@@ -437,7 +462,7 @@ var getHeadlessSolanaMethods = ({
|
|
|
437
462
|
passkey,
|
|
438
463
|
publishableKey,
|
|
439
464
|
relyingPartyOrigin,
|
|
440
|
-
scopes:
|
|
465
|
+
scopes: SCOPES_SIGN
|
|
441
466
|
});
|
|
442
467
|
const { signedTransaction } = await transport.send(
|
|
443
468
|
PostMessageType.WALLET,
|
|
@@ -573,11 +598,6 @@ var getHeadlessAuthenticationMethods = ({
|
|
|
573
598
|
});
|
|
574
599
|
|
|
575
600
|
// src/sdk/headless-general.ts
|
|
576
|
-
var SCOPES_CREATE_WALLET = ["dek_bootstrap", "keyshare_write"];
|
|
577
|
-
var SCOPES_IMPORT_KEY = ["dek_bootstrap", "keyshare_write"];
|
|
578
|
-
var SCOPES_REMOVE_PASSKEY = ["passkey_remove"];
|
|
579
|
-
var SCOPES_PROVISION_EPHEMERAL_SIGNER = ["keyshare_read"];
|
|
580
|
-
var SCOPES_REVOKE_EPHEMERAL_SIGNER = ["ephemeral_signer_revoke"];
|
|
581
601
|
var getHeadlessGeneralMethods = ({
|
|
582
602
|
transport,
|
|
583
603
|
passkey,
|
|
@@ -891,6 +911,7 @@ async function resolveBinding(input) {
|
|
|
891
911
|
const bindings = json.wallets.map((w) => ({
|
|
892
912
|
walletId: w.wallet_id,
|
|
893
913
|
keyId: w.key_id,
|
|
914
|
+
publicAddress: w.public_address,
|
|
894
915
|
derivationPath: w.derivation_path
|
|
895
916
|
}));
|
|
896
917
|
bindingsCache.set(input.apiPubHex, bindings);
|
|
@@ -979,6 +1000,14 @@ async function signWithEphemeralSigner(input) {
|
|
|
979
1000
|
export {
|
|
980
1001
|
DEFAULT_API_BASE_URL,
|
|
981
1002
|
EphemeralSignerSignError,
|
|
1003
|
+
SCOPES_ADD_PASSKEY,
|
|
1004
|
+
SCOPES_CREATE_WALLET,
|
|
1005
|
+
SCOPES_EXPORT_KEY,
|
|
1006
|
+
SCOPES_IMPORT_KEY,
|
|
1007
|
+
SCOPES_PROVISION_EPHEMERAL_SIGNER,
|
|
1008
|
+
SCOPES_REMOVE_PASSKEY,
|
|
1009
|
+
SCOPES_REVOKE_EPHEMERAL_SIGNER,
|
|
1010
|
+
SCOPES_SIGN,
|
|
982
1011
|
assertPasskeyInParent,
|
|
983
1012
|
flattenPresenceTokens,
|
|
984
1013
|
getHeadlessAuthenticationMethods,
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from '../post-message-
|
|
1
|
+
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from '../post-message-BR2NClJ5.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the appropriate MoonKey API URL based on environment configuration
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from '../post-message-
|
|
1
|
+
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from '../post-message-BR2NClJ5.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the appropriate MoonKey API URL based on environment configuration
|
package/dist/utils/index.js
CHANGED
|
@@ -292,12 +292,13 @@ var PostMessageServer = class {
|
|
|
292
292
|
if (queued?.length) {
|
|
293
293
|
this.pending.delete(key);
|
|
294
294
|
const now = Date.now();
|
|
295
|
-
for (const { request, reply, at } of queued) {
|
|
295
|
+
for (const { request, reply, at, ctx } of queued) {
|
|
296
296
|
if (now - at < QUEUE_TTL_MS) {
|
|
297
297
|
void this.invokeHandler(
|
|
298
298
|
handler,
|
|
299
299
|
request,
|
|
300
|
-
reply
|
|
300
|
+
reply,
|
|
301
|
+
ctx
|
|
301
302
|
);
|
|
302
303
|
}
|
|
303
304
|
}
|
|
@@ -349,7 +350,7 @@ var PostMessageServer = class {
|
|
|
349
350
|
id: request.id,
|
|
350
351
|
type: request.type,
|
|
351
352
|
success: false,
|
|
352
|
-
error: `Origin ${event.origin} is not whitelisted. Please add it to your
|
|
353
|
+
error: `Origin ${event.origin} is not whitelisted. Please add it to your MoonX dashboard.`
|
|
353
354
|
});
|
|
354
355
|
return;
|
|
355
356
|
}
|
|
@@ -366,14 +367,20 @@ var PostMessageServer = class {
|
|
|
366
367
|
const key = `${request.type}:${request.method}`;
|
|
367
368
|
const handler = this.handlers.get(key);
|
|
368
369
|
if (handler) {
|
|
369
|
-
await this.invokeHandler(handler, request, reply
|
|
370
|
+
await this.invokeHandler(handler, request, reply, {
|
|
371
|
+
origin: event.origin,
|
|
372
|
+
source: event.source
|
|
373
|
+
});
|
|
370
374
|
} else {
|
|
371
|
-
this.bufferRequest(key, request, reply
|
|
375
|
+
this.bufferRequest(key, request, reply, {
|
|
376
|
+
origin: event.origin,
|
|
377
|
+
source: event.source
|
|
378
|
+
});
|
|
372
379
|
}
|
|
373
380
|
}
|
|
374
|
-
async invokeHandler(handler, request, reply) {
|
|
381
|
+
async invokeHandler(handler, request, reply, ctx) {
|
|
375
382
|
try {
|
|
376
|
-
const data = await handler(request.payload);
|
|
383
|
+
const data = await handler(request.payload, ctx);
|
|
377
384
|
reply({
|
|
378
385
|
id: request.id,
|
|
379
386
|
type: request.type,
|
|
@@ -397,14 +404,14 @@ var PostMessageServer = class {
|
|
|
397
404
|
});
|
|
398
405
|
}
|
|
399
406
|
}
|
|
400
|
-
bufferRequest(key, request, reply) {
|
|
407
|
+
bufferRequest(key, request, reply, ctx) {
|
|
401
408
|
this.evictExpiredPending();
|
|
402
409
|
let queue = this.pending.get(key);
|
|
403
410
|
if (!queue) {
|
|
404
411
|
queue = [];
|
|
405
412
|
this.pending.set(key, queue);
|
|
406
413
|
}
|
|
407
|
-
queue.push({ request, reply, at: Date.now() });
|
|
414
|
+
queue.push({ request, reply, at: Date.now(), ctx });
|
|
408
415
|
if (queue.length > MAX_PENDING_PER_KEY) {
|
|
409
416
|
queue.splice(0, queue.length - MAX_PENDING_PER_KEY);
|
|
410
417
|
}
|
package/dist/utils/index.mjs
CHANGED
package/dist/web/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PostMessageClient } from '../post-message-
|
|
2
|
-
import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-
|
|
1
|
+
import { P as PostMessageClient } from '../post-message-BR2NClJ5.mjs';
|
|
2
|
+
import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-Bt5CAMSt.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
|
-
import { P as PostMessageClient } from '../post-message-
|
|
2
|
-
import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-
|
|
1
|
+
import { P as PostMessageClient } from '../post-message-BR2NClJ5.js';
|
|
2
|
+
import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-pGbKBjWD.js';
|
|
3
3
|
|
|
4
4
|
declare const getCachedPostMessageClient: (contentWindow: Window) => PostMessageClient;
|
|
5
5
|
/**
|
package/dist/web/index.js
CHANGED
|
@@ -137,12 +137,13 @@ var PostMessageServer = class {
|
|
|
137
137
|
if (queued?.length) {
|
|
138
138
|
this.pending.delete(key);
|
|
139
139
|
const now = Date.now();
|
|
140
|
-
for (const { request, reply, at } of queued) {
|
|
140
|
+
for (const { request, reply, at, ctx } of queued) {
|
|
141
141
|
if (now - at < QUEUE_TTL_MS) {
|
|
142
142
|
void this.invokeHandler(
|
|
143
143
|
handler,
|
|
144
144
|
request,
|
|
145
|
-
reply
|
|
145
|
+
reply,
|
|
146
|
+
ctx
|
|
146
147
|
);
|
|
147
148
|
}
|
|
148
149
|
}
|
|
@@ -194,7 +195,7 @@ var PostMessageServer = class {
|
|
|
194
195
|
id: request.id,
|
|
195
196
|
type: request.type,
|
|
196
197
|
success: false,
|
|
197
|
-
error: `Origin ${event.origin} is not whitelisted. Please add it to your
|
|
198
|
+
error: `Origin ${event.origin} is not whitelisted. Please add it to your MoonX dashboard.`
|
|
198
199
|
});
|
|
199
200
|
return;
|
|
200
201
|
}
|
|
@@ -211,14 +212,20 @@ var PostMessageServer = class {
|
|
|
211
212
|
const key = `${request.type}:${request.method}`;
|
|
212
213
|
const handler = this.handlers.get(key);
|
|
213
214
|
if (handler) {
|
|
214
|
-
await this.invokeHandler(handler, request, reply
|
|
215
|
+
await this.invokeHandler(handler, request, reply, {
|
|
216
|
+
origin: event.origin,
|
|
217
|
+
source: event.source
|
|
218
|
+
});
|
|
215
219
|
} else {
|
|
216
|
-
this.bufferRequest(key, request, reply
|
|
220
|
+
this.bufferRequest(key, request, reply, {
|
|
221
|
+
origin: event.origin,
|
|
222
|
+
source: event.source
|
|
223
|
+
});
|
|
217
224
|
}
|
|
218
225
|
}
|
|
219
|
-
async invokeHandler(handler, request, reply) {
|
|
226
|
+
async invokeHandler(handler, request, reply, ctx) {
|
|
220
227
|
try {
|
|
221
|
-
const data = await handler(request.payload);
|
|
228
|
+
const data = await handler(request.payload, ctx);
|
|
222
229
|
reply({
|
|
223
230
|
id: request.id,
|
|
224
231
|
type: request.type,
|
|
@@ -242,14 +249,14 @@ var PostMessageServer = class {
|
|
|
242
249
|
});
|
|
243
250
|
}
|
|
244
251
|
}
|
|
245
|
-
bufferRequest(key, request, reply) {
|
|
252
|
+
bufferRequest(key, request, reply, ctx) {
|
|
246
253
|
this.evictExpiredPending();
|
|
247
254
|
let queue = this.pending.get(key);
|
|
248
255
|
if (!queue) {
|
|
249
256
|
queue = [];
|
|
250
257
|
this.pending.set(key, queue);
|
|
251
258
|
}
|
|
252
|
-
queue.push({ request, reply, at: Date.now() });
|
|
259
|
+
queue.push({ request, reply, at: Date.now(), ctx });
|
|
253
260
|
if (queue.length > MAX_PENDING_PER_KEY) {
|
|
254
261
|
queue.splice(0, queue.length - MAX_PENDING_PER_KEY);
|
|
255
262
|
}
|
package/dist/web/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moon-x/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -66,13 +66,14 @@
|
|
|
66
66
|
"@testing-library/react": "16.3.2",
|
|
67
67
|
"@types/react": "19.2.14",
|
|
68
68
|
"@types/react-dom": "19.2.3",
|
|
69
|
-
"@vitest/ui": "1.
|
|
69
|
+
"@vitest/ui": "4.1.0",
|
|
70
70
|
"happy-dom": "20.8.9",
|
|
71
71
|
"react": "18.3.1",
|
|
72
72
|
"react-dom": "18.3.1",
|
|
73
73
|
"tsup": "8.5.1",
|
|
74
74
|
"typescript": "5.9.3",
|
|
75
|
-
"
|
|
75
|
+
"vite": "7.3.5",
|
|
76
|
+
"vitest": "4.1.0"
|
|
76
77
|
},
|
|
77
78
|
"peerDependencies": {
|
|
78
79
|
"@solana/web3.js": "^1.98.4",
|