@amazon-devices/kepler-subscription-entitlement 1.1.11
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/LICENSE +7 -0
- package/SystemBundles/8bf43b68350737ba24fec64c0efb1c0820f31974fe80c33fc3160445c3efc792.bundle.map +1 -0
- package/SystemBundles/hermes-072/8bf43b68350737ba24fec64c0efb1c0820f31974fe80c33fc3160445c3efc792.bundle.map +1 -0
- package/SystemBundles/hermes-072/index.amzn__kepler-subscription-entitlement-1.hermes.bundle +0 -0
- package/SystemBundles/hermes-083/8bf43b68350737ba24fec64c0efb1c0820f31974fe80c33fc3160445c3efc792.bundle.map +1 -0
- package/SystemBundles/hermes-083/index.amzn__kepler-subscription-entitlement-1.hermes.bundle +0 -0
- package/SystemBundles/index.amzn__kepler-subscription-entitlement-1.hermes.bundle +0 -0
- package/SystemModules/amzn__kepler-subscription-entitlement-1.modules.txt +7 -0
- package/SystemModules/amzn__kepler-subscription-entitlement-1.private.modules.txt +20 -0
- package/SystemModules/keplerscript-system-bundle-config.json +7 -0
- package/THIRD_PARTY_NOTICES.txt +12469 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -0
- package/dist/kepler/tm-manifest.json +1 -0
- package/dist/turbo-modules/AmazonNativeSubscriptionEntitlement.d.ts +18 -0
- package/dist/turbo-modules/AmazonNativeSubscriptionEntitlement.js +12 -0
- package/dist/turbo-modules/Handlers.d.ts +33 -0
- package/dist/turbo-modules/Handlers.js +8 -0
- package/dist/turbo-modules/PrivateHandlers.d.ts +28 -0
- package/dist/turbo-modules/PrivateHandlers.js +38 -0
- package/dist/turbo-modules/SubscriptionEntitlementServer.d.ts +125 -0
- package/dist/turbo-modules/SubscriptionEntitlementServer.js +43 -0
- package/dist/turbo-modules/__mocks__/AmazonNativeSubscriptionEntitlement.d.ts +7 -0
- package/dist/turbo-modules/__mocks__/AmazonNativeSubscriptionEntitlement.js +8 -0
- package/dist/turbo-modules/models/Errors.d.ts +8 -0
- package/dist/turbo-modules/models/Errors.js +21 -0
- package/dist/turbo-modules/models/SubscriptionEntitlementEntry.d.ts +90 -0
- package/dist/turbo-modules/models/SubscriptionEntitlementEntry.js +112 -0
- package/kepler-compatibility.json +15 -0
- package/kepler-transformed-package-info.json +3 -0
- package/package.json +1 -0
- package/react-native.config.js +19 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.SubscriptionEntitlementServer = void 0;
|
|
21
|
+
__exportStar(require("./turbo-modules/models/Errors"), exports);
|
|
22
|
+
__exportStar(require("./turbo-modules/models/SubscriptionEntitlementEntry"), exports);
|
|
23
|
+
__exportStar(require("./turbo-modules/Handlers"), exports);
|
|
24
|
+
var SubscriptionEntitlementServer_1 = require("./turbo-modules/SubscriptionEntitlementServer");
|
|
25
|
+
Object.defineProperty(exports, "SubscriptionEntitlementServer", { enumerable: true, get: function () { return __importDefault(SubscriptionEntitlementServer_1).default; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"schema":1,"fileSets":{"native":[{"arch":"aarch64","variant":"release","directoryPath":"aarch64-release"},{"arch":"armv7","variant":"release","directoryPath":"armv7-release"},{"arch":"x86_64","variant":"release","directoryPath":"x86_64-release"},{"arch":"aarch64","variant":"debug","directoryPath":"aarch64-debug"},{"arch":"armv7","variant":"debug","directoryPath":"armv7-debug"},{"arch":"x86_64","variant":"debug","directoryPath":"x86_64-debug"}]}}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { KeplerTurboModule } from '@amazon-devices/keplerscript-turbomodule-api';
|
|
2
|
+
import { IComponentInstance } from '@amazon-devices/react-native-kepler';
|
|
3
|
+
import { ISubscriptionEntitlementEntry } from './models/SubscriptionEntitlementEntry';
|
|
4
|
+
import { IPrivateSubscriptionEntitlementsHandler } from './PrivateHandlers';
|
|
5
|
+
export interface AmazonNativeSubscriptionEntitlement extends KeplerTurboModule {
|
|
6
|
+
getMajorVersion: () => number;
|
|
7
|
+
getMinorVersion: () => number;
|
|
8
|
+
getPatchVersion: () => number;
|
|
9
|
+
setSubscriptionEntitlementsHandlerForComponent: (getAllSubscriptionEntitlementsCallback: IPrivateSubscriptionEntitlementsHandler['getAllSubscriptionEntitlements'], component: IComponentInstance) => void;
|
|
10
|
+
reportNewSubscription: (subscription: ISubscriptionEntitlementEntry) => void;
|
|
11
|
+
reportRemovedSubscription: (subscription: ISubscriptionEntitlementEntry) => void;
|
|
12
|
+
reportRefreshedSubscriptions: () => void;
|
|
13
|
+
addSubscriptionEntitlementChunk: (subscriptions: ISubscriptionEntitlementEntry[], providerId: number) => void;
|
|
14
|
+
subscriptionEntitlementsProviderCommit: (providerId: number) => void;
|
|
15
|
+
setSubscriptions: (subscriptions: ISubscriptionEntitlementEntry[]) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: AmazonNativeSubscriptionEntitlement;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023 - 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//@ts-ignore
|
|
10
|
+
const keplerscript_turbomodule_api_1 = require("@amazon-devices/keplerscript-turbomodule-api");
|
|
11
|
+
// tslint:disable-next-line
|
|
12
|
+
exports.default = keplerscript_turbomodule_api_1.TurboModuleRegistry.getEnforcing('AmazonNativeSubscriptionEntitlement');
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ISubscriptionEntitlementEntry } from './models/SubscriptionEntitlementEntry';
|
|
2
|
+
/**
|
|
3
|
+
* Interface that content provider applications implement to handle commands from Amazon's subscription entitlement service to fetch subscription data.
|
|
4
|
+
*/
|
|
5
|
+
export interface ISubscriptionEntitlementsHandler {
|
|
6
|
+
/**
|
|
7
|
+
* Handles the `GetAllSubscriptionEntitlements` command.
|
|
8
|
+
* `GetAllSubscriptionEntitlements` commands request that the complete list of subscriptions be sent in response.
|
|
9
|
+
* Implementation of this API can use the `ISubscriptionEntitlementsProvider.addSubscriptionEntitlementChunk(...)` method to provide subscription data in chunks.
|
|
10
|
+
* When `ISubscriptionEntitlementsProvider.commit()` is invoked, all of the provided subscription data will be committed to Amazon's subscription entitlement cloud service.
|
|
11
|
+
*
|
|
12
|
+
* @param {ISubscriptionEntitlementsProvider} subscriptionEntitlementsProvider - A `ISubscriptionEntitlementsProvider` object to send responses.
|
|
13
|
+
*/
|
|
14
|
+
getAllSubscriptionEntitlements(subscriptionEntitlementsProvider: ISubscriptionEntitlementsProvider): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Used to provide responses to commands requesting subscription data.
|
|
18
|
+
*/
|
|
19
|
+
export interface ISubscriptionEntitlementsProvider {
|
|
20
|
+
/**
|
|
21
|
+
* Adds subscription data to the response.
|
|
22
|
+
* Use repeated calls to `addSubscriptionEntitlementChunk` to paginate data to to prevent loading large lists into memory.
|
|
23
|
+
* Must eventually be followed by a call to `commit()` after all entitlements have been sent.
|
|
24
|
+
*
|
|
25
|
+
* @param {ISubscriptionEntitlementEntry[]} subscriptions - A list of subscriptions.
|
|
26
|
+
*/
|
|
27
|
+
addSubscriptionEntitlementChunk(subscriptions: ISubscriptionEntitlementEntry[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Indicates the end of responses.
|
|
30
|
+
* Must be called after the final call of `addSubscriptionEntitlementChunk`.
|
|
31
|
+
*/
|
|
32
|
+
commit(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ISubscriptionEntitlementsProvider } from './Handlers';
|
|
2
|
+
import { ISubscriptionEntitlementEntry } from './models/SubscriptionEntitlementEntry';
|
|
3
|
+
/**
|
|
4
|
+
* JS SubscriptionEntitlementsProvider class exist for short term work around while TM APIs do not have support
|
|
5
|
+
* for passing in nativeObjects from native side of TM into JS callback. Eventually will not need JS implementation
|
|
6
|
+
* of ISubscriptionEntitlementsProvider since a reference to a native SubscriptionEntitlementsProvider will be provided instead.
|
|
7
|
+
*
|
|
8
|
+
* Each new JS SubscriptionEntitlementsProvider has a providerId that is given from native side for TM that maps this
|
|
9
|
+
* JS SubscriptionEntitlementsProvider to a native SubscriptionEntitlementsProvider.
|
|
10
|
+
* JS SubscriptionEntitlementsProvideruses uses TM to pass calls through to the associated native SubscriptionEntitlementsProvider.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SubscriptionEntitlementsProvider implements ISubscriptionEntitlementsProvider {
|
|
13
|
+
providerId: number;
|
|
14
|
+
constructor(providerId: number);
|
|
15
|
+
addSubscriptionEntitlementChunk(subscriptions: ISubscriptionEntitlementEntry[]): void;
|
|
16
|
+
commit(): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Private ISubscriptionEntitlementsHandler exist for short term work around while TM APIs do not have support
|
|
20
|
+
* for passing in nativeObjects from native side of TM into JS callback.
|
|
21
|
+
*
|
|
22
|
+
* IPrivateSubscriptionEntitlementsHandler interface matches the ISubscriptionEntitlementsHandler interface but with
|
|
23
|
+
* the key difference that methods in the private handler do not take a ISubscriptionEntitlementsProvider as a parameter and
|
|
24
|
+
* it takes in a providerId to create the JS SubscriptionEntitlementsProvider with.
|
|
25
|
+
*/
|
|
26
|
+
export interface IPrivateSubscriptionEntitlementsHandler {
|
|
27
|
+
getAllSubscriptionEntitlements(providerId: number): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SubscriptionEntitlementsProvider = void 0;
|
|
13
|
+
const AmazonNativeSubscriptionEntitlement_1 = __importDefault(require("./AmazonNativeSubscriptionEntitlement"));
|
|
14
|
+
if (!AmazonNativeSubscriptionEntitlement_1.default) {
|
|
15
|
+
throw new Error('AmazonNativeSubscriptionEntitlement is null.');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* JS SubscriptionEntitlementsProvider class exist for short term work around while TM APIs do not have support
|
|
19
|
+
* for passing in nativeObjects from native side of TM into JS callback. Eventually will not need JS implementation
|
|
20
|
+
* of ISubscriptionEntitlementsProvider since a reference to a native SubscriptionEntitlementsProvider will be provided instead.
|
|
21
|
+
*
|
|
22
|
+
* Each new JS SubscriptionEntitlementsProvider has a providerId that is given from native side for TM that maps this
|
|
23
|
+
* JS SubscriptionEntitlementsProvider to a native SubscriptionEntitlementsProvider.
|
|
24
|
+
* JS SubscriptionEntitlementsProvideruses uses TM to pass calls through to the associated native SubscriptionEntitlementsProvider.
|
|
25
|
+
*/
|
|
26
|
+
class SubscriptionEntitlementsProvider {
|
|
27
|
+
providerId;
|
|
28
|
+
constructor(providerId) {
|
|
29
|
+
this.providerId = providerId;
|
|
30
|
+
}
|
|
31
|
+
addSubscriptionEntitlementChunk(subscriptions) {
|
|
32
|
+
AmazonNativeSubscriptionEntitlement_1.default.addSubscriptionEntitlementChunk(subscriptions, this.providerId);
|
|
33
|
+
}
|
|
34
|
+
commit() {
|
|
35
|
+
AmazonNativeSubscriptionEntitlement_1.default.subscriptionEntitlementsProviderCommit(this.providerId);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.SubscriptionEntitlementsProvider = SubscriptionEntitlementsProvider;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { IComponentInstance } from '@amazon-devices/react-native-kepler';
|
|
2
|
+
import { ISubscriptionEntitlementEntry } from './models/SubscriptionEntitlementEntry';
|
|
3
|
+
import { ISubscriptionEntitlementsHandler } from './Handlers';
|
|
4
|
+
/**
|
|
5
|
+
* Interface for Subscription Entitlement Server
|
|
6
|
+
*/
|
|
7
|
+
export interface ISubscriptionEntitlementServer {
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated This method is deprecated, please use {@link setSubscriptionEntitlementsHandlerForComponent} instead.
|
|
10
|
+
*/
|
|
11
|
+
setSubscriptionEntitlementsHandler(subscriptionEntitlementsHandler: ISubscriptionEntitlementsHandler): void;
|
|
12
|
+
/**
|
|
13
|
+
* Sets the handler for specific component that will provide subscription entitlement data in response to commands.
|
|
14
|
+
*
|
|
15
|
+
* @param {ISubscriptionEntitlementsHandler} subscriptionEntitlementsHandler - The handler for commands relating to subscription entitlement.
|
|
16
|
+
* @param {IComponentInstance} component - The component instance for which the handler is being set.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import {
|
|
21
|
+
* ISubscriptionEntitlementsHandler,
|
|
22
|
+
* ISubscriptionEntitlementsProvider,
|
|
23
|
+
* SubscriptionEntitlementServer,
|
|
24
|
+
* ...
|
|
25
|
+
* } from "@amazon-devices/kepler-subscription-entitlement";
|
|
26
|
+
*
|
|
27
|
+
* ...
|
|
28
|
+
*
|
|
29
|
+
* // Handler
|
|
30
|
+
* const subscriptionEntitlementHandler: ISubscriptionEntitlementsHandler = {
|
|
31
|
+
* getAllSubscriptionEntitlements: (
|
|
32
|
+
* subscriptionEntitlementsProvider: ISubscriptionEntitlementsProvider,
|
|
33
|
+
* ) => {
|
|
34
|
+
* subscriptionEntitlementsProvider.addSubscriptionEntitlementChunk(<ADD ENTITLEMENTS>));
|
|
35
|
+
* subscriptionEntitlementsProvider.commit();
|
|
36
|
+
* },
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* ...
|
|
40
|
+
*
|
|
41
|
+
* // Headless service
|
|
42
|
+
* onStart(componentInstance: IComponentInstance): Promise<void> {
|
|
43
|
+
* SubscriptionEntitlementServer.setSubscriptionEntitlementsHandlerForComponent(
|
|
44
|
+
* subscriptionEntitlementHandler,
|
|
45
|
+
* componentInstance
|
|
46
|
+
* );
|
|
47
|
+
*
|
|
48
|
+
* // Set other handlers here, in ex. for `ContentPersonalizationServer`
|
|
49
|
+
* ...
|
|
50
|
+
*
|
|
51
|
+
* return Promise.resolve();
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
setSubscriptionEntitlementsHandlerForComponent(subscriptionEntitlementsHandler: ISubscriptionEntitlementsHandler, component: IComponentInstance): void;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated This method is deprecated, please use {@link setSubscriptions} instead.
|
|
58
|
+
*
|
|
59
|
+
* Reports that the customer has a new subscription inserted into their existing subscription list.
|
|
60
|
+
* Only for subscriptions inserted due to on-device customer action. Should be reported at time of insertion.
|
|
61
|
+
*
|
|
62
|
+
* @param {ISubscriptionEntitlementEntry} subscription - The new subscription.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const subscriptionEntry: ISubscriptionEntitlementEntry = new SubscriptionEntitlementEntryBuilder()
|
|
67
|
+
* .acquisitionTimestamp(new Date())
|
|
68
|
+
* .expirationTimestamp(new Date())
|
|
69
|
+
* .subscriptionId('subscriptionId')
|
|
70
|
+
* .build();
|
|
71
|
+
*
|
|
72
|
+
* // Send the event
|
|
73
|
+
* SubscriptionEntitlementServer.reportNewSubscription(subscriptionEntry);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
reportNewSubscription(subscription: ISubscriptionEntitlementEntry): void;
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated This method is deprecated, please use {@link setSubscriptions} instead.
|
|
79
|
+
*
|
|
80
|
+
* Reports that the customer no longer has a subscription in their existing subscription list.
|
|
81
|
+
* Only for subscriptions that are no longer valid or expire due to on-device action. Should be reported at time of removal.
|
|
82
|
+
*
|
|
83
|
+
* @param {ISubscriptionEntitlementEntry} subscription - The removed subscription.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const subscriptionEntry: ISubscriptionEntitlementEntry = new SubscriptionEntitlementEntryBuilder()
|
|
88
|
+
* .acquisitionTimestamp(new Date())
|
|
89
|
+
* .expirationTimestamp(new Date())
|
|
90
|
+
* .subscriptionId('subscriptionId')
|
|
91
|
+
* .build();
|
|
92
|
+
*
|
|
93
|
+
* // Send the event
|
|
94
|
+
* SubscriptionEntitlementServer.reportRemovedSubscription(subscriptionEntry);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
reportRemovedSubscription(subscription: ISubscriptionEntitlementEntry): void;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the list of subscriptions that the customer has.
|
|
100
|
+
*
|
|
101
|
+
* @param {ISubscriptionEntitlementEntry[]} subscriptions - The list of subscriptions.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* const subscriptionEntry: ISubscriptionEntitlementEntry = new SubscriptionEntitlementEntryBuilder()
|
|
106
|
+
* .acquisitionTimestamp(new Date())
|
|
107
|
+
* .expirationTimestamp(new Date())
|
|
108
|
+
* .subscriptionId('subscriptionId')
|
|
109
|
+
* .build();
|
|
110
|
+
*
|
|
111
|
+
* // Send the event
|
|
112
|
+
* SubscriptionEntitlementServer.setSubscriptions([subscriptionEntry]);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
setSubscriptions(subscriptions: ISubscriptionEntitlementEntry[]): void;
|
|
116
|
+
/**
|
|
117
|
+
* Indicates that there have been changes to the subscription entitlement due to off-device actions
|
|
118
|
+
* and a new refreshed list of subscriptions should be fetched.
|
|
119
|
+
*
|
|
120
|
+
* Before using this API, {@link setSubscriptionEntitlementsHandlerForComponent} needs to be called.
|
|
121
|
+
*/
|
|
122
|
+
reportRefreshedSubscriptions(): void;
|
|
123
|
+
}
|
|
124
|
+
declare const _default: ISubscriptionEntitlementServer;
|
|
125
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023 - 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const AmazonNativeSubscriptionEntitlement_1 = __importDefault(require("./AmazonNativeSubscriptionEntitlement"));
|
|
13
|
+
const PrivateHandlers_1 = require("./PrivateHandlers");
|
|
14
|
+
if (!AmazonNativeSubscriptionEntitlement_1.default) {
|
|
15
|
+
throw new Error('SubscriptionEntitlementTurboModule is null.');
|
|
16
|
+
}
|
|
17
|
+
class SubscriptionEntitlementServer {
|
|
18
|
+
setSubscriptionEntitlementsHandler(_subscriptionEntitlementsHandler) {
|
|
19
|
+
console.error('This method is deprecated, please use setSubscriptionEntitlementsHandlerForComponent instead.');
|
|
20
|
+
}
|
|
21
|
+
setSubscriptionEntitlementsHandlerForComponent(subscriptionEntitlementsHandler, component) {
|
|
22
|
+
let privateGetAllSubscriptionEntitlementsCallback = (providerId) => {
|
|
23
|
+
let provider = new PrivateHandlers_1.SubscriptionEntitlementsProvider(providerId);
|
|
24
|
+
subscriptionEntitlementsHandler.getAllSubscriptionEntitlements(provider);
|
|
25
|
+
};
|
|
26
|
+
AmazonNativeSubscriptionEntitlement_1.default.setSubscriptionEntitlementsHandlerForComponent(privateGetAllSubscriptionEntitlementsCallback, component);
|
|
27
|
+
}
|
|
28
|
+
reportNewSubscription(subscription) {
|
|
29
|
+
console.warn('This method is deprecated, please use setSubscriptions instead.');
|
|
30
|
+
AmazonNativeSubscriptionEntitlement_1.default.reportNewSubscription(subscription);
|
|
31
|
+
}
|
|
32
|
+
reportRemovedSubscription(subscription) {
|
|
33
|
+
console.warn('This method is deprecated, please use setSubscriptions instead.');
|
|
34
|
+
AmazonNativeSubscriptionEntitlement_1.default.reportRemovedSubscription(subscription);
|
|
35
|
+
}
|
|
36
|
+
reportRefreshedSubscriptions() {
|
|
37
|
+
AmazonNativeSubscriptionEntitlement_1.default.reportRefreshedSubscriptions();
|
|
38
|
+
}
|
|
39
|
+
setSubscriptions(subscriptions) {
|
|
40
|
+
AmazonNativeSubscriptionEntitlement_1.default.setSubscriptions(subscriptions);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = new SubscriptionEntitlementServer();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.InvalidArgumentError = exports.BaseError = void 0;
|
|
10
|
+
class BaseError extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.BaseError = BaseError;
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when invalid argument is passed to method.
|
|
18
|
+
*/
|
|
19
|
+
class InvalidArgumentError extends BaseError {
|
|
20
|
+
}
|
|
21
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing a customer's entitlement to a subscription in the Amazon catalog. Create using `SubscriptionEntitlementEntryBuilder`.
|
|
3
|
+
*/
|
|
4
|
+
export interface ISubscriptionEntitlementEntry {
|
|
5
|
+
/**
|
|
6
|
+
* Gets the date when the subscription was acquired by the customer.
|
|
7
|
+
*
|
|
8
|
+
* @returns {Date | undefined} Acquisition date. Undefined if not set.
|
|
9
|
+
*/
|
|
10
|
+
get acquisitionTimestamp(): Date | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Gets the date of when the subscription expires for the customer.
|
|
13
|
+
*
|
|
14
|
+
* @returns {Date | undefined} Expiration date. Undefined if not set.
|
|
15
|
+
*/
|
|
16
|
+
get expirationTimestamp(): Date | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the `subscriptionId`, as specified in the Amazon catalog integration the customer is entitled to.
|
|
19
|
+
*
|
|
20
|
+
* @returns {string} `SubscriptionId` as specified in Amazon catalog integration.
|
|
21
|
+
*/
|
|
22
|
+
get subscriptionId(): string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Class representing a customer's entitlement to a subscription in the Amazon catalog. Created using `SubscriptionEntitlementEntryBuilder`.
|
|
26
|
+
*/
|
|
27
|
+
declare class SubscriptionEntitlementEntry implements ISubscriptionEntitlementEntry {
|
|
28
|
+
private readonly _acquisitionTimestampMs?;
|
|
29
|
+
private readonly _expirationTimestampMs?;
|
|
30
|
+
private readonly _subscriptionId;
|
|
31
|
+
constructor(subscriptionId: string, acquisitionTimestamp?: Date, expirationTimestamp?: Date);
|
|
32
|
+
/**
|
|
33
|
+
* Gets the date when the subscription was acquired by the customer.
|
|
34
|
+
*
|
|
35
|
+
* @returns {Date | undefined} Acquisition date. Undefined if not set.
|
|
36
|
+
*/
|
|
37
|
+
get acquisitionTimestamp(): Date | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the date of when the subscription expires for the customer.
|
|
40
|
+
*
|
|
41
|
+
* @returns {Date | undefined} Expiration date. Undefined if not set.
|
|
42
|
+
*/
|
|
43
|
+
get expirationTimestamp(): Date | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the `subscriptionId`, as specified in the Amazon catalog integration the customer is entitled to.
|
|
46
|
+
*
|
|
47
|
+
* @returns {string} `SubscriptionId` as specified in Amazon catalog integration.
|
|
48
|
+
*/
|
|
49
|
+
get subscriptionId(): string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Builder to create a `SubscriptionEntitlementEntry` object.
|
|
53
|
+
*/
|
|
54
|
+
export declare class SubscriptionEntitlementEntryBuilder {
|
|
55
|
+
private mAcquisitionTimestamp?;
|
|
56
|
+
private mExpirationTimestamp?;
|
|
57
|
+
private mSubscriptionId?;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the date when the subscription was acquired by the customer.
|
|
60
|
+
*
|
|
61
|
+
* @param {Date} acquisitionTimestamp - Acquisition date.
|
|
62
|
+
* @returns {SubscriptionEntitlementEntryBuilder} The current `SubscriptionEntitlementEntryBuilder` object.
|
|
63
|
+
*/
|
|
64
|
+
acquisitionTimestamp(acquisitionTimestamp: Date): SubscriptionEntitlementEntryBuilder;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the date of when the subscription expires for the customer.
|
|
67
|
+
* Note that this field should NOT be set for auto-recurring subscriptions.
|
|
68
|
+
* Only set this if the subscription is going to expire unless the customer takes action.
|
|
69
|
+
*
|
|
70
|
+
* @param {Date} expirationTimestamp - Expiration date.
|
|
71
|
+
* @returns {SubscriptionEntitlementEntryBuilder} The current `SubscriptionEntitlementEntryBuilder` object.
|
|
72
|
+
*/
|
|
73
|
+
expirationTimestamp(expirationTimestamp: Date): SubscriptionEntitlementEntryBuilder;
|
|
74
|
+
/**
|
|
75
|
+
* Sets the `subscriptionId`, as specified in Amazon catalog integration the customer is entitled to.
|
|
76
|
+
* This is a required field. `build()` will fail if this field is not set.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} subscriptionId - SubscriptionId as specified in Amazon catalog integration.
|
|
79
|
+
* @returns {SubscriptionEntitlementEntryBuilder} The current `SubscriptionEntitlementEntryBuilder` object.
|
|
80
|
+
*/
|
|
81
|
+
subscriptionId(subscriptionId: string): SubscriptionEntitlementEntryBuilder;
|
|
82
|
+
/**
|
|
83
|
+
* Builds a `SubscriptionEntitlementEntry` object with the fields set on the builder.
|
|
84
|
+
*
|
|
85
|
+
* @throws {InvalidArgumentError} if required fields are not set.
|
|
86
|
+
* @returns {SubscriptionEntitlementEntry} The `SubscriptionEntitlementEntry` object created.
|
|
87
|
+
*/
|
|
88
|
+
build(): SubscriptionEntitlementEntry;
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SubscriptionEntitlementEntryBuilder = void 0;
|
|
10
|
+
const Errors_1 = require("./Errors");
|
|
11
|
+
/**
|
|
12
|
+
* Class representing a customer's entitlement to a subscription in the Amazon catalog. Created using `SubscriptionEntitlementEntryBuilder`.
|
|
13
|
+
*/
|
|
14
|
+
class SubscriptionEntitlementEntry {
|
|
15
|
+
_acquisitionTimestampMs;
|
|
16
|
+
_expirationTimestampMs;
|
|
17
|
+
_subscriptionId;
|
|
18
|
+
constructor(subscriptionId, acquisitionTimestamp, expirationTimestamp) {
|
|
19
|
+
if (acquisitionTimestamp) {
|
|
20
|
+
this._acquisitionTimestampMs = acquisitionTimestamp.getTime();
|
|
21
|
+
}
|
|
22
|
+
if (expirationTimestamp) {
|
|
23
|
+
this._expirationTimestampMs = expirationTimestamp.getTime();
|
|
24
|
+
}
|
|
25
|
+
this._subscriptionId = subscriptionId;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets the date when the subscription was acquired by the customer.
|
|
29
|
+
*
|
|
30
|
+
* @returns {Date | undefined} Acquisition date. Undefined if not set.
|
|
31
|
+
*/
|
|
32
|
+
get acquisitionTimestamp() {
|
|
33
|
+
if (this._acquisitionTimestampMs) {
|
|
34
|
+
return new Date(this._acquisitionTimestampMs);
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets the date of when the subscription expires for the customer.
|
|
40
|
+
*
|
|
41
|
+
* @returns {Date | undefined} Expiration date. Undefined if not set.
|
|
42
|
+
*/
|
|
43
|
+
get expirationTimestamp() {
|
|
44
|
+
if (this._expirationTimestampMs) {
|
|
45
|
+
return new Date(this._expirationTimestampMs);
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the `subscriptionId`, as specified in the Amazon catalog integration the customer is entitled to.
|
|
51
|
+
*
|
|
52
|
+
* @returns {string} `SubscriptionId` as specified in Amazon catalog integration.
|
|
53
|
+
*/
|
|
54
|
+
get subscriptionId() {
|
|
55
|
+
return this._subscriptionId; //non-null assertion is safe due to check in builder for required field
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Builder to create a `SubscriptionEntitlementEntry` object.
|
|
60
|
+
*/
|
|
61
|
+
class SubscriptionEntitlementEntryBuilder {
|
|
62
|
+
mAcquisitionTimestamp;
|
|
63
|
+
mExpirationTimestamp;
|
|
64
|
+
mSubscriptionId;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the date when the subscription was acquired by the customer.
|
|
67
|
+
*
|
|
68
|
+
* @param {Date} acquisitionTimestamp - Acquisition date.
|
|
69
|
+
* @returns {SubscriptionEntitlementEntryBuilder} The current `SubscriptionEntitlementEntryBuilder` object.
|
|
70
|
+
*/
|
|
71
|
+
acquisitionTimestamp(acquisitionTimestamp) {
|
|
72
|
+
this.mAcquisitionTimestamp = acquisitionTimestamp;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Sets the date of when the subscription expires for the customer.
|
|
77
|
+
* Note that this field should NOT be set for auto-recurring subscriptions.
|
|
78
|
+
* Only set this if the subscription is going to expire unless the customer takes action.
|
|
79
|
+
*
|
|
80
|
+
* @param {Date} expirationTimestamp - Expiration date.
|
|
81
|
+
* @returns {SubscriptionEntitlementEntryBuilder} The current `SubscriptionEntitlementEntryBuilder` object.
|
|
82
|
+
*/
|
|
83
|
+
expirationTimestamp(expirationTimestamp) {
|
|
84
|
+
this.mExpirationTimestamp = expirationTimestamp;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sets the `subscriptionId`, as specified in Amazon catalog integration the customer is entitled to.
|
|
89
|
+
* This is a required field. `build()` will fail if this field is not set.
|
|
90
|
+
*
|
|
91
|
+
* @param {string} subscriptionId - SubscriptionId as specified in Amazon catalog integration.
|
|
92
|
+
* @returns {SubscriptionEntitlementEntryBuilder} The current `SubscriptionEntitlementEntryBuilder` object.
|
|
93
|
+
*/
|
|
94
|
+
subscriptionId(subscriptionId) {
|
|
95
|
+
this.mSubscriptionId = subscriptionId;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Builds a `SubscriptionEntitlementEntry` object with the fields set on the builder.
|
|
100
|
+
*
|
|
101
|
+
* @throws {InvalidArgumentError} if required fields are not set.
|
|
102
|
+
* @returns {SubscriptionEntitlementEntry} The `SubscriptionEntitlementEntry` object created.
|
|
103
|
+
*/
|
|
104
|
+
build() {
|
|
105
|
+
if (!this.mSubscriptionId) {
|
|
106
|
+
throw new Errors_1.InvalidArgumentError('InvalidArgumentError - subscriptionId is undefined');
|
|
107
|
+
}
|
|
108
|
+
const subscriptionEntitlementEntry = new SubscriptionEntitlementEntry(this.mSubscriptionId, this.mAcquisitionTimestamp, this.mExpirationTimestamp);
|
|
109
|
+
return subscriptionEntitlementEntry;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.SubscriptionEntitlementEntryBuilder = SubscriptionEntitlementEntryBuilder;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"versions": {
|
|
3
|
+
"1.1.1": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
4
|
+
"1.1.2": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
5
|
+
"1.1.3": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
6
|
+
"1.1.4": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
7
|
+
"1.1.5": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
8
|
+
"1.1.6": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
9
|
+
"1.1.7": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
10
|
+
"1.1.8": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
11
|
+
"1.1.9": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
12
|
+
"1.1.10": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1",
|
|
13
|
+
"1.1.11": "/com.amazon.kepler.kepler_subscription_entitlement_1@IKeplerSubscriptionEntitlement_1"
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "@amazon-devices/kepler-subscription-entitlement", "version": "1.1.11", "main": "dist/index.js", "types": "dist/index.d.ts", "files": ["dist", "react-native.config.js", "kepler-compatibility.json", "SystemModules", "SystemBundles", "THIRD_PARTY_NOTICES.txt", "kepler-transformed-package-info.json"], "scripts": {"clean": "rm -rf bundle kepler-build assets dist", "test:snapshot": "jest --colors --updateSnapshot", "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest --colors", "lint": "eslint --fix src --ext .ts,.tsx && eslint --fix tst --ext .ts,.tsx", "compile": "tsc -p tsconfig-build.json", "build": "npm-run-all version:validate lint test compile", "build-system-bundle": "KEPLER_NPM_COMMAND=npm-pretty-much react-native build-system-bundle-kepler", "check-dbg-syms": "$(brazil-path '[DebugSourceReferenceCheck]pkg.bin')/check_dbg_syms -b build -s kepler ", "prepublishOnly": "npm-run-all check-dbg-syms build-system-bundle", "version:major": "node scripts/version-bump.js major", "version:minor": "node scripts/version-bump.js minor", "version:patch": "node scripts/version-bump.js patch", "version:dry-run-major": "node scripts/version-bump.js major --dry-run", "version:dry-run-minor": "node scripts/version-bump.js minor --dry-run", "version:dry-run-patch": "node scripts/version-bump.js patch --dry-run", "version:validate": "node scripts/validate-versions.js"}, "dependencies": {"@amazon-devices/keplerscript-turbomodule-api": "^1.0.0"}, "peerDependencies": {"@amazon-devices/react-native-kepler": "*", "react-native": "*", "react": "*"}, "devDependencies": {"@babel/core": "^7.12.9", "@react-native-community/eslint-config": "^3.0.1", "@types/jest": "*", "@types/react-native": "*", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "*", "eslint": "*", "jest": "*", "npm-run-all": "*", "prettier": "^2.6.2", "react-native": "*", "ts-jest": "*", "typescript": "^4.5.5", "depcheck": "*", "@babel/plugin-proposal-private-property-in-object": "*", "@amazon-devices/kepler-cli-platform": "^0", "@react-native-community/cli": "^11.2.0"}, "kepler": {"projectType": "turbomodule", "toolchain": "clang", "os": ["vega"], "targets": ["4kmax_g1_vega", "sim_tv_x86_64", "sim_tv_aarch64"], "api": 0.1, "keplerInitializationSharedLibrary": "AmazonSubscriptionEntitlementLib"}, "eslintConfig": {"extends": "@react-native-community", "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint"], "root": true}, "prettier": {"arrowParens": "avoid", "bracketSameLine": true, "bracketSpacing": false, "singleQuote": true, "trailingComma": "all"}, "license": "See license in LICENSE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dependency: {
|
|
3
|
+
platforms: {
|
|
4
|
+
kepler: {
|
|
5
|
+
autolink : {
|
|
6
|
+
"AmazonSubscriptionEntitlementLib" : {
|
|
7
|
+
"libraryName": "libkeplerscript-subscription-entitlement-lib-1.so",
|
|
8
|
+
"linkDynamic": true,
|
|
9
|
+
"provider": "system",
|
|
10
|
+
"components": [],
|
|
11
|
+
"turbomodules": [
|
|
12
|
+
"AmazonNativeSubscriptionEntitlement"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|