@metamask/subscription-controller 7.0.0 → 8.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 (62) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/dist/SubscriptionController-method-action-types.cjs.map +1 -1
  3. package/dist/SubscriptionController-method-action-types.d.cts +55 -18
  4. package/dist/SubscriptionController-method-action-types.d.cts.map +1 -1
  5. package/dist/SubscriptionController-method-action-types.d.mts +55 -18
  6. package/dist/SubscriptionController-method-action-types.d.mts.map +1 -1
  7. package/dist/SubscriptionController-method-action-types.mjs.map +1 -1
  8. package/dist/SubscriptionController.cjs +165 -45
  9. package/dist/SubscriptionController.cjs.map +1 -1
  10. package/dist/SubscriptionController.d.cts +55 -19
  11. package/dist/SubscriptionController.d.cts.map +1 -1
  12. package/dist/SubscriptionController.d.mts +55 -19
  13. package/dist/SubscriptionController.d.mts.map +1 -1
  14. package/dist/SubscriptionController.mjs +166 -46
  15. package/dist/SubscriptionController.mjs.map +1 -1
  16. package/dist/SubscriptionService-method-action-types.cjs.map +1 -1
  17. package/dist/SubscriptionService-method-action-types.d.cts +5 -1
  18. package/dist/SubscriptionService-method-action-types.d.cts.map +1 -1
  19. package/dist/SubscriptionService-method-action-types.d.mts +5 -1
  20. package/dist/SubscriptionService-method-action-types.d.mts.map +1 -1
  21. package/dist/SubscriptionService-method-action-types.mjs.map +1 -1
  22. package/dist/SubscriptionService-structs.cjs +35 -12
  23. package/dist/SubscriptionService-structs.cjs.map +1 -1
  24. package/dist/SubscriptionService-structs.d.cts +185 -237
  25. package/dist/SubscriptionService-structs.d.cts.map +1 -1
  26. package/dist/SubscriptionService-structs.d.mts +185 -237
  27. package/dist/SubscriptionService-structs.d.mts.map +1 -1
  28. package/dist/SubscriptionService-structs.mjs +37 -14
  29. package/dist/SubscriptionService-structs.mjs.map +1 -1
  30. package/dist/SubscriptionService.cjs +25 -3
  31. package/dist/SubscriptionService.cjs.map +1 -1
  32. package/dist/SubscriptionService.d.cts +5 -1
  33. package/dist/SubscriptionService.d.cts.map +1 -1
  34. package/dist/SubscriptionService.d.mts +5 -1
  35. package/dist/SubscriptionService.d.mts.map +1 -1
  36. package/dist/SubscriptionService.mjs +25 -3
  37. package/dist/SubscriptionService.mjs.map +1 -1
  38. package/dist/constants.cjs +2 -0
  39. package/dist/constants.cjs.map +1 -1
  40. package/dist/constants.d.cts +2 -0
  41. package/dist/constants.d.cts.map +1 -1
  42. package/dist/constants.d.mts +2 -0
  43. package/dist/constants.d.mts.map +1 -1
  44. package/dist/constants.mjs +2 -0
  45. package/dist/constants.mjs.map +1 -1
  46. package/dist/index.cjs +2 -1
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +3 -3
  49. package/dist/index.d.cts.map +1 -1
  50. package/dist/index.d.mts +3 -3
  51. package/dist/index.d.mts.map +1 -1
  52. package/dist/index.mjs +1 -1
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/types.cjs +27 -1
  55. package/dist/types.cjs.map +1 -1
  56. package/dist/types.d.cts +171 -10
  57. package/dist/types.d.cts.map +1 -1
  58. package/dist/types.d.mts +171 -10
  59. package/dist/types.d.mts.map +1 -1
  60. package/dist/types.mjs +26 -0
  61. package/dist/types.mjs.map +1 -1
  62. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionService-method-action-types.cjs","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SubscriptionService } from './SubscriptionService.js';\n\n/**\n * Fetches the user's subscriptions.\n *\n * @returns The subscriptions response.\n */\nexport type SubscriptionServiceGetSubscriptionsAction = {\n type: `SubscriptionService:getSubscriptions`;\n handler: SubscriptionService['getSubscriptions'];\n};\n\n/**\n * Cancels a subscription.\n *\n * @param params - The cancel subscription request.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceCancelSubscriptionAction = {\n type: `SubscriptionService:cancelSubscription`;\n handler: SubscriptionService['cancelSubscription'];\n};\n\n/**\n * Reverses a pending subscription cancellation.\n *\n * @param params - The uncancel subscription request.\n * @param params.subscriptionId - The subscription ID to uncancel.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceUnCancelSubscriptionAction = {\n type: `SubscriptionService:unCancelSubscription`;\n handler: SubscriptionService['unCancelSubscription'];\n};\n\n/**\n * Starts a subscription with a card payment method.\n *\n * @param request - The start subscription request.\n * @returns The checkout session response.\n */\nexport type SubscriptionServiceStartSubscriptionWithCardAction = {\n type: `SubscriptionService:startSubscriptionWithCard`;\n handler: SubscriptionService['startSubscriptionWithCard'];\n};\n\n/**\n * Starts a subscription with a crypto payment method.\n *\n * @param request - The start crypto subscription request.\n * @returns The created subscription response.\n */\nexport type SubscriptionServiceStartSubscriptionWithCryptoAction = {\n type: `SubscriptionService:startSubscriptionWithCrypto`;\n handler: SubscriptionService['startSubscriptionWithCrypto'];\n};\n\n/**\n * Updates a subscription's card payment method.\n *\n * @param request - The update payment method request.\n * @returns The redirect URL response.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCardAction = {\n type: `SubscriptionService:updatePaymentMethodCard`;\n handler: SubscriptionService['updatePaymentMethodCard'];\n};\n\n/**\n * Updates a subscription's crypto payment method.\n *\n * @param request - The update payment method request.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCryptoAction = {\n type: `SubscriptionService:updatePaymentMethodCrypto`;\n handler: SubscriptionService['updatePaymentMethodCrypto'];\n};\n\n/**\n * Get the eligibility for a shield subscription.\n *\n * @param request - Optional request object containing user balance category to check cohort eligibility\n * @returns The eligibility for a shield subscription\n */\nexport type SubscriptionServiceGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionService:getSubscriptionsEligibilities`;\n handler: SubscriptionService['getSubscriptionsEligibilities'];\n};\n\n/**\n * Submit a user event. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionServiceSubmitUserEventAction = {\n type: `SubscriptionService:submitUserEvent`;\n handler: SubscriptionService['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionServiceAssignUserToCohortAction = {\n type: `SubscriptionService:assignUserToCohort`;\n handler: SubscriptionService['assignUserToCohort'];\n};\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 { address: '0x1234567890123456789012345678901234567890', products: [ProductType.Shield] }\n */\nexport type SubscriptionServiceSubmitSponsorshipIntentsAction = {\n type: `SubscriptionService:submitSponsorshipIntents`;\n handler: SubscriptionService['submitSponsorshipIntents'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward account ID.\n * @example { rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns The response from the API.\n */\nexport type SubscriptionServiceLinkRewardsAction = {\n type: `SubscriptionService:linkRewards`;\n handler: SubscriptionService['linkRewards'];\n};\n\n/**\n * Fetches subscription pricing information.\n *\n * @returns The pricing response.\n */\nexport type SubscriptionServiceGetPricingAction = {\n type: `SubscriptionService:getPricing`;\n handler: SubscriptionService['getPricing'];\n};\n\n/**\n * Fetches the billing portal URL.\n *\n * @returns The billing portal response.\n */\nexport type SubscriptionServiceGetBillingPortalUrlAction = {\n type: `SubscriptionService:getBillingPortalUrl`;\n handler: SubscriptionService['getBillingPortalUrl'];\n};\n\n/**\n * Union of all SubscriptionService action types.\n */\nexport type SubscriptionServiceMethodActions =\n | SubscriptionServiceGetSubscriptionsAction\n | SubscriptionServiceCancelSubscriptionAction\n | SubscriptionServiceUnCancelSubscriptionAction\n | SubscriptionServiceStartSubscriptionWithCardAction\n | SubscriptionServiceStartSubscriptionWithCryptoAction\n | SubscriptionServiceUpdatePaymentMethodCardAction\n | SubscriptionServiceUpdatePaymentMethodCryptoAction\n | SubscriptionServiceGetSubscriptionsEligibilitiesAction\n | SubscriptionServiceSubmitUserEventAction\n | SubscriptionServiceAssignUserToCohortAction\n | SubscriptionServiceSubmitSponsorshipIntentsAction\n | SubscriptionServiceLinkRewardsAction\n | SubscriptionServiceGetPricingAction\n | SubscriptionServiceGetBillingPortalUrlAction;\n"]}
1
+ {"version":3,"file":"SubscriptionService-method-action-types.cjs","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SubscriptionService } from './SubscriptionService.js';\n\n/**\n * Fetches the user's subscriptions.\n *\n * @returns The subscriptions response.\n */\nexport type SubscriptionServiceGetSubscriptionsAction = {\n type: `SubscriptionService:getSubscriptions`;\n handler: SubscriptionService['getSubscriptions'];\n};\n\n/**\n * Cancels a subscription.\n *\n * @param params - The cancel subscription request.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceCancelSubscriptionAction = {\n type: `SubscriptionService:cancelSubscription`;\n handler: SubscriptionService['cancelSubscription'];\n};\n\n/**\n * Reverses a pending subscription cancellation.\n *\n * @param params - The uncancel subscription request.\n * @param params.subscriptionId - The subscription ID to uncancel.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceUnCancelSubscriptionAction = {\n type: `SubscriptionService:unCancelSubscription`;\n handler: SubscriptionService['unCancelSubscription'];\n};\n\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 */\nexport type SubscriptionServiceStartSubscriptionWithCardAction = {\n type: `SubscriptionService:startSubscriptionWithCard`;\n handler: SubscriptionService['startSubscriptionWithCard'];\n};\n\n/**\n * Starts a subscription with a crypto payment method.\n *\n * @param request - The start crypto subscription request.\n * @returns The created subscription response.\n * @throws If `products` is empty.\n * @throws If the request does not use exactly one of `rawTransaction`\n * (ERC-20 approval) or `delegationHash` (delegation).\n */\nexport type SubscriptionServiceStartSubscriptionWithCryptoAction = {\n type: `SubscriptionService:startSubscriptionWithCrypto`;\n handler: SubscriptionService['startSubscriptionWithCrypto'];\n};\n\n/**\n * Updates a subscription's card payment method.\n *\n * @param request - The update payment method request.\n * @returns The redirect URL response.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCardAction = {\n type: `SubscriptionService:updatePaymentMethodCard`;\n handler: SubscriptionService['updatePaymentMethodCard'];\n};\n\n/**\n * Updates a subscription's crypto payment method.\n *\n * @param request - The update payment method request.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCryptoAction = {\n type: `SubscriptionService:updatePaymentMethodCrypto`;\n handler: SubscriptionService['updatePaymentMethodCrypto'];\n};\n\n/**\n * Get the eligibility for a shield subscription.\n *\n * @param request - Optional request object containing user balance category to check cohort eligibility\n * @returns The eligibility for a shield subscription\n */\nexport type SubscriptionServiceGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionService:getSubscriptionsEligibilities`;\n handler: SubscriptionService['getSubscriptionsEligibilities'];\n};\n\n/**\n * Submit a user event. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionServiceSubmitUserEventAction = {\n type: `SubscriptionService:submitUserEvent`;\n handler: SubscriptionService['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionServiceAssignUserToCohortAction = {\n type: `SubscriptionService:assignUserToCohort`;\n handler: SubscriptionService['assignUserToCohort'];\n};\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 { address: '0x1234567890123456789012345678901234567890', products: [ProductType.Shield] }\n */\nexport type SubscriptionServiceSubmitSponsorshipIntentsAction = {\n type: `SubscriptionService:submitSponsorshipIntents`;\n handler: SubscriptionService['submitSponsorshipIntents'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward account ID.\n * @example { rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns The response from the API.\n */\nexport type SubscriptionServiceLinkRewardsAction = {\n type: `SubscriptionService:linkRewards`;\n handler: SubscriptionService['linkRewards'];\n};\n\n/**\n * Fetches subscription pricing information.\n *\n * @returns The pricing response.\n */\nexport type SubscriptionServiceGetPricingAction = {\n type: `SubscriptionService:getPricing`;\n handler: SubscriptionService['getPricing'];\n};\n\n/**\n * Fetches the billing portal URL.\n *\n * @returns The billing portal response.\n */\nexport type SubscriptionServiceGetBillingPortalUrlAction = {\n type: `SubscriptionService:getBillingPortalUrl`;\n handler: SubscriptionService['getBillingPortalUrl'];\n};\n\n/**\n * Union of all SubscriptionService action types.\n */\nexport type SubscriptionServiceMethodActions =\n | SubscriptionServiceGetSubscriptionsAction\n | SubscriptionServiceCancelSubscriptionAction\n | SubscriptionServiceUnCancelSubscriptionAction\n | SubscriptionServiceStartSubscriptionWithCardAction\n | SubscriptionServiceStartSubscriptionWithCryptoAction\n | SubscriptionServiceUpdatePaymentMethodCardAction\n | SubscriptionServiceUpdatePaymentMethodCryptoAction\n | SubscriptionServiceGetSubscriptionsEligibilitiesAction\n | SubscriptionServiceSubmitUserEventAction\n | SubscriptionServiceAssignUserToCohortAction\n | SubscriptionServiceSubmitSponsorshipIntentsAction\n | SubscriptionServiceLinkRewardsAction\n | SubscriptionServiceGetPricingAction\n | SubscriptionServiceGetBillingPortalUrlAction;\n"]}
@@ -34,7 +34,8 @@ export type SubscriptionServiceUnCancelSubscriptionAction = {
34
34
  handler: SubscriptionService['unCancelSubscription'];
35
35
  };
36
36
  /**
37
- * Starts a subscription with a card payment method.
37
+ * Starts a card-paid subscription checkout session for the requested products
38
+ * (e.g. Shield or Money Account Plus).
38
39
  *
39
40
  * @param request - The start subscription request.
40
41
  * @returns The checkout session response.
@@ -48,6 +49,9 @@ export type SubscriptionServiceStartSubscriptionWithCardAction = {
48
49
  *
49
50
  * @param request - The start crypto subscription request.
50
51
  * @returns The created subscription response.
52
+ * @throws If `products` is empty.
53
+ * @throws If the request does not use exactly one of `rawTransaction`
54
+ * (ERC-20 approval) or `delegationHash` (delegation).
51
55
  */
52
56
  export type SubscriptionServiceStartSubscriptionWithCryptoAction = {
53
57
  type: `SubscriptionService:startSubscriptionWithCrypto`;
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionService-method-action-types.d.cts","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAiC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,mBAAmB,CAAC,2BAA2B,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oDAAoD,G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,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,yCAAyC,GACzC,2CAA2C,GAC3C,6CAA6C,GAC7C,kDAAkD,GAClD,oDAAoD,GACpD,gDAAgD,GAChD,kDAAkD,GAClD,sDAAsD,GACtD,wCAAwC,GACxC,2CAA2C,GAC3C,iDAAiD,GACjD,oCAAoC,GACpC,mCAAmC,GACnC,4CAA4C,CAAC"}
1
+ {"version":3,"file":"SubscriptionService-method-action-types.d.cts","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAiC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,mBAAmB,CAAC,2BAA2B,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oDAA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EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,yCAAyC,GACzC,2CAA2C,GAC3C,6CAA6C,GAC7C,kDAAkD,GAClD,oDAAoD,GACpD,gDAAgD,GAChD,kDAAkD,GAClD,sDAAsD,GACtD,wCAAwC,GACxC,2CAA2C,GAC3C,iDAAiD,GACjD,oCAAoC,GACpC,mCAAmC,GACnC,4CAA4C,CAAC"}
@@ -34,7 +34,8 @@ export type SubscriptionServiceUnCancelSubscriptionAction = {
34
34
  handler: SubscriptionService['unCancelSubscription'];
35
35
  };
36
36
  /**
37
- * Starts a subscription with a card payment method.
37
+ * Starts a card-paid subscription checkout session for the requested products
38
+ * (e.g. Shield or Money Account Plus).
38
39
  *
39
40
  * @param request - The start subscription request.
40
41
  * @returns The checkout session response.
@@ -48,6 +49,9 @@ export type SubscriptionServiceStartSubscriptionWithCardAction = {
48
49
  *
49
50
  * @param request - The start crypto subscription request.
50
51
  * @returns The created subscription response.
52
+ * @throws If `products` is empty.
53
+ * @throws If the request does not use exactly one of `rawTransaction`
54
+ * (ERC-20 approval) or `delegationHash` (delegation).
51
55
  */
52
56
  export type SubscriptionServiceStartSubscriptionWithCryptoAction = {
53
57
  type: `SubscriptionService:startSubscriptionWithCrypto`;
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionService-method-action-types.d.mts","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAiC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,E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EF;;;;;GAKG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,yCAAyC,GACzC,2CAA2C,GAC3C,6CAA6C,GAC7C,kDAAkD,GAClD,oDAAoD,GACpD,gDAAgD,GAChD,kDAAkD,GAClD,sDAAsD,GACtD,wCAAwC,GACxC,2CAA2C,GAC3C,iDAAiD,GACjD,oCAAoC,GACpC,mCAAmC,GACnC,4CAA4C,CAAC"}
1
+ {"version":3,"file":"SubscriptionService-method-action-types.d.mts","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAiC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,E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C;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,yCAAyC,GACzC,2CAA2C,GAC3C,6CAA6C,GAC7C,kDAAkD,GAClD,oDAAoD,GACpD,gDAAgD,GAChD,kDAAkD,GAClD,sDAAsD,GACtD,wCAAwC,GACxC,2CAA2C,GAC3C,iDAAiD,GACjD,oCAAoC,GACpC,mCAAmC,GACnC,4CAA4C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionService-method-action-types.mjs","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SubscriptionService } from './SubscriptionService.js';\n\n/**\n * Fetches the user's subscriptions.\n *\n * @returns The subscriptions response.\n */\nexport type SubscriptionServiceGetSubscriptionsAction = {\n type: `SubscriptionService:getSubscriptions`;\n handler: SubscriptionService['getSubscriptions'];\n};\n\n/**\n * Cancels a subscription.\n *\n * @param params - The cancel subscription request.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceCancelSubscriptionAction = {\n type: `SubscriptionService:cancelSubscription`;\n handler: SubscriptionService['cancelSubscription'];\n};\n\n/**\n * Reverses a pending subscription cancellation.\n *\n * @param params - The uncancel subscription request.\n * @param params.subscriptionId - The subscription ID to uncancel.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceUnCancelSubscriptionAction = {\n type: `SubscriptionService:unCancelSubscription`;\n handler: SubscriptionService['unCancelSubscription'];\n};\n\n/**\n * Starts a subscription with a card payment method.\n *\n * @param request - The start subscription request.\n * @returns The checkout session response.\n */\nexport type SubscriptionServiceStartSubscriptionWithCardAction = {\n type: `SubscriptionService:startSubscriptionWithCard`;\n handler: SubscriptionService['startSubscriptionWithCard'];\n};\n\n/**\n * Starts a subscription with a crypto payment method.\n *\n * @param request - The start crypto subscription request.\n * @returns The created subscription response.\n */\nexport type SubscriptionServiceStartSubscriptionWithCryptoAction = {\n type: `SubscriptionService:startSubscriptionWithCrypto`;\n handler: SubscriptionService['startSubscriptionWithCrypto'];\n};\n\n/**\n * Updates a subscription's card payment method.\n *\n * @param request - The update payment method request.\n * @returns The redirect URL response.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCardAction = {\n type: `SubscriptionService:updatePaymentMethodCard`;\n handler: SubscriptionService['updatePaymentMethodCard'];\n};\n\n/**\n * Updates a subscription's crypto payment method.\n *\n * @param request - The update payment method request.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCryptoAction = {\n type: `SubscriptionService:updatePaymentMethodCrypto`;\n handler: SubscriptionService['updatePaymentMethodCrypto'];\n};\n\n/**\n * Get the eligibility for a shield subscription.\n *\n * @param request - Optional request object containing user balance category to check cohort eligibility\n * @returns The eligibility for a shield subscription\n */\nexport type SubscriptionServiceGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionService:getSubscriptionsEligibilities`;\n handler: SubscriptionService['getSubscriptionsEligibilities'];\n};\n\n/**\n * Submit a user event. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionServiceSubmitUserEventAction = {\n type: `SubscriptionService:submitUserEvent`;\n handler: SubscriptionService['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionServiceAssignUserToCohortAction = {\n type: `SubscriptionService:assignUserToCohort`;\n handler: SubscriptionService['assignUserToCohort'];\n};\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 { address: '0x1234567890123456789012345678901234567890', products: [ProductType.Shield] }\n */\nexport type SubscriptionServiceSubmitSponsorshipIntentsAction = {\n type: `SubscriptionService:submitSponsorshipIntents`;\n handler: SubscriptionService['submitSponsorshipIntents'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward account ID.\n * @example { rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns The response from the API.\n */\nexport type SubscriptionServiceLinkRewardsAction = {\n type: `SubscriptionService:linkRewards`;\n handler: SubscriptionService['linkRewards'];\n};\n\n/**\n * Fetches subscription pricing information.\n *\n * @returns The pricing response.\n */\nexport type SubscriptionServiceGetPricingAction = {\n type: `SubscriptionService:getPricing`;\n handler: SubscriptionService['getPricing'];\n};\n\n/**\n * Fetches the billing portal URL.\n *\n * @returns The billing portal response.\n */\nexport type SubscriptionServiceGetBillingPortalUrlAction = {\n type: `SubscriptionService:getBillingPortalUrl`;\n handler: SubscriptionService['getBillingPortalUrl'];\n};\n\n/**\n * Union of all SubscriptionService action types.\n */\nexport type SubscriptionServiceMethodActions =\n | SubscriptionServiceGetSubscriptionsAction\n | SubscriptionServiceCancelSubscriptionAction\n | SubscriptionServiceUnCancelSubscriptionAction\n | SubscriptionServiceStartSubscriptionWithCardAction\n | SubscriptionServiceStartSubscriptionWithCryptoAction\n | SubscriptionServiceUpdatePaymentMethodCardAction\n | SubscriptionServiceUpdatePaymentMethodCryptoAction\n | SubscriptionServiceGetSubscriptionsEligibilitiesAction\n | SubscriptionServiceSubmitUserEventAction\n | SubscriptionServiceAssignUserToCohortAction\n | SubscriptionServiceSubmitSponsorshipIntentsAction\n | SubscriptionServiceLinkRewardsAction\n | SubscriptionServiceGetPricingAction\n | SubscriptionServiceGetBillingPortalUrlAction;\n"]}
1
+ {"version":3,"file":"SubscriptionService-method-action-types.mjs","sourceRoot":"","sources":["../src/SubscriptionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SubscriptionService } from './SubscriptionService.js';\n\n/**\n * Fetches the user's subscriptions.\n *\n * @returns The subscriptions response.\n */\nexport type SubscriptionServiceGetSubscriptionsAction = {\n type: `SubscriptionService:getSubscriptions`;\n handler: SubscriptionService['getSubscriptions'];\n};\n\n/**\n * Cancels a subscription.\n *\n * @param params - The cancel subscription request.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceCancelSubscriptionAction = {\n type: `SubscriptionService:cancelSubscription`;\n handler: SubscriptionService['cancelSubscription'];\n};\n\n/**\n * Reverses a pending subscription cancellation.\n *\n * @param params - The uncancel subscription request.\n * @param params.subscriptionId - The subscription ID to uncancel.\n * @returns The updated subscription.\n */\nexport type SubscriptionServiceUnCancelSubscriptionAction = {\n type: `SubscriptionService:unCancelSubscription`;\n handler: SubscriptionService['unCancelSubscription'];\n};\n\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 */\nexport type SubscriptionServiceStartSubscriptionWithCardAction = {\n type: `SubscriptionService:startSubscriptionWithCard`;\n handler: SubscriptionService['startSubscriptionWithCard'];\n};\n\n/**\n * Starts a subscription with a crypto payment method.\n *\n * @param request - The start crypto subscription request.\n * @returns The created subscription response.\n * @throws If `products` is empty.\n * @throws If the request does not use exactly one of `rawTransaction`\n * (ERC-20 approval) or `delegationHash` (delegation).\n */\nexport type SubscriptionServiceStartSubscriptionWithCryptoAction = {\n type: `SubscriptionService:startSubscriptionWithCrypto`;\n handler: SubscriptionService['startSubscriptionWithCrypto'];\n};\n\n/**\n * Updates a subscription's card payment method.\n *\n * @param request - The update payment method request.\n * @returns The redirect URL response.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCardAction = {\n type: `SubscriptionService:updatePaymentMethodCard`;\n handler: SubscriptionService['updatePaymentMethodCard'];\n};\n\n/**\n * Updates a subscription's crypto payment method.\n *\n * @param request - The update payment method request.\n */\nexport type SubscriptionServiceUpdatePaymentMethodCryptoAction = {\n type: `SubscriptionService:updatePaymentMethodCrypto`;\n handler: SubscriptionService['updatePaymentMethodCrypto'];\n};\n\n/**\n * Get the eligibility for a shield subscription.\n *\n * @param request - Optional request object containing user balance category to check cohort eligibility\n * @returns The eligibility for a shield subscription\n */\nexport type SubscriptionServiceGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionService:getSubscriptionsEligibilities`;\n handler: SubscriptionService['getSubscriptionsEligibilities'];\n};\n\n/**\n * Submit a user event. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionServiceSubmitUserEventAction = {\n type: `SubscriptionService:submitUserEvent`;\n handler: SubscriptionService['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionServiceAssignUserToCohortAction = {\n type: `SubscriptionService:assignUserToCohort`;\n handler: SubscriptionService['assignUserToCohort'];\n};\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 { address: '0x1234567890123456789012345678901234567890', products: [ProductType.Shield] }\n */\nexport type SubscriptionServiceSubmitSponsorshipIntentsAction = {\n type: `SubscriptionService:submitSponsorshipIntents`;\n handler: SubscriptionService['submitSponsorshipIntents'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward account ID.\n * @example { rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns The response from the API.\n */\nexport type SubscriptionServiceLinkRewardsAction = {\n type: `SubscriptionService:linkRewards`;\n handler: SubscriptionService['linkRewards'];\n};\n\n/**\n * Fetches subscription pricing information.\n *\n * @returns The pricing response.\n */\nexport type SubscriptionServiceGetPricingAction = {\n type: `SubscriptionService:getPricing`;\n handler: SubscriptionService['getPricing'];\n};\n\n/**\n * Fetches the billing portal URL.\n *\n * @returns The billing portal response.\n */\nexport type SubscriptionServiceGetBillingPortalUrlAction = {\n type: `SubscriptionService:getBillingPortalUrl`;\n handler: SubscriptionService['getBillingPortalUrl'];\n};\n\n/**\n * Union of all SubscriptionService action types.\n */\nexport type SubscriptionServiceMethodActions =\n | SubscriptionServiceGetSubscriptionsAction\n | SubscriptionServiceCancelSubscriptionAction\n | SubscriptionServiceUnCancelSubscriptionAction\n | SubscriptionServiceStartSubscriptionWithCardAction\n | SubscriptionServiceStartSubscriptionWithCryptoAction\n | SubscriptionServiceUpdatePaymentMethodCardAction\n | SubscriptionServiceUpdatePaymentMethodCryptoAction\n | SubscriptionServiceGetSubscriptionsEligibilitiesAction\n | SubscriptionServiceSubmitUserEventAction\n | SubscriptionServiceAssignUserToCohortAction\n | SubscriptionServiceSubmitSponsorshipIntentsAction\n | SubscriptionServiceLinkRewardsAction\n | SubscriptionServiceGetPricingAction\n | SubscriptionServiceGetBillingPortalUrlAction;\n"]}
@@ -5,7 +5,7 @@ const superstruct_1 = require("@metamask/superstruct");
5
5
  const utils_1 = require("@metamask/utils");
6
6
  const types_js_1 = require("./types.cjs");
7
7
  const ProductTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.PRODUCT_TYPES));
8
- const PaymentTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.PAYMENT_TYPES));
8
+ const CryptoAuthMethodStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CRYPTO_AUTH_METHODS));
9
9
  const RecurringIntervalStruct = (0, superstruct_1.enums)(Object.values(types_js_1.RECURRING_INTERVALS));
10
10
  const SubscriptionStatusStruct = (0, superstruct_1.enums)(Object.values(types_js_1.SUBSCRIPTION_STATUSES));
11
11
  const CancelTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CANCEL_TYPES));
@@ -93,24 +93,47 @@ const ProductPricingStruct = (0, superstruct_1.type)({
93
93
  name: ProductTypeStruct,
94
94
  prices: (0, superstruct_1.array)(ProductPriceStruct),
95
95
  });
96
- const TokenPaymentInfoStruct = (0, superstruct_1.type)({
97
- symbol: (0, superstruct_1.string)(),
98
- address: utils_1.StrictHexStruct,
99
- decimals: (0, superstruct_1.number)(),
100
- conversionRate: (0, superstruct_1.type)({
101
- usd: (0, superstruct_1.string)(),
96
+ const TokenPaymentInfoConversionRateStruct = (0, superstruct_1.type)({
97
+ usd: (0, superstruct_1.string)(),
98
+ });
99
+ const TokenPaymentInfoStruct = (0, superstruct_1.lazy)(() => (0, superstruct_1.union)([
100
+ (0, superstruct_1.object)({
101
+ symbol: (0, superstruct_1.string)(),
102
+ address: utils_1.StrictHexStruct,
103
+ decimals: (0, superstruct_1.number)(),
104
+ conversionRate: (0, superstruct_1.optional)(TokenPaymentInfoConversionRateStruct),
105
+ isVaultShare: (0, superstruct_1.literal)(true),
106
+ accountantAddress: utils_1.StrictHexStruct,
107
+ sources: (0, superstruct_1.optional)((0, superstruct_1.array)(TokenPaymentInfoStruct)),
102
108
  }),
103
- });
109
+ (0, superstruct_1.object)({
110
+ symbol: (0, superstruct_1.string)(),
111
+ address: utils_1.StrictHexStruct,
112
+ decimals: (0, superstruct_1.number)(),
113
+ conversionRate: (0, superstruct_1.optional)(TokenPaymentInfoConversionRateStruct),
114
+ isVaultShare: (0, superstruct_1.optional)((0, superstruct_1.literal)(false)),
115
+ sources: (0, superstruct_1.optional)((0, superstruct_1.array)(TokenPaymentInfoStruct)),
116
+ }),
117
+ ]));
104
118
  const ChainPaymentInfoStruct = (0, superstruct_1.type)({
105
119
  chainId: utils_1.StrictHexStruct,
106
120
  paymentAddress: utils_1.StrictHexStruct,
121
+ delegateAddress: (0, superstruct_1.optional)(utils_1.StrictHexStruct),
107
122
  tokens: (0, superstruct_1.array)(TokenPaymentInfoStruct),
108
123
  isSponsorshipSupported: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
109
124
  });
110
- const PricingPaymentMethodStruct = (0, superstruct_1.type)({
111
- type: PaymentTypeStruct,
112
- chains: (0, superstruct_1.optional)((0, superstruct_1.array)(ChainPaymentInfoStruct)),
113
- });
125
+ const PricingPaymentMethodStruct = (0, superstruct_1.union)([
126
+ (0, superstruct_1.object)({
127
+ type: (0, superstruct_1.enums)([types_js_1.PAYMENT_TYPES.byCard]),
128
+ products: (0, superstruct_1.optional)((0, superstruct_1.array)(ProductTypeStruct)),
129
+ }),
130
+ (0, superstruct_1.object)({
131
+ type: (0, superstruct_1.enums)([types_js_1.PAYMENT_TYPES.byCrypto]),
132
+ cryptoAuthMethod: (0, superstruct_1.optional)(CryptoAuthMethodStruct),
133
+ products: (0, superstruct_1.optional)((0, superstruct_1.array)(ProductTypeStruct)),
134
+ chains: (0, superstruct_1.optional)((0, superstruct_1.array)(ChainPaymentInfoStruct)),
135
+ }),
136
+ ]);
114
137
  exports.PricingResponseStruct = (0, superstruct_1.type)({
115
138
  products: (0, superstruct_1.array)(ProductPricingStruct),
116
139
  paymentMethods: (0, superstruct_1.array)(PricingPaymentMethodStruct),
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionService-structs.cjs","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":";;;AAAA,uDAU+B;AAC/B,2CAAuE;AAEvE,0CAOoB;AAEpB,MAAM,iBAAiB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,wBAAa,CAAC,CAAC,CAAC;AAC9D,MAAM,iBAAiB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,wBAAa,CAAC,CAAC,CAAC;AAC9D,MAAM,uBAAuB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,8BAAmB,CAAC,CAAC,CAAC;AAC1E,MAAM,wBAAwB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,gCAAqB,CAAC,CAAC,CAAC;AAC7E,MAAM,gBAAgB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,uBAAY,CAAC,CAAC,CAAC;AAC5D,MAAM,8BAA8B,GAAG,IAAA,mBAAK,EAC1C,MAAM,CAAC,MAAM,CAAC,uCAA4B,CAAC,CAC5C,CAAC;AAEF,MAAM,aAAa,GAAG,IAAA,kBAAI,EAAC;IACzB,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,IAAA,mBAAK,EAAC,CAAC,KAAK,CAAC,CAAC;IACxB,UAAU,EAAE,IAAA,oBAAM,GAAE;IACpB,YAAY,EAAE,IAAA,oBAAM,GAAE;CACvB,CAAC,CAAC;AAEH,MAAM,mCAAmC,GAAG,IAAA,kBAAI,EAAC;IAC/C,IAAI,EAAE,IAAA,mBAAK,EAAC,CAAC,wBAAa,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,EAAE,IAAA,kBAAI,EAAC;QACT,KAAK,EAAE,IAAA,oBAAM,GAAE;Q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AY,GAAG,IAAA,kBAAI,EAAC;IACxB,MAAM,EAAE,IAAA,oBAAM,GAAE;IAChB,eAAe,EAAE,IAAA,oBAAM,GAAE;IACzB,QAAQ,EAAE,IAAA,oBAAM,GAAE;IAClB,QAAQ,EAAE,IAAA,qBAAO,GAAE;CACpB,CAAC,CAAC;AAEU,QAAA,6BAA6B,GAAG,IAAA,kBAAI,EAAC;IAChD,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IACjC,iBAAiB,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IACtC,SAAS,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,YAAY,CAAC,CAAC;IACtC,cAAc,EAAE,IAAA,sBAAQ,EAAC,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC,CAAC;IAC5C,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC9B,wBAAwB,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;CAC9C,CAAC,CAAC;AAEU,QAAA,kCAAkC,GAAG,IAAA,mBAAK,EACrD,qCAA6B,CAC9B,CAAC","sourcesContent":["import {\n array,\n boolean,\n enums,\n nullable,\n number,\n optional,\n string,\n type,\n union,\n} from '@metamask/superstruct';\nimport { StrictHexStruct, CaipAccountIdStruct } from '@metamask/utils';\n\nimport {\n CANCEL_TYPES,\n CRYPTO_PAYMENT_METHOD_ERRORS,\n PAYMENT_TYPES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n SUBSCRIPTION_STATUSES,\n} from './types.js';\n\nconst ProductTypeStruct = enums(Object.values(PRODUCT_TYPES));\nconst PaymentTypeStruct = enums(Object.values(PAYMENT_TYPES));\nconst RecurringIntervalStruct = enums(Object.values(RECURRING_INTERVALS));\nconst SubscriptionStatusStruct = enums(Object.values(SUBSCRIPTION_STATUSES));\nconst CancelTypeStruct = enums(Object.values(CANCEL_TYPES));\nconst CryptoPaymentMethodErrorStruct = enums(\n Object.values(CRYPTO_PAYMENT_METHOD_ERRORS),\n);\n\nconst ProductStruct = type({\n name: ProductTypeStruct,\n currency: enums(['usd']),\n unitAmount: number(),\n unitDecimals: number(),\n});\n\nconst SubscriptionCardPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCard]),\n card: type({\n brand: string(),\n displayBrand: string(),\n last4: string(),\n }),\n});\n\nconst SubscriptionCryptoPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCrypto]),\n crypto: type({\n payerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n tokenSymbol: string(),\n error: optional(CryptoPaymentMethodErrorStruct),\n }),\n});\n\nconst SubscriptionPaymentMethodStruct = union([\n SubscriptionCardPaymentMethodStruct,\n SubscriptionCryptoPaymentMethodStruct,\n]);\n\nexport const SubscriptionStruct = type({\n id: string(),\n products: array(ProductStruct),\n currentPeriodStart: string(),\n currentPeriodEnd: string(),\n cancelAtPeriodEnd: optional(boolean()),\n status: SubscriptionStatusStruct,\n interval: RecurringIntervalStruct,\n paymentMethod: SubscriptionPaymentMethodStruct,\n trialPeriodDays: optional(number()),\n trialStart: optional(string()),\n trialEnd: optional(string()),\n endDate: optional(string()),\n canceledAt: optional(string()),\n cancelType: CancelTypeStruct,\n inactiveAt: optional(string()),\n isEligibleForSupport: boolean(),\n billingCycles: optional(number()),\n});\n\nexport const GetSubscriptionsResponseStruct = type({\n customerId: optional(string()),\n subscriptions: array(SubscriptionStruct),\n trialedProducts: array(ProductTypeStruct),\n lastSubscription: optional(SubscriptionStruct),\n rewardAccountId: optional(CaipAccountIdStruct),\n});\n\nexport const StartSubscriptionResponseStruct = type({\n checkoutSessionUrl: string(),\n});\n\nexport const StartCryptoSubscriptionResponseStruct = type({\n subscriptionId: string(),\n status: SubscriptionStatusStruct,\n});\n\nexport const UpdatePaymentMethodCardResponseStruct = type({\n redirectUrl: string(),\n});\n\nexport const BillingPortalResponseStruct = type({\n url: string(),\n});\n\nexport const SubscriptionApiGeneralResponseStruct = type({\n success: boolean(),\n message: optional(string()),\n});\n\nconst ProductPriceStruct = type({\n interval: RecurringIntervalStruct,\n unitAmount: number(),\n unitDecimals: number(),\n currency: enums(['usd']),\n trialPeriodDays: number(),\n minBillingCycles: number(),\n minBillingCyclesForBalance: number(),\n});\n\nconst ProductPricingStruct = type({\n name: ProductTypeStruct,\n prices: array(ProductPriceStruct),\n});\n\nconst TokenPaymentInfoStruct = type({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: type({\n usd: string(),\n }),\n});\n\nconst ChainPaymentInfoStruct = type({\n chainId: StrictHexStruct,\n paymentAddress: StrictHexStruct,\n tokens: array(TokenPaymentInfoStruct),\n isSponsorshipSupported: optional(boolean()),\n});\n\nconst PricingPaymentMethodStruct = type({\n type: PaymentTypeStruct,\n chains: optional(array(ChainPaymentInfoStruct)),\n});\n\nexport const PricingResponseStruct = type({\n products: array(ProductPricingStruct),\n paymentMethods: array(PricingPaymentMethodStruct),\n});\n\nconst CohortStruct = type({\n cohort: string(),\n eligibilityRate: number(),\n priority: number(),\n eligible: boolean(),\n});\n\nexport const SubscriptionEligibilityStruct = type({\n product: ProductTypeStruct,\n canSubscribe: optional(boolean()),\n canViewEntryModal: optional(boolean()),\n modalType: optional(enums(['A', 'B'])),\n cohorts: optional(array(CohortStruct)),\n assignedCohort: optional(nullable(string())),\n assignedAt: optional(string()),\n hasAssignedCohortExpired: optional(boolean()),\n});\n\nexport const SubscriptionEligibilityArrayStruct = array(\n SubscriptionEligibilityStruct,\n);\n"]}
1
+ {"version":3,"file":"SubscriptionService-structs.cjs","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":";;;AAAA,uDAa+B;AAE/B,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O,GAAE,CAAC;IACjC,iBAAiB,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IACtC,SAAS,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,YAAY,CAAC,CAAC;IACtC,cAAc,EAAE,IAAA,sBAAQ,EAAC,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC,CAAC;IAC5C,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC9B,wBAAwB,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;CAC9C,CAAC,CAAC;AAEU,QAAA,kCAAkC,GAAG,IAAA,mBAAK,EACrD,qCAA6B,CAC9B,CAAC","sourcesContent":["import {\n array,\n boolean,\n enums,\n lazy,\n literal,\n nullable,\n number,\n object,\n optional,\n string,\n type,\n union,\n} from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\nimport { StrictHexStruct, CaipAccountIdStruct } from '@metamask/utils';\n\nimport {\n CANCEL_TYPES,\n CRYPTO_AUTH_METHODS,\n CRYPTO_PAYMENT_METHOD_ERRORS,\n PAYMENT_TYPES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n SUBSCRIPTION_STATUSES,\n} from './types.js';\nimport type { TokenPaymentInfo } from './types.js';\n\nconst ProductTypeStruct = enums(Object.values(PRODUCT_TYPES));\nconst CryptoAuthMethodStruct = enums(Object.values(CRYPTO_AUTH_METHODS));\nconst RecurringIntervalStruct = enums(Object.values(RECURRING_INTERVALS));\nconst SubscriptionStatusStruct = enums(Object.values(SUBSCRIPTION_STATUSES));\nconst CancelTypeStruct = enums(Object.values(CANCEL_TYPES));\nconst CryptoPaymentMethodErrorStruct = enums(\n Object.values(CRYPTO_PAYMENT_METHOD_ERRORS),\n);\n\nconst ProductStruct = type({\n name: ProductTypeStruct,\n currency: enums(['usd']),\n unitAmount: number(),\n unitDecimals: number(),\n});\n\nconst SubscriptionCardPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCard]),\n card: type({\n brand: string(),\n displayBrand: string(),\n last4: string(),\n }),\n});\n\nconst SubscriptionCryptoPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCrypto]),\n crypto: type({\n payerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n tokenSymbol: string(),\n error: optional(CryptoPaymentMethodErrorStruct),\n }),\n});\n\nconst SubscriptionPaymentMethodStruct = union([\n SubscriptionCardPaymentMethodStruct,\n SubscriptionCryptoPaymentMethodStruct,\n]);\n\nexport const SubscriptionStruct = type({\n id: string(),\n products: array(ProductStruct),\n currentPeriodStart: string(),\n currentPeriodEnd: string(),\n cancelAtPeriodEnd: optional(boolean()),\n status: SubscriptionStatusStruct,\n interval: RecurringIntervalStruct,\n paymentMethod: SubscriptionPaymentMethodStruct,\n trialPeriodDays: optional(number()),\n trialStart: optional(string()),\n trialEnd: optional(string()),\n endDate: optional(string()),\n canceledAt: optional(string()),\n cancelType: CancelTypeStruct,\n inactiveAt: optional(string()),\n isEligibleForSupport: boolean(),\n billingCycles: optional(number()),\n});\n\nexport const GetSubscriptionsResponseStruct = type({\n customerId: optional(string()),\n subscriptions: array(SubscriptionStruct),\n trialedProducts: array(ProductTypeStruct),\n lastSubscription: optional(SubscriptionStruct),\n rewardAccountId: optional(CaipAccountIdStruct),\n});\n\nexport const StartSubscriptionResponseStruct = type({\n checkoutSessionUrl: string(),\n});\n\nexport const StartCryptoSubscriptionResponseStruct = type({\n subscriptionId: string(),\n status: SubscriptionStatusStruct,\n});\n\nexport const UpdatePaymentMethodCardResponseStruct = type({\n redirectUrl: string(),\n});\n\nexport const BillingPortalResponseStruct = type({\n url: string(),\n});\n\nexport const SubscriptionApiGeneralResponseStruct = type({\n success: boolean(),\n message: optional(string()),\n});\n\nconst ProductPriceStruct = type({\n interval: RecurringIntervalStruct,\n unitAmount: number(),\n unitDecimals: number(),\n currency: enums(['usd']),\n trialPeriodDays: number(),\n minBillingCycles: number(),\n minBillingCyclesForBalance: number(),\n});\n\nconst ProductPricingStruct = type({\n name: ProductTypeStruct,\n prices: array(ProductPriceStruct),\n});\n\nconst TokenPaymentInfoConversionRateStruct = type({\n usd: string(),\n});\n\nconst TokenPaymentInfoStruct: Struct<TokenPaymentInfo> = lazy(() =>\n union([\n object({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: optional(TokenPaymentInfoConversionRateStruct),\n isVaultShare: literal(true),\n accountantAddress: StrictHexStruct,\n sources: optional(array(TokenPaymentInfoStruct)),\n }),\n object({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: optional(TokenPaymentInfoConversionRateStruct),\n isVaultShare: optional(literal(false)),\n sources: optional(array(TokenPaymentInfoStruct)),\n }),\n ]),\n) as Struct<TokenPaymentInfo>;\n\nconst ChainPaymentInfoStruct = type({\n chainId: StrictHexStruct,\n paymentAddress: StrictHexStruct,\n delegateAddress: optional(StrictHexStruct),\n tokens: array(TokenPaymentInfoStruct),\n isSponsorshipSupported: optional(boolean()),\n});\n\nconst PricingPaymentMethodStruct = union([\n object({\n type: enums([PAYMENT_TYPES.byCard]),\n products: optional(array(ProductTypeStruct)),\n }),\n object({\n type: enums([PAYMENT_TYPES.byCrypto]),\n cryptoAuthMethod: optional(CryptoAuthMethodStruct),\n products: optional(array(ProductTypeStruct)),\n chains: optional(array(ChainPaymentInfoStruct)),\n }),\n]);\n\nexport const PricingResponseStruct = type({\n products: array(ProductPricingStruct),\n paymentMethods: array(PricingPaymentMethodStruct),\n});\n\nconst CohortStruct = type({\n cohort: string(),\n eligibilityRate: number(),\n priority: number(),\n eligible: boolean(),\n});\n\nexport const SubscriptionEligibilityStruct = type({\n product: ProductTypeStruct,\n canSubscribe: optional(boolean()),\n canViewEntryModal: optional(boolean()),\n modalType: optional(enums(['A', 'B'])),\n cohorts: optional(array(CohortStruct)),\n assignedCohort: optional(nullable(string())),\n assignedAt: optional(string()),\n hasAssignedCohortExpired: optional(boolean()),\n});\n\nexport const SubscriptionEligibilityArrayStruct = array(\n SubscriptionEligibilityStruct,\n);\n"]}