@metalabel/dfos-client 0.44.0 → 0.46.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.
Files changed (2) hide show
  1. package/dist/index.js +17 -55
  2. package/package.json +7 -6
package/dist/index.js CHANGED
@@ -244,59 +244,21 @@ var opMeta = (jws) => {
244
244
  const createdAt = typeof decoded?.payload?.["createdAt"] === "string" ? (decoded?.payload)["createdAt"] : "";
245
245
  return { cid, createdAt };
246
246
  };
247
- var allCurrentKeys = (state) => [
248
- ...state.authKeys,
249
- ...state.assertKeys,
250
- ...state.controllerKeys
251
- ];
252
- var mergeHistoricalIdentity = (state, log) => {
253
- const maps = {
254
- authKeys: new Map(state.authKeys.map((k) => [k.id, k])),
255
- assertKeys: new Map(state.assertKeys.map((k) => [k.id, k])),
256
- controllerKeys: new Map(state.controllerKeys.map((k) => [k.id, k]))
257
- };
258
- for (const jws of log) {
259
- const decoded = decodeJwsUnsafe(jws);
260
- if (!decoded) continue;
261
- const payload = decoded.payload;
262
- if (payload["type"] !== "create" && payload["type"] !== "update") continue;
263
- for (const field of ["authKeys", "assertKeys", "controllerKeys"]) {
264
- const keys = payload[field];
265
- if (!Array.isArray(keys)) continue;
266
- for (const k of keys) {
267
- if (k && typeof k === "object" && "id" in k && "publicKeyMultibase" in k) {
268
- const id = k.id;
269
- if (!maps[field].has(id)) maps[field].set(id, k);
270
- }
271
- }
272
- }
273
- }
274
- return {
275
- ...state,
276
- authKeys: [...maps.authKeys.values()],
277
- assertKeys: [...maps.assertKeys.values()],
278
- controllerKeys: [...maps.controllerKeys.values()]
279
- };
247
+ var provedKeys = (state) => {
248
+ const proved = state.provedKeys ?? state;
249
+ return [...proved.authKeys, ...proved.assertKeys, ...proved.controllerKeys];
280
250
  };
281
- var keyBytesFor = (state, log, keyId) => {
282
- const current = allCurrentKeys(state).find((k) => k.id === keyId);
283
- if (current) return decodeMultikey(current.publicKeyMultibase).keyBytes;
284
- for (const jws of log) {
285
- const decoded = decodeJwsUnsafe(jws);
286
- if (!decoded) continue;
287
- const payload = decoded.payload;
288
- if (payload["type"] !== "create" && payload["type"] !== "update") continue;
289
- for (const field of ["authKeys", "assertKeys", "controllerKeys"]) {
290
- const keys = payload[field];
291
- if (!Array.isArray(keys)) continue;
292
- for (const k of keys) {
293
- if (k && typeof k === "object" && "id" in k && k.id === keyId && "publicKeyMultibase" in k) {
294
- return decodeMultikey(k.publicKeyMultibase).keyBytes;
295
- }
296
- }
297
- }
251
+ var historicalIdentity = (state) => ({
252
+ ...state,
253
+ ...state.provedKeys ?? {
254
+ authKeys: state.authKeys,
255
+ assertKeys: state.assertKeys,
256
+ controllerKeys: state.controllerKeys
298
257
  }
299
- return null;
258
+ });
259
+ var keyBytesFor = (state, keyId) => {
260
+ const key = provedKeys(state).find((k) => k.id === keyId);
261
+ return key ? decodeMultikey(key.publicKeyMultibase).keyBytes : null;
300
262
  };
301
263
  var createResolvers = (deps) => {
302
264
  const relaysFor = (o) => normalizeRelays(o?.relays ?? deps.relays);
@@ -374,8 +336,8 @@ var createResolvers = (deps) => {
374
336
  };
375
337
  const resolveIdentity = async (did) => {
376
338
  try {
377
- const { state, log } = await getIdentityChain(did);
378
- return mergeHistoricalIdentity(state, log);
339
+ const { state } = await getIdentityChain(did);
340
+ return historicalIdentity(state);
379
341
  } catch {
380
342
  return void 0;
381
343
  }
@@ -385,8 +347,8 @@ var createResolvers = (deps) => {
385
347
  if (hashIdx < 0) throw new Error(`kid must be a DID URL: ${kid}`);
386
348
  const did = kid.substring(0, hashIdx);
387
349
  const keyId = kid.substring(hashIdx + 1);
388
- const { state, log } = await getIdentityChain(did);
389
- const bytes = keyBytesFor(state, log, keyId);
350
+ const { state } = await getIdentityChain(did);
351
+ const bytes = keyBytesFor(state, keyId);
390
352
  if (!bytes) throw new Error(`unknown key ${keyId} on identity ${did}`);
391
353
  return bytes;
392
354
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metalabel/dfos-client",
3
- "version": "0.44.0",
3
+ "version": "0.46.0",
4
4
  "type": "module",
5
5
  "description": "DFOS Client — the client-side kit for participating in the protocol: resolve, verify, prove. Fetch, resolve, verify-orchestration and cache over untrusted relays, plus the SIWD and API-AUTH proof surfaces. Holds no keys; all crypto truth comes from @metalabel/dfos-protocol",
6
6
  "license": "MIT",
@@ -47,20 +47,21 @@
47
47
  "README.md"
48
48
  ],
49
49
  "peerDependencies": {
50
- "@metalabel/dfos-protocol": "^0.44.0",
51
- "@metalabel/dfos-web-relay": "^0.44.0"
50
+ "@metalabel/dfos-protocol": "^0.46.0",
51
+ "@metalabel/dfos-web-relay": "^0.46.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^24.10.4",
55
55
  "tsup": "^8.5.1",
56
+ "typescript": "^5.9.3",
56
57
  "vitest": "^4.1.8",
57
- "@metalabel/dfos-protocol": "0.44.0",
58
- "@metalabel/dfos-web-relay": "0.44.0"
58
+ "@metalabel/dfos-web-relay": "0.46.0",
59
+ "@metalabel/dfos-protocol": "0.46.0"
59
60
  },
60
61
  "scripts": {
61
62
  "build": "tsup",
62
63
  "clean": "rm -rf dist",
63
- "typecheck": "tsc --noEmit",
64
+ "typecheck": "node ../../node_modules/typescript7/bin/tsc --noEmit",
64
65
  "test": "vitest run"
65
66
  }
66
67
  }