@metamask/subscription-controller 9.1.0 → 10.0.1

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/dist/SubscriptionService-structs.d.ts +150 -36
  3. package/dist/SubscriptionService-structs.d.ts.map +1 -1
  4. package/dist/SubscriptionService-structs.js +46 -12
  5. package/dist/SubscriptionService-structs.js.map +1 -1
  6. package/dist/index.d.ts +3 -3
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/selectors.d.ts +41 -1
  11. package/dist/selectors.d.ts.map +1 -1
  12. package/dist/selectors.js +65 -0
  13. package/dist/selectors.js.map +1 -1
  14. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.d.ts +5 -0
  15. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.d.ts.map +1 -1
  16. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.js.map +1 -1
  17. package/dist/subscription-delegation/SubscriptionDelegationService.d.ts +6 -1
  18. package/dist/subscription-delegation/SubscriptionDelegationService.d.ts.map +1 -1
  19. package/dist/subscription-delegation/SubscriptionDelegationService.js +35 -15
  20. package/dist/subscription-delegation/SubscriptionDelegationService.js.map +1 -1
  21. package/dist/subscription-delegation/fingerprint.d.ts +11 -0
  22. package/dist/subscription-delegation/fingerprint.d.ts.map +1 -1
  23. package/dist/subscription-delegation/fingerprint.js +40 -0
  24. package/dist/subscription-delegation/fingerprint.js.map +1 -1
  25. package/dist/types.d.ts +107 -17
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/types.js +39 -0
  28. package/dist/types.js.map +1 -1
  29. package/package.json +10 -10
@@ -66,4 +66,44 @@ export function makeMatchesSubscriptionDelegation(expected) {
66
66
  }
67
67
  };
68
68
  }
69
+ /**
70
+ * Reads the ERC-20 period-transfer `startDate` from a stored delegation.
71
+ *
72
+ * @param entry - Stored AUS delegation.
73
+ * @param enforcers - Enforcer addresses used to locate the period caveat.
74
+ * @returns Unix timestamp in seconds, or `undefined` when the caveat is
75
+ * missing or malformed.
76
+ */
77
+ function getSubscriptionDelegationStartDate(entry, enforcers) {
78
+ const periodCaveat = entry.signedDelegation.caveats.find((caveat) => equalsIgnoreCase(caveat.enforcer, enforcers.erc20TokenPeriodTransfer));
79
+ if (!periodCaveat) {
80
+ return undefined;
81
+ }
82
+ try {
83
+ return Number(decodeERC20TokenPeriodTransferTerms(periodCaveat.terms).startDate);
84
+ }
85
+ catch {
86
+ return undefined;
87
+ }
88
+ }
89
+ /**
90
+ * Returns the fingerprint match with the latest period `startDate`.
91
+ *
92
+ * Equal `startDate`s keep list order. A delegation whose `startDate` cannot
93
+ * be read sorts last.
94
+ *
95
+ * @param matches - Fingerprint-matching AUS delegations, in list order.
96
+ * @param enforcers - Enforcer addresses used to read `startDate`.
97
+ * @returns The preferred match, or `undefined` when `matches` is empty.
98
+ */
99
+ export function pickLatestMatchingSubscriptionDelegation(matches, enforcers) {
100
+ const byStartDateDescending = [...matches].sort((left, right) => {
101
+ const leftStart = getSubscriptionDelegationStartDate(left, enforcers) ??
102
+ Number.NEGATIVE_INFINITY;
103
+ const rightStart = getSubscriptionDelegationStartDate(right, enforcers) ??
104
+ Number.NEGATIVE_INFINITY;
105
+ return rightStart - leftStart;
106
+ });
107
+ return byStartDateDescending[0];
108
+ }
69
109
  //# sourceMappingURL=fingerprint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../src/subscription-delegation/fingerprint.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mCAAmC,EACnC,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAsB/D;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,KAAa;IAC1D,OAAO,IAAI,CAAC,WAAW,EAAE,KA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C,QAAQ,EACf,QAAQ,CAAC,SAAS,CAAC,wBAAwB,CAC5C,CACF,CAAC;QACF,IAAI,CAAC,cAAc,IAAI,CAAC,YAAY,EAAE,CAAC;YACrC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC7D,IAAI,UAAU,CAAC,QAAQ,KAAK,EAAE,EAAE,CAAC;gBAC/B,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,WAAW,GAAG,mCAAmC,CACrD,YAAY,CAAC,KAAK,CACnB,CAAC;YACF,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACtD,MAAM,gBAAgB,GAAG,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC;YAC/D,IAAI,QAAQ,CAAC,eAAe,KAAK,gBAAgB,EAAE,CAAC;gBAClD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,CACL,gBAAgB,CAAC,WAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC;gBACjE,WAAW,CAAC,YAAY,KAAK,QAAQ,CAAC,YAAY;gBAClD,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,QAAQ,CAAC,cAAc,CAC/D,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { DelegationResponse } from '@metamask/authenticated-user-storage';\nimport {\n decodeERC20TokenPeriodTransferTerms,\n decodeValueLteTerms,\n} from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SubscriptionDelegationEnforcers } from './types.js';\nimport { CASH_SUBSCRIPTION_DELEGATION_TYPE } from './types.js';\n\nexport type SubscriptionDelegationFingerprint = {\n delegatorAddress: Hex;\n delegateAddress: Hex;\n chainId: Hex;\n tokenAddress: Hex;\n periodAmount: bigint;\n periodDuration: number;\n /**\n * Current unix timestamp in seconds. Used to classify a stored period\n * `startDate` as immediately redeemable (`<= now`) vs trial-deferred (`> now`).\n */\n nowSeconds: number;\n /**\n * When true, only a still-deferred period start (`> nowSeconds`) matches.\n * When false, only an immediately redeemable start (`<= nowSeconds`) matches.\n */\n isTrialDeferred: boolean;\n enforcers: SubscriptionDelegationEnforcers;\n};\n\n/**\n * Case-insensitive hex equality.\n *\n * @param left - First hex value.\n * @param right - Second hex value.\n * @returns Whether the values are equal ignoring case.\n */\nexport function equalsIgnoreCase(left: string, right: string): boolean {\n return left.toLowerCase() === right.toLowerCase();\n}\n\n/**\n * Builds a predicate that matches a stored AUS delegation to the semantic\n * cash-subscription fingerprint. Salt is ignored so a previously signed\n * equivalent permission can be reused. Period `startDate` is compared only\n * as trial-deferred (`> nowSeconds`) vs immediately redeemable (`<= nowSeconds`)\n * so a positive-length trial cannot reuse a live permission and vice versa.\n *\n * @param expected - Semantic fields that must match.\n * @returns Predicate over {@link DelegationResponse}.\n */\nexport function makeMatchesSubscriptionDelegation(\n expected: SubscriptionDelegationFingerprint,\n): (entry: DelegationResponse) => boolean {\n return (entry) => {\n if (entry.metadata.type !== CASH_SUBSCRIPTION_DELEGATION_TYPE) {\n return false;\n }\n if (\n !equalsIgnoreCase(\n entry.signedDelegation.delegator,\n expected.delegatorAddress,\n )\n ) {\n return false;\n }\n if (\n !equalsIgnoreCase(\n entry.signedDelegation.delegate,\n expected.delegateAddress,\n )\n ) {\n return false;\n }\n if (!equalsIgnoreCase(entry.metadata.chainIdHex, expected.chainId)) {\n return false;\n }\n if (!equalsIgnoreCase(entry.metadata.tokenAddress, expected.tokenAddress)) {\n return false;\n }\n\n const { caveats } = entry.signedDelegation;\n if (caveats.length < 2) {\n return false;\n }\n\n const valueLteCaveat = caveats.find((caveat) =>\n equalsIgnoreCase(caveat.enforcer, expected.enforcers.valueLte),\n );\n const periodCaveat = caveats.find((caveat) =>\n equalsIgnoreCase(\n caveat.enforcer,\n expected.enforcers.erc20TokenPeriodTransfer,\n ),\n );\n if (!valueLteCaveat || !periodCaveat) {\n return false;\n }\n\n try {\n const valueTerms = decodeValueLteTerms(valueLteCaveat.terms);\n if (valueTerms.maxValue !== 0n) {\n return false;\n }\n\n const periodTerms = decodeERC20TokenPeriodTransferTerms(\n periodCaveat.terms,\n );\n const storedStartDate = Number(periodTerms.startDate);\n const isStoredDeferred = storedStartDate > expected.nowSeconds;\n if (expected.isTrialDeferred !== isStoredDeferred) {\n return false;\n }\n\n return (\n equalsIgnoreCase(periodTerms.tokenAddress, expected.tokenAddress) &&\n periodTerms.periodAmount === expected.periodAmount &&\n Number(periodTerms.periodDuration) === expected.periodDuration\n );\n } catch {\n return false;\n }\n };\n}\n"]}
1
+ {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../src/subscription-delegation/fingerprint.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mCAAmC,EACnC,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAsB/D;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,KAAa;IAC1D,OAAO,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;AACpD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iCAAiC,CAC/C,QAA2C;IAE3C,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,iCAAiC,EAAE,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IACE,CAAC,gBAAgB,CACf,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAChC,QAAQ,CAAC,gBAAgB,CAC1B,EACD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IACE,CAAC,gBAAgB,CACf,KAAK,CAAC,gBAAgB,CAAC,QAAQ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,iBAAiB,CAAC;QAC3B,MAAM,UAAU,GACd,kCAAkC,CAAC,KAAK,EAAE,SAAS,CAAC;YACpD,MAAM,CAAC,iBAAiB,CAAC;QAC3B,OAAO,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import type { DelegationResponse } from '@metamask/authenticated-user-storage';\nimport {\n decodeERC20TokenPeriodTransferTerms,\n decodeValueLteTerms,\n} from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\nimport type { SubscriptionDelegationEnforcers } from './types.js';\nimport { CASH_SUBSCRIPTION_DELEGATION_TYPE } from './types.js';\n\nexport type SubscriptionDelegationFingerprint = {\n delegatorAddress: Hex;\n delegateAddress: Hex;\n chainId: Hex;\n tokenAddress: Hex;\n periodAmount: bigint;\n periodDuration: number;\n /**\n * Current unix timestamp in seconds. Used to classify a stored period\n * `startDate` as immediately redeemable (`<= now`) vs trial-deferred (`> now`).\n */\n nowSeconds: number;\n /**\n * When true, only a still-deferred period start (`> nowSeconds`) matches.\n * When false, only an immediately redeemable start (`<= nowSeconds`) matches.\n */\n isTrialDeferred: boolean;\n enforcers: SubscriptionDelegationEnforcers;\n};\n\n/**\n * Case-insensitive hex equality.\n *\n * @param left - First hex value.\n * @param right - Second hex value.\n * @returns Whether the values are equal ignoring case.\n */\nexport function equalsIgnoreCase(left: string, right: string): boolean {\n return left.toLowerCase() === right.toLowerCase();\n}\n\n/**\n * Builds a predicate that matches a stored AUS delegation to the semantic\n * cash-subscription fingerprint. Salt is ignored so a previously signed\n * equivalent permission can be reused. Period `startDate` is compared only\n * as trial-deferred (`> nowSeconds`) vs immediately redeemable (`<= nowSeconds`)\n * so a positive-length trial cannot reuse a live permission and vice versa.\n *\n * @param expected - Semantic fields that must match.\n * @returns Predicate over {@link DelegationResponse}.\n */\nexport function makeMatchesSubscriptionDelegation(\n expected: SubscriptionDelegationFingerprint,\n): (entry: DelegationResponse) => boolean {\n return (entry) => {\n if (entry.metadata.type !== CASH_SUBSCRIPTION_DELEGATION_TYPE) {\n return false;\n }\n if (\n !equalsIgnoreCase(\n entry.signedDelegation.delegator,\n expected.delegatorAddress,\n )\n ) {\n return false;\n }\n if (\n !equalsIgnoreCase(\n entry.signedDelegation.delegate,\n expected.delegateAddress,\n )\n ) {\n return false;\n }\n if (!equalsIgnoreCase(entry.metadata.chainIdHex, expected.chainId)) {\n return false;\n }\n if (!equalsIgnoreCase(entry.metadata.tokenAddress, expected.tokenAddress)) {\n return false;\n }\n\n const { caveats } = entry.signedDelegation;\n if (caveats.length < 2) {\n return false;\n }\n\n const valueLteCaveat = caveats.find((caveat) =>\n equalsIgnoreCase(caveat.enforcer, expected.enforcers.valueLte),\n );\n const periodCaveat = caveats.find((caveat) =>\n equalsIgnoreCase(\n caveat.enforcer,\n expected.enforcers.erc20TokenPeriodTransfer,\n ),\n );\n if (!valueLteCaveat || !periodCaveat) {\n return false;\n }\n\n try {\n const valueTerms = decodeValueLteTerms(valueLteCaveat.terms);\n if (valueTerms.maxValue !== 0n) {\n return false;\n }\n\n const periodTerms = decodeERC20TokenPeriodTransferTerms(\n periodCaveat.terms,\n );\n const storedStartDate = Number(periodTerms.startDate);\n const isStoredDeferred = storedStartDate > expected.nowSeconds;\n if (expected.isTrialDeferred !== isStoredDeferred) {\n return false;\n }\n\n return (\n equalsIgnoreCase(periodTerms.tokenAddress, expected.tokenAddress) &&\n periodTerms.periodAmount === expected.periodAmount &&\n Number(periodTerms.periodDuration) === expected.periodDuration\n );\n } catch {\n return false;\n }\n };\n}\n\n/**\n * Reads the ERC-20 period-transfer `startDate` from a stored delegation.\n *\n * @param entry - Stored AUS delegation.\n * @param enforcers - Enforcer addresses used to locate the period caveat.\n * @returns Unix timestamp in seconds, or `undefined` when the caveat is\n * missing or malformed.\n */\nfunction getSubscriptionDelegationStartDate(\n entry: DelegationResponse,\n enforcers: SubscriptionDelegationEnforcers,\n): number | undefined {\n const periodCaveat = entry.signedDelegation.caveats.find((caveat) =>\n equalsIgnoreCase(caveat.enforcer, enforcers.erc20TokenPeriodTransfer),\n );\n if (!periodCaveat) {\n return undefined;\n }\n\n try {\n return Number(\n decodeERC20TokenPeriodTransferTerms(periodCaveat.terms).startDate,\n );\n } catch {\n return undefined;\n }\n}\n\n/**\n * Returns the fingerprint match with the latest period `startDate`.\n *\n * Equal `startDate`s keep list order. A delegation whose `startDate` cannot\n * be read sorts last.\n *\n * @param matches - Fingerprint-matching AUS delegations, in list order.\n * @param enforcers - Enforcer addresses used to read `startDate`.\n * @returns The preferred match, or `undefined` when `matches` is empty.\n */\nexport function pickLatestMatchingSubscriptionDelegation(\n matches: readonly DelegationResponse[],\n enforcers: SubscriptionDelegationEnforcers,\n): DelegationResponse | undefined {\n const byStartDateDescending = [...matches].sort((left, right) => {\n const leftStart =\n getSubscriptionDelegationStartDate(left, enforcers) ??\n Number.NEGATIVE_INFINITY;\n const rightStart =\n getSubscriptionDelegationStartDate(right, enforcers) ??\n Number.NEGATIVE_INFINITY;\n return rightStart - leftStart;\n });\n\n return byStartDateDescending[0];\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -90,6 +90,13 @@ export declare const SUBSCRIPTION_STATUSES: {
90
90
  readonly paused: 'paused';
91
91
  };
92
92
  export type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];
93
+ export declare const INVOICE_PAYMENT_STATUSES: {
94
+ readonly PROCESSING: 'PROCESSING';
95
+ readonly SUCCEEDED: 'SUCCEEDED';
96
+ readonly FAILED: 'FAILED';
97
+ readonly UNKNOWN: 'UNKNOWN';
98
+ };
99
+ export type InvoicePaymentStatus = (typeof INVOICE_PAYMENT_STATUSES)[keyof typeof INVOICE_PAYMENT_STATUSES];
93
100
  export declare const CANCEL_TYPES: {
94
101
  readonly ALLOWED_IMMEDIATE: 'allowed_immediate';
95
102
  readonly ALLOWED_AT_PERIOD_END: 'allowed_at_period_end';
@@ -106,6 +113,22 @@ export declare const CRYPTO_PAYMENT_METHOD_ERRORS: {
106
113
  readonly INSUFFICIENT_ALLOWANCE: 'insufficient_allowance';
107
114
  };
108
115
  export type CryptoPaymentMethodError = (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];
116
+ /**
117
+ * Errors returned by the Subscription API after crypto payment execution.
118
+ *
119
+ * These are distinct from {@link CRYPTO_PAYMENT_METHOD_ERRORS}, which describe
120
+ * approval/payment-method failures.
121
+ */
122
+ export declare const CRYPTO_PAYMENT_ERRORS: {
123
+ readonly INSUFFICIENT_BALANCE: 'insufficient_balance';
124
+ readonly INSUFFICIENT_ALLOWANCE: 'insufficient_allowance';
125
+ readonly EXCEEDS_DELEGATION_ALLOWANCE: 'exceeds_delegation_allowance';
126
+ readonly DELEGATION_NOT_FOUND: 'delegation_not_found';
127
+ readonly DELEGATION_REVOKED: 'delegation_revoked';
128
+ readonly RECIPIENT_NOT_ALLOWLISTED: 'recipient_not_allowlisted';
129
+ readonly INTERNAL_SERVER_ERROR: 'internal_server_error';
130
+ };
131
+ export type CryptoPaymentError = (typeof CRYPTO_PAYMENT_ERRORS)[keyof typeof CRYPTO_PAYMENT_ERRORS];
109
132
  export declare const MODAL_TYPE: {
110
133
  readonly A: 'A';
111
134
  readonly B: 'B';
@@ -122,8 +145,8 @@ export type Product = {
122
145
  export type Subscription = {
123
146
  id: string;
124
147
  products: Product[];
125
- currentPeriodStart: string;
126
- currentPeriodEnd: string;
148
+ currentPeriodStart?: string;
149
+ currentPeriodEnd?: string;
127
150
  /** is subscription scheduled for cancellation */
128
151
  cancelAtPeriodEnd?: boolean;
129
152
  status: SubscriptionStatus;
@@ -137,12 +160,20 @@ export type Subscription = {
137
160
  /** The date the subscription was canceled. */
138
161
  canceledAt?: string;
139
162
  /** The cancellation type indicating what cancellation options are available for this subscription. */
140
- cancelType: CancelType;
163
+ cancelType?: CancelType;
141
164
  /** The date the subscription was marked as inactive (paused/past_due/canceled). */
142
165
  inactiveAt?: string;
143
166
  /** Whether the user is eligible for support features (priority support and filing claims). True for active subscriptions and inactive subscriptions within grace period. */
144
- isEligibleForSupport: boolean;
167
+ isEligibleForSupport?: boolean;
145
168
  billingCycles?: number;
169
+ /** The most recent invoice associated with the subscription. */
170
+ lastInvoice?: SubscriptionInvoice;
171
+ };
172
+ export type SubscriptionInvoice = {
173
+ id: string;
174
+ status: InvoicePaymentStatus;
175
+ errorCode?: CryptoPaymentError;
176
+ updatedAt: string;
146
177
  };
147
178
  export type SubscriptionCardPaymentMethod = {
148
179
  type: Extract<PaymentType, 'card'>;
@@ -352,27 +383,62 @@ type TokenPaymentInfoBase = {
352
383
  sources?: TokenPaymentInfo[];
353
384
  };
354
385
  /**
355
- * Spot (non-vault) settlement token. Priced via `conversionRate` when provided.
356
- * `accountantAddress` is not present on this variant.
386
+ * Named vault a vault-share settlement token belongs to, e.g. `base` or
387
+ * `premium`. Distinguishes which vault to withdraw from.
388
+ *
389
+ * Deliberately a plain `string` rather than a union: the set of vaults is
390
+ * server-driven and grows without a client release, so narrowing it here would
391
+ * make the pricing response fail validation the first time the API adds a
392
+ * vault. Compare against `VAULT_NAMES` instead of raw literals, and always
393
+ * handle the unknown case.
357
394
  */
358
- export type SpotTokenPaymentInfo = TokenPaymentInfoBase & {
359
- isVaultShare?: false;
395
+ export type VaultName = string;
396
+ /**
397
+ * The vault names known at the time of writing. Not exhaustive — see
398
+ * {@link VaultName}.
399
+ */
400
+ export declare const VAULT_NAMES: {
401
+ readonly base: 'base';
402
+ readonly premium: 'premium';
360
403
  };
404
+ /**
405
+ * Spot (non-vault) settlement token. Priced via `conversionRate` when provided.
406
+ * Neither `accountantAddress` nor `vault` is present on this variant.
407
+ */
408
+ export type SpotTokenPaymentInfo = TokenPaymentInfoBase;
361
409
  /**
362
410
  * Yield-bearing vault share priced via an accountant rate.
363
411
  */
364
412
  export type VaultTokenPaymentInfo = TokenPaymentInfoBase & {
365
- isVaultShare: true;
366
413
  /**
367
- * Veda accountant address used to value this vault share.
414
+ * Veda accountant address used to value this vault share. Every vault has
415
+ * its own accountant, so this is present on every vault-share token — which
416
+ * is what makes it the discriminant for this variant.
368
417
  */
369
418
  accountantAddress: Hex;
419
+ /**
420
+ * Named vault this token is a share of. Sent only for vault-share tokens.
421
+ */
422
+ vault?: VaultName;
370
423
  };
371
424
  /**
372
- * A settlement token in a pricing chain. Discriminated by `isVaultShare`:
373
- * vault shares require `accountantAddress`; spot tokens omit it.
425
+ * A settlement token in a pricing chain. Discriminated by the presence of
426
+ * `accountantAddress`: vault shares carry it (and may carry `vault`), spot
427
+ * tokens carry neither.
428
+ *
429
+ * The API previously sent an explicit `isVaultShare` boolean. It no longer
430
+ * does, so do not reintroduce a dependency on it — use
431
+ * {@link isVaultShareToken}.
374
432
  */
375
433
  export type TokenPaymentInfo = SpotTokenPaymentInfo | VaultTokenPaymentInfo;
434
+ /**
435
+ * Whether a settlement token is a yield-bearing vault share, which must be
436
+ * valued through its accountant rate rather than at face value.
437
+ *
438
+ * @param token - The settlement token to check.
439
+ * @returns True if the token is a vault share.
440
+ */
441
+ export declare function isVaultShareToken(token: TokenPaymentInfo): token is VaultTokenPaymentInfo;
376
442
  export type ChainPaymentInfo = {
377
443
  chainId: Hex;
378
444
  paymentAddress: Hex;
@@ -589,19 +655,43 @@ export type UpdatePaymentMethodCardRequest = {
589
655
  export type UpdatePaymentMethodCardResponse = {
590
656
  redirectUrl: string;
591
657
  };
592
- export type UpdatePaymentMethodCryptoRequest = {
658
+ type UpdatePaymentMethodCryptoRequestBase = {
593
659
  subscriptionId: string;
594
660
  chainId: Hex;
595
661
  payerAddress: Hex;
596
662
  tokenSymbol: string;
663
+ recurringInterval: RecurringInterval;
664
+ billingCycles: number;
665
+ };
666
+ /**
667
+ * ERC-20 approval crypto payment-method update request.
668
+ *
669
+ * `rawTransaction` may be omitted when retrying after a balance top-up.
670
+ */
671
+ export type UpdateErc20PaymentMethodCryptoRequest = UpdatePaymentMethodCryptoRequestBase & {
672
+ cryptoAuthMethod?: typeof CRYPTO_AUTH_METHODS.ERC20_APPROVAL;
597
673
  /**
598
- * The raw transaction to pay for the subscription
599
- * Can be empty if retry after topping up balance
674
+ * The raw transaction to pay for the subscription.
600
675
  */
601
676
  rawTransaction?: Hex;
602
- recurringInterval: RecurringInterval;
603
- billingCycles: number;
677
+ delegationHash?: never;
678
+ };
679
+ /**
680
+ * Delegation crypto payment-method update request used to rotate an active
681
+ * subscription to a replacement delegation.
682
+ */
683
+ export type UpdateDelegationPaymentMethodCryptoRequest = UpdatePaymentMethodCryptoRequestBase & {
684
+ cryptoAuthMethod: typeof CRYPTO_AUTH_METHODS.DELEGATION;
685
+ delegationHash: Hex;
686
+ rawTransaction?: never;
604
687
  };
688
+ /**
689
+ * Request to update a subscription's crypto payment method.
690
+ *
691
+ * Provide `rawTransaction` for the existing ERC-20 approval path, or provide
692
+ * `cryptoAuthMethod: 'delegation'` and `delegationHash` to rotate a delegation.
693
+ */
694
+ export type UpdatePaymentMethodCryptoRequest = UpdateErc20PaymentMethodCryptoRequest | UpdateDelegationPaymentMethodCryptoRequest;
605
695
  export type BillingPortalResponse = {
606
696
  url: string;
607
697
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa;IAC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qBAAqB,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,WAAW,CAAC;IAClB,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD;;OAEG;IACH,OAAO,EAAE,WAAW,CAAC;IACrB;;OAEG;IACH,aAAa,EAAE,+BAA+B,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;;OAMG;IACH,eAAe,EAAE,aAAa,CAAC;CAChC,CAAC"}
package/dist/types.js CHANGED
@@ -61,6 +61,12 @@ export const SUBSCRIPTION_STATUSES = {
61
61
  // Paused states
62
62
  paused: 'paused',
63
63
  };
64
+ export const INVOICE_PAYMENT_STATUSES = {
65
+ PROCESSING: 'PROCESSING',
66
+ SUCCEEDED: 'SUCCEEDED',
67
+ FAILED: 'FAILED',
68
+ UNKNOWN: 'UNKNOWN',
69
+ };
64
70
  export const CANCEL_TYPES = {
65
71
  ALLOWED_IMMEDIATE: 'allowed_immediate',
66
72
  ALLOWED_AT_PERIOD_END: 'allowed_at_period_end',
@@ -74,10 +80,43 @@ export const CRYPTO_PAYMENT_METHOD_ERRORS = {
74
80
  INSUFFICIENT_BALANCE: 'insufficient_balance',
75
81
  INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',
76
82
  };
83
+ /**
84
+ * Errors returned by the Subscription API after crypto payment execution.
85
+ *
86
+ * These are distinct from {@link CRYPTO_PAYMENT_METHOD_ERRORS}, which describe
87
+ * approval/payment-method failures.
88
+ */
89
+ export const CRYPTO_PAYMENT_ERRORS = {
90
+ INSUFFICIENT_BALANCE: 'insufficient_balance',
91
+ INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',
92
+ EXCEEDS_DELEGATION_ALLOWANCE: 'exceeds_delegation_allowance',
93
+ DELEGATION_NOT_FOUND: 'delegation_not_found',
94
+ DELEGATION_REVOKED: 'delegation_revoked',
95
+ RECIPIENT_NOT_ALLOWLISTED: 'recipient_not_allowlisted',
96
+ INTERNAL_SERVER_ERROR: 'internal_server_error',
97
+ };
77
98
  export const MODAL_TYPE = {
78
99
  A: 'A',
79
100
  B: 'B',
80
101
  };
102
+ /**
103
+ * The vault names known at the time of writing. Not exhaustive — see
104
+ * {@link VaultName}.
105
+ */
106
+ export const VAULT_NAMES = {
107
+ base: 'base',
108
+ premium: 'premium',
109
+ };
110
+ /**
111
+ * Whether a settlement token is a yield-bearing vault share, which must be
112
+ * valued through its accountant rate rather than at face value.
113
+ *
114
+ * @param token - The settlement token to check.
115
+ * @returns True if the token is a vault share.
116
+ */
117
+ export function isVaultShareToken(token) {
118
+ return token.accountantAddress !== undefined;
119
+ }
81
120
  export const COHORT_NAMES = {
82
121
  POST_TX: 'post_tx',
83
122
  WALLET_HOME: 'wallet_home',
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;;OAEG;IACH,MAAM,EAAE,QAAQ;IAChB;;OAEG;IACH,kBAAkB,EAAE,oBAAoB;CAChC,CAAC;AAIX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,UAAU,EAAE,YAAY;CAChB,CAAC;AAOX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,WAAW,EAAE,aAAa;IAC1B,eAAe,EAAE,iBAAiB;C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,EAAE,aAAa;CAClB,CAAC;AAIX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,UAAU,EAAE,MAAM;IAClB,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,WAAW;IAC5B,iBAAiB,EAAE,aAAa;IAChC,aAAa,EAAE,KAAK;CACZ,CAAC;AAsBX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,sBAAsB,EAAE,2BAA2B;IACnD,oBAAoB,EAAE,wBAAwB;CACtC,CAAC","sourcesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { CaipAccountId, Hex } from '@metamask/utils';\n\nimport type { CANCELLATION_REASONS } from './constants.js';\n\n/**\n * Error response from the Subscription API.\n */\nexport type SubscriptionApiError = {\n errorCode?: string;\n message?: string;\n statusCode?: number;\n};\n\n/**\n * Supported subscription products.\n */\nexport const PRODUCT_TYPES = {\n /**\n * MetaMask Shield.\n */\n SHIELD: 'shield',\n /**\n * Money Account Plus (delegation-based crypto billing).\n */\n MONEY_ACCOUNT_PLUS: 'money_account_plus',\n} as const;\n\nexport type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];\n\nexport const MoneyAccountFeature = {\n SwapFeeWaiver: 'swapFeeWaiver',\n PerpsFeeWaiver: 'perpsFeeWaiver',\n PredictFreeTx: 'predictFreeTx',\n PremiumApy: 'premiumApy',\n} as const;\n\nexport type MoneyAccountFeature =\n (typeof MoneyAccountFeature)[keyof typeof MoneyAccountFeature];\n\nexport type MoneyAccountEntitlements = Record<MoneyAccountFeature, boolean>;\n\nexport const ShieldFeature = {\n ShieldClaim: 'shieldClaim',\n PrioritySupport: 'prioritySupport',\n} as const;\n\nexport type ShieldFeature = (typeof ShieldFeature)[keyof typeof ShieldFeature];\n\nexport type ShieldEntitlements = Record<ShieldFeature, boolean>;\n\nexport type MoneyAccountPlusClaim = {\n plan: string;\n entitlements: MoneyAccountEntitlements;\n};\n\nexport type ProductEntitlements = {\n [PRODUCT_TYPES.SHIELD]?: {\n entitlements: ShieldEntitlements;\n };\n [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]?: MoneyAccountPlusClaim;\n};\n\nexport type ProductEntitlementFeatureMap = {\n [PRODUCT_TYPES.SHIELD]: ShieldFeature;\n [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]: MoneyAccountFeature;\n};\n\n/**\n * How a crypto subscription is authorized.\n *\n * Use `erc20_approval` with `rawTransaction` (e.g. Shield). Use `delegation`\n * with `delegationHash` (e.g. Money Account Plus).\n */\nexport const CRYPTO_AUTH_METHODS = {\n /**\n * User signs an ERC-20 approve transaction.\n */\n ERC20_APPROVAL: 'erc20_approval',\n /**\n * User authorizes via a stored delegation hash.\n */\n DELEGATION: 'delegation',\n} as const;\n\nexport type CryptoAuthMethod =\n (typeof CRYPTO_AUTH_METHODS)[keyof typeof CRYPTO_AUTH_METHODS];\n\nexport const PAYMENT_TYPES = {\n byCard: 'card',\n byCrypto: 'crypto',\n} as const;\n\nexport type PaymentType = (typeof PAYMENT_TYPES)[keyof typeof PAYMENT_TYPES];\n\nexport const RECURRING_INTERVALS = {\n month: 'month',\n year: 'year',\n} as const;\n\nexport type RecurringInterval =\n (typeof RECURRING_INTERVALS)[keyof typeof RECURRING_INTERVALS];\n\nexport const SUBSCRIPTION_STATUSES = {\n // Initial states\n incomplete: 'incomplete',\n incompleteExpired: 'incomplete_expired',\n // Active states\n provisional: 'provisional',\n trialing: 'trialing',\n active: 'active',\n // Payment issues\n pastDue: 'past_due',\n unpaid: 'unpaid',\n // Cancelled states\n canceled: 'canceled',\n // Paused states\n paused: 'paused',\n} as const;\n\nexport type SubscriptionStatus =\n (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];\n\nexport const CANCEL_TYPES = {\n ALLOWED_IMMEDIATE: 'allowed_immediate',\n ALLOWED_AT_PERIOD_END: 'allowed_at_period_end',\n NOT_ALLOWED: 'not_allowed',\n NOT_ALLOWED_PENDING_VERIFICATION: 'not_allowed_pending_verification',\n} as const;\n\nexport type CancelType = (typeof CANCEL_TYPES)[keyof typeof CANCEL_TYPES];\n\nexport type CancellationReasonCode =\n (typeof CANCELLATION_REASONS)[keyof typeof CANCELLATION_REASONS];\n\nexport const CRYPTO_PAYMENT_METHOD_ERRORS = {\n APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old',\n APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted',\n APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED:\n 'approval_transaction_max_verification_attempts_reached',\n INSUFFICIENT_BALANCE: 'insufficient_balance',\n INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',\n} as const;\n\nexport type CryptoPaymentMethodError =\n (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];\n\nexport const MODAL_TYPE = {\n A: 'A',\n B: 'B',\n} as const;\n\nexport type ModalType = (typeof MODAL_TYPE)[keyof typeof MODAL_TYPE];\n\n/** only usd for now */\nexport type Currency = 'usd';\n\nexport type Product = {\n name: ProductType;\n currency: Currency;\n unitAmount: number;\n unitDecimals: number;\n};\n\n// state\nexport type Subscription = {\n id: string;\n products: Product[];\n currentPeriodStart: string; // ISO 8601\n currentPeriodEnd: string; // ISO 8601\n /** is subscription scheduled for cancellation */\n cancelAtPeriodEnd?: boolean;\n status: SubscriptionStatus;\n interval: RecurringInterval;\n paymentMethod: SubscriptionPaymentMethod;\n trialPeriodDays?: number;\n trialStart?: string; // ISO 8601\n trialEnd?: string; // ISO 8601\n /** Crypto payment only: next billing cycle date (e.g after 12 months) */\n endDate?: string; // ISO 8601\n /** The date the subscription was canceled. */\n canceledAt?: string; // ISO 8601\n /** The cancellation type indicating what cancellation options are available for this subscription. */\n cancelType: CancelType;\n /** The date the subscription was marked as inactive (paused/past_due/canceled). */\n inactiveAt?: string; // ISO 8601\n /** Whether the user is eligible for support features (priority support and filing claims). True for active subscriptions and inactive subscriptions within grace period. */\n isEligibleForSupport: boolean;\n billingCycles?: number;\n};\n\nexport type SubscriptionCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n card: {\n brand: string;\n /** display brand account for dual brand card */\n displayBrand: string;\n last4: string;\n };\n};\n\nexport type SubscriptionCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n crypto: {\n payerAddress: Hex;\n chainId: Hex;\n tokenSymbol: string;\n error?: CryptoPaymentMethodError;\n };\n};\n\nexport type SubscriptionPaymentMethod =\n | SubscriptionCardPaymentMethod\n | SubscriptionCryptoPaymentMethod;\n\nexport type GetSubscriptionsResponse = {\n customerId?: string;\n subscriptions: Subscription[];\n trialedProducts: ProductType[];\n productEntitlements?: ProductEntitlements;\n /** The last subscription that user has subscribed to if any. */\n lastSubscription?: Subscription;\n /** The reward account ID if user has linked rewards to the subscription. */\n rewardAccountId?: CaipAccountId;\n};\n\n/**\n * Benefits available to a subscription user.\n */\nexport type SwapsBenefitUsage = {\n feeBips: string | null;\n capMicroUsd?: number;\n consumedMicroUsd?: number;\n remainingMicroUsd: number | null;\n exhausted: boolean;\n};\n\nexport type PerpsBenefitUsage = {\n builderFeeBips: string | null;\n builderCode: string | null;\n capMicroUsd?: number;\n consumedMicroUsd?: number;\n remainingMicroUsd: number | null;\n exhausted: boolean;\n};\n\nexport type PredictBenefitUsage = {\n builderCode: string | null;\n capTxCount?: number;\n consumedTxCount?: number;\n remainingTxCount: number | null;\n exhausted: boolean;\n};\n\ntype SubscriptionBenefitsProducts = {\n swaps: SwapsBenefitUsage;\n perps: PerpsBenefitUsage;\n predict: PredictBenefitUsage;\n};\n\nexport type SubscriptionBenefitsResponse = {\n eligible: boolean;\n billingPeriodId: string | null;\n products: SubscriptionBenefitsProducts;\n};\n\n/**\n * Benefits state exposed to the UI.\n */\nexport type SubscriptionBenefitsState = SubscriptionBenefitsProducts & {\n billingPeriodId: string | null;\n};\n\nexport type StartSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n successUrl?: string;\n cancelUrl?: string;\n useTestClock?: boolean;\n\n /**\n * Optional CAIP account ID of the rewards account to opt in alongside this\n * subscription. Required when the user wants to link rewards during\n * subscription creation.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId?: CaipAccountId;\n};\n\nexport type StartSubscriptionResponse = {\n checkoutSessionUrl: string;\n};\n\ntype StartCryptoSubscriptionRequestBase = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n chainId: Hex;\n payerAddress: Hex;\n /**\n * e.g. \"USDC\"\n */\n tokenSymbol: string;\n isSponsored?: boolean;\n useTestClock?: boolean;\n /**\n * Optional CAIP account ID of the rewards account to opt in alongside this\n * subscription. Required when the user wants to link rewards during\n * subscription creation.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId?: CaipAccountId;\n};\n\n/**\n * ERC-20 approval crypto subscription request (e.g. Shield).\n *\n * `cryptoAuthMethod` defaults to `CRYPTO_AUTH_METHODS.ERC20_APPROVAL` when\n * omitted.\n */\nexport type StartErc20CryptoSubscriptionRequest =\n StartCryptoSubscriptionRequestBase & {\n cryptoAuthMethod?: typeof CRYPTO_AUTH_METHODS.ERC20_APPROVAL;\n rawTransaction: Hex;\n delegationHash?: never;\n };\n\n/**\n * Delegation-based crypto subscription request (e.g. Money Account Plus).\n */\nexport type StartDelegationCryptoSubscriptionRequest =\n StartCryptoSubscriptionRequestBase & {\n cryptoAuthMethod: typeof CRYPTO_AUTH_METHODS.DELEGATION;\n delegationHash: Hex;\n rawTransaction?: never;\n };\n\n/**\n * Request to start a crypto subscription.\n *\n * Discriminated union of ERC-20 approval vs delegation. Provide\n * `rawTransaction` for ERC-20 approval (the default when `cryptoAuthMethod` is\n * omitted), or `delegationHash` with `cryptoAuthMethod: 'delegation'`.\n * Combining or omitting both is a type error, and is also rejected at runtime\n * by `startSubscriptionWithCrypto`.\n */\nexport type StartCryptoSubscriptionRequest =\n | StartErc20CryptoSubscriptionRequest\n | StartDelegationCryptoSubscriptionRequest;\n\nexport type StartCryptoSubscriptionResponse = {\n subscriptionId: string;\n status: SubscriptionStatus;\n};\n\n/**\n * General response type for the subscription API requests\n * which doesn't require any specific response data.\n */\nexport type SubscriptionApiGeneralResponse = {\n /**\n * Whether the request was successful.\n */\n success: boolean;\n /**\n * The message of the response.\n */\n message?: string;\n};\n\nexport type CancelSubscriptionRequest = {\n subscriptionId: string;\n /** Whether to cancel at the end of the current period */\n cancelAtPeriodEnd?: boolean;\n /** Stable reason code for the cancellation. */\n cancellationReason?: CancellationReasonCode;\n /** Optional free-text feedback for the cancellation. */\n cancellationFeedback?: string;\n};\n\nexport type AuthUtils = {\n getAccessToken: () => Promise<string>;\n};\n\nexport type ProductPrice = {\n interval: RecurringInterval;\n unitAmount: number; // amount in the smallest unit of the currency, e.g., cents\n unitDecimals: number; // number of decimals for the smallest unit of the currency\n /** only usd for now */\n currency: Currency;\n trialPeriodDays: number;\n /** min billing cycles for approval */\n minBillingCycles: number;\n /** min billing cycles for account balance check */\n minBillingCyclesForBalance: number;\n};\n\nexport type ProductPricing = {\n name: ProductType;\n prices: ProductPrice[];\n};\n\ntype TokenPaymentInfoBase = {\n symbol: string;\n address: Hex;\n decimals: number;\n /**\n * example: {\n usd: '1.0',\n },\n */\n conversionRate?: {\n usd: string;\n };\n /**\n * Source tokens that can be converted into this settlement token.\n */\n sources?: TokenPaymentInfo[];\n};\n\n/**\n * Spot (non-vault) settlement token. Priced via `conversionRate` when provided.\n * `accountantAddress` is not present on this variant.\n */\nexport type SpotTokenPaymentInfo = TokenPaymentInfoBase & {\n isVaultShare?: false;\n};\n\n/**\n * Yield-bearing vault share priced via an accountant rate.\n */\nexport type VaultTokenPaymentInfo = TokenPaymentInfoBase & {\n isVaultShare: true;\n /**\n * Veda accountant address used to value this vault share.\n */\n accountantAddress: Hex;\n};\n\n/**\n * A settlement token in a pricing chain. Discriminated by `isVaultShare`:\n * vault shares require `accountantAddress`; spot tokens omit it.\n */\nexport type TokenPaymentInfo = SpotTokenPaymentInfo | VaultTokenPaymentInfo;\n\nexport type ChainPaymentInfo = {\n chainId: Hex;\n paymentAddress: Hex;\n /**\n * Delegate address clients authorize when using the delegation auth method.\n */\n delegateAddress?: Hex;\n tokens: TokenPaymentInfo[];\n /**\n * Whether the chain supports sponsorship for the trialed subscription approval transaction.\n * This is used to determine if the user can be sponsored for the gas fees for the trialed subscription approval transaction.\n */\n isSponsorshipSupported?: boolean;\n};\n\nexport type PricingCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n /**\n * Products that support this payment method.\n */\n products?: ProductType[];\n};\n\nexport type PricingCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n /**\n * Crypto authorization method. Omitted together with `products` on persisted\n * pre-multi-product pricing rows; those rows are treated as Shield + `erc20_approval`.\n * If `products` is set, this field must be explicit.\n */\n cryptoAuthMethod?: CryptoAuthMethod;\n /**\n * Products that support this payment method. Omitted together with\n * `cryptoAuthMethod` on persisted pre-multi-product pricing rows (treated as Shield).\n * If present, must be non-empty and paired with an explicit `cryptoAuthMethod`.\n */\n products?: ProductType[];\n chains?: ChainPaymentInfo[];\n};\n\n/**\n * A pricing payment-method row. Discriminated by `type`: card rows have no\n * crypto fields; crypto rows may include `cryptoAuthMethod` and `chains`.\n */\nexport type PricingPaymentMethod =\n | PricingCardPaymentMethod\n | PricingCryptoPaymentMethod;\n\nexport type PricingResponse = {\n products: ProductPricing[];\n paymentMethods: PricingPaymentMethod[];\n};\n\nexport type GetCryptoApproveTransactionRequest = {\n /**\n * payment chain ID\n */\n chainId: Hex;\n /**\n * Payment token address\n */\n paymentTokenAddress: Hex;\n productType: ProductType;\n interval: RecurringInterval;\n};\n\nexport type GetCryptoApproveTransactionResponse = {\n /**\n * The amount to approve\n * e.g: \"100000000\"\n */\n approveAmount: string;\n /**\n * The contract address (spender)\n */\n paymentAddress: Hex;\n /**\n * The payment token address\n */\n paymentTokenAddress: Hex;\n chainId: Hex;\n};\n\n/**\n * Request to submit a Shield ERC-20 crypto approval transaction.\n */\nexport type SubmitSubscriptionCryptoApprovalRequest = {\n /**\n * The subscription product. Typed as `typeof PRODUCT_TYPES.SHIELD` only at\n * the moment (future might support more product).\n */\n productType: typeof PRODUCT_TYPES.SHIELD;\n /**\n * The transaction metadata. Must have type\n * `TransactionType.shieldSubscriptionApprove`.\n */\n txMeta: TransactionMeta;\n /**\n * Whether the transaction is sponsored.\n */\n isSponsored?: boolean;\n /**\n * The account ID of the reward subscription to link.\n */\n rewardAccountId?: CaipAccountId;\n};\n\nexport const COHORT_NAMES = {\n POST_TX: 'post_tx',\n WALLET_HOME: 'wallet_home',\n} as const;\n\nexport type CohortName = (typeof COHORT_NAMES)[keyof typeof COHORT_NAMES];\n\nexport const BALANCE_CATEGORIES = {\n RANGE_0_99: '0-99',\n RANGE_100_999: '100-999',\n RANGE_1K_9_9K: '1k-9.9k',\n RANGE_10K_99_9K: '10k-99.9k',\n RANGE_100K_999_9K: '100k-999.9k',\n RANGE_1M_PLUS: '1M+',\n} as const;\n\nexport type BalanceCategory =\n (typeof BALANCE_CATEGORIES)[keyof typeof BALANCE_CATEGORIES];\n\nexport type Cohort = {\n cohort: string;\n eligibilityRate: number; // 0-1 probability of being assigned to this cohort\n priority: number; // lower number = higher priority\n eligible: boolean;\n};\n\nexport type SubscriptionEligibility = {\n product: ProductType;\n canSubscribe: boolean;\n canViewEntryModal: boolean;\n modalType?: ModalType;\n cohorts: Cohort[];\n assignedCohort: string | null;\n hasAssignedCohortExpired: boolean;\n};\n\nexport const SubscriptionUserEvent = {\n ShieldEntryModalViewed: 'shield_entry_modal_viewed',\n ShieldCohortAssigned: 'shield_cohort_assigned',\n} as const;\n\nexport type SubscriptionUserEventType =\n (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];\n\nexport type SubmitUserEventRequest = {\n event: SubscriptionUserEventType;\n cohort?: string;\n};\n\nexport type AssignCohortRequest = {\n cohort: string;\n};\n\nexport type GetSubscriptionsEligibilitiesRequest = {\n balanceCategory?: BalanceCategory;\n};\n\n/**\n * Request object for submitting sponsorship intents.\n */\nexport type SubmitSponsorshipIntentsRequest = {\n chainId: Hex;\n address: Hex;\n products: ProductType[];\n paymentTokenSymbol: string;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type SubmitSponsorshipIntentsMethodParams = Pick<\n SubmitSponsorshipIntentsRequest,\n 'chainId' | 'address' | 'products'\n>;\n\nexport type ISubscriptionService = {\n getSubscriptions(): Promise<GetSubscriptionsResponse>;\n getBenefits(): Promise<SubscriptionBenefitsResponse>;\n cancelSubscription(request: CancelSubscriptionRequest): Promise<Subscription>;\n unCancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n /**\n * Starts a card-paid subscription checkout session for the requested products\n * (e.g. Shield or Money Account Plus).\n *\n * @param request - The start subscription request.\n * @returns The checkout session response.\n */\n startSubscriptionWithCard(\n request: StartSubscriptionRequest,\n ): Promise<StartSubscriptionResponse>;\n getBillingPortalUrl(): Promise<BillingPortalResponse>;\n getPricing(): Promise<PricingResponse>;\n startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse>;\n updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse>;\n updatePaymentMethodCrypto(\n request: UpdatePaymentMethodCryptoRequest,\n ): Promise<void>;\n getSubscriptionsEligibilities(\n request?: GetSubscriptionsEligibilitiesRequest,\n ): Promise<SubscriptionEligibility[]>;\n submitUserEvent(request: SubmitUserEventRequest): Promise<void>;\n assignUserToCohort(request: AssignCohortRequest): Promise<void>;\n\n /**\n * Link rewards to a subscription.\n */\n linkRewards(\n request: LinkRewardsRequest,\n ): Promise<SubscriptionApiGeneralResponse>;\n\n /**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n */\n submitSponsorshipIntents(\n request: SubmitSponsorshipIntentsRequest,\n ): Promise<void>;\n};\n\nexport type UpdatePaymentMethodOpts =\n | ({\n paymentType: Extract<PaymentType, 'card'>;\n } & UpdatePaymentMethodCardRequest)\n | ({\n paymentType: Extract<PaymentType, 'crypto'>;\n } & UpdatePaymentMethodCryptoRequest);\n\nexport type UpdatePaymentMethodCardRequest = {\n /**\n * Subscription ID\n */\n subscriptionId: string;\n\n /**\n * Recurring interval\n */\n recurringInterval: RecurringInterval;\n successUrl?: string;\n cancelUrl?: string;\n};\n\nexport type UpdatePaymentMethodCardResponse = {\n redirectUrl: string;\n};\n\nexport type UpdatePaymentMethodCryptoRequest = {\n subscriptionId: string;\n chainId: Hex;\n payerAddress: Hex;\n tokenSymbol: string;\n /**\n * The raw transaction to pay for the subscription\n * Can be empty if retry after topping up balance\n */\n rawTransaction?: Hex;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type BillingPortalResponse = {\n url: string;\n};\n\n/**\n * The cached result of last selected payment methods for the user.\n * These details are being cached to be used internally to track the last selected payment method for the user. (e.g. for crypto subscriptions)\n */\nexport type CachedLastSelectedPaymentMethod = {\n type: PaymentType;\n paymentTokenAddress?: Hex;\n paymentTokenSymbol?: string;\n plan: RecurringInterval;\n useTestClock?: boolean;\n /**\n * Crypto authorization method. Omitted on persisted cache entries written\n * before this field existed; treat as `erc20_approval` when missing.\n */\n cryptoAuthMethod?: CryptoAuthMethod;\n};\n\n/**\n * Request to cache the last selected payment method for a product.\n */\nexport type CacheLastSelectedPaymentMethodRequest = {\n /**\n * The product to cache the payment method for.\n */\n product: ProductType;\n /**\n * The payment method to cache.\n */\n paymentMethod: CachedLastSelectedPaymentMethod;\n};\n\n/**\n * Request object for linking rewards to a subscription.\n */\nexport type LinkRewardsRequest = {\n /**\n * The ID of the reward subscription to be linked to the subscription.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId: CaipAccountId;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;;OAEG;IACH,MAAM,EAAE,QAAQ;IAChB;;OAEG;IACH,kBAAkB,EAAE,oBAAoB;CAChC,CAAC;AAIX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,UAAU,EAAE,YAAY;CAChB,CAAC;AAOX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,WAAW,EAAE,aAAa;IAC1B,eAAe,EAAE,iBAAiB;CAC1B,CAAC;AAuBX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC;;OAEG;IACH,cAAc,EAAE,gBAAgB;IAChC;;OAEG;IACH,UAAU,EAAE,YAAY;CAChB,CAAC;AAKX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,QAAQ;CACV,CAAC;AAIX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACJ,CAAC;AAKX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,UAAU,EAAE,YAAY;IACxB,iBAAiB,EAAE,oBAAoB;IACvC,gBAAgB;IAChB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ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AAiB,KAAK,SAAS,CAAC;AAC1E,CAAC;AA6GD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;CAClB,CAAC;AAIX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,UAAU,EAAE,MAAM;IAClB,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,WAAW;IAC5B,iBAAiB,EAAE,aAAa;IAChC,aAAa,EAAE,KAAK;CACZ,CAAC;AAsBX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,sBAAsB,EAAE,2BAA2B;IACnD,oBAAoB,EAAE,wBAAwB;CACtC,CAAC","sourcesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { CaipAccountId, Hex } from '@metamask/utils';\n\nimport type { CANCELLATION_REASONS } from './constants.js';\n\n/**\n * Error response from the Subscription API.\n */\nexport type SubscriptionApiError = {\n errorCode?: string;\n message?: string;\n statusCode?: number;\n};\n\n/**\n * Supported subscription products.\n */\nexport const PRODUCT_TYPES = {\n /**\n * MetaMask Shield.\n */\n SHIELD: 'shield',\n /**\n * Money Account Plus (delegation-based crypto billing).\n */\n MONEY_ACCOUNT_PLUS: 'money_account_plus',\n} as const;\n\nexport type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];\n\nexport const MoneyAccountFeature = {\n SwapFeeWaiver: 'swapFeeWaiver',\n PerpsFeeWaiver: 'perpsFeeWaiver',\n PredictFreeTx: 'predictFreeTx',\n PremiumApy: 'premiumApy',\n} as const;\n\nexport type MoneyAccountFeature =\n (typeof MoneyAccountFeature)[keyof typeof MoneyAccountFeature];\n\nexport type MoneyAccountEntitlements = Record<MoneyAccountFeature, boolean>;\n\nexport const ShieldFeature = {\n ShieldClaim: 'shieldClaim',\n PrioritySupport: 'prioritySupport',\n} as const;\n\nexport type ShieldFeature = (typeof ShieldFeature)[keyof typeof ShieldFeature];\n\nexport type ShieldEntitlements = Record<ShieldFeature, boolean>;\n\nexport type MoneyAccountPlusClaim = {\n plan: string;\n entitlements: MoneyAccountEntitlements;\n};\n\nexport type ProductEntitlements = {\n [PRODUCT_TYPES.SHIELD]?: {\n entitlements: ShieldEntitlements;\n };\n [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]?: MoneyAccountPlusClaim;\n};\n\nexport type ProductEntitlementFeatureMap = {\n [PRODUCT_TYPES.SHIELD]: ShieldFeature;\n [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]: MoneyAccountFeature;\n};\n\n/**\n * How a crypto subscription is authorized.\n *\n * Use `erc20_approval` with `rawTransaction` (e.g. Shield). Use `delegation`\n * with `delegationHash` (e.g. Money Account Plus).\n */\nexport const CRYPTO_AUTH_METHODS = {\n /**\n * User signs an ERC-20 approve transaction.\n */\n ERC20_APPROVAL: 'erc20_approval',\n /**\n * User authorizes via a stored delegation hash.\n */\n DELEGATION: 'delegation',\n} as const;\n\nexport type CryptoAuthMethod =\n (typeof CRYPTO_AUTH_METHODS)[keyof typeof CRYPTO_AUTH_METHODS];\n\nexport const PAYMENT_TYPES = {\n byCard: 'card',\n byCrypto: 'crypto',\n} as const;\n\nexport type PaymentType = (typeof PAYMENT_TYPES)[keyof typeof PAYMENT_TYPES];\n\nexport const RECURRING_INTERVALS = {\n month: 'month',\n year: 'year',\n} as const;\n\nexport type RecurringInterval =\n (typeof RECURRING_INTERVALS)[keyof typeof RECURRING_INTERVALS];\n\nexport const SUBSCRIPTION_STATUSES = {\n // Initial states\n incomplete: 'incomplete',\n incompleteExpired: 'incomplete_expired',\n // Active states\n provisional: 'provisional',\n trialing: 'trialing',\n active: 'active',\n // Payment issues\n pastDue: 'past_due',\n unpaid: 'unpaid',\n // Cancelled states\n canceled: 'canceled',\n // Paused states\n paused: 'paused',\n} as const;\n\nexport type SubscriptionStatus =\n (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];\n\nexport const INVOICE_PAYMENT_STATUSES = {\n PROCESSING: 'PROCESSING',\n SUCCEEDED: 'SUCCEEDED',\n FAILED: 'FAILED',\n UNKNOWN: 'UNKNOWN',\n} as const;\n\nexport type InvoicePaymentStatus =\n (typeof INVOICE_PAYMENT_STATUSES)[keyof typeof INVOICE_PAYMENT_STATUSES];\n\nexport const CANCEL_TYPES = {\n ALLOWED_IMMEDIATE: 'allowed_immediate',\n ALLOWED_AT_PERIOD_END: 'allowed_at_period_end',\n NOT_ALLOWED: 'not_allowed',\n NOT_ALLOWED_PENDING_VERIFICATION: 'not_allowed_pending_verification',\n} as const;\n\nexport type CancelType = (typeof CANCEL_TYPES)[keyof typeof CANCEL_TYPES];\n\nexport type CancellationReasonCode =\n (typeof CANCELLATION_REASONS)[keyof typeof CANCELLATION_REASONS];\n\nexport const CRYPTO_PAYMENT_METHOD_ERRORS = {\n APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old',\n APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted',\n APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED:\n 'approval_transaction_max_verification_attempts_reached',\n INSUFFICIENT_BALANCE: 'insufficient_balance',\n INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',\n} as const;\n\nexport type CryptoPaymentMethodError =\n (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];\n\n/**\n * Errors returned by the Subscription API after crypto payment execution.\n *\n * These are distinct from {@link CRYPTO_PAYMENT_METHOD_ERRORS}, which describe\n * approval/payment-method failures.\n */\nexport const CRYPTO_PAYMENT_ERRORS = {\n INSUFFICIENT_BALANCE: 'insufficient_balance',\n INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',\n EXCEEDS_DELEGATION_ALLOWANCE: 'exceeds_delegation_allowance',\n DELEGATION_NOT_FOUND: 'delegation_not_found',\n DELEGATION_REVOKED: 'delegation_revoked',\n RECIPIENT_NOT_ALLOWLISTED: 'recipient_not_allowlisted',\n INTERNAL_SERVER_ERROR: 'internal_server_error',\n} as const;\n\nexport type CryptoPaymentError =\n (typeof CRYPTO_PAYMENT_ERRORS)[keyof typeof CRYPTO_PAYMENT_ERRORS];\n\nexport const MODAL_TYPE = {\n A: 'A',\n B: 'B',\n} as const;\n\nexport type ModalType = (typeof MODAL_TYPE)[keyof typeof MODAL_TYPE];\n\n/** only usd for now */\nexport type Currency = 'usd';\n\nexport type Product = {\n name: ProductType;\n currency: Currency;\n unitAmount: number;\n unitDecimals: number;\n};\n\n// state\nexport type Subscription = {\n id: string;\n products: Product[];\n currentPeriodStart?: string; // ISO 8601\n currentPeriodEnd?: string; // ISO 8601\n /** is subscription scheduled for cancellation */\n cancelAtPeriodEnd?: boolean;\n status: SubscriptionStatus;\n interval: RecurringInterval;\n paymentMethod: SubscriptionPaymentMethod;\n trialPeriodDays?: number;\n trialStart?: string; // ISO 8601\n trialEnd?: string; // ISO 8601\n /** Crypto payment only: next billing cycle date (e.g after 12 months) */\n endDate?: string; // ISO 8601\n /** The date the subscription was canceled. */\n canceledAt?: string; // ISO 8601\n /** The cancellation type indicating what cancellation options are available for this subscription. */\n cancelType?: CancelType;\n /** The date the subscription was marked as inactive (paused/past_due/canceled). */\n inactiveAt?: string; // ISO 8601\n /** Whether the user is eligible for support features (priority support and filing claims). True for active subscriptions and inactive subscriptions within grace period. */\n isEligibleForSupport?: boolean;\n billingCycles?: number;\n /** The most recent invoice associated with the subscription. */\n lastInvoice?: SubscriptionInvoice;\n};\n\nexport type SubscriptionInvoice = {\n id: string;\n status: InvoicePaymentStatus;\n errorCode?: CryptoPaymentError;\n updatedAt: string; // ISO 8601\n};\n\nexport type SubscriptionCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n card: {\n brand: string;\n /** display brand account for dual brand card */\n displayBrand: string;\n last4: string;\n };\n};\n\nexport type SubscriptionCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n crypto: {\n payerAddress: Hex;\n chainId: Hex;\n tokenSymbol: string;\n error?: CryptoPaymentMethodError;\n };\n};\n\nexport type SubscriptionPaymentMethod =\n | SubscriptionCardPaymentMethod\n | SubscriptionCryptoPaymentMethod;\n\nexport type GetSubscriptionsResponse = {\n customerId?: string;\n subscriptions: Subscription[];\n trialedProducts: ProductType[];\n productEntitlements?: ProductEntitlements;\n /** The last subscription that user has subscribed to if any. */\n lastSubscription?: Subscription;\n /** The reward account ID if user has linked rewards to the subscription. */\n rewardAccountId?: CaipAccountId;\n};\n\n/**\n * Benefits available to a subscription user.\n */\nexport type SwapsBenefitUsage = {\n feeBips: string | null;\n capMicroUsd?: number;\n consumedMicroUsd?: number;\n remainingMicroUsd: number | null;\n exhausted: boolean;\n};\n\nexport type PerpsBenefitUsage = {\n builderFeeBips: string | null;\n builderCode: string | null;\n capMicroUsd?: number;\n consumedMicroUsd?: number;\n remainingMicroUsd: number | null;\n exhausted: boolean;\n};\n\nexport type PredictBenefitUsage = {\n builderCode: string | null;\n capTxCount?: number;\n consumedTxCount?: number;\n remainingTxCount: number | null;\n exhausted: boolean;\n};\n\ntype SubscriptionBenefitsProducts = {\n swaps: SwapsBenefitUsage;\n perps: PerpsBenefitUsage;\n predict: PredictBenefitUsage;\n};\n\nexport type SubscriptionBenefitsResponse = {\n eligible: boolean;\n billingPeriodId: string | null;\n products: SubscriptionBenefitsProducts;\n};\n\n/**\n * Benefits state exposed to the UI.\n */\nexport type SubscriptionBenefitsState = SubscriptionBenefitsProducts & {\n billingPeriodId: string | null;\n};\n\nexport type StartSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n successUrl?: string;\n cancelUrl?: string;\n useTestClock?: boolean;\n\n /**\n * Optional CAIP account ID of the rewards account to opt in alongside this\n * subscription. Required when the user wants to link rewards during\n * subscription creation.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId?: CaipAccountId;\n};\n\nexport type StartSubscriptionResponse = {\n checkoutSessionUrl: string;\n};\n\ntype StartCryptoSubscriptionRequestBase = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n chainId: Hex;\n payerAddress: Hex;\n /**\n * e.g. \"USDC\"\n */\n tokenSymbol: string;\n isSponsored?: boolean;\n useTestClock?: boolean;\n /**\n * Optional CAIP account ID of the rewards account to opt in alongside this\n * subscription. Required when the user wants to link rewards during\n * subscription creation.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId?: CaipAccountId;\n};\n\n/**\n * ERC-20 approval crypto subscription request (e.g. Shield).\n *\n * `cryptoAuthMethod` defaults to `CRYPTO_AUTH_METHODS.ERC20_APPROVAL` when\n * omitted.\n */\nexport type StartErc20CryptoSubscriptionRequest =\n StartCryptoSubscriptionRequestBase & {\n cryptoAuthMethod?: typeof CRYPTO_AUTH_METHODS.ERC20_APPROVAL;\n rawTransaction: Hex;\n delegationHash?: never;\n };\n\n/**\n * Delegation-based crypto subscription request (e.g. Money Account Plus).\n */\nexport type StartDelegationCryptoSubscriptionRequest =\n StartCryptoSubscriptionRequestBase & {\n cryptoAuthMethod: typeof CRYPTO_AUTH_METHODS.DELEGATION;\n delegationHash: Hex;\n rawTransaction?: never;\n };\n\n/**\n * Request to start a crypto subscription.\n *\n * Discriminated union of ERC-20 approval vs delegation. Provide\n * `rawTransaction` for ERC-20 approval (the default when `cryptoAuthMethod` is\n * omitted), or `delegationHash` with `cryptoAuthMethod: 'delegation'`.\n * Combining or omitting both is a type error, and is also rejected at runtime\n * by `startSubscriptionWithCrypto`.\n */\nexport type StartCryptoSubscriptionRequest =\n | StartErc20CryptoSubscriptionRequest\n | StartDelegationCryptoSubscriptionRequest;\n\nexport type StartCryptoSubscriptionResponse = {\n subscriptionId: string;\n status: SubscriptionStatus;\n};\n\n/**\n * General response type for the subscription API requests\n * which doesn't require any specific response data.\n */\nexport type SubscriptionApiGeneralResponse = {\n /**\n * Whether the request was successful.\n */\n success: boolean;\n /**\n * The message of the response.\n */\n message?: string;\n};\n\nexport type CancelSubscriptionRequest = {\n subscriptionId: string;\n /** Whether to cancel at the end of the current period */\n cancelAtPeriodEnd?: boolean;\n /** Stable reason code for the cancellation. */\n cancellationReason?: CancellationReasonCode;\n /** Optional free-text feedback for the cancellation. */\n cancellationFeedback?: string;\n};\n\nexport type AuthUtils = {\n getAccessToken: () => Promise<string>;\n};\n\nexport type ProductPrice = {\n interval: RecurringInterval;\n unitAmount: number; // amount in the smallest unit of the currency, e.g., cents\n unitDecimals: number; // number of decimals for the smallest unit of the currency\n /** only usd for now */\n currency: Currency;\n trialPeriodDays: number;\n /** min billing cycles for approval */\n minBillingCycles: number;\n /** min billing cycles for account balance check */\n minBillingCyclesForBalance: number;\n};\n\nexport type ProductPricing = {\n name: ProductType;\n prices: ProductPrice[];\n};\n\ntype TokenPaymentInfoBase = {\n symbol: string;\n address: Hex;\n decimals: number;\n /**\n * example: {\n usd: '1.0',\n },\n */\n conversionRate?: {\n usd: string;\n };\n /**\n * Source tokens that can be converted into this settlement token.\n */\n sources?: TokenPaymentInfo[];\n};\n\n/**\n * Named vault a vault-share settlement token belongs to, e.g. `base` or\n * `premium`. Distinguishes which vault to withdraw from.\n *\n * Deliberately a plain `string` rather than a union: the set of vaults is\n * server-driven and grows without a client release, so narrowing it here would\n * make the pricing response fail validation the first time the API adds a\n * vault. Compare against `VAULT_NAMES` instead of raw literals, and always\n * handle the unknown case.\n */\nexport type VaultName = string;\n\n/**\n * The vault names known at the time of writing. Not exhaustive — see\n * {@link VaultName}.\n */\nexport const VAULT_NAMES = {\n base: 'base',\n premium: 'premium',\n} as const;\n\n/**\n * Spot (non-vault) settlement token. Priced via `conversionRate` when provided.\n * Neither `accountantAddress` nor `vault` is present on this variant.\n */\nexport type SpotTokenPaymentInfo = TokenPaymentInfoBase;\n\n/**\n * Yield-bearing vault share priced via an accountant rate.\n */\nexport type VaultTokenPaymentInfo = TokenPaymentInfoBase & {\n /**\n * Veda accountant address used to value this vault share. Every vault has\n * its own accountant, so this is present on every vault-share token — which\n * is what makes it the discriminant for this variant.\n */\n accountantAddress: Hex;\n /**\n * Named vault this token is a share of. Sent only for vault-share tokens.\n */\n vault?: VaultName;\n};\n\n/**\n * A settlement token in a pricing chain. Discriminated by the presence of\n * `accountantAddress`: vault shares carry it (and may carry `vault`), spot\n * tokens carry neither.\n *\n * The API previously sent an explicit `isVaultShare` boolean. It no longer\n * does, so do not reintroduce a dependency on it — use\n * {@link isVaultShareToken}.\n */\nexport type TokenPaymentInfo = SpotTokenPaymentInfo | VaultTokenPaymentInfo;\n\n/**\n * Whether a settlement token is a yield-bearing vault share, which must be\n * valued through its accountant rate rather than at face value.\n *\n * @param token - The settlement token to check.\n * @returns True if the token is a vault share.\n */\nexport function isVaultShareToken(\n token: TokenPaymentInfo,\n): token is VaultTokenPaymentInfo {\n return (token as VaultTokenPaymentInfo).accountantAddress !== undefined;\n}\n\nexport type ChainPaymentInfo = {\n chainId: Hex;\n paymentAddress: Hex;\n /**\n * Delegate address clients authorize when using the delegation auth method.\n */\n delegateAddress?: Hex;\n tokens: TokenPaymentInfo[];\n /**\n * Whether the chain supports sponsorship for the trialed subscription approval transaction.\n * This is used to determine if the user can be sponsored for the gas fees for the trialed subscription approval transaction.\n */\n isSponsorshipSupported?: boolean;\n};\n\nexport type PricingCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n /**\n * Products that support this payment method.\n */\n products?: ProductType[];\n};\n\nexport type PricingCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n /**\n * Crypto authorization method. Omitted together with `products` on persisted\n * pre-multi-product pricing rows; those rows are treated as Shield + `erc20_approval`.\n * If `products` is set, this field must be explicit.\n */\n cryptoAuthMethod?: CryptoAuthMethod;\n /**\n * Products that support this payment method. Omitted together with\n * `cryptoAuthMethod` on persisted pre-multi-product pricing rows (treated as Shield).\n * If present, must be non-empty and paired with an explicit `cryptoAuthMethod`.\n */\n products?: ProductType[];\n chains?: ChainPaymentInfo[];\n};\n\n/**\n * A pricing payment-method row. Discriminated by `type`: card rows have no\n * crypto fields; crypto rows may include `cryptoAuthMethod` and `chains`.\n */\nexport type PricingPaymentMethod =\n | PricingCardPaymentMethod\n | PricingCryptoPaymentMethod;\n\nexport type PricingResponse = {\n products: ProductPricing[];\n paymentMethods: PricingPaymentMethod[];\n};\n\nexport type GetCryptoApproveTransactionRequest = {\n /**\n * payment chain ID\n */\n chainId: Hex;\n /**\n * Payment token address\n */\n paymentTokenAddress: Hex;\n productType: ProductType;\n interval: RecurringInterval;\n};\n\nexport type GetCryptoApproveTransactionResponse = {\n /**\n * The amount to approve\n * e.g: \"100000000\"\n */\n approveAmount: string;\n /**\n * The contract address (spender)\n */\n paymentAddress: Hex;\n /**\n * The payment token address\n */\n paymentTokenAddress: Hex;\n chainId: Hex;\n};\n\n/**\n * Request to submit a Shield ERC-20 crypto approval transaction.\n */\nexport type SubmitSubscriptionCryptoApprovalRequest = {\n /**\n * The subscription product. Typed as `typeof PRODUCT_TYPES.SHIELD` only at\n * the moment (future might support more product).\n */\n productType: typeof PRODUCT_TYPES.SHIELD;\n /**\n * The transaction metadata. Must have type\n * `TransactionType.shieldSubscriptionApprove`.\n */\n txMeta: TransactionMeta;\n /**\n * Whether the transaction is sponsored.\n */\n isSponsored?: boolean;\n /**\n * The account ID of the reward subscription to link.\n */\n rewardAccountId?: CaipAccountId;\n};\n\nexport const COHORT_NAMES = {\n POST_TX: 'post_tx',\n WALLET_HOME: 'wallet_home',\n} as const;\n\nexport type CohortName = (typeof COHORT_NAMES)[keyof typeof COHORT_NAMES];\n\nexport const BALANCE_CATEGORIES = {\n RANGE_0_99: '0-99',\n RANGE_100_999: '100-999',\n RANGE_1K_9_9K: '1k-9.9k',\n RANGE_10K_99_9K: '10k-99.9k',\n RANGE_100K_999_9K: '100k-999.9k',\n RANGE_1M_PLUS: '1M+',\n} as const;\n\nexport type BalanceCategory =\n (typeof BALANCE_CATEGORIES)[keyof typeof BALANCE_CATEGORIES];\n\nexport type Cohort = {\n cohort: string;\n eligibilityRate: number; // 0-1 probability of being assigned to this cohort\n priority: number; // lower number = higher priority\n eligible: boolean;\n};\n\nexport type SubscriptionEligibility = {\n product: ProductType;\n canSubscribe: boolean;\n canViewEntryModal: boolean;\n modalType?: ModalType;\n cohorts: Cohort[];\n assignedCohort: string | null;\n hasAssignedCohortExpired: boolean;\n};\n\nexport const SubscriptionUserEvent = {\n ShieldEntryModalViewed: 'shield_entry_modal_viewed',\n ShieldCohortAssigned: 'shield_cohort_assigned',\n} as const;\n\nexport type SubscriptionUserEventType =\n (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];\n\nexport type SubmitUserEventRequest = {\n event: SubscriptionUserEventType;\n cohort?: string;\n};\n\nexport type AssignCohortRequest = {\n cohort: string;\n};\n\nexport type GetSubscriptionsEligibilitiesRequest = {\n balanceCategory?: BalanceCategory;\n};\n\n/**\n * Request object for submitting sponsorship intents.\n */\nexport type SubmitSponsorshipIntentsRequest = {\n chainId: Hex;\n address: Hex;\n products: ProductType[];\n paymentTokenSymbol: string;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type SubmitSponsorshipIntentsMethodParams = Pick<\n SubmitSponsorshipIntentsRequest,\n 'chainId' | 'address' | 'products'\n>;\n\nexport type ISubscriptionService = {\n getSubscriptions(): Promise<GetSubscriptionsResponse>;\n getBenefits(): Promise<SubscriptionBenefitsResponse>;\n cancelSubscription(request: CancelSubscriptionRequest): Promise<Subscription>;\n unCancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n /**\n * Starts a card-paid subscription checkout session for the requested products\n * (e.g. Shield or Money Account Plus).\n *\n * @param request - The start subscription request.\n * @returns The checkout session response.\n */\n startSubscriptionWithCard(\n request: StartSubscriptionRequest,\n ): Promise<StartSubscriptionResponse>;\n getBillingPortalUrl(): Promise<BillingPortalResponse>;\n getPricing(): Promise<PricingResponse>;\n startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse>;\n updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse>;\n updatePaymentMethodCrypto(\n request: UpdatePaymentMethodCryptoRequest,\n ): Promise<void>;\n getSubscriptionsEligibilities(\n request?: GetSubscriptionsEligibilitiesRequest,\n ): Promise<SubscriptionEligibility[]>;\n submitUserEvent(request: SubmitUserEventRequest): Promise<void>;\n assignUserToCohort(request: AssignCohortRequest): Promise<void>;\n\n /**\n * Link rewards to a subscription.\n */\n linkRewards(\n request: LinkRewardsRequest,\n ): Promise<SubscriptionApiGeneralResponse>;\n\n /**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n */\n submitSponsorshipIntents(\n request: SubmitSponsorshipIntentsRequest,\n ): Promise<void>;\n};\n\nexport type UpdatePaymentMethodOpts =\n | ({\n paymentType: Extract<PaymentType, 'card'>;\n } & UpdatePaymentMethodCardRequest)\n | ({\n paymentType: Extract<PaymentType, 'crypto'>;\n } & UpdatePaymentMethodCryptoRequest);\n\nexport type UpdatePaymentMethodCardRequest = {\n /**\n * Subscription ID\n */\n subscriptionId: string;\n\n /**\n * Recurring interval\n */\n recurringInterval: RecurringInterval;\n successUrl?: string;\n cancelUrl?: string;\n};\n\nexport type UpdatePaymentMethodCardResponse = {\n redirectUrl: string;\n};\n\ntype UpdatePaymentMethodCryptoRequestBase = {\n subscriptionId: string;\n chainId: Hex;\n payerAddress: Hex;\n tokenSymbol: string;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\n/**\n * ERC-20 approval crypto payment-method update request.\n *\n * `rawTransaction` may be omitted when retrying after a balance top-up.\n */\nexport type UpdateErc20PaymentMethodCryptoRequest =\n UpdatePaymentMethodCryptoRequestBase & {\n cryptoAuthMethod?: typeof CRYPTO_AUTH_METHODS.ERC20_APPROVAL;\n /**\n * The raw transaction to pay for the subscription.\n */\n rawTransaction?: Hex;\n delegationHash?: never;\n };\n\n/**\n * Delegation crypto payment-method update request used to rotate an active\n * subscription to a replacement delegation.\n */\nexport type UpdateDelegationPaymentMethodCryptoRequest =\n UpdatePaymentMethodCryptoRequestBase & {\n cryptoAuthMethod: typeof CRYPTO_AUTH_METHODS.DELEGATION;\n delegationHash: Hex;\n rawTransaction?: never;\n };\n\n/**\n * Request to update a subscription's crypto payment method.\n *\n * Provide `rawTransaction` for the existing ERC-20 approval path, or provide\n * `cryptoAuthMethod: 'delegation'` and `delegationHash` to rotate a delegation.\n */\nexport type UpdatePaymentMethodCryptoRequest =\n | UpdateErc20PaymentMethodCryptoRequest\n | UpdateDelegationPaymentMethodCryptoRequest;\n\nexport type BillingPortalResponse = {\n url: string;\n};\n\n/**\n * The cached result of last selected payment methods for the user.\n * These details are being cached to be used internally to track the last selected payment method for the user. (e.g. for crypto subscriptions)\n */\nexport type CachedLastSelectedPaymentMethod = {\n type: PaymentType;\n paymentTokenAddress?: Hex;\n paymentTokenSymbol?: string;\n plan: RecurringInterval;\n useTestClock?: boolean;\n /**\n * Crypto authorization method. Omitted on persisted cache entries written\n * before this field existed; treat as `erc20_approval` when missing.\n */\n cryptoAuthMethod?: CryptoAuthMethod;\n};\n\n/**\n * Request to cache the last selected payment method for a product.\n */\nexport type CacheLastSelectedPaymentMethodRequest = {\n /**\n * The product to cache the payment method for.\n */\n product: ProductType;\n /**\n * The payment method to cache.\n */\n paymentMethod: CachedLastSelectedPaymentMethod;\n};\n\n/**\n * Request object for linking rewards to a subscription.\n */\nexport type LinkRewardsRequest = {\n /**\n * The ID of the reward subscription to be linked to the subscription.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId: CaipAccountId;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/subscription-controller",
3
- "version": "9.1.0",
3
+ "version": "10.0.1",
4
4
  "description": "Handle user subscription",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -50,7 +50,7 @@
50
50
  "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
51
51
  },
52
52
  "dependencies": {
53
- "@metamask/authenticated-user-storage": "^4.0.0",
53
+ "@metamask/authenticated-user-storage": "^4.1.0",
54
54
  "@metamask/base-controller": "^10.0.0",
55
55
  "@metamask/base-data-service": "^2.0.0",
56
56
  "@metamask/chomp-api-service": "^5.0.0",
@@ -60,27 +60,27 @@
60
60
  "@metamask/delegation-deployments": "^1.4.0",
61
61
  "@metamask/messenger": "^3.0.0",
62
62
  "@metamask/money-account-balance-service": "^3.0.0",
63
- "@metamask/money-account-utils": "^2.0.0",
63
+ "@metamask/money-account-utils": "^2.0.1",
64
64
  "@metamask/polling-controller": "^17.0.0",
65
- "@metamask/profile-sync-controller": "^32.1.1",
65
+ "@metamask/profile-sync-controller": "^33.0.0",
66
66
  "@metamask/remote-feature-flag-controller": "^7.0.0",
67
67
  "@metamask/superstruct": "^3.4.1",
68
- "@metamask/transaction-controller": "^70.1.0",
68
+ "@metamask/transaction-controller": "^72.0.0",
69
69
  "@metamask/utils": "^12.0.0",
70
- "@tanstack/query-core": "^5.62.16",
70
+ "@tanstack/query-core": "^5.89.0",
71
71
  "bignumber.js": "^9.1.2",
72
72
  "fast-deep-equal": "^3.1.3"
73
73
  },
74
74
  "devDependencies": {
75
- "@metamask/auto-changelog": "^6.1.0",
75
+ "@metamask/auto-changelog": "^6.2.1",
76
76
  "@types/jest": "^30.0.0",
77
77
  "@typescript/native": "npm:typescript@^7.0.2",
78
78
  "deepmerge": "^4.2.2",
79
79
  "jest": "^30.4.2",
80
80
  "jest-environment-node": "^30.4.1",
81
- "rimraf": "^5.0.5",
82
- "ts-jest": "^29.4.11",
83
- "tsx": "^4.20.5",
81
+ "rimraf": "^6.1.3",
82
+ "ts-jest": "^29.4.12",
83
+ "tsx": "^4.23.15",
84
84
  "typedoc": "^0.25.13",
85
85
  "typedoc-plugin-missing-exports": "^2.0.0",
86
86
  "typescript": "npm:@typescript/typescript6@^6.0.2"