@nestos/kanban 0.0.0-stage → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +165 -2
- package/dist/activity-BbC4sgKL.d.cts +258 -0
- package/dist/activity-Czlan5xW.d.ts +258 -0
- package/dist/activity-module-DaO1Rry0.d.cts +22 -0
- package/dist/activity-module-T22wliZu.d.ts +22 -0
- package/dist/activity-ports-Dqxa86zT.d.cts +12 -0
- package/dist/activity-ports-cxfrelaL.d.ts +12 -0
- package/dist/activity.cjs +16 -0
- package/dist/activity.cjs.map +1 -0
- package/dist/activity.d.cts +12 -0
- package/dist/activity.d.ts +12 -0
- package/dist/activity.js +16 -0
- package/dist/activity.js.map +1 -0
- package/dist/chunk-3JYLJPE5.js +95 -0
- package/dist/chunk-3JYLJPE5.js.map +1 -0
- package/dist/chunk-3LEIHB7Y.js +221 -0
- package/dist/chunk-3LEIHB7Y.js.map +1 -0
- package/dist/chunk-4XF6LQSU.cjs +9 -0
- package/dist/chunk-4XF6LQSU.cjs.map +1 -0
- package/dist/chunk-5Q7WB63A.cjs +282 -0
- package/dist/chunk-5Q7WB63A.cjs.map +1 -0
- package/dist/chunk-7KDOTBRX.cjs +58 -0
- package/dist/chunk-7KDOTBRX.cjs.map +1 -0
- package/dist/chunk-AHHEGTUA.js +148 -0
- package/dist/chunk-AHHEGTUA.js.map +1 -0
- package/dist/chunk-AOHQCX7K.cjs +95 -0
- package/dist/chunk-AOHQCX7K.cjs.map +1 -0
- package/dist/chunk-DINLR6E6.cjs +443 -0
- package/dist/chunk-DINLR6E6.cjs.map +1 -0
- package/dist/chunk-EYTVC2H5.cjs +1612 -0
- package/dist/chunk-EYTVC2H5.cjs.map +1 -0
- package/dist/chunk-FEE2YBZ7.js +1972 -0
- package/dist/chunk-FEE2YBZ7.js.map +1 -0
- package/dist/chunk-FNO5K3A7.js +282 -0
- package/dist/chunk-FNO5K3A7.js.map +1 -0
- package/dist/chunk-IHHDXZPZ.js +382 -0
- package/dist/chunk-IHHDXZPZ.js.map +1 -0
- package/dist/chunk-J3EAIVA3.js +280 -0
- package/dist/chunk-J3EAIVA3.js.map +1 -0
- package/dist/chunk-KH3WF3K4.js +443 -0
- package/dist/chunk-KH3WF3K4.js.map +1 -0
- package/dist/chunk-M35X5PHO.js +196 -0
- package/dist/chunk-M35X5PHO.js.map +1 -0
- package/dist/chunk-QRGZD2JU.cjs +1972 -0
- package/dist/chunk-QRGZD2JU.cjs.map +1 -0
- package/dist/chunk-RBOER6EW.cjs +221 -0
- package/dist/chunk-RBOER6EW.cjs.map +1 -0
- package/dist/chunk-RQP77ZTY.js +9 -0
- package/dist/chunk-RQP77ZTY.js.map +1 -0
- package/dist/chunk-RSH6QSEC.cjs +196 -0
- package/dist/chunk-RSH6QSEC.cjs.map +1 -0
- package/dist/chunk-VMRDXOLX.cjs +148 -0
- package/dist/chunk-VMRDXOLX.cjs.map +1 -0
- package/dist/chunk-X4UHZX6F.js +58 -0
- package/dist/chunk-X4UHZX6F.js.map +1 -0
- package/dist/chunk-XBSGUVCY.cjs +382 -0
- package/dist/chunk-XBSGUVCY.cjs.map +1 -0
- package/dist/chunk-XKDZHAUE.js +1612 -0
- package/dist/chunk-XKDZHAUE.js.map +1 -0
- package/dist/chunk-ZUZGAO6G.cjs +280 -0
- package/dist/chunk-ZUZGAO6G.cjs.map +1 -0
- package/dist/content-C5aJZFlw.d.cts +35 -0
- package/dist/content-hLH5BNud.d.ts +35 -0
- package/dist/contracts/index.cjs +31 -0
- package/dist/contracts/index.cjs.map +1 -0
- package/dist/contracts/index.d.cts +5 -0
- package/dist/contracts/index.d.ts +5 -0
- package/dist/contracts/index.js +31 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/discovery-9E-LfwIw.d.cts +61 -0
- package/dist/discovery-D60yrjej.d.ts +61 -0
- package/dist/discovery.cjs +377 -0
- package/dist/discovery.cjs.map +1 -0
- package/dist/discovery.d.cts +22 -0
- package/dist/discovery.d.ts +22 -0
- package/dist/discovery.js +377 -0
- package/dist/discovery.js.map +1 -0
- package/dist/execution-bridge-fpCnH6z5.d.cts +52 -0
- package/dist/execution-bridge-rk0uVy_n.d.ts +52 -0
- package/dist/execution.cjs +18 -0
- package/dist/execution.cjs.map +1 -0
- package/dist/execution.d.cts +42 -0
- package/dist/execution.d.ts +42 -0
- package/dist/execution.js +18 -0
- package/dist/execution.js.map +1 -0
- package/dist/index.cjs +74 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +54 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/module-CYfE7YhM.d.ts +11 -0
- package/dist/module-Ca9L3qCn.d.cts +11 -0
- package/dist/planning-CHrOqQ6b.d.cts +879 -0
- package/dist/planning-CHrOqQ6b.d.ts +879 -0
- package/dist/ports-B0McVg7B.d.ts +143 -0
- package/dist/ports-BeGO1VRI.d.cts +49 -0
- package/dist/ports-GQy0x-RI.d.cts +143 -0
- package/dist/ports-ykGiNUSx.d.ts +49 -0
- package/dist/runtime/index.cjs +205 -0
- package/dist/runtime/index.cjs.map +1 -0
- package/dist/runtime/index.d.cts +75 -0
- package/dist/runtime/index.d.ts +75 -0
- package/dist/runtime/index.js +205 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/integration.cjs +423 -0
- package/dist/runtime/integration.cjs.map +1 -0
- package/dist/runtime/integration.d.cts +658 -0
- package/dist/runtime/integration.d.ts +658 -0
- package/dist/runtime/integration.js +423 -0
- package/dist/runtime/integration.js.map +1 -0
- package/dist/storage.cjs +21 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +71 -0
- package/dist/storage.d.ts +71 -0
- package/dist/storage.js +21 -0
- package/dist/storage.js.map +1 -0
- package/dist/store-DPwHzGiz.d.cts +28 -0
- package/dist/store-DgdrPCV9.d.ts +28 -0
- package/dist/task-projection-CSorlMws.d.ts +11 -0
- package/dist/task-projection-DKKB_ueb.d.cts +11 -0
- package/examples/standalone.ts +22 -0
- package/package.json +143 -4
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// src/ports.ts
|
|
2
|
+
var KanbanError = class extends Error {
|
|
3
|
+
constructor(code) {
|
|
4
|
+
super(code);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.name = "KanbanError";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var KanbanScanNotStartedError = class extends KanbanError {
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/utils/random.ts
|
|
13
|
+
function randomUUID() {
|
|
14
|
+
const webCrypto = globalThis.crypto;
|
|
15
|
+
if (typeof webCrypto?.randomUUID === "function") {
|
|
16
|
+
try {
|
|
17
|
+
return webCrypto.randomUUID();
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return formatV4(randomBytes(16));
|
|
22
|
+
}
|
|
23
|
+
function randomBytes(length) {
|
|
24
|
+
const bytes = new Uint8Array(length);
|
|
25
|
+
if (typeof globalThis.crypto?.getRandomValues === "function") {
|
|
26
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
27
|
+
return bytes;
|
|
28
|
+
}
|
|
29
|
+
for (let i = 0; i < length; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
30
|
+
return bytes;
|
|
31
|
+
}
|
|
32
|
+
function formatV4(bytes) {
|
|
33
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
34
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
35
|
+
const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, "0"));
|
|
36
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/utils/digest.ts
|
|
40
|
+
var SHA256_K = new Uint32Array([
|
|
41
|
+
1116352408,
|
|
42
|
+
1899447441,
|
|
43
|
+
3049323471,
|
|
44
|
+
3921009573,
|
|
45
|
+
961987163,
|
|
46
|
+
1508970993,
|
|
47
|
+
2453635748,
|
|
48
|
+
2870763221,
|
|
49
|
+
3624381080,
|
|
50
|
+
310598401,
|
|
51
|
+
607225278,
|
|
52
|
+
1426881987,
|
|
53
|
+
1925078388,
|
|
54
|
+
2162078206,
|
|
55
|
+
2614888103,
|
|
56
|
+
3248222580,
|
|
57
|
+
3835390401,
|
|
58
|
+
4022224774,
|
|
59
|
+
264347078,
|
|
60
|
+
604807628,
|
|
61
|
+
770255983,
|
|
62
|
+
1249150122,
|
|
63
|
+
1555081692,
|
|
64
|
+
1996064986,
|
|
65
|
+
2554220882,
|
|
66
|
+
2821834349,
|
|
67
|
+
2952996808,
|
|
68
|
+
3210313671,
|
|
69
|
+
3336571891,
|
|
70
|
+
3584528711,
|
|
71
|
+
113926993,
|
|
72
|
+
338241895,
|
|
73
|
+
666307205,
|
|
74
|
+
773529912,
|
|
75
|
+
1294757372,
|
|
76
|
+
1396182291,
|
|
77
|
+
1695183700,
|
|
78
|
+
1986661051,
|
|
79
|
+
2177026350,
|
|
80
|
+
2456956037,
|
|
81
|
+
2730485921,
|
|
82
|
+
2820302411,
|
|
83
|
+
3259730800,
|
|
84
|
+
3345764771,
|
|
85
|
+
3516065817,
|
|
86
|
+
3600352804,
|
|
87
|
+
4094571909,
|
|
88
|
+
275423344,
|
|
89
|
+
430227734,
|
|
90
|
+
506948616,
|
|
91
|
+
659060556,
|
|
92
|
+
883997877,
|
|
93
|
+
958139571,
|
|
94
|
+
1322822218,
|
|
95
|
+
1537002063,
|
|
96
|
+
1747873779,
|
|
97
|
+
1955562222,
|
|
98
|
+
2024104815,
|
|
99
|
+
2227730452,
|
|
100
|
+
2361852424,
|
|
101
|
+
2428436474,
|
|
102
|
+
2756734187,
|
|
103
|
+
3204031479,
|
|
104
|
+
3329325298
|
|
105
|
+
]);
|
|
106
|
+
var SHA256_H = new Uint32Array([
|
|
107
|
+
1779033703,
|
|
108
|
+
3144134277,
|
|
109
|
+
1013904242,
|
|
110
|
+
2773480762,
|
|
111
|
+
1359893119,
|
|
112
|
+
2600822924,
|
|
113
|
+
528734635,
|
|
114
|
+
1541459225
|
|
115
|
+
]);
|
|
116
|
+
var rotateRight = (value, bits) => (value >>> bits | value << 32 - bits) >>> 0;
|
|
117
|
+
function toBytes(input) {
|
|
118
|
+
if (typeof input === "string") return new TextEncoder().encode(input);
|
|
119
|
+
if (input instanceof Uint8Array && input.buffer instanceof ArrayBuffer) {
|
|
120
|
+
return input;
|
|
121
|
+
}
|
|
122
|
+
if (ArrayBuffer.isView(input)) {
|
|
123
|
+
const source = new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
124
|
+
const copy = new Uint8Array(input.byteLength);
|
|
125
|
+
copy.set(source);
|
|
126
|
+
return copy;
|
|
127
|
+
}
|
|
128
|
+
return new Uint8Array(input);
|
|
129
|
+
}
|
|
130
|
+
function toHex(bytes) {
|
|
131
|
+
return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
132
|
+
}
|
|
133
|
+
function paddedMessage(message) {
|
|
134
|
+
const padded = new Uint8Array((Math.floor((message.length + 8) / 64) + 1) * 64);
|
|
135
|
+
padded.set(message);
|
|
136
|
+
padded[message.length] = 128;
|
|
137
|
+
const view = new DataView(padded.buffer);
|
|
138
|
+
const bitLength = message.length * 8;
|
|
139
|
+
view.setUint32(padded.length - 8, Math.floor(bitLength / 4294967296));
|
|
140
|
+
view.setUint32(padded.length - 4, bitLength >>> 0);
|
|
141
|
+
return padded;
|
|
142
|
+
}
|
|
143
|
+
function blockSchedule(view, offset) {
|
|
144
|
+
const words = new Uint32Array(64);
|
|
145
|
+
for (let i = 0; i < 16; i++) words[i] = view.getUint32(offset + i * 4);
|
|
146
|
+
for (let i = 16; i < 64; i++) {
|
|
147
|
+
const s0 = rotateRight(words[i - 15], 7) ^ rotateRight(words[i - 15], 18) ^ words[i - 15] >>> 3;
|
|
148
|
+
const s1 = rotateRight(words[i - 2], 17) ^ rotateRight(words[i - 2], 19) ^ words[i - 2] >>> 10;
|
|
149
|
+
words[i] = words[i - 16] + s0 + words[i - 7] + s1 >>> 0;
|
|
150
|
+
}
|
|
151
|
+
return words;
|
|
152
|
+
}
|
|
153
|
+
function compressBlock(state, words) {
|
|
154
|
+
let [a, b, c, d, e, f, g, h] = state;
|
|
155
|
+
for (let i = 0; i < 64; i++) {
|
|
156
|
+
const sigma1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
157
|
+
const choose = e & f ^ ~e & g;
|
|
158
|
+
const temp1 = h + sigma1 + choose + SHA256_K[i] + words[i] >>> 0;
|
|
159
|
+
const sigma0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
160
|
+
const majority = a & b ^ a & c ^ b & c;
|
|
161
|
+
const temp2 = sigma0 + majority >>> 0;
|
|
162
|
+
h = g;
|
|
163
|
+
g = f;
|
|
164
|
+
f = e;
|
|
165
|
+
e = d + temp1 >>> 0;
|
|
166
|
+
d = c;
|
|
167
|
+
c = b;
|
|
168
|
+
b = a;
|
|
169
|
+
a = temp1 + temp2 >>> 0;
|
|
170
|
+
}
|
|
171
|
+
const next = [a, b, c, d, e, f, g, h];
|
|
172
|
+
for (let i = 0; i < 8; i++) state[i] = state[i] + next[i] >>> 0;
|
|
173
|
+
}
|
|
174
|
+
function sha256Bytes(input) {
|
|
175
|
+
const padded = paddedMessage(toBytes(input));
|
|
176
|
+
const view = new DataView(padded.buffer);
|
|
177
|
+
const state = SHA256_H.slice();
|
|
178
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
179
|
+
compressBlock(state, blockSchedule(view, offset));
|
|
180
|
+
}
|
|
181
|
+
const out = new Uint8Array(32);
|
|
182
|
+
const outView = new DataView(out.buffer);
|
|
183
|
+
for (let i = 0; i < 8; i++) outView.setUint32(i * 4, state[i]);
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
186
|
+
function sha256HexSync(input) {
|
|
187
|
+
return toHex(sha256Bytes(input));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
KanbanError,
|
|
192
|
+
KanbanScanNotStartedError,
|
|
193
|
+
randomUUID,
|
|
194
|
+
sha256HexSync
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=chunk-M35X5PHO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ports.ts","../src/utils/random.ts","../src/utils/digest.ts"],"sourcesContent":["import type { KanbanActor, KanbanBoard, KanbanCommand, KanbanEvent, KanbanArchivedItem, KanbanItemSummary } from './contracts';\n\nexport interface KanbanState {\n workflow?: import('./contracts').KanbanWorkflowState;\n numbering?: {item: number; log: number; decision: number};\n presetVersions?: Record<string, number>;\n records?: import('./contracts').KanbanProjectRecord[];\n discovery?: import('./scan-ports').KanbanDiscoveryState;\n archiveIndex?: KanbanItemSummary[];\n archiveWrites?: Array<{id: string; value: KanbanArchivedItem | null}>;\n restore?: KanbanArchivedItem;\n schema: 1; board: KanbanBoard; sequence: number; events: KanbanEvent[]; escalations: string[];\n}\nexport interface KanbanReadView {\n /** Board metadata and summary indexes; no item/record bodies. */\n state: KanbanState;\n items: import('./contracts').KanbanItemSummary[];\n records: import('./contracts').KanbanRecordSummary[];\n}\nexport interface KanbanStore {\n boardId?(number: number): Promise<string | null>;\n view?(id: string): Promise<KanbanReadView | null>;\n ids(): Promise<string[]>;\n archived(boardId: string, itemId: string): Promise<KanbanArchivedItem | null>;\n events(id: string, after: number, limit: number, through: number): Promise<KanbanEvent[]>;\n read(id: string): Promise<KanbanState | null>;\n update(id: string, operationId: string, fingerprint: string,\n change: (state: KanbanState | null) => KanbanState): Promise<KanbanState>;\n}\nexport interface KanbanModuleOptions {\n /** Host supplies metadata within the authorized user's/project's session scope. */\n suggestions?(board: KanbanBoard, kind: import('./contracts').KanbanSuggestionKind, search: string, limit: number): Promise<import('./contracts').KanbanSuggestion[] | undefined>;\n verifyOutputs?(input: {stage?: 'observe' | 'accept'; board: KanbanBoard; itemId: string; dispatchId?: string; outputs: import('./contracts').KanbanArtifactRef[]}): Promise<boolean>;\n onCommitted?(boardId: string, service: import('./contracts').KanbanService, now: number): Promise<void>;\n store: KanbanStore;\n /** Trusted identity resolved by the host, never from command payloads. */\n actor: KanbanActor;\n /** Must validate project access, delegated authority and session registration. */\n authorize(input: { actor: KanbanActor; board: KanbanBoard; action: 'create' | 'read' | 'install-content' | KanbanCommand['type']; command?: KanbanCommand }): Promise<void>;\n /** Confirm an automated owner has settled before releasing responsibility. */\n verifyDeletion?(board: KanbanBoard): Promise<void>;\n verifyLifecycle?(board: KanbanBoard, command: KanbanCommand): Promise<void>;\n verifyRelease?(input: {actor: KanbanActor; board: KanbanBoard; item: import('./contracts').KanbanItem}): Promise<boolean>;\n now?: () => number;\n id?: () => string;\n log(event: { operationId: string; boardId?: string; sessionId?: string; stage: string; result: 'success' | 'failure'; code?: string; durationMs: number }): void;\n}\nexport class KanbanError extends Error {\n constructor(readonly code: string) { super(code); this.name = 'KanbanError'; }\n}\n\nexport class KanbanScanNotStartedError extends KanbanError {}\n","/**\n * @file common/utils/random.ts\n * @description UUID v4 that also works outside a secure context.\n *\n * `crypto.randomUUID()` is secure-context-only: it is undefined over plain-HTTP\n * LAN origins (e.g. http://192.168.x.x:3000) and in WebKitGTK, so calling it\n * directly throws \"crypto.randomUUID is not a function\". `crypto.getRandomValues()`\n * stays available everywhere, so it backs the fallback below.\n */\n\n/** UUID v4 — native WebCrypto when available, `getRandomValues` otherwise. */\nexport function randomUUID(): string {\n const webCrypto = globalThis.crypto;\n if (typeof webCrypto?.randomUUID === 'function') {\n try {\n return webCrypto.randomUUID();\n } catch {\n // Present but unusable (insecure context) — fall through.\n }\n }\n return formatV4(randomBytes(16));\n}\n\nfunction randomBytes(length: number): Uint8Array {\n const bytes = new Uint8Array(length);\n if (typeof globalThis.crypto?.getRandomValues === 'function') {\n globalThis.crypto.getRandomValues(bytes);\n return bytes;\n }\n for (let i = 0; i < length; i++) bytes[i] = Math.floor(Math.random() * 256);\n return bytes;\n}\n\nfunction formatV4(bytes: Uint8Array): string {\n bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4\n bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant\n const hex = [...bytes].map(byte => byte.toString(16).padStart(2, '0'));\n return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${hex.slice(6, 8).join('')}-${hex.slice(8, 10).join('')}-${hex.slice(10).join('')}`;\n}\n","/**\n * @file common/utils/digest.ts\n * @description SHA-256 that does not require WebCrypto.\n *\n * `crypto.subtle` only exists in a secure context (HTTPS or localhost) and is\n * absent in WebKitGTK, so `crypto.subtle.digest(...)` throws \"Cannot read\n * properties of undefined (reading 'digest')\" when the app is opened over a LAN\n * HTTP origin (e.g. http://192.168.x.x:3000) or in the packaged Linux app. The\n * pure-JS fallback below computes the very same SHA-256, so digests stay stable\n * across environments.\n */\n\n/** Any input a caller may want hashed. */\nexport type DigestInput = string | ArrayBuffer | ArrayBufferView;\n\nconst SHA256_K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\nconst SHA256_H = new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n\nconst rotateRight = (value: number, bits: number): number =>\n ((value >>> bits) | (value << (32 - bits))) >>> 0;\n\nfunction toBytes(input: DigestInput): Uint8Array<ArrayBuffer> {\n if (typeof input === 'string') return new TextEncoder().encode(input);\n if (input instanceof Uint8Array && input.buffer instanceof ArrayBuffer) {\n return input as Uint8Array<ArrayBuffer>;\n }\n if (ArrayBuffer.isView(input)) {\n // Copy so WebCrypto gets a plain ArrayBuffer (never a SharedArrayBuffer view).\n const source = new Uint8Array(input.buffer as ArrayBufferLike, input.byteOffset, input.byteLength);\n const copy = new Uint8Array(input.byteLength);\n copy.set(source);\n return copy;\n }\n return new Uint8Array(input);\n}\n\nfunction toHex(bytes: Uint8Array): string {\n return [...bytes].map(byte => byte.toString(16).padStart(2, '0')).join('');\n}\n\nfunction paddedMessage(message: Uint8Array): Uint8Array {\n const padded = new Uint8Array((Math.floor((message.length + 8) / 64) + 1) * 64);\n padded.set(message);\n padded[message.length] = 0x80;\n const view = new DataView(padded.buffer);\n const bitLength = message.length * 8;\n view.setUint32(padded.length - 8, Math.floor(bitLength / 0x1_0000_0000));\n view.setUint32(padded.length - 4, bitLength >>> 0);\n return padded;\n}\n\nfunction blockSchedule(view: DataView, offset: number): Uint32Array {\n const words = new Uint32Array(64);\n for (let i = 0; i < 16; i++) words[i] = view.getUint32(offset + i * 4);\n for (let i = 16; i < 64; i++) {\n const s0 = rotateRight(words[i - 15], 7) ^ rotateRight(words[i - 15], 18) ^ (words[i - 15] >>> 3);\n const s1 = rotateRight(words[i - 2], 17) ^ rotateRight(words[i - 2], 19) ^ (words[i - 2] >>> 10);\n words[i] = (words[i - 16] + s0 + words[i - 7] + s1) >>> 0;\n }\n return words;\n}\n\nfunction compressBlock(state: Uint32Array, words: Uint32Array): void {\n let [a, b, c, d, e, f, g, h] = state;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);\n const choose = (e & f) ^ (~e & g);\n const temp1 = (h + sigma1 + choose + SHA256_K[i] + words[i]) >>> 0;\n const sigma0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);\n const majority = (a & b) ^ (a & c) ^ (b & c);\n const temp2 = (sigma0 + majority) >>> 0;\n h = g; g = f; f = e; e = (d + temp1) >>> 0;\n d = c; c = b; b = a; a = (temp1 + temp2) >>> 0;\n }\n const next = [a, b, c, d, e, f, g, h];\n for (let i = 0; i < 8; i++) state[i] = (state[i] + next[i]) >>> 0;\n}\n\n/** Pure-JS SHA-256 usable where WebCrypto is unavailable. */\nexport function sha256Bytes(input: DigestInput): Uint8Array {\n const padded = paddedMessage(toBytes(input));\n const view = new DataView(padded.buffer);\n const state = SHA256_H.slice();\n for (let offset = 0; offset < padded.length; offset += 64) {\n compressBlock(state, blockSchedule(view, offset));\n }\n const out = new Uint8Array(32);\n const outView = new DataView(out.buffer);\n for (let i = 0; i < 8; i++) outView.setUint32(i * 4, state[i]);\n return out;\n}\n\n/** SHA-256 hex digest — WebCrypto when available, pure JS otherwise. */\nexport async function sha256Hex(input: DigestInput): Promise<string> {\n const bytes = toBytes(input);\n const subtle = globalThis.crypto?.subtle;\n if (subtle?.digest) {\n try {\n return toHex(new Uint8Array(await subtle.digest('SHA-256', bytes)));\n } catch {\n // WebCrypto present but unusable (e.g. blocked by an insecure context).\n }\n }\n return toHex(sha256Bytes(bytes));\n}\n\n/**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