@metamask/subscription-controller 6.2.1 → 7.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 +24 -1
- package/LICENSE +1 -0
- package/dist/SubscriptionController-method-action-types.cjs.map +1 -1
- package/dist/SubscriptionController-method-action-types.d.cts.map +1 -1
- package/dist/SubscriptionController-method-action-types.d.mts.map +1 -1
- package/dist/SubscriptionController-method-action-types.mjs.map +1 -1
- package/dist/SubscriptionController.cjs +49 -57
- package/dist/SubscriptionController.cjs.map +1 -1
- package/dist/SubscriptionController.d.cts +7 -11
- package/dist/SubscriptionController.d.cts.map +1 -1
- package/dist/SubscriptionController.d.mts +7 -11
- package/dist/SubscriptionController.d.mts.map +1 -1
- package/dist/SubscriptionController.mjs +18 -26
- package/dist/SubscriptionController.mjs.map +1 -1
- package/dist/SubscriptionService-method-action-types.cjs +7 -0
- package/dist/SubscriptionService-method-action-types.cjs.map +1 -0
- package/dist/SubscriptionService-method-action-types.d.cts +151 -0
- package/dist/SubscriptionService-method-action-types.d.cts.map +1 -0
- package/dist/SubscriptionService-method-action-types.d.mts +151 -0
- package/dist/SubscriptionService-method-action-types.d.mts.map +1 -0
- package/dist/SubscriptionService-method-action-types.mjs +6 -0
- package/dist/SubscriptionService-method-action-types.mjs.map +1 -0
- package/dist/SubscriptionService-structs.cjs +135 -0
- package/dist/SubscriptionService-structs.cjs.map +1 -0
- package/dist/SubscriptionService-structs.d.cts +773 -0
- package/dist/SubscriptionService-structs.d.cts.map +1 -0
- package/dist/SubscriptionService-structs.d.mts +773 -0
- package/dist/SubscriptionService-structs.d.mts.map +1 -0
- package/dist/SubscriptionService-structs.mjs +132 -0
- package/dist/SubscriptionService-structs.mjs.map +1 -0
- package/dist/SubscriptionService.cjs +282 -112
- package/dist/SubscriptionService.cjs.map +1 -1
- package/dist/SubscriptionService.d.cts +90 -10
- package/dist/SubscriptionService.d.cts.map +1 -1
- package/dist/SubscriptionService.d.mts +90 -10
- package/dist/SubscriptionService.d.mts.map +1 -1
- package/dist/SubscriptionService.mjs +257 -87
- package/dist/SubscriptionService.mjs.map +1 -1
- package/dist/constants.cjs +4 -4
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +25 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/logger.cjs +2 -2
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.mjs.map +1 -1
- package/package.json +14 -9
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionEligibilityArrayStruct = exports.SubscriptionEligibilityStruct = exports.PricingResponseStruct = exports.SubscriptionApiGeneralResponseStruct = exports.BillingPortalResponseStruct = exports.UpdatePaymentMethodCardResponseStruct = exports.StartCryptoSubscriptionResponseStruct = exports.StartSubscriptionResponseStruct = exports.GetSubscriptionsResponseStruct = exports.SubscriptionStruct = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
const types_js_1 = require("./types.cjs");
|
|
7
|
+
const ProductTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.PRODUCT_TYPES));
|
|
8
|
+
const PaymentTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.PAYMENT_TYPES));
|
|
9
|
+
const RecurringIntervalStruct = (0, superstruct_1.enums)(Object.values(types_js_1.RECURRING_INTERVALS));
|
|
10
|
+
const SubscriptionStatusStruct = (0, superstruct_1.enums)(Object.values(types_js_1.SUBSCRIPTION_STATUSES));
|
|
11
|
+
const CancelTypeStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CANCEL_TYPES));
|
|
12
|
+
const CryptoPaymentMethodErrorStruct = (0, superstruct_1.enums)(Object.values(types_js_1.CRYPTO_PAYMENT_METHOD_ERRORS));
|
|
13
|
+
const ProductStruct = (0, superstruct_1.type)({
|
|
14
|
+
name: ProductTypeStruct,
|
|
15
|
+
currency: (0, superstruct_1.enums)(['usd']),
|
|
16
|
+
unitAmount: (0, superstruct_1.number)(),
|
|
17
|
+
unitDecimals: (0, superstruct_1.number)(),
|
|
18
|
+
});
|
|
19
|
+
const SubscriptionCardPaymentMethodStruct = (0, superstruct_1.type)({
|
|
20
|
+
type: (0, superstruct_1.enums)([types_js_1.PAYMENT_TYPES.byCard]),
|
|
21
|
+
card: (0, superstruct_1.type)({
|
|
22
|
+
brand: (0, superstruct_1.string)(),
|
|
23
|
+
displayBrand: (0, superstruct_1.string)(),
|
|
24
|
+
last4: (0, superstruct_1.string)(),
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
const SubscriptionCryptoPaymentMethodStruct = (0, superstruct_1.type)({
|
|
28
|
+
type: (0, superstruct_1.enums)([types_js_1.PAYMENT_TYPES.byCrypto]),
|
|
29
|
+
crypto: (0, superstruct_1.type)({
|
|
30
|
+
payerAddress: utils_1.StrictHexStruct,
|
|
31
|
+
chainId: utils_1.StrictHexStruct,
|
|
32
|
+
tokenSymbol: (0, superstruct_1.string)(),
|
|
33
|
+
error: (0, superstruct_1.optional)(CryptoPaymentMethodErrorStruct),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
const SubscriptionPaymentMethodStruct = (0, superstruct_1.union)([
|
|
37
|
+
SubscriptionCardPaymentMethodStruct,
|
|
38
|
+
SubscriptionCryptoPaymentMethodStruct,
|
|
39
|
+
]);
|
|
40
|
+
exports.SubscriptionStruct = (0, superstruct_1.type)({
|
|
41
|
+
id: (0, superstruct_1.string)(),
|
|
42
|
+
products: (0, superstruct_1.array)(ProductStruct),
|
|
43
|
+
currentPeriodStart: (0, superstruct_1.string)(),
|
|
44
|
+
currentPeriodEnd: (0, superstruct_1.string)(),
|
|
45
|
+
cancelAtPeriodEnd: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
46
|
+
status: SubscriptionStatusStruct,
|
|
47
|
+
interval: RecurringIntervalStruct,
|
|
48
|
+
paymentMethod: SubscriptionPaymentMethodStruct,
|
|
49
|
+
trialPeriodDays: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
50
|
+
trialStart: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
51
|
+
trialEnd: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
52
|
+
endDate: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
53
|
+
canceledAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
54
|
+
cancelType: CancelTypeStruct,
|
|
55
|
+
inactiveAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
56
|
+
isEligibleForSupport: (0, superstruct_1.boolean)(),
|
|
57
|
+
billingCycles: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
58
|
+
});
|
|
59
|
+
exports.GetSubscriptionsResponseStruct = (0, superstruct_1.type)({
|
|
60
|
+
customerId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
61
|
+
subscriptions: (0, superstruct_1.array)(exports.SubscriptionStruct),
|
|
62
|
+
trialedProducts: (0, superstruct_1.array)(ProductTypeStruct),
|
|
63
|
+
lastSubscription: (0, superstruct_1.optional)(exports.SubscriptionStruct),
|
|
64
|
+
rewardAccountId: (0, superstruct_1.optional)(utils_1.CaipAccountIdStruct),
|
|
65
|
+
});
|
|
66
|
+
exports.StartSubscriptionResponseStruct = (0, superstruct_1.type)({
|
|
67
|
+
checkoutSessionUrl: (0, superstruct_1.string)(),
|
|
68
|
+
});
|
|
69
|
+
exports.StartCryptoSubscriptionResponseStruct = (0, superstruct_1.type)({
|
|
70
|
+
subscriptionId: (0, superstruct_1.string)(),
|
|
71
|
+
status: SubscriptionStatusStruct,
|
|
72
|
+
});
|
|
73
|
+
exports.UpdatePaymentMethodCardResponseStruct = (0, superstruct_1.type)({
|
|
74
|
+
redirectUrl: (0, superstruct_1.string)(),
|
|
75
|
+
});
|
|
76
|
+
exports.BillingPortalResponseStruct = (0, superstruct_1.type)({
|
|
77
|
+
url: (0, superstruct_1.string)(),
|
|
78
|
+
});
|
|
79
|
+
exports.SubscriptionApiGeneralResponseStruct = (0, superstruct_1.type)({
|
|
80
|
+
success: (0, superstruct_1.boolean)(),
|
|
81
|
+
message: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
82
|
+
});
|
|
83
|
+
const ProductPriceStruct = (0, superstruct_1.type)({
|
|
84
|
+
interval: RecurringIntervalStruct,
|
|
85
|
+
unitAmount: (0, superstruct_1.number)(),
|
|
86
|
+
unitDecimals: (0, superstruct_1.number)(),
|
|
87
|
+
currency: (0, superstruct_1.enums)(['usd']),
|
|
88
|
+
trialPeriodDays: (0, superstruct_1.number)(),
|
|
89
|
+
minBillingCycles: (0, superstruct_1.number)(),
|
|
90
|
+
minBillingCyclesForBalance: (0, superstruct_1.number)(),
|
|
91
|
+
});
|
|
92
|
+
const ProductPricingStruct = (0, superstruct_1.type)({
|
|
93
|
+
name: ProductTypeStruct,
|
|
94
|
+
prices: (0, superstruct_1.array)(ProductPriceStruct),
|
|
95
|
+
});
|
|
96
|
+
const TokenPaymentInfoStruct = (0, superstruct_1.type)({
|
|
97
|
+
symbol: (0, superstruct_1.string)(),
|
|
98
|
+
address: utils_1.StrictHexStruct,
|
|
99
|
+
decimals: (0, superstruct_1.number)(),
|
|
100
|
+
conversionRate: (0, superstruct_1.type)({
|
|
101
|
+
usd: (0, superstruct_1.string)(),
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
const ChainPaymentInfoStruct = (0, superstruct_1.type)({
|
|
105
|
+
chainId: utils_1.StrictHexStruct,
|
|
106
|
+
paymentAddress: utils_1.StrictHexStruct,
|
|
107
|
+
tokens: (0, superstruct_1.array)(TokenPaymentInfoStruct),
|
|
108
|
+
isSponsorshipSupported: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
109
|
+
});
|
|
110
|
+
const PricingPaymentMethodStruct = (0, superstruct_1.type)({
|
|
111
|
+
type: PaymentTypeStruct,
|
|
112
|
+
chains: (0, superstruct_1.optional)((0, superstruct_1.array)(ChainPaymentInfoStruct)),
|
|
113
|
+
});
|
|
114
|
+
exports.PricingResponseStruct = (0, superstruct_1.type)({
|
|
115
|
+
products: (0, superstruct_1.array)(ProductPricingStruct),
|
|
116
|
+
paymentMethods: (0, superstruct_1.array)(PricingPaymentMethodStruct),
|
|
117
|
+
});
|
|
118
|
+
const CohortStruct = (0, superstruct_1.type)({
|
|
119
|
+
cohort: (0, superstruct_1.string)(),
|
|
120
|
+
eligibilityRate: (0, superstruct_1.number)(),
|
|
121
|
+
priority: (0, superstruct_1.number)(),
|
|
122
|
+
eligible: (0, superstruct_1.boolean)(),
|
|
123
|
+
});
|
|
124
|
+
exports.SubscriptionEligibilityStruct = (0, superstruct_1.type)({
|
|
125
|
+
product: ProductTypeStruct,
|
|
126
|
+
canSubscribe: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
127
|
+
canViewEntryModal: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
128
|
+
modalType: (0, superstruct_1.optional)((0, superstruct_1.enums)(['A', 'B'])),
|
|
129
|
+
cohorts: (0, superstruct_1.optional)((0, superstruct_1.array)(CohortStruct)),
|
|
130
|
+
assignedCohort: (0, superstruct_1.optional)((0, superstruct_1.nullable)((0, superstruct_1.string)())),
|
|
131
|
+
assignedAt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
132
|
+
hasAssignedCohortExpired: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
133
|
+
});
|
|
134
|
+
exports.SubscriptionEligibilityArrayStruct = (0, superstruct_1.array)(exports.SubscriptionEligibilityStruct);
|
|
135
|
+
//# sourceMappingURL=SubscriptionService-structs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionService-structs.cjs","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":";;;AAAA,uDAU+B;AAC/B,2CAAuE;AAEvE,0CAOoB;AAEpB,MAAM,iBAAiB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,wBAAa,CAAC,CAAC,CAAC;AAC9D,MAAM,iBAAiB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,wBAAa,CAAC,CAAC,CAAC;AAC9D,MAAM,uBAAuB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,8BAAmB,CAAC,CAAC,CAAC;AAC1E,MAAM,wBAAwB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,gCAAqB,CAAC,CAAC,CAAC;AAC7E,MAAM,gBAAgB,GAAG,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,uBAAY,CAAC,CAAC,CAAC;AAC5D,MAAM,8BAA8B,GAAG,IAAA,mBAAK,EAC1C,MAAM,CAAC,MAAM,CAAC,uCAA4B,CAAC,CAC5C,CAAC;AAEF,MAAM,aAAa,GAAG,IAAA,kBAAI,EAAC;IACzB,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,IAAA,mBAAK,EAAC,CAAC,KAAK,CAAC,CAAC;IACxB,UAAU,EAAE,IAAA,oBAAM,GAAE;IACpB,YAAY,EAAE,IAAA,oBAAM,GAAE;CACvB,CAAC,CAAC;AAEH,MAAM,mCAAmC,GAAG,IAAA,kBAAI,EAAC;IAC/C,IAAI,EAAE,IAAA,mBAAK,EAAC,CAAC,wBAAa,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,EAAE,IAAA,kBAAI,EA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B,CAAC;CAClD,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,IAAA,kBAAI,EAAC;IACxB,MAAM,EAAE,IAAA,oBAAM,GAAE;IAChB,eAAe,EAAE,IAAA,oBAAM,GAAE;IACzB,QAAQ,EAAE,IAAA,oBAAM,GAAE;IAClB,QAAQ,EAAE,IAAA,qBAAO,GAAE;CACpB,CAAC,CAAC;AAEU,QAAA,6BAA6B,GAAG,IAAA,kBAAI,EAAC;IAChD,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IACjC,iBAAiB,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IACtC,SAAS,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,YAAY,CAAC,CAAC;IACtC,cAAc,EAAE,IAAA,sBAAQ,EAAC,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC,CAAC;IAC5C,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC9B,wBAAwB,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;CAC9C,CAAC,CAAC;AAEU,QAAA,kCAAkC,GAAG,IAAA,mBAAK,EACrD,qCAA6B,CAC9B,CAAC","sourcesContent":["import {\n array,\n boolean,\n enums,\n nullable,\n number,\n optional,\n string,\n type,\n union,\n} from '@metamask/superstruct';\nimport { StrictHexStruct, CaipAccountIdStruct } from '@metamask/utils';\n\nimport {\n CANCEL_TYPES,\n CRYPTO_PAYMENT_METHOD_ERRORS,\n PAYMENT_TYPES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n SUBSCRIPTION_STATUSES,\n} from './types.js';\n\nconst ProductTypeStruct = enums(Object.values(PRODUCT_TYPES));\nconst PaymentTypeStruct = enums(Object.values(PAYMENT_TYPES));\nconst RecurringIntervalStruct = enums(Object.values(RECURRING_INTERVALS));\nconst SubscriptionStatusStruct = enums(Object.values(SUBSCRIPTION_STATUSES));\nconst CancelTypeStruct = enums(Object.values(CANCEL_TYPES));\nconst CryptoPaymentMethodErrorStruct = enums(\n Object.values(CRYPTO_PAYMENT_METHOD_ERRORS),\n);\n\nconst ProductStruct = type({\n name: ProductTypeStruct,\n currency: enums(['usd']),\n unitAmount: number(),\n unitDecimals: number(),\n});\n\nconst SubscriptionCardPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCard]),\n card: type({\n brand: string(),\n displayBrand: string(),\n last4: string(),\n }),\n});\n\nconst SubscriptionCryptoPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCrypto]),\n crypto: type({\n payerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n tokenSymbol: string(),\n error: optional(CryptoPaymentMethodErrorStruct),\n }),\n});\n\nconst SubscriptionPaymentMethodStruct = union([\n SubscriptionCardPaymentMethodStruct,\n SubscriptionCryptoPaymentMethodStruct,\n]);\n\nexport const SubscriptionStruct = type({\n id: string(),\n products: array(ProductStruct),\n currentPeriodStart: string(),\n currentPeriodEnd: string(),\n cancelAtPeriodEnd: optional(boolean()),\n status: SubscriptionStatusStruct,\n interval: RecurringIntervalStruct,\n paymentMethod: SubscriptionPaymentMethodStruct,\n trialPeriodDays: optional(number()),\n trialStart: optional(string()),\n trialEnd: optional(string()),\n endDate: optional(string()),\n canceledAt: optional(string()),\n cancelType: CancelTypeStruct,\n inactiveAt: optional(string()),\n isEligibleForSupport: boolean(),\n billingCycles: optional(number()),\n});\n\nexport const GetSubscriptionsResponseStruct = type({\n customerId: optional(string()),\n subscriptions: array(SubscriptionStruct),\n trialedProducts: array(ProductTypeStruct),\n lastSubscription: optional(SubscriptionStruct),\n rewardAccountId: optional(CaipAccountIdStruct),\n});\n\nexport const StartSubscriptionResponseStruct = type({\n checkoutSessionUrl: string(),\n});\n\nexport const StartCryptoSubscriptionResponseStruct = type({\n subscriptionId: string(),\n status: SubscriptionStatusStruct,\n});\n\nexport const UpdatePaymentMethodCardResponseStruct = type({\n redirectUrl: string(),\n});\n\nexport const BillingPortalResponseStruct = type({\n url: string(),\n});\n\nexport const SubscriptionApiGeneralResponseStruct = type({\n success: boolean(),\n message: optional(string()),\n});\n\nconst ProductPriceStruct = type({\n interval: RecurringIntervalStruct,\n unitAmount: number(),\n unitDecimals: number(),\n currency: enums(['usd']),\n trialPeriodDays: number(),\n minBillingCycles: number(),\n minBillingCyclesForBalance: number(),\n});\n\nconst ProductPricingStruct = type({\n name: ProductTypeStruct,\n prices: array(ProductPriceStruct),\n});\n\nconst TokenPaymentInfoStruct = type({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: type({\n usd: string(),\n }),\n});\n\nconst ChainPaymentInfoStruct = type({\n chainId: StrictHexStruct,\n paymentAddress: StrictHexStruct,\n tokens: array(TokenPaymentInfoStruct),\n isSponsorshipSupported: optional(boolean()),\n});\n\nconst PricingPaymentMethodStruct = type({\n type: PaymentTypeStruct,\n chains: optional(array(ChainPaymentInfoStruct)),\n});\n\nexport const PricingResponseStruct = type({\n products: array(ProductPricingStruct),\n paymentMethods: array(PricingPaymentMethodStruct),\n});\n\nconst CohortStruct = type({\n cohort: string(),\n eligibilityRate: number(),\n priority: number(),\n eligible: boolean(),\n});\n\nexport const SubscriptionEligibilityStruct = type({\n product: ProductTypeStruct,\n canSubscribe: optional(boolean()),\n canViewEntryModal: optional(boolean()),\n modalType: optional(enums(['A', 'B'])),\n cohorts: optional(array(CohortStruct)),\n assignedCohort: optional(nullable(string())),\n assignedAt: optional(string()),\n hasAssignedCohortExpired: optional(boolean()),\n});\n\nexport const SubscriptionEligibilityArrayStruct = array(\n SubscriptionEligibilityStruct,\n);\n"]}
|