@memberstack/dom 2.0.6 → 2.0.8
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/lib/index.d.mts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +11 -28
- package/lib/index.mjs +11 -28
- package/package.json +1 -1
package/lib/index.d.mts
CHANGED
|
@@ -1835,7 +1835,7 @@ declare const _default: {
|
|
|
1835
1835
|
preloadModals: () => Promise<void>;
|
|
1836
1836
|
_hideLoader: (element?: HTMLElement | undefined) => void;
|
|
1837
1837
|
_showLoader: (element?: HTMLElement | undefined) => void;
|
|
1838
|
-
_showMessage: (msg: string, isError?: boolean | undefined) => Promise<void>;
|
|
1838
|
+
_showMessage: (msg: string, isError?: boolean | undefined, scopeElement?: HTMLElement | undefined) => Promise<void>;
|
|
1839
1839
|
getMemberCookie: () => string | undefined;
|
|
1840
1840
|
onAuthChange: (cb: AuthCallback) => {
|
|
1841
1841
|
unsubscribe: () => boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -1835,7 +1835,7 @@ declare const _default: {
|
|
|
1835
1835
|
preloadModals: () => Promise<void>;
|
|
1836
1836
|
_hideLoader: (element?: HTMLElement | undefined) => void;
|
|
1837
1837
|
_showLoader: (element?: HTMLElement | undefined) => void;
|
|
1838
|
-
_showMessage: (msg: string, isError?: boolean | undefined) => Promise<void>;
|
|
1838
|
+
_showMessage: (msg: string, isError?: boolean | undefined, scopeElement?: HTMLElement | undefined) => Promise<void>;
|
|
1839
1839
|
getMemberCookie: () => string | undefined;
|
|
1840
1840
|
onAuthChange: (cb: AuthCallback) => {
|
|
1841
1841
|
unsubscribe: () => boolean;
|
package/lib/index.js
CHANGED
|
@@ -286,7 +286,7 @@ var initDefaultMessageBox = () => {
|
|
|
286
286
|
addSuccessBox();
|
|
287
287
|
addErrorBox();
|
|
288
288
|
};
|
|
289
|
-
var showMessage = (msg, isError) => __async(void 0, null, function* () {
|
|
289
|
+
var showMessage = (msg, isError, scopeElement) => __async(void 0, null, function* () {
|
|
290
290
|
if (!msg)
|
|
291
291
|
return;
|
|
292
292
|
yield new Promise((resolve) => {
|
|
@@ -301,11 +301,13 @@ var showMessage = (msg, isError) => __async(void 0, null, function* () {
|
|
|
301
301
|
if (!document.querySelector("[data-ms-message='success']")) {
|
|
302
302
|
initDefaultMessageBox();
|
|
303
303
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
304
|
+
const selector = isError ? "[data-ms-message='error']" : "[data-ms-message='success']";
|
|
305
|
+
let messageBox = null;
|
|
306
|
+
if (scopeElement) {
|
|
307
|
+
messageBox = scopeElement.querySelector(selector);
|
|
308
|
+
}
|
|
309
|
+
if (!messageBox) {
|
|
310
|
+
messageBox = document.querySelector(selector);
|
|
309
311
|
}
|
|
310
312
|
if (!messageBox)
|
|
311
313
|
return;
|
|
@@ -577,13 +579,8 @@ var createRequestHandler = ({
|
|
|
577
579
|
token,
|
|
578
580
|
customEndpoint
|
|
579
581
|
}) => {
|
|
580
|
-
if (!publicKey) {
|
|
581
|
-
throw new Error(
|
|
582
|
-
"Memberstack: publicKey is required. Pass your public key to memberstack.init({ publicKey: 'pk_...' })"
|
|
583
|
-
);
|
|
584
|
-
}
|
|
585
582
|
const warnIfWrongKeyMode = (error) => {
|
|
586
|
-
if (error && typeof error === "object" && "code" in error && error.code === "generic-message" && "message" in error && typeof error.message === "string" && error.message.toLowerCase().includes("disabled") && !publicKey.includes("_sb_")) {
|
|
583
|
+
if (error && typeof error === "object" && "code" in error && error.code === "generic-message" && "message" in error && typeof error.message === "string" && error.message.toLowerCase().includes("disabled") && !(publicKey == null ? void 0 : publicKey.includes("_sb_"))) {
|
|
587
584
|
console.warn(
|
|
588
585
|
"[Memberstack] You're using a Live Mode key (pk_...). If your app hasn't been published yet, use the Test Mode key (pk_sb_...) from Dev Tools in your Memberstack dashboard."
|
|
589
586
|
);
|
|
@@ -606,9 +603,7 @@ var createRequestHandler = ({
|
|
|
606
603
|
method: data.method,
|
|
607
604
|
data: data.data,
|
|
608
605
|
url: formattedUrl,
|
|
609
|
-
headers: __spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues(
|
|
610
|
-
["X-API-Key" /* API_KEY */]: publicKey
|
|
611
|
-
}), appId && { ["X-APP-ID" /* APP_ID */]: appId }), {
|
|
606
|
+
headers: __spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, authHeader && { authorization: `Bearer ${authHeader}` }), publicKey && { ["X-API-Key" /* API_KEY */]: publicKey }), appId && { ["X-APP-ID" /* APP_ID */]: appId }), {
|
|
612
607
|
["X-User-Agent" /* USER_AGENT */]: "@memberstack/client@1.2.0"
|
|
613
608
|
}), data.contentType && { "Content-Type": data.contentType }), sessionToken && {
|
|
614
609
|
["X-Session-ID" /* SESSION_ID */]: sessionToken
|
|
@@ -655,9 +650,7 @@ var createRequestHandler = ({
|
|
|
655
650
|
options == null ? void 0 : options.token
|
|
656
651
|
].find((x) => x);
|
|
657
652
|
const formattedUrl = `${customEndpoint || endpoints.API}${url}`;
|
|
658
|
-
const fetchHeaders = __spreadProps(__spreadValues(
|
|
659
|
-
["X-API-Key" /* API_KEY */]: publicKey
|
|
660
|
-
}), appId && { ["X-APP-ID" /* APP_ID */]: appId }), {
|
|
653
|
+
const fetchHeaders = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, authHeader && { Authorization: `Bearer ${authHeader}` }), publicKey && { ["X-API-Key" /* API_KEY */]: publicKey }), appId && { ["X-APP-ID" /* APP_ID */]: appId }), {
|
|
661
654
|
["X-User-Agent" /* USER_AGENT */]: "@memberstack/client@1.2.0",
|
|
662
655
|
"Content-Type": "application/json",
|
|
663
656
|
Referer: window.location.href
|
|
@@ -3055,16 +3048,6 @@ var methods = {
|
|
|
3055
3048
|
_captchaReady: captchaReadyPromise
|
|
3056
3049
|
};
|
|
3057
3050
|
function init(props) {
|
|
3058
|
-
if (!props.publicKey) {
|
|
3059
|
-
throw new Error(
|
|
3060
|
-
"Memberstack: publicKey is required. Pass your public key to init({ publicKey: 'pk_...' }). Find your key at https://app.memberstack.com/apps"
|
|
3061
|
-
);
|
|
3062
|
-
}
|
|
3063
|
-
if (!props.publicKey.startsWith("pk_")) {
|
|
3064
|
-
throw new Error(
|
|
3065
|
-
`Memberstack: Invalid publicKey format. Keys should start with "pk_sb_" (sandbox) or "pk_" (live). Received: "${props.publicKey.slice(0, 12)}...". Find your key at https://app.memberstack.com/apps`
|
|
3066
|
-
);
|
|
3067
|
-
}
|
|
3068
3051
|
if (props.debug) {
|
|
3069
3052
|
setDebugMode(true);
|
|
3070
3053
|
debugLog(`Initializing Memberstack SDK v${SDK_VERSION}`);
|
package/lib/index.mjs
CHANGED
|
@@ -243,7 +243,7 @@ var initDefaultMessageBox = () => {
|
|
|
243
243
|
addSuccessBox();
|
|
244
244
|
addErrorBox();
|
|
245
245
|
};
|
|
246
|
-
var showMessage = (msg, isError) => __async(void 0, null, function* () {
|
|
246
|
+
var showMessage = (msg, isError, scopeElement) => __async(void 0, null, function* () {
|
|
247
247
|
if (!msg)
|
|
248
248
|
return;
|
|
249
249
|
yield new Promise((resolve) => {
|
|
@@ -258,11 +258,13 @@ var showMessage = (msg, isError) => __async(void 0, null, function* () {
|
|
|
258
258
|
if (!document.querySelector("[data-ms-message='success']")) {
|
|
259
259
|
initDefaultMessageBox();
|
|
260
260
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
const selector = isError ? "[data-ms-message='error']" : "[data-ms-message='success']";
|
|
262
|
+
let messageBox = null;
|
|
263
|
+
if (scopeElement) {
|
|
264
|
+
messageBox = scopeElement.querySelector(selector);
|
|
265
|
+
}
|
|
266
|
+
if (!messageBox) {
|
|
267
|
+
messageBox = document.querySelector(selector);
|
|
266
268
|
}
|
|
267
269
|
if (!messageBox)
|
|
268
270
|
return;
|
|
@@ -534,13 +536,8 @@ var createRequestHandler = ({
|
|
|
534
536
|
token,
|
|
535
537
|
customEndpoint
|
|
536
538
|
}) => {
|
|
537
|
-
if (!publicKey) {
|
|
538
|
-
throw new Error(
|
|
539
|
-
"Memberstack: publicKey is required. Pass your public key to memberstack.init({ publicKey: 'pk_...' })"
|
|
540
|
-
);
|
|
541
|
-
}
|
|
542
539
|
const warnIfWrongKeyMode = (error) => {
|
|
543
|
-
if (error && typeof error === "object" && "code" in error && error.code === "generic-message" && "message" in error && typeof error.message === "string" && error.message.toLowerCase().includes("disabled") && !publicKey.includes("_sb_")) {
|
|
540
|
+
if (error && typeof error === "object" && "code" in error && error.code === "generic-message" && "message" in error && typeof error.message === "string" && error.message.toLowerCase().includes("disabled") && !(publicKey == null ? void 0 : publicKey.includes("_sb_"))) {
|
|
544
541
|
console.warn(
|
|
545
542
|
"[Memberstack] You're using a Live Mode key (pk_...). If your app hasn't been published yet, use the Test Mode key (pk_sb_...) from Dev Tools in your Memberstack dashboard."
|
|
546
543
|
);
|
|
@@ -563,9 +560,7 @@ var createRequestHandler = ({
|
|
|
563
560
|
method: data.method,
|
|
564
561
|
data: data.data,
|
|
565
562
|
url: formattedUrl,
|
|
566
|
-
headers: __spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues(
|
|
567
|
-
["X-API-Key" /* API_KEY */]: publicKey
|
|
568
|
-
}), appId && { ["X-APP-ID" /* APP_ID */]: appId }), {
|
|
563
|
+
headers: __spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, authHeader && { authorization: `Bearer ${authHeader}` }), publicKey && { ["X-API-Key" /* API_KEY */]: publicKey }), appId && { ["X-APP-ID" /* APP_ID */]: appId }), {
|
|
569
564
|
["X-User-Agent" /* USER_AGENT */]: "@memberstack/client@1.2.0"
|
|
570
565
|
}), data.contentType && { "Content-Type": data.contentType }), sessionToken && {
|
|
571
566
|
["X-Session-ID" /* SESSION_ID */]: sessionToken
|
|
@@ -612,9 +607,7 @@ var createRequestHandler = ({
|
|
|
612
607
|
options == null ? void 0 : options.token
|
|
613
608
|
].find((x) => x);
|
|
614
609
|
const formattedUrl = `${customEndpoint || endpoints.API}${url}`;
|
|
615
|
-
const fetchHeaders = __spreadProps(__spreadValues(
|
|
616
|
-
["X-API-Key" /* API_KEY */]: publicKey
|
|
617
|
-
}), appId && { ["X-APP-ID" /* APP_ID */]: appId }), {
|
|
610
|
+
const fetchHeaders = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, authHeader && { Authorization: `Bearer ${authHeader}` }), publicKey && { ["X-API-Key" /* API_KEY */]: publicKey }), appId && { ["X-APP-ID" /* APP_ID */]: appId }), {
|
|
618
611
|
["X-User-Agent" /* USER_AGENT */]: "@memberstack/client@1.2.0",
|
|
619
612
|
"Content-Type": "application/json",
|
|
620
613
|
Referer: window.location.href
|
|
@@ -3012,16 +3005,6 @@ var methods = {
|
|
|
3012
3005
|
_captchaReady: captchaReadyPromise
|
|
3013
3006
|
};
|
|
3014
3007
|
function init(props) {
|
|
3015
|
-
if (!props.publicKey) {
|
|
3016
|
-
throw new Error(
|
|
3017
|
-
"Memberstack: publicKey is required. Pass your public key to init({ publicKey: 'pk_...' }). Find your key at https://app.memberstack.com/apps"
|
|
3018
|
-
);
|
|
3019
|
-
}
|
|
3020
|
-
if (!props.publicKey.startsWith("pk_")) {
|
|
3021
|
-
throw new Error(
|
|
3022
|
-
`Memberstack: Invalid publicKey format. Keys should start with "pk_sb_" (sandbox) or "pk_" (live). Received: "${props.publicKey.slice(0, 12)}...". Find your key at https://app.memberstack.com/apps`
|
|
3023
|
-
);
|
|
3024
|
-
}
|
|
3025
3008
|
if (props.debug) {
|
|
3026
3009
|
setDebugMode(true);
|
|
3027
3010
|
debugLog(`Initializing Memberstack SDK v${SDK_VERSION}`);
|