@mochabug/adapt-sdk 0.1.1 → 0.1.2
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 y={};f(y,{getToken:()=>m});module.exports=k(y);async function m(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 async function getToken(isDevelopment = false): Promise<string> {\n // Development mode - return immediately\n if (isDevelopment) {\n return 'dev-token';\n }\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
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GASA,eAAsBE,EAASE,EAAgB,GAAwB,CAErE,GAAIA,EACF,MAAO,
|
|
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 async function getToken(isDevelopment = false): Promise<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,GASA,eAAsBE,EAASE,EAAgB,GAAwB,CAErE,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
|
-
async function
|
|
1
|
+
async 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 async function getToken(isDevelopment = false): Promise<string> {\n // Development mode - return immediately\n if (isDevelopment) {\n return 'dev-token';\n }\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
|
|
5
|
-
"mappings": "AASA,eAAsBA,EAASC,EAAgB,GAAwB,CAErE,GAAIA,EACF,MAAO,
|
|
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 async function getToken(isDevelopment = false): Promise<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": "AASA,eAAsBA,EAASC,EAAgB,GAAwB,CAErE,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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../src/frontend.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,aAAa,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../src/frontend.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,aAAa,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAwCrE"}
|