@universal-everything/sdk-core 1.4.0-dev.8f0230b → 1.4.0-dev.97bad56

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
@@ -397,12 +397,60 @@ type ProfileWithChains = {
397
397
  extend: ExtendVerdict;
398
398
  chains: ChainStatus[];
399
399
  };
400
- type QuotaSnapshot = {
401
- 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;
402
420
  periodStart: string;
403
421
  includedRemaining: string;
422
+ includedPerPeriod: string;
404
423
  topupRemaining: string;
405
- 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[];
406
454
  };
407
455
  /**
408
456
  * A paid subscription snapshot (from `GET /v1/billing/subscription`).
@@ -414,7 +462,8 @@ type SubscriptionSnapshot = {
414
462
  tier: string;
415
463
  /** `'active' | 'trialing'` mean feature access is granted. */
416
464
  status: string;
417
- source: "stripe" | "apple" | "google";
465
+ /** `'admin'` = granted by the relayer's team; no store to manage it in. */
466
+ source: "stripe" | "apple" | "google" | "admin";
418
467
  externalId: string;
419
468
  currentPeriodEnd: string | null;
420
469
  };
@@ -811,6 +860,36 @@ declare class WalletKitClient {
811
860
  store: "apple";
812
861
  signedTransaction: string;
813
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
+ }>;
814
893
  /**
815
894
  * Stripe Customer Portal URL for the caller's own Stripe subscription.
816
895
  * Rejects with `manage_in_store` (409) for an Apple / Google subscription
@@ -832,6 +911,34 @@ declare class WalletKitClient {
832
911
  * subscription_exists` (already subscribed) and `400 tier_not_purchasable`.
833
912
  */
834
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
+ }>;
835
942
  beginKeyImport(): Promise<ImportBeginResponse>;
836
943
  completeKeyImport(input: ImportCompleteInput): Promise<ImportCompleteResponse>;
837
944
  requestKeyExport(input: ExportRequestInput): Promise<ExportRequestResponse>;
@@ -862,4 +969,4 @@ declare class IdentityError extends Error {
862
969
  constructor(code: IdentityErrorCode, message: string);
863
970
  }
864
971
 
865
- 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 PublicChain, 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
@@ -257,6 +257,26 @@ var WalletKitClient = class {
257
257
  async claimSubscription(input) {
258
258
  return this.#request("POST", "/v1/subscriptions/claim", input);
259
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
+ }
260
280
  /**
261
281
  * Stripe Customer Portal URL for the caller's own Stripe subscription.
262
282
  * Rejects with `manage_in_store` (409) for an Apple / Google subscription
@@ -292,6 +312,50 @@ var WalletKitClient = class {
292
312
  }
293
313
  return session;
294
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
+ }
295
359
  // --- key import / export ---
296
360
  async beginKeyImport() {
297
361
  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.4.0-dev.8f0230b",
3
+ "version": "1.4.0-dev.97bad56",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/universal-everything/universal-relayer.git",