@metamask-previews/subscription-controller 3.3.0-preview-ba016213 → 3.3.0-preview-29587976

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionService.mjs","sourceRoot":"","sources":["../src/SubscriptionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,mCAAmC;AAEzD,OAAO,EACL,UAAU,EACV,kCAAkC,EAEnC,wBAAoB;AACrB,OAAO,EAAE,wBAAwB,EAAE,qBAAiB;AAyBpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAQ,EAAE,IAAY,EAAE,EAAE,CACzD,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,kBAAkB,OAAO,IAAI,EAAE,CAAC;AAErD,MAAM,OAAO,mBAAmB;IAK9B,YAAY,MAAiC;;QAJpC,2CAAU;QAKjB,uBAAA,IAAI,4BAAQ,MAAM,CAAC,GAAG,MAAA,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,GAAG,eAAe,CAAC;QAC7B,OAAO,MAAM,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,MAExB;QACC,MAAM,IAAI,GAAG,iBAAiB,MAAM,CAAC,cAAc,SAAS,CAAC;QAC7D,OAAO,MAAM,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,MAE1B;QACC,MAAM,IAAI,GAAG,iBAAiB,MAAM,CAAC,cAAc,WAAW,CAAC;QAC/D,OAAO,MAAM,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EA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EvD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;YACjD,MAAM;YACN,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,OAAO;aACX;YACD,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;SAC9C,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,YAAY,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAExE,MAAM,IAAI,wBAAwB,CAChC,2BAA2B,YAAY,EAAE,CAC1C,CAAC;IACJ,CAAC;AACH,CAAC,gDAED,KAAK;IACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;IAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\n\nimport {\n getEnvUrls,\n SubscriptionControllerErrorMessage,\n type Env,\n} from './constants';\nimport { SubscriptionServiceError } from './errors';\nimport type {\n AuthUtils,\n BillingPortalResponse,\n GetSubscriptionsResponse,\n ISubscriptionService,\n PricingResponse,\n SubscriptionEligibility,\n StartCryptoSubscriptionRequest,\n StartCryptoSubscriptionResponse,\n StartSubscriptionRequest,\n StartSubscriptionResponse,\n SubmitUserEventRequest,\n Subscription,\n UpdatePaymentMethodCardRequest,\n UpdatePaymentMethodCardResponse,\n UpdatePaymentMethodCryptoRequest,\n SubmitSponsorshipIntentsRequest,\n} from './types';\n\nexport type SubscriptionServiceConfig = {\n env: Env;\n auth: AuthUtils;\n};\n\nexport const SUBSCRIPTION_URL = (env: Env, path: string) =>\n `${getEnvUrls(env).subscriptionApiUrl}/v1/${path}`;\n\nexport class SubscriptionService implements ISubscriptionService {\n readonly #env: Env;\n\n public authUtils: AuthUtils;\n\n constructor(config: SubscriptionServiceConfig) {\n this.#env = config.env;\n this.authUtils = config.auth;\n }\n\n async getSubscriptions(): Promise<GetSubscriptionsResponse> {\n const path = 'subscriptions';\n return await this.#makeRequest(path);\n }\n\n async cancelSubscription(params: {\n subscriptionId: string;\n }): Promise<Subscription> {\n const path = `subscriptions/${params.subscriptionId}/cancel`;\n return await this.#makeRequest(path, 'POST', {});\n }\n\n async unCancelSubscription(params: {\n subscriptionId: string;\n }): Promise<Subscription> {\n const path = `subscriptions/${params.subscriptionId}/uncancel`;\n return await this.#makeRequest(path, 'POST', {});\n }\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 const path = 'subscriptions/card';\n\n return await this.#makeRequest(path, 'POST', request);\n }\n\n async startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse> {\n const path = 'subscriptions/crypto';\n return await this.#makeRequest(path, 'POST', request);\n }\n\n async updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse> {\n const path = `subscriptions/${request.subscriptionId}/payment-method/card`;\n return await this.#makeRequest<UpdatePaymentMethodCardResponse>(\n path,\n 'PATCH',\n {\n ...request,\n subscriptionId: undefined,\n },\n );\n }\n\n async updatePaymentMethodCrypto(request: UpdatePaymentMethodCryptoRequest) {\n const path = `subscriptions/${request.subscriptionId}/payment-method/crypto`;\n await this.#makeRequest(path, 'PATCH', {\n ...request,\n subscriptionId: undefined,\n });\n }\n\n /**\n * Get the eligibility for a shield subscription.\n *\n * @returns The eligibility for a shield subscription\n */\n async getSubscriptionsEligibilities(): Promise<SubscriptionEligibility[]> {\n const path = 'subscriptions/eligibility';\n const results = await this.#makeRequest<SubscriptionEligibility[]>(path);\n return results.map((result) => ({\n ...result,\n canSubscribe: result.canSubscribe || false,\n canViewEntryModal: result.canViewEntryModal || 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 }\n */\n async submitUserEvent(request: SubmitUserEventRequest): Promise<void> {\n const path = 'user-events';\n await this.#makeRequest(path, 'POST', request);\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 path = 'transaction-sponsorship/intents';\n await this.#makeRequest(path, 'POST', request);\n }\n\n async #makeRequest<Result>(\n path: string,\n method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH' = 'GET',\n body?: Record<string, unknown>,\n ): Promise<Result> {\n try {\n const headers = await this.#getAuthorizationHeader();\n const url = new URL(SUBSCRIPTION_URL(this.#env, path));\n\n const response = await handleFetch(url.toString(), {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n body: body ? JSON.stringify(body) : undefined,\n });\n\n return response;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n\n throw new SubscriptionServiceError(\n `failed to make request. ${errorMessage}`,\n );\n }\n }\n\n async #getAuthorizationHeader(): Promise<{ Authorization: string }> {\n const accessToken = await this.authUtils.getAccessToken();\n return { Authorization: `Bearer ${accessToken}` };\n }\n\n async getPricing(): Promise<PricingResponse> {\n const path = 'pricing';\n return await this.#makeRequest<PricingResponse>(path);\n }\n\n async getBillingPortalUrl(): Promise<BillingPortalResponse> {\n const path = 'billing-portal';\n return await this.#makeRequest<BillingPortalResponse>(path);\n }\n}\n"]}
1
+ {"version":3,"file":"SubscriptionService.mjs","sourceRoot":"","sources":["../src/SubscriptionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,mCAAmC;AAEzD,OAAO,EACL,UAAU,EACV,kCAAkC,EAEnC,wBAAoB;AACrB,OAAO,EAAE,wBAAwB,EAAE,qBAAiB;AA2BpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAQ,EAAE,IAAY,EAAE,EAAE,CACzD,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,kBAAkB,OAAO,IAAI,EAAE,CAAC;AAErD,MAAM,OAAO,mBAAmB;IAK9B,YAAY,MAAiC;;QAJpC,2CAAU;QAKjB,uBAAA,IAAI,4BAAQ,MAAM,CAAC,GAAG,MAAA,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,GAAG,eAAe,CAAC;QAC7B,OAAO,MAAM,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,MAExB;QACC,MAAM,IAAI,GAAG,iBAAiB,MAAM,CAAC,cAAc,SAAS,CAAC;QAC7D,OAAO,MAAM,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,MAE1B;QACC,MAAM,IAAI,GAAG,iBAAiB,MAAM,CAAC,cAAc,WAAW,CAAC;QAC/D,OAAO,MAAM,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,yBAAy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wBAAwB,CAChC,2BAA2B,YAAY,EAAE,CAC1C,CAAC;IACJ,CAAC;AACH,CAAC,gDAED,KAAK;IACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;IAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\n\nimport {\n getEnvUrls,\n SubscriptionControllerErrorMessage,\n type Env,\n} from './constants';\nimport { SubscriptionServiceError } from './errors';\nimport type {\n AssignCohortRequest,\n AuthUtils,\n BillingPortalResponse,\n GetSubscriptionsEligibilitiesRequest,\n GetSubscriptionsResponse,\n ISubscriptionService,\n PricingResponse,\n SubscriptionEligibility,\n StartCryptoSubscriptionRequest,\n StartCryptoSubscriptionResponse,\n StartSubscriptionRequest,\n StartSubscriptionResponse,\n SubmitUserEventRequest,\n Subscription,\n UpdatePaymentMethodCardRequest,\n UpdatePaymentMethodCardResponse,\n UpdatePaymentMethodCryptoRequest,\n SubmitSponsorshipIntentsRequest,\n} from './types';\n\nexport type SubscriptionServiceConfig = {\n env: Env;\n auth: AuthUtils;\n};\n\nexport const SUBSCRIPTION_URL = (env: Env, path: string) =>\n `${getEnvUrls(env).subscriptionApiUrl}/v1/${path}`;\n\nexport class SubscriptionService implements ISubscriptionService {\n readonly #env: Env;\n\n public authUtils: AuthUtils;\n\n constructor(config: SubscriptionServiceConfig) {\n this.#env = config.env;\n this.authUtils = config.auth;\n }\n\n async getSubscriptions(): Promise<GetSubscriptionsResponse> {\n const path = 'subscriptions';\n return await this.#makeRequest(path);\n }\n\n async cancelSubscription(params: {\n subscriptionId: string;\n }): Promise<Subscription> {\n const path = `subscriptions/${params.subscriptionId}/cancel`;\n return await this.#makeRequest(path, 'POST', {});\n }\n\n async unCancelSubscription(params: {\n subscriptionId: string;\n }): Promise<Subscription> {\n const path = `subscriptions/${params.subscriptionId}/uncancel`;\n return await this.#makeRequest(path, 'POST', {});\n }\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 const path = 'subscriptions/card';\n\n return await this.#makeRequest(path, 'POST', request);\n }\n\n async startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse> {\n const path = 'subscriptions/crypto';\n return await this.#makeRequest(path, 'POST', request);\n }\n\n async updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse> {\n const path = `subscriptions/${request.subscriptionId}/payment-method/card`;\n return await this.#makeRequest<UpdatePaymentMethodCardResponse>(\n path,\n 'PATCH',\n {\n ...request,\n subscriptionId: undefined,\n },\n );\n }\n\n async updatePaymentMethodCrypto(request: UpdatePaymentMethodCryptoRequest) {\n const path = `subscriptions/${request.subscriptionId}/payment-method/crypto`;\n await this.#makeRequest(path, 'PATCH', {\n ...request,\n subscriptionId: undefined,\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 path = 'subscriptions/eligibility';\n let query: Record<string, string> | undefined;\n if (request?.balanceCategory !== undefined) {\n query = { balanceCategory: request.balanceCategory };\n }\n const results = await this.#makeRequest<SubscriptionEligibility[]>(\n path,\n 'GET',\n undefined,\n query,\n );\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 path = 'user-events';\n await this.#makeRequest(path, 'POST', request);\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 path = 'cohorts/assign';\n await this.#makeRequest(path, 'POST', request);\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 path = 'transaction-sponsorship/intents';\n await this.#makeRequest(path, 'POST', request);\n }\n\n async #makeRequest<Result>(\n path: string,\n method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH' = 'GET',\n body?: Record<string, unknown>,\n queryParams?: Record<string, string>,\n ): Promise<Result> {\n try {\n const headers = await this.#getAuthorizationHeader();\n const url = new URL(SUBSCRIPTION_URL(this.#env, path));\n\n if (queryParams) {\n Object.entries(queryParams).forEach(([key, value]) => {\n url.searchParams.append(key, value);\n });\n }\n\n const response = await handleFetch(url.toString(), {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n body: body ? JSON.stringify(body) : undefined,\n });\n\n return response;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n\n throw new SubscriptionServiceError(\n `failed to make request. ${errorMessage}`,\n );\n }\n }\n\n async #getAuthorizationHeader(): Promise<{ Authorization: string }> {\n const accessToken = await this.authUtils.getAccessToken();\n return { Authorization: `Bearer ${accessToken}` };\n }\n\n async getPricing(): Promise<PricingResponse> {\n const path = 'pricing';\n return await this.#makeRequest<PricingResponse>(path);\n }\n\n async getBillingPortalUrl(): Promise<BillingPortalResponse> {\n const path = 'billing-portal';\n return await this.#makeRequest<BillingPortalResponse>(path);\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubscriptionService = exports.SubscriptionControllerErrorMessage = exports.Env = exports.SubscriptionServiceError = exports.SubscriptionUserEvent = exports.PAYMENT_TYPES = exports.RECURRING_INTERVALS = exports.PRODUCT_TYPES = exports.SUBSCRIPTION_STATUSES = exports.CRYPTO_PAYMENT_METHOD_ERRORS = exports.getDefaultSubscriptionControllerState = exports.SubscriptionController = void 0;
3
+ exports.SubscriptionService = exports.SubscriptionControllerErrorMessage = exports.Env = exports.SubscriptionServiceError = 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.getDefaultSubscriptionControllerState = exports.SubscriptionController = void 0;
4
4
  var SubscriptionController_1 = require("./SubscriptionController.cjs");
5
5
  Object.defineProperty(exports, "SubscriptionController", { enumerable: true, get: function () { return SubscriptionController_1.SubscriptionController; } });
6
6
  Object.defineProperty(exports, "getDefaultSubscriptionControllerState", { enumerable: true, get: function () { return SubscriptionController_1.getDefaultSubscriptionControllerState; } });
@@ -11,6 +11,8 @@ Object.defineProperty(exports, "PRODUCT_TYPES", { enumerable: true, get: functio
11
11
  Object.defineProperty(exports, "RECURRING_INTERVALS", { enumerable: true, get: function () { return types_1.RECURRING_INTERVALS; } });
12
12
  Object.defineProperty(exports, "PAYMENT_TYPES", { enumerable: true, get: function () { return types_1.PAYMENT_TYPES; } });
13
13
  Object.defineProperty(exports, "SubscriptionUserEvent", { enumerable: true, get: function () { return types_1.SubscriptionUserEvent; } });
14
+ Object.defineProperty(exports, "COHORT_NAMES", { enumerable: true, get: function () { return types_1.COHORT_NAMES; } });
15
+ Object.defineProperty(exports, "BALANCE_CATEGORIES", { enumerable: true, get: function () { return types_1.BALANCE_CATEGORIES; } });
14
16
  var errors_1 = require("./errors.cjs");
15
17
  Object.defineProperty(exports, "SubscriptionServiceError", { enumerable: true, get: function () { return errors_1.SubscriptionServiceError; } });
16
18
  var constants_1 = require("./constants.cjs");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAqBA,uEAGkC;AAFhC,gIAAA,sBAAsB,OAAA;AACtB,+IAAA,qCAAqC,OAAA;AAwCvC,qCAOiB;AANf,qHAAA,4BAA4B,OAAA;AAC5B,8GAAA,qBAAqB,OAAA;AACrB,sGAAA,aAAa,OAAA;AACb,4GAAA,mBAAmB,OAAA;AACnB,sGAAA,aAAa,OAAA;AACb,8GAAA,qBAAqB,OAAA;AAEvB,uCAAoD;AAA3C,kHAAA,wBAAwB,OAAA;AACjC,6CAAsE;AAA7D,gGAAA,GAAG,OAAA;AAAE,+HAAA,kCAAkC,OAAA;AAEhD,iEAA4D;AAAnD,0HAAA,mBAAmB,OAAA","sourcesContent":["export type {\n SubscriptionControllerActions,\n SubscriptionControllerState,\n SubscriptionControllerEvents,\n SubscriptionControllerGetSubscriptionsAction,\n SubscriptionControllerGetSubscriptionByProductAction,\n SubscriptionControllerCancelSubscriptionAction,\n SubscriptionControllerStartShieldSubscriptionWithCardAction,\n SubscriptionControllerGetPricingAction,\n SubscriptionControllerGetCryptoApproveTransactionParamsAction,\n SubscriptionControllerStartSubscriptionWithCryptoAction,\n SubscriptionControllerGetBillingPortalUrlAction,\n SubscriptionControllerUpdatePaymentMethodAction,\n SubscriptionControllerGetStateAction,\n SubscriptionControllerMessenger,\n SubscriptionControllerOptions,\n SubscriptionControllerStateChangeEvent,\n SubscriptionControllerSubmitSponsorshipIntentsAction,\n AllowedActions,\n AllowedEvents,\n} from './SubscriptionController';\nexport {\n SubscriptionController,\n getDefaultSubscriptionControllerState,\n} from './SubscriptionController';\nexport type {\n Subscription,\n AuthUtils,\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} from './types';\nexport {\n CRYPTO_PAYMENT_METHOD_ERRORS,\n SUBSCRIPTION_STATUSES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n PAYMENT_TYPES,\n SubscriptionUserEvent,\n} from './types';\nexport { SubscriptionServiceError } from './errors';\nexport { Env, SubscriptionControllerErrorMessage } from './constants';\nexport type { SubscriptionServiceConfig } from './SubscriptionService';\nexport { SubscriptionService } from './SubscriptionService';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAqBA,uEAGkC;AAFhC,gIAAA,sBAAsB,OAAA;AACtB,+IAAA,qCAAqC,OAAA;AA6CvC,qCASiB;AARf,qHAAA,4BAA4B,OAAA;AAC5B,8GAAA,qBAAqB,OAAA;AACrB,sGAAA,aAAa,OAAA;AACb,4GAAA,mBAAmB,OAAA;AACnB,sGAAA,aAAa,OAAA;AACb,8GAAA,qBAAqB,OAAA;AACrB,qGAAA,YAAY,OAAA;AACZ,2GAAA,kBAAkB,OAAA;AAEpB,uCAAoD;AAA3C,kHAAA,wBAAwB,OAAA;AACjC,6CAAsE;AAA7D,gGAAA,GAAG,OAAA;AAAE,+HAAA,kCAAkC,OAAA;AAEhD,iEAA4D;AAAnD,0HAAA,mBAAmB,OAAA","sourcesContent":["export type {\n SubscriptionControllerActions,\n SubscriptionControllerState,\n SubscriptionControllerEvents,\n SubscriptionControllerGetSubscriptionsAction,\n SubscriptionControllerGetSubscriptionByProductAction,\n SubscriptionControllerCancelSubscriptionAction,\n SubscriptionControllerStartShieldSubscriptionWithCardAction,\n SubscriptionControllerGetPricingAction,\n SubscriptionControllerGetCryptoApproveTransactionParamsAction,\n SubscriptionControllerStartSubscriptionWithCryptoAction,\n SubscriptionControllerGetBillingPortalUrlAction,\n SubscriptionControllerUpdatePaymentMethodAction,\n SubscriptionControllerGetStateAction,\n SubscriptionControllerMessenger,\n SubscriptionControllerOptions,\n SubscriptionControllerStateChangeEvent,\n SubscriptionControllerSubmitSponsorshipIntentsAction,\n AllowedActions,\n AllowedEvents,\n} from './SubscriptionController';\nexport {\n SubscriptionController,\n getDefaultSubscriptionControllerState,\n} from './SubscriptionController';\nexport type {\n Subscription,\n AuthUtils,\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} from './types';\nexport {\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} from './types';\nexport { SubscriptionServiceError } from './errors';\nexport { Env, SubscriptionControllerErrorMessage } from './constants';\nexport type { SubscriptionServiceConfig } from './SubscriptionService';\nexport { SubscriptionService } from './SubscriptionService';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  export type { SubscriptionControllerActions, SubscriptionControllerState, SubscriptionControllerEvents, SubscriptionControllerGetSubscriptionsAction, SubscriptionControllerGetSubscriptionByProductAction, SubscriptionControllerCancelSubscriptionAction, SubscriptionControllerStartShieldSubscriptionWithCardAction, SubscriptionControllerGetPricingAction, SubscriptionControllerGetCryptoApproveTransactionParamsAction, SubscriptionControllerStartSubscriptionWithCryptoAction, SubscriptionControllerGetBillingPortalUrlAction, SubscriptionControllerUpdatePaymentMethodAction, SubscriptionControllerGetStateAction, SubscriptionControllerMessenger, SubscriptionControllerOptions, SubscriptionControllerStateChangeEvent, SubscriptionControllerSubmitSponsorshipIntentsAction, AllowedActions, AllowedEvents, } from "./SubscriptionController.cjs";
2
2
  export { SubscriptionController, getDefaultSubscriptionControllerState, } from "./SubscriptionController.cjs";
3
- export type { Subscription, AuthUtils, 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, } from "./types.cjs";
4
- export { CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent, } from "./types.cjs";
3
+ export type { Subscription, AuthUtils, 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, } from "./types.cjs";
4
+ export { CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, } from "./types.cjs";
5
5
  export { SubscriptionServiceError } from "./errors.cjs";
6
6
  export { Env, SubscriptionControllerErrorMessage } from "./constants.cjs";
7
7
  export type { SubscriptionServiceConfig } 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,4CAA4C,EAC5C,oDAAoD,EACpD,8CAA8C,EAC9C,2DAA2D,EAC3D,sCAAsC,EACtC,6DAA6D,EAC7D,uDAAuD,EACvD,+CAA+C,EAC/C,+CAA+C,EAC/C,oCAAoC,EACpC,+BAA+B,EAC/B,6BAA6B,EAC7B,sCAAsC,EACtC,oDAAoD,EACpD,cAAc,EACd,aAAa,GACd,qCAAiC;AAClC,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAiC;AAClC,YAAY,EACV,YAAY,EACZ,SAAS,EACT,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,GACrC,oBAAgB;AACjB,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,GACtB,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,qBAAiB;AACpD,OAAO,EAAE,GAAG,EAAE,kCAAkC,EAAE,wBAAoB;AACtE,YAAY,EAAE,yBAAyB,EAAE,kCAA8B;AACvE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,4CAA4C,EAC5C,oDAAoD,EACpD,8CAA8C,EAC9C,2DAA2D,EAC3D,sCAAsC,EACtC,6DAA6D,EAC7D,uDAAuD,EACvD,+CAA+C,EAC/C,+CAA+C,EAC/C,oCAAoC,EACpC,+BAA+B,EAC/B,6BAA6B,EAC7B,sCAAsC,EACtC,oDAAoD,EACpD,cAAc,EACd,aAAa,GACd,qCAAiC;AAClC,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAiC;AAClC,YAAY,EACV,YAAY,EACZ,SAAS,EACT,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,GACrC,oBAAgB;AACjB,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,GACnB,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,qBAAiB;AACpD,OAAO,EAAE,GAAG,EAAE,kCAAkC,EAAE,wBAAoB;AACtE,YAAY,EAAE,yBAAyB,EAAE,kCAA8B;AACvE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B"}
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  export type { SubscriptionControllerActions, SubscriptionControllerState, SubscriptionControllerEvents, SubscriptionControllerGetSubscriptionsAction, SubscriptionControllerGetSubscriptionByProductAction, SubscriptionControllerCancelSubscriptionAction, SubscriptionControllerStartShieldSubscriptionWithCardAction, SubscriptionControllerGetPricingAction, SubscriptionControllerGetCryptoApproveTransactionParamsAction, SubscriptionControllerStartSubscriptionWithCryptoAction, SubscriptionControllerGetBillingPortalUrlAction, SubscriptionControllerUpdatePaymentMethodAction, SubscriptionControllerGetStateAction, SubscriptionControllerMessenger, SubscriptionControllerOptions, SubscriptionControllerStateChangeEvent, SubscriptionControllerSubmitSponsorshipIntentsAction, AllowedActions, AllowedEvents, } from "./SubscriptionController.mjs";
2
2
  export { SubscriptionController, getDefaultSubscriptionControllerState, } from "./SubscriptionController.mjs";
3
- export type { Subscription, AuthUtils, 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, } from "./types.mjs";
4
- export { CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent, } from "./types.mjs";
3
+ export type { Subscription, AuthUtils, 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, } from "./types.mjs";
4
+ export { CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, } from "./types.mjs";
5
5
  export { SubscriptionServiceError } from "./errors.mjs";
6
6
  export { Env, SubscriptionControllerErrorMessage } from "./constants.mjs";
7
7
  export type { SubscriptionServiceConfig } from "./SubscriptionService.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":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AE,mBAAmB,EAAE,kCAA8B"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  export { SubscriptionController, getDefaultSubscriptionControllerState } from "./SubscriptionController.mjs";
2
- export { CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent } from "./types.mjs";
2
+ export { CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES } from "./types.mjs";
3
3
  export { SubscriptionServiceError } from "./errors.mjs";
4
4
  export { Env, SubscriptionControllerErrorMessage } from "./constants.mjs";
5
5
  export { SubscriptionService } from "./SubscriptionService.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACtC,qCAAiC;AAuClC,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACtB,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,qBAAiB;AACpD,OAAO,EAAE,GAAG,EAAE,kCAAkC,EAAE,wBAAoB;AAEtE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B","sourcesContent":["export type {\n SubscriptionControllerActions,\n SubscriptionControllerState,\n SubscriptionControllerEvents,\n SubscriptionControllerGetSubscriptionsAction,\n SubscriptionControllerGetSubscriptionByProductAction,\n SubscriptionControllerCancelSubscriptionAction,\n SubscriptionControllerStartShieldSubscriptionWithCardAction,\n SubscriptionControllerGetPricingAction,\n SubscriptionControllerGetCryptoApproveTransactionParamsAction,\n SubscriptionControllerStartSubscriptionWithCryptoAction,\n SubscriptionControllerGetBillingPortalUrlAction,\n SubscriptionControllerUpdatePaymentMethodAction,\n SubscriptionControllerGetStateAction,\n SubscriptionControllerMessenger,\n SubscriptionControllerOptions,\n SubscriptionControllerStateChangeEvent,\n SubscriptionControllerSubmitSponsorshipIntentsAction,\n AllowedActions,\n AllowedEvents,\n} from './SubscriptionController';\nexport {\n SubscriptionController,\n getDefaultSubscriptionControllerState,\n} from './SubscriptionController';\nexport type {\n Subscription,\n AuthUtils,\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} from './types';\nexport {\n CRYPTO_PAYMENT_METHOD_ERRORS,\n SUBSCRIPTION_STATUSES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n PAYMENT_TYPES,\n SubscriptionUserEvent,\n} from './types';\nexport { SubscriptionServiceError } from './errors';\nexport { Env, SubscriptionControllerErrorMessage } from './constants';\nexport type { SubscriptionServiceConfig } from './SubscriptionService';\nexport { SubscriptionService } from './SubscriptionService';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACtC,qCAAiC;AA4ClC,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EACnB,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,qBAAiB;AACpD,OAAO,EAAE,GAAG,EAAE,kCAAkC,EAAE,wBAAoB;AAEtE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B","sourcesContent":["export type {\n SubscriptionControllerActions,\n SubscriptionControllerState,\n SubscriptionControllerEvents,\n SubscriptionControllerGetSubscriptionsAction,\n SubscriptionControllerGetSubscriptionByProductAction,\n SubscriptionControllerCancelSubscriptionAction,\n SubscriptionControllerStartShieldSubscriptionWithCardAction,\n SubscriptionControllerGetPricingAction,\n SubscriptionControllerGetCryptoApproveTransactionParamsAction,\n SubscriptionControllerStartSubscriptionWithCryptoAction,\n SubscriptionControllerGetBillingPortalUrlAction,\n SubscriptionControllerUpdatePaymentMethodAction,\n SubscriptionControllerGetStateAction,\n SubscriptionControllerMessenger,\n SubscriptionControllerOptions,\n SubscriptionControllerStateChangeEvent,\n SubscriptionControllerSubmitSponsorshipIntentsAction,\n AllowedActions,\n AllowedEvents,\n} from './SubscriptionController';\nexport {\n SubscriptionController,\n getDefaultSubscriptionControllerState,\n} from './SubscriptionController';\nexport type {\n Subscription,\n AuthUtils,\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} from './types';\nexport {\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} from './types';\nexport { SubscriptionServiceError } from './errors';\nexport { Env, SubscriptionControllerErrorMessage } from './constants';\nexport type { SubscriptionServiceConfig } from './SubscriptionService';\nexport { SubscriptionService } from './SubscriptionService';\n"]}
package/dist/types.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubscriptionUserEvent = exports.CRYPTO_PAYMENT_METHOD_ERRORS = exports.SUBSCRIPTION_STATUSES = exports.RECURRING_INTERVALS = exports.PAYMENT_TYPES = exports.PRODUCT_TYPES = void 0;
3
+ exports.SubscriptionUserEvent = exports.BALANCE_CATEGORIES = exports.COHORT_NAMES = exports.CRYPTO_PAYMENT_METHOD_ERRORS = exports.SUBSCRIPTION_STATUSES = exports.RECURRING_INTERVALS = exports.PAYMENT_TYPES = exports.PRODUCT_TYPES = void 0;
4
4
  exports.PRODUCT_TYPES = {
5
5
  SHIELD: 'shield',
6
6
  };
@@ -35,7 +35,20 @@ exports.CRYPTO_PAYMENT_METHOD_ERRORS = {
35
35
  INSUFFICIENT_BALANCE: 'insufficient_balance',
36
36
  INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',
37
37
  };
38
+ exports.COHORT_NAMES = {
39
+ POST_TX: 'post_tx',
40
+ WALLET_HOME: 'wallet_home',
41
+ };
42
+ exports.BALANCE_CATEGORIES = {
43
+ RANGE_0_99: '0-99',
44
+ RANGE_100_999: '100-999',
45
+ RANGE_1K_9_9K: '1k-9.9k',
46
+ RANGE_10K_99_9K: '10k-99.9k',
47
+ RANGE_100K_999_9K: '100k-999.9k',
48
+ RANGE_1M_PLUS: '1M+',
49
+ };
38
50
  exports.SubscriptionUserEvent = {
39
51
  ShieldEntryModalViewed: 'shield_entry_modal_viewed',
52
+ ShieldCohortAssigned: 'shield_cohort_assigned',
40
53
  };
41
54
  //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;CACR,CAAC;AAIE,QAAA,aAAa,GAAG;IAC3B,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,QAAQ;CACV,CAAC;AAIE,QAAA,mBAAmB,GAAG;IACjC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACJ,CAAC;AAKE,QAAA,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,UAAU,EAAE,YAAY;IACxB,iBAAiB,EAAE,oBAAoB;IACvC,gBAAgB;IAChB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,iBAAiB;IACjB,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,QAAQ;IAChB,mBAAmB;IACnB,QAAQ,EAAE,UAAU;IACpB,gBAAgB;IAChB,MAAM,EAAE,QAAQ;CACR,CAAC;AAKE,QAAA,4BAA4B,GAAG;IAC1C,4BAA4B,EAAE,8BAA8B;IAC5D,6BAA6B,EAAE,+BAA+B;IAC9D,sDAAsD,EACpD,wDAAwD;IAC1D,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;CACxC,CAAC;AA0LE,QAAA,qBAAqB,GAAG;IACnC,sBAAsB,EAAE,2BAA2B;CAC3C,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport const PRODUCT_TYPES = {\n SHIELD: 'shield',\n} as const;\n\nexport type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];\n\nexport const PAYMENT_TYPES = {\n byCard: 'card',\n byCrypto: 'crypto',\n} as const;\n\nexport type PaymentType = (typeof PAYMENT_TYPES)[keyof typeof PAYMENT_TYPES];\n\nexport const RECURRING_INTERVALS = {\n month: 'month',\n year: 'year',\n} as const;\n\nexport type RecurringInterval =\n (typeof RECURRING_INTERVALS)[keyof typeof RECURRING_INTERVALS];\n\nexport const SUBSCRIPTION_STATUSES = {\n // Initial states\n incomplete: 'incomplete',\n incompleteExpired: 'incomplete_expired',\n // Active states\n provisional: 'provisional',\n trialing: 'trialing',\n active: 'active',\n // Payment issues\n pastDue: 'past_due',\n unpaid: 'unpaid',\n // Cancelled states\n canceled: 'canceled',\n // Paused states\n paused: 'paused',\n} as const;\n\nexport type SubscriptionStatus =\n (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];\n\nexport const CRYPTO_PAYMENT_METHOD_ERRORS = {\n APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old',\n APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted',\n APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED:\n 'approval_transaction_max_verification_attempts_reached',\n INSUFFICIENT_BALANCE: 'insufficient_balance',\n INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',\n} as const;\n\nexport type CryptoPaymentMethodError =\n (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];\n\n/** only usd for now */\nexport type Currency = 'usd';\n\nexport type Product = {\n name: ProductType;\n currency: Currency;\n unitAmount: number;\n unitDecimals: number;\n};\n\n// state\nexport type Subscription = {\n id: string;\n products: Product[];\n currentPeriodStart: string; // ISO 8601\n currentPeriodEnd: string; // ISO 8601\n /** is subscription scheduled for cancellation */\n cancelAtPeriodEnd?: boolean;\n status: SubscriptionStatus;\n interval: RecurringInterval;\n paymentMethod: SubscriptionPaymentMethod;\n trialPeriodDays?: number;\n trialStart?: string; // ISO 8601\n trialEnd?: string; // ISO 8601\n /** Crypto payment only: next billing cycle date (e.g after 12 months) */\n endDate?: string; // ISO 8601\n billingCycles?: number;\n};\n\nexport type SubscriptionCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n card: {\n brand: string;\n /** display brand account for dual brand card */\n displayBrand: string;\n last4: string;\n };\n};\n\nexport type SubscriptionCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n crypto: {\n payerAddress: Hex;\n chainId: Hex;\n tokenSymbol: string;\n error?: CryptoPaymentMethodError;\n };\n};\n\nexport type SubscriptionPaymentMethod =\n | SubscriptionCardPaymentMethod\n | SubscriptionCryptoPaymentMethod;\n\nexport type GetSubscriptionsResponse = {\n customerId?: string;\n subscriptions: Subscription[];\n trialedProducts: ProductType[];\n};\n\nexport type StartSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n successUrl?: string;\n};\n\nexport type StartSubscriptionResponse = {\n checkoutSessionUrl: string;\n};\n\nexport type StartCryptoSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n chainId: Hex;\n payerAddress: Hex;\n /**\n * e.g. \"USDC\"\n */\n tokenSymbol: string;\n rawTransaction: Hex;\n isSponsored?: boolean;\n};\n\nexport type StartCryptoSubscriptionResponse = {\n subscriptionId: string;\n status: SubscriptionStatus;\n};\n\nexport type AuthUtils = {\n getAccessToken: () => Promise<string>;\n};\n\nexport type ProductPrice = {\n interval: RecurringInterval;\n unitAmount: number; // amount in the smallest unit of the currency, e.g., cents\n unitDecimals: number; // number of decimals for the smallest unit of the currency\n /** only usd for now */\n currency: Currency;\n trialPeriodDays: number;\n minBillingCycles: number;\n};\n\nexport type ProductPricing = {\n name: ProductType;\n prices: ProductPrice[];\n};\n\nexport type TokenPaymentInfo = {\n symbol: string;\n address: Hex;\n decimals: number;\n /**\n * example: {\n usd: '1.0',\n },\n */\n conversionRate: {\n usd: string;\n };\n};\n\nexport type ChainPaymentInfo = {\n chainId: Hex;\n paymentAddress: Hex;\n tokens: TokenPaymentInfo[];\n /**\n * Whether the chain supports sponsorship for the trialed subscription approval transaction.\n * This is used to determine if the user can be sponsored for the gas fees for the trialed subscription approval transaction.\n */\n isSponsorshipSupported?: boolean;\n};\n\nexport type PricingPaymentMethod = {\n type: PaymentType;\n chains?: ChainPaymentInfo[];\n};\n\nexport type PricingResponse = {\n products: ProductPricing[];\n paymentMethods: PricingPaymentMethod[];\n};\n\nexport type GetCryptoApproveTransactionRequest = {\n /**\n * payment chain ID\n */\n chainId: Hex;\n /**\n * Payment token address\n */\n paymentTokenAddress: Hex;\n productType: ProductType;\n interval: RecurringInterval;\n};\n\nexport type GetCryptoApproveTransactionResponse = {\n /**\n * The amount to approve\n * e.g: \"100000000\"\n */\n approveAmount: string;\n /**\n * The contract address (spender)\n */\n paymentAddress: Hex;\n /**\n * The payment token address\n */\n paymentTokenAddress: Hex;\n chainId: Hex;\n};\n\nexport type SubscriptionEligibility = {\n product: ProductType;\n canSubscribe: boolean;\n minBalanceUSD: number;\n canViewEntryModal: boolean;\n};\n\nexport const SubscriptionUserEvent = {\n ShieldEntryModalViewed: 'shield_entry_modal_viewed',\n} as const;\n\nexport type SubscriptionUserEventType =\n (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];\n\nexport type SubmitUserEventRequest = {\n event: SubscriptionUserEventType;\n};\n\n/**\n * Request object for submitting sponsorship intents.\n */\nexport type SubmitSponsorshipIntentsRequest = {\n chainId: Hex;\n address: Hex;\n products: ProductType[];\n paymentTokenSymbol: string;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type SubmitSponsorshipIntentsMethodParams = Pick<\n SubmitSponsorshipIntentsRequest,\n 'chainId' | 'address' | 'products'\n>;\n\nexport type ISubscriptionService = {\n getSubscriptions(): Promise<GetSubscriptionsResponse>;\n cancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n unCancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n startSubscriptionWithCard(\n request: StartSubscriptionRequest,\n ): Promise<StartSubscriptionResponse>;\n getBillingPortalUrl(): Promise<BillingPortalResponse>;\n getPricing(): Promise<PricingResponse>;\n startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse>;\n updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse>;\n updatePaymentMethodCrypto(\n request: UpdatePaymentMethodCryptoRequest,\n ): Promise<void>;\n getSubscriptionsEligibilities(): Promise<SubscriptionEligibility[]>;\n submitUserEvent(request: SubmitUserEventRequest): Promise<void>;\n\n /**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n */\n submitSponsorshipIntents(\n request: SubmitSponsorshipIntentsRequest,\n ): Promise<void>;\n};\n\nexport type UpdatePaymentMethodOpts =\n | ({\n paymentType: Extract<PaymentType, 'card'>;\n } & UpdatePaymentMethodCardRequest)\n | ({\n paymentType: Extract<PaymentType, 'crypto'>;\n } & UpdatePaymentMethodCryptoRequest);\n\nexport type UpdatePaymentMethodCardRequest = {\n /**\n * Subscription ID\n */\n subscriptionId: string;\n\n /**\n * Recurring interval\n */\n recurringInterval: RecurringInterval;\n successUrl?: string;\n};\n\nexport type UpdatePaymentMethodCardResponse = {\n redirectUrl: string;\n};\n\nexport type UpdatePaymentMethodCryptoRequest = {\n subscriptionId: string;\n chainId: Hex;\n payerAddress: Hex;\n tokenSymbol: string;\n /**\n * The raw transaction to pay for the subscription\n * Can be empty if retry after topping up balance\n */\n rawTransaction?: Hex;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type BillingPortalResponse = {\n url: string;\n};\n\n/**\n * The cached result of last selected payment methods for the user.\n * These details are being cached to be used internally to track the last selected payment method for the user. (e.g. for crypto subscriptions)\n */\nexport type CachedLastSelectedPaymentMethod = {\n type: PaymentType;\n paymentTokenAddress?: Hex;\n paymentTokenSymbol?: string;\n plan: RecurringInterval;\n};\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;CACR,CAAC;AAIE,QAAA,aAAa,GAAG;IAC3B,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,QAAQ;CACV,CAAC;AAIE,QAAA,mBAAmB,GAAG;IACjC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACJ,CAAC;AAKE,QAAA,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,UAAU,EAAE,YAAY;IACxB,iBAAiB,EAAE,oBAAoB;IACvC,gBAAgB;IAChB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,iBAAiB;IACjB,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,QAAQ;IAChB,mBAAmB;IACnB,QAAQ,EAAE,UAAU;IACpB,gBAAgB;IAChB,MAAM,EAAE,QAAQ;CACR,CAAC;AAKE,QAAA,4BAA4B,GAAG;IAC1C,4BAA4B,EAAE,8BAA8B;IAC5D,6BAA6B,EAAE,+BAA+B;IAC9D,sDAAsD,EACpD,wDAAwD;IAC1D,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;CACxC,CAAC;AA2LE,QAAA,YAAY,GAAG;IAC1B,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;CAClB,CAAC;AAIE,QAAA,kBAAkB,GAAG;IAChC,UAAU,EAAE,MAAM;IAClB,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,WAAW;IAC5B,iBAAiB,EAAE,aAAa;IAChC,aAAa,EAAE,KAAK;CACZ,CAAC;AAsBE,QAAA,qBAAqB,GAAG;IACnC,sBAAsB,EAAE,2BAA2B;IACnD,oBAAoB,EAAE,wBAAwB;CACtC,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport const PRODUCT_TYPES = {\n SHIELD: 'shield',\n} as const;\n\nexport type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];\n\nexport const PAYMENT_TYPES = {\n byCard: 'card',\n byCrypto: 'crypto',\n} as const;\n\nexport type PaymentType = (typeof PAYMENT_TYPES)[keyof typeof PAYMENT_TYPES];\n\nexport const RECURRING_INTERVALS = {\n month: 'month',\n year: 'year',\n} as const;\n\nexport type RecurringInterval =\n (typeof RECURRING_INTERVALS)[keyof typeof RECURRING_INTERVALS];\n\nexport const SUBSCRIPTION_STATUSES = {\n // Initial states\n incomplete: 'incomplete',\n incompleteExpired: 'incomplete_expired',\n // Active states\n provisional: 'provisional',\n trialing: 'trialing',\n active: 'active',\n // Payment issues\n pastDue: 'past_due',\n unpaid: 'unpaid',\n // Cancelled states\n canceled: 'canceled',\n // Paused states\n paused: 'paused',\n} as const;\n\nexport type SubscriptionStatus =\n (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];\n\nexport const CRYPTO_PAYMENT_METHOD_ERRORS = {\n APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old',\n APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted',\n APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED:\n 'approval_transaction_max_verification_attempts_reached',\n INSUFFICIENT_BALANCE: 'insufficient_balance',\n INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',\n} as const;\n\nexport type CryptoPaymentMethodError =\n (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];\n\n/** only usd for now */\nexport type Currency = 'usd';\n\nexport type Product = {\n name: ProductType;\n currency: Currency;\n unitAmount: number;\n unitDecimals: number;\n};\n\n// state\nexport type Subscription = {\n id: string;\n products: Product[];\n currentPeriodStart: string; // ISO 8601\n currentPeriodEnd: string; // ISO 8601\n /** is subscription scheduled for cancellation */\n cancelAtPeriodEnd?: boolean;\n status: SubscriptionStatus;\n interval: RecurringInterval;\n paymentMethod: SubscriptionPaymentMethod;\n trialPeriodDays?: number;\n trialStart?: string; // ISO 8601\n trialEnd?: string; // ISO 8601\n /** Crypto payment only: next billing cycle date (e.g after 12 months) */\n endDate?: string; // ISO 8601\n /** The date the subscription was canceled. */\n canceledAt?: string; // ISO 8601\n /** The date the subscription was marked as inactive (paused/past_due/canceled). */\n inactiveAt?: string; // ISO 8601\n /** Whether the user is eligible for support features (priority support and filing claims). True for active subscriptions and inactive subscriptions within grace period. */\n isEligibleForSupport: boolean;\n billingCycles?: number;\n};\n\nexport type SubscriptionCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n card: {\n brand: string;\n /** display brand account for dual brand card */\n displayBrand: string;\n last4: string;\n };\n};\n\nexport type SubscriptionCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n crypto: {\n payerAddress: Hex;\n chainId: Hex;\n tokenSymbol: string;\n error?: CryptoPaymentMethodError;\n };\n};\n\nexport type SubscriptionPaymentMethod =\n | SubscriptionCardPaymentMethod\n | SubscriptionCryptoPaymentMethod;\n\nexport type GetSubscriptionsResponse = {\n customerId?: string;\n subscriptions: Subscription[];\n trialedProducts: ProductType[];\n /** The last subscription that user has subscribed to if any. */\n lastSubscription?: Subscription;\n};\n\nexport type StartSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n successUrl?: string;\n};\n\nexport type StartSubscriptionResponse = {\n checkoutSessionUrl: string;\n};\n\nexport type StartCryptoSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n chainId: Hex;\n payerAddress: Hex;\n /**\n * e.g. \"USDC\"\n */\n tokenSymbol: string;\n rawTransaction: Hex;\n isSponsored?: boolean;\n};\n\nexport type StartCryptoSubscriptionResponse = {\n subscriptionId: string;\n status: SubscriptionStatus;\n};\n\nexport type AuthUtils = {\n getAccessToken: () => Promise<string>;\n};\n\nexport type ProductPrice = {\n interval: RecurringInterval;\n unitAmount: number; // amount in the smallest unit of the currency, e.g., cents\n unitDecimals: number; // number of decimals for the smallest unit of the currency\n /** only usd for now */\n currency: Currency;\n trialPeriodDays: number;\n minBillingCycles: number;\n};\n\nexport type ProductPricing = {\n name: ProductType;\n prices: ProductPrice[];\n};\n\nexport type TokenPaymentInfo = {\n symbol: string;\n address: Hex;\n decimals: number;\n /**\n * example: {\n usd: '1.0',\n },\n */\n conversionRate: {\n usd: string;\n };\n};\n\nexport type ChainPaymentInfo = {\n chainId: Hex;\n paymentAddress: Hex;\n tokens: TokenPaymentInfo[];\n /**\n * Whether the chain supports sponsorship for the trialed subscription approval transaction.\n * This is used to determine if the user can be sponsored for the gas fees for the trialed subscription approval transaction.\n */\n isSponsorshipSupported?: boolean;\n};\n\nexport type PricingPaymentMethod = {\n type: PaymentType;\n chains?: ChainPaymentInfo[];\n};\n\nexport type PricingResponse = {\n products: ProductPricing[];\n paymentMethods: PricingPaymentMethod[];\n};\n\nexport type GetCryptoApproveTransactionRequest = {\n /**\n * payment chain ID\n */\n chainId: Hex;\n /**\n * Payment token address\n */\n paymentTokenAddress: Hex;\n productType: ProductType;\n interval: RecurringInterval;\n};\n\nexport type GetCryptoApproveTransactionResponse = {\n /**\n * The amount to approve\n * e.g: \"100000000\"\n */\n approveAmount: string;\n /**\n * The contract address (spender)\n */\n paymentAddress: Hex;\n /**\n * The payment token address\n */\n paymentTokenAddress: Hex;\n chainId: Hex;\n};\n\nexport const COHORT_NAMES = {\n POST_TX: 'post_tx',\n WALLET_HOME: 'wallet_home',\n} as const;\n\nexport type CohortName = (typeof COHORT_NAMES)[keyof typeof COHORT_NAMES];\n\nexport const BALANCE_CATEGORIES = {\n RANGE_0_99: '0-99',\n RANGE_100_999: '100-999',\n RANGE_1K_9_9K: '1k-9.9k',\n RANGE_10K_99_9K: '10k-99.9k',\n RANGE_100K_999_9K: '100k-999.9k',\n RANGE_1M_PLUS: '1M+',\n} as const;\n\nexport type BalanceCategory =\n (typeof BALANCE_CATEGORIES)[keyof typeof BALANCE_CATEGORIES];\n\nexport type Cohort = {\n cohort: string;\n eligibilityRate: number; // 0-1 probability of being assigned to this cohort\n priority: number; // lower number = higher priority\n eligible: boolean;\n};\n\nexport type SubscriptionEligibility = {\n product: ProductType;\n canSubscribe: boolean;\n minBalanceUSD: number;\n canViewEntryModal: boolean;\n cohorts: Cohort[];\n assignedCohort: string | null;\n hasAssignedCohortExpired: boolean;\n};\n\nexport const SubscriptionUserEvent = {\n ShieldEntryModalViewed: 'shield_entry_modal_viewed',\n ShieldCohortAssigned: 'shield_cohort_assigned',\n} as const;\n\nexport type SubscriptionUserEventType =\n (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];\n\nexport type SubmitUserEventRequest = {\n event: SubscriptionUserEventType;\n cohort?: string;\n};\n\nexport type AssignCohortRequest = {\n cohort: string;\n};\n\nexport type GetSubscriptionsEligibilitiesRequest = {\n balanceCategory?: BalanceCategory;\n};\n\n/**\n * Request object for submitting sponsorship intents.\n */\nexport type SubmitSponsorshipIntentsRequest = {\n chainId: Hex;\n address: Hex;\n products: ProductType[];\n paymentTokenSymbol: string;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type SubmitSponsorshipIntentsMethodParams = Pick<\n SubmitSponsorshipIntentsRequest,\n 'chainId' | 'address' | 'products'\n>;\n\nexport type ISubscriptionService = {\n getSubscriptions(): Promise<GetSubscriptionsResponse>;\n cancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n unCancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n startSubscriptionWithCard(\n request: StartSubscriptionRequest,\n ): Promise<StartSubscriptionResponse>;\n getBillingPortalUrl(): Promise<BillingPortalResponse>;\n getPricing(): Promise<PricingResponse>;\n startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse>;\n updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse>;\n updatePaymentMethodCrypto(\n request: UpdatePaymentMethodCryptoRequest,\n ): Promise<void>;\n getSubscriptionsEligibilities(\n request?: GetSubscriptionsEligibilitiesRequest,\n ): Promise<SubscriptionEligibility[]>;\n submitUserEvent(request: SubmitUserEventRequest): Promise<void>;\n assignUserToCohort(request: AssignCohortRequest): Promise<void>;\n\n /**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n */\n submitSponsorshipIntents(\n request: SubmitSponsorshipIntentsRequest,\n ): Promise<void>;\n};\n\nexport type UpdatePaymentMethodOpts =\n | ({\n paymentType: Extract<PaymentType, 'card'>;\n } & UpdatePaymentMethodCardRequest)\n | ({\n paymentType: Extract<PaymentType, 'crypto'>;\n } & UpdatePaymentMethodCryptoRequest);\n\nexport type UpdatePaymentMethodCardRequest = {\n /**\n * Subscription ID\n */\n subscriptionId: string;\n\n /**\n * Recurring interval\n */\n recurringInterval: RecurringInterval;\n successUrl?: string;\n};\n\nexport type UpdatePaymentMethodCardResponse = {\n redirectUrl: string;\n};\n\nexport type UpdatePaymentMethodCryptoRequest = {\n subscriptionId: string;\n chainId: Hex;\n payerAddress: Hex;\n tokenSymbol: string;\n /**\n * The raw transaction to pay for the subscription\n * Can be empty if retry after topping up balance\n */\n rawTransaction?: Hex;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type BillingPortalResponse = {\n url: string;\n};\n\n/**\n * The cached result of last selected payment methods for the user.\n * These details are being cached to be used internally to track the last selected payment method for the user. (e.g. for crypto subscriptions)\n */\nexport type CachedLastSelectedPaymentMethod = {\n type: PaymentType;\n paymentTokenAddress?: Hex;\n paymentTokenSymbol?: string;\n plan: RecurringInterval;\n};\n"]}
package/dist/types.d.cts CHANGED
@@ -56,6 +56,12 @@ export type Subscription = {
56
56
  trialEnd?: string;
57
57
  /** Crypto payment only: next billing cycle date (e.g after 12 months) */
58
58
  endDate?: string;
59
+ /** The date the subscription was canceled. */
60
+ canceledAt?: string;
61
+ /** The date the subscription was marked as inactive (paused/past_due/canceled). */
62
+ inactiveAt?: string;
63
+ /** Whether the user is eligible for support features (priority support and filing claims). True for active subscriptions and inactive subscriptions within grace period. */
64
+ isEligibleForSupport: boolean;
59
65
  billingCycles?: number;
60
66
  };
61
67
  export type SubscriptionCardPaymentMethod = {
@@ -81,6 +87,8 @@ export type GetSubscriptionsResponse = {
81
87
  customerId?: string;
82
88
  subscriptions: Subscription[];
83
89
  trialedProducts: ProductType[];
90
+ /** The last subscription that user has subscribed to if any. */
91
+ lastSubscription?: Subscription;
84
92
  };
85
93
  export type StartSubscriptionRequest = {
86
94
  products: ProductType[];
@@ -184,18 +192,49 @@ export type GetCryptoApproveTransactionResponse = {
184
192
  paymentTokenAddress: Hex;
185
193
  chainId: Hex;
186
194
  };
195
+ export declare const COHORT_NAMES: {
196
+ readonly POST_TX: "post_tx";
197
+ readonly WALLET_HOME: "wallet_home";
198
+ };
199
+ export type CohortName = (typeof COHORT_NAMES)[keyof typeof COHORT_NAMES];
200
+ export declare const BALANCE_CATEGORIES: {
201
+ readonly RANGE_0_99: "0-99";
202
+ readonly RANGE_100_999: "100-999";
203
+ readonly RANGE_1K_9_9K: "1k-9.9k";
204
+ readonly RANGE_10K_99_9K: "10k-99.9k";
205
+ readonly RANGE_100K_999_9K: "100k-999.9k";
206
+ readonly RANGE_1M_PLUS: "1M+";
207
+ };
208
+ export type BalanceCategory = (typeof BALANCE_CATEGORIES)[keyof typeof BALANCE_CATEGORIES];
209
+ export type Cohort = {
210
+ cohort: string;
211
+ eligibilityRate: number;
212
+ priority: number;
213
+ eligible: boolean;
214
+ };
187
215
  export type SubscriptionEligibility = {
188
216
  product: ProductType;
189
217
  canSubscribe: boolean;
190
218
  minBalanceUSD: number;
191
219
  canViewEntryModal: boolean;
220
+ cohorts: Cohort[];
221
+ assignedCohort: string | null;
222
+ hasAssignedCohortExpired: boolean;
192
223
  };
193
224
  export declare const SubscriptionUserEvent: {
194
225
  readonly ShieldEntryModalViewed: "shield_entry_modal_viewed";
226
+ readonly ShieldCohortAssigned: "shield_cohort_assigned";
195
227
  };
196
228
  export type SubscriptionUserEventType = (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];
197
229
  export type SubmitUserEventRequest = {
198
230
  event: SubscriptionUserEventType;
231
+ cohort?: string;
232
+ };
233
+ export type AssignCohortRequest = {
234
+ cohort: string;
235
+ };
236
+ export type GetSubscriptionsEligibilitiesRequest = {
237
+ balanceCategory?: BalanceCategory;
199
238
  };
200
239
  /**
201
240
  * Request object for submitting sponsorship intents.
@@ -223,8 +262,9 @@ export type ISubscriptionService = {
223
262
  startSubscriptionWithCrypto(request: StartCryptoSubscriptionRequest): Promise<StartCryptoSubscriptionResponse>;
224
263
  updatePaymentMethodCard(request: UpdatePaymentMethodCardRequest): Promise<UpdatePaymentMethodCardResponse>;
225
264
  updatePaymentMethodCrypto(request: UpdatePaymentMethodCryptoRequest): Promise<void>;
226
- getSubscriptionsEligibilities(): Promise<SubscriptionEligibility[]>;
265
+ getSubscriptionsEligibilities(request?: GetSubscriptionsEligibilitiesRequest): Promise<SubscriptionEligibility[]>;
227
266
  submitUserEvent(request: SubmitUserEventRequest): Promise<void>;
267
+ assignUserToCohort(request: AssignCohortRequest): Promise<void>;
228
268
  /**
229
269
  * Submit sponsorship intents to the Subscription Service backend.
230
270
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,eAAO,MAAM,aAAa;;CAEhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE,eAAO,MAAM,qBAAqB;;;;;;;;;;CAexB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE,eAAO,MAAM,4BAA4B;;;;;;CAO/B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAClC,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,OAAO,4BAA4B,CAAC,CAAC;AAEnF,uBAAuB;AACvB,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC;AAE7B,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,QAAQ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M,uBAAuB,GAC/B,CAAC;IACC,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;CAC3C,GAAG,8BAA8B,CAAC,GACnC,CAAC;IACC,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;CAC7C,GAAG,gCAAgC,CAAC,CAAC;AAE1C,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,GAAG,CAAC;IACb,YAAY,EAAE,GAAG,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,WAAW,CAAC;IAClB,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC"}
package/dist/types.d.mts CHANGED
@@ -56,6 +56,12 @@ export type Subscription = {
56
56
  trialEnd?: string;
57
57
  /** Crypto payment only: next billing cycle date (e.g after 12 months) */
58
58
  endDate?: string;
59
+ /** The date the subscription was canceled. */
60
+ canceledAt?: string;
61
+ /** The date the subscription was marked as inactive (paused/past_due/canceled). */
62
+ inactiveAt?: string;
63
+ /** Whether the user is eligible for support features (priority support and filing claims). True for active subscriptions and inactive subscriptions within grace period. */
64
+ isEligibleForSupport: boolean;
59
65
  billingCycles?: number;
60
66
  };
61
67
  export type SubscriptionCardPaymentMethod = {
@@ -81,6 +87,8 @@ export type GetSubscriptionsResponse = {
81
87
  customerId?: string;
82
88
  subscriptions: Subscription[];
83
89
  trialedProducts: ProductType[];
90
+ /** The last subscription that user has subscribed to if any. */
91
+ lastSubscription?: Subscription;
84
92
  };
85
93
  export type StartSubscriptionRequest = {
86
94
  products: ProductType[];
@@ -184,18 +192,49 @@ export type GetCryptoApproveTransactionResponse = {
184
192
  paymentTokenAddress: Hex;
185
193
  chainId: Hex;
186
194
  };
195
+ export declare const COHORT_NAMES: {
196
+ readonly POST_TX: "post_tx";
197
+ readonly WALLET_HOME: "wallet_home";
198
+ };
199
+ export type CohortName = (typeof COHORT_NAMES)[keyof typeof COHORT_NAMES];
200
+ export declare const BALANCE_CATEGORIES: {
201
+ readonly RANGE_0_99: "0-99";
202
+ readonly RANGE_100_999: "100-999";
203
+ readonly RANGE_1K_9_9K: "1k-9.9k";
204
+ readonly RANGE_10K_99_9K: "10k-99.9k";
205
+ readonly RANGE_100K_999_9K: "100k-999.9k";
206
+ readonly RANGE_1M_PLUS: "1M+";
207
+ };
208
+ export type BalanceCategory = (typeof BALANCE_CATEGORIES)[keyof typeof BALANCE_CATEGORIES];
209
+ export type Cohort = {
210
+ cohort: string;
211
+ eligibilityRate: number;
212
+ priority: number;
213
+ eligible: boolean;
214
+ };
187
215
  export type SubscriptionEligibility = {
188
216
  product: ProductType;
189
217
  canSubscribe: boolean;
190
218
  minBalanceUSD: number;
191
219
  canViewEntryModal: boolean;
220
+ cohorts: Cohort[];
221
+ assignedCohort: string | null;
222
+ hasAssignedCohortExpired: boolean;
192
223
  };
193
224
  export declare const SubscriptionUserEvent: {
194
225
  readonly ShieldEntryModalViewed: "shield_entry_modal_viewed";
226
+ readonly ShieldCohortAssigned: "shield_cohort_assigned";
195
227
  };
196
228
  export type SubscriptionUserEventType = (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];
197
229
  export type SubmitUserEventRequest = {
198
230
  event: SubscriptionUserEventType;
231
+ cohort?: string;
232
+ };
233
+ export type AssignCohortRequest = {
234
+ cohort: string;
235
+ };
236
+ export type GetSubscriptionsEligibilitiesRequest = {
237
+ balanceCategory?: BalanceCategory;
199
238
  };
200
239
  /**
201
240
  * Request object for submitting sponsorship intents.
@@ -223,8 +262,9 @@ export type ISubscriptionService = {
223
262
  startSubscriptionWithCrypto(request: StartCryptoSubscriptionRequest): Promise<StartCryptoSubscriptionResponse>;
224
263
  updatePaymentMethodCard(request: UpdatePaymentMethodCardRequest): Promise<UpdatePaymentMethodCardResponse>;
225
264
  updatePaymentMethodCrypto(request: UpdatePaymentMethodCryptoRequest): Promise<void>;
226
- getSubscriptionsEligibilities(): Promise<SubscriptionEligibility[]>;
265
+ getSubscriptionsEligibilities(request?: GetSubscriptionsEligibilitiesRequest): Promise<SubscriptionEligibility[]>;
227
266
  submitUserEvent(request: SubmitUserEventRequest): Promise<void>;
267
+ assignUserToCohort(request: AssignCohortRequest): Promise<void>;
228
268
  /**
229
269
  * Submit sponsorship intents to the Subscription Service backend.
230
270
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,eAAO,MAAM,aAAa;;CAEhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,MAAM,MA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AAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,WAAW,CAAC;IAClB,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC"}
package/dist/types.mjs CHANGED
@@ -32,7 +32,20 @@ export const CRYPTO_PAYMENT_METHOD_ERRORS = {
32
32
  INSUFFICIENT_BALANCE: 'insufficient_balance',
33
33
  INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',
34
34
  };
35
+ export const COHORT_NAMES = {
36
+ POST_TX: 'post_tx',
37
+ WALLET_HOME: 'wallet_home',
38
+ };
39
+ export const BALANCE_CATEGORIES = {
40
+ RANGE_0_99: '0-99',
41
+ RANGE_100_999: '100-999',
42
+ RANGE_1K_9_9K: '1k-9.9k',
43
+ RANGE_10K_99_9K: '10k-99.9k',
44
+ RANGE_100K_999_9K: '100k-999.9k',
45
+ RANGE_1M_PLUS: '1M+',
46
+ };
35
47
  export const SubscriptionUserEvent = {
36
48
  ShieldEntryModalViewed: 'shield_entry_modal_viewed',
49
+ ShieldCohortAssigned: 'shield_cohort_assigned',
37
50
  };
38
51
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;CACR,CAAC;AAIX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,QAAQ;CACV,CAAC;AAIX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACJ,CAAC;AAKX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,UAAU,EAAE,YAAY;IACxB,iBAAiB,EAAE,oBAAoB;IACvC,gBAAgB;IAChB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,iBAAiB;IACjB,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,QAAQ;IAChB,mBAAmB;IACnB,QAAQ,EAAE,UAAU;IACpB,gBAAgB;IAChB,MAAM,EAAE,QAAQ;CACR,CAAC;AAKX,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,4BAA4B,EAAE,8BAA8B;IAC5D,6BAA6B,EAAE,+BAA+B;IAC9D,sDAAsD,EACpD,wDAAwD;IAC1D,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;CACxC,CAAC;AA0LX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,sBAAsB,EAAE,2BAA2B;CAC3C,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport const PRODUCT_TYPES = {\n SHIELD: 'shield',\n} as const;\n\nexport type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];\n\nexport const PAYMENT_TYPES = {\n byCard: 'card',\n byCrypto: 'crypto',\n} as const;\n\nexport type PaymentType = (typeof PAYMENT_TYPES)[keyof typeof PAYMENT_TYPES];\n\nexport const RECURRING_INTERVALS = {\n month: 'month',\n year: 'year',\n} as const;\n\nexport type RecurringInterval =\n (typeof RECURRING_INTERVALS)[keyof typeof RECURRING_INTERVALS];\n\nexport const SUBSCRIPTION_STATUSES = {\n // Initial states\n incomplete: 'incomplete',\n incompleteExpired: 'incomplete_expired',\n // Active states\n provisional: 'provisional',\n trialing: 'trialing',\n active: 'active',\n // Payment issues\n pastDue: 'past_due',\n unpaid: 'unpaid',\n // Cancelled states\n canceled: 'canceled',\n // Paused states\n paused: 'paused',\n} as const;\n\nexport type SubscriptionStatus =\n (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];\n\nexport const CRYPTO_PAYMENT_METHOD_ERRORS = {\n APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old',\n APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted',\n APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED:\n 'approval_transaction_max_verification_attempts_reached',\n INSUFFICIENT_BALANCE: 'insufficient_balance',\n INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',\n} as const;\n\nexport type CryptoPaymentMethodError =\n (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];\n\n/** only usd for now */\nexport type Currency = 'usd';\n\nexport type Product = {\n name: ProductType;\n currency: Currency;\n unitAmount: number;\n unitDecimals: number;\n};\n\n// state\nexport type Subscription = {\n id: string;\n products: Product[];\n currentPeriodStart: string; // ISO 8601\n currentPeriodEnd: string; // ISO 8601\n /** is subscription scheduled for cancellation */\n cancelAtPeriodEnd?: boolean;\n status: SubscriptionStatus;\n interval: RecurringInterval;\n paymentMethod: SubscriptionPaymentMethod;\n trialPeriodDays?: number;\n trialStart?: string; // ISO 8601\n trialEnd?: string; // ISO 8601\n /** Crypto payment only: next billing cycle date (e.g after 12 months) */\n endDate?: string; // ISO 8601\n billingCycles?: number;\n};\n\nexport type SubscriptionCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n card: {\n brand: string;\n /** display brand account for dual brand card */\n displayBrand: string;\n last4: string;\n };\n};\n\nexport type SubscriptionCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n crypto: {\n payerAddress: Hex;\n chainId: Hex;\n tokenSymbol: string;\n error?: CryptoPaymentMethodError;\n };\n};\n\nexport type SubscriptionPaymentMethod =\n | SubscriptionCardPaymentMethod\n | SubscriptionCryptoPaymentMethod;\n\nexport type GetSubscriptionsResponse = {\n customerId?: string;\n subscriptions: Subscription[];\n trialedProducts: ProductType[];\n};\n\nexport type StartSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n successUrl?: string;\n};\n\nexport type StartSubscriptionResponse = {\n checkoutSessionUrl: string;\n};\n\nexport type StartCryptoSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n chainId: Hex;\n payerAddress: Hex;\n /**\n * e.g. \"USDC\"\n */\n tokenSymbol: string;\n rawTransaction: Hex;\n isSponsored?: boolean;\n};\n\nexport type StartCryptoSubscriptionResponse = {\n subscriptionId: string;\n status: SubscriptionStatus;\n};\n\nexport type AuthUtils = {\n getAccessToken: () => Promise<string>;\n};\n\nexport type ProductPrice = {\n interval: RecurringInterval;\n unitAmount: number; // amount in the smallest unit of the currency, e.g., cents\n unitDecimals: number; // number of decimals for the smallest unit of the currency\n /** only usd for now */\n currency: Currency;\n trialPeriodDays: number;\n minBillingCycles: number;\n};\n\nexport type ProductPricing = {\n name: ProductType;\n prices: ProductPrice[];\n};\n\nexport type TokenPaymentInfo = {\n symbol: string;\n address: Hex;\n decimals: number;\n /**\n * example: {\n usd: '1.0',\n },\n */\n conversionRate: {\n usd: string;\n };\n};\n\nexport type ChainPaymentInfo = {\n chainId: Hex;\n paymentAddress: Hex;\n tokens: TokenPaymentInfo[];\n /**\n * Whether the chain supports sponsorship for the trialed subscription approval transaction.\n * This is used to determine if the user can be sponsored for the gas fees for the trialed subscription approval transaction.\n */\n isSponsorshipSupported?: boolean;\n};\n\nexport type PricingPaymentMethod = {\n type: PaymentType;\n chains?: ChainPaymentInfo[];\n};\n\nexport type PricingResponse = {\n products: ProductPricing[];\n paymentMethods: PricingPaymentMethod[];\n};\n\nexport type GetCryptoApproveTransactionRequest = {\n /**\n * payment chain ID\n */\n chainId: Hex;\n /**\n * Payment token address\n */\n paymentTokenAddress: Hex;\n productType: ProductType;\n interval: RecurringInterval;\n};\n\nexport type GetCryptoApproveTransactionResponse = {\n /**\n * The amount to approve\n * e.g: \"100000000\"\n */\n approveAmount: string;\n /**\n * The contract address (spender)\n */\n paymentAddress: Hex;\n /**\n * The payment token address\n */\n paymentTokenAddress: Hex;\n chainId: Hex;\n};\n\nexport type SubscriptionEligibility = {\n product: ProductType;\n canSubscribe: boolean;\n minBalanceUSD: number;\n canViewEntryModal: boolean;\n};\n\nexport const SubscriptionUserEvent = {\n ShieldEntryModalViewed: 'shield_entry_modal_viewed',\n} as const;\n\nexport type SubscriptionUserEventType =\n (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];\n\nexport type SubmitUserEventRequest = {\n event: SubscriptionUserEventType;\n};\n\n/**\n * Request object for submitting sponsorship intents.\n */\nexport type SubmitSponsorshipIntentsRequest = {\n chainId: Hex;\n address: Hex;\n products: ProductType[];\n paymentTokenSymbol: string;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type SubmitSponsorshipIntentsMethodParams = Pick<\n SubmitSponsorshipIntentsRequest,\n 'chainId' | 'address' | 'products'\n>;\n\nexport type ISubscriptionService = {\n getSubscriptions(): Promise<GetSubscriptionsResponse>;\n cancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n unCancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n startSubscriptionWithCard(\n request: StartSubscriptionRequest,\n ): Promise<StartSubscriptionResponse>;\n getBillingPortalUrl(): Promise<BillingPortalResponse>;\n getPricing(): Promise<PricingResponse>;\n startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse>;\n updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse>;\n updatePaymentMethodCrypto(\n request: UpdatePaymentMethodCryptoRequest,\n ): Promise<void>;\n getSubscriptionsEligibilities(): Promise<SubscriptionEligibility[]>;\n submitUserEvent(request: SubmitUserEventRequest): Promise<void>;\n\n /**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n */\n submitSponsorshipIntents(\n request: SubmitSponsorshipIntentsRequest,\n ): Promise<void>;\n};\n\nexport type UpdatePaymentMethodOpts =\n | ({\n paymentType: Extract<PaymentType, 'card'>;\n } & UpdatePaymentMethodCardRequest)\n | ({\n paymentType: Extract<PaymentType, 'crypto'>;\n } & UpdatePaymentMethodCryptoRequest);\n\nexport type UpdatePaymentMethodCardRequest = {\n /**\n * Subscription ID\n */\n subscriptionId: string;\n\n /**\n * Recurring interval\n */\n recurringInterval: RecurringInterval;\n successUrl?: string;\n};\n\nexport type UpdatePaymentMethodCardResponse = {\n redirectUrl: string;\n};\n\nexport type UpdatePaymentMethodCryptoRequest = {\n subscriptionId: string;\n chainId: Hex;\n payerAddress: Hex;\n tokenSymbol: string;\n /**\n * The raw transaction to pay for the subscription\n * Can be empty if retry after topping up balance\n */\n rawTransaction?: Hex;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type BillingPortalResponse = {\n url: string;\n};\n\n/**\n * The cached result of last selected payment methods for the user.\n * These details are being cached to be used internally to track the last selected payment method for the user. (e.g. for crypto subscriptions)\n */\nexport type CachedLastSelectedPaymentMethod = {\n type: PaymentType;\n paymentTokenAddress?: Hex;\n paymentTokenSymbol?: string;\n plan: RecurringInterval;\n};\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;CACR,CAAC;AAIX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,QAAQ;CACV,CAAC;AAIX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACJ,CAAC;AAKX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,UAAU,EAAE,YAAY;IACxB,iBAAiB,EAAE,oBAAoB;IACvC,gBAAgB;IAChB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,iBAAiB;IACjB,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,QAAQ;IAChB,mBAAmB;IACnB,QAAQ,EAAE,UAAU;IACpB,gBAAgB;IAChB,MAAM,EAAE,QAAQ;CACR,CAAC;AAKX,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,4BAA4B,EAAE,8BAA8B;IAC5D,6BAA6B,EAAE,+BAA+B;IAC9D,sDAAsD,EACpD,wDAAwD;IAC1D,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;CACxC,CAAC;AA2LX,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;CAClB,CAAC;AAIX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,UAAU,EAAE,MAAM;IAClB,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,WAAW;IAC5B,iBAAiB,EAAE,aAAa;IAChC,aAAa,EAAE,KAAK;CACZ,CAAC;AAsBX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,sBAAsB,EAAE,2BAA2B;IACnD,oBAAoB,EAAE,wBAAwB;CACtC,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport const PRODUCT_TYPES = {\n SHIELD: 'shield',\n} as const;\n\nexport type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];\n\nexport const PAYMENT_TYPES = {\n byCard: 'card',\n byCrypto: 'crypto',\n} as const;\n\nexport type PaymentType = (typeof PAYMENT_TYPES)[keyof typeof PAYMENT_TYPES];\n\nexport const RECURRING_INTERVALS = {\n month: 'month',\n year: 'year',\n} as const;\n\nexport type RecurringInterval =\n (typeof RECURRING_INTERVALS)[keyof typeof RECURRING_INTERVALS];\n\nexport const SUBSCRIPTION_STATUSES = {\n // Initial states\n incomplete: 'incomplete',\n incompleteExpired: 'incomplete_expired',\n // Active states\n provisional: 'provisional',\n trialing: 'trialing',\n active: 'active',\n // Payment issues\n pastDue: 'past_due',\n unpaid: 'unpaid',\n // Cancelled states\n canceled: 'canceled',\n // Paused states\n paused: 'paused',\n} as const;\n\nexport type SubscriptionStatus =\n (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];\n\nexport const CRYPTO_PAYMENT_METHOD_ERRORS = {\n APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old',\n APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted',\n APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED:\n 'approval_transaction_max_verification_attempts_reached',\n INSUFFICIENT_BALANCE: 'insufficient_balance',\n INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',\n} as const;\n\nexport type CryptoPaymentMethodError =\n (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];\n\n/** only usd for now */\nexport type Currency = 'usd';\n\nexport type Product = {\n name: ProductType;\n currency: Currency;\n unitAmount: number;\n unitDecimals: number;\n};\n\n// state\nexport type Subscription = {\n id: string;\n products: Product[];\n currentPeriodStart: string; // ISO 8601\n currentPeriodEnd: string; // ISO 8601\n /** is subscription scheduled for cancellation */\n cancelAtPeriodEnd?: boolean;\n status: SubscriptionStatus;\n interval: RecurringInterval;\n paymentMethod: SubscriptionPaymentMethod;\n trialPeriodDays?: number;\n trialStart?: string; // ISO 8601\n trialEnd?: string; // ISO 8601\n /** Crypto payment only: next billing cycle date (e.g after 12 months) */\n endDate?: string; // ISO 8601\n /** The date the subscription was canceled. */\n canceledAt?: string; // ISO 8601\n /** The date the subscription was marked as inactive (paused/past_due/canceled). */\n inactiveAt?: string; // ISO 8601\n /** Whether the user is eligible for support features (priority support and filing claims). True for active subscriptions and inactive subscriptions within grace period. */\n isEligibleForSupport: boolean;\n billingCycles?: number;\n};\n\nexport type SubscriptionCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n card: {\n brand: string;\n /** display brand account for dual brand card */\n displayBrand: string;\n last4: string;\n };\n};\n\nexport type SubscriptionCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n crypto: {\n payerAddress: Hex;\n chainId: Hex;\n tokenSymbol: string;\n error?: CryptoPaymentMethodError;\n };\n};\n\nexport type SubscriptionPaymentMethod =\n | SubscriptionCardPaymentMethod\n | SubscriptionCryptoPaymentMethod;\n\nexport type GetSubscriptionsResponse = {\n customerId?: string;\n subscriptions: Subscription[];\n trialedProducts: ProductType[];\n /** The last subscription that user has subscribed to if any. */\n lastSubscription?: Subscription;\n};\n\nexport type StartSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n successUrl?: string;\n};\n\nexport type StartSubscriptionResponse = {\n checkoutSessionUrl: string;\n};\n\nexport type StartCryptoSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n chainId: Hex;\n payerAddress: Hex;\n /**\n * e.g. \"USDC\"\n */\n tokenSymbol: string;\n rawTransaction: Hex;\n isSponsored?: boolean;\n};\n\nexport type StartCryptoSubscriptionResponse = {\n subscriptionId: string;\n status: SubscriptionStatus;\n};\n\nexport type AuthUtils = {\n getAccessToken: () => Promise<string>;\n};\n\nexport type ProductPrice = {\n interval: RecurringInterval;\n unitAmount: number; // amount in the smallest unit of the currency, e.g., cents\n unitDecimals: number; // number of decimals for the smallest unit of the currency\n /** only usd for now */\n currency: Currency;\n trialPeriodDays: number;\n minBillingCycles: number;\n};\n\nexport type ProductPricing = {\n name: ProductType;\n prices: ProductPrice[];\n};\n\nexport type TokenPaymentInfo = {\n symbol: string;\n address: Hex;\n decimals: number;\n /**\n * example: {\n usd: '1.0',\n },\n */\n conversionRate: {\n usd: string;\n };\n};\n\nexport type ChainPaymentInfo = {\n chainId: Hex;\n paymentAddress: Hex;\n tokens: TokenPaymentInfo[];\n /**\n * Whether the chain supports sponsorship for the trialed subscription approval transaction.\n * This is used to determine if the user can be sponsored for the gas fees for the trialed subscription approval transaction.\n */\n isSponsorshipSupported?: boolean;\n};\n\nexport type PricingPaymentMethod = {\n type: PaymentType;\n chains?: ChainPaymentInfo[];\n};\n\nexport type PricingResponse = {\n products: ProductPricing[];\n paymentMethods: PricingPaymentMethod[];\n};\n\nexport type GetCryptoApproveTransactionRequest = {\n /**\n * payment chain ID\n */\n chainId: Hex;\n /**\n * Payment token address\n */\n paymentTokenAddress: Hex;\n productType: ProductType;\n interval: RecurringInterval;\n};\n\nexport type GetCryptoApproveTransactionResponse = {\n /**\n * The amount to approve\n * e.g: \"100000000\"\n */\n approveAmount: string;\n /**\n * The contract address (spender)\n */\n paymentAddress: Hex;\n /**\n * The payment token address\n */\n paymentTokenAddress: Hex;\n chainId: Hex;\n};\n\nexport const COHORT_NAMES = {\n POST_TX: 'post_tx',\n WALLET_HOME: 'wallet_home',\n} as const;\n\nexport type CohortName = (typeof COHORT_NAMES)[keyof typeof COHORT_NAMES];\n\nexport const BALANCE_CATEGORIES = {\n RANGE_0_99: '0-99',\n RANGE_100_999: '100-999',\n RANGE_1K_9_9K: '1k-9.9k',\n RANGE_10K_99_9K: '10k-99.9k',\n RANGE_100K_999_9K: '100k-999.9k',\n RANGE_1M_PLUS: '1M+',\n} as const;\n\nexport type BalanceCategory =\n (typeof BALANCE_CATEGORIES)[keyof typeof BALANCE_CATEGORIES];\n\nexport type Cohort = {\n cohort: string;\n eligibilityRate: number; // 0-1 probability of being assigned to this cohort\n priority: number; // lower number = higher priority\n eligible: boolean;\n};\n\nexport type SubscriptionEligibility = {\n product: ProductType;\n canSubscribe: boolean;\n minBalanceUSD: number;\n canViewEntryModal: boolean;\n cohorts: Cohort[];\n assignedCohort: string | null;\n hasAssignedCohortExpired: boolean;\n};\n\nexport const SubscriptionUserEvent = {\n ShieldEntryModalViewed: 'shield_entry_modal_viewed',\n ShieldCohortAssigned: 'shield_cohort_assigned',\n} as const;\n\nexport type SubscriptionUserEventType =\n (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];\n\nexport type SubmitUserEventRequest = {\n event: SubscriptionUserEventType;\n cohort?: string;\n};\n\nexport type AssignCohortRequest = {\n cohort: string;\n};\n\nexport type GetSubscriptionsEligibilitiesRequest = {\n balanceCategory?: BalanceCategory;\n};\n\n/**\n * Request object for submitting sponsorship intents.\n */\nexport type SubmitSponsorshipIntentsRequest = {\n chainId: Hex;\n address: Hex;\n products: ProductType[];\n paymentTokenSymbol: string;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type SubmitSponsorshipIntentsMethodParams = Pick<\n SubmitSponsorshipIntentsRequest,\n 'chainId' | 'address' | 'products'\n>;\n\nexport type ISubscriptionService = {\n getSubscriptions(): Promise<GetSubscriptionsResponse>;\n cancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n unCancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n startSubscriptionWithCard(\n request: StartSubscriptionRequest,\n ): Promise<StartSubscriptionResponse>;\n getBillingPortalUrl(): Promise<BillingPortalResponse>;\n getPricing(): Promise<PricingResponse>;\n startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse>;\n updatePaymentMethodCard(\n request: UpdatePaymentMethodCardRequest,\n ): Promise<UpdatePaymentMethodCardResponse>;\n updatePaymentMethodCrypto(\n request: UpdatePaymentMethodCryptoRequest,\n ): Promise<void>;\n getSubscriptionsEligibilities(\n request?: GetSubscriptionsEligibilitiesRequest,\n ): Promise<SubscriptionEligibility[]>;\n submitUserEvent(request: SubmitUserEventRequest): Promise<void>;\n assignUserToCohort(request: AssignCohortRequest): Promise<void>;\n\n /**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n */\n submitSponsorshipIntents(\n request: SubmitSponsorshipIntentsRequest,\n ): Promise<void>;\n};\n\nexport type UpdatePaymentMethodOpts =\n | ({\n paymentType: Extract<PaymentType, 'card'>;\n } & UpdatePaymentMethodCardRequest)\n | ({\n paymentType: Extract<PaymentType, 'crypto'>;\n } & UpdatePaymentMethodCryptoRequest);\n\nexport type UpdatePaymentMethodCardRequest = {\n /**\n * Subscription ID\n */\n subscriptionId: string;\n\n /**\n * Recurring interval\n */\n recurringInterval: RecurringInterval;\n successUrl?: string;\n};\n\nexport type UpdatePaymentMethodCardResponse = {\n redirectUrl: string;\n};\n\nexport type UpdatePaymentMethodCryptoRequest = {\n subscriptionId: string;\n chainId: Hex;\n payerAddress: Hex;\n tokenSymbol: string;\n /**\n * The raw transaction to pay for the subscription\n * Can be empty if retry after topping up balance\n */\n rawTransaction?: Hex;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n};\n\nexport type BillingPortalResponse = {\n url: string;\n};\n\n/**\n * The cached result of last selected payment methods for the user.\n * These details are being cached to be used internally to track the last selected payment method for the user. (e.g. for crypto subscriptions)\n */\nexport type CachedLastSelectedPaymentMethod = {\n type: PaymentType;\n paymentTokenAddress?: Hex;\n paymentTokenSymbol?: string;\n plan: RecurringInterval;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/subscription-controller",
3
- "version": "3.3.0-preview-ba016213",
3
+ "version": "3.3.0-preview-29587976",
4
4
  "description": "Handle user subscription",
5
5
  "keywords": [
6
6
  "MetaMask",