@pontive/pontkit-loader 1.0.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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The exact `@pontive/pontkit-core` release this build loads from the CDN.
3
+ *
4
+ * It is the version installed as a dev dependency when the package was built —
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).
7
+ * An exact version, never a range: an exact release is immutable on the CDN,
8
+ * cacheable forever, and the only form that admits an integrity hash.
9
+ *
10
+ * Nothing at runtime may replace this with "whatever is newest" — that is the
11
+ * defect it exists to end. The platform's runtime-config endpoint will be
12
+ * allowed to override it, because that answer is the one the platform has
13
+ * gated (pontive-spec/21-element-versioning-and-compatibility.md §9).
14
+ */
15
+ export declare const CORE_ELEMENTS_VERSION: string;
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=__CORE_ELEMENTS_VERSION__,U=["/__auth/auth/v1/runtime-config","/auth/v1/runtime-config"],j=1500,K=/^\d+\.\d+\.\d+$/;function F(t){return typeof t=="string"&&K.test(t)}function b(t){return typeof t=="string"&&/^https?:\/\//.test(t)}function P(t){return typeof t=="string"&&/^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(t)}async function V(t={}){const a=t.fetchImpl??globalThis.fetch;if(typeof a!="function")return null;const l=t.urls??D(),d=t.timeoutMs??j;for(const e of l){const p=await W(a,e,d);if(p)return p}return null}function D(){return typeof window<"u"&&typeof window.__pontRuntimeConfigUrl=="string"?[window.__pontRuntimeConfigUrl]:U}async function W(t,a,l){const d=typeof AbortController=="function"?new AbortController:null,e=d?setTimeout(()=>d.abort(),l):null;try{const p=await t(a,{headers:{accept:"application/json"},signal:d?.signal});if(!p.ok)return null;const n=await p.json();if(!n||!F(n.core_elements_version))return null;const g={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&&b(n.assets.js)&&b(n.assets.css)&&(g.assets={js:n.assets.js,css:n.assets.css}),n.integrity&&P(n.integrity.js)&&P(n.integrity.css)&&(g.integrity={js:n.integrity.js,css:n.integrity.css}),g}catch{return null}finally{e&&clearTimeout(e)}}let v=null,T=null;const S="@pontive/pontkit-core",q=[t=>`https://cdn.jsdelivr.net/npm/${S}@${t}/dist/index.mjs`,t=>`https://unpkg.com/${S}@${t}/dist/index.mjs`,t=>`https://esm.sh/${S}@${t}/dist/index.mjs`],z=[t=>`https://cdn.jsdelivr.net/npm/${S}@${t}/dist/styles.css`,t=>`https://unpkg.com/${S}@${t}/dist/styles.css`,t=>`https://esm.sh/${S}@${t}/dist/styles.css`],B=$;function X(t,a){return new Promise((l,d)=>{const e=document.createElement("link");e.rel="stylesheet",e.href=t,a&&(e.integrity=a,e.crossOrigin="anonymous"),e.onload=()=>l(),e.onerror=p=>d(p),document.head.appendChild(e)})}function Z(t,a){return new Promise((l,d)=>{const e=document.createElement("script");e.type="module",e.src=t,e.integrity=a,e.crossOrigin="anonymous",e.onload=()=>l(),e.onerror=()=>d(new Error(`core-elements module at ${t} failed to load or did not match its integrity hash`)),document.head.appendChild(e)}).then(()=>import(t))}async function x(){return typeof window>"u"||typeof document>"u"?null:window.__pontLoaded?window.__pontCoreSdk:window.__pontLoading?window.__pontLoading:(T||(T=J().catch(t=>{throw T=null,window.__pontLoading=void 0,t}),window.__pontLoading=T),T)}async function J(){const t=await V(),a=t?.core_elements_version??B,l=q.map(n=>n(a)),d=z.map(n=>n(a));t?.assets&&(l.unshift(t.assets.js),d.unshift(t.assets.css));const e=t?.integrity;let p=null;for(let n=0;n<l.length;n++){const g=l[n],G=d[n];try{let R=function(i){if(!i)return i;const C=[];let _=!1,m=null;const h=new Promise(o=>{m=o}),y=new Proxy(i,{get(o,c,f){if(c==="configure")return(...u)=>{const r=o.configure?.(...u);_=!0;try{C.forEach(({prop:w,args:I,resolve:A,reject:E})=>{try{const M=o[w].apply(o,I);M&&typeof M.then=="function"?M.then(A).catch(E):A(M)}catch(L){E(L)}})}catch{}C.length=0;try{y.__configured=!0}catch{}return m?.(),r};const s=o[c];return typeof s=="function"?(...u)=>{if(!_)return new Promise((r,w)=>{C.push({prop:c,args:u,resolve:r,reject:w})});try{return s.apply(o,u)}catch(r){throw r}}:s}});try{y.__whenConfigured=h,y.__configured=_}catch{}try{i.__whenConfigured=h,i.__configured=_;const o=i.configure;typeof o=="function"&&(i.configure=(...f)=>{const s=o.apply(i,f);_=!0;try{C.forEach(({prop:u,args:r,resolve:w,reject:I})=>{try{const E=i[u].apply(i,r);E&&typeof E.then=="function"?E.then(w).catch(I):w(E)}catch(A){I(A)}})}catch{}C.length=0;try{i.__configured=!0}catch{}return m?.(),s});const c=i.startLoginflow;typeof c=="function"&&(i.startLoginflow=(...f)=>_?c.apply(i,f):new Promise((s,u)=>{h.then(()=>{try{const r=c.apply(i,f);r&&typeof r.then=="function"?r.then(s).catch(u):s(r)}catch(r){u(r)}}).catch(()=>{try{const r=c.apply(i,f);r&&typeof r.then=="function"?r.then(s).catch(u):s(r)}catch(r){u(r)}})}))}catch{}try{h.then(()=>{setTimeout(()=>{try{document.querySelectorAll("pont-signin, pont-signup").forEach(o=>{try{if(o.__pontInitRetried)return;o.__pontInitRetried=!0;const c=o.__pontRetryInit;if(typeof c=="function"){try{c.call(o)}catch(f){console.error(f)}return}if(o.__pontFailedForConfig)try{o.connectedCallback?.()}catch(f){console.error(f)}}catch{}})}catch{}},0)})}catch{}return y};await X(G,e?.css);const k=e?await Z(g,e.js):await import(g),H=k.useAuthProvider?.(),N=R(H);try{k.Auth=N,k.useAuthProvider=()=>N}catch{}window.__pontCoreSdk={...k,Auth:N},v=window.__pontCoreSdk,window.__pontLoaded=!0,window.__pontLoading=void 0;try{const i=C=>{const _=customElements.get(C);if(!_)return;const m=_.prototype;if(m.__pontConfiguredPatched)return;m.__pontConfiguredPatched=!0;const h=m.connectedCallback;typeof h=="function"&&(m.connectedCallback=function(...y){const o=window.__pontCoreSdk?.Auth,c=o?.__whenConfigured,f=!!o?.__configured;if(c&&!f){c.then(()=>{try{h.apply(this,y)}catch(s){console.error(s)}}).catch(()=>{try{h.apply(this,y)}catch(s){console.error(s)}});return}try{h.apply(this,y)}catch(s){if(s&&typeof s.message=="string"&&s.message.includes("Auth.configure() must be called")&&c){c.then(()=>{try{h.apply(this,y)}catch(u){console.error(u)}});return}throw s}})};["pont-signin","pont-signup"].forEach(i)}catch{}return console.log(`PontKit Web Components loaded (${a}) from:`,g),v}catch(R){console.error(`Failed loading from ${g}`,R),p=R}}throw console.error("❌ Failed to load PontKit web components from all CDNs.",p),p}let O=null;async function Q(){typeof window>"u"||window.__pontCoreSdk?.openAccountSettingsModal||(O||(O=x().then(()=>{window.__pontCoreSdk?.openAccountSettingsModal||console.warn("[pontive-react] Core sdk loaded but modal functions are missing.")}).catch(t=>{throw console.error("[pontive-react] Failed to load core SDK:",t),t})),await O)}exports.CORE_ELEMENTS_VERSION=$;exports.RUNTIME_CONFIG_PATHS=U;exports.RUNTIME_CONFIG_TIMEOUT_MS=j;exports.ensureCoreSdkLoaded=Q;exports.fetchRuntimeConfig=V;exports.isExactVersion=F;exports.isSriHash=P;exports.loadWebComponents=x;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/core-elements-version.ts","../src/runtime-config.ts","../src/load-web-components.ts","../src/sdk-loaded.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 (`/__auth/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 \"/__auth/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 coreSdk: 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 `coreSdk` while it was still null, log that the\n// SDK's modal functions were missing, and carry on as if 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.__pontCoreSdk;\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 // 2️⃣ Load CSS first\n await loadCss(cssCdn, integrity?.css);\n\n // 3️⃣ Load JS 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 // 4️⃣ Expose globally\n // Wrap Auth so calls made before `configure()` won't throw. Instead\n // we queue them and flush once configure() is called by the provider.\n function createSafeAuth(auth: any) {\n if (!auth) return auth;\n type QItem = {\n prop: string | symbol;\n args: any[];\n resolve: (v: any) => void;\n reject: (e: any) => void;\n };\n const queue: QItem[] = [];\n let configured = false;\n\n // Expose a configured promise and flag on the proxy so other parts\n // of the app can wait for Auth to be configured (helps avoid errors\n // thrown by custom elements that start flows on connect).\n let resolveWhenConfigured: (() => void) | null = null;\n const whenConfigured = new Promise<void>((res) => {\n resolveWhenConfigured = res;\n });\n\n const proxy = new Proxy(auth, {\n get(target, prop, receiver) {\n if (prop === \"configure\") {\n return (...args: any[]) => {\n const res = (target as any).configure?.(...args);\n configured = true;\n try {\n // flush queued calls\n queue.forEach(({ prop: p, args: a, resolve, reject }) => {\n try {\n const fn = (target as any)[p];\n const r = fn.apply(target, a);\n if (r && typeof r.then === \"function\") {\n r.then(resolve).catch(reject);\n } else {\n resolve(r);\n }\n } catch (err) {\n reject(err);\n }\n });\n } catch (e) {\n // ignore flushing errors\n }\n queue.length = 0;\n // mark proxy as configured and resolve the promise\n try {\n (proxy as any).__configured = true;\n } catch (e) {\n /* ignore */\n }\n resolveWhenConfigured?.();\n return res;\n };\n }\n\n const val = (target as any)[prop];\n if (typeof val === \"function\") {\n return (...args: any[]) => {\n if (!configured) {\n // queue the call and return a Promise that resolves when flushed\n return new Promise((resolve, reject) => {\n queue.push({ prop, args, resolve, reject });\n });\n }\n try {\n return val.apply(target, args);\n } catch (e) {\n // preserve throwing behavior for already-configured\n throw e;\n }\n };\n }\n return val;\n },\n });\n\n // Attach the whenConfigured promise and configured flag to the proxy\n try {\n (proxy as any).__whenConfigured = whenConfigured;\n (proxy as any).__configured = configured;\n } catch (e) {\n /* ignore */\n }\n\n // Also patch the original `auth` object (if present) so that direct\n // imports and in-module usages get queued behavior too. This ensures\n // that calls like `Auth.startLoginflow()` won't throw even if they\n // happen before `configure()` is invoked.\n try {\n // Mark the original with the same hooks\n (auth as any).__whenConfigured = whenConfigured;\n (auth as any).__configured = configured;\n\n const origConfigure = (auth as any).configure;\n if (typeof origConfigure === \"function\") {\n (auth as any).configure = (...args: any[]) => {\n const res = origConfigure.apply(auth, args);\n configured = true;\n try {\n queue.forEach(({ prop: p, args: a, resolve, reject }) => {\n try {\n const fn = (auth as any)[p];\n const r = fn.apply(auth, a);\n if (r && typeof r.then === \"function\") {\n r.then(resolve).catch(reject);\n } else {\n resolve(r);\n }\n } catch (err) {\n reject(err);\n }\n });\n } catch (e) {\n /* ignore */\n }\n queue.length = 0;\n try {\n (auth as any).__configured = true;\n } catch (e) {\n /* ignore */\n }\n resolveWhenConfigured?.();\n return res;\n };\n }\n\n const origStart = (auth as any).startLoginflow;\n if (typeof origStart === \"function\") {\n (auth as any).startLoginflow = (...args: any[]) => {\n if (!configured) {\n return new Promise((resolve, reject) => {\n whenConfigured\n .then(() => {\n try {\n const r = origStart.apply(auth, args);\n if (r && typeof r.then === \"function\") {\n r.then(resolve).catch(reject);\n } else {\n resolve(r);\n }\n } catch (err) {\n reject(err);\n }\n })\n .catch(() => {\n try {\n const r = origStart.apply(auth, args);\n if (r && typeof r.then === \"function\") {\n r.then(resolve).catch(reject);\n } else {\n resolve(r);\n }\n } catch (err) {\n reject(err);\n }\n });\n });\n }\n\n return origStart.apply(auth, args);\n };\n }\n } catch (e) {\n /* ignore */\n }\n\n // When auth is configured, call an explicit retry method on any\n // sign-in/up elements that implement it. Prefer an explicit retry\n // API so elements can be idempotent and avoid duplicate flows.\n try {\n whenConfigured.then(() => {\n setTimeout(() => {\n try {\n document\n .querySelectorAll(\"pont-signin, pont-signup\")\n .forEach((el) => {\n try {\n if ((el as any).__pontInitRetried) return;\n (el as any).__pontInitRetried = true;\n // Prefer an explicit retry API implemented by the element\n // (e.g., `__pontRetryInit`) to avoid re-running the\n // entire `connectedCallback` which may cause duplicates.\n const retry = (el as any).__pontRetryInit;\n if (typeof retry === \"function\") {\n try {\n retry.call(el);\n } catch (e) {\n console.error(e);\n }\n return;\n }\n\n // Fallback: only call connectedCallback if the element\n // provides an explicit flag saying it previously failed\n // due to missing Auth (set by our connectedCallback wrapper\n // when we detect that specific error).\n if ((el as any).__pontFailedForConfig) {\n try {\n (el as any).connectedCallback?.();\n } catch (e) {\n console.error(e);\n }\n }\n } catch (_) {\n // ignore per-element errors\n }\n });\n } catch (_) {\n /* ignore */\n }\n }, 0);\n });\n } catch (e) {\n /* ignore */\n }\n\n return proxy;\n }\n\n // Replace module exports so consumers that import `Auth` directly\n // get the safe proxy as well. Also ensure `useAuthProvider()` returns\n // the proxy.\n const realAuth = module.useAuthProvider?.();\n const safeAuth = createSafeAuth(realAuth);\n\n try {\n (module as any).Auth = safeAuth;\n (module as any).useAuthProvider = () => safeAuth;\n } catch (e) {\n /* ignore */\n }\n\n window.__pontCoreSdk = {\n ...module,\n Auth: safeAuth,\n };\n\n coreSdk = window.__pontCoreSdk;\n\n // Set only once the SDK is actually on the window, so a copy of this\n // package that sees the flag can trust what it reads next to it.\n window.__pontLoaded = true;\n window.__pontLoading = undefined;\n\n // Patch known elements that may start flows on connect so they wait\n // for Auth to be configured instead of throwing. This avoids noisy\n // runtime errors like \"Auth.configure() must be called\".\n try {\n const patchElement = (tagName: string) => {\n const ctor = customElements.get(tagName);\n if (!ctor) return;\n const proto = ctor.prototype as any;\n if (proto.__pontConfiguredPatched) return;\n proto.__pontConfiguredPatched = true;\n\n const orig = proto.connectedCallback;\n if (typeof orig !== \"function\") return;\n\n proto.connectedCallback = function (...args: any[]) {\n const auth = window.__pontCoreSdk?.Auth as any;\n const whenConfigured = auth?.__whenConfigured as\n | Promise<void>\n | undefined;\n const configured = !!auth?.__configured;\n\n if (whenConfigured && !configured) {\n // delay initial connect work until Auth is configured\n whenConfigured\n .then(() => {\n try {\n orig.apply(this, args);\n } catch (e) {\n console.error(e);\n }\n })\n .catch(() => {\n try {\n orig.apply(this, args);\n } catch (e) {\n console.error(e);\n }\n });\n return;\n }\n\n try {\n orig.apply(this, args);\n } catch (e: any) {\n // If it still throws with the configure error, retry after configured\n if (\n e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"Auth.configure() must be called\") &&\n whenConfigured\n ) {\n whenConfigured.then(() => {\n try {\n orig.apply(this, args);\n } catch (err) {\n console.error(err);\n }\n });\n return;\n }\n throw e;\n }\n };\n };\n\n // Elements known to start auth flows on connect\n [\"pont-signin\", \"pont-signup\"].forEach(patchElement);\n } catch (e) {\n /* ignore patch errors */\n }\n\n console.log(\n `PontKit Web Components loaded (${resolvedVersion}) from:`,\n cdn,\n );\n\n return coreSdk;\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","import { loadWebComponents } from \"./load-web-components\";\n\nlet coreSdkLoadPromise: Promise<void> | null = null;\n\n/**\n * Ensures the core SDK is loaded and the global functions are available.\n * Returns a promise that resolves when the SDK is ready.\n */\nexport async function ensureCoreSdkLoaded(): Promise<void> {\n // Nothing to ensure without a browser, and the check below would throw before\n // reaching loadWebComponents' own guard.\n if (typeof window === \"undefined\") {\n return;\n }\n\n // If the functions already exist, we're done.\n if (window.__pontCoreSdk?.openAccountSettingsModal) {\n return;\n }\n\n // Otherwise, start loading the SDK if not already loading.\n if (!coreSdkLoadPromise) {\n coreSdkLoadPromise = loadWebComponents()\n .then(() => {\n // The first SDK script attaches the functions synchronously when it executes.\n if (!window.__pontCoreSdk?.openAccountSettingsModal) {\n console.warn(\n \"[pontive-react] Core sdk loaded but modal functions are missing.\",\n );\n }\n })\n .catch((err) => {\n console.error(\"[pontive-react] Failed to load core SDK:\", err);\n throw err;\n });\n }\n\n await coreSdkLoadPromise;\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","coreSdk","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","createSafeAuth","auth","queue","configured","resolveWhenConfigured","whenConfigured","res","proxy","target","prop","receiver","args","p","a","r","val","e","origConfigure","origStart","el","retry","module","realAuth","safeAuth","patchElement","tagName","ctor","proto","orig","coreSdkLoadPromise","ensureCoreSdkLoaded"],"mappings":"gFAcO,MAAMA,EAAgC,0BCgBhCC,EAAuB,CAClC,iCACA,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,EAAKD,CAAS,EACtD,GAAIE,EAAQ,OAAOA,CACrB,CAEA,OAAO,IACT,CAEA,SAASH,GAAmC,CAC1C,OAAI,OAAO,OAAW,KAAe,OAAO,OAAO,wBAA2B,SACrE,CAAC,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,GAAIZ,CAAG,EAC/CU,EAAYV,CACd,CACF,CAEA,cAAQ,MACN,yDACAU,CAAA,EAEIA,CACR,CCjgBA,IAAIiC,EAA2C,KAM/C,eAAsBC,GAAqC,CAGrD,OAAO,OAAW,KAKlB,OAAO,eAAe,2BAKrBD,IACHA,EAAqBxC,IAClB,KAAK,IAAM,CAEL,OAAO,eAAe,0BACzB,QAAQ,KACN,kEAAA,CAGN,CAAC,EACA,MAAOH,GAAQ,CACd,cAAQ,MAAM,2CAA4CA,CAAG,EACvDA,CACR,CAAC,GAGL,MAAM2C,EACR"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The CDN loader.
3
+ *
4
+ * Every framework binding sits on this: it resolves which @pontive/pontkit-core
5
+ * release to load, fetches it with its integrity hashes, and puts the SDK on
6
+ * the window where the elements and the bindings can both find it.
7
+ *
8
+ * Kept separate from the bindings because Vue, Svelte and Solid need almost
9
+ * nothing else, and must not pull in React to get it.
10
+ */
11
+ export { loadWebComponents } from './load-web-components';
12
+ export { ensureCoreSdkLoaded } from './sdk-loaded';
13
+ export { fetchRuntimeConfig, isExactVersion, isSriHash, RUNTIME_CONFIG_PATHS, RUNTIME_CONFIG_TIMEOUT_MS, } from './runtime-config';
14
+ export { CORE_ELEMENTS_VERSION } from './core-elements-version';
package/dist/index.js ADDED
@@ -0,0 +1,311 @@
1
+ const F = __CORE_ELEMENTS_VERSION__, U = [
2
+ "/__auth/auth/v1/runtime-config",
3
+ "/auth/v1/runtime-config"
4
+ ], x = 1500, V = /^\d+\.\d+\.\d+$/;
5
+ function K(t) {
6
+ return typeof t == "string" && V.test(t);
7
+ }
8
+ function I(t) {
9
+ return typeof t == "string" && /^https?:\/\//.test(t);
10
+ }
11
+ function M(t) {
12
+ return typeof t == "string" && /^sha(256|384|512)-[A-Za-z0-9+/]+=*$/.test(t);
13
+ }
14
+ async function D(t = {}) {
15
+ const a = t.fetchImpl ?? globalThis.fetch;
16
+ if (typeof a != "function") return null;
17
+ const l = t.urls ?? G(), f = t.timeoutMs ?? x;
18
+ for (const e of l) {
19
+ const p = await H(a, e, f);
20
+ if (p) return p;
21
+ }
22
+ return null;
23
+ }
24
+ function G() {
25
+ return typeof window < "u" && typeof window.__pontRuntimeConfigUrl == "string" ? [window.__pontRuntimeConfigUrl] : U;
26
+ }
27
+ async function H(t, a, l) {
28
+ const f = typeof AbortController == "function" ? new AbortController() : null, e = f ? setTimeout(() => f.abort(), l) : null;
29
+ try {
30
+ const p = await t(a, {
31
+ headers: { accept: "application/json" },
32
+ signal: f?.signal
33
+ });
34
+ if (!p.ok) return null;
35
+ const n = await p.json();
36
+ if (!n || !K(n.core_elements_version)) return null;
37
+ const g = {
38
+ core_elements_version: n.core_elements_version,
39
+ source: typeof n.source == "string" ? n.source : void 0,
40
+ catalog_revision: typeof n.catalog_revision == "number" ? n.catalog_revision : void 0
41
+ };
42
+ return n.assets && I(n.assets.js) && I(n.assets.css) && (g.assets = { js: n.assets.js, css: n.assets.css }), n.integrity && M(n.integrity.js) && M(n.integrity.css) && (g.integrity = { js: n.integrity.js, css: n.integrity.css }), g;
43
+ } catch {
44
+ return null;
45
+ } finally {
46
+ e && clearTimeout(e);
47
+ }
48
+ }
49
+ let N = null, k = null;
50
+ const S = "@pontive/pontkit-core", W = [
51
+ (t) => `https://cdn.jsdelivr.net/npm/${S}@${t}/dist/index.mjs`,
52
+ (t) => `https://unpkg.com/${S}@${t}/dist/index.mjs`,
53
+ (t) => `https://esm.sh/${S}@${t}/dist/index.mjs`
54
+ ], q = [
55
+ (t) => `https://cdn.jsdelivr.net/npm/${S}@${t}/dist/styles.css`,
56
+ (t) => `https://unpkg.com/${S}@${t}/dist/styles.css`,
57
+ (t) => `https://esm.sh/${S}@${t}/dist/styles.css`
58
+ ], z = F;
59
+ function B(t, a) {
60
+ return new Promise((l, f) => {
61
+ const e = document.createElement("link");
62
+ e.rel = "stylesheet", e.href = t, a && (e.integrity = a, e.crossOrigin = "anonymous"), e.onload = () => l(), e.onerror = (p) => f(p), document.head.appendChild(e);
63
+ });
64
+ }
65
+ function X(t, a) {
66
+ return new Promise((l, f) => {
67
+ const e = document.createElement("script");
68
+ e.type = "module", e.src = t, e.integrity = a, e.crossOrigin = "anonymous", e.onload = () => l(), e.onerror = () => f(new Error(`core-elements module at ${t} failed to load or did not match its integrity hash`)), document.head.appendChild(e);
69
+ }).then(
70
+ () => import(
71
+ /* webpackIgnore: true */
72
+ /* turbopackIgnore: true */
73
+ /* @vite-ignore */
74
+ t
75
+ )
76
+ );
77
+ }
78
+ async function Z() {
79
+ return typeof window > "u" || typeof document > "u" ? null : window.__pontLoaded ? window.__pontCoreSdk : window.__pontLoading ? window.__pontLoading : (k || (k = J().catch((t) => {
80
+ throw k = null, window.__pontLoading = void 0, t;
81
+ }), window.__pontLoading = k), k);
82
+ }
83
+ async function J() {
84
+ const t = await D(), a = t?.core_elements_version ?? z, l = W.map((n) => n(a)), f = q.map((n) => n(a));
85
+ t?.assets && (l.unshift(t.assets.js), f.unshift(t.assets.css));
86
+ const e = t?.integrity;
87
+ let p = null;
88
+ for (let n = 0; n < l.length; n++) {
89
+ const g = l[n], O = f[n];
90
+ try {
91
+ let P = function(i) {
92
+ if (!i) return i;
93
+ const C = [];
94
+ let _ = !1, m = null;
95
+ const h = new Promise((o) => {
96
+ m = o;
97
+ }), y = new Proxy(i, {
98
+ get(o, c, d) {
99
+ if (c === "configure")
100
+ return (...u) => {
101
+ const r = o.configure?.(...u);
102
+ _ = !0;
103
+ try {
104
+ C.forEach(({ prop: w, args: $, resolve: A, reject: E }) => {
105
+ try {
106
+ const v = o[w].apply(o, $);
107
+ v && typeof v.then == "function" ? v.then(A).catch(E) : A(v);
108
+ } catch (b) {
109
+ E(b);
110
+ }
111
+ });
112
+ } catch {
113
+ }
114
+ C.length = 0;
115
+ try {
116
+ y.__configured = !0;
117
+ } catch {
118
+ }
119
+ return m?.(), r;
120
+ };
121
+ const s = o[c];
122
+ return typeof s == "function" ? (...u) => {
123
+ if (!_)
124
+ return new Promise((r, w) => {
125
+ C.push({ prop: c, args: u, resolve: r, reject: w });
126
+ });
127
+ try {
128
+ return s.apply(o, u);
129
+ } catch (r) {
130
+ throw r;
131
+ }
132
+ } : s;
133
+ }
134
+ });
135
+ try {
136
+ y.__whenConfigured = h, y.__configured = _;
137
+ } catch {
138
+ }
139
+ try {
140
+ i.__whenConfigured = h, i.__configured = _;
141
+ const o = i.configure;
142
+ typeof o == "function" && (i.configure = (...d) => {
143
+ const s = o.apply(i, d);
144
+ _ = !0;
145
+ try {
146
+ C.forEach(({ prop: u, args: r, resolve: w, reject: $ }) => {
147
+ try {
148
+ const E = i[u].apply(i, r);
149
+ E && typeof E.then == "function" ? E.then(w).catch($) : w(E);
150
+ } catch (A) {
151
+ $(A);
152
+ }
153
+ });
154
+ } catch {
155
+ }
156
+ C.length = 0;
157
+ try {
158
+ i.__configured = !0;
159
+ } catch {
160
+ }
161
+ return m?.(), s;
162
+ });
163
+ const c = i.startLoginflow;
164
+ typeof c == "function" && (i.startLoginflow = (...d) => _ ? c.apply(i, d) : new Promise((s, u) => {
165
+ h.then(() => {
166
+ try {
167
+ const r = c.apply(i, d);
168
+ r && typeof r.then == "function" ? r.then(s).catch(u) : s(r);
169
+ } catch (r) {
170
+ u(r);
171
+ }
172
+ }).catch(() => {
173
+ try {
174
+ const r = c.apply(i, d);
175
+ r && typeof r.then == "function" ? r.then(s).catch(u) : s(r);
176
+ } catch (r) {
177
+ u(r);
178
+ }
179
+ });
180
+ }));
181
+ } catch {
182
+ }
183
+ try {
184
+ h.then(() => {
185
+ setTimeout(() => {
186
+ try {
187
+ document.querySelectorAll("pont-signin, pont-signup").forEach((o) => {
188
+ try {
189
+ if (o.__pontInitRetried) return;
190
+ o.__pontInitRetried = !0;
191
+ const c = o.__pontRetryInit;
192
+ if (typeof c == "function") {
193
+ try {
194
+ c.call(o);
195
+ } catch (d) {
196
+ console.error(d);
197
+ }
198
+ return;
199
+ }
200
+ if (o.__pontFailedForConfig)
201
+ try {
202
+ o.connectedCallback?.();
203
+ } catch (d) {
204
+ console.error(d);
205
+ }
206
+ } catch {
207
+ }
208
+ });
209
+ } catch {
210
+ }
211
+ }, 0);
212
+ });
213
+ } catch {
214
+ }
215
+ return y;
216
+ };
217
+ await B(O, e?.css);
218
+ const L = e ? await X(g, e.js) : await import(
219
+ /* webpackIgnore: true */
220
+ /* turbopackIgnore: true */
221
+ /* @vite-ignore */
222
+ g
223
+ ), j = L.useAuthProvider?.(), R = P(j);
224
+ try {
225
+ L.Auth = R, L.useAuthProvider = () => R;
226
+ } catch {
227
+ }
228
+ window.__pontCoreSdk = {
229
+ ...L,
230
+ Auth: R
231
+ }, N = window.__pontCoreSdk, window.__pontLoaded = !0, window.__pontLoading = void 0;
232
+ try {
233
+ const i = (C) => {
234
+ const _ = customElements.get(C);
235
+ if (!_) return;
236
+ const m = _.prototype;
237
+ if (m.__pontConfiguredPatched) return;
238
+ m.__pontConfiguredPatched = !0;
239
+ const h = m.connectedCallback;
240
+ typeof h == "function" && (m.connectedCallback = function(...y) {
241
+ const o = window.__pontCoreSdk?.Auth, c = o?.__whenConfigured, d = !!o?.__configured;
242
+ if (c && !d) {
243
+ c.then(() => {
244
+ try {
245
+ h.apply(this, y);
246
+ } catch (s) {
247
+ console.error(s);
248
+ }
249
+ }).catch(() => {
250
+ try {
251
+ h.apply(this, y);
252
+ } catch (s) {
253
+ console.error(s);
254
+ }
255
+ });
256
+ return;
257
+ }
258
+ try {
259
+ h.apply(this, y);
260
+ } catch (s) {
261
+ if (s && typeof s.message == "string" && s.message.includes("Auth.configure() must be called") && c) {
262
+ c.then(() => {
263
+ try {
264
+ h.apply(this, y);
265
+ } catch (u) {
266
+ console.error(u);
267
+ }
268
+ });
269
+ return;
270
+ }
271
+ throw s;
272
+ }
273
+ });
274
+ };
275
+ ["pont-signin", "pont-signup"].forEach(i);
276
+ } catch {
277
+ }
278
+ return console.log(
279
+ `PontKit Web Components loaded (${a}) from:`,
280
+ g
281
+ ), N;
282
+ } catch (P) {
283
+ console.error(`Failed loading from ${g}`, P), p = P;
284
+ }
285
+ }
286
+ throw console.error(
287
+ "❌ Failed to load PontKit web components from all CDNs.",
288
+ p
289
+ ), p;
290
+ }
291
+ let T = null;
292
+ async function Q() {
293
+ typeof window > "u" || window.__pontCoreSdk?.openAccountSettingsModal || (T || (T = Z().then(() => {
294
+ window.__pontCoreSdk?.openAccountSettingsModal || console.warn(
295
+ "[pontive-react] Core sdk loaded but modal functions are missing."
296
+ );
297
+ }).catch((t) => {
298
+ throw console.error("[pontive-react] Failed to load core SDK:", t), t;
299
+ })), await T);
300
+ }
301
+ export {
302
+ F as CORE_ELEMENTS_VERSION,
303
+ U as RUNTIME_CONFIG_PATHS,
304
+ x as RUNTIME_CONFIG_TIMEOUT_MS,
305
+ Q as ensureCoreSdkLoaded,
306
+ D as fetchRuntimeConfig,
307
+ K as isExactVersion,
308
+ M as isSriHash,
309
+ Z as loadWebComponents
310
+ };
311
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/core-elements-version.ts","../src/runtime-config.ts","../src/load-web-components.ts","../src/sdk-loaded.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 (`/__auth/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 \"/__auth/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 coreSdk: 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 `coreSdk` while it was still null, log that the\n// SDK's modal functions were missing, and carry on as if 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.__pontCoreSdk;\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 // 2️⃣ Load CSS first\n await loadCss(cssCdn, integrity?.css);\n\n // 3️⃣ Load JS 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 // 4️⃣ Expose globally\n // Wrap Auth so calls made before `configure()` won't throw. Instead\n // we queue them and flush once configure() is called by the provider.\n function createSafeAuth(auth: any) {\n if (!auth) return auth;\n type QItem = {\n prop: string | symbol;\n args: any[];\n resolve: (v: any) => void;\n reject: (e: any) => void;\n };\n const queue: QItem[] = [];\n let configured = false;\n\n // Expose a configured promise and flag on the proxy so other parts\n // of the app can wait for Auth to be configured (helps avoid errors\n // thrown by custom elements that start flows on connect).\n let resolveWhenConfigured: (() => void) | null = null;\n const whenConfigured = new Promise<void>((res) => {\n resolveWhenConfigured = res;\n });\n\n const proxy = new Proxy(auth, {\n get(target, prop, receiver) {\n if (prop === \"configure\") {\n return (...args: any[]) => {\n const res = (target as any).configure?.(...args);\n configured = true;\n try {\n // flush queued calls\n queue.forEach(({ prop: p, args: a, resolve, reject }) => {\n try {\n const fn = (target as any)[p];\n const r = fn.apply(target, a);\n if (r && typeof r.then === \"function\") {\n r.then(resolve).catch(reject);\n } else {\n resolve(r);\n }\n } catch (err) {\n reject(err);\n }\n });\n } catch (e) {\n // ignore flushing errors\n }\n queue.length = 0;\n // mark proxy as configured and resolve the promise\n try {\n (proxy as any).__configured = true;\n } catch (e) {\n /* ignore */\n }\n resolveWhenConfigured?.();\n return res;\n };\n }\n\n const val = (target as any)[prop];\n if (typeof val === \"function\") {\n return (...args: any[]) => {\n if (!configured) {\n // queue the call and return a Promise that resolves when flushed\n return new Promise((resolve, reject) => {\n queue.push({ prop, args, resolve, reject });\n });\n }\n try {\n return val.apply(target, args);\n } catch (e) {\n // preserve throwing behavior for already-configured\n throw e;\n }\n };\n }\n return val;\n },\n });\n\n // Attach the whenConfigured promise and configured flag to the proxy\n try {\n (proxy as any).__whenConfigured = whenConfigured;\n (proxy as any).__configured = configured;\n } catch (e) {\n /* ignore */\n }\n\n // Also patch the original `auth` object (if present) so that direct\n // imports and in-module usages get queued behavior too. This ensures\n // that calls like `Auth.startLoginflow()` won't throw even if they\n // happen before `configure()` is invoked.\n try {\n // Mark the original with the same hooks\n (auth as any).__whenConfigured = whenConfigured;\n (auth as any).__configured = configured;\n\n const origConfigure = (auth as any).configure;\n if (typeof origConfigure === \"function\") {\n (auth as any).configure = (...args: any[]) => {\n const res = origConfigure.apply(auth, args);\n configured = true;\n try {\n queue.forEach(({ prop: p, args: a, resolve, reject }) => {\n try {\n const fn = (auth as any)[p];\n const r = fn.apply(auth, a);\n if (r && typeof r.then === \"function\") {\n r.then(resolve).catch(reject);\n } else {\n resolve(r);\n }\n } catch (err) {\n reject(err);\n }\n });\n } catch (e) {\n /* ignore */\n }\n queue.length = 0;\n try {\n (auth as any).__configured = true;\n } catch (e) {\n /* ignore */\n }\n resolveWhenConfigured?.();\n return res;\n };\n }\n\n const origStart = (auth as any).startLoginflow;\n if (typeof origStart === \"function\") {\n (auth as any).startLoginflow = (...args: any[]) => {\n if (!configured) {\n return new Promise((resolve, reject) => {\n whenConfigured\n .then(() => {\n try {\n const r = origStart.apply(auth, args);\n if (r && typeof r.then === \"function\") {\n r.then(resolve).catch(reject);\n } else {\n resolve(r);\n }\n } catch (err) {\n reject(err);\n }\n })\n .catch(() => {\n try {\n const r = origStart.apply(auth, args);\n if (r && typeof r.then === \"function\") {\n r.then(resolve).catch(reject);\n } else {\n resolve(r);\n }\n } catch (err) {\n reject(err);\n }\n });\n });\n }\n\n return origStart.apply(auth, args);\n };\n }\n } catch (e) {\n /* ignore */\n }\n\n // When auth is configured, call an explicit retry method on any\n // sign-in/up elements that implement it. Prefer an explicit retry\n // API so elements can be idempotent and avoid duplicate flows.\n try {\n whenConfigured.then(() => {\n setTimeout(() => {\n try {\n document\n .querySelectorAll(\"pont-signin, pont-signup\")\n .forEach((el) => {\n try {\n if ((el as any).__pontInitRetried) return;\n (el as any).__pontInitRetried = true;\n // Prefer an explicit retry API implemented by the element\n // (e.g., `__pontRetryInit`) to avoid re-running the\n // entire `connectedCallback` which may cause duplicates.\n const retry = (el as any).__pontRetryInit;\n if (typeof retry === \"function\") {\n try {\n retry.call(el);\n } catch (e) {\n console.error(e);\n }\n return;\n }\n\n // Fallback: only call connectedCallback if the element\n // provides an explicit flag saying it previously failed\n // due to missing Auth (set by our connectedCallback wrapper\n // when we detect that specific error).\n if ((el as any).__pontFailedForConfig) {\n try {\n (el as any).connectedCallback?.();\n } catch (e) {\n console.error(e);\n }\n }\n } catch (_) {\n // ignore per-element errors\n }\n });\n } catch (_) {\n /* ignore */\n }\n }, 0);\n });\n } catch (e) {\n /* ignore */\n }\n\n return proxy;\n }\n\n // Replace module exports so consumers that import `Auth` directly\n // get the safe proxy as well. Also ensure `useAuthProvider()` returns\n // the proxy.\n const realAuth = module.useAuthProvider?.();\n const safeAuth = createSafeAuth(realAuth);\n\n try {\n (module as any).Auth = safeAuth;\n (module as any).useAuthProvider = () => safeAuth;\n } catch (e) {\n /* ignore */\n }\n\n window.__pontCoreSdk = {\n ...module,\n Auth: safeAuth,\n };\n\n coreSdk = window.__pontCoreSdk;\n\n // Set only once the SDK is actually on the window, so a copy of this\n // package that sees the flag can trust what it reads next to it.\n window.__pontLoaded = true;\n window.__pontLoading = undefined;\n\n // Patch known elements that may start flows on connect so they wait\n // for Auth to be configured instead of throwing. This avoids noisy\n // runtime errors like \"Auth.configure() must be called\".\n try {\n const patchElement = (tagName: string) => {\n const ctor = customElements.get(tagName);\n if (!ctor) return;\n const proto = ctor.prototype as any;\n if (proto.__pontConfiguredPatched) return;\n proto.__pontConfiguredPatched = true;\n\n const orig = proto.connectedCallback;\n if (typeof orig !== \"function\") return;\n\n proto.connectedCallback = function (...args: any[]) {\n const auth = window.__pontCoreSdk?.Auth as any;\n const whenConfigured = auth?.__whenConfigured as\n | Promise<void>\n | undefined;\n const configured = !!auth?.__configured;\n\n if (whenConfigured && !configured) {\n // delay initial connect work until Auth is configured\n whenConfigured\n .then(() => {\n try {\n orig.apply(this, args);\n } catch (e) {\n console.error(e);\n }\n })\n .catch(() => {\n try {\n orig.apply(this, args);\n } catch (e) {\n console.error(e);\n }\n });\n return;\n }\n\n try {\n orig.apply(this, args);\n } catch (e: any) {\n // If it still throws with the configure error, retry after configured\n if (\n e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"Auth.configure() must be called\") &&\n whenConfigured\n ) {\n whenConfigured.then(() => {\n try {\n orig.apply(this, args);\n } catch (err) {\n console.error(err);\n }\n });\n return;\n }\n throw e;\n }\n };\n };\n\n // Elements known to start auth flows on connect\n [\"pont-signin\", \"pont-signup\"].forEach(patchElement);\n } catch (e) {\n /* ignore patch errors */\n }\n\n console.log(\n `PontKit Web Components loaded (${resolvedVersion}) from:`,\n cdn,\n );\n\n return coreSdk;\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","import { loadWebComponents } from \"./load-web-components\";\n\nlet coreSdkLoadPromise: Promise<void> | null = null;\n\n/**\n * Ensures the core SDK is loaded and the global functions are available.\n * Returns a promise that resolves when the SDK is ready.\n */\nexport async function ensureCoreSdkLoaded(): Promise<void> {\n // Nothing to ensure without a browser, and the check below would throw before\n // reaching loadWebComponents' own guard.\n if (typeof window === \"undefined\") {\n return;\n }\n\n // If the functions already exist, we're done.\n if (window.__pontCoreSdk?.openAccountSettingsModal) {\n return;\n }\n\n // Otherwise, start loading the SDK if not already loading.\n if (!coreSdkLoadPromise) {\n coreSdkLoadPromise = loadWebComponents()\n .then(() => {\n // The first SDK script attaches the functions synchronously when it executes.\n if (!window.__pontCoreSdk?.openAccountSettingsModal) {\n console.warn(\n \"[pontive-react] Core sdk loaded but modal functions are missing.\",\n );\n }\n })\n .catch((err) => {\n console.error(\"[pontive-react] Failed to load core SDK:\", err);\n throw err;\n });\n }\n\n await coreSdkLoadPromise;\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","coreSdk","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","createSafeAuth","auth","queue","configured","resolveWhenConfigured","whenConfigured","res","proxy","target","prop","receiver","args","p","a","r","val","e","origConfigure","origStart","el","retry","module","realAuth","safeAuth","patchElement","tagName","ctor","proto","orig","coreSdkLoadPromise","ensureCoreSdkLoaded"],"mappings":"AAcO,MAAMA,IAAgC,2BCgBhCC,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,aAAaP;AAEvC,aAAWY,KAAOH,GAAM;AACtB,UAAMI,IAAS,MAAMC,EAAQN,GAAWI,GAAKD,CAAS;AACtD,QAAIE,EAAQ,QAAOA;AAAA,EACrB;AAEA,SAAO;AACT;AAEA,SAASH,IAAmC;AAC1C,SAAI,OAAO,SAAW,OAAe,OAAO,OAAO,0BAA2B,WACrE,CAAC,OAAO,sBAAsB,IAGhCX;AACT;AAEA,eAAee,EACbN,GACAI,GACAD,GAC+B;AAC/B,QAAMI,IAAa,OAAO,mBAAoB,aAAa,IAAI,oBAAoB,MAC7EC,IAAQD,IAAa,WAAW,MAAMA,EAAW,MAAA,GAASJ,CAAS,IAAI;AAE7E,MAAI;AACF,UAAMM,IAAW,MAAMT,EAAUI,G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AAA,EACR,CAAC,IAGL,MAAM2C;AACR;"}
@@ -0,0 +1 @@
1
+ export declare function loadWebComponents(): Promise<any>;
@@ -0,0 +1,38 @@
1
+ /** The shape of GET /auth/v1/runtime-config. */
2
+ export interface RuntimeConfig {
3
+ core_elements_version: string;
4
+ catalog_revision?: number;
5
+ source?: string;
6
+ assets?: {
7
+ js: string;
8
+ css: string;
9
+ };
10
+ /**
11
+ * Subresource-integrity hashes ("sha384-…") of the release's module and
12
+ * stylesheet, recorded by the platform when the release was gated. When
13
+ * present the loader passes them to the browser, which refuses bytes that
14
+ * differ — from the platform origin or from any public CDN alike.
15
+ */
16
+ integrity?: {
17
+ js: string;
18
+ css: string;
19
+ };
20
+ }
21
+ export declare const RUNTIME_CONFIG_PATHS: readonly ["/__auth/auth/v1/runtime-config", "/auth/v1/runtime-config"];
22
+ /** How long to wait for the platform before loading the stamped release. */
23
+ export declare const RUNTIME_CONFIG_TIMEOUT_MS = 1500;
24
+ export interface FetchRuntimeConfigOptions {
25
+ fetchImpl?: typeof fetch;
26
+ urls?: readonly string[];
27
+ timeoutMs?: number;
28
+ }
29
+ /** Whether `value` names one release rather than a range or garbage. */
30
+ export declare function isExactVersion(value: unknown): value is string;
31
+ /** Whether `value` is a well-formed SRI value the browser will accept. */
32
+ export declare function isSriHash(value: unknown): value is string;
33
+ /**
34
+ * Reads the platform's runtime config, or null when no candidate URL answers
35
+ * with one that can be trusted. Never throws: the caller's fallback is the
36
+ * stamped release, and a reachability problem should not become a page error.
37
+ */
38
+ export declare function fetchRuntimeConfig(options?: FetchRuntimeConfigOptions): Promise<RuntimeConfig | null>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Ensures the core SDK is loaded and the global functions are available.
3
+ * Returns a promise that resolves when the SDK is ready.
4
+ */
5
+ export declare function ensureCoreSdkLoaded(): Promise<void>;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@pontive/pontkit-loader",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "description": "Loads @pontive/pontkit-core from the CDN at the release the platform decides.",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "sideEffects": false,
21
+ "scripts": {
22
+ "build": "vite build",
23
+ "test": "vitest run",
24
+ "typecheck": "tsc --noEmit"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "devDependencies": {
30
+ "@pontive/pontkit-core": "1.1.1"
31
+ }
32
+ }