@openentity/sdk 0.1.0 → 0.2.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 (3) hide show
  1. package/dist/index.d.ts +32 -1
  2. package/dist/index.js +1044 -217
  3. package/package.json +2 -1
package/dist/index.d.ts CHANGED
@@ -43,6 +43,8 @@ type VerifyResult = {
43
43
  signer?: string;
44
44
  error?: string;
45
45
  };
46
+ /** eddsa-jcs-2022 hashData: sha256(JCS(proof config)) || sha256(JCS(document)). */
47
+ export declare function hashData(obj: object, config: Omit<Proof, "proofValue">): Uint8Array;
46
48
  export declare function signProof(obj: object, kp: KeyPair, created?: string): Promise<Proof>;
47
49
  export declare function signObject<T extends object>(obj: T, kp: KeyPair, created?: string): Promise<T & {
48
50
  proof: Proof;
@@ -74,7 +76,7 @@ export declare function buildDeclaration(input: {
74
76
  }): object;
75
77
  /** sha256 hex of the canonical entry INCLUDING its proof: the next entry's `prev` (spec 7.4). */
76
78
  export declare function recordEntryHash(entry: object): Promise<string>;
77
- type ObjectType = "EntityDocument" | "Declaration" | "Withdrawal" | "RecordEntry" | "Attestation" | "Revocation" | "ContinuityLink" | "Dispute" | "LogLeaf";
79
+ type ObjectType = "EntityDocument" | "Declaration" | "Withdrawal" | "RecordEntry" | "Attestation" | "Revocation" | "ContinuityLink" | "Dispute" | "Presentation" | "LogLeaf";
78
80
  /** Schema check (spec Appendix A) plus size caps: 16 KB for a RecordEntry (7.4), 64 KB for anything else (5.2). */
79
81
  export declare function validate(type: ObjectType, obj: unknown): {
80
82
  ok: boolean;
@@ -101,4 +103,33 @@ export declare function signNote(body: string, keyName: string, kp: KeyPair): Pr
101
103
  /** C2SP vkey for a note key: `<name>+<key id hex>+<base64(0x01 || pubkey)>`. */
102
104
  export declare function noteVkey(keyName: string, publicKey: Uint8Array): string;
103
105
  export declare function verifyNote(note: string, keyName: string, publicKey: Uint8Array): Promise<boolean>;
106
+ /** Sign a proof of control of `kp`'s EID for one audience and one verifier-issued nonce, optionally carrying attestations. */
107
+ export declare function buildPresentation(kp: KeyPair, opts: {
108
+ audience: string;
109
+ nonce: string;
110
+ attestations?: object[];
111
+ }): Promise<object>;
112
+ type AttestationCheck = {
113
+ claim_type?: string;
114
+ issuer?: string;
115
+ ok: boolean;
116
+ error?: string;
117
+ };
118
+ /**
119
+ * Check a presentation the verifier asked for: schema, signature by the EID itself, audience, nonce, freshness (5 minutes).
120
+ * Each carried attestation is checked for subject, expiry and its issuer's signature; revocation needs the issuer or a
121
+ * registry and is the caller's to check when online. `ok` covers the presentation; attestations are reported one by one.
122
+ */
123
+ export declare function verifyPresentation(p: any, opts: {
124
+ audience: string;
125
+ nonce: string;
126
+ now?: Date;
127
+ maxAgeSeconds?: number;
128
+ resolver?: Resolver;
129
+ }): Promise<{
130
+ ok: boolean;
131
+ eid?: string;
132
+ errors: string[];
133
+ attestations: AttestationCheck[];
134
+ }>;
104
135
  export {};