@namiml/web-sdk 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/components/ContextConsumer.d.ts +11 -0
- package/dist/components/ContextProvider.d.ts +53 -0
- package/dist/components/NamiElement.d.ts +10 -0
- package/dist/components/Paywall.d.ts +20 -0
- package/dist/components/TemplateComponent.d.ts +2 -0
- package/dist/components/containers/BackgroundContainer.d.ts +10 -0
- package/dist/components/containers/CollapseContainer.d.ts +12 -0
- package/dist/components/containers/Container.d.ts +10 -0
- package/dist/components/containers/Content.d.ts +10 -0
- package/dist/components/containers/Footer.d.ts +10 -0
- package/dist/components/containers/Header.d.ts +11 -0
- package/dist/components/containers/ProductContainer.d.ts +12 -0
- package/dist/components/elements/Button.d.ts +11 -0
- package/dist/components/elements/Image.d.ts +9 -0
- package/dist/components/elements/SegmentPicker.d.ts +11 -0
- package/dist/components/elements/SegmentPickerItem.d.ts +12 -0
- package/dist/components/elements/Spacer.d.ts +9 -0
- package/dist/components/elements/Text.d.ts +27 -0
- package/dist/components/elements/Video.d.ts +10 -0
- package/dist/components/index.d.ts +34 -0
- package/dist/components/productDetails.d.ts +3 -0
- package/dist/components/styles/reset.d.ts +2 -0
- package/dist/components/utils/actionTap.d.ts +13 -0
- package/dist/components/utils/eventConst.d.ts +5 -0
- package/dist/components/utils/helpers.d.ts +17 -0
- package/dist/components/utils/iconMap.d.ts +1 -0
- package/dist/components/utils/impression.d.ts +4 -0
- package/dist/components/utils/products.d.ts +19 -0
- package/dist/components/utils/state.d.ts +13 -0
- package/dist/components/utils/styles.d.ts +25 -0
- package/dist/core/errors.d.ts +46 -0
- package/dist/core/withRetry.d.ts +2 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/nami/api.d.ts +19 -0
- package/dist/nami/campaign.d.ts +38 -0
- package/dist/nami/customer.d.ts +91 -0
- package/dist/nami/emitter.d.ts +12 -0
- package/dist/nami/entitlement.d.ts +29 -0
- package/dist/nami/index.d.ts +9 -0
- package/dist/nami/namiRefs.d.ts +8 -0
- package/dist/nami/paywalls.d.ts +37 -0
- package/dist/nami/profile.d.ts +12 -0
- package/dist/nami/purchase.d.ts +5 -0
- package/dist/nami/utils/campaign.d.ts +8 -0
- package/dist/nami/utils/entitlement.d.ts +55 -0
- package/dist/nami/utils/paywall.d.ts +2 -0
- package/dist/nami/utils/purchase.d.ts +4 -0
- package/dist/nami-web.cjs +22 -22
- package/dist/nami-web.d.ts +337 -169
- package/dist/nami-web.js +21 -21
- package/dist/nami-web.mjs +21 -21
- package/dist/nami-web.umd.js +22 -22
- package/dist/repositories/campaignRule.repository.d.ts +13 -0
- package/dist/repositories/config.repository.d.ts +5 -0
- package/dist/repositories/device.repository.d.ts +10 -0
- package/dist/repositories/entitlement.repository.d.ts +11 -0
- package/dist/repositories/paywall.repository.d.ts +8 -0
- package/dist/repositories/products.repository.d.ts +6 -0
- package/dist/services/logger.service.d.ts +13 -0
- package/dist/services/session.service.d.ts +4 -0
- package/dist/services/storage.service.d.ts +68 -0
- package/dist/types/api.d.ts +28 -0
- package/dist/types/campaign.d.ts +16 -0
- package/dist/types/components/containers.d.ts +71 -0
- package/dist/types/components/elements.d.ts +82 -0
- package/dist/types/components/index.d.ts +121 -0
- package/dist/types/config.d.ts +44 -0
- package/dist/types/device.d.ts +35 -0
- package/dist/types/entitlements.d.ts +19 -0
- package/dist/types/errors.d.ts +11 -0
- package/dist/types/externals/campaign.d.ts +19 -0
- package/dist/types/externals/config.d.ts +22 -0
- package/dist/types/externals/entitlement.d.ts +11 -0
- package/dist/types/externals/index.d.ts +8 -0
- package/dist/types/externals/languages.d.ts +1 -0
- package/dist/types/externals/paywall.d.ts +73 -0
- package/dist/types/externals/product.d.ts +28 -0
- package/dist/types/externals/purchase.d.ts +18 -0
- package/dist/types/externals/sku.d.ts +17 -0
- package/dist/types/loglevel.d.ts +7 -0
- package/dist/types/paywall.d.ts +184 -0
- package/dist/types/products.d.ts +6 -0
- package/dist/types/profile.d.ts +20 -0
- package/dist/types/purchase.d.ts +32 -0
- package/dist/types/sku.d.ts +22 -0
- package/dist/types/utils.d.ts +1 -0
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/const.d.ts +1 -0
- package/dist/utils/device.d.ts +3 -0
- package/dist/utils/events.d.ts +30 -0
- package/dist/utils/feature-flags.d.ts +1 -0
- package/dist/utils/fonts.d.ts +7 -0
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/ssr-shim.d.ts +1 -0
- package/package.json +13 -6
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Callback } from "src/types/components/containers";
|
|
2
|
+
import { AccountStateAction } from "src/types/profile";
|
|
3
|
+
type AccountStateHandler = (action: AccountStateAction, success: boolean, error?: Error) => void;
|
|
4
|
+
/**
|
|
5
|
+
* NamiCustomerManager provides methods for managing customer-related functionality.
|
|
6
|
+
*/
|
|
7
|
+
export declare class NamiCustomerManager {
|
|
8
|
+
static instance: NamiCustomerManager;
|
|
9
|
+
private emitter;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the customer is logged in.
|
|
12
|
+
*
|
|
13
|
+
* @returns {boolean} Returns true if the customer is logged in, false otherwise.
|
|
14
|
+
*/
|
|
15
|
+
static isLoggedIn(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the external ID of the currently logged in user.
|
|
18
|
+
*
|
|
19
|
+
* @returns The external ID of the logged in user.
|
|
20
|
+
*/
|
|
21
|
+
static loggedInId(): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Logs in a customer with the specified ID.
|
|
24
|
+
*
|
|
25
|
+
* @param id - The ID of the customer to log in. Must be a SHA256 hash or UUID.
|
|
26
|
+
* @returns A Promise that resolves when the login is successful.
|
|
27
|
+
*/
|
|
28
|
+
static login(externalId: string): Promise<void>;
|
|
29
|
+
static logout(): Promise<void>;
|
|
30
|
+
static setCustomerDataPlatformId(id: string): Promise<void>;
|
|
31
|
+
static clearCustomerDataPlatformId(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Registers a callback function to handle changes in the account state.
|
|
34
|
+
*
|
|
35
|
+
* @param callback - The callback function to be registered.
|
|
36
|
+
* @returns A function that can be used to unregister the original callback.
|
|
37
|
+
*/
|
|
38
|
+
static registerAccountStateHandler(callback: AccountStateHandler): Callback;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the anonymous mode for the customer.
|
|
41
|
+
*
|
|
42
|
+
* @param enabled - A boolean value indicating whether the anonymous mode should be enabled or disabled.
|
|
43
|
+
* @returns A Promise that resolves when the anonymous mode is set.
|
|
44
|
+
*/
|
|
45
|
+
static setAnonymousMode(enabled: boolean): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns whether or not the SDK is currently operating in anonymous mode
|
|
48
|
+
*/
|
|
49
|
+
static inAnonymousMode(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Sets an optional customer attributes that can be used to personalize your Nami paywalls.
|
|
52
|
+
*
|
|
53
|
+
* @param key - The name of the attribute. For example: `firstName`.
|
|
54
|
+
* @param value - The value of the customer attribute. For example: `Joe`.
|
|
55
|
+
*/
|
|
56
|
+
static setCustomerAttribute(key: string, value: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves the value for a given key in the on-device customer attribute key/value store.
|
|
59
|
+
*
|
|
60
|
+
* @param key - The name of the attribute. For example: `firstName`
|
|
61
|
+
* @returns The value of the customer attribute.
|
|
62
|
+
*/
|
|
63
|
+
static getCustomerAttribute(key: string): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Clears a value of the given key in the on-device key/value store.
|
|
66
|
+
*
|
|
67
|
+
* @param key - The key of the customer attribute to clear.
|
|
68
|
+
*/
|
|
69
|
+
static clearCustomerAttribute(key: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Clear all customer attributes from the on-device key/value store.
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
static clearAllCustomerAttributes(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Private Static Methods
|
|
77
|
+
*/
|
|
78
|
+
private static invokeStateHandler;
|
|
79
|
+
/**
|
|
80
|
+
* Private Instance Methods
|
|
81
|
+
*/
|
|
82
|
+
private get isSDKInitialized();
|
|
83
|
+
private static updateCustomerDataPlatformId;
|
|
84
|
+
/**
|
|
85
|
+
* Returns whether or not the configured app platform id belongs to an anonymous mode
|
|
86
|
+
* capable Nami account.
|
|
87
|
+
*/
|
|
88
|
+
private static anonymousModeCapability;
|
|
89
|
+
private static refetchConfig;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class NamiEventEmitter {
|
|
2
|
+
private static instance;
|
|
3
|
+
private emitter;
|
|
4
|
+
static getInstance(): NamiEventEmitter;
|
|
5
|
+
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
6
|
+
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
7
|
+
emit(eventName: string, ...args: any[]): void;
|
|
8
|
+
addListener(eventName: string, listener: (...args: any[]) => void): void;
|
|
9
|
+
removeListener(eventName: string, listener: (...args: any[]) => void): void;
|
|
10
|
+
listeners(eventName: string): any[];
|
|
11
|
+
listenerCount(eventName: string): number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NamiActiveEntitlementsHandler, NamiEntitlement } from "src/types/entitlements";
|
|
2
|
+
import { Callback } from "src/types/components/containers";
|
|
3
|
+
export declare class NamiEntitlementManager {
|
|
4
|
+
static instance: NamiEntitlementManager;
|
|
5
|
+
private emitter;
|
|
6
|
+
/**
|
|
7
|
+
* @returns list of currently active entitlements
|
|
8
|
+
*/
|
|
9
|
+
static active(): NamiEntitlement[];
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a Nami Control Center defined Entitlement has at least one backing purchase
|
|
12
|
+
* and it's not expired.
|
|
13
|
+
*
|
|
14
|
+
* @param referenceId - entitlement referenceId
|
|
15
|
+
* @returns True if the entitlement is active for given referenceId, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
static isEntitlementActive(referenceId: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Asks Nami to fetch the latest active entitlements
|
|
20
|
+
*
|
|
21
|
+
* @returns list of NamiEntitlement
|
|
22
|
+
*/
|
|
23
|
+
static refresh(): Promise<NamiEntitlement[]>;
|
|
24
|
+
static registerActiveEntitlementsHandler(handler: NamiActiveEntitlementsHandler): Callback | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Private Instance Methods
|
|
27
|
+
*/
|
|
28
|
+
private get sdkInitialized();
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NamiConfiguration, NamiConfigurationState } from "src/types/config";
|
|
2
|
+
export declare class Nami {
|
|
3
|
+
#private;
|
|
4
|
+
static instance: Nami;
|
|
5
|
+
get isInitialized(): boolean;
|
|
6
|
+
static configure(options: NamiConfiguration): Promise<NamiConfigurationState>;
|
|
7
|
+
private static setInitialConfig;
|
|
8
|
+
private initializeSDK;
|
|
9
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IPaywall } from "src/types/paywall";
|
|
2
|
+
import { NamiProductDetails } from "src/types/externals/product";
|
|
3
|
+
import { Callback } from "src/types/components/containers";
|
|
4
|
+
import { NamiPurchaseDetails } from "src/types/externals/purchase";
|
|
5
|
+
export declare class NamiPaywallManager {
|
|
6
|
+
static instance: NamiPaywallManager;
|
|
7
|
+
private emitter;
|
|
8
|
+
productDetails: NamiProductDetails[];
|
|
9
|
+
static allPaywalls(): IPaywall[];
|
|
10
|
+
static setProductDetails(productDetails: NamiProductDetails[]): void;
|
|
11
|
+
static registerSignInHandler(handler: Callback): Callback;
|
|
12
|
+
static registerCloseHandler(handler: Callback): Callback;
|
|
13
|
+
static registerDeeplinkActionHandler(handler: Callback): Callback;
|
|
14
|
+
static registerBuySkuHandler(handler: Callback): Callback;
|
|
15
|
+
static registerRestoreHandler(handler: Callback): Callback;
|
|
16
|
+
/**
|
|
17
|
+
* Notify the NamiPaywallManager that a purchase initiated from the
|
|
18
|
+
* [NamiBuySkuHandler] is complete. Only available for plans where Nami is
|
|
19
|
+
* not handling subscription & IAP management.
|
|
20
|
+
*/
|
|
21
|
+
static buySkuComplete(purchase: NamiPurchaseDetails): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
Notify the NamiPaywallManager that purchase flow handled by you is cancelled.
|
|
24
|
+
Used to disable product purchase-in-progress loading indicators
|
|
25
|
+
*/
|
|
26
|
+
static buySkuCancel(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Set the video details for the app supplied video
|
|
29
|
+
* @param url The URL of the video
|
|
30
|
+
* @param name The name of the video
|
|
31
|
+
*/
|
|
32
|
+
static setAppSuppliedVideoDetails(url: string, name?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Private Instance Methods
|
|
35
|
+
*/
|
|
36
|
+
private get sdkInitialized();
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class NamiProfileManager {
|
|
2
|
+
static instance: NamiProfileManager;
|
|
3
|
+
private externalId?;
|
|
4
|
+
constructor();
|
|
5
|
+
setExternalId(externalId: string | undefined): NamiProfileManager;
|
|
6
|
+
getExternalId(): string | undefined;
|
|
7
|
+
isLoggedIn(): boolean;
|
|
8
|
+
private save;
|
|
9
|
+
private load;
|
|
10
|
+
login(externalId: string): Promise<void>;
|
|
11
|
+
logout(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NamiCampaign } from "src/types/externals/campaign";
|
|
2
|
+
import { IPaywall } from "src/types/paywall";
|
|
3
|
+
export declare const isValidUrl: (label: string) => boolean;
|
|
4
|
+
export declare const allCampaigns: () => NamiCampaign[];
|
|
5
|
+
export declare const getPaywallDataFromLabel: (value: string, type?: string) => {
|
|
6
|
+
campaign: NamiCampaign | undefined;
|
|
7
|
+
paywall: IPaywall | undefined;
|
|
8
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IEntitlements, NamiEntitlement } from "src/types/entitlements";
|
|
2
|
+
import { NamiPurchase } from "src/types/externals/purchase";
|
|
3
|
+
import { PaywallSKU, SKU } from "src/types/sku";
|
|
4
|
+
import { NamiSKU } from "src/types/externals/sku";
|
|
5
|
+
export declare class EntitlementUtils {
|
|
6
|
+
static instance: EntitlementUtils;
|
|
7
|
+
refIdToPurchasedSKUs: {
|
|
8
|
+
[key: string]: NamiSKU[];
|
|
9
|
+
};
|
|
10
|
+
refIdToRelatedSKUs: {
|
|
11
|
+
[key: string]: NamiSKU[];
|
|
12
|
+
};
|
|
13
|
+
refIdToActivePurchases: {
|
|
14
|
+
[key: string]: NamiPurchase[];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare const toNamiEntitlements: (entitlement: IEntitlements) => NamiEntitlement;
|
|
18
|
+
export declare const setActiveNamiEntitlements: (entitlements: NamiEntitlement[]) => void;
|
|
19
|
+
export declare const activeEntitlements: () => NamiEntitlement[];
|
|
20
|
+
export declare const invokeHandler: () => void;
|
|
21
|
+
export declare const getEntitlementRefIdsForSku: (purchasedSkuId: string) => string[];
|
|
22
|
+
/**
|
|
23
|
+
* Populate a list of [NamiEntitlement] from the entitlements that have been provided by the
|
|
24
|
+
* app config. Also clears any previous list of [NamiEntitlement] from cache
|
|
25
|
+
*/
|
|
26
|
+
export declare const createNamiEntitlements: (entitlements?: IEntitlements[]) => NamiEntitlement[];
|
|
27
|
+
/**
|
|
28
|
+
* For namiPurchase instance, it will have a purchasedSKU that will back the activation of
|
|
29
|
+
* the entitlement.
|
|
30
|
+
*
|
|
31
|
+
* The purchaseSku (pSKU) can then be used to retrieve all entitlements activated by that pSKU
|
|
32
|
+
*
|
|
33
|
+
* The entitlement will then be inspected to see if pSKU has yet to be tracked by that
|
|
34
|
+
* entitlement. If it has not, then it will be added.
|
|
35
|
+
*
|
|
36
|
+
* The entitlement will then be inspected to see if there any active purchases that match
|
|
37
|
+
* the NamiSKU. If there isn't any, then the NamiPurchase is then added to the
|
|
38
|
+
* entitlement's list of active purchases
|
|
39
|
+
*/
|
|
40
|
+
export declare const applyEntitlementActivation: (namiPurchase: NamiPurchase) => string[];
|
|
41
|
+
/**
|
|
42
|
+
* Using the Nami Purchase object, look up the corresponding NamiSKU
|
|
43
|
+
* and set the NamiEntitlement associated to NamiSKU as an active entitlement
|
|
44
|
+
*
|
|
45
|
+
* @return List of strings where each string is a reference Id of an entitlement
|
|
46
|
+
* that was just successfully activated
|
|
47
|
+
*/
|
|
48
|
+
export declare const activateEntitlementByPurchase: (purchase: NamiPurchase) => string[];
|
|
49
|
+
export declare const skuMapFromEntitlements: (entitlements?: IEntitlements[]) => {
|
|
50
|
+
[key: string]: NamiSKU[];
|
|
51
|
+
};
|
|
52
|
+
export declare const updateRelatedSKUsForNamiEntitlement: (entitlementRefId: string, entitlementRefIdToNamiSkus: {
|
|
53
|
+
[key: string]: NamiSKU[];
|
|
54
|
+
}) => void;
|
|
55
|
+
export declare function toNamiSKU(sku: PaywallSKU | SKU): NamiSKU;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NamiPurchaseCompleteResult } from "src/types/purchase";
|
|
2
|
+
import { NamiPurchaseDetails, NamiPurchase } from "src/types/externals/purchase";
|
|
3
|
+
export declare function toNamiPurchase(purchase: NamiPurchaseDetails): NamiPurchase;
|
|
4
|
+
export declare function namiBuySKU(skuRefId: string): NamiPurchaseCompleteResult | undefined;
|