@metamask-previews/subscription-controller 7.0.0-preview-9efd0b754 → 7.0.0-preview-4e64b66e8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/dist/SubscriptionController-method-action-types.cjs.map +1 -1
  3. package/dist/SubscriptionController-method-action-types.d.cts +55 -18
  4. package/dist/SubscriptionController-method-action-types.d.cts.map +1 -1
  5. package/dist/SubscriptionController-method-action-types.d.mts +55 -18
  6. package/dist/SubscriptionController-method-action-types.d.mts.map +1 -1
  7. package/dist/SubscriptionController-method-action-types.mjs.map +1 -1
  8. package/dist/SubscriptionController.cjs +165 -45
  9. package/dist/SubscriptionController.cjs.map +1 -1
  10. package/dist/SubscriptionController.d.cts +53 -17
  11. package/dist/SubscriptionController.d.cts.map +1 -1
  12. package/dist/SubscriptionController.d.mts +53 -17
  13. package/dist/SubscriptionController.d.mts.map +1 -1
  14. package/dist/SubscriptionController.mjs +166 -46
  15. package/dist/SubscriptionController.mjs.map +1 -1
  16. package/dist/SubscriptionService-method-action-types.cjs.map +1 -1
  17. package/dist/SubscriptionService-method-action-types.d.cts +5 -1
  18. package/dist/SubscriptionService-method-action-types.d.cts.map +1 -1
  19. package/dist/SubscriptionService-method-action-types.d.mts +5 -1
  20. package/dist/SubscriptionService-method-action-types.d.mts.map +1 -1
  21. package/dist/SubscriptionService-method-action-types.mjs.map +1 -1
  22. package/dist/SubscriptionService-structs.cjs +35 -12
  23. package/dist/SubscriptionService-structs.cjs.map +1 -1
  24. package/dist/SubscriptionService-structs.d.cts +185 -237
  25. package/dist/SubscriptionService-structs.d.cts.map +1 -1
  26. package/dist/SubscriptionService-structs.d.mts +185 -237
  27. package/dist/SubscriptionService-structs.d.mts.map +1 -1
  28. package/dist/SubscriptionService-structs.mjs +37 -14
  29. package/dist/SubscriptionService-structs.mjs.map +1 -1
  30. package/dist/SubscriptionService.cjs +24 -2
  31. package/dist/SubscriptionService.cjs.map +1 -1
  32. package/dist/SubscriptionService.d.cts +5 -1
  33. package/dist/SubscriptionService.d.cts.map +1 -1
  34. package/dist/SubscriptionService.d.mts +5 -1
  35. package/dist/SubscriptionService.d.mts.map +1 -1
  36. package/dist/SubscriptionService.mjs +24 -2
  37. package/dist/SubscriptionService.mjs.map +1 -1
  38. package/dist/constants.cjs +2 -0
  39. package/dist/constants.cjs.map +1 -1
  40. package/dist/constants.d.cts +2 -0
  41. package/dist/constants.d.cts.map +1 -1
  42. package/dist/constants.d.mts +2 -0
  43. package/dist/constants.d.mts.map +1 -1
  44. package/dist/constants.mjs +2 -0
  45. package/dist/constants.mjs.map +1 -1
  46. package/dist/index.cjs +2 -1
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +3 -3
  49. package/dist/index.d.cts.map +1 -1
  50. package/dist/index.d.mts +3 -3
  51. package/dist/index.d.mts.map +1 -1
  52. package/dist/index.mjs +1 -1
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/types.cjs +27 -1
  55. package/dist/types.cjs.map +1 -1
  56. package/dist/types.d.cts +171 -10
  57. package/dist/types.d.cts.map +1 -1
  58. package/dist/types.d.mts +171 -10
  59. package/dist/types.d.mts.map +1 -1
  60. package/dist/types.mjs +26 -0
  61. package/dist/types.mjs.map +1 -1
  62. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionService.mjs","sourceRoot":"","sources":["../src/SubscriptionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAE9D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mCAAmC;AAGnE,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAI/C,OAAO,EACL,GAAG,EACH,UAAU,EACV,kCAAkC,EAClC,+BAA+B,EAChC,wBAAuB;AACxB,OAAO,EACL,iBAAiB,EACjB,gCAAgC,EAChC,wBAAwB,EACzB,qBAAoB;AACrB,OAAO,EA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;QACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK;YACpB,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,iDAAiD,CAAC;QACxD,uBAAA,IAAI,6CAAkB,EAAE,KAAxB,IAAI,EACF,iBAAiB,CACf,uCAAuC,YAAY,EAAE,EACrD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CACzD,CACF,CAAC;QAEF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","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 SubscriptionEligibilityArrayStruct,\n SubscriptionStruct,\n UpdatePaymentMethodCardResponseStruct,\n} from './SubscriptionService-structs.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 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 '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 * 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 subscription with a card payment method.\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 */\n async startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse> {\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 cacheTime: 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 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"]}
1
+ {"version":3,"file":"SubscriptionService.mjs","sourceRoot":"","sources":["../src/SubscriptionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAE9D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mCAAmC;AAGnE,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAI/C,OAAO,EACL,GAAG,EACH,UAAU,EACV,kCAAkC,EAClC,+BAA+B,EAChC,wBAAuB;AACxB,OAAO,EACL,iBAAiB,EACjB,gCAAgC,EAChC,wBAAwB,EACzB,qBAAo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iceCacheUpdatedEvent,\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 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 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 '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 * 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 cacheTime: 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"]}
@@ -43,6 +43,7 @@ var SubscriptionControllerErrorMessage;
43
43
  SubscriptionControllerErrorMessage["PaymentMethodNotCrypto"] = "SubscriptionController - Payment method is not crypto";
44
44
  SubscriptionControllerErrorMessage["ProductPriceNotFound"] = "SubscriptionController - Product price not found";
45
45
  SubscriptionControllerErrorMessage["SubscriptionNotValidForCryptoApproval"] = "SubscriptionController - Subscription is not valid for crypto approval";
46
+ SubscriptionControllerErrorMessage["CryptoApprovalRequiresShieldApprove"] = "SubscriptionController - Crypto approval is only supported for Shield ERC-20 approve transactions";
46
47
  SubscriptionControllerErrorMessage["LinkRewardsFailed"] = "SubscriptionController - Failed to link rewards";
47
48
  })(SubscriptionControllerErrorMessage || (exports.SubscriptionControllerErrorMessage = SubscriptionControllerErrorMessage = {}));
48
49
  var SubscriptionServiceErrorMessage;
@@ -52,6 +53,7 @@ var SubscriptionServiceErrorMessage;
52
53
  SubscriptionServiceErrorMessage["FailedToUncancelSubscription"] = "Failed to uncancel subscription";
53
54
  SubscriptionServiceErrorMessage["FailedToStartSubscriptionWithCard"] = "Failed to start subscription with card";
54
55
  SubscriptionServiceErrorMessage["FailedToStartSubscriptionWithCrypto"] = "Failed to start subscription with crypto";
56
+ SubscriptionServiceErrorMessage["InvalidCryptoAuthCombo"] = "Crypto subscription requires exactly one of rawTransaction (erc20_approval) or delegationHash (delegation)";
55
57
  SubscriptionServiceErrorMessage["FailedToUpdatePaymentMethodCard"] = "Failed to update payment method card";
56
58
  SubscriptionServiceErrorMessage["FailedToUpdatePaymentMethodCrypto"] = "Failed to update payment method crypto";
57
59
  SubscriptionServiceErrorMessage["FailedToGetSubscriptionsEligibilities"] = "Failed to get subscriptions eligibilities";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,0CAAmD;A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;AAEY,QAAA,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAK,CAAC,CAAC,YAAY;AAEvD,QAAA,4BAA4B,GAAG;IAC1C,gCAAqB,CAAC,MAAM;IAC5B,gCAAqB,CAAC,QAAQ;IAC9B,gCAAqB,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 LinkRewardsFailed = `${controllerName} - Failed to link rewards`,\n}\n\nexport enum SubscriptionServiceErrorMessage {\n FailedToGetSubscriptions = 'Failed to get subscriptions',\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 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
+ {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,0CAAmD;AAEtC,QAAA,cAAc,GAAG,wBAAwB,CAAC;AAEvD,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,kBAAW,CAAA;IACX,kBAAW,CAAA;IACX,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,mBAAH,GAAG,QAId;AAMD,MAAM,QAAQ,GAA8B;IAC1C,GAAG,EAAE;QACH,kBAAkB,EAAE,6CAA6C;KAClE;IACD,GAAG,EAAE;QACH,kBAAkB,EAAE,6CAA6C;KAClE;IACD,GAAG,EAAE;QACH,kBAAkB,EAAE,yCAAyC;KAC9D;CACF,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,GAAQ;IACjC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AALD,gCAKC;AAED,IAAY,kCAUX;AAVD,WAAY,kCAAkC;IAC5C,mHAAwE,CAAA;IACxE,2GAAgE,CAAA;IAChE,wIAA6F,CAAA;IAC7F,iLAAsI,CAAA;IACtI,sHAA2E,CAAA;IAC3E,+GAAoE,CAAA;IACpE,sJAA2G,CAAA;IAC3G,+KAAoI,CAAA;IACpI,2GAAgE,CAAA;AAClE,CAAC,EAVW,kCAAkC,kDAAlC,kCAAkC,QAU7C;AAED,IAAY,+BAgBX;AAhBD,WAAY,+BAA+B;IACzC,2FAAwD,CAAA;IACxD,+FAA4D,CAAA;IAC5D,mGAAgE,CAAA;IAChE,+GAA4E,CAAA;IAC5E,mHAAgF,CAAA;IAChF,wKAAqI,CAAA;IACrI,2GAAwE,CAAA;IACxE,+GAA4E,CAAA;IAC5E,sHAAmF,CAAA;IACnF,0FAAuD,CAAA;IACvD,iGAA8D,CAAA;IAC9D,4GAAyE,CAAA;IACzE,iFAA8C,CAAA;IAC9C,+EAA4C,CAAA;IAC5C,mGAAgE,CAAA;AAClE,CAAC,EAhBW,+BAA+B,+CAA/B,+BAA+B,QAgB1C;AAEY,QAAA,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAK,CAAC,CAAC,YAAY;AAEvD,QAAA,4BAA4B,GAAG;IAC1C,gCAAqB,CAAC,MAAM;IAC5B,gCAAqB,CAAC,QAAQ;IAC9B,gCAAqB,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 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"]}
@@ -23,6 +23,7 @@ export declare enum SubscriptionControllerErrorMessage {
23
23
  PaymentMethodNotCrypto = "SubscriptionController - Payment method is not crypto",
24
24
  ProductPriceNotFound = "SubscriptionController - Product price not found",
25
25
  SubscriptionNotValidForCryptoApproval = "SubscriptionController - Subscription is not valid for crypto approval",
26
+ CryptoApprovalRequiresShieldApprove = "SubscriptionController - Crypto approval is only supported for Shield ERC-20 approve transactions",
26
27
  LinkRewardsFailed = "SubscriptionController - Failed to link rewards"
27
28
  }
28
29
  export declare enum SubscriptionServiceErrorMessage {
@@ -31,6 +32,7 @@ export declare enum SubscriptionServiceErrorMessage {
31
32
  FailedToUncancelSubscription = "Failed to uncancel subscription",
32
33
  FailedToStartSubscriptionWithCard = "Failed to start subscription with card",
33
34
  FailedToStartSubscriptionWithCrypto = "Failed to start subscription with crypto",
35
+ InvalidCryptoAuthCombo = "Crypto subscription requires exactly one of rawTransaction (erc20_approval) or delegationHash (delegation)",
34
36
  FailedToUpdatePaymentMethodCard = "Failed to update payment method card",
35
37
  FailedToUpdatePaymentMethodCrypto = "Failed to update payment method crypto",
36
38
  FailedToGetSubscriptionsEligibilities = "Failed to get subscriptions eligibilities",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.cts","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;CAC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7F,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,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,UAI5B,CAAC"}
@@ -23,6 +23,7 @@ export declare enum SubscriptionControllerErrorMessage {
23
23
  PaymentMethodNotCrypto = "SubscriptionController - Payment method is not crypto",
24
24
  ProductPriceNotFound = "SubscriptionController - Product price not found",
25
25
  SubscriptionNotValidForCryptoApproval = "SubscriptionController - Subscription is not valid for crypto approval",
26
+ CryptoApprovalRequiresShieldApprove = "SubscriptionController - Crypto approval is only supported for Shield ERC-20 approve transactions",
26
27
  LinkRewardsFailed = "SubscriptionController - Failed to link rewards"
27
28
  }
28
29
  export declare enum SubscriptionServiceErrorMessage {
@@ -31,6 +32,7 @@ export declare enum SubscriptionServiceErrorMessage {
31
32
  FailedToUncancelSubscription = "Failed to uncancel subscription",
32
33
  FailedToStartSubscriptionWithCard = "Failed to start subscription with card",
33
34
  FailedToStartSubscriptionWithCrypto = "Failed to start subscription with crypto",
35
+ InvalidCryptoAuthCombo = "Crypto subscription requires exactly one of rawTransaction (erc20_approval) or delegationHash (delegation)",
34
36
  FailedToUpdatePaymentMethodCard = "Failed to update payment method card",
35
37
  FailedToUpdatePaymentMethodCrypto = "Failed to update payment method crypto",
36
38
  FailedToGetSubscriptionsEligibilities = "Failed to get subscriptions eligibilities",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.mts","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,iBAAiB,oDAA+C;CACjE;AAED,oBAAY,+BAA+B;IACzC,wBAAwB,gCAAgC;IACxD,0BAA0B,kCAAkC;IAC5D,4BAA4B,oCAAoC;IAChE,iCAAiC,2CAA2C;IAC5E,mCAAmC,6CAA6C;IAChF,+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,UAI5B,CAAC"}
1
+ {"version":3,"file":"constants.d.mts","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,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,UAI5B,CAAC"}
@@ -39,6 +39,7 @@ export var SubscriptionControllerErrorMessage;
39
39
  SubscriptionControllerErrorMessage["PaymentMethodNotCrypto"] = "SubscriptionController - Payment method is not crypto";
40
40
  SubscriptionControllerErrorMessage["ProductPriceNotFound"] = "SubscriptionController - Product price not found";
41
41
  SubscriptionControllerErrorMessage["SubscriptionNotValidForCryptoApproval"] = "SubscriptionController - Subscription is not valid for crypto approval";
42
+ SubscriptionControllerErrorMessage["CryptoApprovalRequiresShieldApprove"] = "SubscriptionController - Crypto approval is only supported for Shield ERC-20 approve transactions";
42
43
  SubscriptionControllerErrorMessage["LinkRewardsFailed"] = "SubscriptionController - Failed to link rewards";
43
44
  })(SubscriptionControllerErrorMessage || (SubscriptionControllerErrorMessage = {}));
44
45
  export var SubscriptionServiceErrorMessage;
@@ -48,6 +49,7 @@ export var SubscriptionServiceErrorMessage;
48
49
  SubscriptionServiceErrorMessage["FailedToUncancelSubscription"] = "Failed to uncancel subscription";
49
50
  SubscriptionServiceErrorMessage["FailedToStartSubscriptionWithCard"] = "Failed to start subscription with card";
50
51
  SubscriptionServiceErrorMessage["FailedToStartSubscriptionWithCrypto"] = "Failed to start subscription with crypto";
52
+ SubscriptionServiceErrorMessage["InvalidCryptoAuthCombo"] = "Crypto subscription requires exactly one of rawTransaction (erc20_approval) or delegationHash (delegation)";
51
53
  SubscriptionServiceErrorMessage["FailedToUpdatePaymentMethodCard"] = "Failed to update payment method card";
52
54
  SubscriptionServiceErrorMessage["FailedToUpdatePaymentMethodCrypto"] = "Failed to update payment method crypto";
53
55
  SubscriptionServiceErrorMessage["FailedToGetSubscriptionsEligibilities"] = "Failed to get subscriptions eligibilities";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,oBAAmB;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEvD,MAAM,CAAN,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,kBAAW,CAAA;IACX,kBAAW,CAAA;IACX,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,KAAH,GAAG,QAId;AAMD,MAAM,QAAQ,GAA8B;IAC1C,GAAG,EAAE;QACH,kBAAkB,EAAE,6CAA6C;KAClE;IACD,GAAG,EAAE;QACH,kBAAkB,EAAE,6CAA6C;KAClE;IACD,GAAG,EAAE;QACH,kBAAkB,EAAE,yCAAyC;KAC9D;CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,CAAN,IAAY,kCASX;AATD,WAAY,kCAAkC;IAC5C,mHAAwE,CAAA;IACxE,2GAAgE,CAAA;IAChE,wIAA6F,CAAA;IAC7F,iLAAsI,CAAA;IACtI,sHAA2E,CAAA;IAC3E,+GAAoE,CAAA;IACpE,sJAA2G,CAAA;IAC3G,2GAAgE,CAAA;AAClE,CAAC,EATW,kCAAkC,KAAlC,kCAAkC,QAS7C;AAED,MAAM,CAAN,IAAY,+BAeX;AAfD,WAAY,+BAA+B;IACzC,2FAAwD,CAAA;IACxD,+FAA4D,CAAA;IAC5D,mGAAgE,CAAA;IAChE,+GAA4E,CAAA;IAC5E,mHAAgF,CAAA;IAChF,2GAAwE,CAAA;IACxE,+GAA4E,CAAA;IAC5E,sHAAmF,CAAA;IACnF,0FAAuD,CAAA;IACvD,iGAA8D,CAAA;IAC9D,4GAAyE,CAAA;IACzE,iFAA8C,CAAA;IAC9C,+EAA4C,CAAA;IAC5C,mGAAgE,CAAA;AAClE,CAAC,EAfW,+BAA+B,KAA/B,+BAA+B,QAe1C;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAK,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 LinkRewardsFailed = `${controllerName} - Failed to link rewards`,\n}\n\nexport enum SubscriptionServiceErrorMessage {\n FailedToGetSubscriptions = 'Failed to get subscriptions',\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 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
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,oBAAmB;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEvD,MAAM,CAAN,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,kBAAW,CAAA;IACX,kBAAW,CAAA;IACX,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,KAAH,GAAG,QAId;AAMD,MAAM,QAAQ,GAA8B;IAC1C,GAAG,EAAE;QACH,kBAAkB,EAAE,6CAA6C;KAClE;IACD,GAAG,EAAE;QACH,kBAAkB,EAAE,6CAA6C;KAClE;IACD,GAAG,EAAE;QACH,kBAAkB,EAAE,yCAAyC;KAC9D;CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,CAAN,IAAY,kCAUX;AAVD,WAAY,kCAAkC;IAC5C,mHAAwE,CAAA;IACxE,2GAAgE,CAAA;IAChE,wIAA6F,CAAA;IAC7F,iLAAsI,CAAA;IACtI,sHAA2E,CAAA;IAC3E,+GAAoE,CAAA;IACpE,sJAA2G,CAAA;IAC3G,+KAAoI,CAAA;IACpI,2GAAgE,CAAA;AAClE,CAAC,EAVW,kCAAkC,KAAlC,kCAAkC,QAU7C;AAED,MAAM,CAAN,IAAY,+BAgBX;AAhBD,WAAY,+BAA+B;IACzC,2FAAwD,CAAA;IACxD,+FAA4D,CAAA;IAC5D,mGAAgE,CAAA;IAChE,+GAA4E,CAAA;IAC5E,mHAAgF,CAAA;IAChF,wKAAqI,CAAA;IACrI,2GAAwE,CAAA;IACxE,+GAA4E,CAAA;IAC5E,sHAAmF,CAAA;IACnF,0FAAuD,CAAA;IACvD,iGAA8D,CAAA;IAC9D,4GAAyE,CAAA;IACzE,iFAA8C,CAAA;IAC9C,+EAA4C,CAAA;IAC5C,mGAAgE,CAAA;AAClE,CAAC,EAhBW,+BAA+B,KAA/B,+BAA+B,QAgB1C;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAK,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 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"]}
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SUBSCRIPTION_URL = exports.subscriptionServiceName = exports.SubscriptionService = exports.SubscriptionServiceErrorMessage = exports.SubscriptionControllerErrorMessage = exports.Env = exports.SubscriptionServiceError = exports.MODAL_TYPE = exports.BALANCE_CATEGORIES = exports.COHORT_NAMES = exports.SubscriptionUserEvent = exports.PAYMENT_TYPES = exports.RECURRING_INTERVALS = exports.PRODUCT_TYPES = exports.SUBSCRIPTION_STATUSES = exports.CRYPTO_PAYMENT_METHOD_ERRORS = exports.CANCEL_TYPES = exports.getDefaultSubscriptionControllerState = exports.SubscriptionController = void 0;
3
+ exports.SUBSCRIPTION_URL = exports.subscriptionServiceName = exports.SubscriptionService = exports.SubscriptionServiceErrorMessage = exports.SubscriptionControllerErrorMessage = exports.Env = exports.SubscriptionServiceError = exports.MODAL_TYPE = exports.BALANCE_CATEGORIES = exports.COHORT_NAMES = exports.SubscriptionUserEvent = exports.CRYPTO_AUTH_METHODS = exports.PAYMENT_TYPES = exports.RECURRING_INTERVALS = exports.PRODUCT_TYPES = exports.SUBSCRIPTION_STATUSES = exports.CRYPTO_PAYMENT_METHOD_ERRORS = exports.CANCEL_TYPES = exports.getDefaultSubscriptionControllerState = exports.SubscriptionController = void 0;
4
4
  var SubscriptionController_js_1 = require("./SubscriptionController.cjs");
5
5
  Object.defineProperty(exports, "SubscriptionController", { enumerable: true, get: function () { return SubscriptionController_js_1.SubscriptionController; } });
6
6
  Object.defineProperty(exports, "getDefaultSubscriptionControllerState", { enumerable: true, get: function () { return SubscriptionController_js_1.getDefaultSubscriptionControllerState; } });
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "SUBSCRIPTION_STATUSES", { enumerable: true, get:
11
11
  Object.defineProperty(exports, "PRODUCT_TYPES", { enumerable: true, get: function () { return types_js_1.PRODUCT_TYPES; } });
12
12
  Object.defineProperty(exports, "RECURRING_INTERVALS", { enumerable: true, get: function () { return types_js_1.RECURRING_INTERVALS; } });
13
13
  Object.defineProperty(exports, "PAYMENT_TYPES", { enumerable: true, get: function () { return types_js_1.PAYMENT_TYPES; } });
14
+ Object.defineProperty(exports, "CRYPTO_AUTH_METHODS", { enumerable: true, get: function () { return types_js_1.CRYPTO_AUTH_METHODS; } });
14
15
  Object.defineProperty(exports, "SubscriptionUserEvent", { enumerable: true, get: function () { return types_js_1.SubscriptionUserEvent; } });
15
16
  Object.defineProperty(exports, "COHORT_NAMES", { enumerable: true, get: function () { return types_js_1.COHORT_NAMES; } });
16
17
  Object.defineProperty(exports, "BALANCE_CATEGORIES", { enumerable: true, get: function () { return types_js_1.BALANCE_CATEGORIES; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAkCA,0EAGqC;AAFnC,mIAAA,sBAAsB,OAAA;AACtB,kJAAA,qCAAqC,OAAA;AAiDvC,wCAWoB;AAVlB,wGAAA,YAAY,OAAA;AACZ,wHAAA,4BAA4B,OAAA;AAC5B,iHAAA,qBAAqB,OAAA;AACrB,yGAAA,aAAa,OAAA;AACb,+GAAA,mBAAmB,OAAA;AACnB,yGAAA,aAAa,OAAA;AACb,iHAAA,qBAAqB,OAAA;AACrB,wGAAA,YAAY,OAAA;AACZ,8GAAA,kBAAkB,OAAA;AAClB,sGAAA,UAAU,OAAA;AAEZ,0CAAuD;AAA9C,qHAAA,wBAAwB,OAAA;AACjC,gDAIwB;AAHtB,mGAAA,GAAG,OAAA;AACH,kIAAA,kCAAkC,OAAA;AAClC,+HAAA,+BAA+B,OAAA;AAWjC,oEAIkC;AAHhC,6HAAA,mBAAmB,OAAA;AACnB,iIAAA,WAAW,OAA2B;AACtC,0HAAA,gBAAgB,OAAA","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 SubscriptionControllerGetSubscriptionByProductAction,\n SubscriptionControllerGetSubscriptionsEligibilitiesAction,\n SubscriptionControllerCancelSubscriptionAction,\n SubscriptionControllerUnCancelSubscriptionAction,\n SubscriptionControllerStartShieldSubscriptionWithCardAction,\n SubscriptionControllerStartSubscriptionWithCryptoAction,\n SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction,\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 AuthUtils,\n CancelSubscriptionRequest,\n CancelType,\n ISubscriptionService,\n StartCryptoSubscriptionRequest,\n StartCryptoSubscriptionResponse,\n StartSubscriptionRequest,\n StartSubscriptionResponse,\n GetCryptoApproveTransactionRequest,\n GetCryptoApproveTransactionResponse,\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 ChainPaymentInfo,\n Currency,\n PricingPaymentMethod,\n PricingResponse,\n UpdatePaymentMethodOpts,\n BillingPortalResponse,\n CryptoPaymentMethodError,\n UpdatePaymentMethodCryptoRequest,\n UpdatePaymentMethodCardRequest,\n UpdatePaymentMethodCardResponse,\n CachedLastSelectedPaymentMethod,\n SubmitSponsorshipIntentsMethodParams,\n Cohort,\n CohortName,\n BalanceCategory,\n AssignCohortRequest,\n GetSubscriptionsEligibilitiesRequest,\n ModalType,\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 SubscriptionUserEvent,\n COHORT_NAMES,\n BALANCE_CATEGORIES,\n MODAL_TYPE,\n} from './types.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 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"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAkCA,0EAGqC;AAFnC,mIAAA,sBAAsB,OAAA;AACtB,kJAAA,qCAAqC,OAAA;AA0DvC,wCAYoB;AAXlB,wGAAA,YAAY,OAAA;AACZ,wHAAA,4BAA4B,OAAA;AAC5B,iHAAA,qBAAqB,OAAA;AACrB,yGAAA,aAAa,OAAA;AACb,+GAAA,mBAAmB,OAAA;AACnB,yGAAA,aAAa,OAAA;AACb,+GAAA,mBAAmB,OAAA;AACnB,iHAAA,qBAAqB,OAAA;AACrB,wGAAA,YAAY,OAAA;AACZ,8GAAA,kBAAkB,OAAA;AAClB,sGAAA,UAAU,OAAA;AAEZ,0CAAuD;AAA9C,qHAAA,wBAAwB,OAAA;AACjC,gDAIwB;AAHtB,mGAAA,GAAG,OAAA;AACH,kIAAA,kCAAkC,OAAA;AAClC,+HAAA,+BAA+B,OAAA;AAWjC,oEAIkC;AAHhC,6HAAA,mBAAmB,OAAA;AACnB,iIAAA,WAAW,OAA2B;AACtC,0HAAA,gBAAgB,OAAA","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 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 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} 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} from './types.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 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"]}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  export type { SubscriptionControllerActions, SubscriptionControllerState, SubscriptionControllerEvents, SubscriptionControllerGetStateAction, SubscriptionControllerMessenger, SubscriptionControllerOptions, SubscriptionControllerStateChangeEvent, } from "./SubscriptionController.cjs";
2
- export type { SubscriptionControllerGetPricingAction, SubscriptionControllerGetSubscriptionsAction, SubscriptionControllerGetSubscriptionByProductAction, SubscriptionControllerGetSubscriptionsEligibilitiesAction, SubscriptionControllerCancelSubscriptionAction, SubscriptionControllerUnCancelSubscriptionAction, SubscriptionControllerStartShieldSubscriptionWithCardAction, SubscriptionControllerStartSubscriptionWithCryptoAction, SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction, SubscriptionControllerGetCryptoApproveTransactionParamsAction, SubscriptionControllerUpdatePaymentMethodAction, SubscriptionControllerGetBillingPortalUrlAction, SubscriptionControllerCacheLastSelectedPaymentMethodAction, SubscriptionControllerClearLastSelectedPaymentMethodAction, SubscriptionControllerSubmitSponsorshipIntentsAction, SubscriptionControllerSubmitUserEventAction, SubscriptionControllerAssignUserToCohortAction, SubscriptionControllerLinkRewardsAction, SubscriptionControllerGetTokenApproveAmountAction, SubscriptionControllerGetTokenMinimumBalanceAmountAction, SubscriptionControllerClearStateAction, SubscriptionControllerTriggerAccessTokenRefreshAction, SubscriptionControllerStopAllPollingAction, } from "./SubscriptionController-method-action-types.cjs";
2
+ export type { SubscriptionControllerGetPricingAction, SubscriptionControllerGetSubscriptionsAction, 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.cjs";
3
3
  export { SubscriptionController, getDefaultSubscriptionControllerState, } from "./SubscriptionController.cjs";
4
- export type { SubscriptionApiError, Subscription, AuthUtils, CancelSubscriptionRequest, CancelType, ISubscriptionService, StartCryptoSubscriptionRequest, StartCryptoSubscriptionResponse, StartSubscriptionRequest, StartSubscriptionResponse, GetCryptoApproveTransactionRequest, GetCryptoApproveTransactionResponse, SubscriptionCardPaymentMethod, SubscriptionCryptoPaymentMethod, SubscriptionPaymentMethod, SubmitUserEventRequest, SubmitSponsorshipIntentsRequest, SubscriptionEligibility, SubscriptionUserEventType, RecurringInterval, SubscriptionStatus, PaymentType, Product, ProductType, ProductPrice, ProductPricing, TokenPaymentInfo, ChainPaymentInfo, Currency, PricingPaymentMethod, PricingResponse, UpdatePaymentMethodOpts, BillingPortalResponse, CryptoPaymentMethodError, UpdatePaymentMethodCryptoRequest, UpdatePaymentMethodCardRequest, UpdatePaymentMethodCardResponse, CachedLastSelectedPaymentMethod, SubmitSponsorshipIntentsMethodParams, Cohort, CohortName, BalanceCategory, AssignCohortRequest, GetSubscriptionsEligibilitiesRequest, ModalType, } from "./types.cjs";
5
- export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE, } from "./types.cjs";
4
+ export type { SubscriptionApiError, Subscription, 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, } from "./types.cjs";
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, } from "./types.cjs";
6
6
  export { SubscriptionServiceError } from "./errors.cjs";
7
7
  export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from "./constants.cjs";
8
8
  export type { SubscriptionServiceOptions, SubscriptionServiceMessenger, SubscriptionServiceActions, SubscriptionServiceEvents, SubscriptionServiceCacheUpdatedEvent, SubscriptionServiceGranularCacheUpdatedEvent, SubscriptionServiceInvalidateQueriesAction, } from "./SubscriptionService.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,+BAA+B,EAC/B,6BAA6B,EAC7B,sCAAsC,GACvC,qCAAoC;AACrC,YAAY,EACV,sCAAsC,EACtC,4CAA4C,EAC5C,oDAAoD,EACpD,yDAAyD,EACzD,8CAA8C,EAC9C,gDAAgD,EAChD,2DAA2D,EAC3D,uDAAuD,EACvD,kEAAkE,EAClE,6DAA6D,EAC7D,+CAA+C,EAC/C,+CAA+C,EAC/C,0DAA0D,EAC1D,0DAA0D,EAC1D,oDAAoD,EACpD,2CAA2C,EAC3C,8CAA8C,EAC9C,uCAAuC,EACvC,iDAAiD,EACjD,wDAAwD,EACxD,sCAAsC,EACtC,qDAAqD,EACrD,0CAA0C,GAC3C,yDAAwD;AACzD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAoC;AACrC,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,SAAS,EACT,yBAAyB,EACzB,UAAU,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,kCAAkC,EAClC,mCAAmC,EACnC,6BAA6B,EAC7B,+BAA+B,EAC/B,yBAAyB,EACzB,sBAAsB,EACtB,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,gCAAgC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,oCAAoC,EACpC,MAAM,EACN,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,oCAAoC,EACpC,SAAS,GACV,oBAAmB;AACpB,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,UAAU,GACX,oBAAmB;AACpB,OAAO,EAAE,wBAAwB,EAAE,qBAAoB;AACvD,OAAO,EACL,GAAG,EACH,kCAAkC,EAClC,+BAA+B,GAChC,wBAAuB;AACxB,YAAY,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,oCAAoC,EACpC,4CAA4C,EAC5C,0CAA0C,GAC3C,kCAAiC;AAClC,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,GACjB,kCAAiC;AAClC,YAAY,EACV,yCAAyC,EACzC,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,sDAAqD"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,+BAA+B,EAC/B,6BAA6B,EAC7B,sCAAsC,GACvC,qCAAoC;AACrC,YAAY,EACV,sCAAsC,EACtC,4CAA4C,EAC5C,oDAAoD,EACpD,yDAAyD,EACzD,8CAA8C,EAC9C,gDAAgD,EAChD,qDAAqD,EACrD,uDAAuD,EACvD,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B,OAAO,EAAE,wBAAwB,EAAE,qBAAoB;AACvD,OAAO,EACL,GAAG,EACH,kCAAkC,EAClC,+BAA+B,GAChC,wBAAuB;AACxB,YAAY,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,oCAAoC,EACpC,4CAA4C,EAC5C,0CAA0C,GAC3C,kCAAiC;AAClC,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,GACjB,kCAAiC;AAClC,YAAY,EACV,yCAAyC,EACzC,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,sDAAqD"}
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  export type { SubscriptionControllerActions, SubscriptionControllerState, SubscriptionControllerEvents, SubscriptionControllerGetStateAction, SubscriptionControllerMessenger, SubscriptionControllerOptions, SubscriptionControllerStateChangeEvent, } from "./SubscriptionController.mjs";
2
- export type { SubscriptionControllerGetPricingAction, SubscriptionControllerGetSubscriptionsAction, SubscriptionControllerGetSubscriptionByProductAction, SubscriptionControllerGetSubscriptionsEligibilitiesAction, SubscriptionControllerCancelSubscriptionAction, SubscriptionControllerUnCancelSubscriptionAction, SubscriptionControllerStartShieldSubscriptionWithCardAction, SubscriptionControllerStartSubscriptionWithCryptoAction, SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction, SubscriptionControllerGetCryptoApproveTransactionParamsAction, SubscriptionControllerUpdatePaymentMethodAction, SubscriptionControllerGetBillingPortalUrlAction, SubscriptionControllerCacheLastSelectedPaymentMethodAction, SubscriptionControllerClearLastSelectedPaymentMethodAction, SubscriptionControllerSubmitSponsorshipIntentsAction, SubscriptionControllerSubmitUserEventAction, SubscriptionControllerAssignUserToCohortAction, SubscriptionControllerLinkRewardsAction, SubscriptionControllerGetTokenApproveAmountAction, SubscriptionControllerGetTokenMinimumBalanceAmountAction, SubscriptionControllerClearStateAction, SubscriptionControllerTriggerAccessTokenRefreshAction, SubscriptionControllerStopAllPollingAction, } from "./SubscriptionController-method-action-types.mjs";
2
+ export type { SubscriptionControllerGetPricingAction, SubscriptionControllerGetSubscriptionsAction, 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.mjs";
3
3
  export { SubscriptionController, getDefaultSubscriptionControllerState, } from "./SubscriptionController.mjs";
4
- export type { SubscriptionApiError, Subscription, AuthUtils, CancelSubscriptionRequest, CancelType, ISubscriptionService, StartCryptoSubscriptionRequest, StartCryptoSubscriptionResponse, StartSubscriptionRequest, StartSubscriptionResponse, GetCryptoApproveTransactionRequest, GetCryptoApproveTransactionResponse, SubscriptionCardPaymentMethod, SubscriptionCryptoPaymentMethod, SubscriptionPaymentMethod, SubmitUserEventRequest, SubmitSponsorshipIntentsRequest, SubscriptionEligibility, SubscriptionUserEventType, RecurringInterval, SubscriptionStatus, PaymentType, Product, ProductType, ProductPrice, ProductPricing, TokenPaymentInfo, ChainPaymentInfo, Currency, PricingPaymentMethod, PricingResponse, UpdatePaymentMethodOpts, BillingPortalResponse, CryptoPaymentMethodError, UpdatePaymentMethodCryptoRequest, UpdatePaymentMethodCardRequest, UpdatePaymentMethodCardResponse, CachedLastSelectedPaymentMethod, SubmitSponsorshipIntentsMethodParams, Cohort, CohortName, BalanceCategory, AssignCohortRequest, GetSubscriptionsEligibilitiesRequest, ModalType, } from "./types.mjs";
5
- export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE, } from "./types.mjs";
4
+ export type { SubscriptionApiError, Subscription, 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, } from "./types.mjs";
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, } from "./types.mjs";
6
6
  export { SubscriptionServiceError } from "./errors.mjs";
7
7
  export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from "./constants.mjs";
8
8
  export type { SubscriptionServiceOptions, SubscriptionServiceMessenger, SubscriptionServiceActions, SubscriptionServiceEvents, SubscriptionServiceCacheUpdatedEvent, SubscriptionServiceGranularCacheUpdatedEvent, SubscriptionServiceInvalidateQueriesAction, } from "./SubscriptionService.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,+BAA+B,EAC/B,6BAA6B,EAC7B,sCAAsC,GACvC,qCAAoC;AACrC,YAAY,EACV,sCAAsC,EACtC,4CAA4C,EAC5C,oDAAoD,EACpD,yDAAyD,EACzD,8CAA8C,EAC9C,gDAAgD,EAChD,2DAA2D,EAC3D,uDAAuD,EACvD,kEAAkE,EAClE,6DAA6D,EAC7D,+CAA+C,EAC/C,+CAA+C,EAC/C,0DAA0D,EAC1D,0DAA0D,EAC1D,oDAAoD,EACpD,2CAA2C,EAC3C,8CAA8C,EAC9C,uCAAuC,EACvC,iDAAiD,EACjD,wDAAwD,EACxD,sCAAsC,EACtC,qDAAqD,EACrD,0CAA0C,GAC3C,yDAAwD;AACzD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAoC;AACrC,YAAY,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D,wCAAwC,EACxC,2CAA2C,EAC3C,iDAAiD,EACjD,oCAAoC,EACpC,mCAAmC,EACnC,4CAA4C,GAC7C,sDAAqD"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,+BAA+B,EAC/B,6BAA6B,EAC7B,sCAAsC,GACvC,qCAAoC;AACrC,YAAY,EACV,sCAAsC,EACtC,4CAA4C,EAC5C,oDAAoD,EACpD,yDAAyD,EACzD,8CAA8C,EAC9C,gDAAgD,EAChD,qDAAqD,EACrD,uDAAuD,EACvD,4DAA4D,EAC5D,6DAA6D,EAC7D,+CAA+C,EAC/C,+CAA+C,EAC/C,0DAA0D,EAC1D,0DAA0D,EAC1D,oDAAoD,EACpD,2CAA2C,EAC3C,8CAA8C,EAC9C,uCAAuC,EACvC,iDAAiD,EACjD,wDAAwD,EACxD,sCAAsC,EACtC,qDAAqD,EACrD,0CAA0C,GAC3C,yDAAwD;AACzD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAoC;AACrC,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,SAAS,EACT,yBAAyB,EACzB,UAAU,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,wCAAwC,EACxC,mCAAmC,EACnC,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,kCAAkC,EAClC,mCAAmC,EACnC,uCAAuC,EACvC,6BAA6B,EAC7B,+BAA+B,EAC/B,yBAAyB,EACzB,sBAAsB,EACtB,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,gCAAgC,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,GACV,oBAAmB;AACpB,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,UAAU,GACX,oBAAmB;AACpB,OAAO,EAAE,wBAAwB,EAAE,qBAAoB;AACvD,OAAO,EACL,GAAG,EACH,kCAAkC,EAClC,+BAA+B,GAChC,wBAAuB;AACxB,YAAY,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,oCAAoC,EACpC,4CAA4C,EAC5C,0CAA0C,GAC3C,kCAAiC;AAClC,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,GACjB,kCAAiC;AAClC,YAAY,EACV,yCAAyC,EACzC,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,sDAAqD"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  export { SubscriptionController, getDefaultSubscriptionControllerState } from "./SubscriptionController.mjs";
2
- export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE } from "./types.mjs";
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 } from "./types.mjs";
3
3
  export { SubscriptionServiceError } from "./errors.mjs";
4
4
  export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage } from "./constants.mjs";
5
5
  export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL } from "./SubscriptionService.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACtC,qCAAoC;AAgDrC,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACX,oBAAmB;AACpB,OAAO,EAAE,wBAAwB,EAAE,qBAAoB;AACvD,OAAO,EACL,GAAG,EACH,kCAAkC,EAClC,+BAA+B,EAChC,wBAAuB;AAUxB,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,EACjB,kCAAiC","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 SubscriptionControllerGetSubscriptionByProductAction,\n SubscriptionControllerGetSubscriptionsEligibilitiesAction,\n SubscriptionControllerCancelSubscriptionAction,\n SubscriptionControllerUnCancelSubscriptionAction,\n SubscriptionControllerStartShieldSubscriptionWithCardAction,\n SubscriptionControllerStartSubscriptionWithCryptoAction,\n SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction,\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 AuthUtils,\n CancelSubscriptionRequest,\n CancelType,\n ISubscriptionService,\n StartCryptoSubscriptionRequest,\n StartCryptoSubscriptionResponse,\n StartSubscriptionRequest,\n StartSubscriptionResponse,\n GetCryptoApproveTransactionRequest,\n GetCryptoApproveTransactionResponse,\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 ChainPaymentInfo,\n Currency,\n PricingPaymentMethod,\n PricingResponse,\n UpdatePaymentMethodOpts,\n BillingPortalResponse,\n CryptoPaymentMethodError,\n UpdatePaymentMethodCryptoRequest,\n UpdatePaymentMethodCardRequest,\n UpdatePaymentMethodCardResponse,\n CachedLastSelectedPaymentMethod,\n SubmitSponsorshipIntentsMethodParams,\n Cohort,\n CohortName,\n BalanceCategory,\n AssignCohortRequest,\n GetSubscriptionsEligibilitiesRequest,\n ModalType,\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 SubscriptionUserEvent,\n COHORT_NAMES,\n BALANCE_CATEGORIES,\n MODAL_TYPE,\n} from './types.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 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"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACtC,qCAAoC;AAyDrC,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACX,oBAAmB;AACpB,OAAO,EAAE,wBAAwB,EAAE,qBAAoB;AACvD,OAAO,EACL,GAAG,EACH,kCAAkC,EAClC,+BAA+B,EAChC,wBAAuB;AAUxB,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,EACjB,kCAAiC","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 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 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} 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} from './types.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 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"]}
package/dist/types.cjs CHANGED
@@ -1,8 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubscriptionUserEvent = exports.BALANCE_CATEGORIES = exports.COHORT_NAMES = exports.MODAL_TYPE = exports.CRYPTO_PAYMENT_METHOD_ERRORS = exports.CANCEL_TYPES = exports.SUBSCRIPTION_STATUSES = exports.RECURRING_INTERVALS = exports.PAYMENT_TYPES = exports.PRODUCT_TYPES = void 0;
3
+ exports.SubscriptionUserEvent = exports.BALANCE_CATEGORIES = exports.COHORT_NAMES = exports.MODAL_TYPE = exports.CRYPTO_PAYMENT_METHOD_ERRORS = exports.CANCEL_TYPES = exports.SUBSCRIPTION_STATUSES = exports.RECURRING_INTERVALS = exports.PAYMENT_TYPES = exports.CRYPTO_AUTH_METHODS = exports.PRODUCT_TYPES = void 0;
4
+ /**
5
+ * Supported subscription products.
6
+ */
4
7
  exports.PRODUCT_TYPES = {
8
+ /**
9
+ * MetaMask Shield.
10
+ */
5
11
  SHIELD: 'shield',
12
+ /**
13
+ * Money Account Plus (delegation-based crypto billing).
14
+ */
15
+ MONEY_ACCOUNT_PLUS: 'money_account_plus',
16
+ };
17
+ /**
18
+ * How a crypto subscription is authorized.
19
+ *
20
+ * Use `erc20_approval` with `rawTransaction` (e.g. Shield). Use `delegation`
21
+ * with `delegationHash` (e.g. Money Account Plus).
22
+ */
23
+ exports.CRYPTO_AUTH_METHODS = {
24
+ /**
25
+ * User signs an ERC-20 approve transaction.
26
+ */
27
+ ERC20_APPROVAL: 'erc20_approval',
28
+ /**
29
+ * User authorizes via a stored delegation hash.
30
+ */
31
+ DELEGATION: 'delegation',
6
32
  };
7
33
  exports.PAYMENT_TYPES = {
8
34
  byCard: 'card',