@mochabug/adapt-sdk 0.1.3 → 0.1.4
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/cjs/frontend.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var d=(e,n)=>{for(var o in n)s(e,o,{get:n[o],enumerable:!0})},u=(e,n,o,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of f(n))!w.call(e,t)&&t!==o&&s(e,t,{get:()=>n[t],enumerable:!(a=c(n,t))||a.enumerable});return e};var k=e=>u(s({},"__esModule",{value:!0}),e);var y={};d(y,{getToken:()=>g});module.exports=k(y);var r=null;function g(e=!1){if(e)return"dev-token";if(r!==null)return r;let n="mb_token";if(typeof globalThis.window>"u"||typeof globalThis.location>"u")throw new Error("getToken() is only available in browser environments");let o=globalThis,a=o.location.hash.slice(1);if(!a)throw new Error("No token found in URL hash");let t=new URLSearchParams(a),i=t.get(n);if(!i)throw new Error('Token "mb_token" not found in URL hash');r=decodeURIComponent(i),t.delete(n);let l=t.toString(),h=o.location.pathname+o.location.search+(l?"#"+l:"");return o.history.replaceState(null,"",h),r}0&&(module.exports={getToken});
|
|
2
2
|
//# sourceMappingURL=frontend.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/frontend.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Simple token utility for waiting on hash-based tokens\n */\n\n/**\n *
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["frontend_exports", "__export", "getToken", "__toCommonJS", "isDevelopment", "tokenKey", "win", "hash", "params", "token", "newHash", "newUrl"]
|
|
4
|
+
"sourcesContent": ["/**\n * Simple token utility for waiting on hash-based tokens\n */\n\n/**\n * Simple token utility for waiting on hash-based tokens\n */\n\nlet cachedToken: string | null = null;\n\n/**\n * Gets the token from URL hash (first call) or returns cached value (subsequent calls)\n * @param isDevelopment - If true, returns 'dev-token' for local development\n * @returns The token string\n */\nexport function getToken(isDevelopment = false): string {\n // Development mode - return immediately\n if (isDevelopment) {\n return 'dev-token';\n }\n\n // Return cached token if already retrieved\n if (cachedToken !== null) {\n return cachedToken;\n }\n\n const tokenKey = 'mb_token';\n\n // Non-browser environment - throw error\n if (\n typeof (globalThis as any).window === 'undefined' ||\n typeof (globalThis as any).location === 'undefined'\n ) {\n throw new Error('getToken() is only available in browser environments');\n }\n\n const win = globalThis as any;\n\n const hash = win.location.hash.slice(1);\n if (!hash) {\n throw new Error('No token found in URL hash');\n }\n\n const params = new URLSearchParams(hash);\n const token = params.get(tokenKey);\n if (!token) {\n throw new Error('Token \"mb_token\" not found in URL hash');\n }\n\n // Cache the token BEFORE removing from URL\n cachedToken = decodeURIComponent(token);\n\n // Clean URL\n params.delete(tokenKey);\n const newHash = params.toString();\n const newUrl =\n win.location.pathname +\n win.location.search +\n (newHash ? '#' + newHash : '');\n win.history.replaceState(null, '', newUrl);\n\n return cachedToken;\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAQA,IAAII,EAA6B,KAO1B,SAASF,EAASG,EAAgB,GAAe,CAEtD,GAAIA,EACF,MAAO,YAIT,GAAID,IAAgB,KAClB,OAAOA,EAGT,IAAME,EAAW,WAGjB,GACE,OAAQ,WAAmB,OAAW,KACtC,OAAQ,WAAmB,SAAa,IAExC,MAAM,IAAI,MAAM,sDAAsD,EAGxE,IAAMC,EAAM,WAENC,EAAOD,EAAI,SAAS,KAAK,MAAM,CAAC,EACtC,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,4BAA4B,EAG9C,IAAMC,EAAS,IAAI,gBAAgBD,CAAI,EACjCE,EAAQD,EAAO,IAAIH,CAAQ,EACjC,GAAI,CAACI,EACH,MAAM,IAAI,MAAM,wCAAwC,EAI1DN,EAAc,mBAAmBM,CAAK,EAGtCD,EAAO,OAAOH,CAAQ,EACtB,IAAMK,EAAUF,EAAO,SAAS,EAC1BG,EACJL,EAAI,SAAS,SACbA,EAAI,SAAS,QACZI,EAAU,IAAMA,EAAU,IAC7B,OAAAJ,EAAI,QAAQ,aAAa,KAAM,GAAIK,CAAM,EAElCR,CACT",
|
|
6
|
+
"names": ["frontend_exports", "__export", "getToken", "__toCommonJS", "cachedToken", "isDevelopment", "tokenKey", "win", "hash", "params", "token", "newHash", "newUrl"]
|
|
7
7
|
}
|
package/dist/esm/frontend.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
var e=null;function h(i=!1){if(i)return"dev-token";if(e!==null)return e;let t="mb_token";if(typeof globalThis.window>"u"||typeof globalThis.location>"u")throw new Error("getToken() is only available in browser environments");let n=globalThis,a=n.location.hash.slice(1);if(!a)throw new Error("No token found in URL hash");let o=new URLSearchParams(a),r=o.get(t);if(!r)throw new Error('Token "mb_token" not found in URL hash');e=decodeURIComponent(r),o.delete(t);let s=o.toString(),l=n.location.pathname+n.location.search+(s?"#"+s:"");return n.history.replaceState(null,"",l),e}export{h as getToken};
|
|
2
2
|
//# sourceMappingURL=frontend.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/frontend.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Simple token utility for waiting on hash-based tokens\n */\n\n/**\n *
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["getToken", "isDevelopment", "tokenKey", "win", "hash", "params", "token", "newHash", "newUrl"]
|
|
4
|
+
"sourcesContent": ["/**\n * Simple token utility for waiting on hash-based tokens\n */\n\n/**\n * Simple token utility for waiting on hash-based tokens\n */\n\nlet cachedToken: string | null = null;\n\n/**\n * Gets the token from URL hash (first call) or returns cached value (subsequent calls)\n * @param isDevelopment - If true, returns 'dev-token' for local development\n * @returns The token string\n */\nexport function getToken(isDevelopment = false): string {\n // Development mode - return immediately\n if (isDevelopment) {\n return 'dev-token';\n }\n\n // Return cached token if already retrieved\n if (cachedToken !== null) {\n return cachedToken;\n }\n\n const tokenKey = 'mb_token';\n\n // Non-browser environment - throw error\n if (\n typeof (globalThis as any).window === 'undefined' ||\n typeof (globalThis as any).location === 'undefined'\n ) {\n throw new Error('getToken() is only available in browser environments');\n }\n\n const win = globalThis as any;\n\n const hash = win.location.hash.slice(1);\n if (!hash) {\n throw new Error('No token found in URL hash');\n }\n\n const params = new URLSearchParams(hash);\n const token = params.get(tokenKey);\n if (!token) {\n throw new Error('Token \"mb_token\" not found in URL hash');\n }\n\n // Cache the token BEFORE removing from URL\n cachedToken = decodeURIComponent(token);\n\n // Clean URL\n params.delete(tokenKey);\n const newHash = params.toString();\n const newUrl =\n win.location.pathname +\n win.location.search +\n (newHash ? '#' + newHash : '');\n win.history.replaceState(null, '', newUrl);\n\n return cachedToken;\n}\n"],
|
|
5
|
+
"mappings": "AAQA,IAAIA,EAA6B,KAO1B,SAASC,EAASC,EAAgB,GAAe,CAEtD,GAAIA,EACF,MAAO,YAIT,GAAIF,IAAgB,KAClB,OAAOA,EAGT,IAAMG,EAAW,WAGjB,GACE,OAAQ,WAAmB,OAAW,KACtC,OAAQ,WAAmB,SAAa,IAExC,MAAM,IAAI,MAAM,sDAAsD,EAGxE,IAAMC,EAAM,WAENC,EAAOD,EAAI,SAAS,KAAK,MAAM,CAAC,EACtC,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,4BAA4B,EAG9C,IAAMC,EAAS,IAAI,gBAAgBD,CAAI,EACjCE,EAAQD,EAAO,IAAIH,CAAQ,EACjC,GAAI,CAACI,EACH,MAAM,IAAI,MAAM,wCAAwC,EAI1DP,EAAc,mBAAmBO,CAAK,EAGtCD,EAAO,OAAOH,CAAQ,EACtB,IAAMK,EAAUF,EAAO,SAAS,EAC1BG,EACJL,EAAI,SAAS,SACbA,EAAI,SAAS,QACZI,EAAU,IAAMA,EAAU,IAC7B,OAAAJ,EAAI,QAAQ,aAAa,KAAM,GAAIK,CAAM,EAElCT,CACT",
|
|
6
|
+
"names": ["cachedToken", "getToken", "isDevelopment", "tokenKey", "win", "hash", "params", "token", "newHash", "newUrl"]
|
|
7
7
|
}
|
package/dist/frontend.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Simple token utility for waiting on hash-based tokens
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param isDevelopment - If true,
|
|
7
|
-
* @returns
|
|
5
|
+
* Gets the token from URL hash (first call) or returns cached value (subsequent calls)
|
|
6
|
+
* @param isDevelopment - If true, returns 'dev-token' for local development
|
|
7
|
+
* @returns The token string
|
|
8
8
|
*/
|
|
9
9
|
export declare function getToken(isDevelopment?: boolean): string;
|
|
10
10
|
//# sourceMappingURL=frontend.d.ts.map
|
package/dist/frontend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../src/frontend.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../src/frontend.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,aAAa,UAAQ,GAAG,MAAM,CA+CtD"}
|