@universal-everything/sdk-core 1.3.0 → 1.4.0-dev.03fce44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +142 -5
- package/dist/index.js +72 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -290,6 +290,28 @@ type SubscriptionMember = {
|
|
|
290
290
|
/** Added by a client sync rather than by hand. */
|
|
291
291
|
auto: boolean;
|
|
292
292
|
attachedAt: string;
|
|
293
|
+
/**
|
|
294
|
+
* The networks the relayer holds the profile on (whoever holds it), with
|
|
295
|
+
* each row's deploy status, ascending by chain. Empty ⇒ no row anywhere.
|
|
296
|
+
*/
|
|
297
|
+
chains: Array<{
|
|
298
|
+
chainId: number;
|
|
299
|
+
status: ProfileStatus;
|
|
300
|
+
}>;
|
|
301
|
+
};
|
|
302
|
+
/** One network of `GET /v1/chains` — the relayer's public catalog. */
|
|
303
|
+
type PublicChain = {
|
|
304
|
+
chainId: number;
|
|
305
|
+
name: string;
|
|
306
|
+
kind: "mainnet" | "testnet";
|
|
307
|
+
/** Operator kill-switch; a disabled chain is never sponsorable. */
|
|
308
|
+
enabled: boolean;
|
|
309
|
+
/** The backend wallet can sponsor gas right now. */
|
|
310
|
+
funded: boolean;
|
|
311
|
+
/** Public default RPC for browser read-only calls. */
|
|
312
|
+
rpcUrl: string;
|
|
313
|
+
/** Network icon (https or `data:` URL); null ⇒ show initials. */
|
|
314
|
+
iconUrl: string | null;
|
|
293
315
|
};
|
|
294
316
|
/**
|
|
295
317
|
* One entry of `GET /v1/subscriptions`: a subscription of the caller's account
|
|
@@ -375,12 +397,60 @@ type ProfileWithChains = {
|
|
|
375
397
|
extend: ExtendVerdict;
|
|
376
398
|
chains: ChainStatus[];
|
|
377
399
|
};
|
|
378
|
-
|
|
379
|
-
|
|
400
|
+
/** One network kind's quota (`GET /v1/quota` → `kinds`). */
|
|
401
|
+
type KindQuota = {
|
|
402
|
+
/** Whole percent of this kind's monthly credits left (0–100); null = no allowance. */
|
|
403
|
+
percentRemaining: number | null;
|
|
404
|
+
/** When the monthly credits refill (ISO, first of next month UTC). */
|
|
405
|
+
resetsAt: string;
|
|
406
|
+
/** Profiles of this kind vs the cap. The cap only limits creating new ones. */
|
|
407
|
+
profiles?: {
|
|
408
|
+
used: number;
|
|
409
|
+
cap: number;
|
|
410
|
+
};
|
|
411
|
+
/** Cross-chain tickets of this kind: used vs cap. Tickets don't renew monthly. */
|
|
412
|
+
crossChain?: {
|
|
413
|
+
used: number;
|
|
414
|
+
cap: number;
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
/** Gas on one chain, rendered from its kind's credits (legacy shape). */
|
|
418
|
+
type QuotaChain = {
|
|
419
|
+
chainId: number;
|
|
380
420
|
periodStart: string;
|
|
381
421
|
includedRemaining: string;
|
|
422
|
+
includedPerPeriod: string;
|
|
382
423
|
topupRemaining: string;
|
|
383
|
-
|
|
424
|
+
totalRemaining: string;
|
|
425
|
+
/** False for a chain the account holds a profile on but its plan doesn't fund. */
|
|
426
|
+
funded: boolean;
|
|
427
|
+
reason?: "tier_chain_not_allowed" | "chain_disabled";
|
|
428
|
+
note?: string;
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* `GET /v1/quota`. Credits are split into a mainnet and a testnet pool
|
|
432
|
+
* (`kinds`); `credits` is the mainnet pool, and `chains` renders each chain
|
|
433
|
+
* from its own kind's pool.
|
|
434
|
+
*/
|
|
435
|
+
type QuotaSnapshot = {
|
|
436
|
+
tier: string;
|
|
437
|
+
period: string;
|
|
438
|
+
kinds: {
|
|
439
|
+
mainnet: KindQuota;
|
|
440
|
+
testnet: KindQuota;
|
|
441
|
+
};
|
|
442
|
+
credits: {
|
|
443
|
+
remaining: string;
|
|
444
|
+
tierRemaining: string;
|
|
445
|
+
perPeriod: string;
|
|
446
|
+
};
|
|
447
|
+
allowedChains: Array<{
|
|
448
|
+
chainId: number;
|
|
449
|
+
name: string;
|
|
450
|
+
kind: "mainnet" | "testnet";
|
|
451
|
+
sponsored: true;
|
|
452
|
+
}>;
|
|
453
|
+
chains: QuotaChain[];
|
|
384
454
|
};
|
|
385
455
|
/**
|
|
386
456
|
* A paid subscription snapshot (from `GET /v1/billing/subscription`).
|
|
@@ -392,7 +462,8 @@ type SubscriptionSnapshot = {
|
|
|
392
462
|
tier: string;
|
|
393
463
|
/** `'active' | 'trialing'` mean feature access is granted. */
|
|
394
464
|
status: string;
|
|
395
|
-
|
|
465
|
+
/** `'admin'` = granted by the relayer's team; no store to manage it in. */
|
|
466
|
+
source: "stripe" | "apple" | "google" | "admin";
|
|
396
467
|
externalId: string;
|
|
397
468
|
currentPeriodEnd: string | null;
|
|
398
469
|
};
|
|
@@ -725,6 +796,14 @@ declare class WalletKitClient {
|
|
|
725
796
|
audience?: "user" | "dev";
|
|
726
797
|
store?: BillingStore;
|
|
727
798
|
}): Promise<Catalog>;
|
|
799
|
+
/**
|
|
800
|
+
* The relayer's networks with their kind, icon and sponsorability (public;
|
|
801
|
+
* no auth needed). Clients draw networks from this instead of their own
|
|
802
|
+
* lists.
|
|
803
|
+
*/
|
|
804
|
+
listChains(): Promise<{
|
|
805
|
+
chains: PublicChain[];
|
|
806
|
+
}>;
|
|
728
807
|
/**
|
|
729
808
|
* Every subscription of the caller's account, live ones first — what the
|
|
730
809
|
* dashboard's account / subscription dropdown renders.
|
|
@@ -781,6 +860,36 @@ declare class WalletKitClient {
|
|
|
781
860
|
store: "apple";
|
|
782
861
|
signedTransaction: string;
|
|
783
862
|
}): Promise<StoreTransactionResult>;
|
|
863
|
+
/**
|
|
864
|
+
* Merge the caller's account with the account of a Universal Profile the
|
|
865
|
+
* user signs in with now — "Already have a relayer account?" and linking
|
|
866
|
+
* the Privy, extension and mobile-app logins. Pass a fresh UP sign-in
|
|
867
|
+
* (`getNonce` → SIWE message whose Address is the profile → signature),
|
|
868
|
+
* the `POST /v1/auth/login` body. The account with a subscription (else
|
|
869
|
+
* the older one) survives; the other account's id keeps working as an
|
|
870
|
+
* alias. Call it with a Privy (email/social) session (`403
|
|
871
|
+
* privy_login_required` otherwise) and sign with the profile's primary
|
|
872
|
+
* key, the one it was created with (`403 primary_controller_required`;
|
|
873
|
+
* `primary_controller_unknown` when the relayer can't tell which key that
|
|
874
|
+
* is). `merged: false` =
|
|
875
|
+
* the profile already shared the caller's account (or had none yet and
|
|
876
|
+
* just joined it). `warning: "two_subscriptions"` = both accounts had a
|
|
877
|
+
* live subscription and the merged account now holds both. `401` = bad
|
|
878
|
+
* proof, `409 merge_not_allowed` = a developer account.
|
|
879
|
+
*/
|
|
880
|
+
mergeAccounts(proof: {
|
|
881
|
+
message: string;
|
|
882
|
+
signature: string;
|
|
883
|
+
chainId?: number;
|
|
884
|
+
}): Promise<{
|
|
885
|
+
accountId: string;
|
|
886
|
+
merged: boolean;
|
|
887
|
+
/** The profile wasn't registered with the relayer and was added
|
|
888
|
+
* (`false` + `addError` when adding it failed; the logins are linked). */
|
|
889
|
+
added?: boolean;
|
|
890
|
+
addError?: string;
|
|
891
|
+
warning?: "two_subscriptions";
|
|
892
|
+
}>;
|
|
784
893
|
/**
|
|
785
894
|
* Stripe Customer Portal URL for the caller's own Stripe subscription.
|
|
786
895
|
* Rejects with `manage_in_store` (409) for an Apple / Google subscription
|
|
@@ -802,6 +911,34 @@ declare class WalletKitClient {
|
|
|
802
911
|
* subscription_exists` (already subscribed) and `400 tier_not_purchasable`.
|
|
803
912
|
*/
|
|
804
913
|
openCheckout(input: OpenCheckoutInput): Promise<CheckoutSession>;
|
|
914
|
+
/**
|
|
915
|
+
* Buy a booster pack (DEV-16547): creates a Stripe Checkout session for the
|
|
916
|
+
* pack (`POST /v1/billing/topup-session`) and, in a browser, navigates to it
|
|
917
|
+
* unless `redirect: false`. Same return-origin defaulting as `openCheckout`.
|
|
918
|
+
* `returnDeepLink` is passed on but not honoured yet: Stripe returns to the
|
|
919
|
+
* relayer's web pages, which don't hand off to an app.
|
|
920
|
+
*/
|
|
921
|
+
openTopup(input: {
|
|
922
|
+
pack: string;
|
|
923
|
+
returnOrigin?: string;
|
|
924
|
+
returnDeepLink?: string;
|
|
925
|
+
redirect?: boolean;
|
|
926
|
+
}): Promise<CheckoutSession & {
|
|
927
|
+
credits?: string;
|
|
928
|
+
}>;
|
|
929
|
+
/**
|
|
930
|
+
* Manage or cancel a Stripe subscription (DEV-16547): opens the Stripe
|
|
931
|
+
* customer portal (`POST /v1/billing/portal-session`), in a browser by
|
|
932
|
+
* navigating unless `redirect: false`. A store-managed (Apple/Google)
|
|
933
|
+
* subscription is a `409 manage_in_store` `WalletKitError` — send the user to
|
|
934
|
+
* the store instead.
|
|
935
|
+
*/
|
|
936
|
+
openBillingPortal(input?: {
|
|
937
|
+
returnOrigin?: string;
|
|
938
|
+
redirect?: boolean;
|
|
939
|
+
}): Promise<{
|
|
940
|
+
url: string;
|
|
941
|
+
}>;
|
|
805
942
|
beginKeyImport(): Promise<ImportBeginResponse>;
|
|
806
943
|
completeKeyImport(input: ImportCompleteInput): Promise<ImportCompleteResponse>;
|
|
807
944
|
requestKeyExport(input: ExportRequestInput): Promise<ExportRequestResponse>;
|
|
@@ -832,4 +969,4 @@ declare class IdentityError extends Error {
|
|
|
832
969
|
constructor(code: IdentityErrorCode, message: string);
|
|
833
970
|
}
|
|
834
971
|
|
|
835
|
-
export { type AddSubscriptionProfileResult, type BillingStore, type Catalog, type CatalogDefaultPrice, type CatalogPlan, type CatalogProduct, type ChainStatus, type CheckoutSession, type ControlProof, type ControllerSummary, type CoveredBy, type DeployProfileInput, type DeployProfileMultiChainResponse, type DeployProfileResponse, type DeployProfileSingleChainResponse, type DeployQueueStatus, type ExportCompleteResponse, type ExportRequestInput, type ExportRequestResponse, type ExportedKey, type ExtendVerdict, type ExtendVerdictReason, type FreeDefaultSnapshot, type Hex, IdentityError, type IdentityErrorCode, type IdentityProvider, type ImportBeginResponse, type ImportCompleteInput, type ImportCompleteResponse, type IpfsUploadTokenResponse, KeyCustodyError, type KeyCustodyErrorCode, type KeyCustodyOpContext, type KeyCustodyProvider, type Me, 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 StoreTransactionResult, type Subject, type SubscriptionMember, type SubscriptionResponse, type SubscriptionSnapshot, type SubscriptionSummary, TIER_ERROR_CODES, TierError, type VerifiedToken, type VerifyOptions, type Wallet, type WalletInfo, WalletKitClient, type WalletKitClientConfig, WalletKitError, createWalletKitClient };
|
|
972
|
+
export { type AddSubscriptionProfileResult, type BillingStore, type Catalog, type CatalogDefaultPrice, type CatalogPlan, type CatalogProduct, type ChainStatus, type CheckoutSession, type ControlProof, type ControllerSummary, type CoveredBy, type DeployProfileInput, type DeployProfileMultiChainResponse, type DeployProfileResponse, type DeployProfileSingleChainResponse, type DeployQueueStatus, type ExportCompleteResponse, type ExportRequestInput, type ExportRequestResponse, type ExportedKey, type ExtendVerdict, type ExtendVerdictReason, type FreeDefaultSnapshot, type Hex, IdentityError, type IdentityErrorCode, type IdentityProvider, type ImportBeginResponse, type ImportCompleteInput, type ImportCompleteResponse, type IpfsUploadTokenResponse, KeyCustodyError, type KeyCustodyErrorCode, type KeyCustodyOpContext, type KeyCustodyProvider, type KindQuota, type Me, type NonceResponse, type OpContext, type OpenCheckoutInput, type Profile, type ProfileStatus, type ProfileWithChains, type PublicChain, type QuotaChain, type QuotaSnapshot, type RelaySponsoredInput, type RelaySponsoredResponse, type SignLsp25Input, type SignLsp25Response, type SignMessageResponse, type SignTransactionInput, type SignTransactionResponse, type SignTxRequest, type StoreTransactionResult, type Subject, type SubscriptionMember, type SubscriptionResponse, type SubscriptionSnapshot, type SubscriptionSummary, TIER_ERROR_CODES, TierError, type VerifiedToken, type VerifyOptions, type Wallet, type WalletInfo, WalletKitClient, type WalletKitClientConfig, WalletKitError, createWalletKitClient };
|
package/dist/index.js
CHANGED
|
@@ -184,6 +184,14 @@ var WalletKitClient = class {
|
|
|
184
184
|
const qs = query.toString();
|
|
185
185
|
return this.#request("GET", `/v1/billing/catalog${qs ? `?${qs}` : ""}`);
|
|
186
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* The relayer's networks with their kind, icon and sponsorability (public;
|
|
189
|
+
* no auth needed). Clients draw networks from this instead of their own
|
|
190
|
+
* lists.
|
|
191
|
+
*/
|
|
192
|
+
async listChains() {
|
|
193
|
+
return this.#request("GET", "/v1/chains");
|
|
194
|
+
}
|
|
187
195
|
/**
|
|
188
196
|
* Every subscription of the caller's account, live ones first — what the
|
|
189
197
|
* dashboard's account / subscription dropdown renders.
|
|
@@ -249,6 +257,26 @@ var WalletKitClient = class {
|
|
|
249
257
|
async claimSubscription(input) {
|
|
250
258
|
return this.#request("POST", "/v1/subscriptions/claim", input);
|
|
251
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Merge the caller's account with the account of a Universal Profile the
|
|
262
|
+
* user signs in with now — "Already have a relayer account?" and linking
|
|
263
|
+
* the Privy, extension and mobile-app logins. Pass a fresh UP sign-in
|
|
264
|
+
* (`getNonce` → SIWE message whose Address is the profile → signature),
|
|
265
|
+
* the `POST /v1/auth/login` body. The account with a subscription (else
|
|
266
|
+
* the older one) survives; the other account's id keeps working as an
|
|
267
|
+
* alias. Call it with a Privy (email/social) session (`403
|
|
268
|
+
* privy_login_required` otherwise) and sign with the profile's primary
|
|
269
|
+
* key, the one it was created with (`403 primary_controller_required`;
|
|
270
|
+
* `primary_controller_unknown` when the relayer can't tell which key that
|
|
271
|
+
* is). `merged: false` =
|
|
272
|
+
* the profile already shared the caller's account (or had none yet and
|
|
273
|
+
* just joined it). `warning: "two_subscriptions"` = both accounts had a
|
|
274
|
+
* live subscription and the merged account now holds both. `401` = bad
|
|
275
|
+
* proof, `409 merge_not_allowed` = a developer account.
|
|
276
|
+
*/
|
|
277
|
+
async mergeAccounts(proof) {
|
|
278
|
+
return this.#request("POST", "/v1/accounts/merge", proof);
|
|
279
|
+
}
|
|
252
280
|
/**
|
|
253
281
|
* Stripe Customer Portal URL for the caller's own Stripe subscription.
|
|
254
282
|
* Rejects with `manage_in_store` (409) for an Apple / Google subscription
|
|
@@ -284,6 +312,50 @@ var WalletKitClient = class {
|
|
|
284
312
|
}
|
|
285
313
|
return session;
|
|
286
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Buy a booster pack (DEV-16547): creates a Stripe Checkout session for the
|
|
317
|
+
* pack (`POST /v1/billing/topup-session`) and, in a browser, navigates to it
|
|
318
|
+
* unless `redirect: false`. Same return-origin defaulting as `openCheckout`.
|
|
319
|
+
* `returnDeepLink` is passed on but not honoured yet: Stripe returns to the
|
|
320
|
+
* relayer's web pages, which don't hand off to an app.
|
|
321
|
+
*/
|
|
322
|
+
async openTopup(input) {
|
|
323
|
+
const loc = globalThis.window?.location;
|
|
324
|
+
const returnOrigin = input.returnOrigin ?? loc?.origin;
|
|
325
|
+
const session = await this.#request(
|
|
326
|
+
"POST",
|
|
327
|
+
"/v1/billing/topup-session",
|
|
328
|
+
{
|
|
329
|
+
pack: input.pack,
|
|
330
|
+
...input.returnDeepLink ? { returnDeepLink: input.returnDeepLink } : {},
|
|
331
|
+
...returnOrigin ? { returnOrigin } : {}
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
if (input.redirect !== false && loc) {
|
|
335
|
+
loc.href = session.url;
|
|
336
|
+
}
|
|
337
|
+
return session;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Manage or cancel a Stripe subscription (DEV-16547): opens the Stripe
|
|
341
|
+
* customer portal (`POST /v1/billing/portal-session`), in a browser by
|
|
342
|
+
* navigating unless `redirect: false`. A store-managed (Apple/Google)
|
|
343
|
+
* subscription is a `409 manage_in_store` `WalletKitError` — send the user to
|
|
344
|
+
* the store instead.
|
|
345
|
+
*/
|
|
346
|
+
async openBillingPortal(input = {}) {
|
|
347
|
+
const loc = globalThis.window?.location;
|
|
348
|
+
const returnOrigin = input.returnOrigin ?? loc?.origin;
|
|
349
|
+
const session = await this.#request(
|
|
350
|
+
"POST",
|
|
351
|
+
"/v1/billing/portal-session",
|
|
352
|
+
returnOrigin ? { returnOrigin } : {}
|
|
353
|
+
);
|
|
354
|
+
if (input.redirect !== false && loc) {
|
|
355
|
+
loc.href = session.url;
|
|
356
|
+
}
|
|
357
|
+
return session;
|
|
358
|
+
}
|
|
287
359
|
// --- key import / export ---
|
|
288
360
|
async beginKeyImport() {
|
|
289
361
|
return this.#request("GET", "/v1/keys/import/begin");
|