@le-space/orbitdb-identity-provider-webauthn-did 0.2.12 → 0.3.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/README.md +2 -2
- package/package.json +21 -11
- package/src/keystore/provider.js +8 -9
- package/src/varsig/identity.js +37 -4
- package/src/webauthn/provider.js +2 -5
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ Note: WebAuthn varsig support in this repo relies on our forked `@le-space/iso-*
|
|
|
39
39
|
npm install @le-space/orbitdb-identity-provider-webauthn-did
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
Note:
|
|
42
|
+
Note: Ed25519 keystore DIDs are handled without patching OrbitDB. The provider generates the requested libp2p key type and stores it through OrbitDB's public keystore API.
|
|
43
43
|
|
|
44
44
|
## WebAuthn Configuration
|
|
45
45
|
|
|
@@ -186,7 +186,7 @@ sequenceDiagram
|
|
|
186
186
|
Auth-->>WebAuthn: Attestation
|
|
187
187
|
WebAuthn-->>App: Credential
|
|
188
188
|
|
|
189
|
-
App->>KS: getKey()
|
|
189
|
+
App->>KS: getKey() or add generated Ed25519 key
|
|
190
190
|
KS-->>App: Keystore keypair
|
|
191
191
|
|
|
192
192
|
opt encryptKeystore=true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/orbitdb-identity-provider-webauthn-did",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"./standalone": "./src/standalone/index.js"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"postinstall": "patch-package",
|
|
14
13
|
"test": "npm run test:all",
|
|
15
14
|
"test:all": "playwright test",
|
|
16
15
|
"test:headed": "playwright test tests/webauthn-focused.test.js --headed --project=chromium",
|
|
@@ -59,14 +58,14 @@
|
|
|
59
58
|
},
|
|
60
59
|
"homepage": "https://github.com/le-space/orbitdb-identity-provider-webauthn-did#readme",
|
|
61
60
|
"peerDependencies": {
|
|
62
|
-
"@orbitdb/core": "^
|
|
61
|
+
"@orbitdb/core": "^4.0.0"
|
|
63
62
|
},
|
|
64
63
|
"dependencies": {
|
|
65
64
|
"@ipld/dag-ucan": "^3.4.3",
|
|
66
|
-
"@ipld/dag-cbor": "^
|
|
65
|
+
"@ipld/dag-cbor": "^10.0.1",
|
|
67
66
|
"@le-space/ucanto-principal": "^9.1.2",
|
|
68
|
-
"@libp2p/logger": "^
|
|
69
|
-
"@libp2p/crypto": "^5.1.
|
|
67
|
+
"@libp2p/logger": "^6.2.9",
|
|
68
|
+
"@libp2p/crypto": "^5.1.20",
|
|
70
69
|
"@simplewebauthn/browser": "^13.0.0",
|
|
71
70
|
"cbor-web": "^9.0.1",
|
|
72
71
|
"iso-base": "npm:@le-space/iso-base",
|
|
@@ -74,17 +73,28 @@
|
|
|
74
73
|
"iso-passkeys": "npm:@le-space/iso-passkeys",
|
|
75
74
|
"iso-web": "^2.1.0",
|
|
76
75
|
"iso-webauthn-varsig": "npm:@le-space/iso-webauthn-varsig",
|
|
77
|
-
"multiformats": "^
|
|
78
|
-
"patch-package": "^8.0.1",
|
|
76
|
+
"multiformats": "^14.0.0",
|
|
79
77
|
"vite-plugin-node-polyfills": "^0.24.0"
|
|
80
78
|
},
|
|
81
79
|
"devDependencies": {
|
|
82
|
-
"@
|
|
80
|
+
"@chainsafe/libp2p-noise": "^17.0.0",
|
|
81
|
+
"@chainsafe/libp2p-yamux": "^8.0.1",
|
|
82
|
+
"@helia/bitswap": "^4.0.1",
|
|
83
|
+
"@helia/http": "^4.0.1",
|
|
84
|
+
"@helia/libp2p": "^1.0.1",
|
|
85
|
+
"@ipld/dag-json": "^11.0.0",
|
|
86
|
+
"@libp2p/gossipsub": "^16.0.3",
|
|
87
|
+
"@libp2p/identify": "^4.1.8",
|
|
88
|
+
"@libp2p/websockets": "^10.1.15",
|
|
89
|
+
"@orbitdb/core": "^4.0.0",
|
|
90
|
+
"@orbitdb/simple-encryption": "^0.0.2",
|
|
83
91
|
"@playwright/test": "^1.55.0",
|
|
92
|
+
"blockstore-level": "^4.0.1",
|
|
84
93
|
"chai": "^5.0.0",
|
|
94
|
+
"datastore-level": "^13.0.1",
|
|
85
95
|
"eslint": "^9.0.0",
|
|
86
|
-
"helia": "^
|
|
87
|
-
"libp2p": "^
|
|
96
|
+
"helia": "^7.0.1",
|
|
97
|
+
"libp2p": "^3.3.4",
|
|
88
98
|
"mocha": "^10.0.0"
|
|
89
99
|
},
|
|
90
100
|
"engines": {
|
package/src/keystore/provider.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { logger } from '@libp2p/logger';
|
|
6
6
|
import { generateKeyPair } from '@libp2p/crypto/keys';
|
|
7
|
+
import { varint } from 'multiformats';
|
|
8
|
+
import { base58btc } from 'multiformats/bases/base58';
|
|
7
9
|
import * as KeystoreEncryption from './encryption.js';
|
|
8
10
|
import { WebAuthnDIDProvider } from '../webauthn/provider.js';
|
|
9
11
|
|
|
@@ -119,11 +121,6 @@ export class OrbitDBWebAuthnIdentityProvider {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
try {
|
|
122
|
-
// Import multiformats modules
|
|
123
|
-
const multiformats = await import('multiformats');
|
|
124
|
-
const varint = multiformats.varint;
|
|
125
|
-
const { base58btc } = await import('multiformats/bases/base58');
|
|
126
|
-
|
|
127
124
|
if (this.encryptKeystore) {
|
|
128
125
|
const encryptedData = this.unlockedKeypair
|
|
129
126
|
? {
|
|
@@ -157,10 +154,12 @@ export class OrbitDBWebAuthnIdentityProvider {
|
|
|
157
154
|
identityId.substring(0, 32) + '...',
|
|
158
155
|
this.keystoreKeyType
|
|
159
156
|
);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
157
|
+
const keyType =
|
|
158
|
+
this.keystoreKeyType === 'secp256k1' ? 'secp256k1' : 'Ed25519';
|
|
159
|
+
keystoreKey = await generateKeyPair(keyType);
|
|
160
|
+
await this.keystore.addKey(identityId, {
|
|
161
|
+
privateKey: keystoreKey.raw,
|
|
162
|
+
});
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
identityLog(
|
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(
|
package/src/webauthn/provider.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { logger } from '@libp2p/logger';
|
|
9
|
+
import { varint } from 'multiformats';
|
|
10
|
+
import { base58btc } from 'multiformats/bases/base58';
|
|
9
11
|
import * as KeystoreEncryption from '../keystore/encryption.js';
|
|
10
12
|
import {
|
|
11
13
|
buildAuthenticatorSelection,
|
|
@@ -341,11 +343,6 @@ export class WebAuthnDIDProvider {
|
|
|
341
343
|
*/
|
|
342
344
|
static async createDID(credentialInfo) {
|
|
343
345
|
try {
|
|
344
|
-
// Import multiformats modules with correct exports
|
|
345
|
-
const multiformats = await import('multiformats');
|
|
346
|
-
const varint = multiformats.varint;
|
|
347
|
-
const { base58btc } = await import('multiformats/bases/base58');
|
|
348
|
-
|
|
349
346
|
// Extract public key coordinates
|
|
350
347
|
const { x, y } = credentialInfo.publicKey;
|
|
351
348
|
|