@moon-x/core 0.10.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 +3 -3
- package/dist/sdk/index.d.ts +3 -3
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/index.mjs +3 -2
- 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, }: {
|
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, }: {
|
package/dist/sdk/index.js
CHANGED
|
@@ -1210,6 +1210,7 @@ async function resolveBinding(input) {
|
|
|
1210
1210
|
const bindings = json.wallets.map((w) => ({
|
|
1211
1211
|
walletId: w.wallet_id,
|
|
1212
1212
|
keyId: w.key_id,
|
|
1213
|
+
publicAddress: w.public_address,
|
|
1213
1214
|
derivationPath: w.derivation_path
|
|
1214
1215
|
}));
|
|
1215
1216
|
bindingsCache.set(input.apiPubHex, bindings);
|
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
|
|
@@ -911,6 +911,7 @@ async function resolveBinding(input) {
|
|
|
911
911
|
const bindings = json.wallets.map((w) => ({
|
|
912
912
|
walletId: w.wallet_id,
|
|
913
913
|
keyId: w.key_id,
|
|
914
|
+
publicAddress: w.public_address,
|
|
914
915
|
derivationPath: w.derivation_path
|
|
915
916
|
}));
|
|
916
917
|
bindingsCache.set(input.apiPubHex, bindings);
|
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.10.
|
|
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",
|