@universal-everything/sdk-core 1.3.0 → 1.4.0-dev.02ce9e1

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 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
- type QuotaSnapshot = {
379
- subject: string;
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
- total: string;
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
- source: "stripe" | "apple" | "google";
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.
@@ -802,6 +881,34 @@ declare class WalletKitClient {
802
881
  * subscription_exists` (already subscribed) and `400 tier_not_purchasable`.
803
882
  */
804
883
  openCheckout(input: OpenCheckoutInput): Promise<CheckoutSession>;
884
+ /**
885
+ * Buy a booster pack (DEV-16547): creates a Stripe Checkout session for the
886
+ * pack (`POST /v1/billing/topup-session`) and, in a browser, navigates to it
887
+ * unless `redirect: false`. Same return-origin defaulting as `openCheckout`.
888
+ * `returnDeepLink` is passed on but not honoured yet: Stripe returns to the
889
+ * relayer's web pages, which don't hand off to an app.
890
+ */
891
+ openTopup(input: {
892
+ pack: string;
893
+ returnOrigin?: string;
894
+ returnDeepLink?: string;
895
+ redirect?: boolean;
896
+ }): Promise<CheckoutSession & {
897
+ credits?: string;
898
+ }>;
899
+ /**
900
+ * Manage or cancel a Stripe subscription (DEV-16547): opens the Stripe
901
+ * customer portal (`POST /v1/billing/portal-session`), in a browser by
902
+ * navigating unless `redirect: false`. A store-managed (Apple/Google)
903
+ * subscription is a `409 manage_in_store` `WalletKitError` — send the user to
904
+ * the store instead.
905
+ */
906
+ openBillingPortal(input?: {
907
+ returnOrigin?: string;
908
+ redirect?: boolean;
909
+ }): Promise<{
910
+ url: string;
911
+ }>;
805
912
  beginKeyImport(): Promise<ImportBeginResponse>;
806
913
  completeKeyImport(input: ImportCompleteInput): Promise<ImportCompleteResponse>;
807
914
  requestKeyExport(input: ExportRequestInput): Promise<ExportRequestResponse>;
@@ -832,4 +939,4 @@ declare class IdentityError extends Error {
832
939
  constructor(code: IdentityErrorCode, message: string);
833
940
  }
834
941
 
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 };
942
+ 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.
@@ -284,6 +292,50 @@ var WalletKitClient = class {
284
292
  }
285
293
  return session;
286
294
  }
295
+ /**
296
+ * Buy a booster pack (DEV-16547): creates a Stripe Checkout session for the
297
+ * pack (`POST /v1/billing/topup-session`) and, in a browser, navigates to it
298
+ * unless `redirect: false`. Same return-origin defaulting as `openCheckout`.
299
+ * `returnDeepLink` is passed on but not honoured yet: Stripe returns to the
300
+ * relayer's web pages, which don't hand off to an app.
301
+ */
302
+ async openTopup(input) {
303
+ const loc = globalThis.window?.location;
304
+ const returnOrigin = input.returnOrigin ?? loc?.origin;
305
+ const session = await this.#request(
306
+ "POST",
307
+ "/v1/billing/topup-session",
308
+ {
309
+ pack: input.pack,
310
+ ...input.returnDeepLink ? { returnDeepLink: input.returnDeepLink } : {},
311
+ ...returnOrigin ? { returnOrigin } : {}
312
+ }
313
+ );
314
+ if (input.redirect !== false && loc) {
315
+ loc.href = session.url;
316
+ }
317
+ return session;
318
+ }
319
+ /**
320
+ * Manage or cancel a Stripe subscription (DEV-16547): opens the Stripe
321
+ * customer portal (`POST /v1/billing/portal-session`), in a browser by
322
+ * navigating unless `redirect: false`. A store-managed (Apple/Google)
323
+ * subscription is a `409 manage_in_store` `WalletKitError` — send the user to
324
+ * the store instead.
325
+ */
326
+ async openBillingPortal(input = {}) {
327
+ const loc = globalThis.window?.location;
328
+ const returnOrigin = input.returnOrigin ?? loc?.origin;
329
+ const session = await this.#request(
330
+ "POST",
331
+ "/v1/billing/portal-session",
332
+ returnOrigin ? { returnOrigin } : {}
333
+ );
334
+ if (input.redirect !== false && loc) {
335
+ loc.href = session.url;
336
+ }
337
+ return session;
338
+ }
287
339
  // --- key import / export ---
288
340
  async beginKeyImport() {
289
341
  return this.#request("GET", "/v1/keys/import/begin");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@universal-everything/sdk-core",
3
- "version": "1.3.0",
3
+ "version": "1.4.0-dev.02ce9e1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/universal-everything/universal-relayer.git",