@universal-everything/sdk-core 1.0.0-dev.cb4e80f

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 ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023 LUKSO Blockchain GmbH
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @universal-everything/sdk-core
2
+
3
+ Framework-agnostic TypeScript client for the universal-relayer API.
4
+ Zero runtime deps — uses the `fetch` global and native types.
5
+
6
+ Every framework adapter (`sdk-react`, `sdk-vue`, `sdk-svelte`) and the
7
+ `@universal-everything/ui` web components build on top of this. Use it
8
+ directly from Node, Deno, Bun, Cloudflare Workers, or vanilla browser
9
+ JS.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pnpm add @universal-everything/sdk-core
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ ```ts
20
+ import { WalletKitClient, WalletKitError } from "@universal-everything/sdk-core";
21
+
22
+ const client = new WalletKitClient({
23
+ baseUrl: "https://relayer.example.com",
24
+ getAccessToken: async () => "your-privy-access-token",
25
+ });
26
+
27
+ try {
28
+ const wallets = await client.listWallets();
29
+ console.log(wallets);
30
+ } catch (err) {
31
+ if (err instanceof WalletKitError && err.code === "unauthenticated") {
32
+ // refresh token + retry
33
+ } else {
34
+ throw err;
35
+ }
36
+ }
37
+ ```
38
+
39
+ ## What's in the box
40
+
41
+ - `WalletKitClient` — one class, every endpoint.
42
+ - `me()`, `listWallets()`, `getWallet(id)`, `createWallet()`,
43
+ `patchWallet()`, `deleteWallet()`
44
+ - `listProfiles()`, `getProfile(id)`, `deployProfile()`, `importProfile()`
45
+ - `signTransaction()`, `signMessage()`, `signLsp25()`, `relaySponsored()`
46
+ - `getQuota()`, `beginKeyImport()` / `completeKeyImport()`,
47
+ `requestKeyExport()` / `cancelKeyExport()` / `completeKeyExport()`
48
+ - `WalletKitError` — every non-2xx response throws this with:
49
+ - `status: number` — HTTP status
50
+ - `code: string` — server's `error` discriminator (e.g.
51
+ `insufficient_quota`, `profile_not_found`, `unauthenticated`).
52
+ Network failures surface as `code: "network_error"`.
53
+ - `body: unknown` — parsed response body, useful for rich errors like
54
+ `{ error: "insufficient_quota", requested, available }`.
55
+ - Provider interfaces — `IdentityProvider`, `KeyCustodyProvider`, and
56
+ their error types. Implemented by `sdk-core-privy` (production) and
57
+ `sdk-core-local` (tests / local dev).
58
+
59
+ ## Authorization
60
+
61
+ - **Session auth**: pass `getAccessToken` to the constructor. Called
62
+ before each request. Return `null` if no session; the client omits
63
+ the `Authorization` header.
64
+ - **Privy per-op auth** (for operations on user-owned Privy wallets):
65
+ pass an `opContext` per call. `signMessage`, `signTransaction`,
66
+ `signLsp25`, `relaySponsored` all accept one in their options:
67
+ ```ts
68
+ await client.signMessage(msg, {
69
+ opContext: {
70
+ authorizationSignature: "…",
71
+ requestExpiry: Date.now() + 60_000,
72
+ },
73
+ });
74
+ ```
75
+
76
+ ## Custom fetch
77
+
78
+ Pass `fetch` in the constructor if you need to wire retries, proxying,
79
+ or a test mock:
80
+
81
+ ```ts
82
+ const client = new WalletKitClient({
83
+ baseUrl,
84
+ getAccessToken,
85
+ fetch: customFetch,
86
+ });
87
+ ```
88
+
89
+ ## Framework adapters
90
+
91
+ If you're using a framework, reach for the adapter instead of this
92
+ package directly:
93
+
94
+ - React → [`@universal-everything/sdk-react`](../sdk-react/)
95
+ - Vue 3 → [`@universal-everything/sdk-vue`](../sdk-vue/)
96
+ - Svelte 5 → [`@universal-everything/sdk-svelte`](../sdk-svelte/)
97
+ - Any framework (UI) → [`@universal-everything/ui`](../ui/) (Lit web components)
98
+ - viem integration → [`@universal-everything/sdk-core-viem`](../sdk-core-viem/)
@@ -0,0 +1,542 @@
1
+ type Hex = `0x${string}`;
2
+ type WalletInfo = {
3
+ walletId: string;
4
+ address: Hex;
5
+ };
6
+ type ExportedKey = {
7
+ privateKey: Hex;
8
+ address: Hex;
9
+ };
10
+ /**
11
+ * Minimal EVM transaction request shape. Providers may accept richer fields,
12
+ * but this is the contract.
13
+ */
14
+ type SignTxRequest = {
15
+ chainId: number;
16
+ to?: Hex;
17
+ data?: Hex;
18
+ value?: bigint;
19
+ gas?: bigint;
20
+ maxFeePerGas?: bigint;
21
+ maxPriorityFeePerGas?: bigint;
22
+ nonce?: number;
23
+ type?: "eip1559" | "legacy" | "eip2930";
24
+ };
25
+ /**
26
+ * Per-operation context forwarded by the relayer route handler to the
27
+ * provider. Providers that need user-side per-op authorization (e.g.
28
+ * Privy's `privy-authorization-signature` header) read from here;
29
+ * providers that don't (e.g. the in-memory LocalKeyCustodyProvider)
30
+ * ignore it. Keeping this on every key-touching call lets the relayer
31
+ * remain provider-agnostic.
32
+ */
33
+ type KeyCustodyOpContext = {
34
+ /**
35
+ * User-side authorization signature. For Privy this is the value of
36
+ * the `privy-authorization-signature` header the client generated via
37
+ * `generateAuthorizationSignature(payloadBytes)` from their SDK. The
38
+ * client signs the canonical request body (RFC 8785) with their
39
+ * passkey-derived P-256 key; we forward the signature verbatim.
40
+ */
41
+ authorizationSignature?: string;
42
+ /**
43
+ * Unix-ms timestamp after which the authorization signature is no
44
+ * longer valid. Forwarded to Privy as `privy-request-expiry`.
45
+ */
46
+ requestExpiry?: number;
47
+ };
48
+ /**
49
+ * Per-wallet operations. The user-to-wallet relationship lives in our DB,
50
+ * not in the provider — providers only know about backend wallets they
51
+ * manage, by the opaque walletId they assigned at creation time.
52
+ */
53
+ interface KeyCustodyProvider {
54
+ createWallet(opContext?: KeyCustodyOpContext): Promise<WalletInfo>;
55
+ importWallet(privateKey: Hex, opContext?: KeyCustodyOpContext): Promise<WalletInfo>;
56
+ exportWallet(walletId: string, opContext?: KeyCustodyOpContext): Promise<ExportedKey>;
57
+ /** Sign a raw 32-byte hash with no prefix. The LSP-25 path. */
58
+ signDigest(walletId: string, digest32: Uint8Array | Hex, opContext?: KeyCustodyOpContext): Promise<Hex>;
59
+ /** EIP-191 v0x45 personal_sign with the "\x19Ethereum Signed Message:\n" prefix. */
60
+ personalSign(walletId: string, message: string | Uint8Array, opContext?: KeyCustodyOpContext): Promise<Hex>;
61
+ /** Sign and serialize an EVM transaction for the user to broadcast themselves. */
62
+ signTransaction(walletId: string, tx: SignTxRequest, opContext?: KeyCustodyOpContext): Promise<Hex>;
63
+ }
64
+ type KeyCustodyErrorCode = "wallet_not_found" | "invalid_private_key" | "invalid_digest" | "invalid_signature" | "provider_unavailable" | "rate_limited";
65
+ declare class KeyCustodyError extends Error {
66
+ readonly code: KeyCustodyErrorCode;
67
+ constructor(code: KeyCustodyErrorCode, message: string);
68
+ }
69
+
70
+ /**
71
+ * `WalletKitClient` — typed HTTP client over the relayer's `/v1/*`
72
+ * REST API. Framework-agnostic: uses global `fetch`, no React / Vue /
73
+ * Privy imports. Consumers (sdk-react, sdk-vue, sdk-svelte, …)
74
+ * integrate their own auth flow and pass the access token in via
75
+ * `getAccessToken`.
76
+ *
77
+ * Design notes:
78
+ *
79
+ * - **Auth shape**: every protected call carries `Authorization:
80
+ * Bearer <token>`. The `getAccessToken` callback is invoked fresh
81
+ * per request so adapters using Privy's `useAccessToken` (which
82
+ * rotates JWTs silently) stay correct without the SDK caching
83
+ * anything.
84
+ * - **Privy per-op signature**: sign / relay endpoints accept an
85
+ * optional `opContext` with `authorizationSignature` +
86
+ * `requestExpiry`. The SDK forwards those as
87
+ * `privy-authorization-signature` + `privy-request-expiry` headers
88
+ * per Privy's convention, exactly matching the relayer's
89
+ * `opContextFromHeaders` parser.
90
+ * - **Errors**: non-2xx responses throw `WalletKitError`. The `code`
91
+ * field is the server's `error` discriminator (`"profile_not_found"`,
92
+ * `"insufficient_quota"`, etc.), mirrored verbatim so consumers can
93
+ * `switch` on it.
94
+ * - **Types**: response shapes are defined here rather than imported
95
+ * from the relayer — this package must not depend on the server
96
+ * tree. Wire-compatibility is the contract. If a field drifts,
97
+ * bump a minor and make it optional first.
98
+ */
99
+
100
+ type WalletKitClientConfig = {
101
+ /** Base URL of the relayer (no trailing slash; the client tolerates either). */
102
+ baseUrl: string;
103
+ /**
104
+ * Fetch-a-token callback. Can be sync or async. Return `null` to
105
+ * send the request unauthed (which the relayer's auth middleware
106
+ * will promptly 401 for protected routes).
107
+ */
108
+ getAccessToken: () => Promise<string | null> | string | null;
109
+ /** Fetch override for tests / SSR / custom transport. Defaults to global `fetch`. */
110
+ fetch?: typeof fetch;
111
+ };
112
+ type Wallet = {
113
+ walletId: string;
114
+ subject: string;
115
+ address: Hex;
116
+ privyWalletId: string;
117
+ label: string | null;
118
+ isPrimary: boolean;
119
+ createdAt: string;
120
+ };
121
+ type ControllerSummary = {
122
+ controllerId: string;
123
+ address: Hex;
124
+ label: string | null;
125
+ isDefault: boolean;
126
+ walletId: string | null;
127
+ isSignable: boolean;
128
+ };
129
+ type ProfileStatus = "active" | "pending_deploy" | "failed_deploy";
130
+ /**
131
+ * Per-row profile shape — returned by `importProfile`, `deployProfile`,
132
+ * and `PATCH /v1/profiles/:profileId`. One row per (address, chain).
133
+ */
134
+ type Profile = {
135
+ profileId: string;
136
+ address: Hex;
137
+ chainId: number;
138
+ label: string | null;
139
+ status?: ProfileStatus;
140
+ defaultControllerId: string | null;
141
+ controllers: ControllerSummary[];
142
+ createdAt: string;
143
+ };
144
+ /**
145
+ * Per-chain status entry inside `ProfileWithChains.chains`. For C.1 each
146
+ * address has at most one entry; C.2's cross-chain orchestration grows
147
+ * `chains[]` as queued deploys progress.
148
+ */
149
+ /**
150
+ * Cross-chain `deploy_queue` row state. Surfaced on `ChainStatus` so
151
+ * clients can render queued/submitted progress for cross-chain ops
152
+ * (Milestone C.2). `null` for single-chain profiles — no queue row
153
+ * exists.
154
+ */
155
+ type DeployQueueStatus = "pending_submit" | "submitted" | "mined" | "errored" | "cancelled";
156
+ type ChainStatus = {
157
+ profileId: string;
158
+ chainId: number;
159
+ status: ProfileStatus;
160
+ label: string | null;
161
+ defaultControllerId: string | null;
162
+ controllers: ControllerSummary[];
163
+ /** Engine tx hash; null until Engine broadcasts. */
164
+ txHash: string | null;
165
+ lastUpdatedAt: string;
166
+ errorMessage: string | null;
167
+ /** `deploy_queue.status` for cross-chain rows; `null` single-chain. */
168
+ queueStatus: DeployQueueStatus | null;
169
+ };
170
+ /**
171
+ * Address-grouped profile shape — returned by `listProfiles` and
172
+ * `getProfileByAddress`. Address is the natural primary key once a UP
173
+ * may live on multiple chains (handoff G1).
174
+ */
175
+ type ProfileWithChains = {
176
+ address: Hex;
177
+ chains: ChainStatus[];
178
+ };
179
+ type QuotaSnapshot = {
180
+ subject: string;
181
+ periodStart: string;
182
+ includedRemaining: string;
183
+ topupRemaining: string;
184
+ total: string;
185
+ };
186
+ /**
187
+ * A paid subscription snapshot (from `GET /v1/billing/subscription`).
188
+ * `tier` is left as `string` so a server-side tier addition doesn't
189
+ * require an SDK bump to read.
190
+ */
191
+ type SubscriptionSnapshot = {
192
+ subject: string;
193
+ tier: string;
194
+ /** `'active' | 'trialing'` mean feature access is granted. */
195
+ status: string;
196
+ source: "stripe" | "apple" | "google";
197
+ externalId: string;
198
+ currentPeriodEnd: string | null;
199
+ };
200
+ /**
201
+ * The synthesized free-tier default — the shape returned when the user
202
+ * has no paid subscription. `source === null` is the discriminant.
203
+ */
204
+ type FreeDefaultSnapshot = {
205
+ subject: string;
206
+ tier: "free";
207
+ status: "active";
208
+ source: null;
209
+ externalId: null;
210
+ currentPeriodEnd: null;
211
+ };
212
+ type SubscriptionResponse = SubscriptionSnapshot | FreeDefaultSnapshot;
213
+ /** Stripe-hosted Checkout session (from `POST /v1/billing/checkout-session`). */
214
+ type CheckoutSession = {
215
+ id: string;
216
+ url: string;
217
+ };
218
+ type OpenCheckoutInput = {
219
+ /** Only `"pro"` is purchasable today; the server 400s any other tier. */
220
+ tier: "pro";
221
+ /** Deep link for a mobile in-app browser sheet to hop back into the host app. */
222
+ returnDeepLink?: string;
223
+ /** Origin Stripe returns to after checkout. Defaults to `window.location.origin` in a browser. */
224
+ returnOrigin?: string;
225
+ /**
226
+ * Browser only: navigate to the Stripe URL after creating the session.
227
+ * Defaults to `true`. Set `false` to just get `{ url }` back and open it
228
+ * yourself (native in-app sheet, popup, etc.). No-op with no `window`.
229
+ */
230
+ redirect?: boolean;
231
+ };
232
+ type OpContext = {
233
+ authorizationSignature: string;
234
+ requestExpiry?: number;
235
+ };
236
+ type SignTransactionInput = {
237
+ chainId: number;
238
+ to?: Hex;
239
+ data?: Hex;
240
+ value?: string;
241
+ gas?: string;
242
+ maxFeePerGas?: string;
243
+ maxPriorityFeePerGas?: string;
244
+ nonce?: number;
245
+ type?: "eip1559" | "legacy" | "eip2930";
246
+ };
247
+ type SignTransactionResponse = {
248
+ rawTx: Hex;
249
+ walletId: string;
250
+ address: Hex;
251
+ chainId: number;
252
+ };
253
+ type SignMessageResponse = {
254
+ signature: Hex;
255
+ walletId: string;
256
+ address: Hex;
257
+ };
258
+ type SignLsp25Input = {
259
+ profileId: string;
260
+ controllerId?: string;
261
+ value: string;
262
+ calldata: Hex;
263
+ nonce: string;
264
+ validityTimestamps: string;
265
+ };
266
+ type SignLsp25Response = {
267
+ signature: Hex;
268
+ digest: Hex;
269
+ profileId: string;
270
+ controllerId: string;
271
+ controllerAddress: Hex;
272
+ target: Hex;
273
+ chainId: number;
274
+ nonce: string;
275
+ validityTimestamps: string;
276
+ value: string;
277
+ calldata: Hex;
278
+ };
279
+ type RelaySponsoredInput = {
280
+ profileId: string;
281
+ controllerId?: string;
282
+ value: string;
283
+ calldata: Hex;
284
+ validityTimestamps?: string;
285
+ channel?: string;
286
+ };
287
+ type RelaySponsoredResponse = {
288
+ queueId: string;
289
+ nonce: string;
290
+ channel: string;
291
+ profileId: string;
292
+ controllerId: string;
293
+ controllerAddress: Hex;
294
+ target: Hex;
295
+ chainId: number;
296
+ signature: Hex;
297
+ };
298
+ /**
299
+ * A1 control proof accompanying an external `controllerAddress` deploy — a
300
+ * signature by that address over a nonce-bound challenge (see
301
+ * `@universal-everything/sdk-core-viem`'s `buildControlProof`). The
302
+ * `nonce` comes from {@link WalletKitClient.getNonce}.
303
+ */
304
+ type ControlProof = {
305
+ /** 65-byte EIP-191 signature (0x-prefixed, 132 chars) by `controllerAddress`. */
306
+ signature: Hex;
307
+ /** Single-use nonce from `POST /v1/auth/nonce`. */
308
+ nonce: string;
309
+ /** Signature issuance time, unix seconds (server freshness-checks it). */
310
+ issuedAtUnix: number;
311
+ };
312
+ type NonceResponse = {
313
+ nonce: string;
314
+ issuedAt: string;
315
+ };
316
+ type DeployProfileBase = {
317
+ chainId: number;
318
+ label?: string | null;
319
+ predictedAddress: Hex;
320
+ deploymentCalldata: Hex;
321
+ /**
322
+ * Multi-chain target set. When length > 1 the response is
323
+ * {@link DeployProfileMultiChainResponse}; the user's current chain
324
+ * (`chainId`) must be included. Single-chain (`undefined` or
325
+ * length 1) returns {@link DeployProfileSingleChainResponse} as before.
326
+ * External-controller (A1) deploys are single-chain only.
327
+ */
328
+ chains?: number[];
329
+ };
330
+ /**
331
+ * Deploy a sponsored Universal Profile. Two mutually-exclusive controller
332
+ * modes:
333
+ * - **custody**: `controllerWalletId` — a relayer-held wallet row.
334
+ * - **external (A1)**: `controllerAddress` + `controlProof` — a user-held key
335
+ * (a Privy embedded wallet, or an extension/mobile key) that proves control
336
+ * by signing a nonce-bound challenge. Build the proof with
337
+ * `@universal-everything/sdk-core-viem`'s `buildControlProof`.
338
+ */
339
+ type DeployProfileInput = (DeployProfileBase & {
340
+ controllerWalletId: string;
341
+ controllerAddress?: never;
342
+ controlProof?: never;
343
+ }) | (DeployProfileBase & {
344
+ controllerAddress: Hex;
345
+ controlProof: ControlProof;
346
+ controllerWalletId?: never;
347
+ });
348
+ type DeployProfileSingleChainResponse = {
349
+ multiChain: false;
350
+ profileId: string;
351
+ predictedAddress: Hex;
352
+ chainId: number;
353
+ engineTxId: string;
354
+ status: "pending_deploy";
355
+ };
356
+ type DeployProfileMultiChainResponse = {
357
+ multiChain: true;
358
+ opId: string;
359
+ predictedAddress: Hex;
360
+ chains: Array<{
361
+ chainId: number;
362
+ profileId: string;
363
+ queueId: string;
364
+ queueStatus: "submitted" | "pending_submit";
365
+ engineTxId: string | null;
366
+ }>;
367
+ };
368
+ type DeployProfileResponse = DeployProfileSingleChainResponse | DeployProfileMultiChainResponse;
369
+ type ImportBeginResponse = {
370
+ importId: string;
371
+ serverPublicKey: Hex;
372
+ expiresAt: string;
373
+ };
374
+ type ImportCompleteInput = {
375
+ importId: string;
376
+ clientPublicKey: Hex;
377
+ sealed: Hex;
378
+ label?: string | null;
379
+ };
380
+ type ImportCompleteResponse = {
381
+ walletId: string;
382
+ address: Hex;
383
+ linkedControllers: number;
384
+ };
385
+ type ExportRequestInput = {
386
+ walletId: string;
387
+ clientPublicKey: Hex;
388
+ };
389
+ type ExportRequestResponse = {
390
+ exportId: string;
391
+ availableAt: string;
392
+ expiresAt: string;
393
+ };
394
+ type ExportCompleteResponse = {
395
+ sealed: Hex;
396
+ serverPublicKey: Hex;
397
+ address: Hex;
398
+ };
399
+ declare class WalletKitError extends Error {
400
+ readonly status: number;
401
+ /** Server's `error` discriminator, or `"network_error"` on transport failure. */
402
+ readonly code: string;
403
+ readonly body: unknown;
404
+ constructor(status: number, code: string, message: string, body: unknown);
405
+ }
406
+ /**
407
+ * Server `error` discriminators that represent a billing / plan-limit
408
+ * wall — either 402 "out of quota" (buy more) or 403 "your tier doesn't
409
+ * include this" (upgrade). `#request` promotes any response carrying one
410
+ * of these codes to a {@link TierError}. `chain_unavailable` (503) is
411
+ * deliberately absent: it's an operator-side outage, not the caller's plan.
412
+ */
413
+ declare const TIER_ERROR_CODES: ReadonlySet<string>;
414
+ /**
415
+ * A billing / plan-limit condition — the caller hit a quota or a tier
416
+ * boundary the server refuses to cross. Subclass of {@link WalletKitError}
417
+ * so existing `instanceof WalletKitError` handling still catches it, while
418
+ * `instanceof TierError` lets a host app show an upgrade / top-up prompt
419
+ * instead of a generic failure. Switch on `.code` for the specific wall
420
+ * (see {@link TIER_ERROR_CODES}).
421
+ *
422
+ * The typed getters are conveniences over `body`; each is populated only
423
+ * for the codes whose payload carries that field (e.g. `allowedChains`
424
+ * on `tier_not_allowed_for_chain`), and `undefined` otherwise. `body`
425
+ * remains the source of truth.
426
+ */
427
+ declare class TierError extends WalletKitError {
428
+ #private;
429
+ constructor(status: number, code: string, message: string, body: unknown);
430
+ /** Caller's current tier, when the server reports it (`tier` / `currentTier`). */
431
+ get tier(): string | undefined;
432
+ /** Chains the current tier may use (`tier_not_allowed_for_chain`). */
433
+ get allowedChains(): number[] | undefined;
434
+ /** Units requested (`insufficient_quota`). Stringified bigint from the server. */
435
+ get requested(): string | undefined;
436
+ /** Units available (`insufficient_quota`). Stringified bigint from the server. */
437
+ get available(): string | undefined;
438
+ /** The cap that was hit (`cross_chain_capacity_exceeded` / `kind_profile_cap_exceeded`). */
439
+ get cap(): number | undefined;
440
+ /** Current count against the cap. */
441
+ get current(): number | undefined;
442
+ /** Profile kind the cap applies to (`kind_*` / `cross_chain_*`). */
443
+ get kind(): string | undefined;
444
+ /** Chain id the tier didn't allow (`tier_not_allowed_for_chain`). */
445
+ get chainId(): number | undefined;
446
+ }
447
+ declare class WalletKitClient {
448
+ #private;
449
+ constructor(config: WalletKitClientConfig);
450
+ me(): Promise<{
451
+ subject: string;
452
+ isAdmin: boolean;
453
+ }>;
454
+ listWallets(): Promise<Wallet[]>;
455
+ getWallet(walletId: string): Promise<Wallet>;
456
+ createWallet(input?: {
457
+ label?: string | null;
458
+ }): Promise<Wallet>;
459
+ patchWallet(walletId: string, patch: {
460
+ label?: string | null;
461
+ isPrimary?: boolean;
462
+ }): Promise<Wallet>;
463
+ deleteWallet(walletId: string): Promise<{
464
+ walletId: string;
465
+ }>;
466
+ listProfiles(): Promise<ProfileWithChains[]>;
467
+ /**
468
+ * Address-keyed lookup. Returns the single address-grouped entry,
469
+ * with `chains[]` populated (length 1 for single-chain UPs).
470
+ */
471
+ getProfileByAddress(address: Hex): Promise<ProfileWithChains>;
472
+ deployProfile(input: DeployProfileInput): Promise<DeployProfileResponse>;
473
+ /**
474
+ * Fetch a single-use nonce (`POST /v1/auth/nonce`, public — no auth). Used to
475
+ * bind an A1 control proof for an external-controller {@link deployProfile}.
476
+ */
477
+ getNonce(): Promise<NonceResponse>;
478
+ importProfile(input: {
479
+ address: Hex;
480
+ chainId: number;
481
+ controllerWalletId: string;
482
+ label?: string | null;
483
+ }): Promise<Profile>;
484
+ signTransaction(input: SignTransactionInput, opts?: {
485
+ walletId?: string;
486
+ opContext?: OpContext;
487
+ }): Promise<SignTransactionResponse>;
488
+ signMessage(message: string, opts?: {
489
+ walletId?: string;
490
+ encoding?: "utf-8" | "hex";
491
+ opContext?: OpContext;
492
+ }): Promise<SignMessageResponse>;
493
+ signLsp25(input: SignLsp25Input, opContext?: OpContext): Promise<SignLsp25Response>;
494
+ relaySponsored(input: RelaySponsoredInput, opContext?: OpContext): Promise<RelaySponsoredResponse>;
495
+ getQuota(): Promise<QuotaSnapshot>;
496
+ /**
497
+ * The caller's current subscription, or the synthesized free-tier
498
+ * default (`source === null`) when they have no paid subscription.
499
+ */
500
+ getSubscription(): Promise<SubscriptionResponse>;
501
+ /**
502
+ * Start a Stripe Checkout for a tier and return the created session
503
+ * `{ id, url }`. In a browser this ALSO navigates to `url` by default
504
+ * (opt out with `{ redirect: false }` to open the URL yourself — mobile
505
+ * in-app sheet, popup, etc.). Headless / SSR: no `window` ⇒ no
506
+ * navigation, the session is simply returned.
507
+ *
508
+ * Server errors surface as `WalletKitError` — notably `409
509
+ * subscription_exists` (already subscribed) and `400 tier_not_purchasable`.
510
+ */
511
+ openCheckout(input: OpenCheckoutInput): Promise<CheckoutSession>;
512
+ beginKeyImport(): Promise<ImportBeginResponse>;
513
+ completeKeyImport(input: ImportCompleteInput): Promise<ImportCompleteResponse>;
514
+ requestKeyExport(input: ExportRequestInput): Promise<ExportRequestResponse>;
515
+ cancelKeyExport(exportId: string): Promise<{
516
+ ok: true;
517
+ exportId: string;
518
+ }>;
519
+ completeKeyExport(exportId: string): Promise<ExportCompleteResponse>;
520
+ }
521
+ /** Factory mirroring other `createX` helpers in this workspace. */
522
+ declare function createWalletKitClient(config: WalletKitClientConfig): WalletKitClient;
523
+
524
+ type Subject = string;
525
+ type VerifiedToken = {
526
+ subject: Subject;
527
+ claims: Record<string, unknown>;
528
+ };
529
+ type VerifyOptions = {
530
+ audience?: string | string[];
531
+ authorizedParties?: string[];
532
+ };
533
+ interface IdentityProvider {
534
+ verifyToken(token: string, opts?: VerifyOptions): Promise<VerifiedToken>;
535
+ }
536
+ type IdentityErrorCode = "missing_token" | "invalid_token" | "expired_token" | "missing_subject" | "azp_mismatch" | "issuer_mismatch" | "audience_mismatch" | "jwks_unavailable" | "provider_unavailable";
537
+ declare class IdentityError extends Error {
538
+ readonly code: IdentityErrorCode;
539
+ constructor(code: IdentityErrorCode, message: string);
540
+ }
541
+
542
+ export { type ChainStatus, type CheckoutSession, type ControlProof, type ControllerSummary, type DeployProfileInput, type DeployProfileMultiChainResponse, type DeployProfileResponse, type DeployProfileSingleChainResponse, type DeployQueueStatus, type ExportCompleteResponse, type ExportRequestInput, type ExportRequestResponse, type ExportedKey, type FreeDefaultSnapshot, type Hex, IdentityError, type IdentityErrorCode, type IdentityProvider, type ImportBeginResponse, type ImportCompleteInput, type ImportCompleteResponse, KeyCustodyError, type KeyCustodyErrorCode, type KeyCustodyOpContext, type KeyCustodyProvider, type NonceResponse, type OpContext, type OpenCheckoutInput, type Profile, type ProfileStatus, type ProfileWithChains, type QuotaSnapshot, type RelaySponsoredInput, type RelaySponsoredResponse, type SignLsp25Input, type SignLsp25Response, type SignMessageResponse, type SignTransactionInput, type SignTransactionResponse, type SignTxRequest, type Subject, type SubscriptionResponse, type SubscriptionSnapshot, TIER_ERROR_CODES, TierError, type VerifiedToken, type VerifyOptions, type Wallet, type WalletInfo, WalletKitClient, type WalletKitClientConfig, WalletKitError, createWalletKitClient };
package/dist/index.js ADDED
@@ -0,0 +1,289 @@
1
+ // src/client.ts
2
+ var WalletKitError = class extends Error {
3
+ status;
4
+ /** Server's `error` discriminator, or `"network_error"` on transport failure. */
5
+ code;
6
+ body;
7
+ constructor(status, code, message, body) {
8
+ super(message);
9
+ this.name = "WalletKitError";
10
+ this.status = status;
11
+ this.code = code;
12
+ this.body = body;
13
+ }
14
+ };
15
+ var TIER_ERROR_CODES = /* @__PURE__ */ new Set([
16
+ "insufficient_quota",
17
+ "tier_not_allowed_for_chain",
18
+ "cross_chain_capacity_exceeded",
19
+ "cross_chain_chain_not_eligible",
20
+ "kind_profile_cap_exceeded"
21
+ ]);
22
+ var TierError = class extends WalletKitError {
23
+ constructor(status, code, message, body) {
24
+ super(status, code, message, body);
25
+ this.name = "TierError";
26
+ }
27
+ #field(key) {
28
+ return typeof this.body === "object" && this.body !== null && key in this.body ? this.body[key] : void 0;
29
+ }
30
+ /** Caller's current tier, when the server reports it (`tier` / `currentTier`). */
31
+ get tier() {
32
+ return this.#field("currentTier") ?? this.#field("tier");
33
+ }
34
+ /** Chains the current tier may use (`tier_not_allowed_for_chain`). */
35
+ get allowedChains() {
36
+ return this.#field("allowedChains");
37
+ }
38
+ /** Units requested (`insufficient_quota`). Stringified bigint from the server. */
39
+ get requested() {
40
+ return this.#field("requested");
41
+ }
42
+ /** Units available (`insufficient_quota`). Stringified bigint from the server. */
43
+ get available() {
44
+ return this.#field("available");
45
+ }
46
+ /** The cap that was hit (`cross_chain_capacity_exceeded` / `kind_profile_cap_exceeded`). */
47
+ get cap() {
48
+ return this.#field("cap");
49
+ }
50
+ /** Current count against the cap. */
51
+ get current() {
52
+ return this.#field("current");
53
+ }
54
+ /** Profile kind the cap applies to (`kind_*` / `cross_chain_*`). */
55
+ get kind() {
56
+ return this.#field("kind");
57
+ }
58
+ /** Chain id the tier didn't allow (`tier_not_allowed_for_chain`). */
59
+ get chainId() {
60
+ return this.#field("chainId");
61
+ }
62
+ };
63
+ var WalletKitClient = class {
64
+ #baseUrl;
65
+ #getAccessToken;
66
+ #fetch;
67
+ constructor(config) {
68
+ if (!config.baseUrl) throw new Error("WalletKitClient: baseUrl required");
69
+ this.#baseUrl = config.baseUrl.replace(/\/+$/, "");
70
+ this.#getAccessToken = config.getAccessToken;
71
+ this.#fetch = config.fetch ?? ((input, init) => fetch(input, init));
72
+ }
73
+ // --- identity ---
74
+ async me() {
75
+ return this.#request("GET", "/v1/me");
76
+ }
77
+ // --- wallets ---
78
+ async listWallets() {
79
+ return (await this.#request("GET", "/v1/wallets")).wallets;
80
+ }
81
+ async getWallet(walletId) {
82
+ return this.#request("GET", `/v1/wallets/${encodeURIComponent(walletId)}`);
83
+ }
84
+ async createWallet(input = {}) {
85
+ return this.#request("POST", "/v1/wallets", input);
86
+ }
87
+ async patchWallet(walletId, patch) {
88
+ return this.#request(
89
+ "PATCH",
90
+ `/v1/wallets/${encodeURIComponent(walletId)}`,
91
+ patch
92
+ );
93
+ }
94
+ async deleteWallet(walletId) {
95
+ return this.#request(
96
+ "DELETE",
97
+ `/v1/wallets/${encodeURIComponent(walletId)}`
98
+ );
99
+ }
100
+ // --- profiles ---
101
+ async listProfiles() {
102
+ return (await this.#request(
103
+ "GET",
104
+ "/v1/profiles"
105
+ )).profiles;
106
+ }
107
+ /**
108
+ * Address-keyed lookup. Returns the single address-grouped entry,
109
+ * with `chains[]` populated (length 1 for single-chain UPs).
110
+ */
111
+ async getProfileByAddress(address) {
112
+ return this.#request("GET", `/v1/profiles/${encodeURIComponent(address)}`);
113
+ }
114
+ async deployProfile(input) {
115
+ return this.#request("POST", "/v1/profiles", input);
116
+ }
117
+ /**
118
+ * Fetch a single-use nonce (`POST /v1/auth/nonce`, public — no auth). Used to
119
+ * bind an A1 control proof for an external-controller {@link deployProfile}.
120
+ */
121
+ async getNonce() {
122
+ return this.#request("POST", "/v1/auth/nonce");
123
+ }
124
+ async importProfile(input) {
125
+ return this.#request("POST", "/v1/profiles/import", input);
126
+ }
127
+ // --- signing ---
128
+ async signTransaction(input, opts = {}) {
129
+ return this.#request(
130
+ "POST",
131
+ "/v1/sign/transaction",
132
+ { walletId: opts.walletId, tx: input },
133
+ opts.opContext
134
+ );
135
+ }
136
+ async signMessage(message, opts = {}) {
137
+ return this.#request(
138
+ "POST",
139
+ "/v1/sign/message",
140
+ { walletId: opts.walletId, message, encoding: opts.encoding },
141
+ opts.opContext
142
+ );
143
+ }
144
+ async signLsp25(input, opContext) {
145
+ return this.#request("POST", "/v1/sign/lsp25", input, opContext);
146
+ }
147
+ // --- relay ---
148
+ async relaySponsored(input, opContext) {
149
+ return this.#request("POST", "/v1/relay/sponsored", input, opContext);
150
+ }
151
+ // --- quota ---
152
+ async getQuota() {
153
+ return this.#request("GET", "/v1/quota");
154
+ }
155
+ // --- billing ---
156
+ /**
157
+ * The caller's current subscription, or the synthesized free-tier
158
+ * default (`source === null`) when they have no paid subscription.
159
+ */
160
+ async getSubscription() {
161
+ return this.#request("GET", "/v1/billing/subscription");
162
+ }
163
+ /**
164
+ * Start a Stripe Checkout for a tier and return the created session
165
+ * `{ id, url }`. In a browser this ALSO navigates to `url` by default
166
+ * (opt out with `{ redirect: false }` to open the URL yourself — mobile
167
+ * in-app sheet, popup, etc.). Headless / SSR: no `window` ⇒ no
168
+ * navigation, the session is simply returned.
169
+ *
170
+ * Server errors surface as `WalletKitError` — notably `409
171
+ * subscription_exists` (already subscribed) and `400 tier_not_purchasable`.
172
+ */
173
+ async openCheckout(input) {
174
+ const loc = globalThis.window?.location;
175
+ const returnOrigin = input.returnOrigin ?? loc?.origin;
176
+ const session = await this.#request(
177
+ "POST",
178
+ "/v1/billing/checkout-session",
179
+ {
180
+ tier: input.tier,
181
+ ...input.returnDeepLink ? { returnDeepLink: input.returnDeepLink } : {},
182
+ ...returnOrigin ? { returnOrigin } : {}
183
+ }
184
+ );
185
+ if (input.redirect !== false && loc) {
186
+ loc.href = session.url;
187
+ }
188
+ return session;
189
+ }
190
+ // --- key import / export ---
191
+ async beginKeyImport() {
192
+ return this.#request("GET", "/v1/keys/import/begin");
193
+ }
194
+ async completeKeyImport(input) {
195
+ return this.#request("POST", "/v1/keys/import/complete", input);
196
+ }
197
+ async requestKeyExport(input) {
198
+ return this.#request("POST", "/v1/keys/export/request", input);
199
+ }
200
+ async cancelKeyExport(exportId) {
201
+ return this.#request("POST", "/v1/keys/export/cancel", { exportId });
202
+ }
203
+ async completeKeyExport(exportId) {
204
+ return this.#request("POST", "/v1/keys/export/complete", { exportId });
205
+ }
206
+ // ----------------------------------------------------------------------
207
+ // internals
208
+ // ----------------------------------------------------------------------
209
+ async #request(method, path, body, opContext) {
210
+ const token = await this.#getAccessToken();
211
+ const headers = {};
212
+ if (token) headers.Authorization = `Bearer ${token}`;
213
+ if (body !== void 0) headers["Content-Type"] = "application/json";
214
+ if (opContext?.authorizationSignature) {
215
+ headers["privy-authorization-signature"] = opContext.authorizationSignature;
216
+ if (opContext.requestExpiry !== void 0) {
217
+ headers["privy-request-expiry"] = String(opContext.requestExpiry);
218
+ }
219
+ }
220
+ let response;
221
+ try {
222
+ response = await this.#fetch(`${this.#baseUrl}${path}`, {
223
+ method,
224
+ headers,
225
+ body: body === void 0 ? void 0 : JSON.stringify(body)
226
+ });
227
+ } catch (err) {
228
+ throw new WalletKitError(
229
+ 0,
230
+ "network_error",
231
+ `${method} ${path} transport failed: ${err instanceof Error ? err.message : String(err)}`,
232
+ null
233
+ );
234
+ }
235
+ if (response.status === 204) {
236
+ return void 0;
237
+ }
238
+ const text = await response.text();
239
+ let parsed;
240
+ if (text) {
241
+ try {
242
+ parsed = JSON.parse(text);
243
+ } catch {
244
+ parsed = text;
245
+ }
246
+ }
247
+ if (!response.ok) {
248
+ const code = typeof parsed === "object" && parsed !== null && "error" in parsed ? String(parsed.error) : `http_${response.status}`;
249
+ const msg = typeof parsed === "object" && parsed !== null && "message" in parsed ? String(parsed.message) : text || response.statusText;
250
+ if (TIER_ERROR_CODES.has(code)) {
251
+ throw new TierError(response.status, code, msg, parsed);
252
+ }
253
+ throw new WalletKitError(response.status, code, msg, parsed);
254
+ }
255
+ return parsed;
256
+ }
257
+ };
258
+ function createWalletKitClient(config) {
259
+ return new WalletKitClient(config);
260
+ }
261
+
262
+ // src/identity.ts
263
+ var IdentityError = class extends Error {
264
+ code;
265
+ constructor(code, message) {
266
+ super(message);
267
+ this.name = "IdentityError";
268
+ this.code = code;
269
+ }
270
+ };
271
+
272
+ // src/key-custody.ts
273
+ var KeyCustodyError = class extends Error {
274
+ code;
275
+ constructor(code, message) {
276
+ super(message);
277
+ this.name = "KeyCustodyError";
278
+ this.code = code;
279
+ }
280
+ };
281
+ export {
282
+ IdentityError,
283
+ KeyCustodyError,
284
+ TIER_ERROR_CODES,
285
+ TierError,
286
+ WalletKitClient,
287
+ WalletKitError,
288
+ createWalletKitClient
289
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@universal-everything/sdk-core",
3
+ "version": "1.0.0-dev.cb4e80f",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/universal-everything/universal-relayer.git",
7
+ "directory": "packages/sdk-core"
8
+ },
9
+ "type": "module",
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "devDependencies": {
25
+ "typescript": "^5.7.0",
26
+ "vitest": "^4.1.10",
27
+ "tsup": "^8.5.0"
28
+ },
29
+ "scripts": {
30
+ "typecheck": "tsc --noEmit",
31
+ "test": "vitest run",
32
+ "build": "tsup"
33
+ }
34
+ }