@metamask-previews/subscription-controller 0.0.0-preview-a346afae → 0.0.0-preview-5ca78b09
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 +2 -0
- package/dist/SubscriptionController.cjs +83 -2
- package/dist/SubscriptionController.cjs.map +1 -1
- package/dist/SubscriptionController.d.cts +27 -2
- package/dist/SubscriptionController.d.cts.map +1 -1
- package/dist/SubscriptionController.d.mts +27 -2
- package/dist/SubscriptionController.d.mts.map +1 -1
- package/dist/SubscriptionController.mjs +84 -3
- package/dist/SubscriptionController.mjs.map +1 -1
- package/dist/SubscriptionService.cjs +11 -13
- package/dist/SubscriptionService.cjs.map +1 -1
- package/dist/SubscriptionService.d.cts +2 -2
- package/dist/SubscriptionService.d.cts.map +1 -1
- package/dist/SubscriptionService.d.mts +2 -2
- package/dist/SubscriptionService.d.mts.map +1 -1
- package/dist/SubscriptionService.mjs +11 -13
- package/dist/SubscriptionService.mjs.map +1 -1
- package/dist/constants.cjs +3 -3
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.mjs +3 -3
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +72 -17
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +72 -17
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -2
package/dist/types.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,WAEX;AAFD,WAAY,WAAW;IACrB,gCAAiB,CAAA;AACnB,CAAC,EAFW,WAAW,KAAX,WAAW,QAEtB;AAYD,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,kCAAmB,CAAA;AACrB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAED,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,oCAAe,CAAA;IACf,kCAAa,CAAA;AACf,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED,MAAM,CAAN,IAAY,kBAmBX;AAnBD,WAAY,kBAAkB;IAC5B,iBAAiB;IACjB,+CAAyB,CAAA;IACzB,8DAAwC,CAAA;IAExC,gBAAgB;IAChB,iDAA2B,CAAA;IAC3B,2CAAqB,CAAA;IACrB,uCAAiB,CAAA;IAEjB,iBAAiB;IACjB,0CAAoB,CAAA;IACpB,uCAAiB,CAAA;IAEjB,mBAAmB;IACnB,2CAAqB,CAAA;IAErB,gBAAgB;IAChB,uCAAiB,CAAA;AACnB,CAAC,EAnBW,kBAAkB,KAAlB,kBAAkB,QAmB7B","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport enum ProductType {\n SHIELD = 'shield',\n}\n\n/** only usd for now */\nexport type Currency = 'usd';\n\nexport type Product = {\n name: ProductType;\n id: string;\n currency: Currency;\n amount: number;\n};\n\nexport enum PaymentType {\n byCard = 'card',\n byCrypto = 'crypto',\n}\n\nexport enum RecurringInterval {\n month = 'month',\n year = 'year',\n}\n\nexport enum SubscriptionStatus {\n // Initial states\n incomplete = 'incomplete',\n incompleteExpired = 'incomplete_expired',\n\n // Active states\n provisional = 'provisional',\n trialing = 'trialing',\n active = 'active',\n\n // Payment issues\n pastDue = 'past_due',\n unpaid = 'unpaid',\n\n // Cancelled states\n canceled = 'canceled',\n\n // Paused states\n paused = 'paused',\n}\n\n// state\nexport type Subscription = {\n id: string;\n products: Product[];\n currentPeriodStart: string; // ISO 8601\n currentPeriodEnd: string; // ISO 8601\n status: SubscriptionStatus;\n interval: RecurringInterval;\n paymentMethod: SubscriptionPaymentMethod;\n};\n\nexport type SubscriptionPaymentMethod = {\n type: PaymentType;\n crypto?: {\n payerAddress: Hex;\n chainId: Hex;\n tokenSymbol: string;\n };\n};\n\nexport type GetSubscriptionsResponse = {\n customerId?: string;\n subscriptions: Subscription[];\n trialedProducts: ProductType[];\n};\n\nexport type StartSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n};\n\nexport type StartSubscriptionResponse = {\n checkoutSessionUrl: string;\n};\n\nexport type StartCryptoSubscriptionRequest = {\n products: ProductType[];\n isTrialRequested: boolean;\n recurringInterval: RecurringInterval;\n billingCycles: number;\n chainId: Hex;\n payerAddress: Hex;\n /**\n * e.g. \"USDC\"\n */\n tokenSymbol: string;\n rawTransaction: Hex;\n};\n\nexport type StartCryptoSubscriptionResponse = {\n subscriptionId: string;\n status: SubscriptionStatus;\n};\n\nexport type AuthUtils = {\n getAccessToken: () => Promise<string>;\n};\n\nexport type ProductPrice = {\n interval: RecurringInterval;\n unitAmount: number; // amount in the smallest unit of the currency, e.g., cents\n unitDecimals: number; // number of decimals for the smallest unit of the currency\n /** only usd for now */\n currency: Currency;\n trialPeriodDays: number;\n minBillingCycles: number;\n};\n\nexport type ProductPricing = {\n name: ProductType;\n prices: ProductPrice[];\n};\n\nexport type TokenPaymentInfo = {\n symbol: string;\n address: Hex;\n decimals: number;\n /**\n * example: {\n usd: '1.0',\n },\n */\n conversionRate: {\n usd: string;\n };\n};\n\nexport type ChainPaymentInfo = {\n chainId: Hex;\n paymentAddress: Hex;\n tokens: TokenPaymentInfo[];\n};\n\nexport type PricingPaymentMethod = {\n type: PaymentType;\n chains?: ChainPaymentInfo[];\n};\n\nexport type PricingResponse = {\n products: ProductPricing[];\n paymentMethods: PricingPaymentMethod[];\n};\n\nexport type GetCryptoApproveTransactionRequest = {\n /**\n * payment chain ID\n */\n chainId: Hex;\n /**\n * Payment token address\n */\n paymentTokenAddress: Hex;\n productType: ProductType;\n interval: RecurringInterval;\n};\n\nexport type GetCryptoApproveTransactionResponse = {\n /**\n * The amount to approve\n * e.g: \"100000000\"\n */\n approveAmount: string;\n /**\n * The contract address (spender)\n */\n paymentAddress: Hex;\n /**\n * The payment token address\n */\n paymentTokenAddress: Hex;\n chainId: Hex;\n};\n\nexport type ISubscriptionService = {\n getSubscriptions(): Promise<GetSubscriptionsResponse>;\n cancelSubscription(request: { subscriptionId: string }): Promise<void>;\n startSubscriptionWithCard(\n request: StartSubscriptionRequest,\n ): Promise<StartSubscriptionResponse>;\n getPricing(): Promise<PricingResponse>;\n startSubscriptionWithCrypto(\n request: StartCryptoSubscriptionRequest,\n ): Promise<StartCryptoSubscriptionResponse>;\n};\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@metamask-previews/subscription-controller",
|
3
|
-
"version": "0.0.0-preview-
|
3
|
+
"version": "0.0.0-preview-5ca78b09",
|
4
4
|
"description": "Handle user subscription",
|
5
5
|
"keywords": [
|
6
6
|
"MetaMask",
|
@@ -48,6 +48,7 @@
|
|
48
48
|
},
|
49
49
|
"dependencies": {
|
50
50
|
"@metamask/base-controller": "^8.3.0",
|
51
|
+
"@metamask/controller-utils": "^11.12.0",
|
51
52
|
"@metamask/utils": "^11.4.2"
|
52
53
|
},
|
53
54
|
"devDependencies": {
|
@@ -56,7 +57,6 @@
|
|
56
57
|
"@types/jest": "^27.4.1",
|
57
58
|
"deepmerge": "^4.2.2",
|
58
59
|
"jest": "^27.5.1",
|
59
|
-
"nock": "^13.3.1",
|
60
60
|
"ts-jest": "^27.1.4",
|
61
61
|
"typedoc": "^0.24.8",
|
62
62
|
"typedoc-plugin-missing-exports": "^2.0.0",
|