@le-space/orbitdb-identity-provider-webauthn-did 0.12.0 → 0.12.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/CHANGELOG.md +18 -0
- package/package.json +1 -1
- package/src/varsig/identity.js +35 -1
- package/types/index.d.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 0.12.1
|
|
4
|
+
|
|
5
|
+
A peer loads another peer's varsig identity from IPFS again, with Helia 7.
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **`createIpfsIdentityStorage(ipfs).get` returns the block's bytes.** It returned whatever
|
|
10
|
+
`blockstore.get` gave, and Helia 7's blockstore (interface-blockstore 7) gives a generator of
|
|
11
|
+
chunks. Both callers decoded that as bytes, `getIdentity` in `createWebAuthnVarsigIdentities` and
|
|
12
|
+
the IPFS fallback in `wrapWithVarsigVerification`. The decode threw, their catch swallowed it, and
|
|
13
|
+
a peer that had not cached a varsig identity never loaded it from IPFS. `get` now joins the
|
|
14
|
+
chunks, still takes a blockstore that resolves to bytes, and waits at most 30 seconds for a block
|
|
15
|
+
the node does not have, as OrbitDB's own block storage does. The declaration says
|
|
16
|
+
`Promise<Uint8Array | undefined>` again.
|
|
17
|
+
|
|
18
|
+
Tested with two Helia 7 peers over libp2p and bitswap: the one without the identity loads it from
|
|
19
|
+
the other and verifies it, through either caller.
|
|
20
|
+
|
|
3
21
|
## 0.12.0
|
|
4
22
|
|
|
5
23
|
The vault's keeper, once for every application, and the vault on its own entry.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/orbitdb-identity-provider-webauthn-did",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
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
|
"types": "types/index.d.ts",
|
package/src/varsig/identity.js
CHANGED
|
@@ -356,6 +356,32 @@ export async function verifyVarsigIdentity(identity, domainLabels = {}) {
|
|
|
356
356
|
);
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
+
// How long a lookup waits for an identity block this node does not hold:
|
|
360
|
+
// as long as OrbitDB's own block storage waits for any block.
|
|
361
|
+
const IDENTITY_BLOCK_TIMEOUT = 30000;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* The bytes of a block, from whatever a blockstore's `get` gives. Helia 7's
|
|
365
|
+
* blockstore (interface-blockstore 7) yields them in chunks from a generator,
|
|
366
|
+
* and only iterating it fetches a block the node does not have; earlier ones
|
|
367
|
+
* resolve to the bytes.
|
|
368
|
+
* @param {*} result - What `blockstore.get` returned.
|
|
369
|
+
* @returns {Promise<Uint8Array|undefined>}
|
|
370
|
+
*/
|
|
371
|
+
async function readBlockBytes(result) {
|
|
372
|
+
const value = await result;
|
|
373
|
+
if (value instanceof Uint8Array) return value;
|
|
374
|
+
if (
|
|
375
|
+
typeof value?.[Symbol.asyncIterator] === 'function' ||
|
|
376
|
+
typeof value?.[Symbol.iterator] === 'function'
|
|
377
|
+
) {
|
|
378
|
+
const chunks = [];
|
|
379
|
+
for await (const chunk of value) chunks.push(chunk);
|
|
380
|
+
if (chunks.length > 0) return concat(chunks);
|
|
381
|
+
}
|
|
382
|
+
return undefined;
|
|
383
|
+
}
|
|
384
|
+
|
|
359
385
|
/**
|
|
360
386
|
* Create an IPFS blockstore adapter for identity storage.
|
|
361
387
|
* @param {Object} ipfs - Helia/IPFS instance with a blockstore.
|
|
@@ -364,10 +390,18 @@ export async function verifyVarsigIdentity(identity, domainLabels = {}) {
|
|
|
364
390
|
export function createIpfsIdentityStorage(ipfs) {
|
|
365
391
|
if (!ipfs || !ipfs.blockstore) return null;
|
|
366
392
|
return {
|
|
393
|
+
// Until 0.12.1 this returned what `blockstore.get` gave. With Helia 7
|
|
394
|
+
// that is a generator, which both callers then decoded as bytes: the
|
|
395
|
+
// decode threw, their catch swallowed it, and no varsig identity of
|
|
396
|
+
// another peer was ever loaded from IPFS.
|
|
367
397
|
get: async (hash) => {
|
|
368
398
|
try {
|
|
369
399
|
const cid = CID.parse(hash);
|
|
370
|
-
return await
|
|
400
|
+
return await readBlockBytes(
|
|
401
|
+
ipfs.blockstore.get(cid, {
|
|
402
|
+
signal: AbortSignal.timeout(IDENTITY_BLOCK_TIMEOUT),
|
|
403
|
+
})
|
|
404
|
+
);
|
|
371
405
|
} catch {
|
|
372
406
|
return undefined;
|
|
373
407
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -487,8 +487,11 @@ export function verifyVarsigIdentity(
|
|
|
487
487
|
): Promise<boolean>;
|
|
488
488
|
/** `get` and `put` on the instance's blockstore; `null` without one. */
|
|
489
489
|
export function createIpfsIdentityStorage(ipfs?: unknown): {
|
|
490
|
-
/**
|
|
491
|
-
|
|
490
|
+
/**
|
|
491
|
+
* The block's bytes, from Helia 7's blockstore or an older one; `undefined`
|
|
492
|
+
* when it is not found within 30 seconds.
|
|
493
|
+
*/
|
|
494
|
+
get(hash: string): Promise<Uint8Array | undefined>;
|
|
492
495
|
put(hash: string, bytes: Uint8Array): Promise<void>;
|
|
493
496
|
} | null;
|
|
494
497
|
/** OrbitDB's identities, made to verify varsig entries as well. */
|