@0xkey-io/core 0.1.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/LICENSE +201 -0
- package/README.MD +7 -0
- package/dist/0xkey-helpers.d.ts +68 -0
- package/dist/0xkey-helpers.d.ts.map +1 -0
- package/dist/0xkey-helpers.js +466 -0
- package/dist/0xkey-helpers.js.map +1 -0
- package/dist/0xkey-helpers.mjs +399 -0
- package/dist/0xkey-helpers.mjs.map +1 -0
- package/dist/__clients__/core.d.ts +1201 -0
- package/dist/__clients__/core.d.ts.map +1 -0
- package/dist/__clients__/core.js +3489 -0
- package/dist/__clients__/core.js.map +1 -0
- package/dist/__clients__/core.mjs +3487 -0
- package/dist/__clients__/core.mjs.map +1 -0
- package/dist/__generated__/sdk-client-base.d.ts +281 -0
- package/dist/__generated__/sdk-client-base.d.ts.map +1 -0
- package/dist/__generated__/sdk-client-base.js +3906 -0
- package/dist/__generated__/sdk-client-base.js.map +1 -0
- package/dist/__generated__/sdk-client-base.mjs +3904 -0
- package/dist/__generated__/sdk-client-base.mjs.map +1 -0
- package/dist/__generated__/version.d.ts +2 -0
- package/dist/__generated__/version.d.ts.map +1 -0
- package/dist/__generated__/version.js +6 -0
- package/dist/__generated__/version.js.map +1 -0
- package/dist/__generated__/version.mjs +4 -0
- package/dist/__generated__/version.mjs.map +1 -0
- package/dist/__inputs__/public_api.types.d.ts +6014 -0
- package/dist/__inputs__/public_api.types.d.ts.map +1 -0
- package/dist/__polyfills__/jest.setup.webcrypto.d.ts +2 -0
- package/dist/__polyfills__/jest.setup.webcrypto.d.ts.map +1 -0
- package/dist/__polyfills__/window.d.ts +15 -0
- package/dist/__polyfills__/window.d.ts.map +1 -0
- package/dist/__polyfills__/window.js +30 -0
- package/dist/__polyfills__/window.js.map +1 -0
- package/dist/__polyfills__/window.mjs +28 -0
- package/dist/__polyfills__/window.mjs.map +1 -0
- package/dist/__stampers__/api/base.d.ts +27 -0
- package/dist/__stampers__/api/base.d.ts.map +1 -0
- package/dist/__stampers__/api/base.js +102 -0
- package/dist/__stampers__/api/base.js.map +1 -0
- package/dist/__stampers__/api/base.mjs +100 -0
- package/dist/__stampers__/api/base.mjs.map +1 -0
- package/dist/__stampers__/api/mobile/stamper.d.ts +15 -0
- package/dist/__stampers__/api/mobile/stamper.d.ts.map +1 -0
- package/dist/__stampers__/api/mobile/stamper.js +119 -0
- package/dist/__stampers__/api/mobile/stamper.js.map +1 -0
- package/dist/__stampers__/api/mobile/stamper.mjs +117 -0
- package/dist/__stampers__/api/mobile/stamper.mjs.map +1 -0
- package/dist/__stampers__/api/web/stamper.d.ts +14 -0
- package/dist/__stampers__/api/web/stamper.d.ts.map +1 -0
- package/dist/__stampers__/api/web/stamper.js +201 -0
- package/dist/__stampers__/api/web/stamper.js.map +1 -0
- package/dist/__stampers__/api/web/stamper.mjs +199 -0
- package/dist/__stampers__/api/web/stamper.mjs.map +1 -0
- package/dist/__stampers__/passkey/base.d.ts +16 -0
- package/dist/__stampers__/passkey/base.d.ts.map +1 -0
- package/dist/__stampers__/passkey/base.js +138 -0
- package/dist/__stampers__/passkey/base.js.map +1 -0
- package/dist/__stampers__/passkey/base.mjs +134 -0
- package/dist/__stampers__/passkey/base.mjs.map +1 -0
- package/dist/__storage__/base.d.ts +3 -0
- package/dist/__storage__/base.d.ts.map +1 -0
- package/dist/__storage__/base.js +27 -0
- package/dist/__storage__/base.js.map +1 -0
- package/dist/__storage__/base.mjs +25 -0
- package/dist/__storage__/base.mjs.map +1 -0
- package/dist/__storage__/mobile/storage.d.ts +18 -0
- package/dist/__storage__/mobile/storage.d.ts.map +1 -0
- package/dist/__storage__/mobile/storage.js +76 -0
- package/dist/__storage__/mobile/storage.js.map +1 -0
- package/dist/__storage__/mobile/storage.mjs +74 -0
- package/dist/__storage__/mobile/storage.mjs.map +1 -0
- package/dist/__storage__/web/storage.d.ts +19 -0
- package/dist/__storage__/web/storage.d.ts.map +1 -0
- package/dist/__storage__/web/storage.js +79 -0
- package/dist/__storage__/web/storage.js.map +1 -0
- package/dist/__storage__/web/storage.mjs +77 -0
- package/dist/__storage__/web/storage.mjs.map +1 -0
- package/dist/__typedoc-entry__/index.d.ts +3 -0
- package/dist/__typedoc-entry__/index.d.ts.map +1 -0
- package/dist/__types__/auth.d.ts +120 -0
- package/dist/__types__/auth.d.ts.map +1 -0
- package/dist/__types__/auth.js +7 -0
- package/dist/__types__/auth.js.map +1 -0
- package/dist/__types__/auth.mjs +5 -0
- package/dist/__types__/auth.mjs.map +1 -0
- package/dist/__types__/config.d.ts +145 -0
- package/dist/__types__/config.d.ts.map +1 -0
- package/dist/__types__/enums.d.ts +59 -0
- package/dist/__types__/enums.d.ts.map +1 -0
- package/dist/__types__/enums.js +72 -0
- package/dist/__types__/enums.js.map +1 -0
- package/dist/__types__/enums.mjs +70 -0
- package/dist/__types__/enums.mjs.map +1 -0
- package/dist/__types__/error.d.ts +13 -0
- package/dist/__types__/error.d.ts.map +1 -0
- package/dist/__types__/error.js +18 -0
- package/dist/__types__/error.js.map +1 -0
- package/dist/__types__/error.mjs +16 -0
- package/dist/__types__/error.mjs.map +1 -0
- package/dist/__types__/export.d.ts +10 -0
- package/dist/__types__/export.d.ts.map +1 -0
- package/dist/__types__/external-wallets.d.ts +203 -0
- package/dist/__types__/external-wallets.d.ts.map +1 -0
- package/dist/__types__/http.d.ts +17 -0
- package/dist/__types__/http.d.ts.map +1 -0
- package/dist/__types__/http.js +11 -0
- package/dist/__types__/http.js.map +1 -0
- package/dist/__types__/http.mjs +9 -0
- package/dist/__types__/http.mjs.map +1 -0
- package/dist/__types__/index.d.ts +10 -0
- package/dist/__types__/index.d.ts.map +1 -0
- package/dist/__types__/method-types/import-export-params.d.ts +38 -0
- package/dist/__types__/method-types/import-export-params.d.ts.map +1 -0
- package/dist/__types__/method-types/shared.d.ts +378 -0
- package/dist/__types__/method-types/shared.d.ts.map +1 -0
- package/dist/__wallet__/base.d.ts +14 -0
- package/dist/__wallet__/base.d.ts.map +1 -0
- package/dist/__wallet__/base.js +35 -0
- package/dist/__wallet__/base.js.map +1 -0
- package/dist/__wallet__/base.mjs +33 -0
- package/dist/__wallet__/base.mjs.map +1 -0
- package/dist/__wallet__/connector.d.ts +60 -0
- package/dist/__wallet__/connector.d.ts.map +1 -0
- package/dist/__wallet__/connector.js +93 -0
- package/dist/__wallet__/connector.js.map +1 -0
- package/dist/__wallet__/connector.mjs +91 -0
- package/dist/__wallet__/connector.mjs.map +1 -0
- package/dist/__wallet__/mobile/manager.d.ts +51 -0
- package/dist/__wallet__/mobile/manager.d.ts.map +1 -0
- package/dist/__wallet__/mobile/manager.js +115 -0
- package/dist/__wallet__/mobile/manager.js.map +1 -0
- package/dist/__wallet__/mobile/manager.mjs +113 -0
- package/dist/__wallet__/mobile/manager.mjs.map +1 -0
- package/dist/__wallet__/stamper.d.ts +90 -0
- package/dist/__wallet__/stamper.d.ts.map +1 -0
- package/dist/__wallet__/stamper.js +183 -0
- package/dist/__wallet__/stamper.js.map +1 -0
- package/dist/__wallet__/stamper.mjs +180 -0
- package/dist/__wallet__/stamper.mjs.map +1 -0
- package/dist/__wallet__/wallet-connect/base.d.ts +182 -0
- package/dist/__wallet__/wallet-connect/base.d.ts.map +1 -0
- package/dist/__wallet__/wallet-connect/base.js +606 -0
- package/dist/__wallet__/wallet-connect/base.js.map +1 -0
- package/dist/__wallet__/wallet-connect/base.mjs +604 -0
- package/dist/__wallet__/wallet-connect/base.mjs.map +1 -0
- package/dist/__wallet__/wallet-connect/client.d.ts +132 -0
- package/dist/__wallet__/wallet-connect/client.d.ts.map +1 -0
- package/dist/__wallet__/wallet-connect/client.js +262 -0
- package/dist/__wallet__/wallet-connect/client.js.map +1 -0
- package/dist/__wallet__/wallet-connect/client.mjs +260 -0
- package/dist/__wallet__/wallet-connect/client.mjs.map +1 -0
- package/dist/__wallet__/web/manager.d.ts +70 -0
- package/dist/__wallet__/web/manager.d.ts.map +1 -0
- package/dist/__wallet__/web/manager.js +177 -0
- package/dist/__wallet__/web/manager.js.map +1 -0
- package/dist/__wallet__/web/manager.mjs +175 -0
- package/dist/__wallet__/web/manager.mjs.map +1 -0
- package/dist/__wallet__/web/native/ethereum.d.ts +101 -0
- package/dist/__wallet__/web/native/ethereum.d.ts.map +1 -0
- package/dist/__wallet__/web/native/ethereum.js +339 -0
- package/dist/__wallet__/web/native/ethereum.js.map +1 -0
- package/dist/__wallet__/web/native/ethereum.mjs +336 -0
- package/dist/__wallet__/web/native/ethereum.mjs.map +1 -0
- package/dist/__wallet__/web/native/solana.d.ts +72 -0
- package/dist/__wallet__/web/native/solana.d.ts.map +1 -0
- package/dist/__wallet__/web/native/solana.js +215 -0
- package/dist/__wallet__/web/native/solana.js.map +1 -0
- package/dist/__wallet__/web/native/solana.mjs +212 -0
- package/dist/__wallet__/web/native/solana.mjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +10 -0
- package/dist/index.mjs.map +1 -0
- package/dist/utils.d.ts +160 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +1047 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +1007 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { getWallets } from '@wallet-standard/app';
|
|
2
|
+
import { uint8ArrayFromHexString, uint8ArrayToHexString, bs58 } from '@0xkey-io/encoding';
|
|
3
|
+
import { SignIntent, WalletInterfaceType, Chain } from '../../../__types__/enums.mjs';
|
|
4
|
+
import { withTimeoutFallback } from '../../../utils.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for Solana wallet implementations using Wallet Standard.
|
|
8
|
+
*
|
|
9
|
+
* Provides shared logic for:
|
|
10
|
+
* - Provider discovery via `@wallet-standard/app` (`getWallets()`).
|
|
11
|
+
* - Connecting via `standard:connect` and disconnecting via `standard:disconnect`.
|
|
12
|
+
* - Public key retrieval from the wallet's account address (base58 → hex).
|
|
13
|
+
*/
|
|
14
|
+
class BaseSolanaWallet {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.interfaceType = WalletInterfaceType.Solana;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the ed25519 public key for the active account as hex (no 0x prefix).
|
|
19
|
+
*
|
|
20
|
+
* - Ensures the wallet is connected (calls `standard:connect` if needed).
|
|
21
|
+
* - Decodes the Wallet Standard account address (base58) to raw bytes.
|
|
22
|
+
*
|
|
23
|
+
* @param provider - The wallet provider to use.
|
|
24
|
+
* @returns Hex-encoded ed25519 public key (no 0x prefix).
|
|
25
|
+
* @throws {Error} If no account is available.
|
|
26
|
+
*/
|
|
27
|
+
this.getPublicKey = async (provider) => {
|
|
28
|
+
const wallet = asSolana(provider);
|
|
29
|
+
await connectAccount(wallet);
|
|
30
|
+
const account = wallet.accounts[0];
|
|
31
|
+
if (!account) {
|
|
32
|
+
throw new Error("No account in wallet");
|
|
33
|
+
}
|
|
34
|
+
const rawBytes = bs58.decode(account.address);
|
|
35
|
+
return uint8ArrayToHexString(rawBytes);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Discovers Solana-capable Wallet Standard providers.
|
|
39
|
+
*
|
|
40
|
+
* - Uses `getWallets().get()` and filters wallets with at least one `chains` entry
|
|
41
|
+
* starting with `"solana:"`.
|
|
42
|
+
* - For each wallet, collects branding info and any currently connected addresses.
|
|
43
|
+
*
|
|
44
|
+
* @returns A list of discovered Solana `WalletProvider`s (may be empty).
|
|
45
|
+
*/
|
|
46
|
+
this.getProviders = async () => {
|
|
47
|
+
const discovered = [];
|
|
48
|
+
const walletsApi = getWallets();
|
|
49
|
+
const providers = walletsApi
|
|
50
|
+
.get()
|
|
51
|
+
.filter((w) => w.chains?.some((c) => c.startsWith("solana:")));
|
|
52
|
+
await Promise.all(providers.map(async (wallet) => {
|
|
53
|
+
// wrap account access in a timeout to prevent hanging providers from blocking discovery
|
|
54
|
+
const connectedAddresses = await withTimeoutFallback((async () => {
|
|
55
|
+
try {
|
|
56
|
+
return wallet.accounts?.map((a) => a.address) ?? [];
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
})(), []);
|
|
62
|
+
discovered.push({
|
|
63
|
+
interfaceType: WalletInterfaceType.Solana,
|
|
64
|
+
chainInfo: {
|
|
65
|
+
namespace: Chain.Solana,
|
|
66
|
+
},
|
|
67
|
+
// Some wallet providers include leading whitespace in their icon URLs.
|
|
68
|
+
// Next.js 15+ and other frameworks are strict about URL formatting,
|
|
69
|
+
// so we trim
|
|
70
|
+
info: {
|
|
71
|
+
name: wallet.name,
|
|
72
|
+
...(wallet.icon && { icon: wallet.icon.trim() }),
|
|
73
|
+
},
|
|
74
|
+
provider: wallet,
|
|
75
|
+
connectedAddresses,
|
|
76
|
+
});
|
|
77
|
+
}));
|
|
78
|
+
return discovered;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Connects the wallet account, prompting the user if necessary.
|
|
82
|
+
*
|
|
83
|
+
* - Calls `standard:connect` only if no accounts are present. This will prompt the user to connect their wallet.
|
|
84
|
+
*
|
|
85
|
+
* @param provider - The wallet provider to connect.
|
|
86
|
+
* @returns A promise that resolves with the connected wallet's address.
|
|
87
|
+
* @throws {Error} If the wallet does not implement `standard:connect`.
|
|
88
|
+
*/
|
|
89
|
+
this.connectWalletAccount = async (provider) => {
|
|
90
|
+
const wallet = asSolana(provider);
|
|
91
|
+
return await connectAccount(wallet);
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Disconnects the wallet account using Wallet Standard.
|
|
95
|
+
*
|
|
96
|
+
* - Calls `standard:disconnect` if implemented.
|
|
97
|
+
* - Throws if the wallet does not implement `standard:disconnect`.
|
|
98
|
+
*
|
|
99
|
+
* @param provider - The wallet provider to disconnect.
|
|
100
|
+
* @returns A promise that resolves once the wallet disconnects.
|
|
101
|
+
* @throws {Error} If `standard:disconnect` is not supported by the wallet.
|
|
102
|
+
*/
|
|
103
|
+
this.disconnectWalletAccount = async (provider) => {
|
|
104
|
+
const wallet = asSolana(provider);
|
|
105
|
+
const disconnectFeature = wallet.features["standard:disconnect"];
|
|
106
|
+
if (disconnectFeature) {
|
|
107
|
+
await disconnectFeature.disconnect();
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw new Error("Wallet does not support standard:disconnect");
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Signs a message or transaction with the connected Solana wallet.
|
|
117
|
+
*
|
|
118
|
+
* - Ensures the wallet is connected (may prompt via `standard:connect` if its not).
|
|
119
|
+
* - `SignMessage` → `solana:signMessage` (returns hex signature).
|
|
120
|
+
* - `SignTransaction` → `solana:signTransaction` (returns hex signature).
|
|
121
|
+
*
|
|
122
|
+
* @param payload - UTF-8 string (for message) or hex string (for transaction bytes).
|
|
123
|
+
* @param provider - The wallet provider to use.
|
|
124
|
+
* @param intent - The signing intent.
|
|
125
|
+
* @returns Hex-encoded signature (no 0x prefix).
|
|
126
|
+
* @throws {Error} If the provider lacks required features or intent is unsupported.
|
|
127
|
+
*/
|
|
128
|
+
class SolanaWallet extends BaseSolanaWallet {
|
|
129
|
+
constructor() {
|
|
130
|
+
super(...arguments);
|
|
131
|
+
this.sign = async (payload, provider, intent) => {
|
|
132
|
+
const wallet = asSolana(provider);
|
|
133
|
+
await connectAccount(wallet);
|
|
134
|
+
const account = wallet.accounts[0];
|
|
135
|
+
if (!account)
|
|
136
|
+
throw new Error("No account available");
|
|
137
|
+
switch (intent) {
|
|
138
|
+
case SignIntent.SignMessage: {
|
|
139
|
+
const signFeature = wallet.features["solana:signMessage"];
|
|
140
|
+
if (!signFeature)
|
|
141
|
+
throw new Error("Provider does not support solana:signMessage");
|
|
142
|
+
const data = new TextEncoder().encode(payload);
|
|
143
|
+
const results = await signFeature.signMessage({
|
|
144
|
+
account,
|
|
145
|
+
message: data,
|
|
146
|
+
});
|
|
147
|
+
if (!results?.length || !results[0]?.signature) {
|
|
148
|
+
throw new Error("No signature returned from signMessage");
|
|
149
|
+
}
|
|
150
|
+
return uint8ArrayToHexString(results[0].signature);
|
|
151
|
+
}
|
|
152
|
+
case SignIntent.SignTransaction: {
|
|
153
|
+
const signFeature = wallet.features["solana:signTransaction"];
|
|
154
|
+
if (!signFeature)
|
|
155
|
+
throw new Error("Provider does not support solana:signTransaction");
|
|
156
|
+
const data = uint8ArrayFromHexString(payload);
|
|
157
|
+
const results = await signFeature.signTransaction({
|
|
158
|
+
account,
|
|
159
|
+
transaction: data,
|
|
160
|
+
});
|
|
161
|
+
if (!results?.length || !results[0]?.signedTransaction) {
|
|
162
|
+
throw new Error("No signature returned from signTransaction");
|
|
163
|
+
}
|
|
164
|
+
return uint8ArrayToHexString(results[0].signedTransaction);
|
|
165
|
+
}
|
|
166
|
+
default:
|
|
167
|
+
throw new Error(`Unsupported sign intent: ${intent}`);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Casts a WalletRpcProvider to a Wallet Standard Solana wallet.
|
|
174
|
+
*
|
|
175
|
+
* - Validates presence of the Wallet Standard `features` map and `solana:signMessage`.
|
|
176
|
+
* - Use this before calling Solana-specific features (signMessage, signTransaction, etc.).
|
|
177
|
+
*
|
|
178
|
+
* @param provider - The wallet provider to cast.
|
|
179
|
+
* @returns The Wallet Standard wallet object.
|
|
180
|
+
* @throws {Error} If the provider is not a Wallet Standard Solana wallet.
|
|
181
|
+
*/
|
|
182
|
+
const asSolana = (provider) => {
|
|
183
|
+
if (provider.provider &&
|
|
184
|
+
"features" in provider.provider &&
|
|
185
|
+
"solana:signMessage" in provider.provider.features) {
|
|
186
|
+
return provider.provider;
|
|
187
|
+
}
|
|
188
|
+
throw new Error("Expected a Wallet-Standard provider (Solana wallet)");
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Ensures the given Wallet Standard wallet has at least one connected account.
|
|
192
|
+
*
|
|
193
|
+
* - If accounts already exist, resolves immediately.
|
|
194
|
+
* - If not, attempts `standard:connect`, which may prompt the user.
|
|
195
|
+
*
|
|
196
|
+
* @param wallet - The Wallet Standard wallet to connect.
|
|
197
|
+
* @returns A promise that resolves with the connected wallet's address.
|
|
198
|
+
* @throws {Error} If the wallet does not implement `standard:connect`.
|
|
199
|
+
*/
|
|
200
|
+
const connectAccount = async (wallet) => {
|
|
201
|
+
if (wallet.accounts.length)
|
|
202
|
+
return wallet.accounts[0].address;
|
|
203
|
+
const stdConnect = wallet.features["standard:connect"];
|
|
204
|
+
if (stdConnect) {
|
|
205
|
+
await stdConnect.connect();
|
|
206
|
+
return wallet.accounts[0].address;
|
|
207
|
+
}
|
|
208
|
+
throw new Error("Wallet is not connected and does not implement standard:connect");
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export { BaseSolanaWallet, SolanaWallet };
|
|
212
|
+
//# sourceMappingURL=solana.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.mjs","sources":["../../../../src/__wallet__/web/native/solana.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAkBA;;;;;;;AAOG;MACmB,gBAAgB,CAAA;AAAtC,IAAA,WAAA,GAAA;AACW,QAAA,IAAA,CAAA,aAAa,GAAG,mBAAmB,CAAC,MAAM;AAQnD;;;;;;;;;AASG;AACH,QAAA,IAAA,CAAA,YAAY,GAAG,OAAO,QAAwB,KAAqB;AACjE,YAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC;AACjC,YAAA,MAAM,cAAc,CAAC,MAAM,CAAC;YAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClC,IAAI,CAAC,OAAO,EAAE;AACZ,gBAAA,MAAM,IAAI,KAAK,CAAC,sBAAs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B,KAAe;IACvD,IACE,QAAQ,CAAC,QAAQ;QACjB,UAAU,IAAI,QAAQ,CAAC,QAAQ;AAC/B,QAAA,oBAAoB,IAAK,QAAQ,CAAC,QAAgB,CAAC,QAAQ,EAC3D;QACA,OAAO,QAAQ,CAAC,QAAqB;IACvC;AACA,IAAA,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC;AACxE,CAAC;AAED;;;;;;;;;AASG;AACH,MAAM,cAAc,GAAG,OAAO,MAAiB,KAAqB;AAClE,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,OAAO;IAE9D,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAExC;IAEb,IAAI,UAAU,EAAE;AACd,QAAA,MAAM,UAAU,CAAC,OAAO,EAAE;QAC1B,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,OAAO;IACpC;AAEA,IAAA,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE;AACH,CAAC;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export { ApiKeyStamper, signWithApiKey, type TApiKeyStamperConfig, } from "@0xkey-io/api-key-stamper";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export { type TWebauthnStamperConfig, WebauthnStamper, } from "@0xkey-io/webauthn-stamper";
|
|
5
|
+
export { ZeroXKeyClient, type ZeroXKeyClientMethods } from "./__clients__/core";
|
|
6
|
+
export { type ZeroXKeySDKClientBase } from "./__generated__/sdk-client-base";
|
|
7
|
+
export * from "./__types__/auth";
|
|
8
|
+
export * from "./__types__/config";
|
|
9
|
+
export * from "./__types__/enums";
|
|
10
|
+
export * from "./__types__/error";
|
|
11
|
+
export * from "./__types__/export";
|
|
12
|
+
export * from "./__types__/external-wallets";
|
|
13
|
+
export * from "./__types__/http";
|
|
14
|
+
export * from "./__types__/method-types/import-export-params";
|
|
15
|
+
export * from "./__types__/method-types/shared";
|
|
16
|
+
/**@internal */
|
|
17
|
+
export { generateWalletAccountsFromAddressFormat, isEthereumProvider, isSolanaProvider, getAuthProxyConfig, sendSignedRequest, decodeVerificationToken, getClientSignatureMessageForLogin, getClientSignatureMessageForSignup, addressFormatConfig, } from "./utils";
|
|
18
|
+
export * from "@0xkey-io/sdk-types";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,gBAAgB;AAChB,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,oBAAoB,GAC1B,MAAM,2BAA2B,CAAC;AAGnC,gBAAgB;AAChB,OAAO,EACL,KAAK,sBAAsB,EAC3B,eAAe,GAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAG7E,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,+CAA+C,CAAC;AAC9D,cAAc,iCAAiC,CAAC;AAEhD,eAAe;AACf,OAAO,EACL,uCAAuC,EACvC,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,iCAAiC,EACjC,kCAAkC,EAClC,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var apiKeyStamper = require('@0xkey-io/api-key-stamper');
|
|
4
|
+
var webauthnStamper = require('@0xkey-io/webauthn-stamper');
|
|
5
|
+
var core = require('./__clients__/core.js');
|
|
6
|
+
var auth = require('./__types__/auth.js');
|
|
7
|
+
var enums = require('./__types__/enums.js');
|
|
8
|
+
var error = require('./__types__/error.js');
|
|
9
|
+
var http = require('./__types__/http.js');
|
|
10
|
+
var sdkTypes = require('@0xkey-io/sdk-types');
|
|
11
|
+
var utils = require('./utils.js');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(exports, "ApiKeyStamper", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return apiKeyStamper.ApiKeyStamper; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "signWithApiKey", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return apiKeyStamper.signWithApiKey; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "WebauthnStamper", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return webauthnStamper.WebauthnStamper; }
|
|
26
|
+
});
|
|
27
|
+
exports.ZeroXKeyClient = core.ZeroXKeyClient;
|
|
28
|
+
exports.DEFAULT_SESSION_EXPIRATION_IN_SECONDS = auth.DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
|
|
29
|
+
Object.defineProperty(exports, "Chain", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return enums.Chain; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "Curve", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return enums.Curve; }
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "FilterType", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return enums.FilterType; }
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "OtpType", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return enums.OtpType; }
|
|
44
|
+
});
|
|
45
|
+
exports.OtpTypeToFilterTypeMap = enums.OtpTypeToFilterTypeMap;
|
|
46
|
+
Object.defineProperty(exports, "SessionKey", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return enums.SessionKey; }
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "SignIntent", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () { return enums.SignIntent; }
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "StamperType", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return enums.StamperType; }
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, "WalletInterfaceType", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () { return enums.WalletInterfaceType; }
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "WalletSource", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () { return enums.WalletSource; }
|
|
65
|
+
});
|
|
66
|
+
exports.ZeroXKeyRequestError = error.ZeroXKeyRequestError;
|
|
67
|
+
exports.TERMINAL_ACTIVITY_STATUSES = http.TERMINAL_ACTIVITY_STATUSES;
|
|
68
|
+
exports.addressFormatConfig = utils.addressFormatConfig;
|
|
69
|
+
exports.decodeVerificationToken = utils.decodeVerificationToken;
|
|
70
|
+
exports.generateWalletAccountsFromAddressFormat = utils.generateWalletAccountsFromAddressFormat;
|
|
71
|
+
exports.getAuthProxyConfig = utils.getAuthProxyConfig;
|
|
72
|
+
exports.getClientSignatureMessageForLogin = utils.getClientSignatureMessageForLogin;
|
|
73
|
+
exports.getClientSignatureMessageForSignup = utils.getClientSignatureMessageForSignup;
|
|
74
|
+
exports.isEthereumProvider = utils.isEthereumProvider;
|
|
75
|
+
exports.isSolanaProvider = utils.isSolanaProvider;
|
|
76
|
+
exports.sendSignedRequest = utils.sendSignedRequest;
|
|
77
|
+
Object.keys(sdkTypes).forEach(function (k) {
|
|
78
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () { return sdkTypes[k]; }
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ApiKeyStamper, signWithApiKey } from '@0xkey-io/api-key-stamper';
|
|
2
|
+
export { WebauthnStamper } from '@0xkey-io/webauthn-stamper';
|
|
3
|
+
export { ZeroXKeyClient } from './__clients__/core.mjs';
|
|
4
|
+
export { DEFAULT_SESSION_EXPIRATION_IN_SECONDS } from './__types__/auth.mjs';
|
|
5
|
+
export { Chain, Curve, FilterType, OtpType, OtpTypeToFilterTypeMap, SessionKey, SignIntent, StamperType, WalletInterfaceType, WalletSource } from './__types__/enums.mjs';
|
|
6
|
+
export { ZeroXKeyRequestError } from './__types__/error.mjs';
|
|
7
|
+
export { TERMINAL_ACTIVITY_STATUSES } from './__types__/http.mjs';
|
|
8
|
+
export * from '@0xkey-io/sdk-types';
|
|
9
|
+
export { addressFormatConfig, decodeVerificationToken, generateWalletAccountsFromAddressFormat, getAuthProxyConfig, getClientSignatureMessageForLogin, getClientSignatureMessageForSignup, isEthereumProvider, isSolanaProvider, sendSignedRequest } from './utils.mjs';
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { type v1AddressFormat, type v1HashFunction, type v1PayloadEncoding, type Session, type externaldatav1Timestamp, type ProxyTSignupBody, type v1ApiKeyParamsV2, type v1AuthenticatorParamsV2, type v1WalletAccountParams, type v1WalletAccount, type v1OauthProviderParams, type v1SignRawPayloadResult, type v1TransactionType, type ProxyTGetWalletKitConfigResponse, type v1User, type v1CreatePolicyIntentV3, type VerificationToken, ZeroXKeyErrorCodes } from "@0xkey-io/sdk-types";
|
|
2
|
+
import { type CreateSubOrgParams, type WalletProvider, Chain, EvmChainInfo, SolanaChainInfo, EmbeddedWallet, StamperType, TSignedRequest } from "./__types__";
|
|
3
|
+
import type { ZeroXKeySDKClientBase } from "./__generated__/sdk-client-base";
|
|
4
|
+
type AddressFormatConfig = {
|
|
5
|
+
encoding: v1PayloadEncoding;
|
|
6
|
+
hashFunction: v1HashFunction;
|
|
7
|
+
defaultAccounts: v1WalletAccountParams[] | null;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const addressFormatConfig: Record<v1AddressFormat, AddressFormatConfig>;
|
|
11
|
+
export declare const googleISS = "https://accounts.google.com";
|
|
12
|
+
export declare const isReactNative: () => boolean;
|
|
13
|
+
export declare const isWeb: () => boolean;
|
|
14
|
+
export declare const generateRandomBuffer: () => ArrayBuffer;
|
|
15
|
+
export declare const bytesToHex: (bytes: Uint8Array) => string;
|
|
16
|
+
export declare const toExternalTimestamp: (date?: Date) => externaldatav1Timestamp;
|
|
17
|
+
export declare function getActiveSessionOrThrowIfRequired(stampWith: StamperType | undefined, getActiveSession: () => Promise<Session | undefined>): Promise<Session | undefined>;
|
|
18
|
+
export declare function parseSession(token: string | Session): Session;
|
|
19
|
+
export declare function getHashFunction(addressFormat: v1AddressFormat): v1HashFunction;
|
|
20
|
+
export declare function getEncodingType(addressFormat: v1AddressFormat): v1PayloadEncoding;
|
|
21
|
+
export declare function getEncodedMessage(payloadEncoding: v1PayloadEncoding, rawMessage: Uint8Array): string;
|
|
22
|
+
export declare function hexSignedTxToBase58(hex: string): string;
|
|
23
|
+
export declare const broadcastTransaction: (params: {
|
|
24
|
+
signedTransaction: string;
|
|
25
|
+
rpcUrl: string;
|
|
26
|
+
transactionType: v1TransactionType;
|
|
27
|
+
}) => Promise<string>;
|
|
28
|
+
export declare function splitSignature(signature: string, addressFormat: v1AddressFormat): v1SignRawPayloadResult;
|
|
29
|
+
export declare function isWalletAccountArray(arr: any[]): arr is v1WalletAccountParams[];
|
|
30
|
+
export declare function createWalletAccountFromAddressFormat(addressFormat: v1AddressFormat): v1WalletAccountParams;
|
|
31
|
+
/**@internal */
|
|
32
|
+
export declare function generateWalletAccountsFromAddressFormat(params: {
|
|
33
|
+
addresses: v1AddressFormat[];
|
|
34
|
+
existingWalletAccounts?: v1WalletAccount[];
|
|
35
|
+
}): v1WalletAccountParams[];
|
|
36
|
+
export declare function buildSignUpBody(params: {
|
|
37
|
+
createSubOrgParams: CreateSubOrgParams | undefined;
|
|
38
|
+
}): ProxyTSignupBody;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts the public key from a ZeroXKey stamp header value.
|
|
41
|
+
* @param stampHeaderValue - The base64url encoded stamp header value
|
|
42
|
+
* @returns The public key as a hex string
|
|
43
|
+
*/
|
|
44
|
+
export declare function getPublicKeyFromStampHeader(stampHeaderValue: string): string;
|
|
45
|
+
/**@internal */
|
|
46
|
+
export declare function getPolicySignature(policy: v1CreatePolicyIntentV3): string;
|
|
47
|
+
/**@internal */
|
|
48
|
+
export declare function isEthereumProvider(provider: WalletProvider): provider is WalletProvider & {
|
|
49
|
+
chainInfo: EvmChainInfo;
|
|
50
|
+
};
|
|
51
|
+
/**@internal */
|
|
52
|
+
export declare function isSolanaProvider(provider: WalletProvider): provider is WalletProvider & {
|
|
53
|
+
chainInfo: SolanaChainInfo;
|
|
54
|
+
};
|
|
55
|
+
/** @internal */
|
|
56
|
+
export declare function getCurveTypeFromProvider(provider: WalletProvider): "API_KEY_CURVE_SECP256K1" | "API_KEY_CURVE_ED25519";
|
|
57
|
+
/** @internal */
|
|
58
|
+
export declare function getSignatureSchemeFromProvider(provider: WalletProvider): "SIGNATURE_SCHEME_TK_API_SECP256K1_EIP191" | "SIGNATURE_SCHEME_TK_API_ED25519";
|
|
59
|
+
/** @internal */
|
|
60
|
+
export declare function findWalletProviderFromAddress(address: string, providers: WalletProvider[]): WalletProvider | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Derives a wallet address from a given public key and chain.
|
|
63
|
+
*
|
|
64
|
+
* @param chain - "ethereum" or "solana"
|
|
65
|
+
* @param publicKey - The raw public key string (can be compressed or uncompressed)
|
|
66
|
+
* @returns The derived wallet address
|
|
67
|
+
*/
|
|
68
|
+
export declare function addressFromPublicKey(chain: Chain, publicKey: string): string;
|
|
69
|
+
/**@internal */
|
|
70
|
+
export declare function getAuthenticatorAddresses(user: v1User): {
|
|
71
|
+
ethereum: string[];
|
|
72
|
+
solana: string[];
|
|
73
|
+
};
|
|
74
|
+
/**@internal */
|
|
75
|
+
export declare function getAuthProxyConfig(authProxyConfigId: string, authProxyUrl?: string | undefined): Promise<ProxyTGetWalletKitConfigResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Submits a signed request to ZeroXKey.
|
|
78
|
+
*
|
|
79
|
+
* You can pass in the SignedRequest returned by any of the SDK's
|
|
80
|
+
* stamping methods (stampStampLogin, stampGetPolicies, etc.).
|
|
81
|
+
*
|
|
82
|
+
* @deprecated Use `httpClient.sendSignedRequest()` instead, which includes
|
|
83
|
+
* automatic activity polling and result extraction.
|
|
84
|
+
*
|
|
85
|
+
* @param signedRequest A SignedRequest object returned by a stamping method.
|
|
86
|
+
* @returns The parsed JSON response from ZeroXKey.
|
|
87
|
+
* @throws ZeroXKeyNetworkError if the request fails.
|
|
88
|
+
*/
|
|
89
|
+
export declare function sendSignedRequest<T = any>(signedRequest: TSignedRequest): Promise<T>;
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
* Executes an async function with error handling.
|
|
93
|
+
*
|
|
94
|
+
* @param fn The async function to execute with error handling
|
|
95
|
+
* @param errorOptions Options for customizing error handling
|
|
96
|
+
* @param errorOptions.catchFn Optional function to execute in the catch block
|
|
97
|
+
* @param errorOptions.errorMessage The default error message to use if no custom message is found
|
|
98
|
+
* @param errorOptions.errorCode The default error code to use if no custom message is found
|
|
99
|
+
* @param errorOptions.customErrorsByCodes Optional mapping of error codes to custom messages, if you're trying to target a specific error code and surface a custom message, use this
|
|
100
|
+
* @param errorOptions.customErrorsByMessages Optional mapping of error messages to custom messages, if you're trying to target a specific error message and surface a custom message, use this
|
|
101
|
+
* @param finallyFn Optional function to execute in the finally block
|
|
102
|
+
* @returns The result of the async function or throws an error
|
|
103
|
+
*/
|
|
104
|
+
export declare function withZeroXKeyErrorHandling<T>(fn: () => Promise<T>, catchOptions: {
|
|
105
|
+
catchFn?: () => Promise<void>;
|
|
106
|
+
errorMessage: string;
|
|
107
|
+
errorCode: ZeroXKeyErrorCodes;
|
|
108
|
+
customErrorsByCodes?: Partial<Record<ZeroXKeyErrorCodes, {
|
|
109
|
+
message: string;
|
|
110
|
+
code: ZeroXKeyErrorCodes;
|
|
111
|
+
}>>;
|
|
112
|
+
customErrorsByMessages?: Record<string, {
|
|
113
|
+
message: string;
|
|
114
|
+
code: ZeroXKeyErrorCodes;
|
|
115
|
+
}>;
|
|
116
|
+
}, finallyOptions?: {
|
|
117
|
+
finallyFn: () => Promise<void>;
|
|
118
|
+
}): Promise<T>;
|
|
119
|
+
/**
|
|
120
|
+
* @internal
|
|
121
|
+
*
|
|
122
|
+
* Asserts that the provided key pair is a valid P-256 ECDSA key pair.
|
|
123
|
+
* @param pair The key pair to validate.
|
|
124
|
+
*/
|
|
125
|
+
export declare function assertValidP256ECDSAKeyPair(pair: CryptoKeyPair): Promise<void>;
|
|
126
|
+
export declare function isValidPasskeyName(name: string): string;
|
|
127
|
+
export declare function mapAccountsToWallet(accounts: v1WalletAccount[], walletMap: Map<string, EmbeddedWallet>): EmbeddedWallet[];
|
|
128
|
+
export declare function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T>;
|
|
129
|
+
export declare function fetchAllWalletAccountsWithCursor(httpClient: ZeroXKeySDKClientBase, organizationId: string, stampWith?: StamperType): Promise<v1WalletAccount[]>;
|
|
130
|
+
export declare function decodeVerificationToken(verificationToken: string): VerificationToken;
|
|
131
|
+
export declare function getClientSignatureMessageForLogin({ verificationToken, sessionPublicKey, }: {
|
|
132
|
+
verificationToken: string;
|
|
133
|
+
sessionPublicKey?: string;
|
|
134
|
+
}): {
|
|
135
|
+
message: string;
|
|
136
|
+
publicKey: string;
|
|
137
|
+
};
|
|
138
|
+
export declare function getClientSignatureMessageForSignup({ verificationToken, email, phoneNumber, apiKeys, authenticators, oauthProviders, }: {
|
|
139
|
+
verificationToken: string;
|
|
140
|
+
email?: string;
|
|
141
|
+
phoneNumber?: string;
|
|
142
|
+
apiKeys?: v1ApiKeyParamsV2[];
|
|
143
|
+
authenticators?: v1AuthenticatorParamsV2[];
|
|
144
|
+
oauthProviders?: v1OauthProviderParams[];
|
|
145
|
+
}): {
|
|
146
|
+
message: string;
|
|
147
|
+
publicKey: string;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Wraps a promise with a timeout. If the promise doesn't resolve within
|
|
151
|
+
* the specified duration, it resolves to the fallback value instead of throwing.
|
|
152
|
+
*
|
|
153
|
+
* @param promise - The promise to wrap.
|
|
154
|
+
* @param fallback - Value to return if the timeout is reached.
|
|
155
|
+
* @param timeoutMs - Timeout duration in milliseconds. Defaults to 1000ms.
|
|
156
|
+
* @returns The result of the promise, or the fallback if timed out.
|
|
157
|
+
*/
|
|
158
|
+
export declare const withTimeoutFallback: <T>(promise: Promise<T>, fallback: T, timeoutMs?: number) => Promise<T>;
|
|
159
|
+
export {};
|
|
160
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"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