@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
@@ -0,0 +1 @@
1
+ {"version":3,"file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AC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK;gBACpB,CAAC,CAAC,KAAK,CAAC,OAAO;gBACf,CAAC,CAAC,iDAAiD,CAAC;YACxD,IAAI,CAAC,iBAAiB,EAAE,CACtB,iBAAiB,CACf,uCAAuC,YAAY,EAAE,EACrD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CACzD,CACF,CAAC;YAEF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport { BaseDataService } from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { handleWhen, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport { create } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport {\n Env,\n getEnvUrls,\n SubscriptionControllerErrorMessage,\n SubscriptionServiceErrorMessage,\n} from './constants.js';\nimport {\n createSentryError,\n getSubscriptionErrorFromResponse,\n SubscriptionServiceError,\n} from './errors.js';\nimport { createModuleLogger, projectLogger } from './logger.js';\nimport type { SubscriptionServiceMethodActions } from './SubscriptionService-method-action-types.js';\nimport {\n BillingPortalResponseStruct,\n GetSubscriptionsResponseStruct,\n PricingResponseStruct,\n StartCryptoSubscriptionResponseStruct,\n StartSubscriptionResponseStruct,\n SubscriptionApiGeneralResponseStruct,\n SubscriptionBenefitsResponseStruct,\n SubscriptionEligibilityArrayStruct,\n SubscriptionStruct,\n UpdatePaymentMethodCardResponseStruct,\n} from './SubscriptionService-structs.js';\nimport { CRYPTO_AUTH_METHODS } from './types.js';\nimport type {\n AssignCohortRequest,\n BillingPortalResponse,\n CancelSubscriptionRequest,\n GetSubscriptionsEligibilitiesRequest,\n GetSubscriptionsResponse,\n LinkRewardsRequest,\n PricingResponse,\n StartCryptoSubscriptionRequest,\n StartCryptoSubscriptionResponse,\n StartSubscriptionRequest,\n StartSubscriptionResponse,\n SubmitSponsorshipIntentsRequest,\n SubmitUserEventRequest,\n Subscription,\n SubscriptionApiGeneralResponse,\n SubscriptionBenefitsResponse,\n SubscriptionEligibility,\n UpdatePaymentMethodCardRequest,\n UpdatePaymentMethodCardResponse,\n UpdatePaymentMethodCryptoRequest,\n} from './types.js';\n\nexport const serviceName = 'SubscriptionService';\n\nexport const SUBSCRIPTION_URL = (env: Env, path: string): string =>\n `${getEnvUrls(env).subscriptionApiUrl}/v1/${path}`;\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getSubscriptions',\n 'getBenefits',\n 'cancelSubscription',\n 'unCancelSubscription',\n 'startSubscriptionWithCard',\n 'startSubscriptionWithCrypto',\n 'updatePaymentMethodCard',\n 'updatePaymentMethodCrypto',\n 'getSubscriptionsEligibilities',\n 'submitUserEvent',\n 'assignUserToCohort',\n 'submitSponsorshipIntents',\n 'linkRewards',\n 'getPricing',\n 'getBillingPortalUrl',\n] as const;\n\nexport type SubscriptionServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\nexport type SubscriptionServiceActions =\n | SubscriptionServiceMethodActions\n | SubscriptionServiceInvalidateQueriesAction;\n\ntype AllowedActions =\n | AuthenticationController.AuthenticationControllerGetBearerTokenAction\n | AuthenticationController.AuthenticationControllerGetSessionProfileAction;\n\ntype AllowedEvents = never;\n\nexport type SubscriptionServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof serviceName\n>;\n\nexport type SubscriptionServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\nexport type SubscriptionServiceEvents =\n | SubscriptionServiceCacheUpdatedEvent\n | SubscriptionServiceGranularCacheUpdatedEvent;\n\nexport type SubscriptionServiceMessenger = Messenger<\n typeof serviceName,\n SubscriptionServiceActions | AllowedActions,\n SubscriptionServiceEvents | AllowedEvents\n>;\n\nexport type SubscriptionServiceOptions = {\n messenger: SubscriptionServiceMessenger;\n /**\n * The `fetch` function to use for requests. Defaults to the global `fetch`.\n */\n fetchFunction?: typeof fetch;\n env?: Env;\n captureException?: (error: Error) => void;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n};\n\nconst log = createModuleLogger(projectLogger, 'SubscriptionService');\n\nfunction isRetryableError(error: unknown): boolean {\n if (error instanceof HttpError) {\n if (error.httpStatus === 429) {\n return true;\n }\n return error.httpStatus < 400 || error.httpStatus >= 500;\n }\n return true;\n}\n\nconst DEFAULT_POLICY_OPTIONS: CreateServicePolicyOptions = {\n retryFilterPolicy: handleWhen(isRetryableError),\n};\n\n/**\n * Data service for the Subscription API.\n *\n * All requests are authenticated via JWT Bearer tokens obtained from the\n * `AuthenticationController:getBearerToken` messenger action. Cached queries\n * are scoped by `profileId` from\n * `AuthenticationController:getSessionProfile`.\n */\nexport class SubscriptionService extends BaseDataService<\n typeof serviceName,\n SubscriptionServiceMessenger\n> {\n readonly #env: Env;\n\n readonly #fetch: typeof fetch;\n\n readonly #captureException?: (error: Error) => void;\n\n constructor({\n messenger,\n fetchFunction = globalThis.fetch,\n env = Env.PRD,\n captureException,\n queryClientConfig = {},\n policyOptions = {},\n }: SubscriptionServiceOptions) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions: { ...DEFAULT_POLICY_OPTIONS, ...policyOptions },\n });\n\n this.#env = env;\n this.#fetch = fetchFunction;\n this.#captureException = captureException;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches the user's subscriptions.\n *\n * @returns The subscriptions response.\n */\n async getSubscriptions(): Promise<GetSubscriptionsResponse> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'getSubscriptions',\n requestParams: null,\n path: 'subscriptions',\n errorMessage: SubscriptionServiceErrorMessage.FailedToGetSubscriptions,\n });\n\n return create(jsonResponse, GetSubscriptionsResponseStruct);\n }\n\n /**\n * Fetches the user's subscription benefits.\n *\n * @returns The benefits response.\n */\n async getBenefits(): Promise<SubscriptionBenefitsResponse> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'getBenefits',\n requestParams: null,\n path: 'benefits',\n method: 'POST',\n body: {},\n errorMessage: SubscriptionServiceErrorMessage.FailedToGetBenefits,\n });\n\n return create(jsonResponse, SubscriptionBenefitsResponseStruct);\n }\n\n /**\n * Cancels a subscription.\n *\n * @param params - The cancel subscription request.\n * @returns The updated subscription.\n */\n async cancelSubscription(\n params: CancelSubscriptionRequest,\n ): Promise<Subscription> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const path = `subscriptions/${params.subscriptionId}/cancel`;\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'cancelSubscription',\n requestParams: params,\n path,\n method: 'POST',\n body: {\n cancelAtPeriodEnd: params.cancelAtPeriodEnd,\n },\n errorMessage: SubscriptionServiceErrorMessage.FailedToCancelSubscription,\n });\n\n return create(jsonResponse, SubscriptionStruct);\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 */\n async unCancelSubscription(params: {\n subscriptionId: string;\n }): Promise<Subscription> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const path = `subscriptions/${params.subscriptionId}/uncancel`;\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'unCancelSubscription',\n requestParams: params,\n path,\n method: 'POST',\n body: {},\n errorMessage:\n SubscriptionServiceErrorMessage.FailedToUncancelSubscription,\n });\n\n return create(jsonResponse, SubscriptionStruct);\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 */\n async startSubscriptionWithCard(\n request: StartSubscriptionRequest,\n ): Promise<StartSubscriptionResponse> {\n if (request.products.length === 0) {\n throw new SubscriptionServiceError(\n SubscriptionControllerErrorMessage.SubscriptionProductsEmpty,\n );\n }\n\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'startSubscriptionWithCard',\n requestParams: request,\n path: 'subscriptions/card',\n method: 'POST',\n body: request,\n errorMessage:\n SubscriptionServiceErrorMessage.FailedToStartSubscriptionWithCard,\n });\n\n return create(jsonResponse, StartSubscriptionResponseStruct);\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 */\n async startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse> {\n if (request.products.length === 0) {\n throw new SubscriptionServiceError(\n SubscriptionControllerErrorMessage.SubscriptionProductsEmpty,\n );\n }\n\n this.#assertValidCryptoAuthCombo(request);\n\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'startSubscriptionWithCrypto',\n requestParams: request,\n path: 'subscriptions/crypto',\n method: 'POST',\n body: request,\n errorMessage:\n SubscriptionServiceErrorMessage.FailedToStartSubscriptionWithCrypto,\n });\n\n return create(jsonResponse, StartCryptoSubscriptionResponseStruct);\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 */\n async updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const path = `subscriptions/${request.subscriptionId}/payment-method/card`;\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'updatePaymentMethodCard',\n requestParams: request,\n path,\n method: 'PATCH',\n body: {\n ...request,\n subscriptionId: undefined,\n },\n errorMessage:\n SubscriptionServiceErrorMessage.FailedToUpdatePaymentMethodCard,\n });\n\n return create(jsonResponse, UpdatePaymentMethodCardResponseStruct);\n }\n\n /**\n * Updates a subscription's crypto payment method.\n *\n * @param request - The update payment method request.\n */\n async updatePaymentMethodCrypto(\n request: UpdatePaymentMethodCryptoRequest,\n ): Promise<void> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const path = `subscriptions/${request.subscriptionId}/payment-method/crypto`;\n await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'updatePaymentMethodCrypto',\n requestParams: request,\n path,\n method: 'PATCH',\n body: {\n ...request,\n subscriptionId: undefined,\n },\n errorMessage:\n SubscriptionServiceErrorMessage.FailedToUpdatePaymentMethodCrypto,\n });\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 */\n async getSubscriptionsEligibilities(\n request?: GetSubscriptionsEligibilitiesRequest,\n ): Promise<SubscriptionEligibility[]> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n let queryParams: Record<string, string> | undefined;\n if (request?.balanceCategory !== undefined) {\n queryParams = { balanceCategory: request.balanceCategory };\n }\n\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'getSubscriptionsEligibilities',\n requestParams: request ?? null,\n path: 'subscriptions/eligibility',\n queryParams,\n errorMessage:\n SubscriptionServiceErrorMessage.FailedToGetSubscriptionsEligibilities,\n });\n\n const results = create(jsonResponse, SubscriptionEligibilityArrayStruct);\n\n return results.map((result) => ({\n ...result,\n canSubscribe: result.canSubscribe ?? false,\n canViewEntryModal: result.canViewEntryModal ?? false,\n cohorts: result.cohorts ?? [],\n assignedCohort: result.assignedCohort ?? null,\n hasAssignedCohortExpired: result.hasAssignedCohortExpired ?? false,\n }));\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 */\n async submitUserEvent(request: SubmitUserEventRequest): Promise<void> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'submitUserEvent',\n requestParams: request,\n path: 'user-events',\n method: 'POST',\n body: request,\n errorMessage: SubscriptionServiceErrorMessage.FailedToSubmitUserEvent,\n });\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 */\n async assignUserToCohort(request: AssignCohortRequest): Promise<void> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'assignUserToCohort',\n requestParams: request,\n path: 'cohorts/assign',\n method: 'POST',\n body: request,\n errorMessage: SubscriptionServiceErrorMessage.FailedToAssignUserToCohort,\n });\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 */\n async submitSponsorshipIntents(\n request: SubmitSponsorshipIntentsRequest,\n ): Promise<void> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'submitSponsorshipIntents',\n requestParams: request,\n path: 'transaction-sponsorship/intents',\n method: 'POST',\n body: request,\n errorMessage:\n SubscriptionServiceErrorMessage.FailedToSubmitSponsorshipIntents,\n });\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 */\n async linkRewards(\n request: LinkRewardsRequest,\n ): Promise<SubscriptionApiGeneralResponse> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'linkRewards',\n requestParams: request,\n path: 'rewards/link',\n method: 'POST',\n body: request,\n errorMessage: SubscriptionServiceErrorMessage.FailedToLinkRewards,\n });\n\n return create(jsonResponse, SubscriptionApiGeneralResponseStruct);\n }\n\n /**\n * Fetches subscription pricing information.\n *\n * @returns The pricing response.\n */\n async getPricing(): Promise<PricingResponse> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'getPricing',\n requestParams: null,\n path: 'pricing',\n errorMessage: SubscriptionServiceErrorMessage.FailedToGetPricing,\n });\n\n return create(jsonResponse, PricingResponseStruct);\n }\n\n /**\n * Fetches the billing portal URL.\n *\n * @returns The billing portal response.\n */\n async getBillingPortalUrl(): Promise<BillingPortalResponse> {\n const { profileKey, bearerToken } = await this.#getAuthenticatedContext();\n const jsonResponse = await this.#fetchJson({\n profileKey,\n bearerToken,\n methodName: 'getBillingPortalUrl',\n requestParams: null,\n path: 'billing-portal',\n errorMessage: SubscriptionServiceErrorMessage.FailedToGetBillingPortalUrl,\n });\n\n return create(jsonResponse, BillingPortalResponseStruct);\n }\n\n async #fetchJson({\n profileKey,\n bearerToken,\n methodName,\n requestParams,\n path,\n method = 'GET',\n body,\n queryParams,\n errorMessage,\n }: {\n profileKey: string;\n bearerToken: string;\n methodName: string;\n requestParams: unknown;\n path: string;\n method?: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH';\n body?: Record<string, unknown>;\n queryParams?: Record<string, string>;\n errorMessage: string;\n }): Promise<unknown> {\n const url = this.#getSubscriptionApiUrl(path);\n\n if (queryParams) {\n Object.entries(queryParams).forEach(([key, value]) => {\n url.searchParams.append(key, value);\n });\n }\n\n try {\n return await this.fetchQuery({\n queryKey: [\n `${this.name}:${methodName}`,\n profileKey,\n requestParams as Json,\n ],\n staleTime: 0,\n gcTime: 0,\n queryFn: async () => {\n const response = await this.#fetch(url.toString(), {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...this.#headersForToken(bearerToken),\n },\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const apiError = await getSubscriptionErrorFromResponse(response);\n throw new HttpError(response.status, apiError.message);\n }\n\n return response.json();\n },\n });\n } catch (error) {\n log(errorMessage, error);\n\n const errorMessageWithUrl = `${errorMessage} (url: ${url.toString()})`;\n const errorToCapture =\n error instanceof Error ? error : new Error(errorMessage);\n this.#captureException?.(\n createSentryError(errorMessageWithUrl, errorToCapture),\n );\n\n if (error instanceof SubscriptionServiceError) {\n throw error;\n }\n\n throw new SubscriptionServiceError(\n `Failed to make request. ${errorMessageWithUrl}`,\n {\n cause: errorToCapture,\n },\n );\n }\n }\n\n /**\n * Ensures the request uses exactly one crypto auth method: ERC-20 approval\n * (`rawTransaction`, default) or delegation (`delegationHash`).\n *\n * @param request - The start crypto subscription request.\n * @throws If both, neither, or a mismatched combo of auth fields is provided.\n */\n #assertValidCryptoAuthCombo(request: StartCryptoSubscriptionRequest): void {\n const method =\n request.cryptoAuthMethod ?? CRYPTO_AUTH_METHODS.ERC20_APPROVAL;\n const hasRawTransaction = Boolean(request.rawTransaction);\n const hasDelegationHash = Boolean(request.delegationHash);\n const isValidErc20Approval =\n method === CRYPTO_AUTH_METHODS.ERC20_APPROVAL &&\n hasRawTransaction &&\n !hasDelegationHash;\n const isValidDelegation =\n method === CRYPTO_AUTH_METHODS.DELEGATION &&\n hasDelegationHash &&\n !hasRawTransaction;\n\n if (!isValidErc20Approval && !isValidDelegation) {\n throw new SubscriptionServiceError(\n SubscriptionServiceErrorMessage.InvalidCryptoAuthCombo,\n );\n }\n }\n\n async #getAuthenticatedContext(): Promise<{\n profileKey: string;\n bearerToken: string;\n }> {\n try {\n const [bearerToken, sessionProfile] = await Promise.all([\n this.messenger.call('AuthenticationController:getBearerToken'),\n this.messenger.call('AuthenticationController:getSessionProfile'),\n ]);\n\n return { profileKey: sessionProfile.profileId, bearerToken };\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Unknown error when getting authorization header';\n\n this.#captureException?.(\n createSentryError(\n `Failed to get authorization header. ${errorMessage}`,\n error instanceof Error ? error : new Error(errorMessage),\n ),\n );\n\n throw new SubscriptionServiceError(\n `Failed to get authorization header. ${errorMessage}`,\n {\n cause: error instanceof Error ? error : new Error(errorMessage),\n },\n );\n }\n }\n\n #headersForToken(bearerToken: string): Record<string, string> {\n return { Authorization: `Bearer ${bearerToken}` };\n }\n\n #getSubscriptionApiUrl(path: string): URL {\n try {\n return new URL(SUBSCRIPTION_URL(this.#env, path));\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Unknown error when getting subscription API URL';\n this.#captureException?.(\n createSentryError(\n `Failed to get subscription API URL. ${errorMessage}`,\n error instanceof Error ? error : new Error(errorMessage),\n ),\n );\n\n throw error;\n }\n }\n}\n"]}
@@ -28,6 +28,7 @@ export declare enum SubscriptionControllerErrorMessage {
28
28
  }
29
29
  export declare enum SubscriptionServiceErrorMessage {
30
30
  FailedToGetSubscriptions = "Failed to get subscriptions",
31
+ FailedToGetBenefits = "Failed to get benefits",
31
32
  FailedToCancelSubscription = "Failed to cancel subscription",
32
33
  FailedToUncancelSubscription = "Failed to uncancel subscription",
33
34
  FailedToStartSubscriptionWithCard = "Failed to start subscription with card",
@@ -46,4 +47,4 @@ export declare enum SubscriptionServiceErrorMessage {
46
47
  export declare const DEFAULT_POLLING_INTERVAL: number;
47
48
  export declare const ACTIVE_SUBSCRIPTION_STATUSES: string[];
48
49
  export {};
49
- //# sourceMappingURL=constants.d.cts.map
50
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD,oBAAY,GAAG;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,KAAK,YAAY,GAAG;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAcF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,CAKjD;AAED,oBAAY,kCAAkC;IAC5C,qBAAqB,wDAAmD;IACxE,iBAAiB,oDAA+C;IAChE,yBAAyB,yEAAoE;IAC7F,6CAA6C,8FAAyF;IACtI,sBAAsB,0DAAqD;IAC3E,oBAAoB,qDAAgD;IACpE,qCAAqC,2EAAsE;IAC3G,mCAAmC,sGAAiG;IACpI,iBAAiB,oDAA+C;CACjE;AAED,oBAAY,+BAA+B;IACzC,wBAAwB,gCAAgC;IACxD,mBAAmB,2BAA2B;IAC9C,0BAA0B,kCAAkC;IAC5D,4BAA4B,oCAAoC;IAChE,iCAAiC,2CAA2C;IAC5E,mCAAmC,6CAA6C;IAChF,sBAAsB,+GAA+G;IACrI,+BAA+B,yCAAyC;IACxE,iCAAiC,2CAA2C;IAC5E,qCAAqC,8CAA8C;IACnF,uBAAuB,gCAAgC;IACvD,0BAA0B,oCAAoC;IAC9D,gCAAgC,yCAAyC;IACzE,mBAAmB,2BAA2B;IAC9C,kBAAkB,0BAA0B;IAC5C,2BAA2B,qCAAqC;CACjE;AAED,eAAO,MAAM,wBAAwB,QAAiB,CAAC;AAEvD,eAAO,MAAM,4BAA4B,EAIpC,MAAM,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { SUBSCRIPTION_STATUSES } from "./types.mjs";
1
+ import { SUBSCRIPTION_STATUSES } from './types.js';
2
2
  export const controllerName = 'SubscriptionController';
3
3
  export var Env;
4
4
  (function (Env) {
@@ -45,6 +45,7 @@ export var SubscriptionControllerErrorMessage;
45
45
  export var SubscriptionServiceErrorMessage;
46
46
  (function (SubscriptionServiceErrorMessage) {
47
47
  SubscriptionServiceErrorMessage["FailedToGetSubscriptions"] = "Failed to get subscriptions";
48
+ SubscriptionServiceErrorMessage["FailedToGetBenefits"] = "Failed to get benefits";
48
49
  SubscriptionServiceErrorMessage["FailedToCancelSubscription"] = "Failed to cancel subscription";
49
50
  SubscriptionServiceErrorMessage["FailedToUncancelSubscription"] = "Failed to uncancel subscription";
50
51
  SubscriptionServiceErrorMessage["FailedToStartSubscriptionWithCard"] = "Failed to start subscription with card";
@@ -60,10 +61,10 @@ export var SubscriptionServiceErrorMessage;
60
61
  SubscriptionServiceErrorMessage["FailedToGetPricing"] = "Failed to get pricing";
61
62
  SubscriptionServiceErrorMessage["FailedToGetBillingPortalUrl"] = "Failed to get billing portal url";
62
63
  })(SubscriptionServiceErrorMessage || (SubscriptionServiceErrorMessage = {}));
63
- export const DEFAULT_POLLING_INTERVAL = 5 * 60 * 1000; // 5 minutes
64
+ export const DEFAULT_POLLING_INTERVAL = 5 * 60 * 1_000; // 5 minutes
64
65
  export const ACTIVE_SUBSCRIPTION_STATUSES = [
65
66
  SUBSCRIPTION_STATUSES.active,
66
67
  SUBSCRIPTION_STATUSES.trialing,
67
68
  SUBSCRIPTION_STATUSES.provisional,
68
69
  ];
69
- //# sourceMappingURL=constants.mjs.map
70
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,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CAAA;IAC5C,mGAAgE,CAAA;AAClE,CAAC,EAjBW,+BAA+B,KAA/B,+BAA+B,QAiB1C;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,YAAY;AAEpE,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,qBAAqB,CAAC,MAAM;IAC5B,qBAAqB,CAAC,QAAQ;IAC9B,qBAAqB,CAAC,WAAW;CACtB,CAAC","sourcesContent":["import { SUBSCRIPTION_STATUSES } from './types.js';\n\nexport const controllerName = 'SubscriptionController';\n\nexport enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\ntype EnvUrlsEntry = {\n subscriptionApiUrl: string;\n};\n\nconst ENV_URLS: Record<Env, EnvUrlsEntry> = {\n dev: {\n subscriptionApiUrl: 'https://subscription.dev-api.cx.metamask.io',\n },\n uat: {\n subscriptionApiUrl: 'https://subscription.uat-api.cx.metamask.io',\n },\n prd: {\n subscriptionApiUrl: 'https://subscription.api.cx.metamask.io',\n },\n};\n\n/**\n * Validates and returns correct environment endpoints\n *\n * @param env - environment field\n * @returns the correct environment url\n * @throws on invalid environment passed\n */\nexport function getEnvUrls(env: Env): EnvUrlsEntry {\n if (!ENV_URLS[env]) {\n throw new Error('invalid environment configuration');\n }\n return ENV_URLS[env];\n}\n\nexport enum SubscriptionControllerErrorMessage {\n UserAlreadySubscribed = `${controllerName} - User is already subscribed`,\n UserNotSubscribed = `${controllerName} - User is not subscribed`,\n SubscriptionProductsEmpty = `${controllerName} - Subscription products array cannot be empty`,\n PaymentTokenAddressAndSymbolRequiredForCrypto = `${controllerName} - Payment token address and symbol are required for crypto payment`,\n PaymentMethodNotCrypto = `${controllerName} - Payment method is not crypto`,\n ProductPriceNotFound = `${controllerName} - Product price not found`,\n SubscriptionNotValidForCryptoApproval = `${controllerName} - Subscription is not valid for crypto approval`,\n CryptoApprovalRequiresShieldApprove = `${controllerName} - Crypto approval is only supported for Shield ERC-20 approve transactions`,\n LinkRewardsFailed = `${controllerName} - Failed to link rewards`,\n}\n\nexport enum SubscriptionServiceErrorMessage {\n FailedToGetSubscriptions = 'Failed to get subscriptions',\n FailedToGetBenefits = 'Failed to get benefits',\n FailedToCancelSubscription = 'Failed to cancel subscription',\n FailedToUncancelSubscription = 'Failed to uncancel subscription',\n FailedToStartSubscriptionWithCard = 'Failed to start subscription with card',\n FailedToStartSubscriptionWithCrypto = 'Failed to start subscription with crypto',\n InvalidCryptoAuthCombo = 'Crypto subscription requires exactly one of rawTransaction (erc20_approval) or delegationHash (delegation)',\n FailedToUpdatePaymentMethodCard = 'Failed to update payment method card',\n FailedToUpdatePaymentMethodCrypto = 'Failed to update payment method crypto',\n FailedToGetSubscriptionsEligibilities = 'Failed to get subscriptions eligibilities',\n FailedToSubmitUserEvent = 'Failed to submit user event',\n FailedToAssignUserToCohort = 'Failed to assign user to cohort',\n FailedToSubmitSponsorshipIntents = 'Failed to submit sponsorship intents',\n FailedToLinkRewards = 'Failed to link rewards',\n FailedToGetPricing = 'Failed to get pricing',\n FailedToGetBillingPortalUrl = 'Failed to get billing portal url',\n}\n\nexport const DEFAULT_POLLING_INTERVAL = 5 * 60 * 1_000; // 5 minutes\n\nexport const ACTIVE_SUBSCRIPTION_STATUSES = [\n SUBSCRIPTION_STATUSES.active,\n SUBSCRIPTION_STATUSES.trialing,\n SUBSCRIPTION_STATUSES.provisional,\n] as string[];\n"]}
@@ -1,4 +1,4 @@
1
- import { SubscriptionApiError } from "./types.cjs";
1
+ import { SubscriptionApiError } from './types.js';
2
2
  export declare class SubscriptionServiceError extends Error {
3
3
  /**
4
4
  * The underlying error that caused this error.
@@ -31,4 +31,4 @@ export declare function createSentryError(message: string, cause: Error): Error;
31
31
  * @param statusCode - The status code of the response.
32
32
  */
33
33
  export declare function composeSubscriptionApiErrorMessage(error: SubscriptionApiError, statusCode: number): string;
34
- //# sourceMappingURL=errors.d.cts.map
34
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,qBAAa,wBAAyB,SAAQ,KAAK;IACjD;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,YACE,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,KAAK,CAAC;KACf,EAKF;CACF;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,KAAK,CAAC,CA2BhB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAOtE;AAED;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,oBAAoB,EAC3B,UAAU,EAAE,MAAM,GACjB,MAAM,CAMR"}
@@ -1,4 +1,8 @@
1
1
  export class SubscriptionServiceError extends Error {
2
+ /**
3
+ * The underlying error that caused this error.
4
+ */
5
+ cause;
2
6
  constructor(message, options) {
3
7
  super(message);
4
8
  this.name = 'SubscriptionServiceError';
@@ -62,4 +66,4 @@ export function composeSubscriptionApiErrorMessage(error, statusCode) {
62
66
  }
63
67
  return baseErrorMessage;
64
68
  }
65
- //# sourceMappingURL=errors.mjs.map
69
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD;;OAEG;IACH,KAAK,CAAS;IAEd,YACE,OAAe,EACf,OAEC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,OAAO,E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U,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,KAAY;IAC7D,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,OAAO,CAEpC,CAAC;IACF,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAE1B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC,CAChD,KAA2B,EAC3B,UAAkB;IAElB,IAAI,gBAAgB,GAAG,UAAU,KAAK,CAAC,OAAO,IAAI,eAAe,iBAAiB,UAAU,IAAI,qBAAqB,EAAE,CAAC;IACxH,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACpB,gBAAgB,IAAI,gBAAgB,KAAK,CAAC,SAAS,EAAE,CAAC;IACxD,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import { SubscriptionApiError } from './types.js';\n\nexport class SubscriptionServiceError extends Error {\n /**\n * The underlying error that caused this error.\n */\n cause?: Error;\n\n constructor(\n message: string,\n options?: {\n cause?: Error;\n },\n ) {\n super(message);\n this.name = 'SubscriptionServiceError';\n this.cause = options?.cause;\n }\n}\n\n/**\n * Get an error from a response.\n *\n * @param response - The response to get an error from.\n * @returns An error.\n */\nexport async function getSubscriptionErrorFromResponse(\n response: Response,\n): Promise<Error> {\n const contentType = response.headers?.get('content-type');\n const statusCode = response.status;\n try {\n if (contentType?.includes('application/json')) {\n const json = (await response.json()) as SubscriptionApiError;\n const subscriptionApiErrorMessage = composeSubscriptionApiErrorMessage(\n json,\n statusCode,\n );\n return new Error(subscriptionApiErrorMessage);\n } else if (contentType?.includes('text/plain')) {\n const text = await response.text();\n const networkError = `error: ${text}, statusCode: ${statusCode}`;\n return new Error(networkError);\n }\n\n const error =\n 'data' in response && typeof response.data === 'string'\n ? response.data\n : 'Unknown error';\n const networkError = `error: ${error}, statusCode: ${statusCode}`;\n return new Error(networkError);\n } catch (error) {\n const errMessage = error instanceof Error ? error.message : 'Unknown error';\n return new Error(`HTTP ${statusCode} error: ${errMessage}`);\n }\n}\n\n/**\n * Creates an error instance with a readable message and the root cause.\n *\n * @param message - The error message to create a Sentry error from.\n * @param cause - The inner error to create a Sentry error from.\n * @returns A Sentry error.\n */\nexport function createSentryError(message: string, cause: Error): Error {\n const sentryError = new Error(message) as Error & {\n cause: Error;\n };\n sentryError.cause = cause;\n\n return sentryError;\n}\n\n/**\n * Compose an error message from a Subscription API error.\n *\n * @param error - The Subscription API error to compose an error message from.\n * @returns An error message.\n * @param statusCode - The status code of the response.\n */\nexport function composeSubscriptionApiErrorMessage(\n error: SubscriptionApiError,\n statusCode: number,\n): string {\n let baseErrorMessage = `error: ${error.message ?? 'Unknown error'}, statusCode: ${statusCode ?? 'Unknown status code'}`;\n if (error.errorCode) {\n baseErrorMessage += `, errorCode: ${error.errorCode}`;\n }\n return baseErrorMessage;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ export type { SubscriptionControllerActions, SubscriptionControllerState, SubscriptionControllerEvents, SubscriptionControllerGetStateAction, SubscriptionControllerMessenger, SubscriptionControllerOptions, SubscriptionControllerStateChangeEvent, } from './SubscriptionController.js';
2
+ export type { SubscriptionControllerGetPricingAction, SubscriptionControllerGetSubscriptionsAction, SubscriptionControllerGetBenefitsAction, SubscriptionControllerGetSubscriptionByProductAction, SubscriptionControllerGetSubscriptionsEligibilitiesAction, SubscriptionControllerCancelSubscriptionAction, SubscriptionControllerUnCancelSubscriptionAction, SubscriptionControllerStartSubscriptionWithCardAction, SubscriptionControllerStartSubscriptionWithCryptoAction, SubscriptionControllerSubmitSubscriptionCryptoApprovalAction, SubscriptionControllerGetCryptoApproveTransactionParamsAction, SubscriptionControllerUpdatePaymentMethodAction, SubscriptionControllerGetBillingPortalUrlAction, SubscriptionControllerCacheLastSelectedPaymentMethodAction, SubscriptionControllerClearLastSelectedPaymentMethodAction, SubscriptionControllerSubmitSponsorshipIntentsAction, SubscriptionControllerSubmitUserEventAction, SubscriptionControllerAssignUserToCohortAction, SubscriptionControllerLinkRewardsAction, SubscriptionControllerGetTokenApproveAmountAction, SubscriptionControllerGetTokenMinimumBalanceAmountAction, SubscriptionControllerClearStateAction, SubscriptionControllerTriggerAccessTokenRefreshAction, SubscriptionControllerStopAllPollingAction, } from './SubscriptionController-method-action-types.js';
3
+ export { SubscriptionController, getDefaultSubscriptionControllerState, } from './SubscriptionController.js';
4
+ export type { SubscriptionApiError, Subscription, PerpsBenefitUsage, PredictBenefitUsage, SubscriptionBenefitsResponse, SubscriptionBenefitsState, SwapsBenefitUsage, AuthUtils, CancelSubscriptionRequest, CancelType, ISubscriptionService, StartCryptoSubscriptionRequest, StartDelegationCryptoSubscriptionRequest, StartErc20CryptoSubscriptionRequest, StartCryptoSubscriptionResponse, StartSubscriptionRequest, StartSubscriptionResponse, GetCryptoApproveTransactionRequest, GetCryptoApproveTransactionResponse, SubmitSubscriptionCryptoApprovalRequest, SubscriptionCardPaymentMethod, SubscriptionCryptoPaymentMethod, SubscriptionPaymentMethod, SubmitUserEventRequest, SubmitSponsorshipIntentsRequest, SubscriptionEligibility, SubscriptionUserEventType, RecurringInterval, SubscriptionStatus, PaymentType, Product, ProductType, ProductPrice, ProductPricing, TokenPaymentInfo, SpotTokenPaymentInfo, VaultTokenPaymentInfo, ChainPaymentInfo, Currency, CryptoAuthMethod, PricingPaymentMethod, PricingCardPaymentMethod, PricingCryptoPaymentMethod, PricingResponse, UpdatePaymentMethodOpts, BillingPortalResponse, CryptoPaymentMethodError, UpdatePaymentMethodCryptoRequest, UpdatePaymentMethodCardRequest, UpdatePaymentMethodCardResponse, CachedLastSelectedPaymentMethod, CacheLastSelectedPaymentMethodRequest, SubmitSponsorshipIntentsMethodParams, Cohort, CohortName, BalanceCategory, AssignCohortRequest, GetSubscriptionsEligibilitiesRequest, ModalType, MoneyAccountEntitlements, MoneyAccountPlusClaim, ProductEntitlementFeatureMap, ProductEntitlements, ShieldEntitlements, } from './types.js';
5
+ export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, CRYPTO_AUTH_METHODS, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE, MoneyAccountFeature, ShieldFeature, } from './types.js';
6
+ export { selectHasEntitlement, selectIsActiveSubscriber, selectIsUsageAvailable, } from './selectors.js';
7
+ export { SubscriptionServiceError } from './errors.js';
8
+ export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from './constants.js';
9
+ export type { SubscriptionServiceOptions, SubscriptionServiceMessenger, SubscriptionServiceActions, SubscriptionServiceEvents, SubscriptionServiceCacheUpdatedEvent, SubscriptionServiceGranularCacheUpdatedEvent, SubscriptionServiceInvalidateQueriesAction, } from './SubscriptionService.js';
10
+ export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL, } from './SubscriptionService.js';
11
+ export type { SubscriptionServiceGetSubscriptionsAction, SubscriptionServiceGetBenefitsAction, SubscriptionServiceCancelSubscriptionAction, SubscriptionServiceUnCancelSubscriptionAction, SubscriptionServiceStartSubscriptionWithCardAction, SubscriptionServiceStartSubscriptionWithCryptoAction, SubscriptionServiceUpdatePaymentMethodCardAction, SubscriptionServiceUpdatePaymentMethodCryptoAction, SubscriptionServiceGetSubscriptionsEligibilitiesAction, SubscriptionServiceSubmitUserEventAction, SubscriptionServiceAssignUserToCohortAction, SubscriptionServiceSubmitSponsorshipIntentsAction, SubscriptionServiceLinkRewardsAction, SubscriptionServiceGetPricingAction, SubscriptionServiceGetBillingPortalUrlAction, } from './SubscriptionService-method-action-types.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,4BA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gC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,qCAAqC,EACrC,oCAAoC,EACpC,MAAM,EACN,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,oCAAoC,EACpC,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,GAAG,EACH,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,oCAAoC,EACpC,4CAA4C,EAC5C,0CAA0C,GAC3C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,yCAAyC,EACzC,oCAAoC,EACpC,2CAA2C,EAC3C,6CAA6C,EAC7C,kDAAkD,EAClD,oDAAoD,EACpD,gDAAgD,EAChD,kDAAkD,EAClD,sDAAsD,EACtD,wCAAwC,EACxC,2CAA2C,EAC3C,iDAAiD,EACjD,oCAAoC,EACpC,mCAAmC,EACnC,4CAA4C,GAC7C,MAAM,8CAA8C,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { SubscriptionController, getDefaultSubscriptionControllerState, } from './SubscriptionController.js';
2
+ export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, CRYPTO_AUTH_METHODS, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE, MoneyAccountFeature, ShieldFeature, } from './types.js';
3
+ export { selectHasEntitlement, selectIsActiveSubscriber, selectIsUsageAvailable, } from './selectors.js';
4
+ export { SubscriptionServiceError } from './errors.js';
5
+ export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from './constants.js';
6
+ export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL, } from './SubscriptionService.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmCA,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,MAAM,6BAA6B,CAAC;AAmErC,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,GAAG,EACH,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,GACjB,MAAM,0BAA0B,CAAC","sourcesContent":["export type {\n SubscriptionControllerActions,\n SubscriptionControllerState,\n SubscriptionControllerEvents,\n SubscriptionControllerGetStateAction,\n SubscriptionControllerMessenger,\n SubscriptionControllerOptions,\n SubscriptionControllerStateChangeEvent,\n} from './SubscriptionController.js';\nexport type {\n SubscriptionControllerGetPricingAction,\n SubscriptionControllerGetSubscriptionsAction,\n SubscriptionControllerGetBenefitsAction,\n SubscriptionControllerGetSubscriptionByProductAction,\n SubscriptionControllerGetSubscriptionsEligibilitiesAction,\n SubscriptionControllerCancelSubscriptionAction,\n SubscriptionControllerUnCancelSubscriptionAction,\n SubscriptionControllerStartSubscriptionWithCardAction,\n SubscriptionControllerStartSubscriptionWithCryptoAction,\n SubscriptionControllerSubmitSubscriptionCryptoApprovalAction,\n SubscriptionControllerGetCryptoApproveTransactionParamsAction,\n SubscriptionControllerUpdatePaymentMethodAction,\n SubscriptionControllerGetBillingPortalUrlAction,\n SubscriptionControllerCacheLastSelectedPaymentMethodAction,\n SubscriptionControllerClearLastSelectedPaymentMethodAction,\n SubscriptionControllerSubmitSponsorshipIntentsAction,\n SubscriptionControllerSubmitUserEventAction,\n SubscriptionControllerAssignUserToCohortAction,\n SubscriptionControllerLinkRewardsAction,\n SubscriptionControllerGetTokenApproveAmountAction,\n SubscriptionControllerGetTokenMinimumBalanceAmountAction,\n SubscriptionControllerClearStateAction,\n SubscriptionControllerTriggerAccessTokenRefreshAction,\n SubscriptionControllerStopAllPollingAction,\n} from './SubscriptionController-method-action-types.js';\nexport {\n SubscriptionController,\n getDefaultSubscriptionControllerState,\n} from './SubscriptionController.js';\nexport type {\n SubscriptionApiError,\n Subscription,\n PerpsBenefitUsage,\n PredictBenefitUsage,\n SubscriptionBenefitsResponse,\n SubscriptionBenefitsState,\n SwapsBenefitUsage,\n AuthUtils,\n CancelSubscriptionRequest,\n CancelType,\n ISubscriptionService,\n StartCryptoSubscriptionRequest,\n StartDelegationCryptoSubscriptionRequest,\n StartErc20CryptoSubscriptionRequest,\n StartCryptoSubscriptionResponse,\n StartSubscriptionRequest,\n StartSubscriptionResponse,\n GetCryptoApproveTransactionRequest,\n GetCryptoApproveTransactionResponse,\n SubmitSubscriptionCryptoApprovalRequest,\n SubscriptionCardPaymentMethod,\n SubscriptionCryptoPaymentMethod,\n SubscriptionPaymentMethod,\n SubmitUserEventRequest,\n SubmitSponsorshipIntentsRequest,\n SubscriptionEligibility,\n SubscriptionUserEventType,\n RecurringInterval,\n SubscriptionStatus,\n PaymentType,\n Product,\n ProductType,\n ProductPrice,\n ProductPricing,\n TokenPaymentInfo,\n SpotTokenPaymentInfo,\n VaultTokenPaymentInfo,\n ChainPaymentInfo,\n Currency,\n CryptoAuthMethod,\n PricingPaymentMethod,\n PricingCardPaymentMethod,\n PricingCryptoPaymentMethod,\n PricingResponse,\n UpdatePaymentMethodOpts,\n BillingPortalResponse,\n CryptoPaymentMethodError,\n UpdatePaymentMethodCryptoRequest,\n UpdatePaymentMethodCardRequest,\n UpdatePaymentMethodCardResponse,\n CachedLastSelectedPaymentMethod,\n CacheLastSelectedPaymentMethodRequest,\n SubmitSponsorshipIntentsMethodParams,\n Cohort,\n CohortName,\n BalanceCategory,\n AssignCohortRequest,\n GetSubscriptionsEligibilitiesRequest,\n ModalType,\n MoneyAccountEntitlements,\n MoneyAccountPlusClaim,\n ProductEntitlementFeatureMap,\n ProductEntitlements,\n ShieldEntitlements,\n} from './types.js';\nexport {\n CANCEL_TYPES,\n CRYPTO_PAYMENT_METHOD_ERRORS,\n SUBSCRIPTION_STATUSES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n PAYMENT_TYPES,\n CRYPTO_AUTH_METHODS,\n SubscriptionUserEvent,\n COHORT_NAMES,\n BALANCE_CATEGORIES,\n MODAL_TYPE,\n MoneyAccountFeature,\n ShieldFeature,\n} from './types.js';\nexport {\n selectHasEntitlement,\n selectIsActiveSubscriber,\n selectIsUsageAvailable,\n} from './selectors.js';\nexport { SubscriptionServiceError } from './errors.js';\nexport {\n Env,\n SubscriptionControllerErrorMessage,\n SubscriptionServiceErrorMessage,\n} from './constants.js';\nexport type {\n SubscriptionServiceOptions,\n SubscriptionServiceMessenger,\n SubscriptionServiceActions,\n SubscriptionServiceEvents,\n SubscriptionServiceCacheUpdatedEvent,\n SubscriptionServiceGranularCacheUpdatedEvent,\n SubscriptionServiceInvalidateQueriesAction,\n} from './SubscriptionService.js';\nexport {\n SubscriptionService,\n serviceName as subscriptionServiceName,\n SUBSCRIPTION_URL,\n} from './SubscriptionService.js';\nexport type {\n SubscriptionServiceGetSubscriptionsAction,\n SubscriptionServiceGetBenefitsAction,\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} from './SubscriptionService-method-action-types.js';\n"]}
@@ -0,0 +1,4 @@
1
+ import { createModuleLogger } from '@metamask/utils';
2
+ export declare const projectLogger: import("debug").Debugger;
3
+ export { createModuleLogger };
4
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI1E,eAAO,MAAM,aAAa,0BAAsC,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/logger.js ADDED
@@ -0,0 +1,5 @@
1
+ import { createProjectLogger, createModuleLogger } from '@metamask/utils';
2
+ import { controllerName } from './constants.js';
3
+ export const projectLogger = createProjectLogger(controllerName);
4
+ export { createModuleLogger };
5
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC,cAAc,CAAC,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nimport { controllerName } from './constants.js';\n\nexport const projectLogger = createProjectLogger(controllerName);\n\nexport { createModuleLogger };\n"]}
@@ -0,0 +1,38 @@
1
+ import type { SubscriptionControllerState } from './SubscriptionController.js';
2
+ import type { ProductEntitlementFeatureMap, ProductType } from './types.js';
3
+ /**
4
+ * Returns whether a specific product feature entitlement is enabled.
5
+ *
6
+ * Use this to gate paid UX. Missing products or missing features fail closed
7
+ * (`false`). Combine with `selectIsActiveSubscriber` when that is the
8
+ * product rule; this selector only reads the entitlement boolean.
9
+ *
10
+ * @param state - The subscription controller state.
11
+ * @param productType - The product whose entitlement is queried.
12
+ * @param feature - The feature whose entitlement flag is queried.
13
+ * @returns Whether the feature entitlement is true.
14
+ */
15
+ export declare function selectHasEntitlement<TProduct extends ProductType>(state: SubscriptionControllerState, productType: TProduct, feature: ProductEntitlementFeatureMap[TProduct]): boolean;
16
+ /**
17
+ * Usage availability currently matches entitlement because the server folds
18
+ * metered-cap exhaustion into the entitlement flag. Keeping this selector
19
+ * separate gives consumers a stable API if explicit usage claims are added.
20
+ *
21
+ * @param state - The subscription controller state.
22
+ * @param productType - The product whose usage availability is queried.
23
+ * @param feature - The feature whose usage availability is queried.
24
+ * @returns Whether usage is currently available for the feature.
25
+ */
26
+ export declare function selectIsUsageAvailable<TProduct extends ProductType>(state: SubscriptionControllerState, productType: TProduct, feature: ProductEntitlementFeatureMap[TProduct]): boolean;
27
+ /**
28
+ * Returns whether the user has an active subscription for a specific product.
29
+ *
30
+ * Active includes `active`, `trialing`, and `provisional`. Missing products
31
+ * and non-active statuses fail closed (`false`).
32
+ *
33
+ * @param state - The subscription controller state.
34
+ * @param productType - The product to check.
35
+ * @returns Whether the user is an active subscriber for the product.
36
+ */
37
+ export declare function selectIsActiveSubscriber(state: SubscriptionControllerState, productType: ProductType): boolean;
38
+ //# sourceMappingURL=selectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE5E;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,WAAW,EAC/D,KAAK,EAAE,2BAA2B,EAClC,WAAW,EAAE,QAAQ,EACrB,OAAO,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAC9C,OAAO,CAOT;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,SAAS,WAAW,EACjE,KAAK,EAAE,2BAA2B,EAClC,WAAW,EAAE,QAAQ,EACrB,OAAO,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAC9C,OAAO,CAET;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,2BAA2B,EAClC,WAAW,EAAE,WAAW,GACvB,OAAO,CAMT"}
@@ -0,0 +1,46 @@
1
+ import { ACTIVE_SUBSCRIPTION_STATUSES } from './constants.js';
2
+ /**
3
+ * Returns whether a specific product feature entitlement is enabled.
4
+ *
5
+ * Use this to gate paid UX. Missing products or missing features fail closed
6
+ * (`false`). Combine with `selectIsActiveSubscriber` when that is the
7
+ * product rule; this selector only reads the entitlement boolean.
8
+ *
9
+ * @param state - The subscription controller state.
10
+ * @param productType - The product whose entitlement is queried.
11
+ * @param feature - The feature whose entitlement flag is queried.
12
+ * @returns Whether the feature entitlement is true.
13
+ */
14
+ export function selectHasEntitlement(state, productType, feature) {
15
+ const entitlements = state.productEntitlements?.[productType]
16
+ ?.entitlements;
17
+ return Boolean(entitlements?.[feature]);
18
+ }
19
+ /**
20
+ * Usage availability currently matches entitlement because the server folds
21
+ * metered-cap exhaustion into the entitlement flag. Keeping this selector
22
+ * separate gives consumers a stable API if explicit usage claims are added.
23
+ *
24
+ * @param state - The subscription controller state.
25
+ * @param productType - The product whose usage availability is queried.
26
+ * @param feature - The feature whose usage availability is queried.
27
+ * @returns Whether usage is currently available for the feature.
28
+ */
29
+ export function selectIsUsageAvailable(state, productType, feature) {
30
+ return selectHasEntitlement(state, productType, feature);
31
+ }
32
+ /**
33
+ * Returns whether the user has an active subscription for a specific product.
34
+ *
35
+ * Active includes `active`, `trialing`, and `provisional`. Missing products
36
+ * and non-active statuses fail closed (`false`).
37
+ *
38
+ * @param state - The subscription controller state.
39
+ * @param productType - The product to check.
40
+ * @returns Whether the user is an active subscriber for the product.
41
+ */
42
+ export function selectIsActiveSubscriber(state, productType) {
43
+ return state.subscriptions.some((subscription) => ACTIVE_SUBSCRIPTION_STATUSES.includes(subscription.status) &&
44
+ subscription.products.some((product) => product.name === productType));
45
+ }
46
+ //# sourceMappingURL=selectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAI9D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAkC,EAClC,WAAqB,EACrB,OAA+C;IAE/C,MAAM,YAAY,GAAG,KAAK,CAAC,mBAAmB,EAAE,CAAC,WAAW,CAAC;QAC3D,EAAE,YAES,CAAC;IAEd,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAkC,EAClC,WAAqB,EACrB,OAA+C;IAE/C,OAAO,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAkC,EAClC,WAAwB;IAExB,OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,CAC7B,CAAC,YAAY,EAAE,EAAE,CACf,4BAA4B,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC;QAC1D,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,CACxE,CAAC;AACJ,CAAC","sourcesContent":["import { ACTIVE_SUBSCRIPTION_STATUSES } from './constants.js';\nimport type { SubscriptionControllerState } from './SubscriptionController.js';\nimport type { ProductEntitlementFeatureMap, ProductType } from './types.js';\n\n/**\n * Returns whether a specific product feature entitlement is enabled.\n *\n * Use this to gate paid UX. Missing products or missing features fail closed\n * (`false`). Combine with `selectIsActiveSubscriber` when that is the\n * product rule; this selector only reads the entitlement boolean.\n *\n * @param state - The subscription controller state.\n * @param productType - The product whose entitlement is queried.\n * @param feature - The feature whose entitlement flag is queried.\n * @returns Whether the feature entitlement is true.\n */\nexport function selectHasEntitlement<TProduct extends ProductType>(\n state: SubscriptionControllerState,\n productType: TProduct,\n feature: ProductEntitlementFeatureMap[TProduct],\n): boolean {\n const entitlements = state.productEntitlements?.[productType]\n ?.entitlements as\n | Record<ProductEntitlementFeatureMap[TProduct], boolean>\n | undefined;\n\n return Boolean(entitlements?.[feature]);\n}\n\n/**\n * Usage availability currently matches entitlement because the server folds\n * metered-cap exhaustion into the entitlement flag. Keeping this selector\n * separate gives consumers a stable API if explicit usage claims are added.\n *\n * @param state - The subscription controller state.\n * @param productType - The product whose usage availability is queried.\n * @param feature - The feature whose usage availability is queried.\n * @returns Whether usage is currently available for the feature.\n */\nexport function selectIsUsageAvailable<TProduct extends ProductType>(\n state: SubscriptionControllerState,\n productType: TProduct,\n feature: ProductEntitlementFeatureMap[TProduct],\n): boolean {\n return selectHasEntitlement(state, productType, feature);\n}\n\n/**\n * Returns whether the user has an active subscription for a specific product.\n *\n * Active includes `active`, `trialing`, and `provisional`. Missing products\n * and non-active statuses fail closed (`false`).\n *\n * @param state - The subscription controller state.\n * @param productType - The product to check.\n * @returns Whether the user is an active subscriber for the product.\n */\nexport function selectIsActiveSubscriber(\n state: SubscriptionControllerState,\n productType: ProductType,\n): boolean {\n return state.subscriptions.some(\n (subscription) =>\n ACTIVE_SUBSCRIPTION_STATUSES.includes(subscription.status) &&\n subscription.products.some((product) => product.name === productType),\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { TransactionMeta } from "@metamask/transaction-controller";
2
- import type { CaipAccountId, Hex } from "@metamask/utils";
1
+ import type { TransactionMeta } from '@metamask/transaction-controller';
2
+ import type { CaipAccountId, Hex } from '@metamask/utils';
3
3
  /**
4
4
  * Error response from the Subscription API.
5
5
  */
@@ -15,13 +15,41 @@ export declare const PRODUCT_TYPES: {
15
15
  /**
16
16
  * MetaMask Shield.
17
17
  */
18
- readonly SHIELD: "shield";
18
+ readonly SHIELD: 'shield';
19
19
  /**
20
20
  * Money Account Plus (delegation-based crypto billing).
21
21
  */
22
- readonly MONEY_ACCOUNT_PLUS: "money_account_plus";
22
+ readonly MONEY_ACCOUNT_PLUS: 'money_account_plus';
23
23
  };
24
24
  export type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];
25
+ export declare const MoneyAccountFeature: {
26
+ readonly SwapFeeWaiver: 'swapFeeWaiver';
27
+ readonly PerpsFeeWaiver: 'perpsFeeWaiver';
28
+ readonly PredictFreeTx: 'predictFreeTx';
29
+ readonly PremiumApy: 'premiumApy';
30
+ };
31
+ export type MoneyAccountFeature = (typeof MoneyAccountFeature)[keyof typeof MoneyAccountFeature];
32
+ export type MoneyAccountEntitlements = Record<MoneyAccountFeature, boolean>;
33
+ export declare const ShieldFeature: {
34
+ readonly ShieldClaim: 'shieldClaim';
35
+ readonly PrioritySupport: 'prioritySupport';
36
+ };
37
+ export type ShieldFeature = (typeof ShieldFeature)[keyof typeof ShieldFeature];
38
+ export type ShieldEntitlements = Record<ShieldFeature, boolean>;
39
+ export type MoneyAccountPlusClaim = {
40
+ plan: string;
41
+ entitlements: MoneyAccountEntitlements;
42
+ };
43
+ export type ProductEntitlements = {
44
+ [PRODUCT_TYPES.SHIELD]?: {
45
+ entitlements: ShieldEntitlements;
46
+ };
47
+ [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]?: MoneyAccountPlusClaim;
48
+ };
49
+ export type ProductEntitlementFeatureMap = {
50
+ [PRODUCT_TYPES.SHIELD]: ShieldFeature;
51
+ [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]: MoneyAccountFeature;
52
+ };
25
53
  /**
26
54
  * How a crypto subscription is authorized.
27
55
  *
@@ -32,53 +60,53 @@ export declare const CRYPTO_AUTH_METHODS: {
32
60
  /**
33
61
  * User signs an ERC-20 approve transaction.
34
62
  */
35
- readonly ERC20_APPROVAL: "erc20_approval";
63
+ readonly ERC20_APPROVAL: 'erc20_approval';
36
64
  /**
37
65
  * User authorizes via a stored delegation hash.
38
66
  */
39
- readonly DELEGATION: "delegation";
67
+ readonly DELEGATION: 'delegation';
40
68
  };
41
69
  export type CryptoAuthMethod = (typeof CRYPTO_AUTH_METHODS)[keyof typeof CRYPTO_AUTH_METHODS];
42
70
  export declare const PAYMENT_TYPES: {
43
- readonly byCard: "card";
44
- readonly byCrypto: "crypto";
71
+ readonly byCard: 'card';
72
+ readonly byCrypto: 'crypto';
45
73
  };
46
74
  export type PaymentType = (typeof PAYMENT_TYPES)[keyof typeof PAYMENT_TYPES];
47
75
  export declare const RECURRING_INTERVALS: {
48
- readonly month: "month";
49
- readonly year: "year";
76
+ readonly month: 'month';
77
+ readonly year: 'year';
50
78
  };
51
79
  export type RecurringInterval = (typeof RECURRING_INTERVALS)[keyof typeof RECURRING_INTERVALS];
52
80
  export declare const SUBSCRIPTION_STATUSES: {
53
- readonly incomplete: "incomplete";
54
- readonly incompleteExpired: "incomplete_expired";
55
- readonly provisional: "provisional";
56
- readonly trialing: "trialing";
57
- readonly active: "active";
58
- readonly pastDue: "past_due";
59
- readonly unpaid: "unpaid";
60
- readonly canceled: "canceled";
61
- readonly paused: "paused";
81
+ readonly incomplete: 'incomplete';
82
+ readonly incompleteExpired: 'incomplete_expired';
83
+ readonly provisional: 'provisional';
84
+ readonly trialing: 'trialing';
85
+ readonly active: 'active';
86
+ readonly pastDue: 'past_due';
87
+ readonly unpaid: 'unpaid';
88
+ readonly canceled: 'canceled';
89
+ readonly paused: 'paused';
62
90
  };
63
91
  export type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];
64
92
  export declare const CANCEL_TYPES: {
65
- readonly ALLOWED_IMMEDIATE: "allowed_immediate";
66
- readonly ALLOWED_AT_PERIOD_END: "allowed_at_period_end";
67
- readonly NOT_ALLOWED: "not_allowed";
68
- readonly NOT_ALLOWED_PENDING_VERIFICATION: "not_allowed_pending_verification";
93
+ readonly ALLOWED_IMMEDIATE: 'allowed_immediate';
94
+ readonly ALLOWED_AT_PERIOD_END: 'allowed_at_period_end';
95
+ readonly NOT_ALLOWED: 'not_allowed';
96
+ readonly NOT_ALLOWED_PENDING_VERIFICATION: 'not_allowed_pending_verification';
69
97
  };
70
98
  export type CancelType = (typeof CANCEL_TYPES)[keyof typeof CANCEL_TYPES];
71
99
  export declare const CRYPTO_PAYMENT_METHOD_ERRORS: {
72
- readonly APPROVAL_TRANSACTION_TOO_OLD: "approval_transaction_too_old";
73
- readonly APPROVAL_TRANSACTION_REVERTED: "approval_transaction_reverted";
74
- readonly APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED: "approval_transaction_max_verification_attempts_reached";
75
- readonly INSUFFICIENT_BALANCE: "insufficient_balance";
76
- readonly INSUFFICIENT_ALLOWANCE: "insufficient_allowance";
100
+ readonly APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old';
101
+ readonly APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted';
102
+ readonly APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED: 'approval_transaction_max_verification_attempts_reached';
103
+ readonly INSUFFICIENT_BALANCE: 'insufficient_balance';
104
+ readonly INSUFFICIENT_ALLOWANCE: 'insufficient_allowance';
77
105
  };
78
106
  export type CryptoPaymentMethodError = (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];
79
107
  export declare const MODAL_TYPE: {
80
- readonly A: "A";
81
- readonly B: "B";
108
+ readonly A: 'A';
109
+ readonly B: 'B';
82
110
  };
83
111
  export type ModalType = (typeof MODAL_TYPE)[keyof typeof MODAL_TYPE];
84
112
  /** only usd for now */
@@ -137,11 +165,53 @@ export type GetSubscriptionsResponse = {
137
165
  customerId?: string;
138
166
  subscriptions: Subscription[];
139
167
  trialedProducts: ProductType[];
168
+ productEntitlements?: ProductEntitlements;
140
169
  /** The last subscription that user has subscribed to if any. */
141
170
  lastSubscription?: Subscription;
142
171
  /** The reward account ID if user has linked rewards to the subscription. */
143
172
  rewardAccountId?: CaipAccountId;
144
173
  };
174
+ /**
175
+ * Benefits available to a subscription user.
176
+ */
177
+ export type SwapsBenefitUsage = {
178
+ feeBips: string | null;
179
+ capMicroUsd?: number;
180
+ consumedMicroUsd?: number;
181
+ remainingMicroUsd: number | null;
182
+ exhausted: boolean;
183
+ };
184
+ export type PerpsBenefitUsage = {
185
+ builderFeeBips: string | null;
186
+ builderCode: string | null;
187
+ capMicroUsd?: number;
188
+ consumedMicroUsd?: number;
189
+ remainingMicroUsd: number | null;
190
+ exhausted: boolean;
191
+ };
192
+ export type PredictBenefitUsage = {
193
+ builderCode: string | null;
194
+ capTxCount?: number;
195
+ consumedTxCount?: number;
196
+ remainingTxCount: number | null;
197
+ exhausted: boolean;
198
+ };
199
+ type SubscriptionBenefitsProducts = {
200
+ swaps: SwapsBenefitUsage;
201
+ perps: PerpsBenefitUsage;
202
+ predict: PredictBenefitUsage;
203
+ };
204
+ export type SubscriptionBenefitsResponse = {
205
+ eligible: boolean;
206
+ billingPeriodId: string | null;
207
+ products: SubscriptionBenefitsProducts;
208
+ };
209
+ /**
210
+ * Benefits state exposed to the UI.
211
+ */
212
+ export type SubscriptionBenefitsState = SubscriptionBenefitsProducts & {
213
+ billingPeriodId: string | null;
214
+ };
145
215
  export type StartSubscriptionRequest = {
146
216
  products: ProductType[];
147
217
  isTrialRequested: boolean;
@@ -395,17 +465,17 @@ export type SubmitSubscriptionCryptoApprovalRequest = {
395
465
  rewardAccountId?: CaipAccountId;
396
466
  };
397
467
  export declare const COHORT_NAMES: {
398
- readonly POST_TX: "post_tx";
399
- readonly WALLET_HOME: "wallet_home";
468
+ readonly POST_TX: 'post_tx';
469
+ readonly WALLET_HOME: 'wallet_home';
400
470
  };
401
471
  export type CohortName = (typeof COHORT_NAMES)[keyof typeof COHORT_NAMES];
402
472
  export declare const BALANCE_CATEGORIES: {
403
- readonly RANGE_0_99: "0-99";
404
- readonly RANGE_100_999: "100-999";
405
- readonly RANGE_1K_9_9K: "1k-9.9k";
406
- readonly RANGE_10K_99_9K: "10k-99.9k";
407
- readonly RANGE_100K_999_9K: "100k-999.9k";
408
- readonly RANGE_1M_PLUS: "1M+";
473
+ readonly RANGE_0_99: '0-99';
474
+ readonly RANGE_100_999: '100-999';
475
+ readonly RANGE_1K_9_9K: '1k-9.9k';
476
+ readonly RANGE_10K_99_9K: '10k-99.9k';
477
+ readonly RANGE_100K_999_9K: '100k-999.9k';
478
+ readonly RANGE_1M_PLUS: '1M+';
409
479
  };
410
480
  export type BalanceCategory = (typeof BALANCE_CATEGORIES)[keyof typeof BALANCE_CATEGORIES];
411
481
  export type Cohort = {
@@ -424,8 +494,8 @@ export type SubscriptionEligibility = {
424
494
  hasAssignedCohortExpired: boolean;
425
495
  };
426
496
  export declare const SubscriptionUserEvent: {
427
- readonly ShieldEntryModalViewed: "shield_entry_modal_viewed";
428
- readonly ShieldCohortAssigned: "shield_cohort_assigned";
497
+ readonly ShieldEntryModalViewed: 'shield_entry_modal_viewed';
498
+ readonly ShieldCohortAssigned: 'shield_cohort_assigned';
429
499
  };
430
500
  export type SubscriptionUserEventType = (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];
431
501
  export type SubmitUserEventRequest = {
@@ -452,6 +522,7 @@ export type SubmitSponsorshipIntentsRequest = {
452
522
  export type SubmitSponsorshipIntentsMethodParams = Pick<SubmitSponsorshipIntentsRequest, 'chainId' | 'address' | 'products'>;
453
523
  export type ISubscriptionService = {
454
524
  getSubscriptions(): Promise<GetSubscriptionsResponse>;
525
+ getBenefits(): Promise<SubscriptionBenefitsResponse>;
455
526
  cancelSubscription(request: CancelSubscriptionRequest): Promise<Subscription>;
456
527
  unCancelSubscription(request: {
457
528
  subscriptionId: string;
@@ -571,4 +642,4 @@ export type LinkRewardsRequest = {
571
642
  rewardAccountId: CaipAccountId;
572
643
  };
573
644
  export {};
574
- //# sourceMappingURL=types.d.mts.map
645
+ //# sourceMappingURL=types.d.ts.map