@seams/wallet 0.22.0 → 0.23.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/THIRD_PARTY_NOTICES.md +5 -2
- package/dist/.build-inputs.sha256 +1 -1
- package/dist/esm/externalNear/actions.js +26 -0
- package/dist/esm/externalNear/boundary.js +53 -0
- package/dist/esm/externalNear/controller.js +187 -0
- package/dist/esm/externalNear/hot.js +40 -0
- package/dist/esm/externalNear/index.js +3 -0
- package/dist/esm/externalNear/intear.js +109 -0
- package/dist/esm/externalNear/intearPopup.js +83 -0
- package/dist/esm/externalNear/meteor.js +121 -0
- package/dist/esm/externalNear/meteorRequest.js +117 -0
- package/dist/esm/externalNear/types.js +17 -0
- package/dist/esm/externalNear/wallets.js +33 -0
- package/dist/esm/node_modules/borsh/lib/esm/buffer.js +67 -0
- package/dist/esm/node_modules/borsh/lib/esm/deserialize.js +94 -0
- package/dist/esm/node_modules/borsh/lib/esm/index.js +13 -0
- package/dist/esm/node_modules/borsh/lib/esm/serialize.js +127 -0
- package/dist/esm/node_modules/borsh/lib/esm/types.js +19 -0
- package/dist/esm/node_modules/borsh/lib/esm/utils.js +104 -0
- package/dist/esm/plugins/plugin-utils.js +2 -5
- package/dist/esm/react/externalNear.css +90 -0
- package/dist/esm/react/externalNear.js +104 -0
- package/dist/esm/sdk/host-C5KYWEcs.js +1 -0
- package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/esm/sdk/wallet-ui.css +1 -1
- package/dist/public/headers.manifest.json +1 -1
- package/dist/public/sdk/host-C5KYWEcs.js +1 -0
- package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/public/sdk/wallet-ui.css +1 -1
- package/dist/public/wallet-assets.manifest.json +4 -5
- package/dist/public/wallet-service/index.html +4 -4
- package/dist/types/wallet/src/externalNear/actions.d.ts +20 -0
- package/dist/types/wallet/src/externalNear/boundary.d.ts +7 -0
- package/dist/types/wallet/src/externalNear/controller.d.ts +23 -0
- package/dist/types/wallet/src/externalNear/hot.d.ts +13 -0
- package/dist/types/wallet/src/externalNear/index.d.ts +4 -0
- package/dist/types/wallet/src/externalNear/intear.d.ts +12 -0
- package/dist/types/wallet/src/externalNear/intearPopup.d.ts +25 -0
- package/dist/types/wallet/src/externalNear/meteor.d.ts +16 -0
- package/dist/types/wallet/src/externalNear/meteorRequest.d.ts +29 -0
- package/dist/types/wallet/src/externalNear/types.d.ts +67 -0
- package/dist/types/wallet/src/externalNear/wallets.d.ts +4 -0
- package/dist/types/wallet/src/plugins/plugin-utils.d.ts +1 -1
- package/dist/types/wallet/src/react/externalNear.d.ts +26 -0
- package/package.json +18 -1
- package/dist/esm/plugins/SeamsWeb/walletIframe/sanitization.js +0 -18
- package/dist/esm/sdk/host-DoftJdVQ.js +0 -1
- package/dist/public/sdk/host-DoftJdVQ.js +0 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"packageName": "@seams/wallet",
|
|
4
|
-
"packageVersion": "0.
|
|
4
|
+
"packageVersion": "0.23.0",
|
|
5
5
|
"assetRoot": "dist/public",
|
|
6
6
|
"sdkBasePath": "/sdk",
|
|
7
7
|
"walletServicePath": "/wallet-service",
|
|
8
|
-
"walletHostRelayerOriginPolicy": "document_meta_v1",
|
|
9
8
|
"headersManifest": "headers.manifest.json",
|
|
10
9
|
"versionSkewContract": {
|
|
11
10
|
"kind": "wallet_iframe_protocol_handshake",
|
|
12
|
-
"packageVersion": "0.
|
|
11
|
+
"packageVersion": "0.23.0",
|
|
13
12
|
"protocolVersion": "16.0.0",
|
|
14
13
|
"readyPayloadField": "protocolVersion",
|
|
15
14
|
"failureMode": "typed_error",
|
|
@@ -995,8 +994,8 @@
|
|
|
995
994
|
]
|
|
996
995
|
},
|
|
997
996
|
{
|
|
998
|
-
"route": "/sdk/host-
|
|
999
|
-
"sourceFile": "sdk/host-
|
|
997
|
+
"route": "/sdk/host-C5KYWEcs.js",
|
|
998
|
+
"sourceFile": "sdk/host-C5KYWEcs.js",
|
|
1000
999
|
"owner": "wallet_sdk_asset",
|
|
1001
1000
|
"routeClass": "javascript",
|
|
1002
1001
|
"contentType": "text/javascript; charset=utf-8",
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Web3Authn Wallet Service</title>
|
|
7
7
|
<!-- Surface styles are external so strict CSP can keep style-src 'self' -->
|
|
8
|
-
<link rel="stylesheet" href="/sdk/wallet-ui.css?v=0.
|
|
8
|
+
<link rel="stylesheet" href="/sdk/wallet-ui.css?v=0.23.0" />
|
|
9
9
|
<!-- Minimal shims some ESM bundles expect (externalized to enable strict CSP) -->
|
|
10
|
-
<script src="/sdk/wallet-shims.js?v=0.
|
|
10
|
+
<script src="/sdk/wallet-shims.js?v=0.23.0"></script>
|
|
11
11
|
<!-- Hint the browser to fetch the host script earlier -->
|
|
12
|
-
<link rel="modulepreload" href="/sdk/wallet-iframe-host-runtime.js?v=0.
|
|
12
|
+
<link rel="modulepreload" href="/sdk/wallet-iframe-host-runtime.js?v=0.23.0" crossorigin>
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<!-- sdkBasePath points to the SDK root (e.g. '/sdk'). Load the host directly. -->
|
|
16
|
-
<script type="module" src="/sdk/wallet-iframe-host-runtime.js?v=0.
|
|
16
|
+
<script type="module" src="/sdk/wallet-iframe-host-runtime.js?v=0.23.0"></script>
|
|
17
17
|
</body>
|
|
18
18
|
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ActionArgs } from '../core/types/actions';
|
|
2
|
+
/** Wallet Selector's JSON action format, shared by HOT and Intear. */
|
|
3
|
+
export declare function externalNearAction(action: ActionArgs): {
|
|
4
|
+
type: string;
|
|
5
|
+
params: {
|
|
6
|
+
deposit: string;
|
|
7
|
+
methodName?: undefined;
|
|
8
|
+
args?: undefined;
|
|
9
|
+
gas?: undefined;
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
type: string;
|
|
13
|
+
params: {
|
|
14
|
+
methodName: string;
|
|
15
|
+
args: any;
|
|
16
|
+
gas: string;
|
|
17
|
+
deposit: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type TransactionInput } from '../core/types/actions';
|
|
2
|
+
import type { ExternalNearConnection, ExternalNearSubmission } from './types';
|
|
3
|
+
export declare function parseAccounts(raw: unknown): readonly string[];
|
|
4
|
+
export declare function validateTransaction(input: TransactionInput): TransactionInput;
|
|
5
|
+
export declare function parseSubmission(raw: unknown, connection: ExternalNearConnection): ExternalNearSubmission;
|
|
6
|
+
export declare function executionStatus(raw: unknown, submission: ExternalNearSubmission): 'confirmed' | 'failed' | 'unresolved';
|
|
7
|
+
//# sourceMappingURL=boundary.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TransactionInput } from '../core/types/actions';
|
|
2
|
+
import type { ExternalNearConnection, ExternalNearConfig, ExternalNearNetwork, ExternalNearOutcome, ExternalNearResult, ExternalNearSnapshot, ExternalNearSubmission, ExternalNearWalletId } from './types';
|
|
3
|
+
export declare class ExternalNearController {
|
|
4
|
+
private snapshot;
|
|
5
|
+
private enabledWallets;
|
|
6
|
+
readonly network: ExternalNearNetwork;
|
|
7
|
+
private readonly rpcUrl;
|
|
8
|
+
private listeners;
|
|
9
|
+
private generation;
|
|
10
|
+
private provider;
|
|
11
|
+
private pending;
|
|
12
|
+
constructor(config: ExternalNearConfig);
|
|
13
|
+
setWallets(wallets: readonly ExternalNearWalletId[]): void;
|
|
14
|
+
getSnapshot: () => ExternalNearSnapshot;
|
|
15
|
+
subscribe: (listener: () => void) => (() => void);
|
|
16
|
+
private unsubscribe;
|
|
17
|
+
private publish;
|
|
18
|
+
connect(wallet: ExternalNearWalletId): Promise<ExternalNearResult<ExternalNearConnection>>;
|
|
19
|
+
disconnect(): void;
|
|
20
|
+
sendTransaction(connection: ExternalNearConnection, input: TransactionInput): Promise<ExternalNearResult<ExternalNearSubmission>>;
|
|
21
|
+
checkOutcome(submission: ExternalNearSubmission): Promise<ExternalNearOutcome>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TransactionInput } from '../core/types/actions';
|
|
2
|
+
import type { ExternalNearConnection, ExternalNearNetwork, NearWalletProvider } from './types';
|
|
3
|
+
/** Direct extension API documented by hot-dao/hot-sdk-js. No iframe fallback. */
|
|
4
|
+
export declare class HotExtensionProvider implements NearWalletProvider {
|
|
5
|
+
private lifecycle;
|
|
6
|
+
private readonly transport;
|
|
7
|
+
private request;
|
|
8
|
+
connect(network: ExternalNearNetwork): Promise<unknown>;
|
|
9
|
+
accounts(network: ExternalNearNetwork): Promise<unknown>;
|
|
10
|
+
send(connection: ExternalNearConnection, transaction: TransactionInput): Promise<unknown>;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=hot.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ExternalNearController } from './controller';
|
|
2
|
+
export type { ExternalNearConnection, ExternalNearConfig, ExternalNearWalletId, ExternalNearNetwork, ExternalNearOutcome, ExternalNearResult, ExternalNearSnapshot, ExternalNearState, ExternalNearSubmission, } from './types';
|
|
3
|
+
export { nearWalletName } from './wallets';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TransactionInput } from '../core/types/actions';
|
|
2
|
+
import type { ExternalNearConnection, ExternalNearNetwork, NearWalletProvider } from './types';
|
|
3
|
+
export declare class IntearWalletProvider implements NearWalletProvider {
|
|
4
|
+
private lifecycle;
|
|
5
|
+
private popup;
|
|
6
|
+
private session;
|
|
7
|
+
connect(network: ExternalNearNetwork): Promise<unknown>;
|
|
8
|
+
accounts(network: ExternalNearNetwork): Promise<unknown>;
|
|
9
|
+
send(connection: ExternalNearConnection, transaction: TransactionInput): Promise<unknown>;
|
|
10
|
+
dispose(): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=intear.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const INTEAR_ORIGIN = "https://wallet.intear.tech";
|
|
2
|
+
/** One popup per request; origin and WindowProxy together bind every response. */
|
|
3
|
+
export declare class IntearPopup {
|
|
4
|
+
private readonly successType;
|
|
5
|
+
private popup;
|
|
6
|
+
private sent;
|
|
7
|
+
private settled;
|
|
8
|
+
private ready;
|
|
9
|
+
private payload;
|
|
10
|
+
private resolveResult;
|
|
11
|
+
private rejectResult;
|
|
12
|
+
private interval;
|
|
13
|
+
private timeout;
|
|
14
|
+
readonly result: Promise<unknown>;
|
|
15
|
+
constructor(path: '/connect' | '/send-transactions', successType: 'connected' | 'sent');
|
|
16
|
+
private captureResolvers;
|
|
17
|
+
send(payload: object): void;
|
|
18
|
+
private dispatch;
|
|
19
|
+
private receive;
|
|
20
|
+
private checkClosed;
|
|
21
|
+
private expire;
|
|
22
|
+
fail(error: Error): void;
|
|
23
|
+
private cleanup;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=intearPopup.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type TransactionInput } from '../core/types/actions';
|
|
2
|
+
import type { ExternalNearConnection, ExternalNearNetwork, NearWalletProvider } from './types';
|
|
3
|
+
export declare class MeteorExtensionProvider implements NearWalletProvider {
|
|
4
|
+
private readonly rpcUrl;
|
|
5
|
+
private lifecycle;
|
|
6
|
+
private readonly transport;
|
|
7
|
+
private request;
|
|
8
|
+
private account;
|
|
9
|
+
constructor(rpcUrl: string);
|
|
10
|
+
private execute;
|
|
11
|
+
connect(network: ExternalNearNetwork): Promise<unknown>;
|
|
12
|
+
accounts(network: ExternalNearNetwork): Promise<unknown>;
|
|
13
|
+
send(connection: ExternalNearConnection, transaction: TransactionInput): Promise<unknown>;
|
|
14
|
+
dispose(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=meteor.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ExternalNearNetwork } from './types';
|
|
2
|
+
type MeteorTransport = {
|
|
3
|
+
sendMessageDataAndRespond(request: object): Promise<unknown>;
|
|
4
|
+
};
|
|
5
|
+
export declare function meteorTransportFromWindow(): MeteorTransport;
|
|
6
|
+
/** Heartbeats carry one request ID; they never create a second signing request. */
|
|
7
|
+
export declare class MeteorRequest {
|
|
8
|
+
private readonly transport;
|
|
9
|
+
private readonly network;
|
|
10
|
+
private readonly actionType;
|
|
11
|
+
private readonly inputs;
|
|
12
|
+
private readonly uid;
|
|
13
|
+
private state;
|
|
14
|
+
private resolve;
|
|
15
|
+
private reject;
|
|
16
|
+
private timer;
|
|
17
|
+
private deadline;
|
|
18
|
+
readonly result: Promise<unknown>;
|
|
19
|
+
constructor(transport: MeteorTransport, network: ExternalNearNetwork, actionType: 'login' | 'sign', inputs: object);
|
|
20
|
+
private capture;
|
|
21
|
+
private poll;
|
|
22
|
+
private receive;
|
|
23
|
+
private acknowledge;
|
|
24
|
+
private expire;
|
|
25
|
+
cancel(): void;
|
|
26
|
+
private finish;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=meteorRequest.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { TransactionInput } from '../core/types/actions';
|
|
2
|
+
export type ExternalNearWalletId = 'meteor' | 'hot' | 'intear';
|
|
3
|
+
export type ExternalNearNetwork = 'mainnet' | 'testnet';
|
|
4
|
+
export type ExternalNearConfig = Readonly<{
|
|
5
|
+
network: ExternalNearNetwork;
|
|
6
|
+
rpcUrl: string;
|
|
7
|
+
wallets: readonly ExternalNearWalletId[];
|
|
8
|
+
}>;
|
|
9
|
+
export type ExternalNearResult<T> = {
|
|
10
|
+
readonly ok: true;
|
|
11
|
+
readonly value: T;
|
|
12
|
+
readonly code?: never;
|
|
13
|
+
readonly message?: never;
|
|
14
|
+
} | {
|
|
15
|
+
readonly ok: false;
|
|
16
|
+
readonly code: 'unavailable' | 'invalid_input' | 'connection_changed' | 'pending_request' | 'submission_unknown';
|
|
17
|
+
readonly message: string;
|
|
18
|
+
readonly value?: never;
|
|
19
|
+
};
|
|
20
|
+
declare const connectionBrand: unique symbol;
|
|
21
|
+
export declare function connectedNear(wallet: ExternalNearWalletId, accountId: string, network: ExternalNearNetwork, generation: number): ExternalNearConnection;
|
|
22
|
+
export type ExternalNearConnection = Readonly<{
|
|
23
|
+
kind: 'connected';
|
|
24
|
+
[connectionBrand]: true;
|
|
25
|
+
accountId: string;
|
|
26
|
+
network: ExternalNearNetwork;
|
|
27
|
+
wallet: ExternalNearWalletId;
|
|
28
|
+
generation: number;
|
|
29
|
+
}>;
|
|
30
|
+
export type ExternalNearState = ExternalNearConnection | {
|
|
31
|
+
readonly kind: 'disconnected';
|
|
32
|
+
readonly accountId?: never;
|
|
33
|
+
readonly network?: never;
|
|
34
|
+
readonly wallet?: never;
|
|
35
|
+
readonly generation?: never;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'connecting';
|
|
38
|
+
readonly wallet: ExternalNearWalletId;
|
|
39
|
+
readonly accountId?: never;
|
|
40
|
+
readonly network?: never;
|
|
41
|
+
readonly generation?: never;
|
|
42
|
+
};
|
|
43
|
+
export type ExternalNearSnapshot = Readonly<{
|
|
44
|
+
connection: ExternalNearState;
|
|
45
|
+
busy: boolean;
|
|
46
|
+
wallets: readonly ExternalNearWalletId[];
|
|
47
|
+
}>;
|
|
48
|
+
export type ExternalNearSubmission = Readonly<{
|
|
49
|
+
hash: string;
|
|
50
|
+
accountId: string;
|
|
51
|
+
network: ExternalNearNetwork;
|
|
52
|
+
}>;
|
|
53
|
+
export type ExternalNearOutcome = {
|
|
54
|
+
readonly kind: 'confirmed' | 'failed';
|
|
55
|
+
readonly submission: ExternalNearSubmission;
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: 'unresolved';
|
|
58
|
+
readonly submission: ExternalNearSubmission;
|
|
59
|
+
};
|
|
60
|
+
export interface NearWalletProvider {
|
|
61
|
+
connect(network: ExternalNearNetwork): Promise<unknown>;
|
|
62
|
+
accounts(network: ExternalNearNetwork): Promise<unknown>;
|
|
63
|
+
send(connection: ExternalNearConnection, transaction: TransactionInput): Promise<unknown>;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExternalNearWalletId, NearWalletProvider } from './types';
|
|
2
|
+
export declare function nearWalletName(wallet: ExternalNearWalletId): string;
|
|
3
|
+
export declare function createNearWalletProvider(wallet: ExternalNearWalletId, rpcUrl: string): Promise<NearWalletProvider>;
|
|
4
|
+
//# sourceMappingURL=wallets.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type WalletHostVariant } from '../core/browser/walletIframe/hostVariant';
|
|
2
|
-
export declare function buildWalletServiceHtml(sdkBasePath?: string, assetVersion?: string, walletHostVariant?: WalletHostVariant
|
|
2
|
+
export declare function buildWalletServiceHtml(sdkBasePath?: string, assetVersion?: string, walletHostVariant?: WalletHostVariant): string;
|
|
3
3
|
//# sourceMappingURL=plugin-utils.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { type ExternalNearController, type ExternalNearSnapshot, type ExternalNearWalletId } from '../externalNear';
|
|
3
|
+
export declare function useExternalNear(controller: ExternalNearController): ExternalNearSnapshot;
|
|
4
|
+
export declare class ExternalNearWalletPicker extends Component<{
|
|
5
|
+
controller: ExternalNearController;
|
|
6
|
+
}, {
|
|
7
|
+
snapshot: ExternalNearSnapshot;
|
|
8
|
+
message: string;
|
|
9
|
+
}> {
|
|
10
|
+
state: {
|
|
11
|
+
snapshot: Readonly<{
|
|
12
|
+
connection: import("../externalNear").ExternalNearState;
|
|
13
|
+
busy: boolean;
|
|
14
|
+
wallets: readonly ExternalNearWalletId[];
|
|
15
|
+
}>;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
private unsubscribe;
|
|
19
|
+
componentDidMount(): void;
|
|
20
|
+
componentWillUnmount(): void;
|
|
21
|
+
private updateSnapshot;
|
|
22
|
+
private connect;
|
|
23
|
+
private disconnect;
|
|
24
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=externalNear.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seams/wallet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Seams web and runtime TypeScript SDK for NEAR and EVM-family wallets",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -66,6 +66,16 @@
|
|
|
66
66
|
"import": "./dist/esm/SeamsWeb/walletIframe/client/html.js",
|
|
67
67
|
"default": "./dist/esm/SeamsWeb/walletIframe/client/html.js",
|
|
68
68
|
"types": "./dist/types/wallet/src/SeamsWeb/walletIframe/client/html.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./external-near": {
|
|
71
|
+
"types": "./dist/types/wallet/src/externalNear/index.d.ts",
|
|
72
|
+
"import": "./dist/esm/externalNear/index.js",
|
|
73
|
+
"default": "./dist/esm/externalNear/index.js"
|
|
74
|
+
},
|
|
75
|
+
"./react/external-near": {
|
|
76
|
+
"types": "./dist/types/wallet/src/react/externalNear.d.ts",
|
|
77
|
+
"import": "./dist/esm/react/externalNear.js",
|
|
78
|
+
"default": "./dist/esm/react/externalNear.js"
|
|
69
79
|
}
|
|
70
80
|
},
|
|
71
81
|
"files": [
|
|
@@ -100,6 +110,12 @@
|
|
|
100
110
|
],
|
|
101
111
|
"react/*": [
|
|
102
112
|
"dist/types/wallet/src/react/*"
|
|
113
|
+
],
|
|
114
|
+
"external-near": [
|
|
115
|
+
"dist/types/wallet/src/externalNear/index.d.ts"
|
|
116
|
+
],
|
|
117
|
+
"react/external-near": [
|
|
118
|
+
"dist/types/wallet/src/react/externalNear.d.ts"
|
|
103
119
|
]
|
|
104
120
|
}
|
|
105
121
|
},
|
|
@@ -179,6 +195,7 @@
|
|
|
179
195
|
},
|
|
180
196
|
"dependencies": {
|
|
181
197
|
"@near-js/types": "^2.4.0",
|
|
198
|
+
"borsh": "1.0.0",
|
|
182
199
|
"bs58": "^6.0.0",
|
|
183
200
|
"idb": "^8.0.3",
|
|
184
201
|
"preact": "10.29.8",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region src/SeamsWeb/walletIframe/sanitization.ts
|
|
2
|
-
/**
|
|
3
|
-
* Escapes HTML attribute values to prevent injection
|
|
4
|
-
*
|
|
5
|
-
* Converts special characters to HTML entities:
|
|
6
|
-
* - & -> &
|
|
7
|
-
* - " -> "
|
|
8
|
-
* - ' -> '
|
|
9
|
-
* - < -> <
|
|
10
|
-
* - > -> >
|
|
11
|
-
*/
|
|
12
|
-
function escapeHtmlAttribute(value) {
|
|
13
|
-
return value.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { escapeHtmlAttribute };
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=sanitization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,S as t}from"./chains-CPmd4s9f.js";import{n}from"./walletRegistrationSetupPrewarm-CQow9u8m.js";import{t as r}from"./walletDbName-BVZhb4xF.js";import{_ as i,b as a,c as o,d as s,g as c,i as l,m as u,n as d,r as f,t as p,u as m,v as ee,y as te}from"./sessionObservationRevision-abErAhd6.js";import{a as h,c as g,i as _,l as v,n as y,o as ne,s as re,t as ie,u as ae}from"./transactionReviewAdmission-CNNho8IG.js";import{t as b}from"./events-1dzC4Ocx.js";import{t as x}from"./walletIframeIdentity-DJ0KOBHg.js";import{t as S}from"./errors-CI1xdN0d.js";import{t as C}from"./signer-worker-Bh_5foqX.js";function w(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function T(){w(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),oe(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&c(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;u()||i(r)}function oe(){let e=()=>{let e=document;e.documentElement.classList.add(`seams-transparent`),e.body?.classList.add(`seams-transparent`),e.documentElement.classList.remove(`dark`),e.body?.classList.remove(`dark`)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e(),window.addEventListener(`load`,()=>e(),{once:!0})}const E={};let D=null,O=null;function se(e){return e.request.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?e.request.payload?.authorization?.kind===`email_otp`?k(e.kind):(D??=import(`./runtime-recovery-codes-CuqYWqK7.js`),D):k(e.kind)}function ce(){k(`auth`).catch(le)}function le(){}function k(e){let t=E[e];if(t)return t;let n=M(e);return E[e]=n,n.catch(A.bind(null,e,n)),n}function A(e,t){E[e]===t&&delete E[e]}async function j(){D??=import(`./runtime-recovery-codes-CuqYWqK7.js`),O??=Promise.all([D,import(`./mountRecoveryCodeBackupSurface-D3QFgMGE.js`)]).then(()=>void 0),await O}function M(e){switch(e){case`auth`:return import(`./runtime-auth-C0V-5znH.js`);case`near`:return import(`./runtime-near-DRrdWzmr.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-CDSZ3pxS.js`);case`email_otp`:return import(`./runtime-email-otp-DXuxFOjL.js`);case`recovery`:return import(`./runtime-recovery-DlJlaZlf.js`);case`export`:return import(`./runtime-export-Ba12ChDI.js`);case`device_link`:return import(`./runtime-device-link-B1jpHQSF.js`);case`preferences`:return import(`./runtime-preferences-BWyhRaBA.js`)}return N(e)}function N(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function P(e){switch(e.type){case`PM_GET_RECENT_UNLOCKS`:case`PM_GET_CONFIRMATION_CONFIG`:return!0;case`PM_GET_EXACT_WALLET_SESSION_STATE`:{let t=e.request.payload;if(!t||typeof t!=`object`)return!1;let n=Reflect.get(t,`authenticationRead`),r=Reflect.get(t,`wallet`);return(n===`restore`||n===`current`)&&!!r&&typeof r==`object`&&Reflect.get(r,`kind`)===`current`}default:return!1}}function F(e){switch(e.type){case`PM_GET_EXACT_WALLET_SESSION_STATE`:return{revision:p(),walletId:null,state:{kind:`wallet_locked`},session:d()};case`PM_GET_RECENT_UNLOCKS`:return{walletIds:[],accountIds:[],accounts:[],lastUsedAccount:null};case`PM_GET_CONFIRMATION_CONFIG`:return{walletId:null,confirmationConfig:C,revision:0}}}let I=null;function L(){return I??=z().finally(R),I}function R(){I=null}async function z(){try{return typeof indexedDB>`u`||typeof indexedDB.databases!=`function`?!1:(await indexedDB.databases()).some(B)?await V():!0}catch{return!1}}function B(e){return e.name===r}function V(){return new Promise(e=>{let t=indexedDB.open(r);t.onupgradeneeded=()=>t.transaction?.abort(),t.onerror=()=>e(!1),t.onsuccess=()=>{let n=t.result;n.onversionchange=()=>n.close(),H(n).then(t=>{n.close(),e(t===0)},()=>{n.close(),e(!1)})}})}function H(e){let t=Array.from(e.objectStoreNames);return t.length===0?Promise.resolve(0):new Promise((n,r)=>{let i=e.transaction(t,`readonly`),a=0;for(let e of t){let t=i.objectStore(e).count();t.onsuccess=()=>{a+=t.result}}i.oncomplete=()=>n(a),i.onerror=()=>r(i.error),i.onabort=()=>r(i.error)})}function U(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function W(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function G(e){try{return x(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function ue(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_PREPARE_WALLET_RUNTIME`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(o(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(m(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return U(e)}function de(e){return e.kind!==`boot`}let K=!1;const fe=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function q(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function pe(t){return!e(t)||!q(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!q(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function me(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function J(){let e=new Set,t=document.querySelectorAll(`meta[name="seams-wallet-relayer-origin"]`);for(let n of t){let t=n.getAttribute(`content`)?.trim()??``,r;try{r=new URL(t)}catch{throw Error(`Invalid wallet relayer origin policy`)}let i=r.hostname===`localhost`||r.hostname.endsWith(`.localhost`)||r.hostname===`127.0.0.1`||r.hostname===`[::1]`;if(r.origin!==t||r.protocol!==`https:`&&!(r.protocol===`http:`&&i))throw Error(`Invalid wallet relayer origin policy`);e.add(t)}if(e.size===0)throw Error(`Wallet relayer origin policy is missing`);return e}function he(e){let t;try{t=new URL(e).origin}catch{throw Error(`Wallet relayer URL is invalid`)}if(!J().has(t))throw Error(`Wallet relayer origin is not approved by the wallet host`)}function Y(e){try{e.close()}catch{}}function ge(e,t){if(t===`16.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:f,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return Y(e),!0}function X(e,t){return!t||t.has(e)}function Z(e,t,n,r){e.executionGeneration===t&&n(r)}function Q(e,t,n,r){return e.executionGeneration!==t||n(r)}function $(e={}){if(K)return;K=!0,T(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&j().catch(()=>void 0);let r=new Set,i=new Set,o=!1,s={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},c=e=>{try{s.port?.postMessage(e)}catch{}},u=e=>{e&&r.add(e)},d=e=>!!e&&(r.has(e)||_(e)?.cancelled===!0),f=e=>{e&&r.delete(e)},p=e=>{e&&c({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},m=e=>!e||!d(e)?!1:_(e)?.cancelled?!0:(p(e),f(e),!0),x=()=>{for(let e of fe){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(b.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},C=async r=>{let l=r.data;if(!l||!t(l))return;let b=l.requestId,C=s.executionGeneration,w=Z.bind(null,s,C,c),T=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new h(`review_invalid_input`,`Review is unsupported for this request`);let e=g(l.transactionReview);if(e.requestId!==b)throw new h(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new h(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);T=new ie(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>w({type:`TRANSACTION_REVIEW_STATE`,requestId:b,payload:e}),e=>w({type:`ERROR`,requestId:b,payload:{code:e instanceof h?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&y(new h(`review_identity_changed`,`The wallet session changed`));let t=ue(l);if(!de(t))switch(t.type){case`PING`:c({type:`PONG`,requestId:b});return;case`PM_PREPARE_WALLET_RUNTIME`:X(`auth`,e.supportedRuntimeRouteKinds)&&ce(),c({type:`PONG`,requestId:b});return;case`PM_SET_CONFIG`:{let e=ee(s.configuration,te(t.request.payload));he(e.config.network.relayer.url);let r=a(s.configuration.kind===`configured`?s.configuration.config:null)!==a(e.config);if(s.configuration=e,r){s.executionGeneration+=1;let t=e.config;t.registration.publishableKey&&t.registration.projectEnvironmentId&&n(t.network.relayer.url);for(let e of i)c({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}s.onConfigurationChanged?.(),r&&(y(new h(`review_identity_changed`,`Wallet execution configuration changed`)),x()),c({type:`PONG`,requestId:b});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=re(t.request.payload);e&&_(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=g(r),i=_(t.requestId);if(t.requestId===e&&i&&v(t,i.metadata)){let e=new h(ae(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{ne(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}c({type:`PONG`,requestId:b});return}let i=e?_(e):void 0;if(i){i.cancel(new h(`cancelled`,`Request cancelled`)),c({type:`PONG`,requestId:b});return}u(e),x(),e&&p(e),c({type:`PONG`,requestId:b});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-CpDMkSPm.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-CpDMkSPm.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!X(t.kind,e.supportedRuntimeRouteKinds)){c({type:`ERROR`,requestId:b,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}if(b&&i.add(b),!o&&P(t)&&await L()&&!o){if(C!==s.executionGeneration||m(b))return;w({type:`PM_RESULT`,requestId:b,payload:{ok:!0,result:F(t)}});return}o=!0;let r=await se(t);if(C!==s.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:T,state:s,executionGeneration:C,req:t.request,post:Z.bind(null,s,C,c),isCancelled:Q.bind(null,s,C,d),respondIfCancelled:Q.bind(null,s,C,m)})}catch(e){if(C!==s.executionGeneration&&l.type!==`PM_SET_CONFIG`||T?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-CqHi6ji6.js`);if(C!==s.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=S(e),i=t.resolveWalletBoundaryErrorCode({requestType:l.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:l.type,rawCode:n,code:i,message:r}),o=t.resolveWalletBoundarySignerKind(l.type);c({type:`ERROR`,requestId:b,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&o?{signerKind:o}:{}}})}finally{b&&(i.delete(b),f(b)),T?.finish()}};window.addEventListener(`message`,e=>{let t=pe(e.data),n=e.ports[0];if(!(!t||!n||s.port)){if(e.source!==window.parent||!me(e.origin)){Y(n);return}if(!ge(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(s.parentOrigin=e.origin),s.port=n;try{s.port.onmessage=C,s.port.start?.()}catch{}c({type:`READY`,payload:{protocolVersion:l}})}}})}try{$()}catch(e){console.error(`[WalletHost] init failed`,e)}export{$ as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,S as t}from"./chains-CPmd4s9f.js";import{n}from"./walletRegistrationSetupPrewarm-CQow9u8m.js";import{t as r}from"./walletDbName-BVZhb4xF.js";import{_ as i,b as a,c as o,d as s,g as c,i as l,m as u,n as d,r as f,t as p,u as m,v as ee,y as te}from"./sessionObservationRevision-abErAhd6.js";import{a as h,c as g,i as _,l as v,n as y,o as ne,s as re,t as ie,u as ae}from"./transactionReviewAdmission-CNNho8IG.js";import{t as b}from"./events-1dzC4Ocx.js";import{t as x}from"./walletIframeIdentity-DJ0KOBHg.js";import{t as S}from"./errors-CI1xdN0d.js";import{t as C}from"./signer-worker-Bh_5foqX.js";function w(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function T(){w(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),oe(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&c(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;u()||i(r)}function oe(){let e=()=>{let e=document;e.documentElement.classList.add(`seams-transparent`),e.body?.classList.add(`seams-transparent`),e.documentElement.classList.remove(`dark`),e.body?.classList.remove(`dark`)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e(),window.addEventListener(`load`,()=>e(),{once:!0})}const E={};let D=null,O=null;function se(e){return e.request.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?e.request.payload?.authorization?.kind===`email_otp`?k(e.kind):(D??=import(`./runtime-recovery-codes-CuqYWqK7.js`),D):k(e.kind)}function ce(){k(`auth`).catch(le)}function le(){}function k(e){let t=E[e];if(t)return t;let n=M(e);return E[e]=n,n.catch(A.bind(null,e,n)),n}function A(e,t){E[e]===t&&delete E[e]}async function j(){D??=import(`./runtime-recovery-codes-CuqYWqK7.js`),O??=Promise.all([D,import(`./mountRecoveryCodeBackupSurface-D3QFgMGE.js`)]).then(()=>void 0),await O}function M(e){switch(e){case`auth`:return import(`./runtime-auth-C0V-5znH.js`);case`near`:return import(`./runtime-near-DRrdWzmr.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-CDSZ3pxS.js`);case`email_otp`:return import(`./runtime-email-otp-DXuxFOjL.js`);case`recovery`:return import(`./runtime-recovery-DlJlaZlf.js`);case`export`:return import(`./runtime-export-Ba12ChDI.js`);case`device_link`:return import(`./runtime-device-link-B1jpHQSF.js`);case`preferences`:return import(`./runtime-preferences-BWyhRaBA.js`)}return N(e)}function N(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function P(e){switch(e.type){case`PM_GET_RECENT_UNLOCKS`:case`PM_GET_CONFIRMATION_CONFIG`:return!0;case`PM_GET_EXACT_WALLET_SESSION_STATE`:{let t=e.request.payload;if(!t||typeof t!=`object`)return!1;let n=Reflect.get(t,`authenticationRead`),r=Reflect.get(t,`wallet`);return(n===`restore`||n===`current`)&&!!r&&typeof r==`object`&&Reflect.get(r,`kind`)===`current`}default:return!1}}function F(e){switch(e.type){case`PM_GET_EXACT_WALLET_SESSION_STATE`:return{revision:p(),walletId:null,state:{kind:`wallet_locked`},session:d()};case`PM_GET_RECENT_UNLOCKS`:return{walletIds:[],accountIds:[],accounts:[],lastUsedAccount:null};case`PM_GET_CONFIRMATION_CONFIG`:return{walletId:null,confirmationConfig:C,revision:0}}}let I=null;function L(){return I??=z().finally(R),I}function R(){I=null}async function z(){try{return typeof indexedDB>`u`||typeof indexedDB.databases!=`function`?!1:(await indexedDB.databases()).some(B)?await V():!0}catch{return!1}}function B(e){return e.name===r}function V(){return new Promise(e=>{let t=indexedDB.open(r);t.onupgradeneeded=()=>t.transaction?.abort(),t.onerror=()=>e(!1),t.onsuccess=()=>{let n=t.result;n.onversionchange=()=>n.close(),H(n).then(t=>{n.close(),e(t===0)},()=>{n.close(),e(!1)})}})}function H(e){let t=Array.from(e.objectStoreNames);return t.length===0?Promise.resolve(0):new Promise((n,r)=>{let i=e.transaction(t,`readonly`),a=0;for(let e of t){let t=i.objectStore(e).count();t.onsuccess=()=>{a+=t.result}}i.oncomplete=()=>n(a),i.onerror=()=>r(i.error),i.onabort=()=>r(i.error)})}function U(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function W(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function G(e){try{return x(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function ue(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_PREPARE_WALLET_RUNTIME`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(o(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(m(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return U(e)}function de(e){return e.kind!==`boot`}let K=!1;const fe=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function q(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function pe(t){return!e(t)||!q(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!q(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function me(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function J(){let e=new Set,t=document.querySelectorAll(`meta[name="seams-wallet-relayer-origin"]`);for(let n of t){let t=n.getAttribute(`content`)?.trim()??``,r;try{r=new URL(t)}catch{throw Error(`Invalid wallet relayer origin policy`)}let i=r.hostname===`localhost`||r.hostname.endsWith(`.localhost`)||r.hostname===`127.0.0.1`||r.hostname===`[::1]`;if(r.origin!==t||r.protocol!==`https:`&&!(r.protocol===`http:`&&i))throw Error(`Invalid wallet relayer origin policy`);e.add(t)}if(e.size===0)throw Error(`Wallet relayer origin policy is missing`);return e}function he(e){let t;try{t=new URL(e).origin}catch{throw Error(`Wallet relayer URL is invalid`)}if(!J().has(t))throw Error(`Wallet relayer origin is not approved by the wallet host`)}function Y(e){try{e.close()}catch{}}function ge(e,t){if(t===`16.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:f,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return Y(e),!0}function X(e,t){return!t||t.has(e)}function Z(e,t,n,r){e.executionGeneration===t&&n(r)}function Q(e,t,n,r){return e.executionGeneration!==t||n(r)}function $(e={}){if(K)return;K=!0,T(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&j().catch(()=>void 0);let r=new Set,i=new Set,o=!1,s={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},c=e=>{try{s.port?.postMessage(e)}catch{}},u=e=>{e&&r.add(e)},d=e=>!!e&&(r.has(e)||_(e)?.cancelled===!0),f=e=>{e&&r.delete(e)},p=e=>{e&&c({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},m=e=>!e||!d(e)?!1:_(e)?.cancelled?!0:(p(e),f(e),!0),x=()=>{for(let e of fe){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(b.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},C=async r=>{let l=r.data;if(!l||!t(l))return;let b=l.requestId,C=s.executionGeneration,w=Z.bind(null,s,C,c),T=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new h(`review_invalid_input`,`Review is unsupported for this request`);let e=g(l.transactionReview);if(e.requestId!==b)throw new h(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new h(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);T=new ie(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>w({type:`TRANSACTION_REVIEW_STATE`,requestId:b,payload:e}),e=>w({type:`ERROR`,requestId:b,payload:{code:e instanceof h?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&y(new h(`review_identity_changed`,`The wallet session changed`));let t=ue(l);if(!de(t))switch(t.type){case`PING`:c({type:`PONG`,requestId:b});return;case`PM_PREPARE_WALLET_RUNTIME`:X(`auth`,e.supportedRuntimeRouteKinds)&&ce(),c({type:`PONG`,requestId:b});return;case`PM_SET_CONFIG`:{let e=ee(s.configuration,te(t.request.payload));he(e.config.network.relayer.url);let r=a(s.configuration.kind===`configured`?s.configuration.config:null)!==a(e.config);if(s.configuration=e,r){s.executionGeneration+=1;let t=e.config;t.registration.publishableKey&&t.registration.projectEnvironmentId&&n(t.network.relayer.url);for(let e of i)c({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}s.onConfigurationChanged?.(),r&&(y(new h(`review_identity_changed`,`Wallet execution configuration changed`)),x()),c({type:`PONG`,requestId:b});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=re(t.request.payload);e&&_(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=g(r),i=_(t.requestId);if(t.requestId===e&&i&&v(t,i.metadata)){let e=new h(ae(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{ne(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}c({type:`PONG`,requestId:b});return}let i=e?_(e):void 0;if(i){i.cancel(new h(`cancelled`,`Request cancelled`)),c({type:`PONG`,requestId:b});return}u(e),x(),e&&p(e),c({type:`PONG`,requestId:b});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-CpDMkSPm.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-CpDMkSPm.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!X(t.kind,e.supportedRuntimeRouteKinds)){c({type:`ERROR`,requestId:b,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}if(b&&i.add(b),!o&&P(t)&&await L()&&!o){if(C!==s.executionGeneration||m(b))return;w({type:`PM_RESULT`,requestId:b,payload:{ok:!0,result:F(t)}});return}o=!0;let r=await se(t);if(C!==s.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:T,state:s,executionGeneration:C,req:t.request,post:Z.bind(null,s,C,c),isCancelled:Q.bind(null,s,C,d),respondIfCancelled:Q.bind(null,s,C,m)})}catch(e){if(C!==s.executionGeneration&&l.type!==`PM_SET_CONFIG`||T?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-CqHi6ji6.js`);if(C!==s.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=S(e),i=t.resolveWalletBoundaryErrorCode({requestType:l.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:l.type,rawCode:n,code:i,message:r}),o=t.resolveWalletBoundarySignerKind(l.type);c({type:`ERROR`,requestId:b,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&o?{signerKind:o}:{}}})}finally{b&&(i.delete(b),f(b)),T?.finish()}};window.addEventListener(`message`,e=>{let t=pe(e.data),n=e.ports[0];if(!(!t||!n||s.port)){if(e.source!==window.parent||!me(e.origin)){Y(n);return}if(!ge(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(s.parentOrigin=e.origin),s.port=n;try{s.port.onmessage=C,s.port.start?.()}catch{}c({type:`READY`,payload:{protocolVersion:l}})}}})}try{$()}catch(e){console.error(`[WalletHost] init failed`,e)}export{$ as t};
|