@namiml/sdk-core 3.4.1-dev.202605281900 → 3.4.1-rc.202605282113
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/dist/index.cjs +176 -379
- package/dist/index.d.ts +462 -591
- package/dist/index.mjs +176 -378
- package/dist/internal.cjs +47 -0
- package/dist/internal.d.ts +1717 -0
- package/dist/internal.mjs +39 -0
- package/package.json +6 -1
package/dist/index.cjs
CHANGED
|
@@ -98,7 +98,7 @@ const {
|
|
|
98
98
|
// version — stamped by scripts/version.sh
|
|
99
99
|
NAMI_SDK_VERSION: exports.NAMI_SDK_VERSION = "3.4.1",
|
|
100
100
|
// full package version including dev suffix — stamped by scripts/version.sh
|
|
101
|
-
NAMI_SDK_PACKAGE_VERSION: exports.NAMI_SDK_PACKAGE_VERSION = "3.4.1-
|
|
101
|
+
NAMI_SDK_PACKAGE_VERSION: exports.NAMI_SDK_PACKAGE_VERSION = "3.4.1-rc.202605282113",
|
|
102
102
|
// environments
|
|
103
103
|
PRODUCTION: exports.PRODUCTION = "production", DEVELOPMENT: exports.DEVELOPMENT = "development",
|
|
104
104
|
// error messages
|
|
@@ -108,7 +108,7 @@ AUTH_DEVICE: exports.AUTH_DEVICE = "nami_auth_device", NAMI_CONFIGURATION: expor
|
|
|
108
108
|
// API settings
|
|
109
109
|
API_VERSION: exports.API_VERSION = "v3", BASE_URL_PATH: exports.BASE_URL_PATH = `sdk/${exports.API_VERSION}/platform`, BASE_URL: exports.BASE_URL = "https://app.namiml.com", BASE_STAGING_URL: exports.BASE_STAGING_URL = "https://app-staging.namiml.com", CUSTOM_HOST_PREFIX: exports.CUSTOM_HOST_PREFIX = "namiAPIHost=", USE_STAGING_API: exports.USE_STAGING_API = "useStagingAPI",
|
|
110
110
|
// // extended client info
|
|
111
|
-
EXTENDED_CLIENT_INFO_PREFIX: exports.EXTENDED_CLIENT_INFO_PREFIX = "extendedClientInfo", EXTENDED_CLIENT_INFO_DELIMITER: exports.EXTENDED_CLIENT_INFO_DELIMITER = ":", VALIDATE_PRODUCT_GROUPS: exports.VALIDATE_PRODUCT_GROUPS = "validateProductGroups", LOG_HTTP_REQUESTS: exports.LOG_HTTP_REQUESTS = "logHTTPRequests", LOG_HTTP_TRAFFIC: exports.LOG_HTTP_TRAFFIC = "logHTTPTraffic",
|
|
111
|
+
EXTENDED_CLIENT_INFO_PREFIX: exports.EXTENDED_CLIENT_INFO_PREFIX = "extendedClientInfo", EXTENDED_CLIENT_INFO_DELIMITER: exports.EXTENDED_CLIENT_INFO_DELIMITER = ":", VALIDATE_PRODUCT_GROUPS: exports.VALIDATE_PRODUCT_GROUPS = "validateProductGroups", LOG_HTTP_REQUESTS: exports.LOG_HTTP_REQUESTS = "logHTTPRequests", LOG_HTTP_TRAFFIC: exports.LOG_HTTP_TRAFFIC = "logHTTPTraffic", EXTENDED_PLATFORM: exports.EXTENDED_PLATFORM = "extended-platform", EXTENDED_PLATFORM_VERSION: exports.EXTENDED_PLATFORM_VERSION = "extended-platform-version", API_MAX_CALLS_LIMIT: exports.API_MAX_CALLS_LIMIT = 2, API_RETRY_DELAY_SEC: exports.API_RETRY_DELAY_SEC = 2, API_TIMEOUT_LIMIT: exports.API_TIMEOUT_LIMIT = 20000, DEVICE_API_TIMEOUT_LIMIT: exports.DEVICE_API_TIMEOUT_LIMIT = 2000,
|
|
112
112
|
// status codes
|
|
113
113
|
STATUS_SUCCESS: exports.STATUS_SUCCESS = 200, STATUS_BAD_REQUEST: exports.STATUS_BAD_REQUEST = 400, STATUS_NOT_FOUND: exports.STATUS_NOT_FOUND = 404, STATUS_CONFLICT: exports.STATUS_CONFLICT = 409, STATUS_INTERNAL_SERVER_ERROR: exports.STATUS_INTERNAL_SERVER_ERROR = 500,
|
|
114
114
|
// configuration states
|
|
@@ -6803,10 +6803,6 @@ const shouldLogHTTPTraffic = () => {
|
|
|
6803
6803
|
const namiCommands = storageService.getNamiConfig()?.namiCommands;
|
|
6804
6804
|
return namiCommands?.includes(exports.LOG_HTTP_TRAFFIC) ?? false;
|
|
6805
6805
|
};
|
|
6806
|
-
const shouldLogStartupTelemetry = () => {
|
|
6807
|
-
const namiCommands = storageService.getNamiConfig()?.namiCommands;
|
|
6808
|
-
return namiCommands?.includes(exports.STARTUP_TELEMETRY) ?? false;
|
|
6809
|
-
};
|
|
6810
6806
|
function tryParseJson(str) {
|
|
6811
6807
|
const trimmed = str.trim();
|
|
6812
6808
|
if (!trimmed.startsWith("{") && !trimmed.startsWith("["))
|
|
@@ -7041,6 +7037,10 @@ exports.NamiCampaignRuleType = void 0;
|
|
|
7041
7037
|
NamiCampaignRuleType["UNKNOWN"] = "unknown";
|
|
7042
7038
|
NamiCampaignRuleType["URL"] = "url";
|
|
7043
7039
|
})(exports.NamiCampaignRuleType || (exports.NamiCampaignRuleType = {}));
|
|
7040
|
+
// NamiCampaignManagerStatic interface + const proxy live in
|
|
7041
|
+
// `src/managers/campaign.ts`. They must stay out of this file: PaywallState
|
|
7042
|
+
// type-imports from here, and pulling in the manager class triggers a
|
|
7043
|
+
// constructor chain that runs before PaywallState finishes loading. See NAM-1207.
|
|
7044
7044
|
|
|
7045
7045
|
/**
|
|
7046
7046
|
* Get initial paywalls from storage service.
|
|
@@ -8677,12 +8677,12 @@ SessionService.instance = new SessionService();
|
|
|
8677
8677
|
* @class NamiPurchaseManager
|
|
8678
8678
|
* Provides methods for managing all aspects of a purchase in the Nami SDK.
|
|
8679
8679
|
*/
|
|
8680
|
-
class NamiPurchaseManager {
|
|
8680
|
+
let NamiPurchaseManager$1 = class NamiPurchaseManager {
|
|
8681
8681
|
static allPurchases() {
|
|
8682
8682
|
return [];
|
|
8683
8683
|
}
|
|
8684
|
-
}
|
|
8685
|
-
NamiPurchaseManager.instance = new NamiPurchaseManager();
|
|
8684
|
+
};
|
|
8685
|
+
NamiPurchaseManager$1.instance = new NamiPurchaseManager$1();
|
|
8686
8686
|
|
|
8687
8687
|
var en = {
|
|
8688
8688
|
nami_day: "day",
|
|
@@ -11741,7 +11741,7 @@ const createNamiEntitlements = (entitlements) => {
|
|
|
11741
11741
|
const namiEntitlements = activeEntitlements();
|
|
11742
11742
|
if (!entitlements)
|
|
11743
11743
|
return namiEntitlements;
|
|
11744
|
-
NamiPurchaseManager.allPurchases().forEach((namiPurchase) => {
|
|
11744
|
+
NamiPurchaseManager$1.allPurchases().forEach((namiPurchase) => {
|
|
11745
11745
|
applyEntitlementActivation(namiPurchase);
|
|
11746
11746
|
});
|
|
11747
11747
|
const entitlementsToSkus = skuMapFromEntitlements(entitlements);
|
|
@@ -11929,123 +11929,6 @@ class CustomerJourneyRepository {
|
|
|
11929
11929
|
}
|
|
11930
11930
|
CustomerJourneyRepository.instance = new CustomerJourneyRepository();
|
|
11931
11931
|
|
|
11932
|
-
const PREFIX = "[NamiStartup]";
|
|
11933
|
-
/**
|
|
11934
|
-
* Module-level singleton for startup timing instrumentation.
|
|
11935
|
-
*
|
|
11936
|
-
* All methods are cheap no-ops when the `startupTelemetry` namiCommand flag
|
|
11937
|
-
* is absent. The flag is read once at `start()` and cached; subsequent calls
|
|
11938
|
-
* to `mark()` and the span helpers use that cached boolean so the hot path
|
|
11939
|
-
* never hits storage.
|
|
11940
|
-
*
|
|
11941
|
-
* Log format (info level via the shared logger):
|
|
11942
|
-
* [NamiStartup] phase=<name> ms=<n>
|
|
11943
|
-
* [NamiStartup] SUMMARY total_to_ready=<ms> decode=<ms> process=<ms> placements=<n>
|
|
11944
|
-
*/
|
|
11945
|
-
class StartupTelemetry {
|
|
11946
|
-
constructor() {
|
|
11947
|
-
this.enabled = false;
|
|
11948
|
-
this.t0 = 0;
|
|
11949
|
-
this.lastMark = 0;
|
|
11950
|
-
// Accumulated segment durations for the SUMMARY line
|
|
11951
|
-
this.decodeDuration = 0;
|
|
11952
|
-
this.processDuration = 0;
|
|
11953
|
-
this.placements = 0;
|
|
11954
|
-
// One-shot guard: only log the very first launch lookup
|
|
11955
|
-
this.firstLaunchLogged = false;
|
|
11956
|
-
}
|
|
11957
|
-
/**
|
|
11958
|
-
* Call at the first line of configure(). Reads the feature flag once and
|
|
11959
|
-
* stores t0 if the flag is on.
|
|
11960
|
-
*/
|
|
11961
|
-
start() {
|
|
11962
|
-
this.enabled = shouldLogStartupTelemetry();
|
|
11963
|
-
if (!this.enabled)
|
|
11964
|
-
return;
|
|
11965
|
-
this.t0 = Date.now();
|
|
11966
|
-
this.lastMark = this.t0;
|
|
11967
|
-
this.decodeDuration = 0;
|
|
11968
|
-
this.processDuration = 0;
|
|
11969
|
-
this.placements = 0;
|
|
11970
|
-
this.firstLaunchLogged = false;
|
|
11971
|
-
}
|
|
11972
|
-
/**
|
|
11973
|
-
* Log a named phase checkpoint.
|
|
11974
|
-
*
|
|
11975
|
-
* - Emits `[NamiStartup] phase=<name> ms=<segment> [extras]`
|
|
11976
|
-
* - On phase `ready`: also emits `total_to_ready=<ms>` and a SUMMARY line.
|
|
11977
|
-
* - On phase `initial_config_decoded`: records the decode segment.
|
|
11978
|
-
* - On phase `initial_processed`: records the process segment + placement count.
|
|
11979
|
-
*
|
|
11980
|
-
* @param phase Phase key string (e.g. "initial_config_decoded").
|
|
11981
|
-
* @param extras Optional key/value pairs appended to the log line.
|
|
11982
|
-
*/
|
|
11983
|
-
mark(phase, extras) {
|
|
11984
|
-
if (!this.enabled)
|
|
11985
|
-
return;
|
|
11986
|
-
const now = Date.now();
|
|
11987
|
-
const segmentMs = now - this.lastMark;
|
|
11988
|
-
this.lastMark = now;
|
|
11989
|
-
// Accumulate segment durations for SUMMARY
|
|
11990
|
-
if (phase === "initial_config_decoded") {
|
|
11991
|
-
this.decodeDuration = segmentMs;
|
|
11992
|
-
}
|
|
11993
|
-
else if (phase === "initial_processed") {
|
|
11994
|
-
this.processDuration = segmentMs;
|
|
11995
|
-
if (extras?.count !== undefined) {
|
|
11996
|
-
this.placements = extras.count;
|
|
11997
|
-
}
|
|
11998
|
-
}
|
|
11999
|
-
const extrasStr = extras
|
|
12000
|
-
? " " + Object.entries(extras).map(([k, v]) => `${k}=${v}`).join(" ")
|
|
12001
|
-
: "";
|
|
12002
|
-
if (phase === "ready") {
|
|
12003
|
-
const totalToReady = now - this.t0;
|
|
12004
|
-
logger.info(`${PREFIX} phase=${phase} ms=${segmentMs} total_to_ready=${totalToReady}${extrasStr}`);
|
|
12005
|
-
logger.info(`${PREFIX} SUMMARY total_to_ready=${totalToReady} decode=${this.decodeDuration} process=${this.processDuration} placements=${this.placements}`);
|
|
12006
|
-
}
|
|
12007
|
-
else {
|
|
12008
|
-
logger.info(`${PREFIX} phase=${phase} ms=${segmentMs}${extrasStr}`);
|
|
12009
|
-
}
|
|
12010
|
-
}
|
|
12011
|
-
/**
|
|
12012
|
-
* Wrap the very first launch lookup call. Only the first invocation is
|
|
12013
|
-
* instrumented; subsequent calls return immediately without logging.
|
|
12014
|
-
*
|
|
12015
|
-
* @param label The campaign label being looked up.
|
|
12016
|
-
* @param fn The synchronous lookup function to time.
|
|
12017
|
-
* @returns The return value of `fn`.
|
|
12018
|
-
*/
|
|
12019
|
-
firstLaunchLookup(label, fn) {
|
|
12020
|
-
if (!this.enabled || this.firstLaunchLogged) {
|
|
12021
|
-
return fn();
|
|
12022
|
-
}
|
|
12023
|
-
this.firstLaunchLogged = true;
|
|
12024
|
-
const t = Date.now();
|
|
12025
|
-
const result = fn();
|
|
12026
|
-
const ms = Date.now() - t;
|
|
12027
|
-
logger.info(`${PREFIX} phase=first_launch_lookup ms=${ms} label=${label}`);
|
|
12028
|
-
return result;
|
|
12029
|
-
}
|
|
12030
|
-
/**
|
|
12031
|
-
* Wrap the background server fetch. Logs duration and campaign count when
|
|
12032
|
-
* the promise settles.
|
|
12033
|
-
*
|
|
12034
|
-
* @param fn An async function that performs the server fetch.
|
|
12035
|
-
* @returns A promise that resolves/rejects with the same value as `fn`.
|
|
12036
|
-
*/
|
|
12037
|
-
async serverFetch(fn) {
|
|
12038
|
-
if (!this.enabled)
|
|
12039
|
-
return fn();
|
|
12040
|
-
const t = Date.now();
|
|
12041
|
-
const result = await fn();
|
|
12042
|
-
const ms = Date.now() - t;
|
|
12043
|
-
logger.info(`${PREFIX} phase=server_fetch ms=${ms} campaigns=${result.length}`);
|
|
12044
|
-
return result;
|
|
12045
|
-
}
|
|
12046
|
-
}
|
|
12047
|
-
const startupTelemetry = new StartupTelemetry();
|
|
12048
|
-
|
|
12049
11932
|
class NamiRefs {
|
|
12050
11933
|
constructor() {
|
|
12051
11934
|
// In-memory flag for device registration failures (not persisted)
|
|
@@ -12113,9 +11996,7 @@ class NamiRefs {
|
|
|
12113
11996
|
: this.initIdentifiedDevice(config);
|
|
12114
11997
|
const splitPosition = audienceSplitPosition(deviceId);
|
|
12115
11998
|
if (initialConfig.campaign_rules) {
|
|
12116
|
-
|
|
12117
|
-
storageService.setCampaignRules(exports.INITIAL_CAMPAIGN_RULES, mappedCampaigns);
|
|
12118
|
-
startupTelemetry.mark("initial_processed", { count: mappedCampaigns.length });
|
|
11999
|
+
storageService.setCampaignRules(exports.INITIAL_CAMPAIGN_RULES, mapAnonymousCampaigns(initialConfig.campaign_rules, splitPosition, currentFormFactor));
|
|
12119
12000
|
}
|
|
12120
12001
|
if (deviceTask)
|
|
12121
12002
|
await deviceTask;
|
|
@@ -12125,7 +12006,7 @@ class NamiRefs {
|
|
|
12125
12006
|
ProductRepository.instance.fetchProducts(),
|
|
12126
12007
|
CustomerJourneyRepository.instance.fetchCustomerJourneyState(),
|
|
12127
12008
|
EntitlementRepository.instance.fetchActiveEntitlements(),
|
|
12128
|
-
|
|
12009
|
+
this.fetchCampaignsAndPaywalls(),
|
|
12129
12010
|
]).catch(async (error) => {
|
|
12130
12011
|
if (error instanceof ConflictError) {
|
|
12131
12012
|
storageService.resetDevice();
|
|
@@ -12340,7 +12221,7 @@ class Nami {
|
|
|
12340
12221
|
CampaignRuleRepository.instance.reset();
|
|
12341
12222
|
// Lazy import to avoid a load-order cycle (NamiFlowManager imports
|
|
12342
12223
|
// back to this module for `Nami.instance.maxLogging`).
|
|
12343
|
-
const { NamiFlowManager } = await Promise.resolve().then(function () { return NamiFlowManager$
|
|
12224
|
+
const { NamiFlowManager } = await Promise.resolve().then(function () { return NamiFlowManager$2; });
|
|
12344
12225
|
NamiFlowManager.reset();
|
|
12345
12226
|
// Give platform adapters a chance to drop their own state
|
|
12346
12227
|
// (e.g. Expo's UI adapter holds listener refs from PaywallView).
|
|
@@ -12353,12 +12234,10 @@ class Nami {
|
|
|
12353
12234
|
* @returns {Promise<NamiConfigurationState>}
|
|
12354
12235
|
*/
|
|
12355
12236
|
static async configure(options) {
|
|
12356
|
-
startupTelemetry.start();
|
|
12357
12237
|
if (!options.appPlatformID) {
|
|
12358
12238
|
throw new PlatformIDRequiredError();
|
|
12359
12239
|
}
|
|
12360
12240
|
this.setInitialConfig(options);
|
|
12361
|
-
startupTelemetry.mark("initial_config_decoded");
|
|
12362
12241
|
return await Nami.instance.initializeSDK(options);
|
|
12363
12242
|
}
|
|
12364
12243
|
static setInitialConfig(config) {
|
|
@@ -12437,7 +12316,6 @@ class Nami {
|
|
|
12437
12316
|
logger.info("SDK successfully initialized!");
|
|
12438
12317
|
const state = partialReconfig || fullReconfig ? exports.RECONFIG_SUCCESS : exports.INITIAL_SUCCESS;
|
|
12439
12318
|
getPlatformAdapters().ui.postConfigure?.();
|
|
12440
|
-
startupTelemetry.mark("ready");
|
|
12441
12319
|
return {
|
|
12442
12320
|
sdkInitialized: true,
|
|
12443
12321
|
configureState: state,
|
|
@@ -12447,20 +12325,6 @@ class Nami {
|
|
|
12447
12325
|
_Nami_isInitialized = new WeakMap();
|
|
12448
12326
|
Nami.instance = new Nami();
|
|
12449
12327
|
|
|
12450
|
-
exports.LaunchCampaignError = void 0;
|
|
12451
|
-
(function (LaunchCampaignError) {
|
|
12452
|
-
LaunchCampaignError["DEFAULT_CAMPAIGN_NOT_FOUND"] = "Default campaign not found";
|
|
12453
|
-
LaunchCampaignError["LABELED_CAMPAIGN_NOT_FOUND"] = "Labeled campaign not found";
|
|
12454
|
-
LaunchCampaignError["CAMPAIGN_DATA_NOT_FOUND"] = "Campaign data not found";
|
|
12455
|
-
LaunchCampaignError["PAYWALL_ALREADY_DISPLAYED"] = "Paywall is already being displayed";
|
|
12456
|
-
LaunchCampaignError["SDK_NOT_INITIALIZED"] = "SDK has not been initialized";
|
|
12457
|
-
LaunchCampaignError["PAYWALL_COULD_NOT_DISPLAY"] = "Failed to display paywall";
|
|
12458
|
-
LaunchCampaignError["URL_CAMPAIGN_NOT_FOUND"] = "URL campaign not found";
|
|
12459
|
-
LaunchCampaignError["PRODUCT_DATA_NOT_FOUND"] = "Product data not found";
|
|
12460
|
-
LaunchCampaignError["PRODUCT_GROUPS_NOT_FOUND"] = "Product groups not found";
|
|
12461
|
-
LaunchCampaignError["FLOW_SCREEN_DATA_UNAVILABLE"] = "Flow unavailable due to missing screen data";
|
|
12462
|
-
})(exports.LaunchCampaignError || (exports.LaunchCampaignError = {}));
|
|
12463
|
-
|
|
12464
12328
|
const VALID_STYLES = new Set(['fullscreen', 'sheet', 'compact_sheet', 'modal']);
|
|
12465
12329
|
function getEffectiveWebStyle(style) {
|
|
12466
12330
|
if (!style || !VALID_STYLES.has(style))
|
|
@@ -12512,6 +12376,20 @@ exports.NamiPaywallAction = void 0;
|
|
|
12512
12376
|
NamiPaywallAction["UNKNOWN"] = "UNKNOWN";
|
|
12513
12377
|
})(exports.NamiPaywallAction || (exports.NamiPaywallAction = {}));
|
|
12514
12378
|
|
|
12379
|
+
exports.LaunchCampaignError = void 0;
|
|
12380
|
+
(function (LaunchCampaignError) {
|
|
12381
|
+
LaunchCampaignError["DEFAULT_CAMPAIGN_NOT_FOUND"] = "Default campaign not found";
|
|
12382
|
+
LaunchCampaignError["LABELED_CAMPAIGN_NOT_FOUND"] = "Labeled campaign not found";
|
|
12383
|
+
LaunchCampaignError["CAMPAIGN_DATA_NOT_FOUND"] = "Campaign data not found";
|
|
12384
|
+
LaunchCampaignError["PAYWALL_ALREADY_DISPLAYED"] = "Paywall is already being displayed";
|
|
12385
|
+
LaunchCampaignError["SDK_NOT_INITIALIZED"] = "SDK has not been initialized";
|
|
12386
|
+
LaunchCampaignError["PAYWALL_COULD_NOT_DISPLAY"] = "Failed to display paywall";
|
|
12387
|
+
LaunchCampaignError["URL_CAMPAIGN_NOT_FOUND"] = "URL campaign not found";
|
|
12388
|
+
LaunchCampaignError["PRODUCT_DATA_NOT_FOUND"] = "Product data not found";
|
|
12389
|
+
LaunchCampaignError["PRODUCT_GROUPS_NOT_FOUND"] = "Product groups not found";
|
|
12390
|
+
LaunchCampaignError["FLOW_SCREEN_DATA_UNAVILABLE"] = "Flow unavailable due to missing screen data";
|
|
12391
|
+
})(exports.LaunchCampaignError || (exports.LaunchCampaignError = {}));
|
|
12392
|
+
|
|
12515
12393
|
const NamiFlowStepType = {
|
|
12516
12394
|
ENTRY: 'entry',
|
|
12517
12395
|
SCREEN: 'screen',
|
|
@@ -12538,7 +12416,6 @@ exports.NamiFlowActionFunction = void 0;
|
|
|
12538
12416
|
NamiFlowActionFunction["SET_TAGS"] = "setTags";
|
|
12539
12417
|
NamiFlowActionFunction["PAUSE"] = "flowPause";
|
|
12540
12418
|
NamiFlowActionFunction["RESUME"] = "flowResume";
|
|
12541
|
-
NamiFlowActionFunction["SET_LAUNCH_CONTEXT"] = "setLaunchContext";
|
|
12542
12419
|
})(exports.NamiFlowActionFunction || (exports.NamiFlowActionFunction = {}));
|
|
12543
12420
|
const HandoffTag = {
|
|
12544
12421
|
SEQUENCE: '__handoff_sequence__',
|
|
@@ -13122,16 +12999,6 @@ class FlowLiquidResolver {
|
|
|
13122
12999
|
const idx = screenState?.getSelectedSlideIndexForCurrentCarousel();
|
|
13123
13000
|
return idx != null ? `${idx + 1}` : undefined;
|
|
13124
13001
|
}
|
|
13125
|
-
case "productGroupId":
|
|
13126
|
-
return PaywallState.currentProvider?.state.currentGroupId || undefined;
|
|
13127
|
-
case "productGroupName": {
|
|
13128
|
-
const s = PaywallState.currentProvider?.state;
|
|
13129
|
-
return s?.groups?.find(g => g.id === s.currentGroupId)?.displayName ?? undefined;
|
|
13130
|
-
}
|
|
13131
|
-
case "productGroupRef": {
|
|
13132
|
-
const s = PaywallState.currentProvider?.state;
|
|
13133
|
-
return s?.groups?.find(g => g.id === s.currentGroupId)?.ref ?? undefined;
|
|
13134
|
-
}
|
|
13135
13002
|
default:
|
|
13136
13003
|
return undefined;
|
|
13137
13004
|
}
|
|
@@ -13255,7 +13122,7 @@ exports.AccountStateAction = void 0;
|
|
|
13255
13122
|
AccountStateAction["NAMI_DEVICE_ID_CLEARED"] = "nami_device_id_cleared";
|
|
13256
13123
|
})(exports.AccountStateAction || (exports.AccountStateAction = {}));
|
|
13257
13124
|
|
|
13258
|
-
class NamiFlowManager {
|
|
13125
|
+
let NamiFlowManager$1 = class NamiFlowManager {
|
|
13259
13126
|
static get instance() {
|
|
13260
13127
|
if (!NamiFlowManager._instance) {
|
|
13261
13128
|
NamiFlowManager._instance = new NamiFlowManager();
|
|
@@ -13565,11 +13432,11 @@ class NamiFlowManager {
|
|
|
13565
13432
|
static getCurrentFlowStepAutoAdvanceDelay() {
|
|
13566
13433
|
return this.instance.getCurrentFlowStepAutoAdvanceDelay();
|
|
13567
13434
|
}
|
|
13568
|
-
}
|
|
13435
|
+
};
|
|
13569
13436
|
|
|
13570
|
-
var NamiFlowManager$
|
|
13437
|
+
var NamiFlowManager$2 = /*#__PURE__*/Object.freeze({
|
|
13571
13438
|
__proto__: null,
|
|
13572
|
-
NamiFlowManager: NamiFlowManager
|
|
13439
|
+
NamiFlowManager: NamiFlowManager$1
|
|
13573
13440
|
});
|
|
13574
13441
|
|
|
13575
13442
|
const SHOULD_SHOW_LOADING_INDICATOR = false;
|
|
@@ -13591,7 +13458,7 @@ const isAsyncLoginLogoutDisabled = () => {
|
|
|
13591
13458
|
* @class NamiCustomerManager
|
|
13592
13459
|
* Provides methods for managing customer-related functionality.
|
|
13593
13460
|
*/
|
|
13594
|
-
class NamiCustomerManager {
|
|
13461
|
+
let NamiCustomerManager$1 = class NamiCustomerManager {
|
|
13595
13462
|
constructor() {
|
|
13596
13463
|
this.emitter = NamiEventEmitter.getInstance();
|
|
13597
13464
|
NamiConditionEvaluator.shared.registerNamespaceResolver("UserTags", (identifier) => {
|
|
@@ -13654,8 +13521,8 @@ class NamiCustomerManager {
|
|
|
13654
13521
|
// refresh fire-and-forget — failures are logged but do not surface.
|
|
13655
13522
|
NamiProfileManager.instance.loginLocal(externalId);
|
|
13656
13523
|
this.invokeStateHandler(exports.AccountStateAction.LOGIN, true);
|
|
13657
|
-
if (NamiFlowManager.instance.flowOpen) {
|
|
13658
|
-
const currentFlow = NamiFlowManager.instance.currentFlow;
|
|
13524
|
+
if (NamiFlowManager$1.instance.flowOpen) {
|
|
13525
|
+
const currentFlow = NamiFlowManager$1.instance.currentFlow;
|
|
13659
13526
|
const currentStep = currentFlow?.currentFlowStep;
|
|
13660
13527
|
if (currentStep) {
|
|
13661
13528
|
if (Nami.instance.maxLogging) {
|
|
@@ -13676,8 +13543,8 @@ class NamiCustomerManager {
|
|
|
13676
13543
|
await NamiProfileManager.instance.login(externalId);
|
|
13677
13544
|
await EntitlementRepository.instance.fetchActiveEntitlements();
|
|
13678
13545
|
this.invokeStateHandler(exports.AccountStateAction.LOGIN, true);
|
|
13679
|
-
if (NamiFlowManager.instance.flowOpen) {
|
|
13680
|
-
const currentFlow = NamiFlowManager.instance.currentFlow;
|
|
13546
|
+
if (NamiFlowManager$1.instance.flowOpen) {
|
|
13547
|
+
const currentFlow = NamiFlowManager$1.instance.currentFlow;
|
|
13681
13548
|
const currentStep = currentFlow?.currentFlowStep;
|
|
13682
13549
|
if (currentStep) {
|
|
13683
13550
|
if (Nami.instance.maxLogging) {
|
|
@@ -13689,8 +13556,8 @@ class NamiCustomerManager {
|
|
|
13689
13556
|
}
|
|
13690
13557
|
catch (error) {
|
|
13691
13558
|
this.invokeStateHandler(exports.AccountStateAction.LOGIN, false, error);
|
|
13692
|
-
if (NamiFlowManager.instance.flowOpen) {
|
|
13693
|
-
const currentFlow = NamiFlowManager.instance.currentFlow;
|
|
13559
|
+
if (NamiFlowManager$1.instance.flowOpen) {
|
|
13560
|
+
const currentFlow = NamiFlowManager$1.instance.currentFlow;
|
|
13694
13561
|
const currentStep = currentFlow?.currentFlowStep;
|
|
13695
13562
|
if (currentStep) {
|
|
13696
13563
|
if (Nami.instance.maxLogging) {
|
|
@@ -13723,8 +13590,8 @@ class NamiCustomerManager {
|
|
|
13723
13590
|
// refresh fire-and-forget — failures are logged but do not surface.
|
|
13724
13591
|
NamiProfileManager.instance.logoutLocal();
|
|
13725
13592
|
this.invokeStateHandler(exports.AccountStateAction.LOGOUT, true);
|
|
13726
|
-
if (NamiFlowManager.instance.flowOpen) {
|
|
13727
|
-
const currentFlow = NamiFlowManager.instance.currentFlow;
|
|
13593
|
+
if (NamiFlowManager$1.instance.flowOpen) {
|
|
13594
|
+
const currentFlow = NamiFlowManager$1.instance.currentFlow;
|
|
13728
13595
|
const currentStep = currentFlow?.currentFlowStep;
|
|
13729
13596
|
if (currentStep) {
|
|
13730
13597
|
if (Nami.instance.maxLogging) {
|
|
@@ -13745,8 +13612,8 @@ class NamiCustomerManager {
|
|
|
13745
13612
|
await NamiProfileManager.instance.logout();
|
|
13746
13613
|
await EntitlementRepository.instance.fetchActiveEntitlements();
|
|
13747
13614
|
this.invokeStateHandler(exports.AccountStateAction.LOGOUT, true);
|
|
13748
|
-
if (NamiFlowManager.instance.flowOpen) {
|
|
13749
|
-
const currentFlow = NamiFlowManager.instance.currentFlow;
|
|
13615
|
+
if (NamiFlowManager$1.instance.flowOpen) {
|
|
13616
|
+
const currentFlow = NamiFlowManager$1.instance.currentFlow;
|
|
13750
13617
|
const currentStep = currentFlow?.currentFlowStep;
|
|
13751
13618
|
if (currentStep) {
|
|
13752
13619
|
currentFlow.executeLifecycle(currentStep, NamiReservedActions.LOGOUT_SUCCESS);
|
|
@@ -13755,8 +13622,8 @@ class NamiCustomerManager {
|
|
|
13755
13622
|
}
|
|
13756
13623
|
catch (error) {
|
|
13757
13624
|
this.invokeStateHandler(exports.AccountStateAction.LOGOUT, false, error);
|
|
13758
|
-
if (NamiFlowManager.instance.flowOpen) {
|
|
13759
|
-
const currentFlow = NamiFlowManager.instance.currentFlow;
|
|
13625
|
+
if (NamiFlowManager$1.instance.flowOpen) {
|
|
13626
|
+
const currentFlow = NamiFlowManager$1.instance.currentFlow;
|
|
13760
13627
|
const currentStep = currentFlow?.currentFlowStep;
|
|
13761
13628
|
if (currentStep) {
|
|
13762
13629
|
currentFlow.executeLifecycle(currentStep, NamiReservedActions.LOGOUT_FAILURE);
|
|
@@ -13865,8 +13732,8 @@ class NamiCustomerManager {
|
|
|
13865
13732
|
PaywallState.setCustomerAttribute({ [key]: value });
|
|
13866
13733
|
logger.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${key}`);
|
|
13867
13734
|
}
|
|
13868
|
-
if (NamiFlowManager.instance.flowOpen) {
|
|
13869
|
-
const currentFlow = NamiFlowManager.instance.currentFlow;
|
|
13735
|
+
if (NamiFlowManager$1.instance.flowOpen) {
|
|
13736
|
+
const currentFlow = NamiFlowManager$1.instance.currentFlow;
|
|
13870
13737
|
if (currentFlow) {
|
|
13871
13738
|
const currentStep = currentFlow.currentFlowStep;
|
|
13872
13739
|
if (currentStep) {
|
|
@@ -14040,8 +13907,8 @@ class NamiCustomerManager {
|
|
|
14040
13907
|
]);
|
|
14041
13908
|
}
|
|
14042
13909
|
}
|
|
14043
|
-
}
|
|
14044
|
-
NamiCustomerManager.instance = new NamiCustomerManager();
|
|
13910
|
+
};
|
|
13911
|
+
NamiCustomerManager$1.instance = new NamiCustomerManager$1();
|
|
14045
13912
|
|
|
14046
13913
|
class BasicNamiFlow {
|
|
14047
13914
|
constructor(flowObject = {}) {
|
|
@@ -14077,16 +13944,6 @@ class NamiFlow extends BasicNamiFlow {
|
|
|
14077
13944
|
this.forward(entry.id);
|
|
14078
13945
|
}
|
|
14079
13946
|
}
|
|
14080
|
-
applyLaunchContextAttributes(attrs) {
|
|
14081
|
-
if (!this.context) {
|
|
14082
|
-
this.context = { customAttributes: {} };
|
|
14083
|
-
new LaunchContextResolver(this.context);
|
|
14084
|
-
}
|
|
14085
|
-
// Guard against a runtime-supplied context that omits customAttributes
|
|
14086
|
-
// (the field is required by the type but may be absent in untyped JSON).
|
|
14087
|
-
this.context.customAttributes ??= {};
|
|
14088
|
-
Object.assign(this.context.customAttributes, attrs);
|
|
14089
|
-
}
|
|
14090
13947
|
registerResolvers(context) {
|
|
14091
13948
|
if (context) {
|
|
14092
13949
|
new LaunchContextResolver(context);
|
|
@@ -14343,9 +14200,6 @@ class NamiFlow extends BasicNamiFlow {
|
|
|
14343
14200
|
this.back();
|
|
14344
14201
|
break;
|
|
14345
14202
|
case exports.NamiFlowActionFunction.NEXT:
|
|
14346
|
-
if (action.parameters?.customAttributes) {
|
|
14347
|
-
this.applyLaunchContextAttributes(action.parameters.customAttributes);
|
|
14348
|
-
}
|
|
14349
14203
|
if (action.parameters?.step) {
|
|
14350
14204
|
this.forward(action.parameters.step);
|
|
14351
14205
|
}
|
|
@@ -14354,9 +14208,6 @@ class NamiFlow extends BasicNamiFlow {
|
|
|
14354
14208
|
}
|
|
14355
14209
|
break;
|
|
14356
14210
|
case exports.NamiFlowActionFunction.NAVIGATE:
|
|
14357
|
-
if (action.parameters?.customAttributes) {
|
|
14358
|
-
this.applyLaunchContextAttributes(action.parameters.customAttributes);
|
|
14359
|
-
}
|
|
14360
14211
|
if (action.parameters?.step) {
|
|
14361
14212
|
if (this.previousFlowStep?.id === action.parameters.step) {
|
|
14362
14213
|
this.back();
|
|
@@ -14478,24 +14329,10 @@ class NamiFlow extends BasicNamiFlow {
|
|
|
14478
14329
|
if (action.parameters) {
|
|
14479
14330
|
PaywallState.setUserTags(action.parameters);
|
|
14480
14331
|
Object.entries(action.parameters).forEach(([key, value]) => {
|
|
14481
|
-
NamiCustomerManager.setCustomerAttribute(key, value);
|
|
14332
|
+
NamiCustomerManager$1.setCustomerAttribute(key, value);
|
|
14482
14333
|
});
|
|
14483
14334
|
}
|
|
14484
14335
|
break;
|
|
14485
|
-
case exports.NamiFlowActionFunction.SET_LAUNCH_CONTEXT: {
|
|
14486
|
-
// Two supported shapes (matches the nav-action customAttributes wire shape
|
|
14487
|
-
// and the { key, value } shape used by Apple/Android/Roku). We deliberately
|
|
14488
|
-
// do NOT treat arbitrary top-level parameters as attributes, to avoid writing
|
|
14489
|
-
// reserved keys (step, delay, …) into the launch context.
|
|
14490
|
-
const params = action.parameters;
|
|
14491
|
-
if (params?.customAttributes) {
|
|
14492
|
-
this.applyLaunchContextAttributes(params.customAttributes);
|
|
14493
|
-
}
|
|
14494
|
-
else if (params?.key !== undefined && params?.value !== undefined) {
|
|
14495
|
-
this.applyLaunchContextAttributes({ [params.key]: params.value });
|
|
14496
|
-
}
|
|
14497
|
-
break;
|
|
14498
|
-
}
|
|
14499
14336
|
default:
|
|
14500
14337
|
logger.warn(`Missing action handler for ${action.function}`, action);
|
|
14501
14338
|
break;
|
|
@@ -14625,7 +14462,7 @@ class NamiFlow extends BasicNamiFlow {
|
|
|
14625
14462
|
* @class NamiCampaignManager
|
|
14626
14463
|
* Provides methods for managing all aspects of a campaign.
|
|
14627
14464
|
*/
|
|
14628
|
-
class NamiCampaignManager {
|
|
14465
|
+
let NamiCampaignManager$1 = class NamiCampaignManager {
|
|
14629
14466
|
constructor() {
|
|
14630
14467
|
this.emitter = NamiEventEmitter.getInstance();
|
|
14631
14468
|
}
|
|
@@ -14723,7 +14560,7 @@ class NamiCampaignManager {
|
|
|
14723
14560
|
resultCallback(false, exports.LaunchCampaignError.SDK_NOT_INITIALIZED);
|
|
14724
14561
|
throw new SDKNotInitializedError();
|
|
14725
14562
|
}
|
|
14726
|
-
const data =
|
|
14563
|
+
const data = getPaywallDataFromLabel(value, type);
|
|
14727
14564
|
let paywall = data.paywall;
|
|
14728
14565
|
const campaign = data.campaign;
|
|
14729
14566
|
if (!campaign || (!paywall && !campaign.flow)) {
|
|
@@ -14855,8 +14692,115 @@ class NamiCampaignManager {
|
|
|
14855
14692
|
}
|
|
14856
14693
|
return { type, value };
|
|
14857
14694
|
}
|
|
14858
|
-
}
|
|
14859
|
-
NamiCampaignManager.instance = new NamiCampaignManager();
|
|
14695
|
+
};
|
|
14696
|
+
NamiCampaignManager$1.instance = new NamiCampaignManager$1();
|
|
14697
|
+
|
|
14698
|
+
// Re-export the class itself, typed as the narrow public interface. The
|
|
14699
|
+
// runtime value IS the class (same object identity), so `jest.spyOn(...)`
|
|
14700
|
+
// in tests intercepts the same method that internal callers reach via
|
|
14701
|
+
// direct class import — no method-call indirection. The public `.d.ts`
|
|
14702
|
+
// however only sees the `NamiCampaignManagerStatic` surface: no
|
|
14703
|
+
// `.instance`, no `register()`-internal helpers, no private statics.
|
|
14704
|
+
// Renderer/test code that needs the unrestricted class imports from
|
|
14705
|
+
// `@namiml/sdk-core/internal`. See NAM-1207.
|
|
14706
|
+
const NamiCampaignManager = NamiCampaignManager$1;
|
|
14707
|
+
|
|
14708
|
+
// Re-export the class itself, typed as the narrow public interface. Same
|
|
14709
|
+
// object identity as the underlying class so jest.spyOn works. See
|
|
14710
|
+
// `src/managers/campaign.ts` and NAM-1207 for the full rationale.
|
|
14711
|
+
const NamiCustomerManager = NamiCustomerManager$1;
|
|
14712
|
+
|
|
14713
|
+
/**
|
|
14714
|
+
* @class NamiEntitlementManager
|
|
14715
|
+
* Contains all methods and objects to work with entitlements in the SDK.
|
|
14716
|
+
*/
|
|
14717
|
+
let NamiEntitlementManager$1 = class NamiEntitlementManager {
|
|
14718
|
+
constructor() {
|
|
14719
|
+
this.emitter = NamiEventEmitter.getInstance();
|
|
14720
|
+
}
|
|
14721
|
+
/**
|
|
14722
|
+
* @returns {NamiEntitlement[]} A list of currently active entitlements
|
|
14723
|
+
*/
|
|
14724
|
+
static active() {
|
|
14725
|
+
if (!hasPurchaseManagement()) {
|
|
14726
|
+
return createNamiEntitlements();
|
|
14727
|
+
}
|
|
14728
|
+
return activeEntitlements();
|
|
14729
|
+
}
|
|
14730
|
+
/**
|
|
14731
|
+
* Checks if a Nami Control Center defined Entitlement has at least one backing purchase
|
|
14732
|
+
* and it's not expired.
|
|
14733
|
+
*
|
|
14734
|
+
* @param referenceId - entitlement referenceId
|
|
14735
|
+
* @returns {boolean} True if the entitlement is active for given referenceId, false otherwise.
|
|
14736
|
+
*/
|
|
14737
|
+
static isEntitlementActive(referenceId) {
|
|
14738
|
+
if (!hasPurchaseManagement("NamiEntitlementManager.isEntitlementActive")) {
|
|
14739
|
+
return false;
|
|
14740
|
+
}
|
|
14741
|
+
return this.active().some((entitlement) => entitlement.referenceId == referenceId);
|
|
14742
|
+
}
|
|
14743
|
+
/**
|
|
14744
|
+
* Asks Nami to fetch the latest active entitlements
|
|
14745
|
+
*
|
|
14746
|
+
* @returns {Promise<NamiEntitlement[]>} A promise that resolves to a list of NamiEntitlement
|
|
14747
|
+
*/
|
|
14748
|
+
static async refresh() {
|
|
14749
|
+
if (!this.instance.sdkInitialized) {
|
|
14750
|
+
throw new SDKNotInitializedError();
|
|
14751
|
+
}
|
|
14752
|
+
if (!hasPurchaseManagement("NamiEntitlementManager.refresh")) {
|
|
14753
|
+
return [];
|
|
14754
|
+
}
|
|
14755
|
+
await EntitlementRepository.instance.fetchActiveEntitlements();
|
|
14756
|
+
return activeEntitlements();
|
|
14757
|
+
}
|
|
14758
|
+
/**
|
|
14759
|
+
* When there has been an update received to the active entitlements,
|
|
14760
|
+
* the Nami SDK will provide notification of that event through
|
|
14761
|
+
* this callback with list of active [NamiEntitlement]
|
|
14762
|
+
*
|
|
14763
|
+
* @param {NamiActiveEntitlementsHandler} handler - The callback function that will be invoked when the campaign list is updated.
|
|
14764
|
+
* @returns {Callback} A function that can be called to unregister the handler.
|
|
14765
|
+
*/
|
|
14766
|
+
static registerActiveEntitlementsHandler(handler) {
|
|
14767
|
+
if (hasPurchaseManagement("NamiEntitlementManager.registerActiveEntitlementsHandler")) {
|
|
14768
|
+
this.instance.emitter.addListener(exports.AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED, handler);
|
|
14769
|
+
return () => {
|
|
14770
|
+
this.instance.emitter.removeListener(exports.AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED, handler);
|
|
14771
|
+
};
|
|
14772
|
+
}
|
|
14773
|
+
}
|
|
14774
|
+
/**
|
|
14775
|
+
* Clear any provisional entitlement grants, which are entitlements issued on-device only.
|
|
14776
|
+
* Useful for development and purchase testing. Not recommended to be called in production.
|
|
14777
|
+
*/
|
|
14778
|
+
static clearProvisionalEntitlementGrants() {
|
|
14779
|
+
let entitlements = activeEntitlements();
|
|
14780
|
+
entitlements = entitlements.filter((entitlement) => {
|
|
14781
|
+
return entitlement.expires && entitlement.expires > new Date().valueOf();
|
|
14782
|
+
});
|
|
14783
|
+
storageService.setNamiEntitlements(exports.LOCAL_NAMI_ENTITLEMENTS, entitlements);
|
|
14784
|
+
this.instance.emitter.emit(exports.AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED);
|
|
14785
|
+
}
|
|
14786
|
+
/**
|
|
14787
|
+
* Private Instance Methods
|
|
14788
|
+
*/
|
|
14789
|
+
get sdkInitialized() {
|
|
14790
|
+
return Nami.instance.isInitialized;
|
|
14791
|
+
}
|
|
14792
|
+
};
|
|
14793
|
+
NamiEntitlementManager$1.instance = new NamiEntitlementManager$1();
|
|
14794
|
+
|
|
14795
|
+
// Re-export the class itself, typed as the narrow public interface. Same
|
|
14796
|
+
// object identity as the underlying class so jest.spyOn works. See
|
|
14797
|
+
// `src/managers/campaign.ts` and NAM-1207.
|
|
14798
|
+
const NamiEntitlementManager = NamiEntitlementManager$1;
|
|
14799
|
+
|
|
14800
|
+
// Re-export the class itself, typed as the narrow public interface. Same
|
|
14801
|
+
// object identity as the underlying class so jest.spyOn works. See
|
|
14802
|
+
// `src/managers/campaign.ts` and NAM-1207.
|
|
14803
|
+
const NamiFlowManager = NamiFlowManager$1;
|
|
14860
14804
|
|
|
14861
14805
|
const postConversion = async (transactionInfo) => {
|
|
14862
14806
|
if (isAnonymousMode()) {
|
|
@@ -14875,7 +14819,7 @@ const postConversion = async (transactionInfo) => {
|
|
|
14875
14819
|
* @class NamiPaywallManager
|
|
14876
14820
|
* Provides methods for managing all aspects of a paywall in the Nami SDK.
|
|
14877
14821
|
*/
|
|
14878
|
-
class NamiPaywallManager {
|
|
14822
|
+
let NamiPaywallManager$1 = class NamiPaywallManager {
|
|
14879
14823
|
constructor() {
|
|
14880
14824
|
this.emitter = NamiEventEmitter.getInstance();
|
|
14881
14825
|
}
|
|
@@ -14958,14 +14902,14 @@ class NamiPaywallManager {
|
|
|
14958
14902
|
static async buySkuComplete(purchase) {
|
|
14959
14903
|
// clear loading indicator
|
|
14960
14904
|
PaywallState.setPurchaseInProgress(false);
|
|
14961
|
-
if (NamiFlowManager.instance.flowOpen) {
|
|
14962
|
-
const flow = NamiFlowManager.instance.currentFlow;
|
|
14905
|
+
if (NamiFlowManager$1.instance.flowOpen) {
|
|
14906
|
+
const flow = NamiFlowManager$1.instance.currentFlow;
|
|
14963
14907
|
const currentStep = flow?.currentFlowStep;
|
|
14964
14908
|
if (flow && currentStep) {
|
|
14965
14909
|
flow.executeLifecycle(currentStep, NamiReservedActions.PURCHASE_SUCCESS);
|
|
14966
14910
|
}
|
|
14967
14911
|
}
|
|
14968
|
-
if (NamiCustomerManager.inAnonymousMode()) {
|
|
14912
|
+
if (NamiCustomerManager$1.inAnonymousMode()) {
|
|
14969
14913
|
logger.debug("Skipping purchase validation - anonymous mode");
|
|
14970
14914
|
return;
|
|
14971
14915
|
}
|
|
@@ -15046,142 +14990,19 @@ class NamiPaywallManager {
|
|
|
15046
14990
|
get sdkInitialized() {
|
|
15047
14991
|
return Nami.instance.isInitialized;
|
|
15048
14992
|
}
|
|
15049
|
-
}
|
|
15050
|
-
NamiPaywallManager.instance = new NamiPaywallManager();
|
|
15051
|
-
NamiPaywallManager.emitter = NamiEventEmitter.getInstance();
|
|
14993
|
+
};
|
|
14994
|
+
NamiPaywallManager$1.instance = new NamiPaywallManager$1();
|
|
14995
|
+
NamiPaywallManager$1.emitter = NamiEventEmitter.getInstance();
|
|
15052
14996
|
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
class NamiEntitlementManager {
|
|
15058
|
-
constructor() {
|
|
15059
|
-
this.emitter = NamiEventEmitter.getInstance();
|
|
15060
|
-
}
|
|
15061
|
-
/**
|
|
15062
|
-
* @returns {NamiEntitlement[]} A list of currently active entitlements
|
|
15063
|
-
*/
|
|
15064
|
-
static active() {
|
|
15065
|
-
if (!hasPurchaseManagement()) {
|
|
15066
|
-
return createNamiEntitlements();
|
|
15067
|
-
}
|
|
15068
|
-
return activeEntitlements();
|
|
15069
|
-
}
|
|
15070
|
-
/**
|
|
15071
|
-
* Checks if a Nami Control Center defined Entitlement has at least one backing purchase
|
|
15072
|
-
* and it's not expired.
|
|
15073
|
-
*
|
|
15074
|
-
* @param referenceId - entitlement referenceId
|
|
15075
|
-
* @returns {boolean} True if the entitlement is active for given referenceId, false otherwise.
|
|
15076
|
-
*/
|
|
15077
|
-
static isEntitlementActive(referenceId) {
|
|
15078
|
-
if (!hasPurchaseManagement("NamiEntitlementManager.isEntitlementActive")) {
|
|
15079
|
-
return false;
|
|
15080
|
-
}
|
|
15081
|
-
return this.active().some((entitlement) => entitlement.referenceId == referenceId);
|
|
15082
|
-
}
|
|
15083
|
-
/**
|
|
15084
|
-
* Asks Nami to fetch the latest active entitlements
|
|
15085
|
-
*
|
|
15086
|
-
* @returns {Promise<NamiEntitlement[]>} A promise that resolves to a list of NamiEntitlement
|
|
15087
|
-
*/
|
|
15088
|
-
static async refresh() {
|
|
15089
|
-
if (!this.instance.sdkInitialized) {
|
|
15090
|
-
throw new SDKNotInitializedError();
|
|
15091
|
-
}
|
|
15092
|
-
if (!hasPurchaseManagement("NamiEntitlementManager.refresh")) {
|
|
15093
|
-
return [];
|
|
15094
|
-
}
|
|
15095
|
-
await EntitlementRepository.instance.fetchActiveEntitlements();
|
|
15096
|
-
return activeEntitlements();
|
|
15097
|
-
}
|
|
15098
|
-
/**
|
|
15099
|
-
* When there has been an update received to the active entitlements,
|
|
15100
|
-
* the Nami SDK will provide notification of that event through
|
|
15101
|
-
* this callback with list of active [NamiEntitlement]
|
|
15102
|
-
*
|
|
15103
|
-
* @param {NamiActiveEntitlementsHandler} handler - The callback function that will be invoked when the campaign list is updated.
|
|
15104
|
-
* @returns {Callback} A function that can be called to unregister the handler.
|
|
15105
|
-
*/
|
|
15106
|
-
static registerActiveEntitlementsHandler(handler) {
|
|
15107
|
-
if (hasPurchaseManagement("NamiEntitlementManager.registerActiveEntitlementsHandler")) {
|
|
15108
|
-
this.instance.emitter.addListener(exports.AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED, handler);
|
|
15109
|
-
return () => {
|
|
15110
|
-
this.instance.emitter.removeListener(exports.AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED, handler);
|
|
15111
|
-
};
|
|
15112
|
-
}
|
|
15113
|
-
}
|
|
15114
|
-
/**
|
|
15115
|
-
* Clear any provisional entitlement grants, which are entitlements issued on-device only.
|
|
15116
|
-
* Useful for development and purchase testing. Not recommended to be called in production.
|
|
15117
|
-
*/
|
|
15118
|
-
static clearProvisionalEntitlementGrants() {
|
|
15119
|
-
let entitlements = activeEntitlements();
|
|
15120
|
-
entitlements = entitlements.filter((entitlement) => {
|
|
15121
|
-
return entitlement.expires && entitlement.expires > new Date().valueOf();
|
|
15122
|
-
});
|
|
15123
|
-
storageService.setNamiEntitlements(exports.LOCAL_NAMI_ENTITLEMENTS, entitlements);
|
|
15124
|
-
this.instance.emitter.emit(exports.AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED);
|
|
15125
|
-
}
|
|
15126
|
-
/**
|
|
15127
|
-
* Private Instance Methods
|
|
15128
|
-
*/
|
|
15129
|
-
get sdkInitialized() {
|
|
15130
|
-
return Nami.instance.isInitialized;
|
|
15131
|
-
}
|
|
15132
|
-
}
|
|
15133
|
-
NamiEntitlementManager.instance = new NamiEntitlementManager();
|
|
14997
|
+
// Re-export the class itself, typed as the narrow public interface. Same
|
|
14998
|
+
// object identity as the underlying class so jest.spyOn works. See
|
|
14999
|
+
// `src/managers/campaign.ts` and NAM-1207.
|
|
15000
|
+
const NamiPaywallManager = NamiPaywallManager$1;
|
|
15134
15001
|
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
* This allows you to intercept a handoff step in a Nami Flow and execute custom logic
|
|
15140
|
-
*
|
|
15141
|
-
* @param handoffStepHandler - A callback function that will be called when a handoff occurs.
|
|
15142
|
-
* It receives the `handoffTag` string (identifying the step) and an optional `handoffData`
|
|
15143
|
-
* object with additional context. If `undefined`, the current handler is cleared.
|
|
15144
|
-
*
|
|
15145
|
-
*/
|
|
15146
|
-
registerStepHandoff: NamiFlowManager.registerStepHandoff.bind(NamiFlowManager),
|
|
15147
|
-
/**
|
|
15148
|
-
* Registers a handler to be invoked when events are emitted.
|
|
15149
|
-
*
|
|
15150
|
-
* This enables you to use your own custom event tracking.
|
|
15151
|
-
*
|
|
15152
|
-
* @param eventHandler - A callback function that will be called when an event occurs.
|
|
15153
|
-
* The argument is a key-value object containing event data.
|
|
15154
|
-
* If `undefined`, the current handler is cleared
|
|
15155
|
-
*
|
|
15156
|
-
*/
|
|
15157
|
-
registerEventHandler: NamiFlowManager.registerEventHandler.bind(NamiFlowManager),
|
|
15158
|
-
/**
|
|
15159
|
-
* Resumes the Nami Flow after a handoff has been completed.
|
|
15160
|
-
*
|
|
15161
|
-
* This should be called by once any custom logic associated with
|
|
15162
|
-
* a handoff has completed.
|
|
15163
|
-
* It signals to continue to the next step in the flow sequence.
|
|
15164
|
-
*/
|
|
15165
|
-
resume: NamiFlowManager.resume.bind(NamiFlowManager),
|
|
15166
|
-
/**
|
|
15167
|
-
* Finishes the current flow programmatically.
|
|
15168
|
-
*
|
|
15169
|
-
* This can be used to end the flow at any point, typically after a handoff or custom logic.
|
|
15170
|
-
*/
|
|
15171
|
-
finish: NamiFlowManager.finish.bind(NamiFlowManager),
|
|
15172
|
-
/**
|
|
15173
|
-
* Pauses the current flow.
|
|
15174
|
-
*
|
|
15175
|
-
* This can be used to temporarily halt the flow, typically in response to user input or other events.
|
|
15176
|
-
*/
|
|
15177
|
-
pause: NamiFlowManager.pause.bind(NamiFlowManager),
|
|
15178
|
-
/**
|
|
15179
|
-
* Checks if a flow is currently open.
|
|
15180
|
-
*
|
|
15181
|
-
* @returns {boolean} - True if a flow is open, false otherwise.
|
|
15182
|
-
*/
|
|
15183
|
-
isFlowOpen: NamiFlowManager.isFlowOpen.bind(NamiFlowManager),
|
|
15184
|
-
});
|
|
15002
|
+
// Re-export the class itself, typed as the narrow public interface. Same
|
|
15003
|
+
// object identity as the underlying class so jest.spyOn works. See
|
|
15004
|
+
// `src/managers/campaign.ts` and NAM-1207.
|
|
15005
|
+
const NamiPurchaseManager = NamiPurchaseManager$1;
|
|
15185
15006
|
|
|
15186
15007
|
const BorderMap = {
|
|
15187
15008
|
upperLeft: 'border-top-left-radius',
|
|
@@ -64435,29 +64256,6 @@ const convertLocale = (locale) => {
|
|
|
64435
64256
|
return intlLocale.language + (intlLocale.region ?? intlLocale.script ?? '');
|
|
64436
64257
|
};
|
|
64437
64258
|
|
|
64438
|
-
/**
|
|
64439
|
-
* Coerces the four launch-context wire-format variants of a boolean —
|
|
64440
|
-
* `true`, `false`, `"true"`, `"false"` — into a JS `boolean`.
|
|
64441
|
-
*
|
|
64442
|
-
* Returns `undefined` for everything else (case-variant strings, numbers,
|
|
64443
|
-
* `null`, `undefined`, empty string, objects). Callers decide how to treat
|
|
64444
|
-
* the `undefined` case; the helper deliberately does not coerce numerics or
|
|
64445
|
-
* mixed-case strings so unintended truthy-by-presence behavior doesn't sneak
|
|
64446
|
-
* back in.
|
|
64447
|
-
*/
|
|
64448
|
-
function coerceBooleanish(value) {
|
|
64449
|
-
if (value === true || value === false) {
|
|
64450
|
-
return value;
|
|
64451
|
-
}
|
|
64452
|
-
if (typeof value === 'string') {
|
|
64453
|
-
if (value === 'true')
|
|
64454
|
-
return true;
|
|
64455
|
-
if (value === 'false')
|
|
64456
|
-
return false;
|
|
64457
|
-
}
|
|
64458
|
-
return undefined;
|
|
64459
|
-
}
|
|
64460
|
-
|
|
64461
64259
|
/**
|
|
64462
64260
|
* Components that are skipped entirely (they and their subtree do not
|
|
64463
64261
|
* contribute text to the page-level announcement).
|
|
@@ -64734,7 +64532,6 @@ exports.NamiFlowManager = NamiFlowManager;
|
|
|
64734
64532
|
exports.NamiFlowStepType = NamiFlowStepType;
|
|
64735
64533
|
exports.NamiPaywallManager = NamiPaywallManager;
|
|
64736
64534
|
exports.NamiPaywallManagerEvents = exports.PaywallManagerEvents;
|
|
64737
|
-
exports.NamiProfileManager = NamiProfileManager;
|
|
64738
64535
|
exports.NamiPurchaseManager = NamiPurchaseManager;
|
|
64739
64536
|
exports.NamiRefs = NamiRefs;
|
|
64740
64537
|
exports.NamiReservedActions = NamiReservedActions;
|
|
@@ -64750,6 +64547,7 @@ exports.SHOULD_SHOW_LOADING_INDICATOR = SHOULD_SHOW_LOADING_INDICATOR;
|
|
|
64750
64547
|
exports.SessionService = SessionService;
|
|
64751
64548
|
exports.SimpleEventTarget = SimpleEventTarget;
|
|
64752
64549
|
exports.StorageService = StorageService;
|
|
64550
|
+
exports._NamiProfileManager = NamiProfileManager;
|
|
64753
64551
|
exports.activateEntitlementByPurchase = activateEntitlementByPurchase;
|
|
64754
64552
|
exports.activeEntitlements = activeEntitlements;
|
|
64755
64553
|
exports.aggregateScreenreaderText = aggregateScreenreaderText;
|
|
@@ -64761,7 +64559,6 @@ exports.bestUrlCampaignMatch = bestUrlCampaignMatch;
|
|
|
64761
64559
|
exports.bigintToUuid = bigintToUuid;
|
|
64762
64560
|
exports.checkAnySkuHasPromoOffer = checkAnySkuHasPromoOffer;
|
|
64763
64561
|
exports.checkAnySkuHasTrialOffer = checkAnySkuHasTrialOffer;
|
|
64764
|
-
exports.coerceBooleanish = coerceBooleanish;
|
|
64765
64562
|
exports.convertISO8601PeriodToText = convertISO8601PeriodToText;
|
|
64766
64563
|
exports.convertLocale = convertLocale;
|
|
64767
64564
|
exports.convertOfferToPricingPhase = convertOfferToPricingPhase;
|