@metamask-previews/subscription-controller 9.0.1-preview-b3db565c8 → 9.0.1-preview-cfb927be0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/constants.d.ts +16 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +17 -0
  5. package/dist/constants.js.map +1 -1
  6. package/dist/index.d.ts +7 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.d.ts +44 -0
  11. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.d.ts.map +1 -0
  12. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.js +6 -0
  13. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.js.map +1 -0
  14. package/dist/subscription-delegation/SubscriptionDelegationService.d.ts +93 -0
  15. package/dist/subscription-delegation/SubscriptionDelegationService.d.ts.map +1 -0
  16. package/dist/subscription-delegation/SubscriptionDelegationService.js +290 -0
  17. package/dist/subscription-delegation/SubscriptionDelegationService.js.map +1 -0
  18. package/dist/subscription-delegation/amount.d.ts +49 -0
  19. package/dist/subscription-delegation/amount.d.ts.map +1 -0
  20. package/dist/subscription-delegation/amount.js +84 -0
  21. package/dist/subscription-delegation/amount.js.map +1 -0
  22. package/dist/subscription-delegation/caveats.d.ts +41 -0
  23. package/dist/subscription-delegation/caveats.d.ts.map +1 -0
  24. package/dist/subscription-delegation/caveats.js +59 -0
  25. package/dist/subscription-delegation/caveats.js.map +1 -0
  26. package/dist/subscription-delegation/fingerprint.d.ts +42 -0
  27. package/dist/subscription-delegation/fingerprint.d.ts.map +1 -0
  28. package/dist/subscription-delegation/fingerprint.js +80 -0
  29. package/dist/subscription-delegation/fingerprint.js.map +1 -0
  30. package/dist/subscription-delegation/types.d.ts +73 -0
  31. package/dist/subscription-delegation/types.d.ts.map +1 -0
  32. package/dist/subscription-delegation/types.js +10 -0
  33. package/dist/subscription-delegation/types.js.map +1 -0
  34. package/package.json +10 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add `SubscriptionDelegationService` for Money Account Plus cash-subscription delegation setup. ([#10130](https://github.com/MetaMask/core/pull/10130))
13
+ - New messenger action `SubscriptionDelegationService:prepareDelegation` orchestrates periodic caveat construction, signing, CHOMP verification, Authenticated User Storage persistence, and CHOMP intent registration.
14
+ - Returns a verified `delegationHash` with `disposition: 'created' | 'reused'` for `SubscriptionController.startSubscriptionWithCrypto`; the controller does not depend on this service.
15
+ - `prepareDelegation` accepts the product, recurring interval, payer address, trial selection, optional balance-check flag, and optional `skipChompInteractions` flag; it resolves plan, token, and delegate data through `SubscriptionController:getPricing`.
16
+ - When `skipChompInteractions` is true, CHOMP verify and intent registration are skipped; the returned hash is computed locally and AUS persistence still occurs.
17
+ - Resolves the chain from `moneyAccountVaultConfig` and Delegation Framework v1.3.0 enforcers from `@metamask/delegation-deployments`.
18
+ - Uses pricing `delegateAddress` as both the delegation `delegate` and the RedeemerEnforcer redeemer.
19
+ - Offsets the period-transfer `startDate` by pricing `trialPeriodDays` only when the trial is selected.
20
+ - New messenger action `SubscriptionDelegationService:checkMoneyAccountBalance` compares Money Account convertible mUSD balance against pricing `unitAmount × minBillingCyclesForBalance`; `prepareDelegation` can gate on it via `checkBalance`.
21
+ - Exports `CASH_SUBSCRIPTION_DELEGATION_TYPE` (`'cash-subscription'`) for AUS metadata (and for CHOMP intent metadata once chomp-api-service supports that type).
22
+ - Only Money Account Plus is supported; Shield continues to use ERC-20 approval.
23
+
10
24
  ## [9.0.1]
11
25
 
12
26
  ### Changed
@@ -44,6 +44,22 @@ export declare enum SubscriptionServiceErrorMessage {
44
44
  FailedToGetPricing = "Failed to get pricing",
45
45
  FailedToGetBillingPortalUrl = "Failed to get billing portal url"
46
46
  }
47
+ export declare enum SubscriptionDelegationServiceErrorMessage {
48
+ InvalidAmount = "Subscription delegation amount must be a non-negative integer",
49
+ InvalidDecimals = "Subscription delegation decimals must be a non-negative integer",
50
+ InvalidTrialPeriodDays = "Subscription delegation trial period days must be a non-negative integer",
51
+ InvalidMinimumFundingCycles = "Subscription delegation minimum funding cycles must be a positive integer",
52
+ LossyAmountScale = "Subscription delegation amount cannot be scaled to token decimals without remainder",
53
+ UnsupportedRecurringInterval = "Unsupported subscription recurring interval",
54
+ UnsupportedProduct = "Subscription delegation is only supported for Money Account",
55
+ MissingMoneyAccountVaultConfig = "Money Account vault configuration is missing or invalid",
56
+ DelegationContractsNotFound = "Subscription delegation contracts were not found for the configured chain",
57
+ PricingConfigurationNotFound = "Subscription delegation pricing configuration was not found",
58
+ InsufficientBalance = "Money Account balance is insufficient for the subscription funding requirement",
59
+ ChompRejectedDelegation = "CHOMP rejected the subscription delegation",
60
+ ChompMissingDelegationHash = "CHOMP verify response did not include a delegation hash",
61
+ ChompDelegationHashMismatch = "CHOMP verify response delegation hash does not match the locally computed hash"
62
+ }
47
63
  export declare const DEFAULT_POLLING_INTERVAL: number;
48
64
  export declare const ACTIVE_SUBSCRIPTION_STATUSES: string[];
49
65
  export {};
@@ -1 +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;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ACpI,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,oBAAY,yCAAyC;IACnD,aAAa,kEAAkE;IAC/E,eAAe,oEAAoE;IACnF,sBAAsB,6EAA6E;IACnG,2BAA2B,8EAA8E;IACzG,gBAAgB,wFAAwF;IACxG,4BAA4B,gDAAgD;IAC5E,kBAAkB,gEAAgE;IAClF,8BAA8B,4DAA4D;IAC1F,2BAA2B,8EAA8E;IACzG,4BAA4B,gEAAgE;IAC5F,mBAAmB,mFAAmF;IACtG,uBAAuB,+CAA+C;IACtE,0BAA0B,4DAA4D;IACtF,2BAA2B,mFAAmF;CAC/G;AAED,eAAO,MAAM,wBAAwB,QAAiB,CAAC;AAEvD,eAAO,MAAM,4BAA4B,EAIpC,MAAM,EAAE,CAAC"}
package/dist/constants.js CHANGED
@@ -61,6 +61,23 @@ 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 var SubscriptionDelegationServiceErrorMessage;
65
+ (function (SubscriptionDelegationServiceErrorMessage) {
66
+ SubscriptionDelegationServiceErrorMessage["InvalidAmount"] = "Subscription delegation amount must be a non-negative integer";
67
+ SubscriptionDelegationServiceErrorMessage["InvalidDecimals"] = "Subscription delegation decimals must be a non-negative integer";
68
+ SubscriptionDelegationServiceErrorMessage["InvalidTrialPeriodDays"] = "Subscription delegation trial period days must be a non-negative integer";
69
+ SubscriptionDelegationServiceErrorMessage["InvalidMinimumFundingCycles"] = "Subscription delegation minimum funding cycles must be a positive integer";
70
+ SubscriptionDelegationServiceErrorMessage["LossyAmountScale"] = "Subscription delegation amount cannot be scaled to token decimals without remainder";
71
+ SubscriptionDelegationServiceErrorMessage["UnsupportedRecurringInterval"] = "Unsupported subscription recurring interval";
72
+ SubscriptionDelegationServiceErrorMessage["UnsupportedProduct"] = "Subscription delegation is only supported for Money Account";
73
+ SubscriptionDelegationServiceErrorMessage["MissingMoneyAccountVaultConfig"] = "Money Account vault configuration is missing or invalid";
74
+ SubscriptionDelegationServiceErrorMessage["DelegationContractsNotFound"] = "Subscription delegation contracts were not found for the configured chain";
75
+ SubscriptionDelegationServiceErrorMessage["PricingConfigurationNotFound"] = "Subscription delegation pricing configuration was not found";
76
+ SubscriptionDelegationServiceErrorMessage["InsufficientBalance"] = "Money Account balance is insufficient for the subscription funding requirement";
77
+ SubscriptionDelegationServiceErrorMessage["ChompRejectedDelegation"] = "CHOMP rejected the subscription delegation";
78
+ SubscriptionDelegationServiceErrorMessage["ChompMissingDelegationHash"] = "CHOMP verify response did not include a delegation hash";
79
+ SubscriptionDelegationServiceErrorMessage["ChompDelegationHashMismatch"] = "CHOMP verify response delegation hash does not match the locally computed hash";
80
+ })(SubscriptionDelegationServiceErrorMessage || (SubscriptionDelegationServiceErrorMessage = {}));
64
81
  export const DEFAULT_POLLING_INTERVAL = 5 * 60 * 1_000; // 5 minutes
65
82
  export const ACTIVE_SUBSCRIPTION_STATUSES = [
66
83
  SUBSCRIPTION_STATUSES.active,
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EA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D,4GAAyE,CAAA;IACzE,iFAA8C,CAAA;IAC9C,+EAA4C,CAAA;IAC5C,mGAAgE,CAAA;AAClE,CAAC,EAjBW,+BAA+B,KAA/B,+BAA+B,QAiB1C;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,YAAY;AAEpE,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,qBAAqB,CAAC,MAAM;IAC5B,qBAAqB,CAAC,QAAQ;IAC9B,qBAAqB,CAAC,WAAW;CACtB,CAAC","sourcesContent":["import { SUBSCRIPTION_STATUSES } from './types.js';\n\nexport const controllerName = 'SubscriptionController';\n\nexport enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\ntype EnvUrlsEntry = {\n subscriptionApiUrl: string;\n};\n\nconst ENV_URLS: Record<Env, EnvUrlsEntry> = {\n dev: {\n subscriptionApiUrl: 'https://subscription.dev-api.cx.metamask.io',\n },\n uat: {\n subscriptionApiUrl: 'https://subscription.uat-api.cx.metamask.io',\n },\n prd: {\n subscriptionApiUrl: 'https://subscription.api.cx.metamask.io',\n },\n};\n\n/**\n * Validates and returns correct environment endpoints\n *\n * @param env - environment field\n * @returns the correct environment url\n * @throws on invalid environment passed\n */\nexport function getEnvUrls(env: Env): EnvUrlsEntry {\n if (!ENV_URLS[env]) {\n throw new Error('invalid environment configuration');\n }\n return ENV_URLS[env];\n}\n\nexport enum SubscriptionControllerErrorMessage {\n UserAlreadySubscribed = `${controllerName} - User is already subscribed`,\n UserNotSubscribed = `${controllerName} - User is not subscribed`,\n SubscriptionProductsEmpty = `${controllerName} - Subscription products array cannot be empty`,\n PaymentTokenAddressAndSymbolRequiredForCrypto = `${controllerName} - Payment token address and symbol are required for crypto payment`,\n PaymentMethodNotCrypto = `${controllerName} - Payment method is not crypto`,\n ProductPriceNotFound = `${controllerName} - Product price not found`,\n SubscriptionNotValidForCryptoApproval = `${controllerName} - Subscription is not valid for crypto approval`,\n CryptoApprovalRequiresShieldApprove = `${controllerName} - Crypto approval is only supported for Shield ERC-20 approve transactions`,\n LinkRewardsFailed = `${controllerName} - Failed to link rewards`,\n}\n\nexport enum SubscriptionServiceErrorMessage {\n FailedToGetSubscriptions = 'Failed to get subscriptions',\n 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
+ {"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,CAA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nD,4HAA+E,CAAA;IAC/E,gIAAmF,CAAA;IACnF,gJAAmG,CAAA;IACnG,sJAAyG,CAAA;IACzG,qJAAwG,CAAA;IACxG,yHAA4E,CAAA;IAC5E,+HAAkF,CAAA;IAClF,uIAA0F,CAAA;IAC1F,sJAAyG,CAAA;IACzG,yIAA4F,CAAA;IAC5F,mJAAsG,CAAA;IACtG,mHAAsE,CAAA;IACtE,mIAAsF,CAAA;IACtF,2JAA8G,CAAA;AAChH,CAAC,EAfW,yCAAyC,KAAzC,yCAAyC,QAepD;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,YAAY;AAEpE,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,qBAAqB,CAAC,MAAM;IAC5B,qBAAqB,CAAC,QAAQ;IAC9B,qBAAqB,CAAC,WAAW;CACtB,CAAC","sourcesContent":["import { SUBSCRIPTION_STATUSES } from './types.js';\n\nexport const controllerName = 'SubscriptionController';\n\nexport enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\ntype EnvUrlsEntry = {\n subscriptionApiUrl: string;\n};\n\nconst ENV_URLS: Record<Env, EnvUrlsEntry> = {\n dev: {\n subscriptionApiUrl: 'https://subscription.dev-api.cx.metamask.io',\n },\n uat: {\n subscriptionApiUrl: 'https://subscription.uat-api.cx.metamask.io',\n },\n prd: {\n subscriptionApiUrl: 'https://subscription.api.cx.metamask.io',\n },\n};\n\n/**\n * Validates and returns correct environment endpoints\n *\n * @param env - environment field\n * @returns the correct environment url\n * @throws on invalid environment passed\n */\nexport function getEnvUrls(env: Env): EnvUrlsEntry {\n if (!ENV_URLS[env]) {\n throw new Error('invalid environment configuration');\n }\n return ENV_URLS[env];\n}\n\nexport enum SubscriptionControllerErrorMessage {\n UserAlreadySubscribed = `${controllerName} - User is already subscribed`,\n UserNotSubscribed = `${controllerName} - User is not subscribed`,\n SubscriptionProductsEmpty = `${controllerName} - Subscription products array cannot be empty`,\n PaymentTokenAddressAndSymbolRequiredForCrypto = `${controllerName} - Payment token address and symbol are required for crypto payment`,\n PaymentMethodNotCrypto = `${controllerName} - Payment method is not crypto`,\n ProductPriceNotFound = `${controllerName} - Product price not found`,\n SubscriptionNotValidForCryptoApproval = `${controllerName} - Subscription is not valid for crypto approval`,\n CryptoApprovalRequiresShieldApprove = `${controllerName} - Crypto approval is only supported for Shield ERC-20 approve transactions`,\n LinkRewardsFailed = `${controllerName} - Failed to link rewards`,\n}\n\nexport enum SubscriptionServiceErrorMessage {\n FailedToGetSubscriptions = 'Failed to get subscriptions',\n 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 enum SubscriptionDelegationServiceErrorMessage {\n InvalidAmount = 'Subscription delegation amount must be a non-negative integer',\n InvalidDecimals = 'Subscription delegation decimals must be a non-negative integer',\n InvalidTrialPeriodDays = 'Subscription delegation trial period days must be a non-negative integer',\n InvalidMinimumFundingCycles = 'Subscription delegation minimum funding cycles must be a positive integer',\n LossyAmountScale = 'Subscription delegation amount cannot be scaled to token decimals without remainder',\n UnsupportedRecurringInterval = 'Unsupported subscription recurring interval',\n UnsupportedProduct = 'Subscription delegation is only supported for Money Account',\n MissingMoneyAccountVaultConfig = 'Money Account vault configuration is missing or invalid',\n DelegationContractsNotFound = 'Subscription delegation contracts were not found for the configured chain',\n PricingConfigurationNotFound = 'Subscription delegation pricing configuration was not found',\n InsufficientBalance = 'Money Account balance is insufficient for the subscription funding requirement',\n ChompRejectedDelegation = 'CHOMP rejected the subscription delegation',\n ChompMissingDelegationHash = 'CHOMP verify response did not include a delegation hash',\n ChompDelegationHashMismatch = 'CHOMP verify response delegation hash does not match the locally computed hash',\n}\n\nexport const DEFAULT_POLLING_INTERVAL = 5 * 60 * 1_000; // 5 minutes\n\nexport const ACTIVE_SUBSCRIPTION_STATUSES = [\n SUBSCRIPTION_STATUSES.active,\n SUBSCRIPTION_STATUSES.trialing,\n SUBSCRIPTION_STATUSES.provisional,\n] as string[];\n"]}
package/dist/index.d.ts CHANGED
@@ -5,8 +5,14 @@ export type { SubscriptionApiError, Subscription, PerpsBenefitUsage, PredictBene
5
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
6
  export { selectHasEntitlement, selectIsActiveSubscriber, selectIsUsageAvailable, } from './selectors.js';
7
7
  export { SubscriptionServiceError } from './errors.js';
8
- export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from './constants.js';
8
+ export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, SubscriptionDelegationServiceErrorMessage, } from './constants.js';
9
9
  export type { SubscriptionServiceOptions, SubscriptionServiceMessenger, SubscriptionServiceActions, SubscriptionServiceEvents, SubscriptionServiceCacheUpdatedEvent, SubscriptionServiceGranularCacheUpdatedEvent, SubscriptionServiceInvalidateQueriesAction, } from './SubscriptionService.js';
10
10
  export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL, } from './SubscriptionService.js';
11
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
+ export type { SubscriptionDelegationServiceActions, SubscriptionDelegationServiceEvents, SubscriptionDelegationServiceMessenger, SubscriptionDelegationServiceOptions, } from './subscription-delegation/SubscriptionDelegationService.js';
13
+ export { SubscriptionDelegationService, serviceName as subscriptionDelegationServiceName, } from './subscription-delegation/SubscriptionDelegationService.js';
14
+ export type { SubscriptionDelegationServicePrepareDelegationAction } from './subscription-delegation/SubscriptionDelegationService-method-action-types.js';
15
+ export type { SubscriptionDelegationServiceCheckMoneyAccountBalanceAction } from './subscription-delegation/SubscriptionDelegationService-method-action-types.js';
16
+ export type { MoneyAccountBalanceCheckRequest, MoneyAccountBalanceCheckResult, PrepareSubscriptionDelegationRequest, PreparedSubscriptionDelegation, } from './subscription-delegation/types.js';
17
+ export { CASH_SUBSCRIPTION_DELEGATION_TYPE } from './subscription-delegation/types.js';
12
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3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,gCAAgC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,qCAAqC,EACrC,oCAAoC,EACpC,MAAM,EACN,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,oCAAoC,EACpC,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,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;AACxB,YAAY,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,oCAAoC,EACpC,4CAA4C,EAC5C,0CAA0C,GAC3C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"A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YAAY,EACV,oCAAoC,EACpC,mCAAmC,EACnC,sCAAsC,EACtC,oCAAoC,GACrC,MAAM,4DAA4D,CAAC;AACpE,OAAO,EACL,6BAA6B,EAC7B,WAAW,IAAI,iCAAiC,GACjD,MAAM,4DAA4D,CAAC;AACpE,YAAY,EAAE,oDAAoD,EAAE,MAAM,gFAAgF,CAAC;AAC3J,YAAY,EAAE,2DAA2D,EAAE,MAAM,gFAAgF,CAAC;AAClK,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC"}
package/dist/index.js CHANGED
@@ -2,6 +2,8 @@ export { SubscriptionController, getDefaultSubscriptionControllerState, } from '
2
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
3
  export { selectHasEntitlement, selectIsActiveSubscriber, selectIsUsageAvailable, } from './selectors.js';
4
4
  export { SubscriptionServiceError } from './errors.js';
5
- export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, } from './constants.js';
5
+ export { Env, SubscriptionControllerErrorMessage, SubscriptionServiceErrorMessage, SubscriptionDelegationServiceErrorMessage, } from './constants.js';
6
6
  export { SubscriptionService, serviceName as subscriptionServiceName, SUBSCRIPTION_URL, } from './SubscriptionService.js';
7
+ export { SubscriptionDelegationService, serviceName as subscriptionDelegationServiceName, } from './subscription-delegation/SubscriptionDelegationService.js';
8
+ export { CASH_SUBSCRIPTION_DELEGATION_TYPE } from './subscription-delegation/types.js';
7
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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"]}
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,EAC/B,yCAAyC,GAC1C,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EACL,mBAAmB,EACnB,WAAW,IAAI,uBAAuB,EACtC,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAyBlC,OAAO,EACL,6BAA6B,EAC7B,WAAW,IAAI,iCAAiC,GACjD,MAAM,4DAA4D,CAAC;AASpE,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,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 SubscriptionDelegationServiceErrorMessage,\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\nexport type {\n SubscriptionDelegationServiceActions,\n SubscriptionDelegationServiceEvents,\n SubscriptionDelegationServiceMessenger,\n SubscriptionDelegationServiceOptions,\n} from './subscription-delegation/SubscriptionDelegationService.js';\nexport {\n SubscriptionDelegationService,\n serviceName as subscriptionDelegationServiceName,\n} from './subscription-delegation/SubscriptionDelegationService.js';\nexport type { SubscriptionDelegationServicePrepareDelegationAction } from './subscription-delegation/SubscriptionDelegationService-method-action-types.js';\nexport type { SubscriptionDelegationServiceCheckMoneyAccountBalanceAction } from './subscription-delegation/SubscriptionDelegationService-method-action-types.js';\nexport type {\n MoneyAccountBalanceCheckRequest,\n MoneyAccountBalanceCheckResult,\n PrepareSubscriptionDelegationRequest,\n PreparedSubscriptionDelegation,\n} from './subscription-delegation/types.js';\nexport { CASH_SUBSCRIPTION_DELEGATION_TYPE } from './subscription-delegation/types.js';\n"]}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { SubscriptionDelegationService } from './SubscriptionDelegationService.js';
6
+ /**
7
+ * Checks whether the Money Account holds enough convertible mUSD value to
8
+ * cover pricing `unitAmount × minBillingCyclesForBalance`.
9
+ *
10
+ * @param request - Payer address and pricing amount fields.
11
+ * @returns Balance comparison in mUSD base units (6 decimals).
12
+ */
13
+ export type SubscriptionDelegationServiceCheckMoneyAccountBalanceAction = {
14
+ type: `SubscriptionDelegationService:checkMoneyAccountBalance`;
15
+ handler: SubscriptionDelegationService['checkMoneyAccountBalance'];
16
+ };
17
+ /**
18
+ * Prepares a cash-subscription delegation and returns its hash.
19
+ *
20
+ * Reuses a stored AUS delegation that matches the semantic fingerprint when
21
+ * one exists (ensuring a CHOMP intent is active for its hash, unless
22
+ * `skipChompInteractions` is true). Reuse classifies period `startDate` as
23
+ * trial-deferred (`> now`) vs immediately redeemable, matching creation.
24
+ * If there is no match, builds, signs, optionally verifies with CHOMP,
25
+ * persists, and optionally registers a new delegation.
26
+ *
27
+ * When `skipChompInteractions` is true (required for alpha), CHOMP verify
28
+ * and intent calls are skipped; the returned hash is computed locally. The
29
+ * default CHOMP-enabled path requires a follow-up chomp-api-service release
30
+ * that accepts `'cash-subscription'` intent metadata.
31
+ *
32
+ * @param request - Authoritative pricing and payer details for the delegation.
33
+ * @returns The delegation hash (CHOMP-verified unless skipped) and whether it
34
+ * was created or reused.
35
+ */
36
+ export type SubscriptionDelegationServicePrepareDelegationAction = {
37
+ type: `SubscriptionDelegationService:prepareDelegation`;
38
+ handler: SubscriptionDelegationService['prepareDelegation'];
39
+ };
40
+ /**
41
+ * Union of all SubscriptionDelegationService action types.
42
+ */
43
+ export type SubscriptionDelegationServiceMethodActions = SubscriptionDelegationServiceCheckMoneyAccountBalanceAction | SubscriptionDelegationServicePrepareDelegationAction;
44
+ //# sourceMappingURL=SubscriptionDelegationService-method-action-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionDelegationService-method-action-types.d.ts","sourceRoot":"","sources":["../../src/subscription-delegation/SubscriptionDelegationService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAExF;;;;;;GAMG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,6BAA6B,CAAC,0BAA0B,CAAC,CAAC;CACpE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,6BAA6B,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0CAA0C,GAClD,2DAA2D,GAC3D,oDAAoD,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=SubscriptionDelegationService-method-action-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionDelegationService-method-action-types.js","sourceRoot":"","sources":["../../src/subscription-delegation/SubscriptionDelegationService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SubscriptionDelegationService } from './SubscriptionDelegationService.js';\n\n/**\n * Checks whether the Money Account holds enough convertible mUSD value to\n * cover pricing `unitAmount × minBillingCyclesForBalance`.\n *\n * @param request - Payer address and pricing amount fields.\n * @returns Balance comparison in mUSD base units (6 decimals).\n */\nexport type SubscriptionDelegationServiceCheckMoneyAccountBalanceAction = {\n type: `SubscriptionDelegationService:checkMoneyAccountBalance`;\n handler: SubscriptionDelegationService['checkMoneyAccountBalance'];\n};\n\n/**\n * Prepares a cash-subscription delegation and returns its hash.\n *\n * Reuses a stored AUS delegation that matches the semantic fingerprint when\n * one exists (ensuring a CHOMP intent is active for its hash, unless\n * `skipChompInteractions` is true). Reuse classifies period `startDate` as\n * trial-deferred (`> now`) vs immediately redeemable, matching creation.\n * If there is no match, builds, signs, optionally verifies with CHOMP,\n * persists, and optionally registers a new delegation.\n *\n * When `skipChompInteractions` is true (required for alpha), CHOMP verify\n * and intent calls are skipped; the returned hash is computed locally. The\n * default CHOMP-enabled path requires a follow-up chomp-api-service release\n * that accepts `'cash-subscription'` intent metadata.\n *\n * @param request - Authoritative pricing and payer details for the delegation.\n * @returns The delegation hash (CHOMP-verified unless skipped) and whether it\n * was created or reused.\n */\nexport type SubscriptionDelegationServicePrepareDelegationAction = {\n type: `SubscriptionDelegationService:prepareDelegation`;\n handler: SubscriptionDelegationService['prepareDelegation'];\n};\n\n/**\n * Union of all SubscriptionDelegationService action types.\n */\nexport type SubscriptionDelegationServiceMethodActions =\n | SubscriptionDelegationServiceCheckMoneyAccountBalanceAction\n | SubscriptionDelegationServicePrepareDelegationAction;\n"]}
@@ -0,0 +1,93 @@
1
+ import type { AuthenticatedUserStorageServiceCreateDelegationAction, AuthenticatedUserStorageServiceListDelegationsAction } from '@metamask/authenticated-user-storage';
2
+ import type { ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceVerifyDelegationAction } from '@metamask/chomp-api-service';
3
+ import type { DelegationControllerSignDelegationAction } from '@metamask/delegation-controller';
4
+ import type { Messenger } from '@metamask/messenger';
5
+ import type { MoneyAccountBalanceServiceFetchBalanceWithFallbackAction } from '@metamask/money-account-balance-service';
6
+ import type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';
7
+ import type { SubscriptionControllerGetPricingAction } from '../SubscriptionController-method-action-types.js';
8
+ import type { SubscriptionDelegationServiceMethodActions } from './SubscriptionDelegationService-method-action-types.js';
9
+ import type { MoneyAccountBalanceCheckRequest, MoneyAccountBalanceCheckResult, PrepareSubscriptionDelegationRequest, PreparedSubscriptionDelegation } from './types.js';
10
+ /**
11
+ * The name of the {@link SubscriptionDelegationService}, used to namespace the
12
+ * service's actions and events.
13
+ */
14
+ export declare const serviceName = "SubscriptionDelegationService";
15
+ /**
16
+ * Actions that {@link SubscriptionDelegationService} exposes to other consumers.
17
+ */
18
+ export type SubscriptionDelegationServiceActions = SubscriptionDelegationServiceMethodActions;
19
+ /**
20
+ * Actions from other messengers that {@link SubscriptionDelegationServiceMessenger} calls.
21
+ */
22
+ type AllowedActions = AuthenticatedUserStorageServiceListDelegationsAction | AuthenticatedUserStorageServiceCreateDelegationAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | DelegationControllerSignDelegationAction | MoneyAccountBalanceServiceFetchBalanceWithFallbackAction | RemoteFeatureFlagControllerGetStateAction | SubscriptionControllerGetPricingAction;
23
+ /**
24
+ * Events that {@link SubscriptionDelegationService} exposes to other consumers.
25
+ */
26
+ export type SubscriptionDelegationServiceEvents = never;
27
+ type AllowedEvents = never;
28
+ /**
29
+ * The messenger which is restricted to actions and events accessed by
30
+ * {@link SubscriptionDelegationService}.
31
+ */
32
+ export type SubscriptionDelegationServiceMessenger = Messenger<typeof serviceName, SubscriptionDelegationServiceActions | AllowedActions, SubscriptionDelegationServiceEvents | AllowedEvents>;
33
+ /**
34
+ * Options for constructing {@link SubscriptionDelegationService}.
35
+ */
36
+ export type SubscriptionDelegationServiceOptions = {
37
+ messenger: SubscriptionDelegationServiceMessenger;
38
+ };
39
+ /**
40
+ * Stateless orchestrator for cash-subscription delegation setup.
41
+ *
42
+ * Owns the workflow: size periodic caveats → sign → CHOMP verify → persist to
43
+ * Authenticated User Storage → register CHOMP intent. Returns a verified
44
+ * `delegationHash` for `SubscriptionController.startSubscriptionWithCrypto`.
45
+ *
46
+ * Alpha callers must pass `skipChompInteractions: true` until a follow-up
47
+ * `@metamask/chomp-api-service` release accepts `'cash-subscription'` intent
48
+ * metadata. The CHOMP-enabled path (`skipChompInteractions` unset/false)
49
+ * remains dormant and is not production-ready without that package support.
50
+ *
51
+ * Each call resolves the Money Account chain from remote feature flags, then
52
+ * resolves its price, payment token, and delegate from `SubscriptionController`
53
+ * pricing. The pricing `delegateAddress` is used as both the delegation
54
+ * `delegate` and the RedeemerEnforcer redeemer.
55
+ *
56
+ * Does not own subscription state; `SubscriptionController` does not depend on
57
+ * this service. Only Money Account Plus is supported.
58
+ */
59
+ export declare class SubscriptionDelegationService {
60
+ #private;
61
+ readonly name: typeof serviceName;
62
+ constructor(options: SubscriptionDelegationServiceOptions);
63
+ /**
64
+ * Checks whether the Money Account holds enough convertible mUSD value to
65
+ * cover pricing `unitAmount × minBillingCyclesForBalance`.
66
+ *
67
+ * @param request - Payer address and pricing amount fields.
68
+ * @returns Balance comparison in mUSD base units (6 decimals).
69
+ */
70
+ checkMoneyAccountBalance(request: MoneyAccountBalanceCheckRequest): Promise<MoneyAccountBalanceCheckResult>;
71
+ /**
72
+ * Prepares a cash-subscription delegation and returns its hash.
73
+ *
74
+ * Reuses a stored AUS delegation that matches the semantic fingerprint when
75
+ * one exists (ensuring a CHOMP intent is active for its hash, unless
76
+ * `skipChompInteractions` is true). Reuse classifies period `startDate` as
77
+ * trial-deferred (`> now`) vs immediately redeemable, matching creation.
78
+ * If there is no match, builds, signs, optionally verifies with CHOMP,
79
+ * persists, and optionally registers a new delegation.
80
+ *
81
+ * When `skipChompInteractions` is true (required for alpha), CHOMP verify
82
+ * and intent calls are skipped; the returned hash is computed locally. The
83
+ * default CHOMP-enabled path requires a follow-up chomp-api-service release
84
+ * that accepts `'cash-subscription'` intent metadata.
85
+ *
86
+ * @param request - Authoritative pricing and payer details for the delegation.
87
+ * @returns The delegation hash (CHOMP-verified unless skipped) and whether it
88
+ * was created or reused.
89
+ */
90
+ prepareDelegation(request: PrepareSubscriptionDelegationRequest): Promise<PreparedSubscriptionDelegation>;
91
+ }
92
+ export {};
93
+ //# sourceMappingURL=SubscriptionDelegationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionDelegationService.d.ts","sourceRoot":"","sources":["../../src/subscription-delegation/SubscriptionDel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