@anuma/sdk 6.44.0 → 7.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.
- package/dist/expo/index.cjs +137 -9
- package/dist/expo/index.d.mts +8 -1
- package/dist/expo/index.d.ts +8 -1
- package/dist/expo/index.mjs +136 -9
- package/dist/index.cjs +188 -212
- package/dist/index.d.mts +1 -149
- package/dist/index.d.ts +1 -149
- package/dist/index.mjs +188 -209
- package/dist/react/index.cjs +4386 -7331
- package/dist/react/index.d.mts +38 -1016
- package/dist/react/index.d.ts +38 -1016
- package/dist/react/index.mjs +2955 -5844
- package/dist/server/index.cjs +126 -5
- package/dist/server/index.d.mts +8 -1
- package/dist/server/index.d.ts +8 -1
- package/dist/server/index.mjs +125 -5
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1106,30 +1106,6 @@ var postApiV1WebhooksRevenuecat = (options) => (options?.client ?? client).post(
|
|
|
1106
1106
|
});
|
|
1107
1107
|
var getApiV1ZetaCreditRate = (options) => (options?.client ?? client).get({ url: "/api/v1/zeta/credit-rate", ...options });
|
|
1108
1108
|
var getApiV1ZetaMarket = (options) => (options?.client ?? client).get({ url: "/api/v1/zeta/market", ...options });
|
|
1109
|
-
var postAuthOauthByProviderExchange = (options) => (options.client ?? client).post({
|
|
1110
|
-
url: "/auth/oauth/{provider}/exchange",
|
|
1111
|
-
...options,
|
|
1112
|
-
headers: {
|
|
1113
|
-
"Content-Type": "application/json",
|
|
1114
|
-
...options.headers
|
|
1115
|
-
}
|
|
1116
|
-
});
|
|
1117
|
-
var postAuthOauthByProviderRefresh = (options) => (options.client ?? client).post({
|
|
1118
|
-
url: "/auth/oauth/{provider}/refresh",
|
|
1119
|
-
...options,
|
|
1120
|
-
headers: {
|
|
1121
|
-
"Content-Type": "application/json",
|
|
1122
|
-
...options.headers
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
var postAuthOauthByProviderRevoke = (options) => (options.client ?? client).post({
|
|
1126
|
-
url: "/auth/oauth/{provider}/revoke",
|
|
1127
|
-
...options,
|
|
1128
|
-
headers: {
|
|
1129
|
-
"Content-Type": "application/json",
|
|
1130
|
-
...options.headers
|
|
1131
|
-
}
|
|
1132
|
-
});
|
|
1133
1109
|
var getHealth = (options) => (options?.client ?? client).get({ url: "/health", ...options });
|
|
1134
1110
|
|
|
1135
1111
|
// src/lib/chat/fileContext.ts
|
|
@@ -1172,6 +1148,192 @@ function attachFileContextToLastUserMessage(messages, fileContext) {
|
|
|
1172
1148
|
return result;
|
|
1173
1149
|
}
|
|
1174
1150
|
|
|
1151
|
+
// src/lib/logger.ts
|
|
1152
|
+
var consoleLogger = {
|
|
1153
|
+
debug: console.log.bind(console),
|
|
1154
|
+
info: console.info.bind(console),
|
|
1155
|
+
warn: console.warn.bind(console),
|
|
1156
|
+
error: console.error.bind(console)
|
|
1157
|
+
};
|
|
1158
|
+
var noopLogger = {
|
|
1159
|
+
debug: () => {
|
|
1160
|
+
},
|
|
1161
|
+
info: () => {
|
|
1162
|
+
},
|
|
1163
|
+
warn: () => {
|
|
1164
|
+
},
|
|
1165
|
+
error: () => {
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
1169
|
+
var loggerGlobal = globalThis;
|
|
1170
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
1171
|
+
var fallbackWarned = false;
|
|
1172
|
+
function getLoggerState() {
|
|
1173
|
+
try {
|
|
1174
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
1175
|
+
} catch {
|
|
1176
|
+
if (!fallbackWarned) {
|
|
1177
|
+
fallbackWarned = true;
|
|
1178
|
+
fallbackLoggerState.logger.warn(
|
|
1179
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
return fallbackLoggerState;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
function setLogger(logger) {
|
|
1186
|
+
getLoggerState().logger = logger;
|
|
1187
|
+
}
|
|
1188
|
+
function getLogger() {
|
|
1189
|
+
return getLoggerState().logger;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// src/react/useEncryption.ts
|
|
1193
|
+
var EncryptionKeyMissingError = class extends Error {
|
|
1194
|
+
constructor(address, version) {
|
|
1195
|
+
super(
|
|
1196
|
+
`Encryption key (${version}) not found for ${address}. Please sign a message to generate your encryption key.`
|
|
1197
|
+
);
|
|
1198
|
+
this.name = "EncryptionKeyMissingError";
|
|
1199
|
+
this.address = address;
|
|
1200
|
+
this.version = version;
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
var encryptionKeyStore = /* @__PURE__ */ new Map();
|
|
1204
|
+
var cryptoKeyCache = /* @__PURE__ */ new Map();
|
|
1205
|
+
var clearAllEncryptionStateCallbacks = /* @__PURE__ */ new Set();
|
|
1206
|
+
function onClearAllEncryptionState(callback) {
|
|
1207
|
+
clearAllEncryptionStateCallbacks.add(callback);
|
|
1208
|
+
return () => {
|
|
1209
|
+
clearAllEncryptionStateCallbacks.delete(callback);
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
function getStoredKeyByVersion(address, version) {
|
|
1213
|
+
const keys = encryptionKeyStore.get(address);
|
|
1214
|
+
if (!keys) return null;
|
|
1215
|
+
const value = version === "v2" ? keys.legacy : keys.current;
|
|
1216
|
+
return value ?? null;
|
|
1217
|
+
}
|
|
1218
|
+
function hexNibble(code) {
|
|
1219
|
+
if (code >= 48 && code <= 57) return code - 48;
|
|
1220
|
+
if (code >= 65 && code <= 70) return code - 55;
|
|
1221
|
+
if (code >= 97 && code <= 102) return code - 87;
|
|
1222
|
+
return -1;
|
|
1223
|
+
}
|
|
1224
|
+
function hexToBytes(hex) {
|
|
1225
|
+
if (typeof hex !== "string") {
|
|
1226
|
+
throw new TypeError(
|
|
1227
|
+
"hexToBytes: expected a hex string. Pass raw signature bytes to deriveKeyFromSignatureBytes instead of stringifying them."
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
1231
|
+
if (cleanHex.length === 0 || cleanHex.length % 2 !== 0) {
|
|
1232
|
+
throw new Error(
|
|
1233
|
+
`hexToBytes: invalid hex string (expected a non-empty even length, got ${cleanHex.length})`
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
1237
|
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
1238
|
+
const hi = hexNibble(cleanHex.charCodeAt(i));
|
|
1239
|
+
const lo = hexNibble(cleanHex.charCodeAt(i + 1));
|
|
1240
|
+
if (hi < 0 || lo < 0) {
|
|
1241
|
+
throw new Error(`hexToBytes: invalid hex string (non-hex character at index ${i})`);
|
|
1242
|
+
}
|
|
1243
|
+
bytes[i / 2] = hi << 4 | lo;
|
|
1244
|
+
}
|
|
1245
|
+
return bytes;
|
|
1246
|
+
}
|
|
1247
|
+
var SHARED_TEXT_ENCODER = new TextEncoder();
|
|
1248
|
+
var SHARED_TEXT_DECODER = new TextDecoder();
|
|
1249
|
+
async function getEncryptionKey(address, version = "v3") {
|
|
1250
|
+
const cacheKey = `${address}:${version}`;
|
|
1251
|
+
const cachedKey = cryptoKeyCache.get(cacheKey);
|
|
1252
|
+
if (cachedKey) {
|
|
1253
|
+
return cachedKey;
|
|
1254
|
+
}
|
|
1255
|
+
const keyHex = getStoredKeyByVersion(address, version);
|
|
1256
|
+
if (!keyHex) {
|
|
1257
|
+
throw new EncryptionKeyMissingError(address, version);
|
|
1258
|
+
}
|
|
1259
|
+
const keyBytes = hexToBytes(keyHex);
|
|
1260
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
1261
|
+
"raw",
|
|
1262
|
+
keyBytes.buffer,
|
|
1263
|
+
{ name: "AES-GCM" },
|
|
1264
|
+
false,
|
|
1265
|
+
["encrypt", "decrypt"]
|
|
1266
|
+
);
|
|
1267
|
+
cryptoKeyCache.set(cacheKey, cryptoKey);
|
|
1268
|
+
return cryptoKey;
|
|
1269
|
+
}
|
|
1270
|
+
async function decryptData(encryptedHex, address, version = "v3") {
|
|
1271
|
+
const key = await getEncryptionKey(address, version);
|
|
1272
|
+
return decryptDataWithKey(encryptedHex, key);
|
|
1273
|
+
}
|
|
1274
|
+
function hasEncryptionKey(address, version) {
|
|
1275
|
+
return getStoredKeyByVersion(address, version ?? "v3") !== null;
|
|
1276
|
+
}
|
|
1277
|
+
async function decryptDataWithKey(encryptedHex, key) {
|
|
1278
|
+
const combined = hexToBytes(encryptedHex);
|
|
1279
|
+
const iv = combined.subarray(0, 12);
|
|
1280
|
+
const encryptedData = combined.subarray(12);
|
|
1281
|
+
const decryptedData = await crypto.subtle.decrypt(
|
|
1282
|
+
{
|
|
1283
|
+
name: "AES-GCM",
|
|
1284
|
+
iv
|
|
1285
|
+
},
|
|
1286
|
+
key,
|
|
1287
|
+
encryptedData
|
|
1288
|
+
);
|
|
1289
|
+
return SHARED_TEXT_DECODER.decode(decryptedData);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// src/lib/db/encryption-utils.ts
|
|
1293
|
+
function isEncrypted(value) {
|
|
1294
|
+
const prefix = value.startsWith("enc:v3:") ? "enc:v3:" : value.startsWith("enc:v2:") ? "enc:v2:" : null;
|
|
1295
|
+
if (!prefix) return false;
|
|
1296
|
+
const payload = value.slice(prefix.length);
|
|
1297
|
+
return payload.length >= 56 && /^[0-9a-f]+$/i.test(payload);
|
|
1298
|
+
}
|
|
1299
|
+
function hasEncryptedToolPayload(event) {
|
|
1300
|
+
return [event.arguments, event.output].some(
|
|
1301
|
+
(value) => typeof value === "string" && isEncrypted(value)
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
function detectEncryptionVersion(value) {
|
|
1305
|
+
if (value.startsWith("enc:v3:")) {
|
|
1306
|
+
return { version: "v3", encryptedData: value.slice("enc:v3:".length) };
|
|
1307
|
+
}
|
|
1308
|
+
if (value.startsWith("enc:v2:")) {
|
|
1309
|
+
return { version: "v2", encryptedData: value.slice("enc:v2:".length) };
|
|
1310
|
+
}
|
|
1311
|
+
return null;
|
|
1312
|
+
}
|
|
1313
|
+
async function decryptFieldDetailed(value, address) {
|
|
1314
|
+
if (!value) return { status: "plaintext", value };
|
|
1315
|
+
const detected = detectEncryptionVersion(value);
|
|
1316
|
+
if (!detected) return { status: "plaintext", value };
|
|
1317
|
+
if (detected.encryptedData.length < 56 || !/^[0-9a-f]+$/i.test(detected.encryptedData)) {
|
|
1318
|
+
return { status: "invalid_payload", value, version: detected.version };
|
|
1319
|
+
}
|
|
1320
|
+
try {
|
|
1321
|
+
const plaintext = await decryptData(detected.encryptedData, address, detected.version);
|
|
1322
|
+
return { status: "ok", value: plaintext, version: detected.version };
|
|
1323
|
+
} catch (error) {
|
|
1324
|
+
if (error instanceof EncryptionKeyMissingError) {
|
|
1325
|
+
getLogger().warn("Failed to decrypt field (key missing for version):", error.message);
|
|
1326
|
+
return { status: "key_missing", value, version: detected.version };
|
|
1327
|
+
}
|
|
1328
|
+
getLogger().warn("Failed to decrypt field (auth mismatch or crypto error):", error);
|
|
1329
|
+
return { status: "auth_mismatch", value, version: detected.version };
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
async function decryptField(value, address) {
|
|
1333
|
+
const result = await decryptFieldDetailed(value, address);
|
|
1334
|
+
return result.value;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1175
1337
|
// src/lib/chat/reservationReceipts.ts
|
|
1176
1338
|
var ACTIONS = [
|
|
1177
1339
|
{
|
|
@@ -1193,7 +1355,8 @@ function extractReservationReceipts(toolCallEvents) {
|
|
|
1193
1355
|
for (const event of toolCallEvents ?? []) {
|
|
1194
1356
|
const action = ACTIONS.find((a) => event.name?.endsWith(a.tool));
|
|
1195
1357
|
const output = event.output ?? "";
|
|
1196
|
-
if (!action || !output || NOT_AN_ATTEMPT.test(output))
|
|
1358
|
+
if (!action || !output || hasEncryptedToolPayload(event) || NOT_AN_ATTEMPT.test(output))
|
|
1359
|
+
continue;
|
|
1197
1360
|
const kept = latest.get(action.kind)?.status;
|
|
1198
1361
|
if (kept === "made") continue;
|
|
1199
1362
|
const receipt = toReceipt(action, event.arguments ?? "", output);
|
|
@@ -1442,187 +1605,6 @@ function getImageModel(r) {
|
|
|
1442
1605
|
return r.image_model;
|
|
1443
1606
|
}
|
|
1444
1607
|
|
|
1445
|
-
// src/lib/logger.ts
|
|
1446
|
-
var consoleLogger = {
|
|
1447
|
-
debug: console.log.bind(console),
|
|
1448
|
-
info: console.info.bind(console),
|
|
1449
|
-
warn: console.warn.bind(console),
|
|
1450
|
-
error: console.error.bind(console)
|
|
1451
|
-
};
|
|
1452
|
-
var noopLogger = {
|
|
1453
|
-
debug: () => {
|
|
1454
|
-
},
|
|
1455
|
-
info: () => {
|
|
1456
|
-
},
|
|
1457
|
-
warn: () => {
|
|
1458
|
-
},
|
|
1459
|
-
error: () => {
|
|
1460
|
-
}
|
|
1461
|
-
};
|
|
1462
|
-
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
1463
|
-
var loggerGlobal = globalThis;
|
|
1464
|
-
var fallbackLoggerState = { logger: consoleLogger };
|
|
1465
|
-
var fallbackWarned = false;
|
|
1466
|
-
function getLoggerState() {
|
|
1467
|
-
try {
|
|
1468
|
-
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
1469
|
-
} catch {
|
|
1470
|
-
if (!fallbackWarned) {
|
|
1471
|
-
fallbackWarned = true;
|
|
1472
|
-
fallbackLoggerState.logger.warn(
|
|
1473
|
-
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
1474
|
-
);
|
|
1475
|
-
}
|
|
1476
|
-
return fallbackLoggerState;
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
function setLogger(logger) {
|
|
1480
|
-
getLoggerState().logger = logger;
|
|
1481
|
-
}
|
|
1482
|
-
function getLogger() {
|
|
1483
|
-
return getLoggerState().logger;
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
// src/react/useEncryption.ts
|
|
1487
|
-
var EncryptionKeyMissingError = class extends Error {
|
|
1488
|
-
constructor(address, version) {
|
|
1489
|
-
super(
|
|
1490
|
-
`Encryption key (${version}) not found for ${address}. Please sign a message to generate your encryption key.`
|
|
1491
|
-
);
|
|
1492
|
-
this.name = "EncryptionKeyMissingError";
|
|
1493
|
-
this.address = address;
|
|
1494
|
-
this.version = version;
|
|
1495
|
-
}
|
|
1496
|
-
};
|
|
1497
|
-
var encryptionKeyStore = /* @__PURE__ */ new Map();
|
|
1498
|
-
var cryptoKeyCache = /* @__PURE__ */ new Map();
|
|
1499
|
-
var clearAllEncryptionStateCallbacks = /* @__PURE__ */ new Set();
|
|
1500
|
-
function onClearAllEncryptionState(callback) {
|
|
1501
|
-
clearAllEncryptionStateCallbacks.add(callback);
|
|
1502
|
-
return () => {
|
|
1503
|
-
clearAllEncryptionStateCallbacks.delete(callback);
|
|
1504
|
-
};
|
|
1505
|
-
}
|
|
1506
|
-
function getStoredKeyByVersion(address, version) {
|
|
1507
|
-
const keys = encryptionKeyStore.get(address);
|
|
1508
|
-
if (!keys) return null;
|
|
1509
|
-
const value = version === "v2" ? keys.legacy : keys.current;
|
|
1510
|
-
return value ?? null;
|
|
1511
|
-
}
|
|
1512
|
-
function hexNibble(code) {
|
|
1513
|
-
if (code >= 48 && code <= 57) return code - 48;
|
|
1514
|
-
if (code >= 65 && code <= 70) return code - 55;
|
|
1515
|
-
if (code >= 97 && code <= 102) return code - 87;
|
|
1516
|
-
return -1;
|
|
1517
|
-
}
|
|
1518
|
-
function hexToBytes(hex) {
|
|
1519
|
-
if (typeof hex !== "string") {
|
|
1520
|
-
throw new TypeError(
|
|
1521
|
-
"hexToBytes: expected a hex string. Pass raw signature bytes to deriveKeyFromSignatureBytes instead of stringifying them."
|
|
1522
|
-
);
|
|
1523
|
-
}
|
|
1524
|
-
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
1525
|
-
if (cleanHex.length === 0 || cleanHex.length % 2 !== 0) {
|
|
1526
|
-
throw new Error(
|
|
1527
|
-
`hexToBytes: invalid hex string (expected a non-empty even length, got ${cleanHex.length})`
|
|
1528
|
-
);
|
|
1529
|
-
}
|
|
1530
|
-
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
1531
|
-
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
1532
|
-
const hi = hexNibble(cleanHex.charCodeAt(i));
|
|
1533
|
-
const lo = hexNibble(cleanHex.charCodeAt(i + 1));
|
|
1534
|
-
if (hi < 0 || lo < 0) {
|
|
1535
|
-
throw new Error(`hexToBytes: invalid hex string (non-hex character at index ${i})`);
|
|
1536
|
-
}
|
|
1537
|
-
bytes[i / 2] = hi << 4 | lo;
|
|
1538
|
-
}
|
|
1539
|
-
return bytes;
|
|
1540
|
-
}
|
|
1541
|
-
var SHARED_TEXT_ENCODER = new TextEncoder();
|
|
1542
|
-
var SHARED_TEXT_DECODER = new TextDecoder();
|
|
1543
|
-
async function getEncryptionKey(address, version = "v3") {
|
|
1544
|
-
const cacheKey = `${address}:${version}`;
|
|
1545
|
-
const cachedKey = cryptoKeyCache.get(cacheKey);
|
|
1546
|
-
if (cachedKey) {
|
|
1547
|
-
return cachedKey;
|
|
1548
|
-
}
|
|
1549
|
-
const keyHex = getStoredKeyByVersion(address, version);
|
|
1550
|
-
if (!keyHex) {
|
|
1551
|
-
throw new EncryptionKeyMissingError(address, version);
|
|
1552
|
-
}
|
|
1553
|
-
const keyBytes = hexToBytes(keyHex);
|
|
1554
|
-
const cryptoKey = await crypto.subtle.importKey(
|
|
1555
|
-
"raw",
|
|
1556
|
-
keyBytes.buffer,
|
|
1557
|
-
{ name: "AES-GCM" },
|
|
1558
|
-
false,
|
|
1559
|
-
["encrypt", "decrypt"]
|
|
1560
|
-
);
|
|
1561
|
-
cryptoKeyCache.set(cacheKey, cryptoKey);
|
|
1562
|
-
return cryptoKey;
|
|
1563
|
-
}
|
|
1564
|
-
async function decryptData(encryptedHex, address, version = "v3") {
|
|
1565
|
-
const key = await getEncryptionKey(address, version);
|
|
1566
|
-
return decryptDataWithKey(encryptedHex, key);
|
|
1567
|
-
}
|
|
1568
|
-
function hasEncryptionKey(address, version) {
|
|
1569
|
-
return getStoredKeyByVersion(address, version ?? "v3") !== null;
|
|
1570
|
-
}
|
|
1571
|
-
async function decryptDataWithKey(encryptedHex, key) {
|
|
1572
|
-
const combined = hexToBytes(encryptedHex);
|
|
1573
|
-
const iv = combined.subarray(0, 12);
|
|
1574
|
-
const encryptedData = combined.subarray(12);
|
|
1575
|
-
const decryptedData = await crypto.subtle.decrypt(
|
|
1576
|
-
{
|
|
1577
|
-
name: "AES-GCM",
|
|
1578
|
-
iv
|
|
1579
|
-
},
|
|
1580
|
-
key,
|
|
1581
|
-
encryptedData
|
|
1582
|
-
);
|
|
1583
|
-
return SHARED_TEXT_DECODER.decode(decryptedData);
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
// src/lib/db/encryption-utils.ts
|
|
1587
|
-
function isEncrypted(value) {
|
|
1588
|
-
const prefix = value.startsWith("enc:v3:") ? "enc:v3:" : value.startsWith("enc:v2:") ? "enc:v2:" : null;
|
|
1589
|
-
if (!prefix) return false;
|
|
1590
|
-
const payload = value.slice(prefix.length);
|
|
1591
|
-
return payload.length >= 56 && /^[0-9a-f]+$/i.test(payload);
|
|
1592
|
-
}
|
|
1593
|
-
function detectEncryptionVersion(value) {
|
|
1594
|
-
if (value.startsWith("enc:v3:")) {
|
|
1595
|
-
return { version: "v3", encryptedData: value.slice("enc:v3:".length) };
|
|
1596
|
-
}
|
|
1597
|
-
if (value.startsWith("enc:v2:")) {
|
|
1598
|
-
return { version: "v2", encryptedData: value.slice("enc:v2:".length) };
|
|
1599
|
-
}
|
|
1600
|
-
return null;
|
|
1601
|
-
}
|
|
1602
|
-
async function decryptFieldDetailed(value, address) {
|
|
1603
|
-
if (!value) return { status: "plaintext", value };
|
|
1604
|
-
const detected = detectEncryptionVersion(value);
|
|
1605
|
-
if (!detected) return { status: "plaintext", value };
|
|
1606
|
-
if (detected.encryptedData.length < 56 || !/^[0-9a-f]+$/i.test(detected.encryptedData)) {
|
|
1607
|
-
return { status: "invalid_payload", value, version: detected.version };
|
|
1608
|
-
}
|
|
1609
|
-
try {
|
|
1610
|
-
const plaintext = await decryptData(detected.encryptedData, address, detected.version);
|
|
1611
|
-
return { status: "ok", value: plaintext, version: detected.version };
|
|
1612
|
-
} catch (error) {
|
|
1613
|
-
if (error instanceof EncryptionKeyMissingError) {
|
|
1614
|
-
getLogger().warn("Failed to decrypt field (key missing for version):", error.message);
|
|
1615
|
-
return { status: "key_missing", value, version: detected.version };
|
|
1616
|
-
}
|
|
1617
|
-
getLogger().warn("Failed to decrypt field (auth mismatch or crypto error):", error);
|
|
1618
|
-
return { status: "auth_mismatch", value, version: detected.version };
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
async function decryptField(value, address) {
|
|
1622
|
-
const result = await decryptFieldDetailed(value, address);
|
|
1623
|
-
return result.value;
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
1608
|
// src/lib/db/chat/lazyDecrypt.ts
|
|
1627
1609
|
var LRU_CAPACITY = 256;
|
|
1628
1610
|
var titleCache = /* @__PURE__ */ new Map();
|
|
@@ -3892,9 +3874,6 @@ export {
|
|
|
3892
3874
|
postApiV1WalletsBinding,
|
|
3893
3875
|
postApiV1WalletsBindingNonce,
|
|
3894
3876
|
postApiV1WebhooksRevenuecat,
|
|
3895
|
-
postAuthOauthByProviderExchange,
|
|
3896
|
-
postAuthOauthByProviderRefresh,
|
|
3897
|
-
postAuthOauthByProviderRevoke,
|
|
3898
3877
|
putApiV1AdminAgentsById,
|
|
3899
3878
|
putApiV1AdminAppsByAppIdApiKeysById,
|
|
3900
3879
|
putApiV1AdminAppsById,
|