@ideem/zsm-client-sdk 2.4.0 → 2.5.0
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/{RELEASE_NOTES.txt → CHANGELOG.md} +42 -6
- package/EventCoordinator.js +267 -0
- package/FIDO2Client.js +15 -0
- package/FIDO2ClientBase.js +117 -0
- package/GlobalScoping.js +8 -0
- package/IdentityIndexing.js +51 -0
- package/PluginManager.js +111 -0
- package/RelyingParty.js +15 -0
- package/RelyingPartyBase.js +197 -0
- package/UMFAClient.js +15 -0
- package/UMFAClientBase.js +125 -0
- package/Utils.js +44 -0
- package/WASMRustInterface.js +1458 -0
- package/WebAuthnClient.js +29 -0
- package/WebAuthnClientBase.js +429 -0
- package/ZSMClientSDK.js +28 -463
- package/package.json +19 -50
- package/shims/VanillaJSLoader.js +96 -0
- package/shims/es-module-shims.js +1067 -0
- package/worker.js +0 -2503
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// @ideem/zsm-client-sdk/shims/VanillaJSLoader.js (ESM; single-tag, passive loader)
|
|
2
|
+
|
|
3
|
+
/* ---------- tiny helpers ---------- */
|
|
4
|
+
const $tag = () =>
|
|
5
|
+
document.querySelector('script[type="module"][src$="shims/VanillaJSLoader.js"]') ||
|
|
6
|
+
document.currentScript ||
|
|
7
|
+
null;
|
|
8
|
+
|
|
9
|
+
const join = (base, rel) => new URL(String(rel).replace(/^\.\//, ""), base).href;
|
|
10
|
+
|
|
11
|
+
function computeNodeModulesBase({ allowGuessAtRoot = true } = {}) {
|
|
12
|
+
const el = $tag();
|
|
13
|
+
|
|
14
|
+
// 1) Explicit overrides (absolute or relative to page)
|
|
15
|
+
const override = el?.dataset?.nodeModules || window.IDEEM_NODE_MODULES;
|
|
16
|
+
if (override) return new URL(override, document.baseURI).href.replace(/\/+$/, "/");
|
|
17
|
+
|
|
18
|
+
// 2) Infer from the actual URL this loader was fetched from (or its tag src)
|
|
19
|
+
const candidates = [
|
|
20
|
+
(typeof import.meta !== "undefined" && import.meta && import.meta.url) ? import.meta.url : null,
|
|
21
|
+
el?.src || null,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
for (const c of candidates) {
|
|
25
|
+
if (!c) continue;
|
|
26
|
+
try {
|
|
27
|
+
const href = new URL(c, document.baseURI).href;
|
|
28
|
+
const m = href.match(/^(.*\/node_modules\/)/i);
|
|
29
|
+
if (m) return m[1];
|
|
30
|
+
} catch { /* ignore */ }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 3) Optional last-ditch guess at site root
|
|
34
|
+
if (allowGuessAtRoot) return new URL("/node_modules/", document.baseURI).href;
|
|
35
|
+
|
|
36
|
+
throw new TypeError(
|
|
37
|
+
'[VanillaJSLoader] :: Could not determine the `/node_modules/` base path.\n' +
|
|
38
|
+
'Pass the path to your `node_modules/` folder via either a `data-node-modules="<URL>"` attribute on the loader <script> ' +
|
|
39
|
+
'or set window.IDEEM_NODE_MODULES="<URL>" before including the shim <script>.'
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function injectImportMap(imports) {
|
|
44
|
+
const el = document.createElement("script");
|
|
45
|
+
el.type = "importmap";
|
|
46
|
+
el.textContent = JSON.stringify({ imports }, null, 2);
|
|
47
|
+
document.head.appendChild(el);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function ensureImportMapSupport() {
|
|
51
|
+
const hasNative =
|
|
52
|
+
typeof HTMLScriptElement !== "undefined" &&
|
|
53
|
+
"supports" in HTMLScriptElement &&
|
|
54
|
+
HTMLScriptElement.supports?.("importmap");
|
|
55
|
+
|
|
56
|
+
if (hasNative) return; // synchronous path on modern browsers
|
|
57
|
+
|
|
58
|
+
// Load shim from the same shims/ folder as this file, then proceed
|
|
59
|
+
const s = document.createElement("script");
|
|
60
|
+
s.defer = true;
|
|
61
|
+
s.src = new URL("./es-module-shims.js", import.meta.url).href;
|
|
62
|
+
document.head.appendChild(s);
|
|
63
|
+
await new Promise((res, rej) => {
|
|
64
|
+
s.addEventListener("load", res, { once: true });
|
|
65
|
+
s.addEventListener("error", () => rej(new Error("Failed to load es-module-shims")));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* ---------- first-party plugin registry ---------- */
|
|
70
|
+
const PLUGINS = [
|
|
71
|
+
{ pkg: "@ideem/plugins.passkeys-plus", entry: "PasskeysPlus.js" },
|
|
72
|
+
{ pkg: "@ideem/plugins.perf-logger", entry: "index.js" },
|
|
73
|
+
{ pkg: "@ideem/plugins.worker-thread", entry: "WorkerThread.js" },
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
/* ---------- main ---------- */
|
|
77
|
+
(async function main() {
|
|
78
|
+
// Only async if we need to load the shim; users never touch promises.
|
|
79
|
+
await ensureImportMapSupport();
|
|
80
|
+
|
|
81
|
+
const base = computeNodeModulesBase(); // or { allowGuessAtRoot: true } if you prefer
|
|
82
|
+
|
|
83
|
+
// Core SDK (adjust entry filename if different)
|
|
84
|
+
const imports = {
|
|
85
|
+
"@ideem/zsm-client-sdk": join(base, "@ideem/zsm-client-sdk/ZSMClientSDK.js"),
|
|
86
|
+
"@ideem/zsm-client-sdk/": join(base, "@ideem/zsm-client-sdk/"),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Map all official plugins (harmless unless actually imported)
|
|
90
|
+
for (const { pkg, entry } of PLUGINS) {
|
|
91
|
+
imports[pkg] = join(base, `${pkg}/${entry}`);
|
|
92
|
+
imports[`${pkg}/`] = join(base, `${pkg}/`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
injectImportMap(imports);
|
|
96
|
+
})();
|