@metamask/subscription-controller 8.0.1 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/dist/{SubscriptionController-method-action-types.d.mts → SubscriptionController-method-action-types.d.ts} +14 -3
  3. package/dist/SubscriptionController-method-action-types.d.ts.map +1 -0
  4. package/dist/{SubscriptionController-method-action-types.mjs → SubscriptionController-method-action-types.js} +1 -1
  5. package/dist/SubscriptionController-method-action-types.js.map +1 -0
  6. package/dist/{SubscriptionController.d.mts → SubscriptionController.d.ts} +29 -19
  7. package/dist/SubscriptionController.d.ts.map +1 -0
  8. package/dist/{SubscriptionController.mjs → SubscriptionController.js} +391 -190
  9. package/dist/SubscriptionController.js.map +1 -0
  10. package/dist/{SubscriptionService-method-action-types.d.mts → SubscriptionService-method-action-types.d.ts} +12 -3
  11. package/dist/SubscriptionService-method-action-types.d.ts.map +1 -0
  12. package/dist/{SubscriptionService-method-action-types.mjs → SubscriptionService-method-action-types.js} +1 -1
  13. package/dist/SubscriptionService-method-action-types.js.map +1 -0
  14. package/dist/{SubscriptionService-structs.d.mts → SubscriptionService-structs.d.ts} +302 -134
  15. package/dist/SubscriptionService-structs.d.ts.map +1 -0
  16. package/dist/{SubscriptionService-structs.mjs → SubscriptionService-structs.js} +55 -4
  17. package/dist/SubscriptionService-structs.js.map +1 -0
  18. package/dist/{SubscriptionService.d.cts → SubscriptionService.d.ts} +16 -10
  19. package/dist/SubscriptionService.d.ts.map +1 -0
  20. package/dist/{SubscriptionService.mjs → SubscriptionService.js} +159 -141
  21. package/dist/SubscriptionService.js.map +1 -0
  22. package/dist/{constants.d.cts → constants.d.ts} +2 -1
  23. package/dist/constants.d.ts.map +1 -0
  24. package/dist/{constants.mjs → constants.js} +4 -3
  25. package/dist/constants.js.map +1 -0
  26. package/dist/{errors.d.cts → errors.d.ts} +2 -2
  27. package/dist/errors.d.ts.map +1 -0
  28. package/dist/{errors.mjs → errors.js} +5 -1
  29. package/dist/errors.js.map +1 -0
  30. package/dist/index.d.ts +12 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +7 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/logger.d.ts +4 -0
  35. package/dist/logger.d.ts.map +1 -0
  36. package/dist/logger.js +5 -0
  37. package/dist/logger.js.map +1 -0
  38. package/dist/selectors.d.ts +38 -0
  39. package/dist/selectors.d.ts.map +1 -0
  40. package/dist/selectors.js +46 -0
  41. package/dist/selectors.js.map +1 -0
  42. package/dist/{types.d.mts → types.d.ts} +112 -41
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/{types.mjs → types.js} +11 -1
  45. package/dist/types.js.map +1 -0
  46. package/package.json +22 -25
  47. package/dist/SubscriptionController-method-action-types.cjs +0 -7
  48. package/dist/SubscriptionController-method-action-types.cjs.map +0 -1
  49. package/dist/SubscriptionController-method-action-types.d.cts +0 -250
  50. package/dist/SubscriptionController-method-action-types.d.cts.map +0 -1
  51. package/dist/SubscriptionController-method-action-types.d.mts.map +0 -1
  52. package/dist/SubscriptionController-method-action-types.mjs.map +0 -1
  53. package/dist/SubscriptionController.cjs +0 -744
  54. package/dist/SubscriptionController.cjs.map +0 -1
  55. package/dist/SubscriptionController.d.cts +0 -258
  56. package/dist/SubscriptionController.d.cts.map +0 -1
  57. package/dist/SubscriptionController.d.mts.map +0 -1
  58. package/dist/SubscriptionController.mjs.map +0 -1
  59. package/dist/SubscriptionService-method-action-types.cjs +0 -7
  60. package/dist/SubscriptionService-method-action-types.cjs.map +0 -1
  61. package/dist/SubscriptionService-method-action-types.d.cts +0 -155
  62. package/dist/SubscriptionService-method-action-types.d.cts.map +0 -1
  63. package/dist/SubscriptionService-method-action-types.d.mts.map +0 -1
  64. package/dist/SubscriptionService-method-action-types.mjs.map +0 -1
  65. package/dist/SubscriptionService-structs.cjs +0 -158
  66. package/dist/SubscriptionService-structs.cjs.map +0 -1
  67. package/dist/SubscriptionService-structs.d.cts +0 -721
  68. package/dist/SubscriptionService-structs.d.cts.map +0 -1
  69. package/dist/SubscriptionService-structs.d.mts.map +0 -1
  70. package/dist/SubscriptionService-structs.mjs.map +0 -1
  71. package/dist/SubscriptionService.cjs +0 -477
  72. package/dist/SubscriptionService.cjs.map +0 -1
  73. package/dist/SubscriptionService.d.cts.map +0 -1
  74. package/dist/SubscriptionService.d.mts +0 -149
  75. package/dist/SubscriptionService.d.mts.map +0 -1
  76. package/dist/SubscriptionService.mjs.map +0 -1
  77. package/dist/constants.cjs +0 -73
  78. package/dist/constants.cjs.map +0 -1
  79. package/dist/constants.d.cts.map +0 -1
  80. package/dist/constants.d.mts +0 -49
  81. package/dist/constants.d.mts.map +0 -1
  82. package/dist/constants.mjs.map +0 -1
  83. package/dist/errors.cjs +0 -72
  84. package/dist/errors.cjs.map +0 -1
  85. package/dist/errors.d.cts.map +0 -1
  86. package/dist/errors.d.mts +0 -34
  87. package/dist/errors.d.mts.map +0 -1
  88. package/dist/errors.mjs.map +0 -1
  89. package/dist/index.cjs +0 -29
  90. package/dist/index.cjs.map +0 -1
  91. package/dist/index.d.cts +0 -11
  92. package/dist/index.d.cts.map +0 -1
  93. package/dist/index.d.mts +0 -11
  94. package/dist/index.d.mts.map +0 -1
  95. package/dist/index.mjs +0 -6
  96. package/dist/index.mjs.map +0 -1
  97. package/dist/logger.cjs +0 -8
  98. package/dist/logger.cjs.map +0 -1
  99. package/dist/logger.d.cts +0 -5
  100. package/dist/logger.d.cts.map +0 -1
  101. package/dist/logger.d.mts +0 -5
  102. package/dist/logger.d.mts.map +0 -1
  103. package/dist/logger.mjs +0 -5
  104. package/dist/logger.mjs.map +0 -1
  105. package/dist/types.cjs +0 -90
  106. package/dist/types.cjs.map +0 -1
  107. package/dist/types.d.cts +0 -574
  108. package/dist/types.d.cts.map +0 -1
  109. package/dist/types.d.mts.map +0 -1
  110. package/dist/types.mjs.map +0 -1
@@ -1,155 +0,0 @@
1
- /**
2
- * This file is auto generated.
3
- * Do not edit manually.
4
- */
5
- import type { SubscriptionService } from "./SubscriptionService.cjs";
6
- /**
7
- * Fetches the user's subscriptions.
8
- *
9
- * @returns The subscriptions response.
10
- */
11
- export type SubscriptionServiceGetSubscriptionsAction = {
12
- type: `SubscriptionService:getSubscriptions`;
13
- handler: SubscriptionService['getSubscriptions'];
14
- };
15
- /**
16
- * Cancels a subscription.
17
- *
18
- * @param params - The cancel subscription request.
19
- * @returns The updated subscription.
20
- */
21
- export type SubscriptionServiceCancelSubscriptionAction = {
22
- type: `SubscriptionService:cancelSubscription`;
23
- handler: SubscriptionService['cancelSubscription'];
24
- };
25
- /**
26
- * Reverses a pending subscription cancellation.
27
- *
28
- * @param params - The uncancel subscription request.
29
- * @param params.subscriptionId - The subscription ID to uncancel.
30
- * @returns The updated subscription.
31
- */
32
- export type SubscriptionServiceUnCancelSubscriptionAction = {
33
- type: `SubscriptionService:unCancelSubscription`;
34
- handler: SubscriptionService['unCancelSubscription'];
35
- };
36
- /**
37
- * Starts a card-paid subscription checkout session for the requested products
38
- * (e.g. Shield or Money Account Plus).
39
- *
40
- * @param request - The start subscription request.
41
- * @returns The checkout session response.
42
- */
43
- export type SubscriptionServiceStartSubscriptionWithCardAction = {
44
- type: `SubscriptionService:startSubscriptionWithCard`;
45
- handler: SubscriptionService['startSubscriptionWithCard'];
46
- };
47
- /**
48
- * Starts a subscription with a crypto payment method.
49
- *
50
- * @param request - The start crypto subscription request.
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).
55
- */
56
- export type SubscriptionServiceStartSubscriptionWithCryptoAction = {
57
- type: `SubscriptionService:startSubscriptionWithCrypto`;
58
- handler: SubscriptionService['startSubscriptionWithCrypto'];
59
- };
60
- /**
61
- * Updates a subscription's card payment method.
62
- *
63
- * @param request - The update payment method request.
64
- * @returns The redirect URL response.
65
- */
66
- export type SubscriptionServiceUpdatePaymentMethodCardAction = {
67
- type: `SubscriptionService:updatePaymentMethodCard`;
68
- handler: SubscriptionService['updatePaymentMethodCard'];
69
- };
70
- /**
71
- * Updates a subscription's crypto payment method.
72
- *
73
- * @param request - The update payment method request.
74
- */
75
- export type SubscriptionServiceUpdatePaymentMethodCryptoAction = {
76
- type: `SubscriptionService:updatePaymentMethodCrypto`;
77
- handler: SubscriptionService['updatePaymentMethodCrypto'];
78
- };
79
- /**
80
- * Get the eligibility for a shield subscription.
81
- *
82
- * @param request - Optional request object containing user balance category to check cohort eligibility
83
- * @returns The eligibility for a shield subscription
84
- */
85
- export type SubscriptionServiceGetSubscriptionsEligibilitiesAction = {
86
- type: `SubscriptionService:getSubscriptionsEligibilities`;
87
- handler: SubscriptionService['getSubscriptionsEligibilities'];
88
- };
89
- /**
90
- * Submit a user event. (e.g. shield modal viewed)
91
- *
92
- * @param request - Request object containing the event to submit.
93
- * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }
94
- */
95
- export type SubscriptionServiceSubmitUserEventAction = {
96
- type: `SubscriptionService:submitUserEvent`;
97
- handler: SubscriptionService['submitUserEvent'];
98
- };
99
- /**
100
- * Assign user to a cohort.
101
- *
102
- * @param request - Request object containing the cohort to assign the user to.
103
- * @example { cohort: 'post_tx' }
104
- */
105
- export type SubscriptionServiceAssignUserToCohortAction = {
106
- type: `SubscriptionService:assignUserToCohort`;
107
- handler: SubscriptionService['assignUserToCohort'];
108
- };
109
- /**
110
- * Submit sponsorship intents to the Subscription Service backend.
111
- *
112
- * This is intended to be used together with the crypto subscription flow.
113
- * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.
114
- *
115
- * @param request - Request object containing the address and products.
116
- * @example { address: '0x1234567890123456789012345678901234567890', products: [ProductType.Shield] }
117
- */
118
- export type SubscriptionServiceSubmitSponsorshipIntentsAction = {
119
- type: `SubscriptionService:submitSponsorshipIntents`;
120
- handler: SubscriptionService['submitSponsorshipIntents'];
121
- };
122
- /**
123
- * Link rewards to a subscription.
124
- *
125
- * @param request - Request object containing the reward account ID.
126
- * @example { rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }
127
- * @returns The response from the API.
128
- */
129
- export type SubscriptionServiceLinkRewardsAction = {
130
- type: `SubscriptionService:linkRewards`;
131
- handler: SubscriptionService['linkRewards'];
132
- };
133
- /**
134
- * Fetches subscription pricing information.
135
- *
136
- * @returns The pricing response.
137
- */
138
- export type SubscriptionServiceGetPricingAction = {
139
- type: `SubscriptionService:getPricing`;
140
- handler: SubscriptionService['getPricing'];
141
- };
142
- /**
143
- * Fetches the billing portal URL.
144
- *
145
- * @returns The billing portal response.
146
- */
147
- export type SubscriptionServiceGetBillingPortalUrlAction = {
148
- type: `SubscriptionService:getBillingPortalUrl`;
149
- handler: SubscriptionService['getBillingPortalUrl'];
150
- };
151
- /**
152
- * Union of all SubscriptionService action types.
153
- */
154
- export type SubscriptionServiceMethodActions = SubscriptionServiceGetSubscriptionsAction | SubscriptionServiceCancelSubscriptionAction | SubscriptionServiceUnCancelSubscriptionAction | SubscriptionServiceStartSubscriptionWithCardAction | SubscriptionServiceStartSubscriptionWithCryptoAction | SubscriptionServiceUpdatePaymentMethodCardAction | SubscriptionServiceUpdatePaymentMethodCryptoAction | SubscriptionServiceGetSubscriptionsEligibilitiesAction | SubscriptionServiceSubmitUserEventAction | SubscriptionServiceAssignUserToCohortAction | SubscriptionServiceSubmitSponsorshipIntentsAction | SubscriptionServiceLinkRewardsAction | SubscriptionServiceGetPricingAction | SubscriptionServiceGetBillingPortalUrlAction;
155
- //# sourceMappingURL=SubscriptionService-method-action-types.d.cts.map
@@ -1 +0,0 @@
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,yCAAy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AAO,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;CACjD,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;;;;;;;;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 +0,0 @@
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;AAC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AAqC,CAAC;IAC5C,OAAO,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;CACjD,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;;;;;;;;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 +0,0 @@
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"]}
@@ -1,158 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubscriptionEligibilityArrayStruct = exports.SubscriptionEligibilityStruct = exports.PricingResponseStruct = exports.SubscriptionApiGeneralResponseStruct = exports.BillingPortalResponseStruct = exports.UpdatePaymentMethodCardResponseStruct = exports.StartCryptoSubscriptionResponseStruct = exports.StartSubscriptionResponseStruct = exports.GetSubscriptionsResponseStruct = exports.SubscriptionStruct = void 0;
4
- const superstruct_1 = require("@metamask/superstruct");
5
- const utils_1 = require("@metamask/utils");
6
- const types_js_1 = require("./types.cjs");
7
- const ProductTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.PRODUCT_TYPES));
8
- const CryptoAuthMethodStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CRYPTO_AUTH_METHODS));
9
- const RecurringIntervalStruct = (0, superstruct_1.enums)(Object.values(types_js_1.RECURRING_INTERVALS));
10
- const SubscriptionStatusStruct = (0, superstruct_1.enums)(Object.values(types_js_1.SUBSCRIPTION_STATUSES));
11
- const CancelTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CANCEL_TYPES));
12
- const CryptoPaymentMethodErrorStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CRYPTO_PAYMENT_METHOD_ERRORS));
13
- const ProductStruct = (0, superstruct_1.type)({
14
- name: ProductTypeStruct,
15
- currency: (0, superstruct_1.enums)(['usd']),
16
- unitAmount: (0, superstruct_1.number)(),
17
- unitDecimals: (0, superstruct_1.number)(),
18
- });
19
- const SubscriptionCardPaymentMethodStruct = (0, superstruct_1.type)({
20
- type: (0, superstruct_1.enums)([types_js_1.PAYMENT_TYPES.byCard]),
21
- card: (0, superstruct_1.type)({
22
- brand: (0, superstruct_1.string)(),
23
- displayBrand: (0, superstruct_1.string)(),
24
- last4: (0, superstruct_1.string)(),
25
- }),
26
- });
27
- const SubscriptionCryptoPaymentMethodStruct = (0, superstruct_1.type)({
28
- type: (0, superstruct_1.enums)([types_js_1.PAYMENT_TYPES.byCrypto]),
29
- crypto: (0, superstruct_1.type)({
30
- payerAddress: utils_1.StrictHexStruct,
31
- chainId: utils_1.StrictHexStruct,
32
- tokenSymbol: (0, superstruct_1.string)(),
33
- error: (0, superstruct_1.optional)(CryptoPaymentMethodErrorStruct),
34
- }),
35
- });
36
- const SubscriptionPaymentMethodStruct = (0, superstruct_1.union)([
37
- SubscriptionCardPaymentMethodStruct,
38
- SubscriptionCryptoPaymentMethodStruct,
39
- ]);
40
- exports.SubscriptionStruct = (0, superstruct_1.type)({
41
- id: (0, superstruct_1.string)(),
42
- products: (0, superstruct_1.array)(ProductStruct),
43
- currentPeriodStart: (0, superstruct_1.string)(),
44
- currentPeriodEnd: (0, superstruct_1.string)(),
45
- cancelAtPeriodEnd: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
46
- status: SubscriptionStatusStruct,
47
- interval: RecurringIntervalStruct,
48
- paymentMethod: SubscriptionPaymentMethodStruct,
49
- trialPeriodDays: (0, superstruct_1.optional)((0, superstruct_1.number)()),
50
- trialStart: (0, superstruct_1.optional)((0, superstruct_1.string)()),
51
- trialEnd: (0, superstruct_1.optional)((0, superstruct_1.string)()),
52
- endDate: (0, superstruct_1.optional)((0, superstruct_1.string)()),
53
- canceledAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
54
- cancelType: CancelTypeStruct,
55
- inactiveAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
56
- isEligibleForSupport: (0, superstruct_1.boolean)(),
57
- billingCycles: (0, superstruct_1.optional)((0, superstruct_1.number)()),
58
- });
59
- exports.GetSubscriptionsResponseStruct = (0, superstruct_1.type)({
60
- customerId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
61
- subscriptions: (0, superstruct_1.array)(exports.SubscriptionStruct),
62
- trialedProducts: (0, superstruct_1.array)(ProductTypeStruct),
63
- lastSubscription: (0, superstruct_1.optional)(exports.SubscriptionStruct),
64
- rewardAccountId: (0, superstruct_1.optional)(utils_1.CaipAccountIdStruct),
65
- });
66
- exports.StartSubscriptionResponseStruct = (0, superstruct_1.type)({
67
- checkoutSessionUrl: (0, superstruct_1.string)(),
68
- });
69
- exports.StartCryptoSubscriptionResponseStruct = (0, superstruct_1.type)({
70
- subscriptionId: (0, superstruct_1.string)(),
71
- status: SubscriptionStatusStruct,
72
- });
73
- exports.UpdatePaymentMethodCardResponseStruct = (0, superstruct_1.type)({
74
- redirectUrl: (0, superstruct_1.string)(),
75
- });
76
- exports.BillingPortalResponseStruct = (0, superstruct_1.type)({
77
- url: (0, superstruct_1.string)(),
78
- });
79
- exports.SubscriptionApiGeneralResponseStruct = (0, superstruct_1.type)({
80
- success: (0, superstruct_1.boolean)(),
81
- message: (0, superstruct_1.optional)((0, superstruct_1.string)()),
82
- });
83
- const ProductPriceStruct = (0, superstruct_1.type)({
84
- interval: RecurringIntervalStruct,
85
- unitAmount: (0, superstruct_1.number)(),
86
- unitDecimals: (0, superstruct_1.number)(),
87
- currency: (0, superstruct_1.enums)(['usd']),
88
- trialPeriodDays: (0, superstruct_1.number)(),
89
- minBillingCycles: (0, superstruct_1.number)(),
90
- minBillingCyclesForBalance: (0, superstruct_1.number)(),
91
- });
92
- const ProductPricingStruct = (0, superstruct_1.type)({
93
- name: ProductTypeStruct,
94
- prices: (0, superstruct_1.array)(ProductPriceStruct),
95
- });
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)),
108
- }),
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
- ]));
118
- const ChainPaymentInfoStruct = (0, superstruct_1.type)({
119
- chainId: utils_1.StrictHexStruct,
120
- paymentAddress: utils_1.StrictHexStruct,
121
- delegateAddress: (0, superstruct_1.optional)(utils_1.StrictHexStruct),
122
- tokens: (0, superstruct_1.array)(TokenPaymentInfoStruct),
123
- isSponsorshipSupported: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
124
- });
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
- ]);
137
- exports.PricingResponseStruct = (0, superstruct_1.type)({
138
- products: (0, superstruct_1.array)(ProductPricingStruct),
139
- paymentMethods: (0, superstruct_1.array)(PricingPaymentMethodStruct),
140
- });
141
- const CohortStruct = (0, superstruct_1.type)({
142
- cohort: (0, superstruct_1.string)(),
143
- eligibilityRate: (0, superstruct_1.number)(),
144
- priority: (0, superstruct_1.number)(),
145
- eligible: (0, superstruct_1.boolean)(),
146
- });
147
- exports.SubscriptionEligibilityStruct = (0, superstruct_1.type)({
148
- product: ProductTypeStruct,
149
- canSubscribe: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
150
- canViewEntryModal: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
151
- modalType: (0, superstruct_1.optional)((0, superstruct_1.enums)(['A', 'B'])),
152
- cohorts: (0, superstruct_1.optional)((0, superstruct_1.array)(CohortStruct)),
153
- assignedCohort: (0, superstruct_1.optional)((0, superstruct_1.nullable)((0, superstruct_1.string)())),
154
- assignedAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
155
- hasAssignedCohortExpired: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
156
- });
157
- exports.SubscriptionEligibilityArrayStruct = (0, superstruct_1.array)(exports.SubscriptionEligibilityStruct);
158
- //# sourceMappingURL=SubscriptionService-structs.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Subsc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BAAI,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 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"]}