@universal-everything/sdk-core 1.4.0-dev.ee9f053 → 1.5.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/dist/index.d.ts CHANGED
@@ -462,7 +462,8 @@ type SubscriptionSnapshot = {
462
462
  tier: string;
463
463
  /** `'active' | 'trialing'` mean feature access is granted. */
464
464
  status: string;
465
- source: "stripe" | "apple" | "google";
465
+ /** `'admin'` = granted by the relayer's team; no store to manage it in. */
466
+ source: "stripe" | "apple" | "google" | "admin";
466
467
  externalId: string;
467
468
  currentPeriodEnd: string | null;
468
469
  };
@@ -859,6 +860,36 @@ declare class WalletKitClient {
859
860
  store: "apple";
860
861
  signedTransaction: string;
861
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
+ }>;
862
893
  /**
863
894
  * Stripe Customer Portal URL for the caller's own Stripe subscription.
864
895
  * Rejects with `manage_in_store` (409) for an Apple / Google subscription
@@ -880,6 +911,34 @@ declare class WalletKitClient {
880
911
  * subscription_exists` (already subscribed) and `400 tier_not_purchasable`.
881
912
  */
882
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
+ }>;
883
942
  beginKeyImport(): Promise<ImportBeginResponse>;
884
943
  completeKeyImport(input: ImportCompleteInput): Promise<ImportCompleteResponse>;
885
944
  requestKeyExport(input: ExportRequestInput): Promise<ExportRequestResponse>;
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.ee9f053",
3
+ "version": "1.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/universal-everything/universal-relayer.git",