@inupedia/spotlight-client 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clientTool.d.ts.map +1 -1
- package/dist/clientTool.js +85 -1
- package/package.json +2 -2
package/dist/clientTool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientTool.d.ts","sourceRoot":"","sources":["../src/clientTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC,eAAO,MAAM,gBAAgB,eAA+C,CAAC;AAE7E,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,mEAAmE;IACnE,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,wBAAwB,CAAC;CAClC;AAED,MAAM,MAAM,iBAAiB,CAAC,MAAM,EAAE,OAAO,IAAI,CAC/C,KAAK,EAAE,MAAM,KACV,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,MAAM,MAAM,UAAU,CAAC,MAAM,GAAG,KAAK,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
76
76
|
}
|
|
77
77
|
async function sha256(value) {
|
|
78
78
|
const bytes = new TextEncoder().encode(value);
|
|
79
|
-
const digest =
|
|
79
|
+
const digest = globalThis.crypto?.subtle
|
|
80
|
+
? await globalThis.crypto.subtle.digest("SHA-256", bytes)
|
|
81
|
+
: sha256Fallback(bytes);
|
|
80
82
|
return `sha256:${[...new Uint8Array(digest)]
|
|
81
83
|
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
82
84
|
.join("")}`;
|
|
83
85
|
}
|
|
86
|
+
const SHA256_INITIAL_STATE = [
|
|
87
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f,
|
|
88
|
+
0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
89
|
+
];
|
|
90
|
+
const SHA256_ROUND_CONSTANTS = [
|
|
91
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
|
|
92
|
+
0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
|
|
93
|
+
0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
|
|
94
|
+
0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
|
95
|
+
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
|
|
96
|
+
0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
|
|
97
|
+
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
|
|
98
|
+
0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
99
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
|
|
100
|
+
0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
|
|
101
|
+
0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
|
|
102
|
+
0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
103
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
104
|
+
];
|
|
105
|
+
function rotateRight(value, amount) {
|
|
106
|
+
return (value >>> amount) | (value << (32 - amount));
|
|
107
|
+
}
|
|
108
|
+
/** Browser-safe SHA-256 for HTTP origins where Web Crypto is unavailable. */
|
|
109
|
+
function sha256Fallback(bytes) {
|
|
110
|
+
const bitLength = bytes.length * 8;
|
|
111
|
+
const paddedLength = Math.ceil((bytes.length + 9) / 64) * 64;
|
|
112
|
+
const padded = new Uint8Array(paddedLength);
|
|
113
|
+
padded.set(bytes);
|
|
114
|
+
padded[bytes.length] = 0x80;
|
|
115
|
+
const paddedView = new DataView(padded.buffer);
|
|
116
|
+
paddedView.setUint32(paddedLength - 8, Math.floor(bitLength / 0x100000000));
|
|
117
|
+
paddedView.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
118
|
+
const state = [...SHA256_INITIAL_STATE];
|
|
119
|
+
const words = new Uint32Array(64);
|
|
120
|
+
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
121
|
+
for (let index = 0; index < 16; index += 1) {
|
|
122
|
+
words[index] = paddedView.getUint32(offset + index * 4);
|
|
123
|
+
}
|
|
124
|
+
for (let index = 16; index < 64; index += 1) {
|
|
125
|
+
const previous15 = words[index - 15] ?? 0;
|
|
126
|
+
const previous2 = words[index - 2] ?? 0;
|
|
127
|
+
const sigma0 = rotateRight(previous15, 7) ^
|
|
128
|
+
rotateRight(previous15, 18) ^
|
|
129
|
+
(previous15 >>> 3);
|
|
130
|
+
const sigma1 = rotateRight(previous2, 17) ^
|
|
131
|
+
rotateRight(previous2, 19) ^
|
|
132
|
+
(previous2 >>> 10);
|
|
133
|
+
words[index] =
|
|
134
|
+
(words[index - 16] + sigma0 + words[index - 7] + sigma1) >>> 0;
|
|
135
|
+
}
|
|
136
|
+
let [a, b, c, d, e, f, g, h] = state;
|
|
137
|
+
for (let index = 0; index < 64; index += 1) {
|
|
138
|
+
const sum1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
139
|
+
const choose = (e & f) ^ (~e & g);
|
|
140
|
+
const temporary1 = (h + sum1 + choose + SHA256_ROUND_CONSTANTS[index] + words[index]) >>>
|
|
141
|
+
0;
|
|
142
|
+
const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
143
|
+
const majority = (a & b) ^ (a & c) ^ (b & c);
|
|
144
|
+
const temporary2 = (sum0 + majority) >>> 0;
|
|
145
|
+
h = g;
|
|
146
|
+
g = f;
|
|
147
|
+
f = e;
|
|
148
|
+
e = (d + temporary1) >>> 0;
|
|
149
|
+
d = c;
|
|
150
|
+
c = b;
|
|
151
|
+
b = a;
|
|
152
|
+
a = (temporary1 + temporary2) >>> 0;
|
|
153
|
+
}
|
|
154
|
+
state[0] = (state[0] + a) >>> 0;
|
|
155
|
+
state[1] = (state[1] + b) >>> 0;
|
|
156
|
+
state[2] = (state[2] + c) >>> 0;
|
|
157
|
+
state[3] = (state[3] + d) >>> 0;
|
|
158
|
+
state[4] = (state[4] + e) >>> 0;
|
|
159
|
+
state[5] = (state[5] + f) >>> 0;
|
|
160
|
+
state[6] = (state[6] + g) >>> 0;
|
|
161
|
+
state[7] = (state[7] + h) >>> 0;
|
|
162
|
+
}
|
|
163
|
+
const digest = new Uint8Array(32);
|
|
164
|
+
const digestView = new DataView(digest.buffer);
|
|
165
|
+
state.forEach((word, index) => digestView.setUint32(index * 4, word));
|
|
166
|
+
return digest;
|
|
167
|
+
}
|
|
84
168
|
export async function createClientToolManifest(options) {
|
|
85
169
|
const registry = createClientToolRegistry(options.tools);
|
|
86
170
|
const tools = [...registry.descriptors].sort((a, b) => a.name.localeCompare(b.name));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inupedia/spotlight-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Build-described browser Client Tools and HTTP helpers for Inupedia Spotlight",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@babel/types": "^7.28.5",
|
|
34
34
|
"magic-string": "^0.30.21",
|
|
35
35
|
"yaml": "^2.8.4",
|
|
36
|
-
"@inupedia/spotlight-protocol": "0.
|
|
36
|
+
"@inupedia/spotlight-protocol": "0.5.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|