@le-space/orbitdb-identity-provider-webauthn-did 0.2.11 → 0.2.13
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/package.json +1 -1
- package/src/index.js +1 -0
- package/src/varsig/identity.js +37 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/orbitdb-identity-provider-webauthn-did",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "WebAuthn-based DID identity provider for OrbitDB for hardware-secured wallets and biometric Passkey authentication",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
package/src/index.js
CHANGED
package/src/varsig/identity.js
CHANGED
|
@@ -17,6 +17,31 @@ const IDENTITY_CODEC = dagCbor;
|
|
|
17
17
|
const IDENTITY_HASHER = sha256;
|
|
18
18
|
const IDENTITY_HASH_ENCODING = base58btc;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* OrbitDB KeyStore verifyMessage expects signature and publicKey as base16 strings.
|
|
22
|
+
* Replicated oplog entries often carry Uint8Arrays; passing those through makes
|
|
23
|
+
* verifySignature() fail silently (see @orbitdb/core keystore). This affects the
|
|
24
|
+
* main database log and nested access-controller manifest DBs alike.
|
|
25
|
+
*
|
|
26
|
+
* @param {Uint8Array|string} value
|
|
27
|
+
* @returns {string|Uint8Array}
|
|
28
|
+
*/
|
|
29
|
+
function toOrbitDbBase16KeyMaterial(value) {
|
|
30
|
+
if (value instanceof Uint8Array) {
|
|
31
|
+
let hex = '';
|
|
32
|
+
for (let i = 0; i < value.length; i++) {
|
|
33
|
+
hex += value[i].toString(16).padStart(2, '0');
|
|
34
|
+
}
|
|
35
|
+
return hex;
|
|
36
|
+
}
|
|
37
|
+
if (ArrayBuffer.isView(value) && !(value instanceof Uint8Array)) {
|
|
38
|
+
return toOrbitDbBase16KeyMaterial(
|
|
39
|
+
new Uint8Array(value.buffer, value.byteOffset, value.byteLength)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
|
|
20
45
|
/**
|
|
21
46
|
* Encode an identity value as CBOR and compute its CID hash.
|
|
22
47
|
* @param {Object} value - Identity payload.
|
|
@@ -115,7 +140,11 @@ async function verifyOplogSignatureHybrid(
|
|
|
115
140
|
if (varsigOk) return true;
|
|
116
141
|
if (fallbackIdentities && typeof fallbackIdentities.verify === 'function') {
|
|
117
142
|
try {
|
|
118
|
-
return await fallbackIdentities.verify(
|
|
143
|
+
return await fallbackIdentities.verify(
|
|
144
|
+
toOrbitDbBase16KeyMaterial(signature),
|
|
145
|
+
toOrbitDbBase16KeyMaterial(publicKey),
|
|
146
|
+
data
|
|
147
|
+
);
|
|
119
148
|
} catch {
|
|
120
149
|
return false;
|
|
121
150
|
}
|
|
@@ -352,15 +381,19 @@ export function wrapWithVarsigVerification(
|
|
|
352
381
|
|
|
353
382
|
// Hybrid verify: tries default keystore verification, then varsig verification
|
|
354
383
|
const hybridVerify = async (signature, publicKey, data) => {
|
|
355
|
-
// Try default keystore verification
|
|
384
|
+
// Try default keystore verification (Uint8Array -> base16 for OrbitDB keystore)
|
|
356
385
|
try {
|
|
357
|
-
const result = await defaultIdentities.verify(
|
|
386
|
+
const result = await defaultIdentities.verify(
|
|
387
|
+
toOrbitDbBase16KeyMaterial(signature),
|
|
388
|
+
toOrbitDbBase16KeyMaterial(publicKey),
|
|
389
|
+
data
|
|
390
|
+
);
|
|
358
391
|
if (result) return true;
|
|
359
392
|
} catch {
|
|
360
393
|
// Default verification failed, try varsig
|
|
361
394
|
}
|
|
362
395
|
|
|
363
|
-
// Try varsig verification (
|
|
396
|
+
// Try varsig verification (raw bytes; varsig envelope decode)
|
|
364
397
|
if (publicKey instanceof Uint8Array) {
|
|
365
398
|
try {
|
|
366
399
|
return await verifyVarsigForPayload(
|