@pontive/pontkit-loader 1.13.0 → 1.14.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/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p="1.58.0",_=["/__pontive/auth/v1/runtime-config","/auth/v1/runtime-config"],g=1500,E=/^\d+\.\d+\.\d+$/;function w(t){return typeof t=="string"&&E.test(t)}function f(t){return typeof t=="string"&&/^https?:\/\//.test(t)}function u(t){return typeof t=="string"&&/^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(t)}async function h(t={}){const e=t.fetchImpl??globalThis.fetch;if(typeof e!="function")return null;const i=t.urls??C(),s=t.timeoutMs??g;for(const o of i){const r=await S(e,o,s);if(r)return r}return null}function C(){return typeof window<"u"&&typeof window.__pontRuntimeConfigUrl=="string"?[window.__pontRuntimeConfigUrl]:_}async function S(t,e,i){const s=typeof AbortController=="function"?new AbortController:null,o=s?setTimeout(()=>s.abort(),i):null;try{const r=await t(e,{headers:{accept:"application/json"},signal:s?.signal});if(!r.ok)return null;const n=await r.json();if(!n||!w(n.core_elements_version))return null;const c={core_elements_version:n.core_elements_version,source:typeof n.source=="string"?n.source:void 0,catalog_revision:typeof n.catalog_revision=="number"?n.catalog_revision:void 0};return n.assets&&f(n.assets.js)&&f(n.assets.css)&&(c.assets={js:n.assets.js,css:n.assets.css}),n.integrity&&u(n.integrity.js)&&u(n.integrity.css)&&(c.integrity={js:n.integrity.js,css:n.integrity.css}),c}catch{return null}finally{o&&clearTimeout(o)}}let m=null,d=null;const l="@pontive/pontkit-core",T=[t=>`https://cdn.jsdelivr.net/npm/${l}@${t}/dist/index.mjs`,t=>`https://unpkg.com/${l}@${t}/dist/index.mjs`,t=>`https://esm.sh/${l}@${t}/dist/index.mjs`],N=[t=>`https://cdn.jsdelivr.net/npm/${l}@${t}/dist/styles.css`,t=>`https://unpkg.com/${l}@${t}/dist/styles.css`,t=>`https://esm.sh/${l}@${t}/dist/styles.css`],O=p;function M(t,e){return new Promise((i,s)=>{const o=document.createElement("link");o.rel="stylesheet",o.href=t,e&&(o.integrity=e,o.crossOrigin="anonymous"),o.onload=()=>i(),o.onerror=r=>s(r),document.head.appendChild(o)})}function $(t,e){return new Promise((i,s)=>{const o=document.createElement("script");o.type="module",o.src=t,o.integrity=e,o.crossOrigin="anonymous",o.onload=()=>i(),o.onerror=()=>s(new Error(`core-elements module at ${t} failed to load or did not match its integrity hash`)),document.head.appendChild(o)}).then(()=>import(t))}async function j(){return typeof window>"u"||typeof document>"u"?null:window.__pontLoaded?window.__pontCore:window.__pontLoading?window.__pontLoading:(d||(d=v().catch(t=>{throw d=null,window.__pontLoading=void 0,t}),window.__pontLoading=d),d)}async function v(){const t=await h(),e=t?.core_elements_version??O,i=T.map(n=>n(e)),s=N.map(n=>n(e));t?.assets&&(i.unshift(t.assets.js),s.unshift(t.assets.css));const o=t?.integrity;let r=null;for(let n=0;n<i.length;n++){const c=i[n],y=s[n];try{await M(y,o?.css);const a=o?await $(c,o.js):await import(c);return window.__pontCore=a,m=a,window.__pontLoaded=!0,window.__pontLoading=void 0,console.log(`PontKit Web Components loaded (${e}) from:`,c),m}catch(a){console.error(`Failed loading from ${c}`,a),r=a}}throw console.error("❌ Failed to load PontKit web components from all CDNs.",r),r}exports.CORE_ELEMENTS_VERSION=p;exports.RUNTIME_CONFIG_PATHS=_;exports.RUNTIME_CONFIG_TIMEOUT_MS=g;exports.fetchRuntimeConfig=h;exports.isExactVersion=w;exports.isSriHash=u;exports.loadWebComponents=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m="1.58.0",_=["/__pontive/auth/v1/runtime-config","/auth/v1/runtime-config"],g=1500,C=/^\d+\.\d+\.\d+$/;function w(t){return typeof t=="string"&&C.test(t)}function f(t){return typeof t=="string"&&/^https?:\/\//.test(t)}function u(t){return typeof t=="string"&&/^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(t)}async function h(t={}){const e=t.fetchImpl??globalThis.fetch;if(typeof e!="function")return null;const i=t.urls??E(),s=t.timeoutMs??g;for(const o of i){const r=await T(e,o,s);if(r)return r}return null}function E(){return typeof window<"u"&&typeof window.__pontRuntimeConfigUrl=="string"?[window.__pontRuntimeConfigUrl]:_}async function T(t,e,i){const s=typeof AbortController=="function"?new AbortController:null,o=s?setTimeout(()=>s.abort(),i):null;try{const r=await t(e,{headers:{accept:"application/json"},signal:s?.signal});if(!r.ok)return null;const n=await r.json();if(!n||!w(n.pontkit_version))return null;const c={pontkit_version:n.pontkit_version,source:typeof n.source=="string"?n.source:void 0,catalog_revision:typeof n.catalog_revision=="number"?n.catalog_revision:void 0};return n.assets&&f(n.assets.js)&&f(n.assets.css)&&(c.assets={js:n.assets.js,css:n.assets.css}),n.integrity&&u(n.integrity.js)&&u(n.integrity.css)&&(c.integrity={js:n.integrity.js,css:n.integrity.css}),c}catch{return null}finally{o&&clearTimeout(o)}}let p=null,l=null;const a="@pontive/pontkit-core",S=[t=>`https://cdn.jsdelivr.net/npm/${a}@${t}/dist/index.mjs`,t=>`https://unpkg.com/${a}@${t}/dist/index.mjs`,t=>`https://esm.sh/${a}@${t}/dist/index.mjs`],O=[t=>`https://cdn.jsdelivr.net/npm/${a}@${t}/dist/styles.css`,t=>`https://unpkg.com/${a}@${t}/dist/styles.css`,t=>`https://esm.sh/${a}@${t}/dist/styles.css`],I=m;function N(t,e){return new Promise((i,s)=>{const o=document.createElement("link");o.rel="stylesheet",o.href=t,e&&(o.integrity=e,o.crossOrigin="anonymous"),o.onload=()=>i(),o.onerror=r=>s(r),document.head.appendChild(o)})}function $(t,e){return new Promise((i,s)=>{const o=document.createElement("script");o.type="module",o.src=t,o.integrity=e,o.crossOrigin="anonymous",o.onload=()=>i(),o.onerror=()=>s(new Error(`pontkit-core module at ${t} failed to load or did not match its integrity hash`)),document.head.appendChild(o)}).then(()=>import(t))}async function j(){return typeof window>"u"||typeof document>"u"?null:window.__pontLoaded?window.__pontCore:window.__pontLoading?window.__pontLoading:(l||(l=v().catch(t=>{throw l=null,window.__pontLoading=void 0,t}),window.__pontLoading=l),l)}async function v(){const t=await h(),e=t?.pontkit_version??I,i=S.map(n=>n(e)),s=O.map(n=>n(e));t?.assets&&(i.unshift(t.assets.js),s.unshift(t.assets.css));const o=t?.integrity;let r=null;for(let n=0;n<i.length;n++){const c=i[n],y=s[n];try{await N(y,o?.css);const d=o?await $(c,o.js):await import(c);return window.__pontCore=d,p=d,window.__pontLoaded=!0,window.__pontLoading=void 0,console.log(`PontKit Web Components loaded (${e}) from:`,c),p}catch(d){console.error(`Failed loading from ${c}`,d),r=d}}throw console.error("❌ Failed to load PontKit web components from all CDNs.",r),r}exports.PONTKIT_CORE_VERSION=m;exports.RUNTIME_CONFIG_PATHS=_;exports.RUNTIME_CONFIG_TIMEOUT_MS=g;exports.fetchRuntimeConfig=h;exports.isExactVersion=w;exports.isSriHash=u;exports.loadWebComponents=j;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/core-elements-version.ts","../src/runtime-config.ts","../src/load-web-components.ts"],"sourcesContent":["/**\n * The exact `@pontive/pontkit-core` release this build loads from the CDN.\n *\n * It is the version installed as a dev dependency when the package was built —\n * i.e. the one the test suite ran against — baked in by `define` in\n * vite.config.ts and vitest.config.ts (see scripts/core-elements-version.mjs).\n * An exact version, never a range: an exact release is immutable on the CDN,\n * cacheable forever, and the only form that admits an integrity hash.\n *\n * Nothing at runtime may replace this with \"whatever is newest\" — that is the\n * defect it exists to end. The platform's runtime-config endpoint will be\n * allowed to override it, because that answer is the one the platform has\n * gated (pontive-spec/21-element-versioning-and-compatibility.md §9).\n */\nexport const CORE_ELEMENTS_VERSION: string = __CORE_ELEMENTS_VERSION__;\n","// Which @pontive/pontkit-core release to load, asked of the platform.\n//\n// The platform decides which release a project's screens render with — one\n// deployment default, an optional per-project canary — and publishes the answer\n// at `GET /auth/v1/runtime-config` on the project's auth server\n// (pontive-spec/21-element-versioning-and-compatibility.md §9). This package\n// reads it once, before importing the bundle, so an embedded widget renders\n// with the same release the hosted login pages do. The build-time stamp\n// (CORE_ELEMENTS_VERSION) is the fallback when the answer cannot be read.\n//\n// The endpoint is reached through the app's own origin when the SDK's proxy is\n// mounted (`/__pontive/auth/v1/...`), and directly on `/auth/v1/...` when the app\n// itself runs on the auth domain. Both are tried; a host page can name a URL\n// outright with `window.__pontRuntimeConfigUrl`.\n\n/** The shape of GET /auth/v1/runtime-config. */\nexport interface RuntimeConfig {\n core_elements_version: string;\n catalog_revision?: number;\n source?: string;\n assets?: { js: string; css: string };\n /**\n * Subresource-integrity hashes (\"sha384-…\") of the release's module and\n * stylesheet, recorded by the platform when the release was gated. When\n * present the loader passes them to the browser, which refuses bytes that\n * differ — from the platform origin or from any public CDN alike.\n */\n integrity?: { js: string; css: string };\n}\n\nexport const RUNTIME_CONFIG_PATHS = [\n \"/__pontive/auth/v1/runtime-config\",\n \"/auth/v1/runtime-config\",\n] as const;\n\n/** How long to wait for the platform before loading the stamped release. */\nexport const RUNTIME_CONFIG_TIMEOUT_MS = 1500;\n\nconst EXACT_VERSION = /^\\d+\\.\\d+\\.\\d+$/;\n\nexport interface FetchRuntimeConfigOptions {\n fetchImpl?: typeof fetch;\n urls?: readonly string[];\n timeoutMs?: number;\n}\n\n/** Whether `value` names one release rather than a range or garbage. */\nexport function isExactVersion(value: unknown): value is string {\n return typeof value === \"string\" && EXACT_VERSION.test(value);\n}\n\nfunction isHttpUrl(value: unknown): value is string {\n return typeof value === \"string\" && /^https?:\\/\\//.test(value);\n}\n\n/** Whether `value` is a well-formed SRI value the browser will accept. */\nexport function isSriHash(value: unknown): value is string {\n return typeof value === \"string\" && /^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(value);\n}\n\n/**\n * Reads the platform's runtime config, or null when no candidate URL answers\n * with one that can be trusted. Never throws: the caller's fallback is the\n * stamped release, and a reachability problem should not become a page error.\n */\nexport async function fetchRuntimeConfig(\n options: FetchRuntimeConfigOptions = {},\n): Promise<RuntimeConfig | null> {\n const fetchImpl = options.fetchImpl ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") return null;\n\n const urls = options.urls ?? candidateUrls();\n const timeoutMs = options.timeoutMs ?? RUNTIME_CONFIG_TIMEOUT_MS;\n\n for (const url of urls) {\n const config = await readOne(fetchImpl, url, timeoutMs);\n if (config) return config;\n }\n\n return null;\n}\n\nfunction candidateUrls(): readonly string[] {\n if (typeof window !== \"undefined\" && typeof window.__pontRuntimeConfigUrl === \"string\") {\n return [window.__pontRuntimeConfigUrl];\n }\n\n return RUNTIME_CONFIG_PATHS;\n}\n\nasync function readOne(\n fetchImpl: typeof fetch,\n url: string,\n timeoutMs: number,\n): Promise<RuntimeConfig | null> {\n const controller = typeof AbortController === \"function\" ? new AbortController() : null;\n const timer = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;\n\n try {\n const response = await fetchImpl(url, {\n headers: { accept: \"application/json\" },\n signal: controller?.signal,\n });\n if (!response.ok) return null;\n\n const body = (await response.json()) as Partial<RuntimeConfig> | null;\n if (!body || !isExactVersion(body.core_elements_version)) return null;\n\n const config: RuntimeConfig = {\n core_elements_version: body.core_elements_version,\n source: typeof body.source === \"string\" ? body.source : undefined,\n catalog_revision:\n typeof body.catalog_revision === \"number\" ? body.catalog_revision : undefined,\n };\n\n // Assets are taken only as a pair of absolute URLs; anything else means\n // \"load from the CDN list by version\".\n if (body.assets && isHttpUrl(body.assets.js) && isHttpUrl(body.assets.css)) {\n config.assets = { js: body.assets.js, css: body.assets.css };\n }\n\n // Half a pair is no pair: the browser would check one file and not the\n // other, and nobody would notice the unchecked one.\n if (body.integrity && isSriHash(body.integrity.js) && isSriHash(body.integrity.css)) {\n config.integrity = { js: body.integrity.js, css: body.integrity.css };\n }\n\n return config;\n } catch {\n return null;\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n","import { CORE_ELEMENTS_VERSION } from \"./core-elements-version\";\nimport { fetchRuntimeConfig } from \"./runtime-config\";\n\nlet core: any = null;\n\n// The load in flight, if any. This is the guard, and it is a promise rather\n// than a boolean on purpose: a flag set before the first `await` let a second\n// concurrent caller return `core` while it was still null and carry on as if\n// it were ready. A\n// promise gives every caller the same eventual answer. It is cleared on failure\n// so a later call can retry rather than inherit a latched failure.\nlet loadPromise: Promise<any> | null = null;\n\nconst PACKAGE_NAME = \"@pontive/pontkit-core\";\n\n// Base CDN templates (version will be injected)\nconst CDN_TEMPLATES = [\n (v: string) =>\n `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n (v: string) => `https://unpkg.com/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n (v: string) => `https://esm.sh/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n];\n\nconst CSS_TEMPLATES = [\n (v: string) =>\n `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${v}/dist/styles.css`,\n (v: string) => `https://unpkg.com/${PACKAGE_NAME}@${v}/dist/styles.css`,\n (v: string) => `https://esm.sh/${PACKAGE_NAME}@${v}/dist/styles.css`,\n];\n\n// Which release loads is decided by the PLATFORM, and failing that at BUILD\n// time — never by asking a registry at runtime. This package used to fetch jsDelivr's version list and take the\n// newest entry of any major — the `1.x` filter had been commented out — with\n// `^1` as the fallback when the fetch failed, a different major from the 2.x\n// the wrappers target. Whatever npm happened to hold newest is not a version\n// anyone tested against, and a customer's page picked it up on the next reload\n// with nothing in their build having changed.\n//\n// Now the project's auth server says which release its screens load\n// (GET /auth/v1/runtime-config, see ./runtime-config.ts), so an embedded widget\n// renders with the same bundle the hosted login pages do, and a canary or a\n// promotion reaches it without a rebuild. CORE_ELEMENTS_VERSION — the exact\n// release this package was built and tested with — is the fallback when that\n// endpoint cannot be read.\nconst FALLBACK_VERSION = CORE_ELEMENTS_VERSION;\n\nfunction loadCss(url: string, integrity?: string) {\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = url;\n if (integrity) {\n // SRI is only enforced on a CORS-mode fetch; the platform origin and the\n // public CDNs all answer with Access-Control-Allow-Origin: *.\n link.integrity = integrity;\n link.crossOrigin = \"anonymous\";\n }\n link.onload = () => resolve();\n link.onerror = (err) => reject(err);\n document.head.appendChild(link);\n });\n}\n\n// Loads the module through a <script type=\"module\"> carrying the integrity\n// attribute, then imports it. A dynamic import() cannot carry SRI, but the\n// script element can, and once it has fetched and verified the module the\n// browser's module map holds it under that URL — the import() that follows\n// resolves from the map without a second fetch. A hash mismatch fails the\n// script's load, the promise rejects, and the loader moves to the next\n// source, which is the right outcome: bytes the platform did not gate must not\n// run, wherever they came from.\nfunction loadVerifiedModule(url: string, integrity: string): Promise<any> {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.type = \"module\";\n script.src = url;\n script.integrity = integrity;\n script.crossOrigin = \"anonymous\";\n script.onload = () => resolve();\n script.onerror = () =>\n reject(new Error(`core-elements module at ${url} failed to load or did not match its integrity hash`));\n document.head.appendChild(script);\n }).then(\n () =>\n import(\n /* webpackIgnore: true */\n /* turbopackIgnore: true */\n /* @vite-ignore */\n url\n ),\n );\n}\n\nexport async function loadWebComponents(): Promise<any> {\n // No DOM means no custom elements to define and no CDN to fetch from.\n //\n // Returning rather than throwing matters because src/index.ts calls this at\n // module scope: under a server renderer the rejection surfaced as a console\n // error on every render, reporting a failure that is not one. Checked before\n // the guards below so the browser still loads normally after hydration.\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return null;\n }\n\n // Another copy of this package on the same page already finished loading.\n if (window.__pontLoaded) {\n return window.__pontCore;\n }\n\n // Another copy of this package on the same page is loading right now.\n if (window.__pontLoading) {\n return window.__pontLoading;\n }\n\n if (!loadPromise) {\n loadPromise = loadFromCdn().catch((err) => {\n loadPromise = null;\n window.__pontLoading = undefined;\n throw err;\n });\n\n window.__pontLoading = loadPromise;\n }\n\n return loadPromise;\n}\n\nasync function loadFromCdn(): Promise<any> {\n const runtime = await fetchRuntimeConfig();\n const resolvedVersion = runtime?.core_elements_version ?? FALLBACK_VERSION;\n\n const CDN_SOURCES = CDN_TEMPLATES.map((fn) => fn(resolvedVersion));\n const CSS_SOURCES = CSS_TEMPLATES.map((fn) => fn(resolvedVersion));\n\n // The platform's own asset location goes first when it names one; the public\n // CDNs stay as the fallback list for the same version.\n if (runtime?.assets) {\n CDN_SOURCES.unshift(runtime.assets.js);\n CSS_SOURCES.unshift(runtime.assets.css);\n }\n\n // The hashes describe the npm release's bytes, which every source below\n // serves verbatim, so they apply to all of them — not only to the\n // platform's. A source whose bytes differ is a source that must not run.\n const integrity = runtime?.integrity;\n\n let lastError: unknown = null;\n\n for (let i = 0; i < CDN_SOURCES.length; i++) {\n const cdn = CDN_SOURCES[i];\n const cssCdn = CSS_SOURCES[i];\n\n try {\n // The stylesheet first, so the elements never render unstyled.\n await loadCss(cssCdn, integrity?.css);\n\n // Then the module.\n //\n // All three ignore directives, and none of them is optional.\n //\n // `cdn` is a full URL resolved at runtime, so a bundler that tries to\n // resolve it statically cannot: webpack and Turbopack turn a dynamic\n // import with a variable specifier into a module-graph lookup and throw\n // `Cannot find module 'https://…'` at runtime — no network request is ever\n // made, and the message reads as though the CDN were at fault. Next.js\n // uses Turbopack in development and webpack in production, so an app\n // built with it failed on every CDN in the list identically.\n //\n // `@vite-ignore` alone covered only Vite. Each bundler reads its own\n // comment and ignores the others, so all three coexist and each one keeps\n // this a real runtime import.\n const module: any = integrity\n ? await loadVerifiedModule(cdn, integrity.js)\n : await import(\n /* webpackIgnore: true */\n /* turbopackIgnore: true */\n /* @vite-ignore */\n cdn\n );\n\n // The elements define themselves on import. The module is kept on the\n // window so a second copy of this package on the page (two bindings,\n // two bundles) answers from it instead of loading the bundle again.\n // There is no SDK in it: the provider element is given one by its host\n // (the React `Provider` injects @pontive/oidc-client's `Auth`).\n window.__pontCore = module;\n core = module;\n\n // Set only once the module is on the window, so a copy of this package\n // that sees the flag can trust what it reads next to it.\n window.__pontLoaded = true;\n window.__pontLoading = undefined;\n\n console.log(\n `PontKit Web Components loaded (${resolvedVersion}) from:`,\n cdn,\n );\n\n return core;\n } catch (err) {\n console.error(`Failed loading from ${cdn}`, err);\n lastError = err;\n }\n }\n\n console.error(\n \"❌ Failed to load PontKit web components from all CDNs.\",\n lastError,\n );\n throw lastError;\n}\n"],"names":["CORE_ELEMENTS_VERSION","RUNTIME_CONFIG_PATHS","RUNTIME_CONFIG_TIMEOUT_MS","EXACT_VERSION","isExactVersion","value","isHttpUrl","isSriHash","fetchRuntimeConfig","options","fetchImpl","urls","candidateUrls","timeoutMs","url","config","readOne","controller","timer","response","body","core","loadPromise","PACKAGE_NAME","CDN_TEMPLATES","v","CSS_TEMPLATES","FALLBACK_VERSION","loadCss","integrity","resolve","reject","link","err","loadVerifiedModule","script","loadWebComponents","loadFromCdn","runtime","resolvedVersion","CDN_SOURCES","fn","CSS_SOURCES","lastError","i","cdn","cssCdn","module"],"mappings":"gFAcO,MAAMA,EAAgC,SCgBhCC,EAAuB,CAClC,oCACA,yBACF,EAGaC,EAA4B,KAEnCC,EAAgB,kBASf,SAASC,EAAeC,EAAiC,CAC9D,OAAO,OAAOA,GAAU,UAAYF,EAAc,KAAKE,CAAK,CAC9D,CAEA,SAASC,EAAUD,EAAiC,CAClD,OAAO,OAAOA,GAAU,UAAY,eAAe,KAAKA,CAAK,CAC/D,CAGO,SAASE,EAAUF,EAAiC,CACzD,OAAO,OAAOA,GAAU,UAAY,sCAAsC,KAAKA,CAAK,CACtF,CAOA,eAAsBG,EACpBC,EAAqC,GACN,CAC/B,MAAMC,EAAYD,EAAQ,WAAa,WAAW,MAClD,GAAI,OAAOC,GAAc,WAAY,OAAO,KAE5C,MAAMC,EAAOF,EAAQ,MAAQG,EAAA,EACvBC,EAAYJ,EAAQ,WAAaP,EAEvC,UAAWY,KAAOH,EAAM,CACtB,MAAMI,EAAS,MAAMC,EAAQN,EAAWI,EA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BA,EACT,CAEA,eAAee,GAA4B,CACzC,MAAMC,EAAU,MAAM9B,EAAA,EAChB+B,EAAkBD,GAAS,uBAAyBX,EAEpDa,EAAchB,EAAc,IAAKiB,GAAOA,EAAGF,CAAe,CAAC,EAC3DG,EAAchB,EAAc,IAAKe,GAAOA,EAAGF,CAAe,CAAC,EAI7DD,GAAS,SACXE,EAAY,QAAQF,EAAQ,OAAO,EAAE,EACrCI,EAAY,QAAQJ,EAAQ,OAAO,GAAG,GAMxC,MAAMT,EAAYS,GAAS,UAE3B,IAAIK,EAAqB,KAEzB,QAASC,EAAI,EAAGA,EAAIJ,EAAY,OAAQI,IAAK,CAC3C,MAAMC,EAAML,EAAYI,CAAC,EACnBE,EAASJ,EAAYE,CAAC,EAE5B,GAAI,CAEF,MAAMhB,EAAQkB,EAAQjB,GAAW,GAAG,EAiBpC,MAAMkB,EAAclB,EAChB,MAAMK,EAAmBW,EAAKhB,EAAU,EAAE,EAC1C,MAAM,OAIJgB,GAQN,cAAO,WAAaE,EACpB1B,EAAO0B,EAIP,OAAO,aAAe,GACtB,OAAO,cAAgB,OAEvB,QAAQ,IACN,kCAAkCR,CAAe,UACjDM,CAAA,EAGKxB,CACT,OAASY,EAAK,CACZ,QAAQ,MAAM,uBAAuBY,CAAG,GAAIZ,CAAG,EAC/CU,EAAYV,CACd,CACF,CAEA,cAAQ,MACN,yDACAU,CAAA,EAEIA,CACR"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/pontkit-core-version.ts","../src/runtime-config.ts","../src/load-web-components.ts"],"sourcesContent":["/**\n * The exact `@pontive/pontkit-core` release this build loads from the CDN.\n *\n * It is the version installed as a dev dependency when the package was built —\n * i.e. the one the test suite ran against — baked in by `define` in\n * vite.config.ts and vitest.config.ts (see scripts/pontkit-core-version.mjs).\n * An exact version, never a range: an exact release is immutable on the CDN,\n * cacheable forever, and the only form that admits an integrity hash.\n *\n * Nothing at runtime may replace this with \"whatever is newest\" — that is the\n * defect it exists to end. The platform's runtime-config endpoint will be\n * allowed to override it, because that answer is the one the platform has\n * gated (pontive-spec/21-element-versioning-and-compatibility.md §9).\n */\nexport const PONTKIT_CORE_VERSION: string = __PONTKIT_CORE_VERSION__;\n","// Which @pontive/pontkit-core release to load, asked of the platform.\n//\n// The platform decides which release a project's screens render with — one\n// deployment default, an optional per-project canary — and publishes the answer\n// at `GET /auth/v1/runtime-config` on the project's auth server\n// (pontive-spec/21-element-versioning-and-compatibility.md §9). This package\n// reads it once, before importing the bundle, so an embedded widget renders\n// with the same release the hosted login pages do. The build-time stamp\n// (PONTKIT_CORE_VERSION) is the fallback when the answer cannot be read.\n//\n// The endpoint is reached through the app's own origin when the SDK's proxy is\n// mounted (`/__pontive/auth/v1/...`), and directly on `/auth/v1/...` when the app\n// itself runs on the auth domain. Both are tried; a host page can name a URL\n// outright with `window.__pontRuntimeConfigUrl`.\n\n/** The shape of GET /auth/v1/runtime-config. */\nexport interface RuntimeConfig {\n pontkit_version: string;\n catalog_revision?: number;\n source?: string;\n assets?: { js: string; css: string };\n /**\n * Subresource-integrity hashes (\"sha384-…\") of the release's module and\n * stylesheet, recorded by the platform when the release was gated. When\n * present the loader passes them to the browser, which refuses bytes that\n * differ — from the platform origin or from any public CDN alike.\n */\n integrity?: { js: string; css: string };\n}\n\nexport const RUNTIME_CONFIG_PATHS = [\n \"/__pontive/auth/v1/runtime-config\",\n \"/auth/v1/runtime-config\",\n] as const;\n\n/** How long to wait for the platform before loading the stamped release. */\nexport const RUNTIME_CONFIG_TIMEOUT_MS = 1500;\n\nconst EXACT_VERSION = /^\\d+\\.\\d+\\.\\d+$/;\n\nexport interface FetchRuntimeConfigOptions {\n fetchImpl?: typeof fetch;\n urls?: readonly string[];\n timeoutMs?: number;\n}\n\n/** Whether `value` names one release rather than a range or garbage. */\nexport function isExactVersion(value: unknown): value is string {\n return typeof value === \"string\" && EXACT_VERSION.test(value);\n}\n\nfunction isHttpUrl(value: unknown): value is string {\n return typeof value === \"string\" && /^https?:\\/\\//.test(value);\n}\n\n/** Whether `value` is a well-formed SRI value the browser will accept. */\nexport function isSriHash(value: unknown): value is string {\n return typeof value === \"string\" && /^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(value);\n}\n\n/**\n * Reads the platform's runtime config, or null when no candidate URL answers\n * with one that can be trusted. Never throws: the caller's fallback is the\n * stamped release, and a reachability problem should not become a page error.\n */\nexport async function fetchRuntimeConfig(\n options: FetchRuntimeConfigOptions = {},\n): Promise<RuntimeConfig | null> {\n const fetchImpl = options.fetchImpl ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") return null;\n\n const urls = options.urls ?? candidateUrls();\n const timeoutMs = options.timeoutMs ?? RUNTIME_CONFIG_TIMEOUT_MS;\n\n for (const url of urls) {\n const config = await readOne(fetchImpl, url, timeoutMs);\n if (config) return config;\n }\n\n return null;\n}\n\nfunction candidateUrls(): readonly string[] {\n if (typeof window !== \"undefined\" && typeof window.__pontRuntimeConfigUrl === \"string\") {\n return [window.__pontRuntimeConfigUrl];\n }\n\n return RUNTIME_CONFIG_PATHS;\n}\n\nasync function readOne(\n fetchImpl: typeof fetch,\n url: string,\n timeoutMs: number,\n): Promise<RuntimeConfig | null> {\n const controller = typeof AbortController === \"function\" ? new AbortController() : null;\n const timer = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;\n\n try {\n const response = await fetchImpl(url, {\n headers: { accept: \"application/json\" },\n signal: controller?.signal,\n });\n if (!response.ok) return null;\n\n const body = (await response.json()) as Partial<RuntimeConfig> | null;\n if (!body || !isExactVersion(body.pontkit_version)) return null;\n\n const config: RuntimeConfig = {\n pontkit_version: body.pontkit_version,\n source: typeof body.source === \"string\" ? body.source : undefined,\n catalog_revision:\n typeof body.catalog_revision === \"number\" ? body.catalog_revision : undefined,\n };\n\n // Assets are taken only as a pair of absolute URLs; anything else means\n // \"load from the CDN list by version\".\n if (body.assets && isHttpUrl(body.assets.js) && isHttpUrl(body.assets.css)) {\n config.assets = { js: body.assets.js, css: body.assets.css };\n }\n\n // Half a pair is no pair: the browser would check one file and not the\n // other, and nobody would notice the unchecked one.\n if (body.integrity && isSriHash(body.integrity.js) && isSriHash(body.integrity.css)) {\n config.integrity = { js: body.integrity.js, css: body.integrity.css };\n }\n\n return config;\n } catch {\n return null;\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n","import { PONTKIT_CORE_VERSION } from \"./pontkit-core-version\";\nimport { fetchRuntimeConfig } from \"./runtime-config\";\n\nlet core: any = null;\n\n// The load in flight, if any. This is the guard, and it is a promise rather\n// than a boolean on purpose: a flag set before the first `await` let a second\n// concurrent caller return `core` while it was still null and carry on as if\n// it were ready. A\n// promise gives every caller the same eventual answer. It is cleared on failure\n// so a later call can retry rather than inherit a latched failure.\nlet loadPromise: Promise<any> | null = null;\n\nconst PACKAGE_NAME = \"@pontive/pontkit-core\";\n\n// Base CDN templates (version will be injected)\nconst CDN_TEMPLATES = [\n (v: string) =>\n `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n (v: string) => `https://unpkg.com/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n (v: string) => `https://esm.sh/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n];\n\nconst CSS_TEMPLATES = [\n (v: string) =>\n `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${v}/dist/styles.css`,\n (v: string) => `https://unpkg.com/${PACKAGE_NAME}@${v}/dist/styles.css`,\n (v: string) => `https://esm.sh/${PACKAGE_NAME}@${v}/dist/styles.css`,\n];\n\n// Which release loads is decided by the PLATFORM, and failing that at BUILD\n// time — never by asking a registry at runtime. This package used to fetch jsDelivr's version list and take the\n// newest entry of any major — the `1.x` filter had been commented out — with\n// `^1` as the fallback when the fetch failed, a different major from the 2.x\n// the wrappers target. Whatever npm happened to hold newest is not a version\n// anyone tested against, and a customer's page picked it up on the next reload\n// with nothing in their build having changed.\n//\n// Now the project's auth server says which release its screens load\n// (GET /auth/v1/runtime-config, see ./runtime-config.ts), so an embedded widget\n// renders with the same bundle the hosted login pages do, and a canary or a\n// promotion reaches it without a rebuild. PONTKIT_CORE_VERSION — the exact\n// release this package was built and tested with — is the fallback when that\n// endpoint cannot be read.\nconst FALLBACK_VERSION = PONTKIT_CORE_VERSION;\n\nfunction loadCss(url: string, integrity?: string) {\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = url;\n if (integrity) {\n // SRI is only enforced on a CORS-mode fetch; the platform origin and the\n // public CDNs all answer with Access-Control-Allow-Origin: *.\n link.integrity = integrity;\n link.crossOrigin = \"anonymous\";\n }\n link.onload = () => resolve();\n link.onerror = (err) => reject(err);\n document.head.appendChild(link);\n });\n}\n\n// Loads the module through a <script type=\"module\"> carrying the integrity\n// attribute, then imports it. A dynamic import() cannot carry SRI, but the\n// script element can, and once it has fetched and verified the module the\n// browser's module map holds it under that URL — the import() that follows\n// resolves from the map without a second fetch. A hash mismatch fails the\n// script's load, the promise rejects, and the loader moves to the next\n// source, which is the right outcome: bytes the platform did not gate must not\n// run, wherever they came from.\nfunction loadVerifiedModule(url: string, integrity: string): Promise<any> {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.type = \"module\";\n script.src = url;\n script.integrity = integrity;\n script.crossOrigin = \"anonymous\";\n script.onload = () => resolve();\n script.onerror = () =>\n reject(new Error(`pontkit-core module at ${url} failed to load or did not match its integrity hash`));\n document.head.appendChild(script);\n }).then(\n () =>\n import(\n /* webpackIgnore: true */\n /* turbopackIgnore: true */\n /* @vite-ignore */\n url\n ),\n );\n}\n\nexport async function loadWebComponents(): Promise<any> {\n // No DOM means no custom elements to define and no CDN to fetch from.\n //\n // Returning rather than throwing matters because src/index.ts calls this at\n // module scope: under a server renderer the rejection surfaced as a console\n // error on every render, reporting a failure that is not one. Checked before\n // the guards below so the browser still loads normally after hydration.\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return null;\n }\n\n // Another copy of this package on the same page already finished loading.\n if (window.__pontLoaded) {\n return window.__pontCore;\n }\n\n // Another copy of this package on the same page is loading right now.\n if (window.__pontLoading) {\n return window.__pontLoading;\n }\n\n if (!loadPromise) {\n loadPromise = loadFromCdn().catch((err) => {\n loadPromise = null;\n window.__pontLoading = undefined;\n throw err;\n });\n\n window.__pontLoading = loadPromise;\n }\n\n return loadPromise;\n}\n\nasync function loadFromCdn(): Promise<any> {\n const runtime = await fetchRuntimeConfig();\n const resolvedVersion = runtime?.pontkit_version ?? FALLBACK_VERSION;\n\n const CDN_SOURCES = CDN_TEMPLATES.map((fn) => fn(resolvedVersion));\n const CSS_SOURCES = CSS_TEMPLATES.map((fn) => fn(resolvedVersion));\n\n // The platform's own asset location goes first when it names one; the public\n // CDNs stay as the fallback list for the same version.\n if (runtime?.assets) {\n CDN_SOURCES.unshift(runtime.assets.js);\n CSS_SOURCES.unshift(runtime.assets.css);\n }\n\n // The hashes describe the npm release's bytes, which every source below\n // serves verbatim, so they apply to all of them — not only to the\n // platform's. A source whose bytes differ is a source that must not run.\n const integrity = runtime?.integrity;\n\n let lastError: unknown = null;\n\n for (let i = 0; i < CDN_SOURCES.length; i++) {\n const cdn = CDN_SOURCES[i];\n const cssCdn = CSS_SOURCES[i];\n\n try {\n // The stylesheet first, so the elements never render unstyled.\n await loadCss(cssCdn, integrity?.css);\n\n // Then the module.\n //\n // All three ignore directives, and none of them is optional.\n //\n // `cdn` is a full URL resolved at runtime, so a bundler that tries to\n // resolve it statically cannot: webpack and Turbopack turn a dynamic\n // import with a variable specifier into a module-graph lookup and throw\n // `Cannot find module 'https://…'` at runtime — no network request is ever\n // made, and the message reads as though the CDN were at fault. Next.js\n // uses Turbopack in development and webpack in production, so an app\n // built with it failed on every CDN in the list identically.\n //\n // `@vite-ignore` alone covered only Vite. Each bundler reads its own\n // comment and ignores the others, so all three coexist and each one keeps\n // this a real runtime import.\n const module: any = integrity\n ? await loadVerifiedModule(cdn, integrity.js)\n : await import(\n /* webpackIgnore: true */\n /* turbopackIgnore: true */\n /* @vite-ignore */\n cdn\n );\n\n // The elements define themselves on import. The module is kept on the\n // window so a second copy of this package on the page (two bindings,\n // two bundles) answers from it instead of loading the bundle again.\n // There is no SDK in it: the provider element is given one by its host\n // (the React `Provider` injects @pontive/oidc-client's `Auth`).\n window.__pontCore = module;\n core = module;\n\n // Set only once the module is on the window, so a copy of this package\n // that sees the flag can trust what it reads next to it.\n window.__pontLoaded = true;\n window.__pontLoading = undefined;\n\n console.log(\n `PontKit Web Components loaded (${resolvedVersion}) from:`,\n cdn,\n );\n\n return core;\n } catch (err) {\n console.error(`Failed loading from ${cdn}`, err);\n lastError = err;\n }\n }\n\n console.error(\n \"❌ Failed to load PontKit web components from all CDNs.\",\n lastError,\n );\n throw lastError;\n}\n"],"names":["PONTKIT_CORE_VERSION","RUNTIME_CONFIG_PATHS","RUNTIME_CONFIG_TIMEOUT_MS","EXACT_VERSION","isExactVersion","value","isHttpUrl","isSriHash","fetchRuntimeConfig","options","fetchImpl","urls","candidateUrls","timeoutMs","url","config","readOne","controller","timer","response","body","core","loadPromise","PACKAGE_NAME","CDN_TEMPLATES","v","CSS_TEMPLATES","FALLBACK_VERSION","loadCss","integrity","resolve","reject","link","err","loadVerifiedModule","script","loadWebComponents","loadFromCdn","runtime","resolvedVersion","CDN_SOURCES","fn","CSS_SOURCES","lastError","i","cdn","cssCdn","module"],"mappings":"gFAcO,MAAMA,EAA+B,SCgB/BC,EAAuB,CAClC,oCACA,yBACF,EAGaC,EAA4B,KAEnCC,EAAgB,kBASf,SAASC,EAAeC,EAAiC,CAC9D,OAAO,OAAOA,GAAU,UAAYF,EAAc,KAAKE,CAAK,CAC9D,CAEA,SAASC,EAAUD,EAAiC,CAClD,OAAO,OAAOA,GAAU,UAAY,eAAe,KAAKA,CAAK,CAC/D,CAGO,SAASE,EAAUF,EAAiC,CACzD,OAAO,OAAOA,GAAU,UAAY,sCAAsC,KAAKA,CAAK,CACtF,CAOA,eAAsBG,EACpBC,EAAqC,GACN,CAC/B,MAAMC,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OAAW,KAAe,OAAO,SAAa,IAChD,KAIL,OAAO,aACF,OAAO,WAIZ,OAAO,cACF,OAAO,eAGXd,IACHA,EAAce,EAAA,EAAc,MAAOJ,GAAQ,CACzC,MAAAX,EAAc,KACd,OAAO,cAAgB,OACjBW,CACR,CAAC,EAED,OAAO,cAAgBX,GAGlBA,EACT,CAEA,eAAee,GAA4B,CACzC,MAAMC,EAAU,MAAM9B,EAAA,EAChB+B,EAAkBD,GAAS,iBAAmBX,EAE9Ca,EAAchB,EAAc,IAAKiB,GAAOA,EAAGF,CAAe,CAAC,EAC3DG,EAAchB,EAAc,IAAKe,GAAOA,EAAGF,CAAe,CAAC,EAI7DD,GAAS,SACXE,EAAY,QAAQF,EAAQ,OAAO,EAAE,EACrCI,EAAY,QAAQJ,EAAQ,OAAO,GAAG,GAMxC,MAAMT,EAAYS,GAAS,UAE3B,IAAIK,EAAqB,KAEzB,QAASC,EAAI,EAAGA,EAAIJ,EAAY,OAAQI,IAAK,CAC3C,MAAMC,EAAML,EAAYI,CAAC,EACnBE,EAASJ,EAAYE,CAAC,EAE5B,GAAI,CAEF,MAAMhB,EAAQkB,EAAQjB,GAAW,GAAG,EAiBpC,MAAMkB,EAAclB,EAChB,MAAMK,EAAmBW,EAAKhB,EAAU,EAAE,EAC1C,MAAM,OAIJgB,GAQN,cAAO,WAAaE,EACpB1B,EAAO0B,EAIP,OAAO,aAAe,GACtB,OAAO,cAAgB,OAEvB,QAAQ,IACN,kCAAkCR,CAAe,UACjDM,CAAA,EAGKxB,CACT,OAASY,EAAK,CACZ,QAAQ,MAAM,uBAAuBY,CAAG,GAAIZ,CAAG,EAC/CU,EAAYV,CACd,CACF,CAEA,cAAQ,MACN,yDACAU,CAAA,EAEIA,CACR"}
package/dist/index.d.ts CHANGED
@@ -10,4 +10,4 @@
10
10
  */
11
11
  export { loadWebComponents } from './load-web-components';
12
12
  export { fetchRuntimeConfig, isExactVersion, isSriHash, RUNTIME_CONFIG_PATHS, RUNTIME_CONFIG_TIMEOUT_MS, } from './runtime-config';
13
- export { CORE_ELEMENTS_VERSION } from './core-elements-version';
13
+ export { PONTKIT_CORE_VERSION } from './pontkit-core-version';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const _ = "1.58.0", g = [
2
2
  "/__pontive/auth/v1/runtime-config",
3
3
  "/auth/v1/runtime-config"
4
- ], N = 1500, w = /^\d+\.\d+\.\d+$/;
4
+ ], I = 1500, w = /^\d+\.\d+\.\d+$/;
5
5
  function h(t) {
6
6
  return typeof t == "string" && w.test(t);
7
7
  }
@@ -12,11 +12,11 @@ function f(t) {
12
12
  return typeof t == "string" && /^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(t);
13
13
  }
14
14
  async function y(t = {}) {
15
- const e = t.fetchImpl ?? globalThis.fetch;
16
- if (typeof e != "function") return null;
17
- const i = t.urls ?? C(), s = t.timeoutMs ?? 1500;
15
+ const s = t.fetchImpl ?? globalThis.fetch;
16
+ if (typeof s != "function") return null;
17
+ const i = t.urls ?? C(), e = t.timeoutMs ?? 1500;
18
18
  for (const o of i) {
19
- const r = await E(e, o, s);
19
+ const r = await E(s, o, e);
20
20
  if (r) return r;
21
21
  }
22
22
  return null;
@@ -24,18 +24,18 @@ async function y(t = {}) {
24
24
  function C() {
25
25
  return typeof window < "u" && typeof window.__pontRuntimeConfigUrl == "string" ? [window.__pontRuntimeConfigUrl] : g;
26
26
  }
27
- async function E(t, e, i) {
28
- const s = typeof AbortController == "function" ? new AbortController() : null, o = s ? setTimeout(() => s.abort(), i) : null;
27
+ async function E(t, s, i) {
28
+ const e = typeof AbortController == "function" ? new AbortController() : null, o = e ? setTimeout(() => e.abort(), i) : null;
29
29
  try {
30
- const r = await t(e, {
30
+ const r = await t(s, {
31
31
  headers: { accept: "application/json" },
32
- signal: s?.signal
32
+ signal: e?.signal
33
33
  });
34
34
  if (!r.ok) return null;
35
35
  const n = await r.json();
36
- if (!n || !h(n.core_elements_version)) return null;
36
+ if (!n || !h(n.pontkit_version)) return null;
37
37
  const c = {
38
- core_elements_version: n.core_elements_version,
38
+ pontkit_version: n.pontkit_version,
39
39
  source: typeof n.source == "string" ? n.source : void 0,
40
40
  catalog_revision: typeof n.catalog_revision == "number" ? n.catalog_revision : void 0
41
41
  };
@@ -47,25 +47,25 @@ async function E(t, e, i) {
47
47
  }
48
48
  }
49
49
  let p = null, a = null;
50
- const l = "@pontive/pontkit-core", S = [
51
- (t) => `https://cdn.jsdelivr.net/npm/${l}@${t}/dist/index.mjs`,
52
- (t) => `https://unpkg.com/${l}@${t}/dist/index.mjs`,
53
- (t) => `https://esm.sh/${l}@${t}/dist/index.mjs`
54
- ], T = [
55
- (t) => `https://cdn.jsdelivr.net/npm/${l}@${t}/dist/styles.css`,
56
- (t) => `https://unpkg.com/${l}@${t}/dist/styles.css`,
57
- (t) => `https://esm.sh/${l}@${t}/dist/styles.css`
50
+ const d = "@pontive/pontkit-core", T = [
51
+ (t) => `https://cdn.jsdelivr.net/npm/${d}@${t}/dist/index.mjs`,
52
+ (t) => `https://unpkg.com/${d}@${t}/dist/index.mjs`,
53
+ (t) => `https://esm.sh/${d}@${t}/dist/index.mjs`
54
+ ], S = [
55
+ (t) => `https://cdn.jsdelivr.net/npm/${d}@${t}/dist/styles.css`,
56
+ (t) => `https://unpkg.com/${d}@${t}/dist/styles.css`,
57
+ (t) => `https://esm.sh/${d}@${t}/dist/styles.css`
58
58
  ], $ = _;
59
- function j(t, e) {
60
- return new Promise((i, s) => {
59
+ function j(t, s) {
60
+ return new Promise((i, e) => {
61
61
  const o = document.createElement("link");
62
- o.rel = "stylesheet", o.href = t, e && (o.integrity = e, o.crossOrigin = "anonymous"), o.onload = () => i(), o.onerror = (r) => s(r), document.head.appendChild(o);
62
+ o.rel = "stylesheet", o.href = t, s && (o.integrity = s, o.crossOrigin = "anonymous"), o.onload = () => i(), o.onerror = (r) => e(r), document.head.appendChild(o);
63
63
  });
64
64
  }
65
- function v(t, e) {
66
- return new Promise((i, s) => {
65
+ function v(t, s) {
66
+ return new Promise((i, e) => {
67
67
  const o = document.createElement("script");
68
- o.type = "module", o.src = t, o.integrity = e, o.crossOrigin = "anonymous", o.onload = () => i(), o.onerror = () => s(new Error(`core-elements module at ${t} failed to load or did not match its integrity hash`)), document.head.appendChild(o);
68
+ o.type = "module", o.src = t, o.integrity = s, o.crossOrigin = "anonymous", o.onload = () => i(), o.onerror = () => e(new Error(`pontkit-core module at ${t} failed to load or did not match its integrity hash`)), document.head.appendChild(o);
69
69
  }).then(
70
70
  () => import(
71
71
  /* webpackIgnore: true */
@@ -75,32 +75,32 @@ function v(t, e) {
75
75
  )
76
76
  );
77
77
  }
78
- async function O() {
79
- return typeof window > "u" || typeof document > "u" ? null : window.__pontLoaded ? window.__pontCore : window.__pontLoading ? window.__pontLoading : (a || (a = M().catch((t) => {
78
+ async function N() {
79
+ return typeof window > "u" || typeof document > "u" ? null : window.__pontLoaded ? window.__pontCore : window.__pontLoading ? window.__pontLoading : (a || (a = O().catch((t) => {
80
80
  throw a = null, window.__pontLoading = void 0, t;
81
81
  }), window.__pontLoading = a), a);
82
82
  }
83
- async function M() {
84
- const t = await y(), e = t?.core_elements_version ?? $, i = S.map((n) => n(e)), s = T.map((n) => n(e));
85
- t?.assets && (i.unshift(t.assets.js), s.unshift(t.assets.css));
83
+ async function O() {
84
+ const t = await y(), s = t?.pontkit_version ?? $, i = T.map((n) => n(s)), e = S.map((n) => n(s));
85
+ t?.assets && (i.unshift(t.assets.js), e.unshift(t.assets.css));
86
86
  const o = t?.integrity;
87
87
  let r = null;
88
88
  for (let n = 0; n < i.length; n++) {
89
- const c = i[n], m = s[n];
89
+ const c = i[n], m = e[n];
90
90
  try {
91
91
  await j(m, o?.css);
92
- const d = o ? await v(c, o.js) : await import(
92
+ const l = o ? await v(c, o.js) : await import(
93
93
  /* webpackIgnore: true */
94
94
  /* turbopackIgnore: true */
95
95
  /* @vite-ignore */
96
96
  c
97
97
  );
98
- return window.__pontCore = d, p = d, window.__pontLoaded = !0, window.__pontLoading = void 0, console.log(
99
- `PontKit Web Components loaded (${e}) from:`,
98
+ return window.__pontCore = l, p = l, window.__pontLoaded = !0, window.__pontLoading = void 0, console.log(
99
+ `PontKit Web Components loaded (${s}) from:`,
100
100
  c
101
101
  ), p;
102
- } catch (d) {
103
- console.error(`Failed loading from ${c}`, d), r = d;
102
+ } catch (l) {
103
+ console.error(`Failed loading from ${c}`, l), r = l;
104
104
  }
105
105
  }
106
106
  throw console.error(
@@ -109,12 +109,12 @@ async function M() {
109
109
  ), r;
110
110
  }
111
111
  export {
112
- _ as CORE_ELEMENTS_VERSION,
112
+ _ as PONTKIT_CORE_VERSION,
113
113
  g as RUNTIME_CONFIG_PATHS,
114
- N as RUNTIME_CONFIG_TIMEOUT_MS,
114
+ I as RUNTIME_CONFIG_TIMEOUT_MS,
115
115
  y as fetchRuntimeConfig,
116
116
  h as isExactVersion,
117
117
  f as isSriHash,
118
- O as loadWebComponents
118
+ N as loadWebComponents
119
119
  };
120
120
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/core-elements-version.ts","../src/runtime-config.ts","../src/load-web-components.ts"],"sourcesContent":["/**\n * The exact `@pontive/pontkit-core` release this build loads from the CDN.\n *\n * It is the version installed as a dev dependency when the package was built —\n * i.e. the one the test suite ran against — baked in by `define` in\n * vite.config.ts and vitest.config.ts (see scripts/core-elements-version.mjs).\n * An exact version, never a range: an exact release is immutable on the CDN,\n * cacheable forever, and the only form that admits an integrity hash.\n *\n * Nothing at runtime may replace this with \"whatever is newest\" — that is the\n * defect it exists to end. The platform's runtime-config endpoint will be\n * allowed to override it, because that answer is the one the platform has\n * gated (pontive-spec/21-element-versioning-and-compatibility.md §9).\n */\nexport const CORE_ELEMENTS_VERSION: string = __CORE_ELEMENTS_VERSION__;\n","// Which @pontive/pontkit-core release to load, asked of the platform.\n//\n// The platform decides which release a project's screens render with — one\n// deployment default, an optional per-project canary — and publishes the answer\n// at `GET /auth/v1/runtime-config` on the project's auth server\n// (pontive-spec/21-element-versioning-and-compatibility.md §9). This package\n// reads it once, before importing the bundle, so an embedded widget renders\n// with the same release the hosted login pages do. The build-time stamp\n// (CORE_ELEMENTS_VERSION) is the fallback when the answer cannot be read.\n//\n// The endpoint is reached through the app's own origin when the SDK's proxy is\n// mounted (`/__pontive/auth/v1/...`), and directly on `/auth/v1/...` when the app\n// itself runs on the auth domain. Both are tried; a host page can name a URL\n// outright with `window.__pontRuntimeConfigUrl`.\n\n/** The shape of GET /auth/v1/runtime-config. */\nexport interface RuntimeConfig {\n core_elements_version: string;\n catalog_revision?: number;\n source?: string;\n assets?: { js: string; css: string };\n /**\n * Subresource-integrity hashes (\"sha384-…\") of the release's module and\n * stylesheet, recorded by the platform when the release was gated. When\n * present the loader passes them to the browser, which refuses bytes that\n * differ — from the platform origin or from any public CDN alike.\n */\n integrity?: { js: string; css: string };\n}\n\nexport const RUNTIME_CONFIG_PATHS = [\n \"/__pontive/auth/v1/runtime-config\",\n \"/auth/v1/runtime-config\",\n] as const;\n\n/** How long to wait for the platform before loading the stamped release. */\nexport const RUNTIME_CONFIG_TIMEOUT_MS = 1500;\n\nconst EXACT_VERSION = /^\\d+\\.\\d+\\.\\d+$/;\n\nexport interface FetchRuntimeConfigOptions {\n fetchImpl?: typeof fetch;\n urls?: readonly string[];\n timeoutMs?: number;\n}\n\n/** Whether `value` names one release rather than a range or garbage. */\nexport function isExactVersion(value: unknown): value is string {\n return typeof value === \"string\" && EXACT_VERSION.test(value);\n}\n\nfunction isHttpUrl(value: unknown): value is string {\n return typeof value === \"string\" && /^https?:\\/\\//.test(value);\n}\n\n/** Whether `value` is a well-formed SRI value the browser will accept. */\nexport function isSriHash(value: unknown): value is string {\n return typeof value === \"string\" && /^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(value);\n}\n\n/**\n * Reads the platform's runtime config, or null when no candidate URL answers\n * with one that can be trusted. Never throws: the caller's fallback is the\n * stamped release, and a reachability problem should not become a page error.\n */\nexport async function fetchRuntimeConfig(\n options: FetchRuntimeConfigOptions = {},\n): Promise<RuntimeConfig | null> {\n const fetchImpl = options.fetchImpl ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") return null;\n\n const urls = options.urls ?? candidateUrls();\n const timeoutMs = options.timeoutMs ?? RUNTIME_CONFIG_TIMEOUT_MS;\n\n for (const url of urls) {\n const config = await readOne(fetchImpl, url, timeoutMs);\n if (config) return config;\n }\n\n return null;\n}\n\nfunction candidateUrls(): readonly string[] {\n if (typeof window !== \"undefined\" && typeof window.__pontRuntimeConfigUrl === \"string\") {\n return [window.__pontRuntimeConfigUrl];\n }\n\n return RUNTIME_CONFIG_PATHS;\n}\n\nasync function readOne(\n fetchImpl: typeof fetch,\n url: string,\n timeoutMs: number,\n): Promise<RuntimeConfig | null> {\n const controller = typeof AbortController === \"function\" ? new AbortController() : null;\n const timer = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;\n\n try {\n const response = await fetchImpl(url, {\n headers: { accept: \"application/json\" },\n signal: controller?.signal,\n });\n if (!response.ok) return null;\n\n const body = (await response.json()) as Partial<RuntimeConfig> | null;\n if (!body || !isExactVersion(body.core_elements_version)) return null;\n\n const config: RuntimeConfig = {\n core_elements_version: body.core_elements_version,\n source: typeof body.source === \"string\" ? body.source : undefined,\n catalog_revision:\n typeof body.catalog_revision === \"number\" ? body.catalog_revision : undefined,\n };\n\n // Assets are taken only as a pair of absolute URLs; anything else means\n // \"load from the CDN list by version\".\n if (body.assets && isHttpUrl(body.assets.js) && isHttpUrl(body.assets.css)) {\n config.assets = { js: body.assets.js, css: body.assets.css };\n }\n\n // Half a pair is no pair: the browser would check one file and not the\n // other, and nobody would notice the unchecked one.\n if (body.integrity && isSriHash(body.integrity.js) && isSriHash(body.integrity.css)) {\n config.integrity = { js: body.integrity.js, css: body.integrity.css };\n }\n\n return config;\n } catch {\n return null;\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n","import { CORE_ELEMENTS_VERSION } from \"./core-elements-version\";\nimport { fetchRuntimeConfig } from \"./runtime-config\";\n\nlet core: any = null;\n\n// The load in flight, if any. This is the guard, and it is a promise rather\n// than a boolean on purpose: a flag set before the first `await` let a second\n// concurrent caller return `core` while it was still null and carry on as if\n// it were ready. A\n// promise gives every caller the same eventual answer. It is cleared on failure\n// so a later call can retry rather than inherit a latched failure.\nlet loadPromise: Promise<any> | null = null;\n\nconst PACKAGE_NAME = \"@pontive/pontkit-core\";\n\n// Base CDN templates (version will be injected)\nconst CDN_TEMPLATES = [\n (v: string) =>\n `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n (v: string) => `https://unpkg.com/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n (v: string) => `https://esm.sh/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n];\n\nconst CSS_TEMPLATES = [\n (v: string) =>\n `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${v}/dist/styles.css`,\n (v: string) => `https://unpkg.com/${PACKAGE_NAME}@${v}/dist/styles.css`,\n (v: string) => `https://esm.sh/${PACKAGE_NAME}@${v}/dist/styles.css`,\n];\n\n// Which release loads is decided by the PLATFORM, and failing that at BUILD\n// time — never by asking a registry at runtime. This package used to fetch jsDelivr's version list and take the\n// newest entry of any major — the `1.x` filter had been commented out — with\n// `^1` as the fallback when the fetch failed, a different major from the 2.x\n// the wrappers target. Whatever npm happened to hold newest is not a version\n// anyone tested against, and a customer's page picked it up on the next reload\n// with nothing in their build having changed.\n//\n// Now the project's auth server says which release its screens load\n// (GET /auth/v1/runtime-config, see ./runtime-config.ts), so an embedded widget\n// renders with the same bundle the hosted login pages do, and a canary or a\n// promotion reaches it without a rebuild. CORE_ELEMENTS_VERSION — the exact\n// release this package was built and tested with — is the fallback when that\n// endpoint cannot be read.\nconst FALLBACK_VERSION = CORE_ELEMENTS_VERSION;\n\nfunction loadCss(url: string, integrity?: string) {\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = url;\n if (integrity) {\n // SRI is only enforced on a CORS-mode fetch; the platform origin and the\n // public CDNs all answer with Access-Control-Allow-Origin: *.\n link.integrity = integrity;\n link.crossOrigin = \"anonymous\";\n }\n link.onload = () => resolve();\n link.onerror = (err) => reject(err);\n document.head.appendChild(link);\n });\n}\n\n// Loads the module through a <script type=\"module\"> carrying the integrity\n// attribute, then imports it. A dynamic import() cannot carry SRI, but the\n// script element can, and once it has fetched and verified the module the\n// browser's module map holds it under that URL — the import() that follows\n// resolves from the map without a second fetch. A hash mismatch fails the\n// script's load, the promise rejects, and the loader moves to the next\n// source, which is the right outcome: bytes the platform did not gate must not\n// run, wherever they came from.\nfunction loadVerifiedModule(url: string, integrity: string): Promise<any> {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.type = \"module\";\n script.src = url;\n script.integrity = integrity;\n script.crossOrigin = \"anonymous\";\n script.onload = () => resolve();\n script.onerror = () =>\n reject(new Error(`core-elements module at ${url} failed to load or did not match its integrity hash`));\n document.head.appendChild(script);\n }).then(\n () =>\n import(\n /* webpackIgnore: true */\n /* turbopackIgnore: true */\n /* @vite-ignore */\n url\n ),\n );\n}\n\nexport async function loadWebComponents(): Promise<any> {\n // No DOM means no custom elements to define and no CDN to fetch from.\n //\n // Returning rather than throwing matters because src/index.ts calls this at\n // module scope: under a server renderer the rejection surfaced as a console\n // error on every render, reporting a failure that is not one. Checked before\n // the guards below so the browser still loads normally after hydration.\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return null;\n }\n\n // Another copy of this package on the same page already finished loading.\n if (window.__pontLoaded) {\n return window.__pontCore;\n }\n\n // Another copy of this package on the same page is loading right now.\n if (window.__pontLoading) {\n return window.__pontLoading;\n }\n\n if (!loadPromise) {\n loadPromise = loadFromCdn().catch((err) => {\n loadPromise = null;\n window.__pontLoading = undefined;\n throw err;\n });\n\n window.__pontLoading = loadPromise;\n }\n\n return loadPromise;\n}\n\nasync function loadFromCdn(): Promise<any> {\n const runtime = await fetchRuntimeConfig();\n const resolvedVersion = runtime?.core_elements_version ?? FALLBACK_VERSION;\n\n const CDN_SOURCES = CDN_TEMPLATES.map((fn) => fn(resolvedVersion));\n const CSS_SOURCES = CSS_TEMPLATES.map((fn) => fn(resolvedVersion));\n\n // The platform's own asset location goes first when it names one; the public\n // CDNs stay as the fallback list for the same version.\n if (runtime?.assets) {\n CDN_SOURCES.unshift(runtime.assets.js);\n CSS_SOURCES.unshift(runtime.assets.css);\n }\n\n // The hashes describe the npm release's bytes, which every source below\n // serves verbatim, so they apply to all of them — not only to the\n // platform's. A source whose bytes differ is a source that must not run.\n const integrity = runtime?.integrity;\n\n let lastError: unknown = null;\n\n for (let i = 0; i < CDN_SOURCES.length; i++) {\n const cdn = CDN_SOURCES[i];\n const cssCdn = CSS_SOURCES[i];\n\n try {\n // The stylesheet first, so the elements never render unstyled.\n await loadCss(cssCdn, integrity?.css);\n\n // Then the module.\n //\n // All three ignore directives, and none of them is optional.\n //\n // `cdn` is a full URL resolved at runtime, so a bundler that tries to\n // resolve it statically cannot: webpack and Turbopack turn a dynamic\n // import with a variable specifier into a module-graph lookup and throw\n // `Cannot find module 'https://…'` at runtime — no network request is ever\n // made, and the message reads as though the CDN were at fault. Next.js\n // uses Turbopack in development and webpack in production, so an app\n // built with it failed on every CDN in the list identically.\n //\n // `@vite-ignore` alone covered only Vite. Each bundler reads its own\n // comment and ignores the others, so all three coexist and each one keeps\n // this a real runtime import.\n const module: any = integrity\n ? await loadVerifiedModule(cdn, integrity.js)\n : await import(\n /* webpackIgnore: true */\n /* turbopackIgnore: true */\n /* @vite-ignore */\n cdn\n );\n\n // The elements define themselves on import. The module is kept on the\n // window so a second copy of this package on the page (two bindings,\n // two bundles) answers from it instead of loading the bundle again.\n // There is no SDK in it: the provider element is given one by its host\n // (the React `Provider` injects @pontive/oidc-client's `Auth`).\n window.__pontCore = module;\n core = module;\n\n // Set only once the module is on the window, so a copy of this package\n // that sees the flag can trust what it reads next to it.\n window.__pontLoaded = true;\n window.__pontLoading = undefined;\n\n console.log(\n `PontKit Web Components loaded (${resolvedVersion}) from:`,\n cdn,\n );\n\n return core;\n } catch (err) {\n console.error(`Failed loading from ${cdn}`, err);\n lastError = err;\n }\n }\n\n console.error(\n \"❌ Failed to load PontKit web components from all CDNs.\",\n lastError,\n );\n throw lastError;\n}\n"],"names":["CORE_ELEMENTS_VERSION","RUNTIME_CONFIG_PATHS","RUNTIME_CONFIG_TIMEOUT_MS","EXACT_VERSION","isExactVersion","value","isHttpUrl","isSriHash","fetchRuntimeConfig","options","fetchImpl","urls","candidateUrls","timeoutMs","url","config","readOne","controller","timer","response","body","core","loadPromise","PACKAGE_NAME","CDN_TEMPLATES","v","CSS_TEMPLATES","FALLBACK_VERSION","loadCss","integrity","resolve","reject","link","err","loadVerifiedModule","script","loadWebComponents","loadFromCdn","runtime","resolvedVersion","CDN_SOURCES","fn","CSS_SOURCES","lastError","i","cdn","cssCdn","module"],"mappings":"AAcO,MAAMA,IAAgC,UCgBhCC,IAAuB;AAAA,EAClC;AAAA,EACA;AACF,GAGaC,IAA4B,MAEnCC,IAAgB;AASf,SAASC,EAAeC,GAAiC;AAC9D,SAAO,OAAOA,KAAU,YAAYF,EAAc,KAAKE,CAAK;AAC9D;AAEA,SAASC,EAAUD,GAAiC;AAClD,SAAO,OAAOA,KAAU,YAAY,eAAe,KAAKA,CAAK;AAC/D;AAGO,SAASE,EAAUF,GAAiC;AACzD,SAAO,OAAOA,KAAU,YAAY,sCAAsC,KAAKA,CAAK;AACtF;AAOA,eAAsBG,EACpBC,IAAqC,IACN;AAC/B,QAAMC,IAAYD,EAAQ,aAAa,WAAW;AAClD,MAAI,OAAOC,KAAc,WAAY,QAAO;AAE5C,QAAMC,IAAOF,EAAQ,QAAQG,EAAA,GACvBC,IAAYJ,EAAQ,aAAa;AAEvC,aAAWK,KAAOH,GAAM;AACtB,UAAMI,IAAS,MAAMC,EAAQN,GAAWI,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core-version.ts","../src/runtime-config.ts","../src/load-web-components.ts"],"sourcesContent":["/**\n * The exact `@pontive/pontkit-core` release this build loads from the CDN.\n *\n * It is the version installed as a dev dependency when the package was built —\n * i.e. the one the test suite ran against — baked in by `define` in\n * vite.config.ts and vitest.config.ts (see scripts/pontkit-core-version.mjs).\n * An exact version, never a range: an exact release is immutable on the CDN,\n * cacheable forever, and the only form that admits an integrity hash.\n *\n * Nothing at runtime may replace this with \"whatever is newest\" — that is the\n * defect it exists to end. The platform's runtime-config endpoint will be\n * allowed to override it, because that answer is the one the platform has\n * gated (pontive-spec/21-element-versioning-and-compatibility.md §9).\n */\nexport const PONTKIT_CORE_VERSION: string = __PONTKIT_CORE_VERSION__;\n","// Which @pontive/pontkit-core release to load, asked of the platform.\n//\n// The platform decides which release a project's screens render with — one\n// deployment default, an optional per-project canary — and publishes the answer\n// at `GET /auth/v1/runtime-config` on the project's auth server\n// (pontive-spec/21-element-versioning-and-compatibility.md §9). This package\n// reads it once, before importing the bundle, so an embedded widget renders\n// with the same release the hosted login pages do. The build-time stamp\n// (PONTKIT_CORE_VERSION) is the fallback when the answer cannot be read.\n//\n// The endpoint is reached through the app's own origin when the SDK's proxy is\n// mounted (`/__pontive/auth/v1/...`), and directly on `/auth/v1/...` when the app\n// itself runs on the auth domain. Both are tried; a host page can name a URL\n// outright with `window.__pontRuntimeConfigUrl`.\n\n/** The shape of GET /auth/v1/runtime-config. */\nexport interface RuntimeConfig {\n pontkit_version: string;\n catalog_revision?: number;\n source?: string;\n assets?: { js: string; css: string };\n /**\n * Subresource-integrity hashes (\"sha384-…\") of the release's module and\n * stylesheet, recorded by the platform when the release was gated. When\n * present the loader passes them to the browser, which refuses bytes that\n * differ — from the platform origin or from any public CDN alike.\n */\n integrity?: { js: string; css: string };\n}\n\nexport const RUNTIME_CONFIG_PATHS = [\n \"/__pontive/auth/v1/runtime-config\",\n \"/auth/v1/runtime-config\",\n] as const;\n\n/** How long to wait for the platform before loading the stamped release. */\nexport const RUNTIME_CONFIG_TIMEOUT_MS = 1500;\n\nconst EXACT_VERSION = /^\\d+\\.\\d+\\.\\d+$/;\n\nexport interface FetchRuntimeConfigOptions {\n fetchImpl?: typeof fetch;\n urls?: readonly string[];\n timeoutMs?: number;\n}\n\n/** Whether `value` names one release rather than a range or garbage. */\nexport function isExactVersion(value: unknown): value is string {\n return typeof value === \"string\" && EXACT_VERSION.test(value);\n}\n\nfunction isHttpUrl(value: unknown): value is string {\n return typeof value === \"string\" && /^https?:\\/\\//.test(value);\n}\n\n/** Whether `value` is a well-formed SRI value the browser will accept. */\nexport function isSriHash(value: unknown): value is string {\n return typeof value === \"string\" && /^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(value);\n}\n\n/**\n * Reads the platform's runtime config, or null when no candidate URL answers\n * with one that can be trusted. Never throws: the caller's fallback is the\n * stamped release, and a reachability problem should not become a page error.\n */\nexport async function fetchRuntimeConfig(\n options: FetchRuntimeConfigOptions = {},\n): Promise<RuntimeConfig | null> {\n const fetchImpl = options.fetchImpl ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") return null;\n\n const urls = options.urls ?? candidateUrls();\n const timeoutMs = options.timeoutMs ?? RUNTIME_CONFIG_TIMEOUT_MS;\n\n for (const url of urls) {\n const config = await readOne(fetchImpl, url, timeoutMs);\n if (config) return config;\n }\n\n return null;\n}\n\nfunction candidateUrls(): readonly string[] {\n if (typeof window !== \"undefined\" && typeof window.__pontRuntimeConfigUrl === \"string\") {\n return [window.__pontRuntimeConfigUrl];\n }\n\n return RUNTIME_CONFIG_PATHS;\n}\n\nasync function readOne(\n fetchImpl: typeof fetch,\n url: string,\n timeoutMs: number,\n): Promise<RuntimeConfig | null> {\n const controller = typeof AbortController === \"function\" ? new AbortController() : null;\n const timer = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;\n\n try {\n const response = await fetchImpl(url, {\n headers: { accept: \"application/json\" },\n signal: controller?.signal,\n });\n if (!response.ok) return null;\n\n const body = (await response.json()) as Partial<RuntimeConfig> | null;\n if (!body || !isExactVersion(body.pontkit_version)) return null;\n\n const config: RuntimeConfig = {\n pontkit_version: body.pontkit_version,\n source: typeof body.source === \"string\" ? body.source : undefined,\n catalog_revision:\n typeof body.catalog_revision === \"number\" ? body.catalog_revision : undefined,\n };\n\n // Assets are taken only as a pair of absolute URLs; anything else means\n // \"load from the CDN list by version\".\n if (body.assets && isHttpUrl(body.assets.js) && isHttpUrl(body.assets.css)) {\n config.assets = { js: body.assets.js, css: body.assets.css };\n }\n\n // Half a pair is no pair: the browser would check one file and not the\n // other, and nobody would notice the unchecked one.\n if (body.integrity && isSriHash(body.integrity.js) && isSriHash(body.integrity.css)) {\n config.integrity = { js: body.integrity.js, css: body.integrity.css };\n }\n\n return config;\n } catch {\n return null;\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n","import { PONTKIT_CORE_VERSION } from \"./pontkit-core-version\";\nimport { fetchRuntimeConfig } from \"./runtime-config\";\n\nlet core: any = null;\n\n// The load in flight, if any. This is the guard, and it is a promise rather\n// than a boolean on purpose: a flag set before the first `await` let a second\n// concurrent caller return `core` while it was still null and carry on as if\n// it were ready. A\n// promise gives every caller the same eventual answer. It is cleared on failure\n// so a later call can retry rather than inherit a latched failure.\nlet loadPromise: Promise<any> | null = null;\n\nconst PACKAGE_NAME = \"@pontive/pontkit-core\";\n\n// Base CDN templates (version will be injected)\nconst CDN_TEMPLATES = [\n (v: string) =>\n `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n (v: string) => `https://unpkg.com/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n (v: string) => `https://esm.sh/${PACKAGE_NAME}@${v}/dist/index.mjs`,\n];\n\nconst CSS_TEMPLATES = [\n (v: string) =>\n `https://cdn.jsdelivr.net/npm/${PACKAGE_NAME}@${v}/dist/styles.css`,\n (v: string) => `https://unpkg.com/${PACKAGE_NAME}@${v}/dist/styles.css`,\n (v: string) => `https://esm.sh/${PACKAGE_NAME}@${v}/dist/styles.css`,\n];\n\n// Which release loads is decided by the PLATFORM, and failing that at BUILD\n// time — never by asking a registry at runtime. This package used to fetch jsDelivr's version list and take the\n// newest entry of any major — the `1.x` filter had been commented out — with\n// `^1` as the fallback when the fetch failed, a different major from the 2.x\n// the wrappers target. Whatever npm happened to hold newest is not a version\n// anyone tested against, and a customer's page picked it up on the next reload\n// with nothing in their build having changed.\n//\n// Now the project's auth server says which release its screens load\n// (GET /auth/v1/runtime-config, see ./runtime-config.ts), so an embedded widget\n// renders with the same bundle the hosted login pages do, and a canary or a\n// promotion reaches it without a rebuild. PONTKIT_CORE_VERSION — the exact\n// release this package was built and tested with — is the fallback when that\n// endpoint cannot be read.\nconst FALLBACK_VERSION = PONTKIT_CORE_VERSION;\n\nfunction loadCss(url: string, integrity?: string) {\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = url;\n if (integrity) {\n // SRI is only enforced on a CORS-mode fetch; the platform origin and the\n // public CDNs all answer with Access-Control-Allow-Origin: *.\n link.integrity = integrity;\n link.crossOrigin = \"anonymous\";\n }\n link.onload = () => resolve();\n link.onerror = (err) => reject(err);\n document.head.appendChild(link);\n });\n}\n\n// Loads the module through a <script type=\"module\"> carrying the integrity\n// attribute, then imports it. A dynamic import() cannot carry SRI, but the\n// script element can, and once it has fetched and verified the module the\n// browser's module map holds it under that URL — the import() that follows\n// resolves from the map without a second fetch. A hash mismatch fails the\n// script's load, the promise rejects, and the loader moves to the next\n// source, which is the right outcome: bytes the platform did not gate must not\n// run, wherever they came from.\nfunction loadVerifiedModule(url: string, integrity: string): Promise<any> {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.type = \"module\";\n script.src = url;\n script.integrity = integrity;\n script.crossOrigin = \"anonymous\";\n script.onload = () => resolve();\n script.onerror = () =>\n reject(new Error(`pontkit-core module at ${url} failed to load or did not match its integrity hash`));\n document.head.appendChild(script);\n }).then(\n () =>\n import(\n /* webpackIgnore: true */\n /* turbopackIgnore: true */\n /* @vite-ignore */\n url\n ),\n );\n}\n\nexport async function loadWebComponents(): Promise<any> {\n // No DOM means no custom elements to define and no CDN to fetch from.\n //\n // Returning rather than throwing matters because src/index.ts calls this at\n // module scope: under a server renderer the rejection surfaced as a console\n // error on every render, reporting a failure that is not one. Checked before\n // the guards below so the browser still loads normally after hydration.\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return null;\n }\n\n // Another copy of this package on the same page already finished loading.\n if (window.__pontLoaded) {\n return window.__pontCore;\n }\n\n // Another copy of this package on the same page is loading right now.\n if (window.__pontLoading) {\n return window.__pontLoading;\n }\n\n if (!loadPromise) {\n loadPromise = loadFromCdn().catch((err) => {\n loadPromise = null;\n window.__pontLoading = undefined;\n throw err;\n });\n\n window.__pontLoading = loadPromise;\n }\n\n return loadPromise;\n}\n\nasync function loadFromCdn(): Promise<any> {\n const runtime = await fetchRuntimeConfig();\n const resolvedVersion = runtime?.pontkit_version ?? FALLBACK_VERSION;\n\n const CDN_SOURCES = CDN_TEMPLATES.map((fn) => fn(resolvedVersion));\n const CSS_SOURCES = CSS_TEMPLATES.map((fn) => fn(resolvedVersion));\n\n // The platform's own asset location goes first when it names one; the public\n // CDNs stay as the fallback list for the same version.\n if (runtime?.assets) {\n CDN_SOURCES.unshift(runtime.assets.js);\n CSS_SOURCES.unshift(runtime.assets.css);\n }\n\n // The hashes describe the npm release's bytes, which every source below\n // serves verbatim, so they apply to all of them — not only to the\n // platform's. A source whose bytes differ is a source that must not run.\n const integrity = runtime?.integrity;\n\n let lastError: unknown = null;\n\n for (let i = 0; i < CDN_SOURCES.length; i++) {\n const cdn = CDN_SOURCES[i];\n const cssCdn = CSS_SOURCES[i];\n\n try {\n // The stylesheet first, so the elements never render unstyled.\n await loadCss(cssCdn, integrity?.css);\n\n // Then the module.\n //\n // All three ignore directives, and none of them is optional.\n //\n // `cdn` is a full URL resolved at runtime, so a bundler that tries to\n // resolve it statically cannot: webpack and Turbopack turn a dynamic\n // import with a variable specifier into a module-graph lookup and throw\n // `Cannot find module 'https://…'` at runtime — no network request is ever\n // made, and the message reads as though the CDN were at fault. Next.js\n // uses Turbopack in development and webpack in production, so an app\n // built with it failed on every CDN in the list identically.\n //\n // `@vite-ignore` alone covered only Vite. Each bundler reads its own\n // comment and ignores the others, so all three coexist and each one keeps\n // this a real runtime import.\n const module: any = integrity\n ? await loadVerifiedModule(cdn, integrity.js)\n : await import(\n /* webpackIgnore: true */\n /* turbopackIgnore: true */\n /* @vite-ignore */\n cdn\n );\n\n // The elements define themselves on import. The module is kept on the\n // window so a second copy of this package on the page (two bindings,\n // two bundles) answers from it instead of loading the bundle again.\n // There is no SDK in it: the provider element is given one by its host\n // (the React `Provider` injects @pontive/oidc-client's `Auth`).\n window.__pontCore = module;\n core = module;\n\n // Set only once the module is on the window, so a copy of this package\n // that sees the flag can trust what it reads next to it.\n window.__pontLoaded = true;\n window.__pontLoading = undefined;\n\n console.log(\n `PontKit Web Components loaded (${resolvedVersion}) from:`,\n cdn,\n );\n\n return core;\n } catch (err) {\n console.error(`Failed loading from ${cdn}`, err);\n lastError = err;\n }\n }\n\n console.error(\n \"❌ Failed to load PontKit web components from all CDNs.\",\n lastError,\n );\n throw lastError;\n}\n"],"names":["PONTKIT_CORE_VERSION","RUNTIME_CONFIG_PATHS","RUNTIME_CONFIG_TIMEOUT_MS","EXACT_VERSION","isExactVersion","value","isHttpUrl","isSriHash","fetchRuntimeConfig","options","fetchImpl","urls","candidateUrls","timeoutMs","url","config","readOne","controller","timer","response","body","core","loadPromise","PACKAGE_NAME","CDN_TEMPLATES","v","CSS_TEMPLATES","FALLBACK_VERSION","loadCss","integrity","resolve","reject","link","err","loadVerifiedModule","script","loadWebComponents","loadFromCdn","runtime","resolvedVersion","CDN_SOURCES","fn","CSS_SOURCES","lastError","i","cdn","cssCdn","module"],"mappings":"AAcO,MAAMA,IAA+B,UCgB/BC,IAAuB;AAAA,EAClC;AAAA,EACA;AACF,GAGaC,I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AI;AAEF,YAAMhB,EAAQkB,GAAQjB,GAAW,GAAG;AAiBpC,YAAMkB,IAAclB,IAChB,MAAMK,EAAmBW,GAAKhB,EAAU,EAAE,IAC1C,MAAM;AAAA;AAAA;AAAA;AAAA,QAIJgB;AAAA;AAQN,oBAAO,aAAaE,GACpB1B,IAAO0B,GAIP,OAAO,eAAe,IACtB,OAAO,gBAAgB,QAEvB,QAAQ;AAAA,QACN,kCAAkCR,CAAe;AAAA,QACjDM;AAAA,MAAA,GAGKxB;AAAA,IACT,SAASY,GAAK;AACZ,cAAQ,MAAM,uBAAuBY,CAAG,IAAIZ,CAAG,GAC/CU,IAAYV;AAAA,IACd;AAAA,EACF;AAEA,gBAAQ;AAAA,IACN;AAAA,IACAU;AAAA,EAAA,GAEIA;AACR;"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * It is the version installed as a dev dependency when the package was built —
5
5
  * i.e. the one the test suite ran against — baked in by `define` in
6
- * vite.config.ts and vitest.config.ts (see scripts/core-elements-version.mjs).
6
+ * vite.config.ts and vitest.config.ts (see scripts/pontkit-core-version.mjs).
7
7
  * An exact version, never a range: an exact release is immutable on the CDN,
8
8
  * cacheable forever, and the only form that admits an integrity hash.
9
9
  *
@@ -12,4 +12,4 @@
12
12
  * allowed to override it, because that answer is the one the platform has
13
13
  * gated (pontive-spec/21-element-versioning-and-compatibility.md §9).
14
14
  */
15
- export declare const CORE_ELEMENTS_VERSION: string;
15
+ export declare const PONTKIT_CORE_VERSION: string;
@@ -1,6 +1,6 @@
1
1
  /** The shape of GET /auth/v1/runtime-config. */
2
2
  export interface RuntimeConfig {
3
- core_elements_version: string;
3
+ pontkit_version: string;
4
4
  catalog_revision?: number;
5
5
  source?: string;
6
6
  assets?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pontive/pontkit-loader",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "license": "MIT",
5
5
  "description": "Loads @pontive/pontkit-core from the CDN at the release the platform decides.",
6
6
  "type": "module",