@metamask/subscription-controller 8.1.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -1
- package/dist/{SubscriptionController-method-action-types.d.mts → SubscriptionController-method-action-types.d.ts} +2 -2
- package/dist/SubscriptionController-method-action-types.d.ts.map +1 -0
- package/dist/{SubscriptionController-method-action-types.mjs → SubscriptionController-method-action-types.js} +1 -1
- package/dist/SubscriptionController-method-action-types.js.map +1 -0
- package/dist/{SubscriptionController.d.mts → SubscriptionController.d.ts} +18 -18
- package/dist/SubscriptionController.d.ts.map +1 -0
- package/dist/{SubscriptionController.mjs → SubscriptionController.js} +371 -274
- package/dist/SubscriptionController.js.map +1 -0
- package/dist/{SubscriptionService-method-action-types.d.cts → SubscriptionService-method-action-types.d.ts} +2 -2
- package/dist/SubscriptionService-method-action-types.d.ts.map +1 -0
- package/dist/{SubscriptionService-method-action-types.mjs → SubscriptionService-method-action-types.js} +1 -1
- package/dist/SubscriptionService-method-action-types.js.map +1 -0
- package/dist/{SubscriptionService-structs.d.cts → SubscriptionService-structs.d.ts} +164 -164
- package/dist/SubscriptionService-structs.d.ts.map +1 -0
- package/dist/{SubscriptionService-structs.mjs → SubscriptionService-structs.js} +4 -4
- package/dist/SubscriptionService-structs.js.map +1 -0
- package/dist/{SubscriptionService.d.cts → SubscriptionService.d.ts} +10 -10
- package/dist/SubscriptionService.d.ts.map +1 -0
- package/dist/{SubscriptionService.mjs → SubscriptionService.js} +141 -143
- package/dist/SubscriptionService.js.map +1 -0
- package/dist/{constants.d.cts → constants.d.ts} +1 -1
- package/dist/constants.d.ts.map +1 -0
- package/dist/{constants.mjs → constants.js} +3 -3
- package/dist/constants.js.map +1 -0
- package/dist/{errors.d.cts → errors.d.ts} +2 -2
- package/dist/errors.d.ts.map +1 -0
- package/dist/{errors.mjs → errors.js} +5 -1
- package/dist/errors.js.map +1 -0
- package/dist/{index.d.cts → index.d.ts} +12 -12
- package/dist/index.d.ts.map +1 -0
- package/dist/{index.mjs → index.js} +7 -7
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +5 -0
- package/dist/logger.js.map +1 -0
- package/dist/{selectors.d.mts → selectors.d.ts} +3 -3
- package/dist/selectors.d.ts.map +1 -0
- package/dist/{selectors.mjs → selectors.js} +2 -2
- package/dist/selectors.js.map +1 -0
- package/dist/{types.d.mts → types.d.ts} +47 -47
- package/dist/types.d.ts.map +1 -0
- package/dist/{types.mjs → types.js} +1 -1
- package/dist/types.js.map +1 -0
- package/package.json +19 -23
- package/dist/SubscriptionController-method-action-types.cjs +0 -7
- package/dist/SubscriptionController-method-action-types.cjs.map +0 -1
- package/dist/SubscriptionController-method-action-types.d.cts +0 -261
- package/dist/SubscriptionController-method-action-types.d.cts.map +0 -1
- package/dist/SubscriptionController-method-action-types.d.mts.map +0 -1
- package/dist/SubscriptionController-method-action-types.mjs.map +0 -1
- package/dist/SubscriptionController.cjs +0 -844
- package/dist/SubscriptionController.cjs.map +0 -1
- package/dist/SubscriptionController.d.cts +0 -268
- package/dist/SubscriptionController.d.cts.map +0 -1
- package/dist/SubscriptionController.d.mts.map +0 -1
- package/dist/SubscriptionController.mjs.map +0 -1
- package/dist/SubscriptionService-method-action-types.cjs +0 -7
- package/dist/SubscriptionService-method-action-types.cjs.map +0 -1
- package/dist/SubscriptionService-method-action-types.d.cts.map +0 -1
- package/dist/SubscriptionService-method-action-types.d.mts +0 -164
- package/dist/SubscriptionService-method-action-types.d.mts.map +0 -1
- package/dist/SubscriptionService-method-action-types.mjs.map +0 -1
- package/dist/SubscriptionService-structs.cjs +0 -209
- package/dist/SubscriptionService-structs.cjs.map +0 -1
- package/dist/SubscriptionService-structs.d.cts.map +0 -1
- package/dist/SubscriptionService-structs.d.mts +0 -889
- package/dist/SubscriptionService-structs.d.mts.map +0 -1
- package/dist/SubscriptionService-structs.mjs.map +0 -1
- package/dist/SubscriptionService.cjs +0 -497
- package/dist/SubscriptionService.cjs.map +0 -1
- package/dist/SubscriptionService.d.cts.map +0 -1
- package/dist/SubscriptionService.d.mts +0 -155
- package/dist/SubscriptionService.d.mts.map +0 -1
- package/dist/SubscriptionService.mjs.map +0 -1
- package/dist/constants.cjs +0 -74
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.d.cts.map +0 -1
- package/dist/constants.d.mts +0 -50
- package/dist/constants.d.mts.map +0 -1
- package/dist/constants.mjs.map +0 -1
- package/dist/errors.cjs +0 -72
- package/dist/errors.cjs.map +0 -1
- package/dist/errors.d.cts.map +0 -1
- package/dist/errors.d.mts +0 -34
- package/dist/errors.d.mts.map +0 -1
- package/dist/errors.mjs.map +0 -1
- package/dist/index.cjs +0 -35
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -12
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/logger.cjs +0 -8
- package/dist/logger.cjs.map +0 -1
- package/dist/logger.d.cts +0 -5
- package/dist/logger.d.cts.map +0 -1
- package/dist/logger.d.mts +0 -5
- package/dist/logger.d.mts.map +0 -1
- package/dist/logger.mjs +0 -5
- package/dist/logger.mjs.map +0 -1
- package/dist/selectors.cjs +0 -52
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts +0 -38
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs.map +0 -1
- package/dist/types.cjs +0 -100
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.cts +0 -645
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/types.mjs.map +0 -1
|
@@ -47,4 +47,4 @@ export declare enum SubscriptionServiceErrorMessage {
|
|
|
47
47
|
export declare const DEFAULT_POLLING_INTERVAL: number;
|
|
48
48
|
export declare const ACTIVE_SUBSCRIPTION_STATUSES: string[];
|
|
49
49
|
export {};
|
|
50
|
-
//# sourceMappingURL=constants.d.
|
|
50
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD,oBAAY,GAAG;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,KAAK,YAAY,GAAG;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAcF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,CAKjD;AAED,oBAAY,kCAAkC;IAC5C,qBAAqB,wDAAmD;IACxE,iBAAiB,oDAA+C;IAChE,yBAAyB,yEAAoE;IAC7F,6CAA6C,8FAAyF;IACtI,sBAAsB,0DAAqD;IAC3E,oBAAoB,qDAAgD;IACpE,qCAAqC,2EAAsE;IAC3G,mCAAmC,sGAAiG;IACpI,iBAAiB,oDAA+C;CACjE;AAED,oBAAY,+BAA+B;IACzC,wBAAwB,gCAAgC;IACxD,mBAAmB,2BAA2B;IAC9C,0BAA0B,kCAAkC;IAC5D,4BAA4B,oCAAoC;IAChE,iCAAiC,2CAA2C;IAC5E,mCAAmC,6CAA6C;IAChF,sBAAsB,+GAA+G;IACrI,+BAA+B,yCAAyC;IACxE,iCAAiC,2CAA2C;IAC5E,qCAAqC,8CAA8C;IACnF,uBAAuB,gCAAgC;IACvD,0BAA0B,oCAAoC;IAC9D,gCAAgC,yCAAyC;IACzE,mBAAmB,2BAA2B;IAC9C,kBAAkB,0BAA0B;IAC5C,2BAA2B,qCAAqC;CACjE;AAED,eAAO,MAAM,wBAAwB,QAAiB,CAAC;AAEvD,eAAO,MAAM,4BAA4B,EAIpC,MAAM,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SUBSCRIPTION_STATUSES } from
|
|
1
|
+
import { SUBSCRIPTION_STATUSES } from './types.js';
|
|
2
2
|
export const controllerName = 'SubscriptionController';
|
|
3
3
|
export var Env;
|
|
4
4
|
(function (Env) {
|
|
@@ -61,10 +61,10 @@ export var SubscriptionServiceErrorMessage;
|
|
|
61
61
|
SubscriptionServiceErrorMessage["FailedToGetPricing"] = "Failed to get pricing";
|
|
62
62
|
SubscriptionServiceErrorMessage["FailedToGetBillingPortalUrl"] = "Failed to get billing portal url";
|
|
63
63
|
})(SubscriptionServiceErrorMessage || (SubscriptionServiceErrorMessage = {}));
|
|
64
|
-
export const DEFAULT_POLLING_INTERVAL = 5 * 60 *
|
|
64
|
+
export const DEFAULT_POLLING_INTERVAL = 5 * 60 * 1_000; // 5 minutes
|
|
65
65
|
export const ACTIVE_SUBSCRIPTION_STATUSES = [
|
|
66
66
|
SUBSCRIPTION_STATUSES.active,
|
|
67
67
|
SUBSCRIPTION_STATUSES.trialing,
|
|
68
68
|
SUBSCRIPTION_STATUSES.provisional,
|
|
69
69
|
];
|
|
70
|
-
//# sourceMappingURL=constants.
|
|
70
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEvD,MAAM,CAAN,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,kBAAW,CAAA;IACX,kBAAW,CAAA;IACX,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,KAAH,GAAG,QAId;AAMD,MAAM,QAAQ,GAA8B;IAC1C,GAAG,EAAE;QACH,kBAAkB,EAAE,6CAA6C;KAClE;IACD,GAAG,EAAE;QACH,kBAAkB,EAAE,6CAA6C;KAClE;IACD,GAAG,EAAE;QACH,kBAAkB,EAAE,yCAAyC;KAC9D;CAC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const controllerName = 'SubscriptionController';\n\nexport enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\ntype EnvUrlsEntry = {\n subscriptionApiUrl: string;\n};\n\nconst ENV_URLS: Record<Env, EnvUrlsEntry> = {\n dev: {\n subscriptionApiUrl: 'https://subscription.dev-api.cx.metamask.io',\n },\n uat: {\n subscriptionApiUrl: 'https://subscription.uat-api.cx.metamask.io',\n },\n prd: {\n subscriptionApiUrl: 'https://subscription.api.cx.metamask.io',\n },\n};\n\n/**\n * Validates and returns correct environment endpoints\n *\n * @param env - environment field\n * @returns the correct environment url\n * @throws on invalid environment passed\n */\nexport function getEnvUrls(env: Env): EnvUrlsEntry {\n if (!ENV_URLS[env]) {\n throw new Error('invalid environment configuration');\n }\n return ENV_URLS[env];\n}\n\nexport enum SubscriptionControllerErrorMessage {\n UserAlreadySubscribed = `${controllerName} - User is already subscribed`,\n UserNotSubscribed = `${controllerName} - User is not subscribed`,\n SubscriptionProductsEmpty = `${controllerName} - Subscription products array cannot be empty`,\n PaymentTokenAddressAndSymbolRequiredForCrypto = `${controllerName} - Payment token address and symbol are required for crypto payment`,\n PaymentMethodNotCrypto = `${controllerName} - Payment method is not crypto`,\n ProductPriceNotFound = `${controllerName} - Product price not found`,\n SubscriptionNotValidForCryptoApproval = `${controllerName} - Subscription is not valid for crypto approval`,\n CryptoApprovalRequiresShieldApprove = `${controllerName} - Crypto approval is only supported for Shield ERC-20 approve transactions`,\n LinkRewardsFailed = `${controllerName} - Failed to link rewards`,\n}\n\nexport enum SubscriptionServiceErrorMessage {\n FailedToGetSubscriptions = 'Failed to get subscriptions',\n FailedToGetBenefits = 'Failed to get benefits',\n FailedToCancelSubscription = 'Failed to cancel subscription',\n FailedToUncancelSubscription = 'Failed to uncancel subscription',\n FailedToStartSubscriptionWithCard = 'Failed to start subscription with card',\n FailedToStartSubscriptionWithCrypto = 'Failed to start subscription with crypto',\n InvalidCryptoAuthCombo = 'Crypto subscription requires exactly one of rawTransaction (erc20_approval) or delegationHash (delegation)',\n FailedToUpdatePaymentMethodCard = 'Failed to update payment method card',\n FailedToUpdatePaymentMethodCrypto = 'Failed to update payment method crypto',\n FailedToGetSubscriptionsEligibilities = 'Failed to get subscriptions eligibilities',\n FailedToSubmitUserEvent = 'Failed to submit user event',\n FailedToAssignUserToCohort = 'Failed to assign user to cohort',\n FailedToSubmitSponsorshipIntents = 'Failed to submit sponsorship intents',\n FailedToLinkRewards = 'Failed to link rewards',\n FailedToGetPricing = 'Failed to get pricing',\n FailedToGetBillingPortalUrl = 'Failed to get billing portal url',\n}\n\nexport const DEFAULT_POLLING_INTERVAL = 5 * 60 * 1_000; // 5 minutes\n\nexport const ACTIVE_SUBSCRIPTION_STATUSES = [\n SUBSCRIPTION_STATUSES.active,\n SUBSCRIPTION_STATUSES.trialing,\n SUBSCRIPTION_STATUSES.provisional,\n] as string[];\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SubscriptionApiError } from
|
|
1
|
+
import { SubscriptionApiError } from './types.js';
|
|
2
2
|
export declare class SubscriptionServiceError extends Error {
|
|
3
3
|
/**
|
|
4
4
|
* The underlying error that caused this error.
|
|
@@ -31,4 +31,4 @@ export declare function createSentryError(message: string, cause: Error): Error;
|
|
|
31
31
|
* @param statusCode - The status code of the response.
|
|
32
32
|
*/
|
|
33
33
|
export declare function composeSubscriptionApiErrorMessage(error: SubscriptionApiError, statusCode: number): string;
|
|
34
|
-
//# sourceMappingURL=errors.d.
|
|
34
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,qBAAa,wBAAyB,SAAQ,KAAK;IACjD;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,YACE,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,KAAK,CAAC;KACf,EAKF;CACF;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,KAAK,CAAC,CA2BhB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAOtE;AAED;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,oBAAoB,EAC3B,UAAU,EAAE,MAAM,GACjB,MAAM,CAMR"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export class SubscriptionServiceError extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* The underlying error that caused this error.
|
|
4
|
+
*/
|
|
5
|
+
cause;
|
|
2
6
|
constructor(message, options) {
|
|
3
7
|
super(message);
|
|
4
8
|
this.name = 'SubscriptionServiceError';
|
|
@@ -62,4 +66,4 @@ export function composeSubscriptionApiErrorMessage(error, statusCode) {
|
|
|
62
66
|
}
|
|
63
67
|
return baseErrorMessage;
|
|
64
68
|
}
|
|
65
|
-
//# sourceMappingURL=errors.
|
|
69
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD;;OAEG;IACH,KAAK,CAAS;IAEd,YACE,OAAe,EACf,OAEC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;IAC9B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,QAAkB;IAElB,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,EAAE,GAA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OAAO,CAEpC,CAAC;IACF,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAE1B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC,CAChD,KAA2B,EAC3B,UAAkB;IAElB,IAAI,gBAAgB,GAAG,UAAU,KAAK,CAAC,OAAO,IAAI,eAAe,iBAAiB,UAAU,IAAI,qBAAqB,EAAE,CAAC;IACxH,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACpB,gBAAgB,IAAI,gBAAgB,KAAK,CAAC,SAAS,EAAE,CAAC;IACxD,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import { SubscriptionApiError } from './types.js';\n\nexport class SubscriptionServiceError extends Error {\n /**\n * The underlying error that caused this error.\n */\n cause?: Error;\n\n constructor(\n message: string,\n options?: {\n cause?: Error;\n },\n ) {\n super(message);\n this.name = 'SubscriptionServiceError';\n this.cause = options?.cause;\n }\n}\n\n/**\n * Get an error from a response.\n *\n * @param response - The response to get an error from.\n * @returns An error.\n */\nexport async function getSubscriptionErrorFromResponse(\n response: Response,\n): Promise<Error> {\n const contentType = response.headers?.get('content-type');\n const statusCode = response.status;\n try {\n if (contentType?.includes('application/json')) {\n const json = (await response.json()) as SubscriptionApiError;\n const subscriptionApiErrorMessage = composeSubscriptionApiErrorMessage(\n json,\n statusCode,\n );\n return new Error(subscriptionApiErrorMessage);\n } else if (contentType?.includes('text/plain')) {\n const text = await response.text();\n const networkError = `error: ${text}, statusCode: ${statusCode}`;\n return new Error(networkError);\n }\n\n const error =\n 'data' in response && typeof response.data === 'string'\n ? response.data\n : 'Unknown error';\n const networkError = `error: ${error}, statusCode: ${statusCode}`;\n return new Error(networkError);\n } catch (error) {\n const errMessage = error instanceof Error ? error.message : 'Unknown error';\n return new Error(`HTTP ${statusCode} error: ${errMessage}`);\n }\n}\n\n/**\n * Creates an error instance with a readable message and the root cause.\n *\n * @param message - The error message to create a Sentry error from.\n * @param cause - The inner error to create a Sentry error from.\n * @returns A Sentry error.\n */\nexport function createSentryError(message: string, cause: Error): Error {\n const sentryError = new Error(message) as Error & {\n cause: Error;\n };\n sentryError.cause = cause;\n\n return sentryError;\n}\n\n/**\n * Compose an error message from a Subscription API error.\n *\n * @param error - The Subscription API error to compose an error message from.\n * @returns An error message.\n * @param statusCode - The status code of the response.\n */\nexport function composeSubscriptionApiErrorMessage(\n error: SubscriptionApiError,\n statusCode: number,\n): string {\n let baseErrorMessage = `error: ${error.message ?? 'Unknown error'}, statusCode: ${statusCode ?? 'Unknown status code'}`;\n if (error.errorCode) {\n baseErrorMessage += `, errorCode: ${error.errorCode}`;\n }\n return baseErrorMessage;\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export type { SubscriptionControllerActions, SubscriptionControllerState, SubscriptionControllerEvents, SubscriptionControllerGetStateAction, SubscriptionControllerMessenger, SubscriptionControllerOptions, SubscriptionControllerStateChangeEvent, } from
|
|
2
|
-
export type { SubscriptionControllerGetPricingAction, SubscriptionControllerGetSubscriptionsAction, SubscriptionControllerGetBenefitsAction, SubscriptionControllerGetSubscriptionByProductAction, SubscriptionControllerGetSubscriptionsEligibilitiesAction, SubscriptionControllerCancelSubscriptionAction, SubscriptionControllerUnCancelSubscriptionAction, SubscriptionControllerStartSubscriptionWithCardAction, SubscriptionControllerStartSubscriptionWithCryptoAction, SubscriptionControllerSubmitSubscriptionCryptoApprovalAction, SubscriptionControllerGetCryptoApproveTransactionParamsAction, SubscriptionControllerUpdatePaymentMethodAction, SubscriptionControllerGetBillingPortalUrlAction, SubscriptionControllerCacheLastSelectedPaymentMethodAction, SubscriptionControllerClearLastSelectedPaymentMethodAction, SubscriptionControllerSubmitSponsorshipIntentsAction, SubscriptionControllerSubmitUserEventAction, SubscriptionControllerAssignUserToCohortAction, SubscriptionControllerLinkRewardsAction, SubscriptionControllerGetTokenApproveAmountAction, SubscriptionControllerGetTokenMinimumBalanceAmountAction, SubscriptionControllerClearStateAction, SubscriptionControllerTriggerAccessTokenRefreshAction, SubscriptionControllerStopAllPollingAction, } from
|
|
3
|
-
export { SubscriptionController, getDefaultSubscriptionControllerState, } from
|
|
4
|
-
export type { SubscriptionApiError, Subscription, PerpsBenefitUsage, PredictBenefitUsage, SubscriptionBenefitsResponse, SubscriptionBenefitsState, SwapsBenefitUsage, AuthUtils, CancelSubscriptionRequest, CancelType, ISubscriptionService, StartCryptoSubscriptionRequest, StartDelegationCryptoSubscriptionRequest, StartErc20CryptoSubscriptionRequest, StartCryptoSubscriptionResponse, StartSubscriptionRequest, StartSubscriptionResponse, GetCryptoApproveTransactionRequest, GetCryptoApproveTransactionResponse, SubmitSubscriptionCryptoApprovalRequest, SubscriptionCardPaymentMethod, SubscriptionCryptoPaymentMethod, SubscriptionPaymentMethod, SubmitUserEventRequest, SubmitSponsorshipIntentsRequest, SubscriptionEligibility, SubscriptionUserEventType, RecurringInterval, SubscriptionStatus, PaymentType, Product, ProductType, ProductPrice, ProductPricing, TokenPaymentInfo, SpotTokenPaymentInfo, VaultTokenPaymentInfo, ChainPaymentInfo, Currency, CryptoAuthMethod, PricingPaymentMethod, PricingCardPaymentMethod, PricingCryptoPaymentMethod, PricingResponse, UpdatePaymentMethodOpts, BillingPortalResponse, CryptoPaymentMethodError, UpdatePaymentMethodCryptoRequest, UpdatePaymentMethodCardRequest, UpdatePaymentMethodCardResponse, CachedLastSelectedPaymentMethod, CacheLastSelectedPaymentMethodRequest, SubmitSponsorshipIntentsMethodParams, Cohort, CohortName, BalanceCategory, AssignCohortRequest, GetSubscriptionsEligibilitiesRequest, ModalType, MoneyAccountEntitlements, MoneyAccountPlusClaim, ProductEntitlementFeatureMap, ProductEntitlements, ShieldEntitlements, } from
|
|
5
|
-
export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, CRYPTO_AUTH_METHODS, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE, MoneyAccountFeature, ShieldFeature, } from
|
|
6
|
-
export { selectHasEntitlement, selectIsActiveSubscriber, selectIsUsageAvailable, } from
|
|
7
|
-
export { SubscriptionServiceError } from
|
|
8
|
-
export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from
|
|
9
|
-
export type { SubscriptionServiceOptions, SubscriptionServiceMessenger, SubscriptionServiceActions, SubscriptionServiceEvents, SubscriptionServiceCacheUpdatedEvent, SubscriptionServiceGranularCacheUpdatedEvent, SubscriptionServiceInvalidateQueriesAction, } from
|
|
10
|
-
export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL, } from
|
|
11
|
-
export type { SubscriptionServiceGetSubscriptionsAction, SubscriptionServiceGetBenefitsAction, SubscriptionServiceCancelSubscriptionAction, SubscriptionServiceUnCancelSubscriptionAction, SubscriptionServiceStartSubscriptionWithCardAction, SubscriptionServiceStartSubscriptionWithCryptoAction, SubscriptionServiceUpdatePaymentMethodCardAction, SubscriptionServiceUpdatePaymentMethodCryptoAction, SubscriptionServiceGetSubscriptionsEligibilitiesAction, SubscriptionServiceSubmitUserEventAction, SubscriptionServiceAssignUserToCohortAction, SubscriptionServiceSubmitSponsorshipIntentsAction, SubscriptionServiceLinkRewardsAction, SubscriptionServiceGetPricingAction, SubscriptionServiceGetBillingPortalUrlAction, } from
|
|
12
|
-
//# sourceMappingURL=index.d.
|
|
1
|
+
export type { SubscriptionControllerActions, SubscriptionControllerState, SubscriptionControllerEvents, SubscriptionControllerGetStateAction, SubscriptionControllerMessenger, SubscriptionControllerOptions, SubscriptionControllerStateChangeEvent, } from './SubscriptionController.js';
|
|
2
|
+
export type { SubscriptionControllerGetPricingAction, SubscriptionControllerGetSubscriptionsAction, SubscriptionControllerGetBenefitsAction, SubscriptionControllerGetSubscriptionByProductAction, SubscriptionControllerGetSubscriptionsEligibilitiesAction, SubscriptionControllerCancelSubscriptionAction, SubscriptionControllerUnCancelSubscriptionAction, SubscriptionControllerStartSubscriptionWithCardAction, SubscriptionControllerStartSubscriptionWithCryptoAction, SubscriptionControllerSubmitSubscriptionCryptoApprovalAction, SubscriptionControllerGetCryptoApproveTransactionParamsAction, SubscriptionControllerUpdatePaymentMethodAction, SubscriptionControllerGetBillingPortalUrlAction, SubscriptionControllerCacheLastSelectedPaymentMethodAction, SubscriptionControllerClearLastSelectedPaymentMethodAction, SubscriptionControllerSubmitSponsorshipIntentsAction, SubscriptionControllerSubmitUserEventAction, SubscriptionControllerAssignUserToCohortAction, SubscriptionControllerLinkRewardsAction, SubscriptionControllerGetTokenApproveAmountAction, SubscriptionControllerGetTokenMinimumBalanceAmountAction, SubscriptionControllerClearStateAction, SubscriptionControllerTriggerAccessTokenRefreshAction, SubscriptionControllerStopAllPollingAction, } from './SubscriptionController-method-action-types.js';
|
|
3
|
+
export { SubscriptionController, getDefaultSubscriptionControllerState, } from './SubscriptionController.js';
|
|
4
|
+
export type { SubscriptionApiError, Subscription, PerpsBenefitUsage, PredictBenefitUsage, SubscriptionBenefitsResponse, SubscriptionBenefitsState, SwapsBenefitUsage, AuthUtils, CancelSubscriptionRequest, CancelType, ISubscriptionService, StartCryptoSubscriptionRequest, StartDelegationCryptoSubscriptionRequest, StartErc20CryptoSubscriptionRequest, StartCryptoSubscriptionResponse, StartSubscriptionRequest, StartSubscriptionResponse, GetCryptoApproveTransactionRequest, GetCryptoApproveTransactionResponse, SubmitSubscriptionCryptoApprovalRequest, SubscriptionCardPaymentMethod, SubscriptionCryptoPaymentMethod, SubscriptionPaymentMethod, SubmitUserEventRequest, SubmitSponsorshipIntentsRequest, SubscriptionEligibility, SubscriptionUserEventType, RecurringInterval, SubscriptionStatus, PaymentType, Product, ProductType, ProductPrice, ProductPricing, TokenPaymentInfo, SpotTokenPaymentInfo, VaultTokenPaymentInfo, ChainPaymentInfo, Currency, CryptoAuthMethod, PricingPaymentMethod, PricingCardPaymentMethod, PricingCryptoPaymentMethod, PricingResponse, UpdatePaymentMethodOpts, BillingPortalResponse, CryptoPaymentMethodError, UpdatePaymentMethodCryptoRequest, UpdatePaymentMethodCardRequest, UpdatePaymentMethodCardResponse, CachedLastSelectedPaymentMethod, CacheLastSelectedPaymentMethodRequest, SubmitSponsorshipIntentsMethodParams, Cohort, CohortName, BalanceCategory, AssignCohortRequest, GetSubscriptionsEligibilitiesRequest, ModalType, MoneyAccountEntitlements, MoneyAccountPlusClaim, ProductEntitlementFeatureMap, ProductEntitlements, ShieldEntitlements, } from './types.js';
|
|
5
|
+
export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, CRYPTO_AUTH_METHODS, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE, MoneyAccountFeature, ShieldFeature, } from './types.js';
|
|
6
|
+
export { selectHasEntitlement, selectIsActiveSubscriber, selectIsUsageAvailable, } from './selectors.js';
|
|
7
|
+
export { SubscriptionServiceError } from './errors.js';
|
|
8
|
+
export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from './constants.js';
|
|
9
|
+
export type { SubscriptionServiceOptions, SubscriptionServiceMessenger, SubscriptionServiceActions, SubscriptionServiceEvents, SubscriptionServiceCacheUpdatedEvent, SubscriptionServiceGranularCacheUpdatedEvent, SubscriptionServiceInvalidateQueriesAction, } from './SubscriptionService.js';
|
|
10
|
+
export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL, } from './SubscriptionService.js';
|
|
11
|
+
export type { SubscriptionServiceGetSubscriptionsAction, SubscriptionServiceGetBenefitsAction, SubscriptionServiceCancelSubscriptionAction, SubscriptionServiceUnCancelSubscriptionAction, SubscriptionServiceStartSubscriptionWithCardAction, SubscriptionServiceStartSubscriptionWithCryptoAction, SubscriptionServiceUpdatePaymentMethodCardAction, SubscriptionServiceUpdatePaymentMethodCryptoAction, SubscriptionServiceGetSubscriptionsEligibilitiesAction, SubscriptionServiceSubmitUserEventAction, SubscriptionServiceAssignUserToCohortAction, SubscriptionServiceSubmitSponsorshipIntentsAction, SubscriptionServiceLinkRewardsAction, SubscriptionServiceGetPricingAction, SubscriptionServiceGetBillingPortalUrlAction, } from './SubscriptionService-method-action-types.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,+BAA+B,EAC/B,6BAA6B,EAC7B,sCAAsC,GACvC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,sCAAsC,EACtC,4CAA4C,EAC5C,uCAAuC,EACvC,oDAAoD,EACpD,yDAAyD,EACzD,8CAA8C,EAC9C,gDAAgD,EAChD,qDAAqD,EACrD,uDAAuD,EACvD,4DAA4D,EAC5D,6DAA6D,EAC7D,+CAA+C,EAC/C,+CAA+C,EAC/C,0DAA0D,EAC1D,0DAA0D,EAC1D,oDAAoD,EACpD,2CAA2C,EAC3C,8CAA8C,EAC9C,uCAAuC,EACvC,iDAAiD,EACjD,wDAAwD,EACxD,sCAAsC,EACtC,qDAAqD,EACrD,0CAA0C,GAC3C,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,yBAAyB,EACzB,iBAAiB,EACjB,SAAS,EACT,yBAAyB,EACzB,UAAU,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,wCAAwC,EACxC,mCAAmC,EACnC,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,kCAAkC,EAClC,mCAAmC,EACnC,uCAAu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I,uBAAuB,EACtC,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,yCAAyC,EACzC,oCAAoC,EACpC,2CAA2C,EAC3C,6CAA6C,EAC7C,kDAAkD,EAClD,oDAAoD,EACpD,gDAAgD,EAChD,kDAAkD,EAClD,sDAAsD,EACtD,wCAAwC,EACxC,2CAA2C,EAC3C,iDAAiD,EACjD,oCAAoC,EACpC,mCAAmC,EACnC,4CAA4C,GAC7C,MAAM,8CAA8C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { SubscriptionController, getDefaultSubscriptionControllerState } from
|
|
2
|
-
export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, CRYPTO_AUTH_METHODS, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE, MoneyAccountFeature, ShieldFeature } from
|
|
3
|
-
export { selectHasEntitlement, selectIsActiveSubscriber, selectIsUsageAvailable } from
|
|
4
|
-
export { SubscriptionServiceError } from
|
|
5
|
-
export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage } from
|
|
6
|
-
export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL } from
|
|
7
|
-
//# sourceMappingURL=index.
|
|
1
|
+
export { SubscriptionController, getDefaultSubscriptionControllerState, } from './SubscriptionController.js';
|
|
2
|
+
export { CANCEL_TYPES, CRYPTO_PAYMENT_METHOD_ERRORS, SUBSCRIPTION_STATUSES, PRODUCT_TYPES, RECURRING_INTERVALS, PAYMENT_TYPES, CRYPTO_AUTH_METHODS, SubscriptionUserEvent, COHORT_NAMES, BALANCE_CATEGORIES, MODAL_TYPE, MoneyAccountFeature, ShieldFeature, } from './types.js';
|
|
3
|
+
export { selectHasEntitlement, selectIsActiveSubscriber, selectIsUsageAvailable, } from './selectors.js';
|
|
4
|
+
export { SubscriptionServiceError } from './errors.js';
|
|
5
|
+
export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from './constants.js';
|
|
6
|
+
export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL, } from './SubscriptionService.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmCA,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,MAAM,6BAA6B,CAAC;AAmErC,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,GAAG,EACH,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,GACjB,MAAM,0BAA0B,CAAC","sourcesContent":["export type {\n SubscriptionControllerActions,\n SubscriptionControllerState,\n SubscriptionControllerEvents,\n SubscriptionControllerGetStateAction,\n SubscriptionControllerMessenger,\n SubscriptionControllerOptions,\n SubscriptionControllerStateChangeEvent,\n} from './SubscriptionController.js';\nexport type {\n SubscriptionControllerGetPricingAction,\n SubscriptionControllerGetSubscriptionsAction,\n SubscriptionControllerGetBenefitsAction,\n SubscriptionControllerGetSubscriptionByProductAction,\n SubscriptionControllerGetSubscriptionsEligibilitiesAction,\n SubscriptionControllerCancelSubscriptionAction,\n SubscriptionControllerUnCancelSubscriptionAction,\n SubscriptionControllerStartSubscriptionWithCardAction,\n SubscriptionControllerStartSubscriptionWithCryptoAction,\n SubscriptionControllerSubmitSubscriptionCryptoApprovalAction,\n SubscriptionControllerGetCryptoApproveTransactionParamsAction,\n SubscriptionControllerUpdatePaymentMethodAction,\n SubscriptionControllerGetBillingPortalUrlAction,\n SubscriptionControllerCacheLastSelectedPaymentMethodAction,\n SubscriptionControllerClearLastSelectedPaymentMethodAction,\n SubscriptionControllerSubmitSponsorshipIntentsAction,\n SubscriptionControllerSubmitUserEventAction,\n SubscriptionControllerAssignUserToCohortAction,\n SubscriptionControllerLinkRewardsAction,\n SubscriptionControllerGetTokenApproveAmountAction,\n SubscriptionControllerGetTokenMinimumBalanceAmountAction,\n SubscriptionControllerClearStateAction,\n SubscriptionControllerTriggerAccessTokenRefreshAction,\n SubscriptionControllerStopAllPollingAction,\n} from './SubscriptionController-method-action-types.js';\nexport {\n SubscriptionController,\n getDefaultSubscriptionControllerState,\n} from './SubscriptionController.js';\nexport type {\n SubscriptionApiError,\n Subscription,\n PerpsBenefitUsage,\n PredictBenefitUsage,\n SubscriptionBenefitsResponse,\n SubscriptionBenefitsState,\n SwapsBenefitUsage,\n AuthUtils,\n CancelSubscriptionRequest,\n CancelType,\n ISubscriptionService,\n StartCryptoSubscriptionRequest,\n StartDelegationCryptoSubscriptionRequest,\n StartErc20CryptoSubscriptionRequest,\n StartCryptoSubscriptionResponse,\n StartSubscriptionRequest,\n StartSubscriptionResponse,\n GetCryptoApproveTransactionRequest,\n GetCryptoApproveTransactionResponse,\n SubmitSubscriptionCryptoApprovalRequest,\n SubscriptionCardPaymentMethod,\n SubscriptionCryptoPaymentMethod,\n SubscriptionPaymentMethod,\n SubmitUserEventRequest,\n SubmitSponsorshipIntentsRequest,\n SubscriptionEligibility,\n SubscriptionUserEventType,\n RecurringInterval,\n SubscriptionStatus,\n PaymentType,\n Product,\n ProductType,\n ProductPrice,\n ProductPricing,\n TokenPaymentInfo,\n SpotTokenPaymentInfo,\n VaultTokenPaymentInfo,\n ChainPaymentInfo,\n Currency,\n CryptoAuthMethod,\n PricingPaymentMethod,\n PricingCardPaymentMethod,\n PricingCryptoPaymentMethod,\n PricingResponse,\n UpdatePaymentMethodOpts,\n BillingPortalResponse,\n CryptoPaymentMethodError,\n UpdatePaymentMethodCryptoRequest,\n UpdatePaymentMethodCardRequest,\n UpdatePaymentMethodCardResponse,\n CachedLastSelectedPaymentMethod,\n CacheLastSelectedPaymentMethodRequest,\n SubmitSponsorshipIntentsMethodParams,\n Cohort,\n CohortName,\n BalanceCategory,\n AssignCohortRequest,\n GetSubscriptionsEligibilitiesRequest,\n ModalType,\n MoneyAccountEntitlements,\n MoneyAccountPlusClaim,\n ProductEntitlementFeatureMap,\n ProductEntitlements,\n ShieldEntitlements,\n} from './types.js';\nexport {\n CANCEL_TYPES,\n CRYPTO_PAYMENT_METHOD_ERRORS,\n SUBSCRIPTION_STATUSES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n PAYMENT_TYPES,\n CRYPTO_AUTH_METHODS,\n SubscriptionUserEvent,\n COHORT_NAMES,\n BALANCE_CATEGORIES,\n MODAL_TYPE,\n MoneyAccountFeature,\n ShieldFeature,\n} from './types.js';\nexport {\n selectHasEntitlement,\n selectIsActiveSubscriber,\n selectIsUsageAvailable,\n} from './selectors.js';\nexport { SubscriptionServiceError } from './errors.js';\nexport {\n Env,\n SubscriptionControllerErrorMessage,\n SubscriptionServiceErrorMessage,\n} from './constants.js';\nexport type {\n SubscriptionServiceOptions,\n SubscriptionServiceMessenger,\n SubscriptionServiceActions,\n SubscriptionServiceEvents,\n SubscriptionServiceCacheUpdatedEvent,\n SubscriptionServiceGranularCacheUpdatedEvent,\n SubscriptionServiceInvalidateQueriesAction,\n} from './SubscriptionService.js';\nexport {\n SubscriptionService,\n serviceName as subscriptionServiceName,\n SUBSCRIPTION_URL,\n} from './SubscriptionService.js';\nexport type {\n SubscriptionServiceGetSubscriptionsAction,\n SubscriptionServiceGetBenefitsAction,\n SubscriptionServiceCancelSubscriptionAction,\n SubscriptionServiceUnCancelSubscriptionAction,\n SubscriptionServiceStartSubscriptionWithCardAction,\n SubscriptionServiceStartSubscriptionWithCryptoAction,\n SubscriptionServiceUpdatePaymentMethodCardAction,\n SubscriptionServiceUpdatePaymentMethodCryptoAction,\n SubscriptionServiceGetSubscriptionsEligibilitiesAction,\n SubscriptionServiceSubmitUserEventAction,\n SubscriptionServiceAssignUserToCohortAction,\n SubscriptionServiceSubmitSponsorshipIntentsAction,\n SubscriptionServiceLinkRewardsAction,\n SubscriptionServiceGetPricingAction,\n SubscriptionServiceGetBillingPortalUrlAction,\n} from './SubscriptionService-method-action-types.js';\n"]}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI1E,eAAO,MAAM,aAAa,0BAAsC,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC,cAAc,CAAC,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nimport { controllerName } from './constants.js';\n\nexport const projectLogger = createProjectLogger(controllerName);\n\nexport { createModuleLogger };\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SubscriptionControllerState } from
|
|
2
|
-
import type { ProductEntitlementFeatureMap, ProductType } from
|
|
1
|
+
import type { SubscriptionControllerState } from './SubscriptionController.js';
|
|
2
|
+
import type { ProductEntitlementFeatureMap, ProductType } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Returns whether a specific product feature entitlement is enabled.
|
|
5
5
|
*
|
|
@@ -35,4 +35,4 @@ export declare function selectIsUsageAvailable<TProduct extends ProductType>(sta
|
|
|
35
35
|
* @returns Whether the user is an active subscriber for the product.
|
|
36
36
|
*/
|
|
37
37
|
export declare function selectIsActiveSubscriber(state: SubscriptionControllerState, productType: ProductType): boolean;
|
|
38
|
-
//# sourceMappingURL=selectors.d.
|
|
38
|
+
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE5E;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,WAAW,EAC/D,KAAK,EAAE,2BAA2B,EAClC,WAAW,EAAE,QAAQ,EACrB,OAAO,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAC9C,OAAO,CAOT;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,SAAS,WAAW,EACjE,KAAK,EAAE,2BAA2B,EAClC,WAAW,EAAE,QAAQ,EACrB,OAAO,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAC9C,OAAO,CAET;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,2BAA2B,EAClC,WAAW,EAAE,WAAW,GACvB,OAAO,CAMT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTIVE_SUBSCRIPTION_STATUSES } from
|
|
1
|
+
import { ACTIVE_SUBSCRIPTION_STATUSES } from './constants.js';
|
|
2
2
|
/**
|
|
3
3
|
* Returns whether a specific product feature entitlement is enabled.
|
|
4
4
|
*
|
|
@@ -43,4 +43,4 @@ export function selectIsActiveSubscriber(state, productType) {
|
|
|
43
43
|
return state.subscriptions.some((subscription) => ACTIVE_SUBSCRIPTION_STATUSES.includes(subscription.status) &&
|
|
44
44
|
subscription.products.some((product) => product.name === productType));
|
|
45
45
|
}
|
|
46
|
-
//# sourceMappingURL=selectors.
|
|
46
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAI9D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAkC,EAClC,WAAqB,EACrB,OAA+C;IAE/C,MAAM,YAAY,GAAG,KAAK,CAAC,mBAAmB,EAAE,CAAC,WAAW,CAAC;QAC3D,EAAE,YAES,CAAC;IAEd,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAkC,EAClC,WAAqB,EACrB,OAA+C;IAE/C,OAAO,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAkC,EAClC,WAAwB;IAExB,OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,CAC7B,CAAC,YAAY,EAAE,EAAE,CACf,4BAA4B,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC;QAC1D,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,CACxE,CAAC;AACJ,CAAC","sourcesContent":["import { ACTIVE_SUBSCRIPTION_STATUSES } from './constants.js';\nimport type { SubscriptionControllerState } from './SubscriptionController.js';\nimport type { ProductEntitlementFeatureMap, ProductType } from './types.js';\n\n/**\n * Returns whether a specific product feature entitlement is enabled.\n *\n * Use this to gate paid UX. Missing products or missing features fail closed\n * (`false`). Combine with `selectIsActiveSubscriber` when that is the\n * product rule; this selector only reads the entitlement boolean.\n *\n * @param state - The subscription controller state.\n * @param productType - The product whose entitlement is queried.\n * @param feature - The feature whose entitlement flag is queried.\n * @returns Whether the feature entitlement is true.\n */\nexport function selectHasEntitlement<TProduct extends ProductType>(\n state: SubscriptionControllerState,\n productType: TProduct,\n feature: ProductEntitlementFeatureMap[TProduct],\n): boolean {\n const entitlements = state.productEntitlements?.[productType]\n ?.entitlements as\n | Record<ProductEntitlementFeatureMap[TProduct], boolean>\n | undefined;\n\n return Boolean(entitlements?.[feature]);\n}\n\n/**\n * Usage availability currently matches entitlement because the server folds\n * metered-cap exhaustion into the entitlement flag. Keeping this selector\n * separate gives consumers a stable API if explicit usage claims are added.\n *\n * @param state - The subscription controller state.\n * @param productType - The product whose usage availability is queried.\n * @param feature - The feature whose usage availability is queried.\n * @returns Whether usage is currently available for the feature.\n */\nexport function selectIsUsageAvailable<TProduct extends ProductType>(\n state: SubscriptionControllerState,\n productType: TProduct,\n feature: ProductEntitlementFeatureMap[TProduct],\n): boolean {\n return selectHasEntitlement(state, productType, feature);\n}\n\n/**\n * Returns whether the user has an active subscription for a specific product.\n *\n * Active includes `active`, `trialing`, and `provisional`. Missing products\n * and non-active statuses fail closed (`false`).\n *\n * @param state - The subscription controller state.\n * @param productType - The product to check.\n * @returns Whether the user is an active subscriber for the product.\n */\nexport function selectIsActiveSubscriber(\n state: SubscriptionControllerState,\n productType: ProductType,\n): boolean {\n return state.subscriptions.some(\n (subscription) =>\n ACTIVE_SUBSCRIPTION_STATUSES.includes(subscription.status) &&\n subscription.products.some((product) => product.name === productType),\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TransactionMeta } from
|
|
2
|
-
import type { CaipAccountId, Hex } from
|
|
1
|
+
import type { TransactionMeta } from '@metamask/transaction-controller';
|
|
2
|
+
import type { CaipAccountId, Hex } from '@metamask/utils';
|
|
3
3
|
/**
|
|
4
4
|
* Error response from the Subscription API.
|
|
5
5
|
*/
|
|
@@ -15,24 +15,24 @@ export declare const PRODUCT_TYPES: {
|
|
|
15
15
|
/**
|
|
16
16
|
* MetaMask Shield.
|
|
17
17
|
*/
|
|
18
|
-
readonly SHIELD:
|
|
18
|
+
readonly SHIELD: 'shield';
|
|
19
19
|
/**
|
|
20
20
|
* Money Account Plus (delegation-based crypto billing).
|
|
21
21
|
*/
|
|
22
|
-
readonly MONEY_ACCOUNT_PLUS:
|
|
22
|
+
readonly MONEY_ACCOUNT_PLUS: 'money_account_plus';
|
|
23
23
|
};
|
|
24
24
|
export type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];
|
|
25
25
|
export declare const MoneyAccountFeature: {
|
|
26
|
-
readonly SwapFeeWaiver:
|
|
27
|
-
readonly PerpsFeeWaiver:
|
|
28
|
-
readonly PredictFreeTx:
|
|
29
|
-
readonly PremiumApy:
|
|
26
|
+
readonly SwapFeeWaiver: 'swapFeeWaiver';
|
|
27
|
+
readonly PerpsFeeWaiver: 'perpsFeeWaiver';
|
|
28
|
+
readonly PredictFreeTx: 'predictFreeTx';
|
|
29
|
+
readonly PremiumApy: 'premiumApy';
|
|
30
30
|
};
|
|
31
31
|
export type MoneyAccountFeature = (typeof MoneyAccountFeature)[keyof typeof MoneyAccountFeature];
|
|
32
32
|
export type MoneyAccountEntitlements = Record<MoneyAccountFeature, boolean>;
|
|
33
33
|
export declare const ShieldFeature: {
|
|
34
|
-
readonly ShieldClaim:
|
|
35
|
-
readonly PrioritySupport:
|
|
34
|
+
readonly ShieldClaim: 'shieldClaim';
|
|
35
|
+
readonly PrioritySupport: 'prioritySupport';
|
|
36
36
|
};
|
|
37
37
|
export type ShieldFeature = (typeof ShieldFeature)[keyof typeof ShieldFeature];
|
|
38
38
|
export type ShieldEntitlements = Record<ShieldFeature, boolean>;
|
|
@@ -60,53 +60,53 @@ export declare const CRYPTO_AUTH_METHODS: {
|
|
|
60
60
|
/**
|
|
61
61
|
* User signs an ERC-20 approve transaction.
|
|
62
62
|
*/
|
|
63
|
-
readonly ERC20_APPROVAL:
|
|
63
|
+
readonly ERC20_APPROVAL: 'erc20_approval';
|
|
64
64
|
/**
|
|
65
65
|
* User authorizes via a stored delegation hash.
|
|
66
66
|
*/
|
|
67
|
-
readonly DELEGATION:
|
|
67
|
+
readonly DELEGATION: 'delegation';
|
|
68
68
|
};
|
|
69
69
|
export type CryptoAuthMethod = (typeof CRYPTO_AUTH_METHODS)[keyof typeof CRYPTO_AUTH_METHODS];
|
|
70
70
|
export declare const PAYMENT_TYPES: {
|
|
71
|
-
readonly byCard:
|
|
72
|
-
readonly byCrypto:
|
|
71
|
+
readonly byCard: 'card';
|
|
72
|
+
readonly byCrypto: 'crypto';
|
|
73
73
|
};
|
|
74
74
|
export type PaymentType = (typeof PAYMENT_TYPES)[keyof typeof PAYMENT_TYPES];
|
|
75
75
|
export declare const RECURRING_INTERVALS: {
|
|
76
|
-
readonly month:
|
|
77
|
-
readonly year:
|
|
76
|
+
readonly month: 'month';
|
|
77
|
+
readonly year: 'year';
|
|
78
78
|
};
|
|
79
79
|
export type RecurringInterval = (typeof RECURRING_INTERVALS)[keyof typeof RECURRING_INTERVALS];
|
|
80
80
|
export declare const SUBSCRIPTION_STATUSES: {
|
|
81
|
-
readonly incomplete:
|
|
82
|
-
readonly incompleteExpired:
|
|
83
|
-
readonly provisional:
|
|
84
|
-
readonly trialing:
|
|
85
|
-
readonly active:
|
|
86
|
-
readonly pastDue:
|
|
87
|
-
readonly unpaid:
|
|
88
|
-
readonly canceled:
|
|
89
|
-
readonly paused:
|
|
81
|
+
readonly incomplete: 'incomplete';
|
|
82
|
+
readonly incompleteExpired: 'incomplete_expired';
|
|
83
|
+
readonly provisional: 'provisional';
|
|
84
|
+
readonly trialing: 'trialing';
|
|
85
|
+
readonly active: 'active';
|
|
86
|
+
readonly pastDue: 'past_due';
|
|
87
|
+
readonly unpaid: 'unpaid';
|
|
88
|
+
readonly canceled: 'canceled';
|
|
89
|
+
readonly paused: 'paused';
|
|
90
90
|
};
|
|
91
91
|
export type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];
|
|
92
92
|
export declare const CANCEL_TYPES: {
|
|
93
|
-
readonly ALLOWED_IMMEDIATE:
|
|
94
|
-
readonly ALLOWED_AT_PERIOD_END:
|
|
95
|
-
readonly NOT_ALLOWED:
|
|
96
|
-
readonly NOT_ALLOWED_PENDING_VERIFICATION:
|
|
93
|
+
readonly ALLOWED_IMMEDIATE: 'allowed_immediate';
|
|
94
|
+
readonly ALLOWED_AT_PERIOD_END: 'allowed_at_period_end';
|
|
95
|
+
readonly NOT_ALLOWED: 'not_allowed';
|
|
96
|
+
readonly NOT_ALLOWED_PENDING_VERIFICATION: 'not_allowed_pending_verification';
|
|
97
97
|
};
|
|
98
98
|
export type CancelType = (typeof CANCEL_TYPES)[keyof typeof CANCEL_TYPES];
|
|
99
99
|
export declare const CRYPTO_PAYMENT_METHOD_ERRORS: {
|
|
100
|
-
readonly APPROVAL_TRANSACTION_TOO_OLD:
|
|
101
|
-
readonly APPROVAL_TRANSACTION_REVERTED:
|
|
102
|
-
readonly APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED:
|
|
103
|
-
readonly INSUFFICIENT_BALANCE:
|
|
104
|
-
readonly INSUFFICIENT_ALLOWANCE:
|
|
100
|
+
readonly APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old';
|
|
101
|
+
readonly APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted';
|
|
102
|
+
readonly APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED: 'approval_transaction_max_verification_attempts_reached';
|
|
103
|
+
readonly INSUFFICIENT_BALANCE: 'insufficient_balance';
|
|
104
|
+
readonly INSUFFICIENT_ALLOWANCE: 'insufficient_allowance';
|
|
105
105
|
};
|
|
106
106
|
export type CryptoPaymentMethodError = (typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];
|
|
107
107
|
export declare const MODAL_TYPE: {
|
|
108
|
-
readonly A:
|
|
109
|
-
readonly B:
|
|
108
|
+
readonly A: 'A';
|
|
109
|
+
readonly B: 'B';
|
|
110
110
|
};
|
|
111
111
|
export type ModalType = (typeof MODAL_TYPE)[keyof typeof MODAL_TYPE];
|
|
112
112
|
/** only usd for now */
|
|
@@ -465,17 +465,17 @@ export type SubmitSubscriptionCryptoApprovalRequest = {
|
|
|
465
465
|
rewardAccountId?: CaipAccountId;
|
|
466
466
|
};
|
|
467
467
|
export declare const COHORT_NAMES: {
|
|
468
|
-
readonly POST_TX:
|
|
469
|
-
readonly WALLET_HOME:
|
|
468
|
+
readonly POST_TX: 'post_tx';
|
|
469
|
+
readonly WALLET_HOME: 'wallet_home';
|
|
470
470
|
};
|
|
471
471
|
export type CohortName = (typeof COHORT_NAMES)[keyof typeof COHORT_NAMES];
|
|
472
472
|
export declare const BALANCE_CATEGORIES: {
|
|
473
|
-
readonly RANGE_0_99:
|
|
474
|
-
readonly RANGE_100_999:
|
|
475
|
-
readonly RANGE_1K_9_9K:
|
|
476
|
-
readonly RANGE_10K_99_9K:
|
|
477
|
-
readonly RANGE_100K_999_9K:
|
|
478
|
-
readonly RANGE_1M_PLUS:
|
|
473
|
+
readonly RANGE_0_99: '0-99';
|
|
474
|
+
readonly RANGE_100_999: '100-999';
|
|
475
|
+
readonly RANGE_1K_9_9K: '1k-9.9k';
|
|
476
|
+
readonly RANGE_10K_99_9K: '10k-99.9k';
|
|
477
|
+
readonly RANGE_100K_999_9K: '100k-999.9k';
|
|
478
|
+
readonly RANGE_1M_PLUS: '1M+';
|
|
479
479
|
};
|
|
480
480
|
export type BalanceCategory = (typeof BALANCE_CATEGORIES)[keyof typeof BALANCE_CATEGORIES];
|
|
481
481
|
export type Cohort = {
|
|
@@ -494,8 +494,8 @@ export type SubscriptionEligibility = {
|
|
|
494
494
|
hasAssignedCohortExpired: boolean;
|
|
495
495
|
};
|
|
496
496
|
export declare const SubscriptionUserEvent: {
|
|
497
|
-
readonly ShieldEntryModalViewed:
|
|
498
|
-
readonly ShieldCohortAssigned:
|
|
497
|
+
readonly ShieldEntryModalViewed: 'shield_entry_modal_viewed';
|
|
498
|
+
readonly ShieldCohortAssigned: 'shield_cohort_assigned';
|
|
499
499
|
};
|
|
500
500
|
export type SubscriptionUserEventType = (typeof SubscriptionUserEvent)[keyof typeof SubscriptionUserEvent];
|
|
501
501
|
export type SubmitUserEventRequest = {
|
|
@@ -642,4 +642,4 @@ export type LinkRewardsRequest = {
|
|
|
642
642
|
rewardAccountId: CaipAccountId;
|
|
643
643
|
};
|
|
644
644
|
export {};
|
|
645
|
-
//# sourceMappingURL=types.d.
|
|
645
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;aACH,MAAM,EAAE,QAAQ;IAChB;;OAEG;aACH,kBAAkB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xB,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;CACE,CAAC;AAsZX,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 { TransactionMeta } from '@metamask/transaction-controller';\nimport type { CaipAccountId, Hex } from '@metamask/utils';\n\n/**\n * Error response from the Subscription API.\n */\nexport type SubscriptionApiError = {\n errorCode?: string;\n message?: string;\n statusCode?: number;\n};\n\n/**\n * Supported subscription products.\n */\nexport const PRODUCT_TYPES = {\n /**\n * MetaMask Shield.\n */\n SHIELD: 'shield',\n /**\n * Money Account Plus (delegation-based crypto billing).\n */\n MONEY_ACCOUNT_PLUS: 'money_account_plus',\n} as const;\n\nexport type ProductType = (typeof PRODUCT_TYPES)[keyof typeof PRODUCT_TYPES];\n\nexport const MoneyAccountFeature = {\n SwapFeeWaiver: 'swapFeeWaiver',\n PerpsFeeWaiver: 'perpsFeeWaiver',\n PredictFreeTx: 'predictFreeTx',\n PremiumApy: 'premiumApy',\n} as const;\n\nexport type MoneyAccountFeature =\n (typeof MoneyAccountFeature)[keyof typeof MoneyAccountFeature];\n\nexport type MoneyAccountEntitlements = Record<MoneyAccountFeature, boolean>;\n\nexport const ShieldFeature = {\n ShieldClaim: 'shieldClaim',\n PrioritySupport: 'prioritySupport',\n} as const;\n\nexport type ShieldFeature = (typeof ShieldFeature)[keyof typeof ShieldFeature];\n\nexport type ShieldEntitlements = Record<ShieldFeature, boolean>;\n\nexport type MoneyAccountPlusClaim = {\n plan: string;\n entitlements: MoneyAccountEntitlements;\n};\n\nexport type ProductEntitlements = {\n [PRODUCT_TYPES.SHIELD]?: {\n entitlements: ShieldEntitlements;\n };\n [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]?: MoneyAccountPlusClaim;\n};\n\nexport type ProductEntitlementFeatureMap = {\n [PRODUCT_TYPES.SHIELD]: ShieldFeature;\n [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]: MoneyAccountFeature;\n};\n\n/**\n * How a crypto subscription is authorized.\n *\n * Use `erc20_approval` with `rawTransaction` (e.g. Shield). Use `delegation`\n * with `delegationHash` (e.g. Money Account Plus).\n */\nexport const CRYPTO_AUTH_METHODS = {\n /**\n * User signs an ERC-20 approve transaction.\n */\n ERC20_APPROVAL: 'erc20_approval',\n /**\n * User authorizes via a stored delegation hash.\n */\n DELEGATION: 'delegation',\n} as const;\n\nexport type CryptoAuthMethod =\n (typeof CRYPTO_AUTH_METHODS)[keyof typeof CRYPTO_AUTH_METHODS];\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 CANCEL_TYPES = {\n ALLOWED_IMMEDIATE: 'allowed_immediate',\n ALLOWED_AT_PERIOD_END: 'allowed_at_period_end',\n NOT_ALLOWED: 'not_allowed',\n NOT_ALLOWED_PENDING_VERIFICATION: 'not_allowed_pending_verification',\n} as const;\n\nexport type CancelType = (typeof CANCEL_TYPES)[keyof typeof CANCEL_TYPES];\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\nexport const MODAL_TYPE = {\n A: 'A',\n B: 'B',\n} as const;\n\nexport type ModalType = (typeof MODAL_TYPE)[keyof typeof MODAL_TYPE];\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 cancellation type indicating what cancellation options are available for this subscription. */\n cancelType: CancelType;\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 productEntitlements?: ProductEntitlements;\n /** The last subscription that user has subscribed to if any. */\n lastSubscription?: Subscription;\n /** The reward account ID if user has linked rewards to the subscription. */\n rewardAccountId?: CaipAccountId;\n};\n\n/**\n * Benefits available to a subscription user.\n */\nexport type SwapsBenefitUsage = {\n feeBips: string | null;\n capMicroUsd?: number;\n consumedMicroUsd?: number;\n remainingMicroUsd: number | null;\n exhausted: boolean;\n};\n\nexport type PerpsBenefitUsage = {\n builderFeeBips: string | null;\n builderCode: string | null;\n capMicroUsd?: number;\n consumedMicroUsd?: number;\n remainingMicroUsd: number | null;\n exhausted: boolean;\n};\n\nexport type PredictBenefitUsage = {\n builderCode: string | null;\n capTxCount?: number;\n consumedTxCount?: number;\n remainingTxCount: number | null;\n exhausted: boolean;\n};\n\ntype SubscriptionBenefitsProducts = {\n swaps: SwapsBenefitUsage;\n perps: PerpsBenefitUsage;\n predict: PredictBenefitUsage;\n};\n\nexport type SubscriptionBenefitsResponse = {\n eligible: boolean;\n billingPeriodId: string | null;\n products: SubscriptionBenefitsProducts;\n};\n\n/**\n * Benefits state exposed to the UI.\n */\nexport type SubscriptionBenefitsState = SubscriptionBenefitsProducts & {\n billingPeriodId: string | null;\n};\n\nexport type StartSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n successUrl?: string;\n cancelUrl?: string;\n useTestClock?: boolean;\n\n /**\n * Optional CAIP account ID of the rewards account to opt in alongside this\n * subscription. Required when the user wants to link rewards during\n * subscription creation.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId?: CaipAccountId;\n};\n\nexport type StartSubscriptionResponse = {\n checkoutSessionUrl: string;\n};\n\ntype StartCryptoSubscriptionRequestBase = {\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 isSponsored?: boolean;\n useTestClock?: boolean;\n /**\n * Optional CAIP account ID of the rewards account to opt in alongside this\n * subscription. Required when the user wants to link rewards during\n * subscription creation.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId?: CaipAccountId;\n};\n\n/**\n * ERC-20 approval crypto subscription request (e.g. Shield).\n *\n * `cryptoAuthMethod` defaults to `CRYPTO_AUTH_METHODS.ERC20_APPROVAL` when\n * omitted.\n */\nexport type StartErc20CryptoSubscriptionRequest =\n StartCryptoSubscriptionRequestBase & {\n cryptoAuthMethod?: typeof CRYPTO_AUTH_METHODS.ERC20_APPROVAL;\n rawTransaction: Hex;\n delegationHash?: never;\n };\n\n/**\n * Delegation-based crypto subscription request (e.g. Money Account Plus).\n */\nexport type StartDelegationCryptoSubscriptionRequest =\n StartCryptoSubscriptionRequestBase & {\n cryptoAuthMethod: typeof CRYPTO_AUTH_METHODS.DELEGATION;\n delegationHash: Hex;\n rawTransaction?: never;\n };\n\n/**\n * Request to start a crypto subscription.\n *\n * Discriminated union of ERC-20 approval vs delegation. Provide\n * `rawTransaction` for ERC-20 approval (the default when `cryptoAuthMethod` is\n * omitted), or `delegationHash` with `cryptoAuthMethod: 'delegation'`.\n * Combining or omitting both is a type error, and is also rejected at runtime\n * by `startSubscriptionWithCrypto`.\n */\nexport type StartCryptoSubscriptionRequest =\n | StartErc20CryptoSubscriptionRequest\n | StartDelegationCryptoSubscriptionRequest;\n\nexport type StartCryptoSubscriptionResponse = {\n subscriptionId: string;\n status: SubscriptionStatus;\n};\n\n/**\n * General response type for the subscription API requests\n * which doesn't require any specific response data.\n */\nexport type SubscriptionApiGeneralResponse = {\n /**\n * Whether the request was successful.\n */\n success: boolean;\n /**\n * The message of the response.\n */\n message?: string;\n};\n\nexport type CancelSubscriptionRequest = {\n subscriptionId: string;\n /** Whether to cancel at the end of the current period */\n cancelAtPeriodEnd?: boolean;\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 /** min billing cycles for approval */\n minBillingCycles: number;\n /** min billing cycles for account balance check */\n minBillingCyclesForBalance: number;\n};\n\nexport type ProductPricing = {\n name: ProductType;\n prices: ProductPrice[];\n};\n\ntype TokenPaymentInfoBase = {\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 * Source tokens that can be converted into this settlement token.\n */\n sources?: TokenPaymentInfo[];\n};\n\n/**\n * Spot (non-vault) settlement token. Priced via `conversionRate` when provided.\n * `accountantAddress` is not present on this variant.\n */\nexport type SpotTokenPaymentInfo = TokenPaymentInfoBase & {\n isVaultShare?: false;\n};\n\n/**\n * Yield-bearing vault share priced via an accountant rate.\n */\nexport type VaultTokenPaymentInfo = TokenPaymentInfoBase & {\n isVaultShare: true;\n /**\n * Veda accountant address used to value this vault share.\n */\n accountantAddress: Hex;\n};\n\n/**\n * A settlement token in a pricing chain. Discriminated by `isVaultShare`:\n * vault shares require `accountantAddress`; spot tokens omit it.\n */\nexport type TokenPaymentInfo = SpotTokenPaymentInfo | VaultTokenPaymentInfo;\n\nexport type ChainPaymentInfo = {\n chainId: Hex;\n paymentAddress: Hex;\n /**\n * Delegate address clients authorize when using the delegation auth method.\n */\n delegateAddress?: 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 PricingCardPaymentMethod = {\n type: Extract<PaymentType, 'card'>;\n /**\n * Products that support this payment method.\n */\n products?: ProductType[];\n};\n\nexport type PricingCryptoPaymentMethod = {\n type: Extract<PaymentType, 'crypto'>;\n /**\n * Crypto authorization method. Omitted together with `products` on persisted\n * pre-multi-product pricing rows; those rows are treated as Shield + `erc20_approval`.\n * If `products` is set, this field must be explicit.\n */\n cryptoAuthMethod?: CryptoAuthMethod;\n /**\n * Products that support this payment method. Omitted together with\n * `cryptoAuthMethod` on persisted pre-multi-product pricing rows (treated as Shield).\n * If present, must be non-empty and paired with an explicit `cryptoAuthMethod`.\n */\n products?: ProductType[];\n chains?: ChainPaymentInfo[];\n};\n\n/**\n * A pricing payment-method row. Discriminated by `type`: card rows have no\n * crypto fields; crypto rows may include `cryptoAuthMethod` and `chains`.\n */\nexport type PricingPaymentMethod =\n | PricingCardPaymentMethod\n | PricingCryptoPaymentMethod;\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\n/**\n * Request to submit a Shield ERC-20 crypto approval transaction.\n */\nexport type SubmitSubscriptionCryptoApprovalRequest = {\n /**\n * The subscription product. Typed as `typeof PRODUCT_TYPES.SHIELD` only at\n * the moment (future might support more product).\n */\n productType: typeof PRODUCT_TYPES.SHIELD;\n /**\n * The transaction metadata. Must have type\n * `TransactionType.shieldSubscriptionApprove`.\n */\n txMeta: TransactionMeta;\n /**\n * Whether the transaction is sponsored.\n */\n isSponsored?: boolean;\n /**\n * The account ID of the reward subscription to link.\n */\n rewardAccountId?: CaipAccountId;\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 canViewEntryModal: boolean;\n modalType?: ModalType;\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 getBenefits(): Promise<SubscriptionBenefitsResponse>;\n cancelSubscription(request: CancelSubscriptionRequest): Promise<Subscription>;\n unCancelSubscription(request: {\n subscriptionId: string;\n }): Promise<Subscription>;\n /**\n * Starts a card-paid subscription checkout session for the requested products\n * (e.g. Shield or Money Account Plus).\n *\n * @param request - The start subscription request.\n * @returns The checkout session response.\n */\n 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 * Link rewards to a subscription.\n */\n linkRewards(\n request: LinkRewardsRequest,\n ): Promise<SubscriptionApiGeneralResponse>;\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 cancelUrl?: 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 useTestClock?: boolean;\n /**\n * Crypto authorization method. Omitted on persisted cache entries written\n * before this field existed; treat as `erc20_approval` when missing.\n */\n cryptoAuthMethod?: CryptoAuthMethod;\n};\n\n/**\n * Request to cache the last selected payment method for a product.\n */\nexport type CacheLastSelectedPaymentMethodRequest = {\n /**\n * The product to cache the payment method for.\n */\n product: ProductType;\n /**\n * The payment method to cache.\n */\n paymentMethod: CachedLastSelectedPaymentMethod;\n};\n\n/**\n * Request object for linking rewards to a subscription.\n */\nexport type LinkRewardsRequest = {\n /**\n * The ID of the reward subscription to be linked to the subscription.\n *\n * @example {\n * rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890',\n * }\n */\n rewardAccountId: CaipAccountId;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/subscription-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Handle user subscription",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -18,19 +18,12 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist/"
|
|
20
20
|
],
|
|
21
|
+
"type": "module",
|
|
21
22
|
"sideEffects": false,
|
|
22
|
-
"main": "./dist/index.cjs",
|
|
23
|
-
"types": "./dist/index.d.cts",
|
|
24
23
|
"exports": {
|
|
25
24
|
".": {
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"default": "./dist/index.mjs"
|
|
29
|
-
},
|
|
30
|
-
"require": {
|
|
31
|
-
"types": "./dist/index.d.cts",
|
|
32
|
-
"default": "./dist/index.cjs"
|
|
33
|
-
}
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
34
27
|
},
|
|
35
28
|
"./package.json": "./package.json"
|
|
36
29
|
},
|
|
@@ -39,9 +32,11 @@
|
|
|
39
32
|
"registry": "https://registry.npmjs.org/"
|
|
40
33
|
},
|
|
41
34
|
"scripts": {
|
|
42
|
-
"build": "
|
|
43
|
-
"build:all": "
|
|
35
|
+
"build": "tsc --project tsconfig.build.json",
|
|
36
|
+
"build:all": "tsc --build tsconfig.build.json --verbose",
|
|
37
|
+
"build:clean": "yarn build:only-clean && yarn build",
|
|
44
38
|
"build:docs": "typedoc",
|
|
39
|
+
"build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
|
|
45
40
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/subscription-controller",
|
|
46
41
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/subscription-controller",
|
|
47
42
|
"lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
|
|
@@ -55,14 +50,14 @@
|
|
|
55
50
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
56
51
|
},
|
|
57
52
|
"dependencies": {
|
|
58
|
-
"@metamask/base-controller": "^
|
|
59
|
-
"@metamask/base-data-service": "^
|
|
60
|
-
"@metamask/controller-utils": "^
|
|
61
|
-
"@metamask/messenger": "^
|
|
62
|
-
"@metamask/polling-controller": "^
|
|
63
|
-
"@metamask/profile-sync-controller": "^
|
|
53
|
+
"@metamask/base-controller": "^10.0.0",
|
|
54
|
+
"@metamask/base-data-service": "^2.0.0",
|
|
55
|
+
"@metamask/controller-utils": "^13.0.0",
|
|
56
|
+
"@metamask/messenger": "^3.0.0",
|
|
57
|
+
"@metamask/polling-controller": "^17.0.0",
|
|
58
|
+
"@metamask/profile-sync-controller": "^31.0.0",
|
|
64
59
|
"@metamask/superstruct": "^3.4.1",
|
|
65
|
-
"@metamask/transaction-controller": "^
|
|
60
|
+
"@metamask/transaction-controller": "^70.0.0",
|
|
66
61
|
"@metamask/utils": "^11.12.0",
|
|
67
62
|
"@tanstack/query-core": "^5.62.16",
|
|
68
63
|
"bignumber.js": "^9.1.2",
|
|
@@ -70,17 +65,18 @@
|
|
|
70
65
|
},
|
|
71
66
|
"devDependencies": {
|
|
72
67
|
"@metamask/auto-changelog": "^6.1.0",
|
|
73
|
-
"@ts-bridge/cli": "^0.6.4",
|
|
74
68
|
"@types/jest": "^30.0.0",
|
|
69
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
75
70
|
"deepmerge": "^4.2.2",
|
|
76
71
|
"jest": "^30.4.2",
|
|
72
|
+
"rimraf": "^5.0.5",
|
|
77
73
|
"ts-jest": "^29.4.11",
|
|
78
74
|
"tsx": "^4.20.5",
|
|
79
75
|
"typedoc": "^0.25.13",
|
|
80
76
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
81
|
-
"typescript": "
|
|
77
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
82
78
|
},
|
|
83
79
|
"engines": {
|
|
84
|
-
"node": "^
|
|
80
|
+
"node": "^22.14.0 || ^24"
|
|
85
81
|
}
|
|
86
82
|
}
|