@did-plc/lib 0.0.2 → 0.0.4

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/dist/client.d.ts CHANGED
@@ -20,26 +20,7 @@ export declare class Client {
20
20
  rotationKeys: string[];
21
21
  signer: Keypair;
22
22
  }): Promise<string>;
23
- ensureLastOp(did: any): Promise<{
24
- type: "create";
25
- service: string;
26
- signingKey: string;
27
- recoveryKey: string;
28
- handle: string;
29
- prev: null;
30
- sig: string;
31
- } | {
32
- type: "plc_operation";
33
- alsoKnownAs: string[];
34
- rotationKeys: string[];
35
- verificationMethods: Record<string, string>;
36
- services: Record<string, {
37
- type: string;
38
- endpoint: string;
39
- }>;
40
- prev: string | null;
41
- sig: string;
42
- }>;
23
+ private ensureLastOp;
43
24
  updateData(did: string, signer: Keypair, fn: (lastOp: t.UnsignedOperation) => Omit<t.UnsignedOperation, 'prev'>): Promise<void>;
44
25
  updateAtprotoKey(did: string, signer: Keypair, atprotoKey: string): Promise<void>;
45
26
  updateHandle(did: string, signer: Keypair, handle: string): Promise<void>;
package/dist/data.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare const assureValidNextOp: (did: string, ops: t.IndexedOperation[],
5
5
  prev: CID | null;
6
6
  }>;
7
7
  export declare const validateOperationLog: (did: string, ops: t.CompatibleOpOrTombstone[]) => Promise<t.DocumentData | null>;
8
+ export declare const opToData: (did: string, op: t.CompatibleOpOrTombstone) => t.DocumentData | null;
8
9
  export declare const getLastOpWithCid: (ops: t.CompatibleOpOrTombstone[]) => Promise<{
9
10
  op: t.CompatibleOpOrTombstone;
10
11
  cid: CID;
package/dist/index.js CHANGED
@@ -24353,6 +24353,7 @@ __export(src_exports2, {
24353
24353
  getLastOpWithCid: () => getLastOpWithCid,
24354
24354
  indexedOperation: () => indexedOperation,
24355
24355
  normalizeOp: () => normalizeOp,
24356
+ opToData: () => opToData,
24356
24357
  signOperation: () => signOperation,
24357
24358
  tombstoneOp: () => tombstoneOp,
24358
24359
  updateAtprotoKeyOp: () => updateAtprotoKeyOp,
@@ -33037,19 +33038,26 @@ var validateOperationLog = async (did, ops) => {
33037
33038
  throw new MisorderedOperationError();
33038
33039
  }
33039
33040
  await assureValidSig(doc.rotationKeys, op);
33040
- if (import_common13.check.is(op, def.tombstone)) {
33041
+ const data = opToData(did, op);
33042
+ if (data === null) {
33041
33043
  if (i === rest.length - 1) {
33042
33044
  return null;
33043
33045
  } else {
33044
33046
  throw new MisorderedOperationError();
33045
33047
  }
33046
33048
  }
33047
- const { verificationMethods, rotationKeys, alsoKnownAs, services } = op;
33048
- doc = { did, verificationMethods, rotationKeys, alsoKnownAs, services };
33049
+ doc = data;
33049
33050
  prev = await (0, import_common13.cidForCbor)(op);
33050
33051
  }
33051
33052
  return doc;
33052
33053
  };
33054
+ var opToData = (did, op) => {
33055
+ if (import_common13.check.is(op, def.tombstone)) {
33056
+ return null;
33057
+ }
33058
+ const { verificationMethods, rotationKeys, alsoKnownAs, services } = normalizeOp(op);
33059
+ return { did, verificationMethods, rotationKeys, alsoKnownAs, services };
33060
+ };
33053
33061
  var getLastOpWithCid = async (ops) => {
33054
33062
  const op = ops.at(-1);
33055
33063
  if (!op) {
@@ -33149,6 +33157,7 @@ var formatKeyAndContext = (key) => {
33149
33157
  getLastOpWithCid,
33150
33158
  indexedOperation,
33151
33159
  normalizeOp,
33160
+ opToData,
33152
33161
  signOperation,
33153
33162
  tombstoneOp,
33154
33163
  updateAtprotoKeyOp,