@palbase/web 4.0.0 → 4.0.1

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 @@
1
+ {"version":3,"sources":["../src/messaging/wasm/asset.ts"],"sourcesContent":["import encodedWasm from './pkg/palbe_mls_bg.wasm';\n\n// Built as a private package-import target. Keeping the bytes in their own\n// lazily imported JavaScript module lets browser bundlers carry/split the MLS\n// engine without a public-path convention, while Node ESM and CJS resolve the\n// exact same package-owned bytes.\nexport default encodedWasm;\n"],"mappings":";;;;;;AAMA,IAAO,gBAAQ;","names":[]}
@@ -1,9 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
1
  // src/api-key.ts
8
2
  var API_KEY_RE = /^pb_([a-z0-9]+)_[cs][A-Za-z0-9]{20}$/;
9
3
  var PUBLISHABLE_API_KEY_RE = /^pb_([a-z0-9]+)_c[A-Za-z0-9]{20}$/;
@@ -17,8 +11,7 @@ function environmentRefFromPublishableApiKey(apiKey) {
17
11
  }
18
12
 
19
13
  export {
20
- __export,
21
14
  environmentRefFromApiKey,
22
15
  environmentRefFromPublishableApiKey
23
16
  };
24
- //# sourceMappingURL=chunk-S7NAY3MW.js.map
17
+ //# sourceMappingURL=chunk-NXEPAEF5.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api-key.ts"],"sourcesContent":["/**\n * `pb_<environmentRef>_<scope><random>` → environmentRef ('' if malformed).\n * Utility for callers that only have a raw key. App-bound runtime storage and\n * palbe/next cookie naming use the explicit `PalbeConfig.environmentRef` emitted\n * by `palbe-gen`.\n *\n * The key is shape-validated (prefix `pb`, non-empty environmentRef, and a\n * `<scope><20-base62-random>` secret segment where scope ∈ {c,s}) before a ref\n * is returned. A structurally-invalid key returns '' so session storage stays\n * UNSCOPED rather than getting bound to a partially-parsed ref — a loose parse\n * (e.g. `pb_victim_cXX`) must not scope persisted sessions to `victim` and\n * hydrate a session belonging to a different, real key. The backend remains the\n * authority that rejects a bad key on the first request; this keeps the client's\n * local session-storage scoping honest. (Audit finding apikey-ref-mismatch.)\n */\nconst API_KEY_RE = /^pb_([a-z0-9]+)_[cs][A-Za-z0-9]{20}$/;\nconst PUBLISHABLE_API_KEY_RE = /^pb_([a-z0-9]+)_c[A-Za-z0-9]{20}$/;\n\nexport function environmentRefFromApiKey(apiKey: string): string {\n const m = API_KEY_RE.exec(apiKey);\n return m ? (m[1] ?? '') : '';\n}\n\n/** Internal app-runtime parser: browser config accepts publishable keys only. */\nexport function environmentRefFromPublishableApiKey(apiKey: string): string {\n const match = PUBLISHABLE_API_KEY_RE.exec(apiKey);\n return match ? (match[1] ?? '') : '';\n}\n"],"mappings":";;;;;;;AAeA,IAAM,aAAa;AACnB,IAAM,yBAAyB;AAExB,SAAS,yBAAyB,QAAwB;AAC/D,QAAM,IAAI,WAAW,KAAK,MAAM;AAChC,SAAO,IAAK,EAAE,CAAC,KAAK,KAAM;AAC5B;AAGO,SAAS,oCAAoC,QAAwB;AAC1E,QAAM,QAAQ,uBAAuB,KAAK,MAAM;AAChD,SAAO,QAAS,MAAM,CAAC,KAAK,KAAM;AACpC;","names":[]}
1
+ {"version":3,"sources":["../src/api-key.ts"],"sourcesContent":["/**\n * `pb_<environmentRef>_<scope><random>` → environmentRef ('' if malformed).\n * Utility for callers that only have a raw key. App-bound runtime storage and\n * palbe/next cookie naming use the explicit `PalbeConfig.environmentRef` emitted\n * by `palbe-gen`.\n *\n * The key is shape-validated (prefix `pb`, non-empty environmentRef, and a\n * `<scope><20-base62-random>` secret segment where scope ∈ {c,s}) before a ref\n * is returned. A structurally-invalid key returns '' so session storage stays\n * UNSCOPED rather than getting bound to a partially-parsed ref — a loose parse\n * (e.g. `pb_victim_cXX`) must not scope persisted sessions to `victim` and\n * hydrate a session belonging to a different, real key. The backend remains the\n * authority that rejects a bad key on the first request; this keeps the client's\n * local session-storage scoping honest. (Audit finding apikey-ref-mismatch.)\n */\nconst API_KEY_RE = /^pb_([a-z0-9]+)_[cs][A-Za-z0-9]{20}$/;\nconst PUBLISHABLE_API_KEY_RE = /^pb_([a-z0-9]+)_c[A-Za-z0-9]{20}$/;\n\nexport function environmentRefFromApiKey(apiKey: string): string {\n const m = API_KEY_RE.exec(apiKey);\n return m ? (m[1] ?? '') : '';\n}\n\n/** Internal app-runtime parser: browser config accepts publishable keys only. */\nexport function environmentRefFromPublishableApiKey(apiKey: string): string {\n const match = PUBLISHABLE_API_KEY_RE.exec(apiKey);\n return match ? (match[1] ?? '') : '';\n}\n"],"mappings":";AAeA,IAAM,aAAa;AACnB,IAAM,yBAAyB;AAExB,SAAS,yBAAyB,QAAwB;AAC/D,QAAM,IAAI,WAAW,KAAK,MAAM;AAChC,SAAO,IAAK,EAAE,CAAC,KAAK,KAAM;AAC5B;AAGO,SAAS,oCAAoC,QAAwB;AAC1E,QAAM,QAAQ,uBAAuB,KAAK,MAAM;AAChD,SAAO,QAAS,MAAM,CAAC,KAAK,KAAM;AACpC;","names":[]}
@@ -0,0 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export {
8
+ __export
9
+ };
10
+ //# sourceMappingURL=chunk-PZ5AY32C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +1,9 @@
1
1
  import {
2
- __export,
3
2
  environmentRefFromPublishableApiKey
4
- } from "./chunk-S7NAY3MW.js";
3
+ } from "./chunk-NXEPAEF5.js";
4
+ import {
5
+ __export
6
+ } from "./chunk-PZ5AY32C.js";
5
7
 
6
8
  // ../core/dist/index.js
7
9
  var CACHE_TTL_MS = 5 * 60 * 1e3;
@@ -6432,26 +6434,25 @@ var GLUE_MODULE = "./palbe_mls_bg.js";
6432
6434
  var SNIPPET_MODULE = "./snippets/mls-rs-core-f99cdecbb456b09c/inline0.js";
6433
6435
  var inflight = null;
6434
6436
  var ready = null;
6435
- async function loadWasmModule() {
6436
- const wasmUrl = new URL("./pkg/palbe_mls_bg.wasm", import.meta.url);
6437
- if (wasmUrl.protocol === "file:") {
6438
- const fsSpecifier = ["node", "fs/promises"].join(":");
6439
- const { readFile } = await import(
6440
- /* webpackIgnore: true */
6441
- fsSpecifier
6442
- );
6443
- const bytes = await readFile(wasmUrl);
6444
- return WebAssembly.compile(bytes);
6437
+ function decodeBase64(encoded) {
6438
+ if (typeof encoded !== "string" || encoded.length === 0 || typeof globalThis.atob !== "function") {
6439
+ throw new Error("palbe-mls WASM asset is invalid");
6445
6440
  }
6446
- const response = await fetch(wasmUrl);
6447
- if (typeof WebAssembly.compileStreaming === "function") {
6448
- try {
6449
- return await WebAssembly.compileStreaming(Promise.resolve(response));
6450
- } catch {
6451
- }
6441
+ let binary;
6442
+ try {
6443
+ binary = globalThis.atob(encoded);
6444
+ } catch {
6445
+ throw new Error("palbe-mls WASM asset is invalid");
6446
+ }
6447
+ const bytes = new Uint8Array(binary.length);
6448
+ for (let index = 0; index < binary.length; index += 1) {
6449
+ bytes[index] = binary.charCodeAt(index);
6452
6450
  }
6453
- const buffer = await response.arrayBuffer();
6454
- return WebAssembly.compile(buffer);
6451
+ return bytes.buffer;
6452
+ }
6453
+ async function loadWasmModule() {
6454
+ const asset = await import("#palbase-mls-wasm");
6455
+ return WebAssembly.compile(decodeBase64(asset.default));
6455
6456
  }
6456
6457
  function buildImports() {
6457
6458
  return {
@@ -6462,7 +6463,7 @@ function buildImports() {
6462
6463
  function initMls() {
6463
6464
  if (ready) return Promise.resolve(ready);
6464
6465
  if (inflight) return inflight;
6465
- inflight = (async () => {
6466
+ const attempt = (async () => {
6466
6467
  const module2 = await loadWasmModule();
6467
6468
  const instance = await WebAssembly.instantiate(module2, buildImports());
6468
6469
  const setWasm = __wbg_set_wasm;
@@ -6481,7 +6482,11 @@ function initMls() {
6481
6482
  ready = g;
6482
6483
  return g;
6483
6484
  })();
6484
- return inflight;
6485
+ inflight = attempt;
6486
+ void attempt.catch(() => {
6487
+ if (inflight === attempt) inflight = null;
6488
+ });
6489
+ return attempt;
6485
6490
  }
6486
6491
  function requireMls() {
6487
6492
  if (!ready) {
@@ -8934,7 +8939,7 @@ function defaultSessionStorage(key) {
8934
8939
  }
8935
8940
 
8936
8941
  // src/version.ts
8937
- var VERSION = "4.0.0";
8942
+ var VERSION = "4.0.1";
8938
8943
 
8939
8944
  // src/runtime.ts
8940
8945
  function buildRuntime(config) {
@@ -9361,4 +9366,4 @@ export {
9361
9366
  pb,
9362
9367
  createBoundClient
9363
9368
  };
9364
- //# sourceMappingURL=chunk-NP4NIY7A.js.map
9369
+ //# sourceMappingURL=chunk-TGDS6VMT.js.map