@thurinlabs/identity-kit 1.0.2 → 1.0.3
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 +21 -0
- package/README.md +4 -0
- package/dist/embed.global.js +26 -6
- package/dist/embed.global.js.map +1 -1
- package/dist/index.cjs +26 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1339,7 +1339,9 @@ function keyIdToBytes(keyId) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
|
|
1341
1341
|
// src/core/pgp.ts
|
|
1342
|
-
|
|
1342
|
+
function pgpConfig(openpgp) {
|
|
1343
|
+
return { ...openpgp.config, rejectCurves: /* @__PURE__ */ new Set() };
|
|
1344
|
+
}
|
|
1343
1345
|
function algorithmName(keyOrSubkey) {
|
|
1344
1346
|
try {
|
|
1345
1347
|
const info = keyOrSubkey.getAlgorithmInfo();
|
|
@@ -1361,7 +1363,9 @@ function algorithmName(keyOrSubkey) {
|
|
|
1361
1363
|
}
|
|
1362
1364
|
async function parsePgpKey(armoredKey) {
|
|
1363
1365
|
try {
|
|
1364
|
-
const
|
|
1366
|
+
const openpgp = await Promise.resolve().then(() => _interopRequireWildcard(require("openpgp")));
|
|
1367
|
+
const { readKey } = openpgp;
|
|
1368
|
+
const config = pgpConfig(openpgp);
|
|
1365
1369
|
const key = await readKey({ armoredKey });
|
|
1366
1370
|
const fingerprint = key.getFingerprint().toUpperCase();
|
|
1367
1371
|
const algorithm = algorithmName(key);
|
|
@@ -1382,7 +1386,10 @@ async function parsePgpKey(armoredKey) {
|
|
|
1382
1386
|
cert.signatureType,
|
|
1383
1387
|
{ userID: user.userID, key: key.keyPacket },
|
|
1384
1388
|
void 0,
|
|
1385
|
-
|
|
1389
|
+
// date: now
|
|
1390
|
+
void 0,
|
|
1391
|
+
// detached
|
|
1392
|
+
config
|
|
1386
1393
|
);
|
|
1387
1394
|
} catch (e3) {
|
|
1388
1395
|
continue;
|
|
@@ -1426,15 +1433,28 @@ async function verifyAttestation({
|
|
|
1426
1433
|
if (!pgpPublicKey || !pgpSignature) {
|
|
1427
1434
|
return { verified: false, reason: "Missing PGP data" };
|
|
1428
1435
|
}
|
|
1429
|
-
const
|
|
1436
|
+
const openpgp = await Promise.resolve().then(() => _interopRequireWildcard(require("openpgp")));
|
|
1437
|
+
const { readKey, readCleartextMessage, LiteralDataPacket } = openpgp;
|
|
1438
|
+
const config = pgpConfig(openpgp);
|
|
1430
1439
|
const publicKey = await readKey({ armoredKey: pgpPublicKey });
|
|
1431
1440
|
const keyFingerprint = publicKey.getFingerprint().toUpperCase();
|
|
1432
1441
|
if (keyFingerprint !== fingerprint.toUpperCase()) {
|
|
1433
1442
|
return { verified: false, reason: "Key fingerprint mismatch" };
|
|
1434
1443
|
}
|
|
1435
1444
|
const message = await readCleartextMessage({ cleartextMessage: pgpSignature });
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1445
|
+
const msg = message;
|
|
1446
|
+
const now = /* @__PURE__ */ new Date();
|
|
1447
|
+
let signed = false;
|
|
1448
|
+
for (const sig of msg.signature.packets) {
|
|
1449
|
+
if (!publicKey.getKeys(sig.issuerKeyID).length) continue;
|
|
1450
|
+
const signingKey = await publicKey.getSigningKey(sig.issuerKeyID, now, void 0, config);
|
|
1451
|
+
const literal = new LiteralDataPacket();
|
|
1452
|
+
literal.setText(_nullishCoalesce(msg.text, () => ( message.getText().replace(/\r?\n/g, "\r\n"))));
|
|
1453
|
+
await sig.verify(signingKey.keyPacket, sig.signatureType, literal, now, true, config);
|
|
1454
|
+
signed = true;
|
|
1455
|
+
break;
|
|
1456
|
+
}
|
|
1457
|
+
if (!signed) return { verified: false, reason: "Message is not signed by this key" };
|
|
1438
1458
|
const signedText = message.getText();
|
|
1439
1459
|
if (!signedText.toLowerCase().includes(ethAddress.toLowerCase())) {
|
|
1440
1460
|
return { verified: false, reason: "Signed message does not contain ETH address" };
|