@mochabug/adapt-sdk 0.1.1 → 0.1.3
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 r=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var f=(o,n)=>{for(var e in n)r(o,e,{get:n[e],enumerable:!0})},d=(o,n,e,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of c(n))!w.call(o,t)&&t!==e&&r(o,t,{get:()=>n[t],enumerable:!(a=h(n,t))||a.enumerable});return o};var k=o=>d(r({},"__esModule",{value:!0}),o);var g={};f(g,{getToken:()=>b});module.exports=k(g);function b(o=!1){if(o)return"dev-token";let n="mb_token";if(typeof globalThis.window>"u"||typeof globalThis.location>"u")throw new Error("getToken() is only available in browser environments");let e=globalThis,a=e.location.hash.slice(1);if(!a)throw new Error("No token found in URL hash");let t=new URLSearchParams(a),s=t.get("mb_token");if(!s)throw new Error('Token "mb_token" not found in URL hash');t.delete(n);let i=t.toString(),l=e.location.pathname+e.location.search+(i?"#"+i:"");return e.history.replaceState(null,"",l),decodeURIComponent(s)}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 * Waits for a token to become available in the URL hash\n * @param isDevelopment - If true, resolves immediately with 'dev-token' for local development\n * @returns Promise that resolves with the token\n */\nexport
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["frontend_exports", "__export", "getToken", "__toCommonJS", "isDevelopment", "
|
|
4
|
+
"sourcesContent": ["/**\n * Simple token utility for waiting on hash-based tokens\n */\n\n/**\n * Waits for a token to become available in the URL hash\n * @param isDevelopment - If true, resolves immediately with 'dev-token' for local development\n * @returns Promise that resolves with the token\n */\nexport function getToken(isDevelopment = false): string {\n // Development mode - return immediately\n if (isDevelopment) {\n return 'dev-token';\n }\n\n const tokenKey = 'mb_token';\n\n // Non-browser environment - throw error (using globalThis for universal compatibility)\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 // In browsers, globalThis is window, so we can use it directly\n const win = globalThis as any;\n\n const hash = win.location.hash.slice(1); // Remove leading #\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('mb_token');\n if (!token) {\n throw new Error('Token \"mb_token\" not found in URL hash');\n }\n\n // Remove the key from hash and 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 decodeURIComponent(token);\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GASO,SAASE,EAASE,EAAgB,GAAe,CAEtD,GAAIA,EACF,MAAO,YAGT,IAAMC,EAAW,WAGjB,GACE,OAAQ,WAAmB,OAAW,KACtC,OAAQ,WAAmB,SAAa,IAExC,MAAM,IAAI,MAAM,sDAAsD,EAIxE,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,IAAI,UAAU,EACnC,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,wCAAwC,EAI1DD,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,EAElC,mBAAmBF,CAAK,CACjC",
|
|
6
|
+
"names": ["frontend_exports", "__export", "getToken", "__toCommonJS", "isDevelopment", "tokenKey", "win", "hash", "params", "token", "newHash", "newUrl"]
|
|
7
7
|
}
|
package/dist/esm/frontend.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function l(r=!1){if(r)return"dev-token";let s="mb_token";if(typeof globalThis.window>"u"||typeof globalThis.location>"u")throw new Error("getToken() is only available in browser environments");let n=globalThis,e=n.location.hash.slice(1);if(!e)throw new Error("No token found in URL hash");let o=new URLSearchParams(e),t=o.get("mb_token");if(!t)throw new Error('Token "mb_token" not found in URL hash');o.delete(s);let a=o.toString(),i=n.location.pathname+n.location.search+(a?"#"+a:"");return n.history.replaceState(null,"",i),decodeURIComponent(t)}export{l 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 * Waits for a token to become available in the URL hash\n * @param isDevelopment - If true, resolves immediately with 'dev-token' for local development\n * @returns Promise that resolves with the token\n */\nexport
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["getToken", "isDevelopment", "
|
|
4
|
+
"sourcesContent": ["/**\n * Simple token utility for waiting on hash-based tokens\n */\n\n/**\n * Waits for a token to become available in the URL hash\n * @param isDevelopment - If true, resolves immediately with 'dev-token' for local development\n * @returns Promise that resolves with the token\n */\nexport function getToken(isDevelopment = false): string {\n // Development mode - return immediately\n if (isDevelopment) {\n return 'dev-token';\n }\n\n const tokenKey = 'mb_token';\n\n // Non-browser environment - throw error (using globalThis for universal compatibility)\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 // In browsers, globalThis is window, so we can use it directly\n const win = globalThis as any;\n\n const hash = win.location.hash.slice(1); // Remove leading #\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('mb_token');\n if (!token) {\n throw new Error('Token \"mb_token\" not found in URL hash');\n }\n\n // Remove the key from hash and 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 decodeURIComponent(token);\n}\n"],
|
|
5
|
+
"mappings": "AASO,SAASA,EAASC,EAAgB,GAAe,CAEtD,GAAIA,EACF,MAAO,YAGT,IAAMC,EAAW,WAGjB,GACE,OAAQ,WAAmB,OAAW,KACtC,OAAQ,WAAmB,SAAa,IAExC,MAAM,IAAI,MAAM,sDAAsD,EAIxE,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,IAAI,UAAU,EACnC,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,wCAAwC,EAI1DD,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,EAElC,mBAAmBF,CAAK,CACjC",
|
|
6
|
+
"names": ["getToken", "isDevelopment", "tokenKey", "win", "hash", "params", "token", "newHash", "newUrl"]
|
|
7
7
|
}
|
package/dist/frontend.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @param isDevelopment - If true, resolves immediately with 'dev-token' for local development
|
|
7
7
|
* @returns Promise that resolves with the token
|
|
8
8
|
*/
|
|
9
|
-
export declare function getToken(isDevelopment?: boolean):
|
|
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;AAEH;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../src/frontend.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,aAAa,UAAQ,GAAG,MAAM,CAwCtD"}
|