@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/orbitdb-identity-provider-webauthn-did",
3
- "version": "0.2.11",
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
@@ -44,6 +44,7 @@ import {
44
44
  storeWebAuthnVarsigCredential,
45
45
  loadWebAuthnVarsigCredential,
46
46
  clearWebAuthnVarsigCredential,
47
+ isUnsupportedVarsigEnvelopeError,
47
48
  } from './varsig/index.js';
48
49
 
49
50
  export {
@@ -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(signature, publicKey, data);
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 first
384
+ // Try default keystore verification (Uint8Array -> base16 for OrbitDB keystore)
356
385
  try {
357
- const result = await defaultIdentities.verify(signature, publicKey, data);
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 (varsig uses Uint8Array public keys)
396
+ // Try varsig verification (raw bytes; varsig envelope decode)
364
397
  if (publicKey instanceof Uint8Array) {
365
398
  try {
366
399
  return await verifyVarsigForPayload(