@saasquatch/component-environment 1.0.9-0 → 1.0.9
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.d.ts +1 -12
- package/dist/index.js +0 -52
- package/dist/index.mjs +0 -47
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,20 +7,14 @@ declare global {
|
|
|
7
7
|
squatchUserIdentity?: ContextProvider<UserIdentity | undefined>;
|
|
8
8
|
squatchLocale?: ContextProvider<string | undefined>;
|
|
9
9
|
squatchProgramId?: ContextProvider<string | undefined>;
|
|
10
|
-
squatchVerification?: ContextProvider<VerificationContext | undefined>;
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
declare type UserContextName = "sq:user-identity";
|
|
14
13
|
declare type LocaleContextName = "sq:locale";
|
|
15
14
|
declare type ProgramContextName = "sq:program-id";
|
|
16
|
-
declare type VerificationContextName = "sq:verification";
|
|
17
15
|
declare const USER_CONTEXT_NAME: UserContextName;
|
|
18
16
|
declare const LOCALE_CONTEXT_NAME: LocaleContextName;
|
|
19
17
|
declare const PROGRAM_CONTEXT_NAME: ProgramContextName;
|
|
20
|
-
declare const VERIFICATION_CONTEXT_NAME: VerificationContextName;
|
|
21
|
-
declare type VerificationContext = {
|
|
22
|
-
token: string;
|
|
23
|
-
};
|
|
24
18
|
/**
|
|
25
19
|
* The value stored in the UserContext
|
|
26
20
|
*/
|
|
@@ -302,9 +296,4 @@ declare function setProgramId(programId: string | undefined): void;
|
|
|
302
296
|
*/
|
|
303
297
|
declare function getProgramId(): string | undefined;
|
|
304
298
|
|
|
305
|
-
|
|
306
|
-
declare function checkVerificationToken(token: string): boolean;
|
|
307
|
-
declare function setVerificationContext(context: VerificationContext): void;
|
|
308
|
-
declare function getVerificationContext(): VerificationContext | undefined;
|
|
309
|
-
|
|
310
|
-
export { BrowserHistory, DEFAULT_MEDIUM, DecodedSquatchJWT, DecodedWidgetAPIJWT, EngagementMedium, Environment, EnvironmentSDK, HistoryEntry, LOCALE_CONTEXT_NAME, LazyHistory, LocaleContextName, MemoryHistory, PROGRAM_CONTEXT_NAME, PortalEnv, ProgramContextName, SquatchAdmin, SquatchAndroid, SquatchJS2, USER_CONTEXT_NAME, UserContextName, UserId, UserIdentity, VERIFICATION_CONTEXT_NAME, VerificationContext, VerificationContextName, WidgetIdent, checkVerificationToken, getAppDomain, getEngagementMedium, getEnvironment, getEnvironmentSDK, getLocale, getProgramId, getTenantAlias, getUserIdentity, getVerificationContext, _default as history, isDemo, lazilyStartLocaleContext, lazilyStartProgramContext, lazilyStartUserContext, lazilyStartVerificationContext, setLocale, setProgramId, setUserIdentity, setVerificationContext, userIdentityFromJwt, validateLocale };
|
|
299
|
+
export { BrowserHistory, DEFAULT_MEDIUM, DecodedSquatchJWT, DecodedWidgetAPIJWT, EngagementMedium, Environment, EnvironmentSDK, HistoryEntry, LOCALE_CONTEXT_NAME, LazyHistory, LocaleContextName, MemoryHistory, PROGRAM_CONTEXT_NAME, PortalEnv, ProgramContextName, SquatchAdmin, SquatchAndroid, SquatchJS2, USER_CONTEXT_NAME, UserContextName, UserId, UserIdentity, WidgetIdent, getAppDomain, getEngagementMedium, getEnvironment, getEnvironmentSDK, getLocale, getProgramId, getTenantAlias, getUserIdentity, _default as history, isDemo, lazilyStartLocaleContext, lazilyStartProgramContext, lazilyStartUserContext, setLocale, setProgramId, setUserIdentity, userIdentityFromJwt, validateLocale };
|
package/dist/index.js
CHANGED
|
@@ -47,8 +47,6 @@ __export(src_exports, {
|
|
|
47
47
|
MemoryHistory: () => MemoryHistory,
|
|
48
48
|
PROGRAM_CONTEXT_NAME: () => PROGRAM_CONTEXT_NAME,
|
|
49
49
|
USER_CONTEXT_NAME: () => USER_CONTEXT_NAME,
|
|
50
|
-
VERIFICATION_CONTEXT_NAME: () => VERIFICATION_CONTEXT_NAME,
|
|
51
|
-
checkVerificationToken: () => checkVerificationToken,
|
|
52
50
|
getAppDomain: () => getAppDomain,
|
|
53
51
|
getEngagementMedium: () => getEngagementMedium,
|
|
54
52
|
getEnvironment: () => getEnvironment,
|
|
@@ -57,17 +55,14 @@ __export(src_exports, {
|
|
|
57
55
|
getProgramId: () => getProgramId,
|
|
58
56
|
getTenantAlias: () => getTenantAlias,
|
|
59
57
|
getUserIdentity: () => getUserIdentity,
|
|
60
|
-
getVerificationContext: () => getVerificationContext,
|
|
61
58
|
history: () => history_default,
|
|
62
59
|
isDemo: () => isDemo,
|
|
63
60
|
lazilyStartLocaleContext: () => lazilyStartLocaleContext,
|
|
64
61
|
lazilyStartProgramContext: () => lazilyStartProgramContext,
|
|
65
62
|
lazilyStartUserContext: () => lazilyStartUserContext,
|
|
66
|
-
lazilyStartVerificationContext: () => lazilyStartVerificationContext,
|
|
67
63
|
setLocale: () => setLocale,
|
|
68
64
|
setProgramId: () => setProgramId,
|
|
69
65
|
setUserIdentity: () => setUserIdentity,
|
|
70
|
-
setVerificationContext: () => setVerificationContext,
|
|
71
66
|
userIdentityFromJwt: () => userIdentityFromJwt,
|
|
72
67
|
validateLocale: () => validateLocale
|
|
73
68
|
});
|
|
@@ -77,7 +72,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
77
72
|
var USER_CONTEXT_NAME = "sq:user-identity";
|
|
78
73
|
var LOCALE_CONTEXT_NAME = "sq:locale";
|
|
79
74
|
var PROGRAM_CONTEXT_NAME = "sq:program-id";
|
|
80
|
-
var VERIFICATION_CONTEXT_NAME = "sq:verification";
|
|
81
75
|
var DEFAULT_MEDIUM = "EMBED";
|
|
82
76
|
|
|
83
77
|
// src/environment.ts
|
|
@@ -626,47 +620,6 @@ function getProgramId() {
|
|
|
626
620
|
var _a;
|
|
627
621
|
return (_a = window.squatchProgramId) == null ? void 0 : _a.context;
|
|
628
622
|
}
|
|
629
|
-
|
|
630
|
-
// src/contexts/VerificationContext.ts
|
|
631
|
-
var import_equality2 = __toESM(require("@wry/equality"));
|
|
632
|
-
var import_jwt_decode2 = __toESM(require("jwt-decode"));
|
|
633
|
-
var import_dom_context5 = require("dom-context");
|
|
634
|
-
var debug8 = (...args) => debug(VERIFICATION_CONTEXT_NAME, ...args);
|
|
635
|
-
function lazilyStartVerificationContext() {
|
|
636
|
-
let globalProvider = window.squatchVerification;
|
|
637
|
-
if (!globalProvider) {
|
|
638
|
-
globalProvider = new import_dom_context5.ContextProvider({
|
|
639
|
-
element: document.documentElement,
|
|
640
|
-
initialState: void 0,
|
|
641
|
-
contextName: VERIFICATION_CONTEXT_NAME
|
|
642
|
-
}).start();
|
|
643
|
-
window.squatchVerification = globalProvider;
|
|
644
|
-
}
|
|
645
|
-
return globalProvider;
|
|
646
|
-
}
|
|
647
|
-
function checkVerificationToken(token) {
|
|
648
|
-
if (!token)
|
|
649
|
-
return false;
|
|
650
|
-
const decoded = (0, import_jwt_decode2.default)(token);
|
|
651
|
-
const isSquatchJWT = decoded.user && decoded.user.id && decoded.user.accountId;
|
|
652
|
-
if (!isSquatchJWT)
|
|
653
|
-
return false;
|
|
654
|
-
const currentUser = getUserIdentity();
|
|
655
|
-
if (decoded.user.id !== (currentUser == null ? void 0 : currentUser.id) || decoded.user.accountId !== (currentUser == null ? void 0 : currentUser.accountId))
|
|
656
|
-
return false;
|
|
657
|
-
return true;
|
|
658
|
-
}
|
|
659
|
-
function setVerificationContext(context) {
|
|
660
|
-
const globalProvider = lazilyStartVerificationContext();
|
|
661
|
-
if (!(0, import_equality2.default)(globalProvider.context, context)) {
|
|
662
|
-
debug8(`Setting verification context to [${JSON.stringify(context)}]`);
|
|
663
|
-
globalProvider.context = context;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
function getVerificationContext() {
|
|
667
|
-
var _a;
|
|
668
|
-
return (_a = window.squatchVerification) == null ? void 0 : _a.context;
|
|
669
|
-
}
|
|
670
623
|
// Annotate the CommonJS export names for ESM import in node:
|
|
671
624
|
0 && (module.exports = {
|
|
672
625
|
BrowserHistory,
|
|
@@ -676,8 +629,6 @@ function getVerificationContext() {
|
|
|
676
629
|
MemoryHistory,
|
|
677
630
|
PROGRAM_CONTEXT_NAME,
|
|
678
631
|
USER_CONTEXT_NAME,
|
|
679
|
-
VERIFICATION_CONTEXT_NAME,
|
|
680
|
-
checkVerificationToken,
|
|
681
632
|
getAppDomain,
|
|
682
633
|
getEngagementMedium,
|
|
683
634
|
getEnvironment,
|
|
@@ -686,17 +637,14 @@ function getVerificationContext() {
|
|
|
686
637
|
getProgramId,
|
|
687
638
|
getTenantAlias,
|
|
688
639
|
getUserIdentity,
|
|
689
|
-
getVerificationContext,
|
|
690
640
|
history,
|
|
691
641
|
isDemo,
|
|
692
642
|
lazilyStartLocaleContext,
|
|
693
643
|
lazilyStartProgramContext,
|
|
694
644
|
lazilyStartUserContext,
|
|
695
|
-
lazilyStartVerificationContext,
|
|
696
645
|
setLocale,
|
|
697
646
|
setProgramId,
|
|
698
647
|
setUserIdentity,
|
|
699
|
-
setVerificationContext,
|
|
700
648
|
userIdentityFromJwt,
|
|
701
649
|
validateLocale
|
|
702
650
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
23
23
|
var USER_CONTEXT_NAME = "sq:user-identity";
|
|
24
24
|
var LOCALE_CONTEXT_NAME = "sq:locale";
|
|
25
25
|
var PROGRAM_CONTEXT_NAME = "sq:program-id";
|
|
26
|
-
var VERIFICATION_CONTEXT_NAME = "sq:verification";
|
|
27
26
|
var DEFAULT_MEDIUM = "EMBED";
|
|
28
27
|
|
|
29
28
|
// src/environment.ts
|
|
@@ -572,47 +571,6 @@ function getProgramId() {
|
|
|
572
571
|
var _a;
|
|
573
572
|
return (_a = window.squatchProgramId) == null ? void 0 : _a.context;
|
|
574
573
|
}
|
|
575
|
-
|
|
576
|
-
// src/contexts/VerificationContext.ts
|
|
577
|
-
import equal2 from "@wry/equality";
|
|
578
|
-
import decode2 from "jwt-decode";
|
|
579
|
-
import { ContextProvider as ContextProvider4 } from "dom-context";
|
|
580
|
-
var debug8 = (...args) => debug(VERIFICATION_CONTEXT_NAME, ...args);
|
|
581
|
-
function lazilyStartVerificationContext() {
|
|
582
|
-
let globalProvider = window.squatchVerification;
|
|
583
|
-
if (!globalProvider) {
|
|
584
|
-
globalProvider = new ContextProvider4({
|
|
585
|
-
element: document.documentElement,
|
|
586
|
-
initialState: void 0,
|
|
587
|
-
contextName: VERIFICATION_CONTEXT_NAME
|
|
588
|
-
}).start();
|
|
589
|
-
window.squatchVerification = globalProvider;
|
|
590
|
-
}
|
|
591
|
-
return globalProvider;
|
|
592
|
-
}
|
|
593
|
-
function checkVerificationToken(token) {
|
|
594
|
-
if (!token)
|
|
595
|
-
return false;
|
|
596
|
-
const decoded = decode2(token);
|
|
597
|
-
const isSquatchJWT = decoded.user && decoded.user.id && decoded.user.accountId;
|
|
598
|
-
if (!isSquatchJWT)
|
|
599
|
-
return false;
|
|
600
|
-
const currentUser = getUserIdentity();
|
|
601
|
-
if (decoded.user.id !== (currentUser == null ? void 0 : currentUser.id) || decoded.user.accountId !== (currentUser == null ? void 0 : currentUser.accountId))
|
|
602
|
-
return false;
|
|
603
|
-
return true;
|
|
604
|
-
}
|
|
605
|
-
function setVerificationContext(context) {
|
|
606
|
-
const globalProvider = lazilyStartVerificationContext();
|
|
607
|
-
if (!equal2(globalProvider.context, context)) {
|
|
608
|
-
debug8(`Setting verification context to [${JSON.stringify(context)}]`);
|
|
609
|
-
globalProvider.context = context;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
function getVerificationContext() {
|
|
613
|
-
var _a;
|
|
614
|
-
return (_a = window.squatchVerification) == null ? void 0 : _a.context;
|
|
615
|
-
}
|
|
616
574
|
export {
|
|
617
575
|
BrowserHistory,
|
|
618
576
|
DEFAULT_MEDIUM,
|
|
@@ -621,8 +579,6 @@ export {
|
|
|
621
579
|
MemoryHistory,
|
|
622
580
|
PROGRAM_CONTEXT_NAME,
|
|
623
581
|
USER_CONTEXT_NAME,
|
|
624
|
-
VERIFICATION_CONTEXT_NAME,
|
|
625
|
-
checkVerificationToken,
|
|
626
582
|
getAppDomain,
|
|
627
583
|
getEngagementMedium,
|
|
628
584
|
getEnvironment,
|
|
@@ -631,17 +587,14 @@ export {
|
|
|
631
587
|
getProgramId,
|
|
632
588
|
getTenantAlias,
|
|
633
589
|
getUserIdentity,
|
|
634
|
-
getVerificationContext,
|
|
635
590
|
history_default as history,
|
|
636
591
|
isDemo,
|
|
637
592
|
lazilyStartLocaleContext,
|
|
638
593
|
lazilyStartProgramContext,
|
|
639
594
|
lazilyStartUserContext,
|
|
640
|
-
lazilyStartVerificationContext,
|
|
641
595
|
setLocale,
|
|
642
596
|
setProgramId,
|
|
643
597
|
setUserIdentity,
|
|
644
|
-
setVerificationContext,
|
|
645
598
|
userIdentityFromJwt,
|
|
646
599
|
validateLocale
|
|
647
600
|
};
|