@metamask-previews/subscription-controller 8.0.1-preview-abca9bcea → 8.0.1-preview-ec24abb79

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 (70) hide show
  1. package/CHANGELOG.md +0 -15
  2. package/dist/SubscriptionController-method-action-types.cjs.map +1 -1
  3. package/dist/SubscriptionController-method-action-types.d.cts +1 -12
  4. package/dist/SubscriptionController-method-action-types.d.cts.map +1 -1
  5. package/dist/SubscriptionController-method-action-types.d.mts +1 -12
  6. package/dist/SubscriptionController-method-action-types.d.mts.map +1 -1
  7. package/dist/SubscriptionController-method-action-types.mjs.map +1 -1
  8. package/dist/SubscriptionController.cjs +36 -136
  9. package/dist/SubscriptionController.cjs.map +1 -1
  10. package/dist/SubscriptionController.d.cts +4 -14
  11. package/dist/SubscriptionController.d.cts.map +1 -1
  12. package/dist/SubscriptionController.d.mts +4 -14
  13. package/dist/SubscriptionController.d.mts.map +1 -1
  14. package/dist/SubscriptionController.mjs +36 -140
  15. package/dist/SubscriptionController.mjs.map +1 -1
  16. package/dist/SubscriptionService-method-action-types.cjs.map +1 -1
  17. package/dist/SubscriptionService-method-action-types.d.cts +1 -10
  18. package/dist/SubscriptionService-method-action-types.d.cts.map +1 -1
  19. package/dist/SubscriptionService-method-action-types.d.mts +1 -10
  20. package/dist/SubscriptionService-method-action-types.d.mts.map +1 -1
  21. package/dist/SubscriptionService-method-action-types.mjs.map +1 -1
  22. package/dist/SubscriptionService-structs.cjs +1 -52
  23. package/dist/SubscriptionService-structs.cjs.map +1 -1
  24. package/dist/SubscriptionService-structs.d.cts +7 -175
  25. package/dist/SubscriptionService-structs.d.cts.map +1 -1
  26. package/dist/SubscriptionService-structs.d.mts +7 -175
  27. package/dist/SubscriptionService-structs.d.mts.map +1 -1
  28. package/dist/SubscriptionService-structs.mjs +1 -52
  29. package/dist/SubscriptionService-structs.mjs.map +1 -1
  30. package/dist/SubscriptionService.cjs +0 -20
  31. package/dist/SubscriptionService.cjs.map +1 -1
  32. package/dist/SubscriptionService.d.cts +1 -7
  33. package/dist/SubscriptionService.d.cts.map +1 -1
  34. package/dist/SubscriptionService.d.mts +1 -7
  35. package/dist/SubscriptionService.d.mts.map +1 -1
  36. package/dist/SubscriptionService.mjs +1 -21
  37. package/dist/SubscriptionService.mjs.map +1 -1
  38. package/dist/constants.cjs +0 -1
  39. package/dist/constants.cjs.map +1 -1
  40. package/dist/constants.d.cts +0 -1
  41. package/dist/constants.d.cts.map +1 -1
  42. package/dist/constants.d.mts +0 -1
  43. package/dist/constants.d.mts.map +1 -1
  44. package/dist/constants.mjs +0 -1
  45. package/dist/constants.mjs.map +1 -1
  46. package/dist/index.cjs +1 -7
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +4 -5
  49. package/dist/index.d.cts.map +1 -1
  50. package/dist/index.d.mts +4 -5
  51. package/dist/index.d.mts.map +1 -1
  52. package/dist/index.mjs +1 -2
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/types.cjs +1 -11
  55. package/dist/types.cjs.map +1 -1
  56. package/dist/types.d.cts +0 -71
  57. package/dist/types.d.cts.map +1 -1
  58. package/dist/types.d.mts +0 -71
  59. package/dist/types.d.mts.map +1 -1
  60. package/dist/types.mjs +0 -10
  61. package/dist/types.mjs.map +1 -1
  62. package/package.json +4 -5
  63. package/dist/selectors.cjs +0 -52
  64. package/dist/selectors.cjs.map +0 -1
  65. package/dist/selectors.d.cts +0 -38
  66. package/dist/selectors.d.cts.map +0 -1
  67. package/dist/selectors.d.mts +0 -38
  68. package/dist/selectors.d.mts.map +0 -1
  69. package/dist/selectors.mjs +0 -46
  70. package/dist/selectors.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAAA,kDAA8D;AAI9D;;;;;;;;;;;GAWG;AACH,SAAgB,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;AAXD,oDAWC;AAED;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CACpC,KAAkC,EAClC,WAAqB,EACrB,OAA+C;IAE/C,OAAO,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAND,wDAMC;AAED;;;;;;;;;GASG;AACH,SAAgB,wBAAwB,CACtC,KAAkC,EAClC,WAAwB;IAExB,OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,CAC7B,CAAC,YAAY,EAAE,EAAE,CACf,2CAA4B,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;AATD,4DASC","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,38 +0,0 @@
1
- import type { SubscriptionControllerState } from "./SubscriptionController.cjs";
2
- import type { ProductEntitlementFeatureMap, ProductType } from "./types.cjs";
3
- /**
4
- * Returns whether a specific product feature entitlement is enabled.
5
- *
6
- * Use this to gate paid UX. Missing products or missing features fail closed
7
- * (`false`). Combine with `selectIsActiveSubscriber` when that is the
8
- * product rule; this selector only reads the entitlement boolean.
9
- *
10
- * @param state - The subscription controller state.
11
- * @param productType - The product whose entitlement is queried.
12
- * @param feature - The feature whose entitlement flag is queried.
13
- * @returns Whether the feature entitlement is true.
14
- */
15
- export declare function selectHasEntitlement<TProduct extends ProductType>(state: SubscriptionControllerState, productType: TProduct, feature: ProductEntitlementFeatureMap[TProduct]): boolean;
16
- /**
17
- * Usage availability currently matches entitlement because the server folds
18
- * metered-cap exhaustion into the entitlement flag. Keeping this selector
19
- * separate gives consumers a stable API if explicit usage claims are added.
20
- *
21
- * @param state - The subscription controller state.
22
- * @param productType - The product whose usage availability is queried.
23
- * @param feature - The feature whose usage availability is queried.
24
- * @returns Whether usage is currently available for the feature.
25
- */
26
- export declare function selectIsUsageAvailable<TProduct extends ProductType>(state: SubscriptionControllerState, productType: TProduct, feature: ProductEntitlementFeatureMap[TProduct]): boolean;
27
- /**
28
- * Returns whether the user has an active subscription for a specific product.
29
- *
30
- * Active includes `active`, `trialing`, and `provisional`. Missing products
31
- * and non-active statuses fail closed (`false`).
32
- *
33
- * @param state - The subscription controller state.
34
- * @param productType - The product to check.
35
- * @returns Whether the user is an active subscriber for the product.
36
- */
37
- export declare function selectIsActiveSubscriber(state: SubscriptionControllerState, productType: ProductType): boolean;
38
- //# sourceMappingURL=selectors.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,qCAAoC;AAC/E,OAAO,KAAK,EAAE,4BAA4B,EAAE,WAAW,EAAE,oBAAmB;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,38 +0,0 @@
1
- import type { SubscriptionControllerState } from "./SubscriptionController.mjs";
2
- import type { ProductEntitlementFeatureMap, ProductType } from "./types.mjs";
3
- /**
4
- * Returns whether a specific product feature entitlement is enabled.
5
- *
6
- * Use this to gate paid UX. Missing products or missing features fail closed
7
- * (`false`). Combine with `selectIsActiveSubscriber` when that is the
8
- * product rule; this selector only reads the entitlement boolean.
9
- *
10
- * @param state - The subscription controller state.
11
- * @param productType - The product whose entitlement is queried.
12
- * @param feature - The feature whose entitlement flag is queried.
13
- * @returns Whether the feature entitlement is true.
14
- */
15
- export declare function selectHasEntitlement<TProduct extends ProductType>(state: SubscriptionControllerState, productType: TProduct, feature: ProductEntitlementFeatureMap[TProduct]): boolean;
16
- /**
17
- * Usage availability currently matches entitlement because the server folds
18
- * metered-cap exhaustion into the entitlement flag. Keeping this selector
19
- * separate gives consumers a stable API if explicit usage claims are added.
20
- *
21
- * @param state - The subscription controller state.
22
- * @param productType - The product whose usage availability is queried.
23
- * @param feature - The feature whose usage availability is queried.
24
- * @returns Whether usage is currently available for the feature.
25
- */
26
- export declare function selectIsUsageAvailable<TProduct extends ProductType>(state: SubscriptionControllerState, productType: TProduct, feature: ProductEntitlementFeatureMap[TProduct]): boolean;
27
- /**
28
- * Returns whether the user has an active subscription for a specific product.
29
- *
30
- * Active includes `active`, `trialing`, and `provisional`. Missing products
31
- * and non-active statuses fail closed (`false`).
32
- *
33
- * @param state - The subscription controller state.
34
- * @param productType - The product to check.
35
- * @returns Whether the user is an active subscriber for the product.
36
- */
37
- export declare function selectIsActiveSubscriber(state: SubscriptionControllerState, productType: ProductType): boolean;
38
- //# sourceMappingURL=selectors.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,qCAAoC;AAC/E,OAAO,KAAK,EAAE,4BAA4B,EAAE,WAAW,EAAE,oBAAmB;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,46 +0,0 @@
1
- import { ACTIVE_SUBSCRIPTION_STATUSES } from "./constants.mjs";
2
- /**
3
- * Returns whether a specific product feature entitlement is enabled.
4
- *
5
- * Use this to gate paid UX. Missing products or missing features fail closed
6
- * (`false`). Combine with `selectIsActiveSubscriber` when that is the
7
- * product rule; this selector only reads the entitlement boolean.
8
- *
9
- * @param state - The subscription controller state.
10
- * @param productType - The product whose entitlement is queried.
11
- * @param feature - The feature whose entitlement flag is queried.
12
- * @returns Whether the feature entitlement is true.
13
- */
14
- export function selectHasEntitlement(state, productType, feature) {
15
- const entitlements = state.productEntitlements?.[productType]
16
- ?.entitlements;
17
- return Boolean(entitlements?.[feature]);
18
- }
19
- /**
20
- * Usage availability currently matches entitlement because the server folds
21
- * metered-cap exhaustion into the entitlement flag. Keeping this selector
22
- * separate gives consumers a stable API if explicit usage claims are added.
23
- *
24
- * @param state - The subscription controller state.
25
- * @param productType - The product whose usage availability is queried.
26
- * @param feature - The feature whose usage availability is queried.
27
- * @returns Whether usage is currently available for the feature.
28
- */
29
- export function selectIsUsageAvailable(state, productType, feature) {
30
- return selectHasEntitlement(state, productType, feature);
31
- }
32
- /**
33
- * Returns whether the user has an active subscription for a specific product.
34
- *
35
- * Active includes `active`, `trialing`, and `provisional`. Missing products
36
- * and non-active statuses fail closed (`false`).
37
- *
38
- * @param state - The subscription controller state.
39
- * @param productType - The product to check.
40
- * @returns Whether the user is an active subscriber for the product.
41
- */
42
- export function selectIsActiveSubscriber(state, productType) {
43
- return state.subscriptions.some((subscription) => ACTIVE_SUBSCRIPTION_STATUSES.includes(subscription.status) &&
44
- subscription.products.some((product) => product.name === productType));
45
- }
46
- //# sourceMappingURL=selectors.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,wBAAuB;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"]}