mcard-js 2.1.47 → 2.1.49

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.
Files changed (52) hide show
  1. package/dist/AbstractSqlEngine-DKka6XjT.d.cts +451 -0
  2. package/dist/AbstractSqlEngine-DKka6XjT.d.ts +451 -0
  3. package/dist/CardCollection-TYC67XOH.js +10 -0
  4. package/dist/CardCollection-ZQ3G3Q3A.js +10 -0
  5. package/dist/EventProducer-VFDOM5W2.js +47 -0
  6. package/dist/IndexedDBEngine-5CEFZDOG.js +12 -0
  7. package/dist/IndexedDBEngine-BWXAB46W.js +12 -0
  8. package/dist/LLMRuntime-PH3MOQ2Y.js +17 -0
  9. package/dist/LambdaRuntime-DMEBYJIN.js +19 -0
  10. package/dist/LambdaRuntime-YH74FHIW.js +19 -0
  11. package/dist/Loader-OBPDJNFH.js +12 -0
  12. package/dist/Loader-WZXYG4GE.js +12 -0
  13. package/dist/MCard-RHTWJPHJ.js +8 -0
  14. package/dist/NetworkRuntime-KBQURQ6A.js +1598 -0
  15. package/dist/NetworkRuntime-S4DZCGVN.js +1598 -0
  16. package/dist/OllamaProvider-SPGO5Z5E.js +9 -0
  17. package/dist/chunk-3FFEA2XK.js +149 -0
  18. package/dist/chunk-7AXRV7NS.js +112 -0
  19. package/dist/chunk-AAO4GDBI.js +2360 -0
  20. package/dist/chunk-ASW6AOA7.js +140 -0
  21. package/dist/chunk-BJJZWPIF.js +112 -0
  22. package/dist/chunk-GGQCF7ZK.js +170 -0
  23. package/dist/chunk-HIVVDGE5.js +497 -0
  24. package/dist/chunk-HWBEGVEN.js +364 -0
  25. package/dist/chunk-ISY5LYLF.js +217 -0
  26. package/dist/chunk-KVZYFZJ5.js +427 -0
  27. package/dist/chunk-NGTY4P6A.js +275 -0
  28. package/dist/chunk-OAHWTOEB.js +275 -0
  29. package/dist/chunk-OUW2SUGM.js +368 -0
  30. package/dist/chunk-QKH3N62B.js +2360 -0
  31. package/dist/chunk-QPVEUPMU.js +299 -0
  32. package/dist/chunk-RZENJZGX.js +299 -0
  33. package/dist/chunk-VYDZR4ZD.js +364 -0
  34. package/dist/chunk-XJZOEM5F.js +903 -0
  35. package/dist/chunk-Z7EFXSTO.js +217 -0
  36. package/dist/index.browser.cjs +58 -20
  37. package/dist/index.browser.d.cts +34 -17
  38. package/dist/index.browser.d.ts +34 -17
  39. package/dist/index.browser.js +12 -8
  40. package/dist/index.cjs +644 -167
  41. package/dist/index.d.cts +725 -5
  42. package/dist/index.d.ts +725 -5
  43. package/dist/index.js +536 -95
  44. package/dist/storage/SqliteNodeEngine.cjs +28 -20
  45. package/dist/storage/SqliteNodeEngine.d.cts +1 -1
  46. package/dist/storage/SqliteNodeEngine.d.ts +1 -1
  47. package/dist/storage/SqliteNodeEngine.js +5 -5
  48. package/dist/storage/SqliteWasmEngine.cjs +28 -20
  49. package/dist/storage/SqliteWasmEngine.d.cts +1 -1
  50. package/dist/storage/SqliteWasmEngine.d.ts +1 -1
  51. package/dist/storage/SqliteWasmEngine.js +5 -5
  52. package/package.json +3 -1
@@ -0,0 +1,217 @@
1
+ import {
2
+ AbstractSqlEngine,
3
+ initCoreSchemas
4
+ } from "./chunk-HIVVDGE5.js";
5
+ import {
6
+ createPage
7
+ } from "./chunk-3EIBJPNF.js";
8
+ import {
9
+ Handle_exports,
10
+ init_Handle
11
+ } from "./chunk-ADV52544.js";
12
+ import {
13
+ DEFAULT_PAGE_SIZE,
14
+ SQLITE_BUSY_TIMEOUT_MS
15
+ } from "./chunk-3FFEA2XK.js";
16
+ import {
17
+ MCard
18
+ } from "./chunk-GGQCF7ZK.js";
19
+ import {
20
+ __toCommonJS
21
+ } from "./chunk-PNKVD2UK.js";
22
+
23
+ // src/storage/engines/SqliteNodeEngine.ts
24
+ var SqliteNodeEngine = class _SqliteNodeEngine extends AbstractSqlEngine {
25
+ db;
26
+ dbPath;
27
+ /**
28
+ * Convert a database row into an MCard instance.
29
+ */
30
+ rowToCard(row) {
31
+ const rawContent = row.content;
32
+ const content = rawContent instanceof Buffer ? new Uint8Array(rawContent) : new Uint8Array(rawContent);
33
+ return MCard.fromData(content, String(row.hash), String(row.g_time));
34
+ }
35
+ /**
36
+ * Create a new SqliteNodeEngine via async factory.
37
+ * @param dbPath Path to database file, or ':memory:' for in-memory database
38
+ */
39
+ static async create(dbPath = ":memory:") {
40
+ const engine = new _SqliteNodeEngine(dbPath);
41
+ await engine.init();
42
+ return engine;
43
+ }
44
+ constructor(dbPath) {
45
+ super();
46
+ this.dbPath = dbPath;
47
+ }
48
+ async init() {
49
+ try {
50
+ const mod = await import("better-sqlite3");
51
+ const Database = mod.default || mod;
52
+ this.db = new Database(this.dbPath);
53
+ this.setupDatabase();
54
+ } catch (e) {
55
+ console.error(`SqliteNodeEngine: Failed to load better-sqlite3: ${e.message}`);
56
+ throw e;
57
+ }
58
+ }
59
+ /**
60
+ * Initialize database schema
61
+ */
62
+ setupDatabase() {
63
+ this.db.pragma("journal_mode = WAL");
64
+ this.db.pragma(`busy_timeout = ${SQLITE_BUSY_TIMEOUT_MS}`);
65
+ this.db.pragma("synchronous = NORMAL");
66
+ initCoreSchemas(this.db);
67
+ }
68
+ // ======================================================================
69
+ // AbstractSqlEngine primitives
70
+ // ======================================================================
71
+ async queryRows(sql, ...params) {
72
+ const stmt = this.db.prepare(sql);
73
+ return stmt.all(...params);
74
+ }
75
+ async execSql(sql, ...params) {
76
+ if (params.length === 0) {
77
+ this.db.exec(sql);
78
+ return 0;
79
+ }
80
+ const stmt = this.db.prepare(sql);
81
+ const result = stmt.run(...params);
82
+ return result.changes;
83
+ }
84
+ /**
85
+ * Close the database connection
86
+ */
87
+ close() {
88
+ this.db.close();
89
+ }
90
+ /**
91
+ * Get the database path
92
+ */
93
+ getDbPath() {
94
+ return this.dbPath;
95
+ }
96
+ // =========== Card Operations (overrides to use Buffer.from for better-sqlite3) ===========
97
+ async add(card) {
98
+ const stmt = this.db.prepare(
99
+ "INSERT OR REPLACE INTO card (hash, content, g_time) VALUES (?, ?, ?)"
100
+ );
101
+ stmt.run(card.hash, Buffer.from(card.content), card.g_time);
102
+ return card.hash;
103
+ }
104
+ // =========== Sync card operations (for performance-critical callers) ===========
105
+ addSync(card) {
106
+ const stmt = this.db.prepare(
107
+ "INSERT OR REPLACE INTO card (hash, content, g_time) VALUES (?, ?, ?)"
108
+ );
109
+ stmt.run(card.hash, Buffer.from(card.content), card.g_time);
110
+ return card.hash;
111
+ }
112
+ getSync(hash) {
113
+ const stmt = this.db.prepare("SELECT hash, content, g_time FROM card WHERE hash = ?");
114
+ const row = stmt.get(hash);
115
+ if (!row) return null;
116
+ return this.rowToCard(row);
117
+ }
118
+ deleteSync(hash) {
119
+ const stmt = this.db.prepare("DELETE FROM card WHERE hash = ?");
120
+ const result = stmt.run(hash);
121
+ return result.changes > 0;
122
+ }
123
+ getPageSync(pageNumber = 1, pageSize = DEFAULT_PAGE_SIZE) {
124
+ if (pageNumber < 1) throw new Error("Page number must be >= 1");
125
+ if (pageSize < 1) throw new Error("Page size must be >= 1");
126
+ const totalItems = this.countSync();
127
+ const offset = (pageNumber - 1) * pageSize;
128
+ const stmt = this.db.prepare(
129
+ "SELECT hash, content, g_time FROM card ORDER BY g_time DESC LIMIT ? OFFSET ?"
130
+ );
131
+ const rows = stmt.all(pageSize, offset);
132
+ const items = rows.map((row) => this.rowToCard(row));
133
+ return createPage(items, totalItems, pageNumber, pageSize);
134
+ }
135
+ countSync() {
136
+ const stmt = this.db.prepare("SELECT COUNT(*) as cnt FROM card");
137
+ const row = stmt.get();
138
+ return row.cnt;
139
+ }
140
+ clearSync() {
141
+ this.db.exec("DELETE FROM handle_history");
142
+ this.db.exec("DELETE FROM handle_registry");
143
+ this.db.exec("DELETE FROM card");
144
+ }
145
+ // =========== Additional sync search operations ===========
146
+ searchByString(searchString, pageNumber = 1, pageSize = DEFAULT_PAGE_SIZE) {
147
+ if (pageNumber < 1) throw new Error("Page number must be >= 1");
148
+ if (pageSize < 1) throw new Error("Page size must be >= 1");
149
+ const pattern = `%${searchString}%`;
150
+ const offset = (pageNumber - 1) * pageSize;
151
+ const countStmt = this.db.prepare(`
152
+ SELECT COUNT(*) as cnt FROM card
153
+ WHERE hash LIKE ? OR g_time LIKE ? OR CAST(content AS TEXT) LIKE ?
154
+ `);
155
+ const countRow = countStmt.get(pattern, pattern, pattern);
156
+ const totalItems = countRow.cnt;
157
+ const stmt = this.db.prepare(`
158
+ SELECT hash, content, g_time FROM card
159
+ WHERE hash LIKE ? OR g_time LIKE ? OR CAST(content AS TEXT) LIKE ?
160
+ ORDER BY g_time DESC LIMIT ? OFFSET ?
161
+ `);
162
+ const rows = stmt.all(pattern, pattern, pattern, pageSize, offset);
163
+ const items = rows.map((row) => this.rowToCard(row));
164
+ return createPage(items, totalItems, pageNumber, pageSize);
165
+ }
166
+ searchByContent(searchPattern, pageNumber = 1, pageSize = DEFAULT_PAGE_SIZE) {
167
+ if (pageNumber < 1) throw new Error("Page number must be >= 1");
168
+ if (pageSize < 1) throw new Error("Page size must be >= 1");
169
+ if (!searchPattern || typeof searchPattern === "string" && searchPattern.length === 0) {
170
+ throw new Error("Search pattern cannot be empty");
171
+ }
172
+ const searchBytes = typeof searchPattern === "string" ? Buffer.from(searchPattern, "utf-8") : Buffer.from(searchPattern);
173
+ const offset = (pageNumber - 1) * pageSize;
174
+ const countStmt = this.db.prepare("SELECT COUNT(*) as cnt FROM card WHERE INSTR(content, ?) > 0");
175
+ const countRow = countStmt.get(searchBytes);
176
+ const totalItems = countRow.cnt;
177
+ const stmt = this.db.prepare(`
178
+ SELECT hash, content, g_time FROM card
179
+ WHERE INSTR(content, ?) > 0
180
+ ORDER BY g_time DESC LIMIT ? OFFSET ?
181
+ `);
182
+ const rows = stmt.all(searchBytes, pageSize, offset);
183
+ const items = rows.map((row) => this.rowToCard(row));
184
+ return createPage(items, totalItems, pageNumber, pageSize);
185
+ }
186
+ getAllCards() {
187
+ const stmt = this.db.prepare("SELECT hash, content, g_time FROM card ORDER BY g_time DESC");
188
+ const rows = stmt.all();
189
+ const items = rows.map((row) => this.rowToCard(row));
190
+ return createPage(items, items.length, 1, items.length || 1);
191
+ }
192
+ // =========== Unique sync method (not in AbstractSqlEngine) ===========
193
+ deleteHistoryEntrySync(handle, previousHash) {
194
+ const { validateHandle } = (init_Handle(), __toCommonJS(Handle_exports));
195
+ const normalized = validateHandle(handle);
196
+ const performStitch = this.db.transaction(() => {
197
+ const rOut = this.db.prepare(
198
+ "SELECT id, previous_hash FROM handle_history WHERE handle = ? AND previous_hash = ? ORDER BY id DESC LIMIT 1"
199
+ ).get(normalized, previousHash);
200
+ if (!rOut) return;
201
+ const rIn = this.db.prepare(
202
+ "SELECT id, previous_hash FROM handle_history WHERE handle = ? AND id < ? ORDER BY id DESC LIMIT 1"
203
+ ).get(normalized, rOut.id);
204
+ if (rIn) {
205
+ this.db.prepare("UPDATE handle_history SET previous_hash = ? WHERE id = ?").run(rIn.previous_hash, rOut.id);
206
+ this.db.prepare("DELETE FROM handle_history WHERE id = ?").run(rIn.id);
207
+ } else {
208
+ this.db.prepare("DELETE FROM handle_history WHERE id = ?").run(rOut.id);
209
+ }
210
+ });
211
+ performStitch();
212
+ }
213
+ };
214
+
215
+ export {
216
+ SqliteNodeEngine
217
+ };
@@ -96,13 +96,13 @@ var init_GTime = __esm({
96
96
  static DEFAULT_ALGORITHM = "sha256";
97
97
  /**
98
98
  * Generate a GTime stamp for the current moment
99
- * Format: HASH_ALGO|TIMESTAMP|REGION_CODE
99
+ * Format: ALGORITHM|TIMESTAMP|LOCALE_OR_DID
100
+ * Representing the mathematical coordinate (a,b,c) for an event signature.
100
101
  */
101
- static stampNow(hashAlgorithm = this.DEFAULT_ALGORITHM) {
102
+ static stampNow(hashAlgorithm = this.DEFAULT_ALGORITHM, localeOrDID = "UTC") {
102
103
  const algo = hashAlgorithm.toLowerCase();
103
104
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
104
- const region = "UTC";
105
- return `${algo}|${timestamp}|${region}`;
105
+ return `${algo}|${timestamp}|${localeOrDID}`;
106
106
  }
107
107
  /**
108
108
  * Parse a GTime string
@@ -115,26 +115,28 @@ var init_GTime = __esm({
115
115
  return {
116
116
  algorithm: parts[0],
117
117
  timestamp: new Date(parts[1]),
118
- region: parts[2]
118
+ localeOrDID: parts[2]
119
119
  };
120
120
  }
121
- /**
122
- * Get the hash algorithm from a GTime string
123
- */
124
- static getHashAlgorithm(gtime) {
121
+ /** Extract coordinate a: Algorithm */
122
+ static getAlgorithm(gtime) {
125
123
  return this.parse(gtime).algorithm;
126
124
  }
127
- /**
128
- * Get the timestamp from a GTime string
129
- */
125
+ /** Alias for backward compatibility */
126
+ static getHashAlgorithm(gtime) {
127
+ return this.getAlgorithm(gtime);
128
+ }
129
+ /** Extract coordinate b: Timestamp */
130
130
  static getTimestamp(gtime) {
131
131
  return this.parse(gtime).timestamp;
132
132
  }
133
- /**
134
- * Get the region code from a GTime string
135
- */
133
+ /** Extract coordinate c: Locale or DID */
134
+ static getLocaleOrDID(gtime) {
135
+ return this.parse(gtime).localeOrDID;
136
+ }
137
+ /** Alias for backward compatibility */
136
138
  static getRegionCode(gtime) {
137
- return this.parse(gtime).region;
139
+ return this.getLocaleOrDID(gtime);
138
140
  }
139
141
  /**
140
142
  * Check if the provided hash function is valid.
@@ -147,11 +149,11 @@ var init_GTime = __esm({
147
149
  return VALID_HASH_ALGORITHMS.includes(hashFunction.toLowerCase());
148
150
  }
149
151
  /**
150
- * Check if the provided region code is valid.
151
- * Matches Python's GTime.is_valid_region_code()
152
+ * Check if the provided locale/region code is valid.
153
+ * Maintains backward compatibility by checking for strings.
152
154
  */
153
155
  static isValidRegionCode(regionCode) {
154
- return Boolean(regionCode && regionCode === regionCode.toUpperCase());
156
+ return Boolean(regionCode && typeof regionCode === "string");
155
157
  }
156
158
  /**
157
159
  * Check if the provided timestamp is in ISO format.
@@ -355,6 +357,8 @@ __export(index_browser_exports, {
355
357
  MCard: () => MCard,
356
358
  MCardStore: () => MCardStore,
357
359
  Maybe: () => Maybe,
360
+ PostconditionViolation: () => PostconditionViolation,
361
+ PreconditionViolation: () => PreconditionViolation,
358
362
  Reader: () => Reader,
359
363
  ServiceWorkerPTR: () => ServiceWorkerPTR,
360
364
  SqliteWasmEngine: () => SqliteWasmEngine,
@@ -525,6 +529,8 @@ var app_config_default = {
525
529
  default_ws_host: "127.0.0.1",
526
530
  default_ws_port: 5321,
527
531
  default_api_port: 5320,
532
+ default_python_api_port: 28302,
533
+ default_js_api_port: 28303,
528
534
  default_server_host: "0.0.0.0",
529
535
  cors_origins: [
530
536
  "http://localhost:3000",
@@ -554,7 +560,8 @@ var app_config_default = {
554
560
  default_server_memory_db: "servermemory.db",
555
561
  default_mcard_db: "mcard.db",
556
562
  default_server_log_db: "server_log.db",
557
- default_push_subscriptions_file: "subscriptions.json"
563
+ default_push_subscriptions_file: "subscriptions.json",
564
+ default_vcard_db_path: "data/vcard.db"
558
565
  },
559
566
  services: {
560
567
  default_ollama_base_url: "http://localhost:11434",
@@ -607,6 +614,9 @@ var INDEXEDDB_DEFAULT_DB_VERSION = 1;
607
614
  var DEFAULT_IDENTITY_PROVIDER = String(identity.provider ?? "sqlite");
608
615
  var DEFAULT_IDENTITY_SPACE_PATH = String(identity.space_path ?? "./data/IDENTITY_SPACE.db");
609
616
  var DEFAULT_API_PORT = Number(network.default_api_port ?? 5320);
617
+ var DEFAULT_PYTHON_API_PORT = Number(network.default_python_api_port ?? 28302);
618
+ var DEFAULT_JS_API_PORT = Number(network.default_js_api_port ?? 28303);
619
+ var DEFAULT_VCARD_DB_PATH = String(app_config_default.storage?.default_vcard_db_path ?? "./data/vcard.db");
610
620
  var DEFAULT_WS_PORT = Number(network.default_ws_port ?? 5321);
611
621
  var DEFAULT_WS_HOST = String(network.default_ws_host ?? "127.0.0.1");
612
622
  var DEFAULT_SERVER_HOST = String(network.default_server_host ?? "0.0.0.0");
@@ -2154,6 +2164,32 @@ var VerificationStatus = /* @__PURE__ */ ((VerificationStatus2) => {
2154
2164
  VerificationStatus2["SKIPPED"] = "skipped";
2155
2165
  return VerificationStatus2;
2156
2166
  })(VerificationStatus || {});
2167
+ var PreconditionViolation = class extends Error {
2168
+ pcardHash;
2169
+ inputHash;
2170
+ detail;
2171
+ constructor(pcardHash, inputHash, detail = "") {
2172
+ const msg = `PreconditionViolation: PCard ${pcardHash.substring(0, 16)} rejected input ${inputHash.substring(0, 16)}${detail ? ` \u2014 ${detail}` : ""}`;
2173
+ super(msg);
2174
+ this.name = "PreconditionViolation";
2175
+ this.pcardHash = pcardHash;
2176
+ this.inputHash = inputHash;
2177
+ this.detail = detail;
2178
+ }
2179
+ };
2180
+ var PostconditionViolation = class extends Error {
2181
+ pcardHash;
2182
+ outputRepr;
2183
+ detail;
2184
+ constructor(pcardHash, outputRepr, detail = "") {
2185
+ const msg = `PostconditionViolation: PCard ${pcardHash.substring(0, 16)} postcondition failed for output ${outputRepr.substring(0, 64)}${detail ? ` \u2014 ${detail}` : ""}`;
2186
+ super(msg);
2187
+ this.name = "PostconditionViolation";
2188
+ this.pcardHash = pcardHash;
2189
+ this.outputRepr = outputRepr;
2190
+ this.detail = detail;
2191
+ }
2192
+ };
2157
2193
 
2158
2194
  // src/ptr/browser/storage/MCardStore.ts
2159
2195
  var import_idb2 = require("idb");
@@ -2788,6 +2824,8 @@ var validationRegistry = new ValidationRegistry();
2788
2824
  MCard,
2789
2825
  MCardStore,
2790
2826
  Maybe,
2827
+ PostconditionViolation,
2828
+ PreconditionViolation,
2791
2829
  Reader,
2792
2830
  ServiceWorkerPTR,
2793
2831
  SqliteWasmEngine,
@@ -1,4 +1,4 @@
1
- import { S as StorageEngine, M as MCard, P as Page } from './AbstractSqlEngine-BSfp8S_Y.cjs';
1
+ import { S as StorageEngine, M as MCard, P as Page } from './AbstractSqlEngine-DKka6XjT.cjs';
2
2
  export { SqliteWasmEngine } from './storage/SqliteWasmEngine.cjs';
3
3
  import { getWebInstrumentations, Faro } from '@grafana/faro-web-sdk';
4
4
 
@@ -6,28 +6,27 @@ declare class GTime {
6
6
  private static readonly DEFAULT_ALGORITHM;
7
7
  /**
8
8
  * Generate a GTime stamp for the current moment
9
- * Format: HASH_ALGO|TIMESTAMP|REGION_CODE
9
+ * Format: ALGORITHM|TIMESTAMP|LOCALE_OR_DID
10
+ * Representing the mathematical coordinate (a,b,c) for an event signature.
10
11
  */
11
- static stampNow(hashAlgorithm?: string): string;
12
+ static stampNow(hashAlgorithm?: string, localeOrDID?: string): string;
12
13
  /**
13
14
  * Parse a GTime string
14
15
  */
15
16
  static parse(gtime: string): {
16
- timestamp: Date;
17
17
  algorithm: string;
18
- region: string;
18
+ timestamp: Date;
19
+ localeOrDID: string;
19
20
  };
20
- /**
21
- * Get the hash algorithm from a GTime string
22
- */
21
+ /** Extract coordinate a: Algorithm */
22
+ static getAlgorithm(gtime: string): string;
23
+ /** Alias for backward compatibility */
23
24
  static getHashAlgorithm(gtime: string): string;
24
- /**
25
- * Get the timestamp from a GTime string
26
- */
25
+ /** Extract coordinate b: Timestamp */
27
26
  static getTimestamp(gtime: string): Date;
28
- /**
29
- * Get the region code from a GTime string
30
- */
27
+ /** Extract coordinate c: Locale or DID */
28
+ static getLocaleOrDID(gtime: string): string;
29
+ /** Alias for backward compatibility */
31
30
  static getRegionCode(gtime: string): string;
32
31
  /**
33
32
  * Check if the provided hash function is valid.
@@ -35,8 +34,8 @@ declare class GTime {
35
34
  */
36
35
  static isValidHashFunction(hashFunction: string): boolean;
37
36
  /**
38
- * Check if the provided region code is valid.
39
- * Matches Python's GTime.is_valid_region_code()
37
+ * Check if the provided locale/region code is valid.
38
+ * Maintains backward compatibility by checking for strings.
40
39
  */
41
40
  static isValidRegionCode(regionCode: string): boolean;
42
41
  /**
@@ -701,6 +700,24 @@ interface ExecutionResult {
701
700
  liveness_metrics: LivenessMetric[];
702
701
  error_message?: string;
703
702
  }
703
+ /**
704
+ * Raised when a PCard's precondition check fails during VCard Sandwich evaluation.
705
+ */
706
+ declare class PreconditionViolation extends Error {
707
+ readonly pcardHash: string;
708
+ readonly inputHash: string;
709
+ readonly detail: string;
710
+ constructor(pcardHash: string, inputHash: string, detail?: string);
711
+ }
712
+ /**
713
+ * Raised when a PCard's postcondition check fails during VCard Sandwich evaluation.
714
+ */
715
+ declare class PostconditionViolation extends Error {
716
+ readonly pcardHash: string;
717
+ readonly outputRepr: string;
718
+ readonly detail: string;
719
+ constructor(pcardHash: string, outputRepr: string, detail?: string);
720
+ }
704
721
 
705
722
  type StoredMCardContent = string | Uint8Array | Record<string, unknown>;
706
723
  type CardRecord = {
@@ -821,4 +838,4 @@ declare class ValidationRegistry {
821
838
  }
822
839
  declare const validationRegistry: ValidationRegistry;
823
840
 
824
- export { ALGORITHM_HIERARCHY, CardCollection, ContentHandle, ContentTypeInterpreter, EVENT_CONSTANTS, Either, ErrorCodes, type ExecutionResult, FaroSidecar, type FaroSidecarConfig, GTime, HandleValidationError, HashValidator, IO, IndexedDBEngine, type JsonRpcRequest, type JsonRpcResponse, LensProtocol, type LivenessMetric, MCard, MCardStore, Maybe, Page, type PolynomialTerm, type PrimeHash, Reader, type SafetyViolation, ServiceWorkerPTR, State, StorageEngine, ValidationRegistry, VerificationStatus, Writer, computeHash, validateHandle, validationRegistry };
841
+ export { ALGORITHM_HIERARCHY, CardCollection, ContentHandle, ContentTypeInterpreter, EVENT_CONSTANTS, Either, ErrorCodes, type ExecutionResult, FaroSidecar, type FaroSidecarConfig, GTime, HandleValidationError, HashValidator, IO, IndexedDBEngine, type JsonRpcRequest, type JsonRpcResponse, LensProtocol, type LivenessMetric, MCard, MCardStore, Maybe, Page, type PolynomialTerm, PostconditionViolation, PreconditionViolation, type PrimeHash, Reader, type SafetyViolation, ServiceWorkerPTR, State, StorageEngine, ValidationRegistry, VerificationStatus, Writer, computeHash, validateHandle, validationRegistry };
@@ -1,4 +1,4 @@
1
- import { S as StorageEngine, M as MCard, P as Page } from './AbstractSqlEngine-BSfp8S_Y.js';
1
+ import { S as StorageEngine, M as MCard, P as Page } from './AbstractSqlEngine-DKka6XjT.js';
2
2
  export { SqliteWasmEngine } from './storage/SqliteWasmEngine.js';
3
3
  import { getWebInstrumentations, Faro } from '@grafana/faro-web-sdk';
4
4
 
@@ -6,28 +6,27 @@ declare class GTime {
6
6
  private static readonly DEFAULT_ALGORITHM;
7
7
  /**
8
8
  * Generate a GTime stamp for the current moment
9
- * Format: HASH_ALGO|TIMESTAMP|REGION_CODE
9
+ * Format: ALGORITHM|TIMESTAMP|LOCALE_OR_DID
10
+ * Representing the mathematical coordinate (a,b,c) for an event signature.
10
11
  */
11
- static stampNow(hashAlgorithm?: string): string;
12
+ static stampNow(hashAlgorithm?: string, localeOrDID?: string): string;
12
13
  /**
13
14
  * Parse a GTime string
14
15
  */
15
16
  static parse(gtime: string): {
16
- timestamp: Date;
17
17
  algorithm: string;
18
- region: string;
18
+ timestamp: Date;
19
+ localeOrDID: string;
19
20
  };
20
- /**
21
- * Get the hash algorithm from a GTime string
22
- */
21
+ /** Extract coordinate a: Algorithm */
22
+ static getAlgorithm(gtime: string): string;
23
+ /** Alias for backward compatibility */
23
24
  static getHashAlgorithm(gtime: string): string;
24
- /**
25
- * Get the timestamp from a GTime string
26
- */
25
+ /** Extract coordinate b: Timestamp */
27
26
  static getTimestamp(gtime: string): Date;
28
- /**
29
- * Get the region code from a GTime string
30
- */
27
+ /** Extract coordinate c: Locale or DID */
28
+ static getLocaleOrDID(gtime: string): string;
29
+ /** Alias for backward compatibility */
31
30
  static getRegionCode(gtime: string): string;
32
31
  /**
33
32
  * Check if the provided hash function is valid.
@@ -35,8 +34,8 @@ declare class GTime {
35
34
  */
36
35
  static isValidHashFunction(hashFunction: string): boolean;
37
36
  /**
38
- * Check if the provided region code is valid.
39
- * Matches Python's GTime.is_valid_region_code()
37
+ * Check if the provided locale/region code is valid.
38
+ * Maintains backward compatibility by checking for strings.
40
39
  */
41
40
  static isValidRegionCode(regionCode: string): boolean;
42
41
  /**
@@ -701,6 +700,24 @@ interface ExecutionResult {
701
700
  liveness_metrics: LivenessMetric[];
702
701
  error_message?: string;
703
702
  }
703
+ /**
704
+ * Raised when a PCard's precondition check fails during VCard Sandwich evaluation.
705
+ */
706
+ declare class PreconditionViolation extends Error {
707
+ readonly pcardHash: string;
708
+ readonly inputHash: string;
709
+ readonly detail: string;
710
+ constructor(pcardHash: string, inputHash: string, detail?: string);
711
+ }
712
+ /**
713
+ * Raised when a PCard's postcondition check fails during VCard Sandwich evaluation.
714
+ */
715
+ declare class PostconditionViolation extends Error {
716
+ readonly pcardHash: string;
717
+ readonly outputRepr: string;
718
+ readonly detail: string;
719
+ constructor(pcardHash: string, outputRepr: string, detail?: string);
720
+ }
704
721
 
705
722
  type StoredMCardContent = string | Uint8Array | Record<string, unknown>;
706
723
  type CardRecord = {
@@ -821,4 +838,4 @@ declare class ValidationRegistry {
821
838
  }
822
839
  declare const validationRegistry: ValidationRegistry;
823
840
 
824
- export { ALGORITHM_HIERARCHY, CardCollection, ContentHandle, ContentTypeInterpreter, EVENT_CONSTANTS, Either, ErrorCodes, type ExecutionResult, FaroSidecar, type FaroSidecarConfig, GTime, HandleValidationError, HashValidator, IO, IndexedDBEngine, type JsonRpcRequest, type JsonRpcResponse, LensProtocol, type LivenessMetric, MCard, MCardStore, Maybe, Page, type PolynomialTerm, type PrimeHash, Reader, type SafetyViolation, ServiceWorkerPTR, State, StorageEngine, ValidationRegistry, VerificationStatus, Writer, computeHash, validateHandle, validationRegistry };
841
+ export { ALGORITHM_HIERARCHY, CardCollection, ContentHandle, ContentTypeInterpreter, EVENT_CONSTANTS, Either, ErrorCodes, type ExecutionResult, FaroSidecar, type FaroSidecarConfig, GTime, HandleValidationError, HashValidator, IO, IndexedDBEngine, type JsonRpcRequest, type JsonRpcResponse, LensProtocol, type LivenessMetric, MCard, MCardStore, Maybe, Page, type PolynomialTerm, PostconditionViolation, PreconditionViolation, type PrimeHash, Reader, type SafetyViolation, ServiceWorkerPTR, State, StorageEngine, ValidationRegistry, VerificationStatus, Writer, computeHash, validateHandle, validationRegistry };
@@ -3,6 +3,8 @@ import {
3
3
  FaroSidecar,
4
4
  LensProtocol,
5
5
  MCardStore,
6
+ PostconditionViolation,
7
+ PreconditionViolation,
6
8
  Reader,
7
9
  ServiceWorkerPTR,
8
10
  State,
@@ -11,10 +13,10 @@ import {
11
13
  Writer,
12
14
  computeHash,
13
15
  validationRegistry
14
- } from "./chunk-SP4YPKPR.js";
16
+ } from "./chunk-XJZOEM5F.js";
15
17
  import {
16
18
  IndexedDBEngine
17
- } from "./chunk-GQZKMXGA.js";
19
+ } from "./chunk-NGTY4P6A.js";
18
20
  import {
19
21
  IO
20
22
  } from "./chunk-MPMRBT5R.js";
@@ -23,8 +25,8 @@ import {
23
25
  } from "./chunk-2KADE3SE.js";
24
26
  import {
25
27
  SqliteWasmEngine
26
- } from "./chunk-UFSXA5QB.js";
27
- import "./chunk-FPW33LMV.js";
28
+ } from "./chunk-7AXRV7NS.js";
29
+ import "./chunk-HIVVDGE5.js";
28
30
  import "./chunk-3EIBJPNF.js";
29
31
  import {
30
32
  ContentHandle,
@@ -39,16 +41,16 @@ import {
39
41
  import {
40
42
  CardCollection,
41
43
  Maybe
42
- } from "./chunk-Q7EHSN3K.js";
43
- import "./chunk-J3IDWMDN.js";
44
+ } from "./chunk-QPVEUPMU.js";
45
+ import "./chunk-3FFEA2XK.js";
44
46
  import {
45
47
  ContentTypeInterpreter,
46
48
  MCard
47
- } from "./chunk-2NFGZ6PA.js";
49
+ } from "./chunk-GGQCF7ZK.js";
48
50
  import {
49
51
  GTime,
50
52
  HashValidator
51
- } from "./chunk-7NKII2JA.js";
53
+ } from "./chunk-ASW6AOA7.js";
52
54
  import "./chunk-PNKVD2UK.js";
53
55
 
54
56
  // src/index.browser.ts
@@ -71,6 +73,8 @@ export {
71
73
  MCard,
72
74
  MCardStore,
73
75
  Maybe,
76
+ PostconditionViolation,
77
+ PreconditionViolation,
74
78
  Reader,
75
79
  ServiceWorkerPTR,
76
80
  SqliteWasmEngine,