@interop/vc 11.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CredentialIssuancePurpose.js","sourceRoot":"","sources":["../src/CredentialIssuancePurpose.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,4BAA4B,CAAA;AAM9C,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAEpC,MAAM,EACJ,QAAQ,EAAE,EAAE,qBAAqB,EAAE,EACpC,GAAG,KAAK,CAAA;AAET;;;;GAIG;AACH,MAAM,OAAO,yBAA0B,SAAQ,qBAAqB;IAClE;;;;;;;OAOG;IACH,YAAY,EACV,UAAU,EACV,IAAI,EACJ,iBAAiB,KAKf,EAAE;QACJ,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAA;IAChD,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,QAAQ,CACZ,KAAa,EACb,EACE,QAAQ,EACR,KAAK,EACL,kBAAkB,EAClB,cAAc,EAMf;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE;gBACzC,QAAQ;gBACR,KAAK;gBACL,kBAAkB;gBAClB,cAAc;aACf,CAAC,CAAA;YAEF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBAClB,MAAM,MAAM,CAAC,KAAK,CAAA;YACpB,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;YAEnD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;YACnD,CAAC;YAED,MAAM,QAAQ,GAAG,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;YAEzE,MAAM,UAAU,GAAG,MAAM,CAAC,UAAyC,CAAA;YACnE,IAAI,UAAU,EAAE,EAAE,KAAK,QAAQ,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAA;YACH,CAAC;YAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAc,EAAE,CAAA;QAChD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare const contexts: Map<string, unknown>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,sBAA6B,CAAA"}
@@ -0,0 +1,15 @@
1
+ /*!
2
+ * Copyright (c) 2019-2023 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ import { contexts as credentialsContexts } from 'credentials-context';
5
+ import { contexts as credentialsV2Contexts } from '@digitalcredentials/credentials-v2-context';
6
+ export const contexts = new Map();
7
+ // adds the _contexts to the contexts map
8
+ function addContexts(_contexts) {
9
+ for (const [url, context] of _contexts.entries()) {
10
+ contexts.set(url, context);
11
+ }
12
+ }
13
+ addContexts(credentialsContexts);
14
+ addContexts(credentialsV2Contexts);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,IAAI,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAAE,QAAQ,IAAI,qBAAqB,EAAE,MAAM,4CAA4C,CAAA;AAE9F,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAA;AAElD,yCAAyC;AACzC,SAAS,WAAW,CAAC,SAA+B;IAClD,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QACjD,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAC5B,CAAC;AACH,CAAC;AAED,WAAW,CAAC,mBAAmB,CAAC,CAAA;AAChC,WAAW,CAAC,qBAAqB,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) 2019-2023 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ import type { RemoteDocument } from '@interop/jsonld-signatures';
5
+ export declare function documentLoader(url: string): Promise<RemoteDocument>;
6
+ //# sourceMappingURL=documentLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentLoader.d.ts","sourceRoot":"","sources":["../src/documentLoader.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAIhE,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAUzE"}
@@ -0,0 +1,14 @@
1
+ // load locally embedded contexts
2
+ import { contexts } from './contexts/index.js';
3
+ export async function documentLoader(url) {
4
+ const context = contexts.get(url);
5
+ if (context !== undefined) {
6
+ return {
7
+ contextUrl: null,
8
+ documentUrl: url,
9
+ document: context
10
+ };
11
+ }
12
+ throw new Error(`Document loader unable to load URL "${url}".`);
13
+ }
14
+ //# sourceMappingURL=documentLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentLoader.js","sourceRoot":"","sources":["../src/documentLoader.ts"],"names":[],"mappings":"AAIA,iCAAiC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACjC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO;YACL,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,GAAG;YAChB,QAAQ,EAAE,OAAO;SAClB,CAAA;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,IAAI,CAAC,CAAA;AACjE,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { IVerifiableCredential } from '@interop/data-integrity-core';
2
+ export declare const CREDENTIALS_CONTEXT_V1_URL: string;
3
+ export declare const CREDENTIALS_CONTEXT_V2_URL: string;
4
+ export declare const dateRegex: RegExp;
5
+ /**
6
+ * Asserts that a context array's first item is a credentials context.
7
+ *
8
+ * @throws {Error} If the first context is not a credentials context.
9
+ */
10
+ export declare function assertCredentialContext({ context }: {
11
+ context: unknown[];
12
+ }): void;
13
+ /**
14
+ * Throws if a Date is not in the correct format.
15
+ *
16
+ * @throws {Error} Throws if the date is not a proper date string.
17
+ */
18
+ export declare function assertDateString({ credential, prop }: {
19
+ credential: Record<string, unknown>;
20
+ prop: string;
21
+ }): void;
22
+ /**
23
+ * Checks if a VC is using a specific context version.
24
+ *
25
+ * @returns True if the first context matches the version.
26
+ */
27
+ export declare function checkContextVersion({ credential, version }: {
28
+ credential?: IVerifiableCredential;
29
+ version: number;
30
+ }): boolean;
31
+ /**
32
+ * Compares two times with consideration of max clock skew.
33
+ *
34
+ * `maxClockSkew` is in seconds. Returns a number greater than, equal to, or
35
+ * less than zero, comparable to a sort comparator.
36
+ */
37
+ export declare function compareTime({ t1, t2, maxClockSkew }: {
38
+ t1: Date | number;
39
+ t2: Date | number;
40
+ maxClockSkew: number;
41
+ }): number;
42
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEzE,eAAO,MAAM,0BAA0B,EAAE,MACgB,CAAA;AACzD,eAAO,MAAM,0BAA0B,EAAE,MACG,CAAA;AAK5C,eAAO,MAAM,SAAS,QAMrB,CAAA;AASD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,OAAO,EACR,EAAE;IACD,OAAO,EAAE,OAAO,EAAE,CAAA;CACnB,GAAG,IAAI,CASP;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,IAAI,EACL,EAAE;IACD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,IAAI,CAKP;AAgBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,OAAO,EACR,EAAE;IACD,UAAU,CAAC,EAAE,qBAAqB,CAAA;IAClC,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,OAAO,CAEV;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAC1B,EAAE,EACF,EAAE,EACF,YAAY,EACb,EAAE;IACD,EAAE,EAAE,IAAI,GAAG,MAAM,CAAA;IACjB,EAAE,EAAE,IAAI,GAAG,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;CACrB,GAAG,MAAM,CAST"}
@@ -0,0 +1,79 @@
1
+ /*!
2
+ * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ import * as credentialsContext from 'credentials-context';
5
+ import * as credentialsContextV2 from '@digitalcredentials/credentials-v2-context';
6
+ export const CREDENTIALS_CONTEXT_V1_URL = credentialsContext.constants.CREDENTIALS_CONTEXT_V1_URL;
7
+ export const CREDENTIALS_CONTEXT_V2_URL = credentialsContextV2.constants.CONTEXT_URL;
8
+ // Z and T must be uppercase
9
+ // xml schema date time RegExp
10
+ // @see https://www.w3.org/TR/xmlschema11-2/#dateTime
11
+ export const dateRegex = new RegExp('-?([1-9][0-9]{3,}|0[0-9]{3})' +
12
+ '-(0[1-9]|1[0-2])' +
13
+ '-(0[1-9]|[12][0-9]|3[01])' +
14
+ 'T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](.[0-9]+)?|(24:00:00(.0+)?))' +
15
+ '(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?');
16
+ // entries should be in ascending version order
17
+ // so v1 is entry 0
18
+ const credentialContextUrls = new Set([
19
+ CREDENTIALS_CONTEXT_V1_URL,
20
+ CREDENTIALS_CONTEXT_V2_URL
21
+ ]);
22
+ /**
23
+ * Asserts that a context array's first item is a credentials context.
24
+ *
25
+ * @throws {Error} If the first context is not a credentials context.
26
+ */
27
+ export function assertCredentialContext({ context }) {
28
+ // ensure first context is credentials context url
29
+ if (credentialContextUrls.has(context[0]) === false) {
30
+ // throw if the first context is not a credentials context
31
+ throw new Error(`"${CREDENTIALS_CONTEXT_V1_URL}" or "${CREDENTIALS_CONTEXT_V2_URL}"` +
32
+ ' needs to be first in the list of contexts.');
33
+ }
34
+ }
35
+ /**
36
+ * Throws if a Date is not in the correct format.
37
+ *
38
+ * @throws {Error} Throws if the date is not a proper date string.
39
+ */
40
+ export function assertDateString({ credential, prop }) {
41
+ const value = credential[prop];
42
+ if (!dateRegex.test(value)) {
43
+ throw new Error(`"${prop}" must be a valid date: ${value}`);
44
+ }
45
+ }
46
+ /**
47
+ * Turns the first context in a VC into a numbered version.
48
+ *
49
+ * @returns A number representing the version.
50
+ */
51
+ function getContextVersion({ credential }) {
52
+ const firstContext = credential?.['@context']?.[0];
53
+ return [...credentialContextUrls].indexOf(firstContext) + 1;
54
+ }
55
+ /**
56
+ * Checks if a VC is using a specific context version.
57
+ *
58
+ * @returns True if the first context matches the version.
59
+ */
60
+ export function checkContextVersion({ credential, version }) {
61
+ return getContextVersion({ credential }) === version;
62
+ }
63
+ /**
64
+ * Compares two times with consideration of max clock skew.
65
+ *
66
+ * `maxClockSkew` is in seconds. Returns a number greater than, equal to, or
67
+ * less than zero, comparable to a sort comparator.
68
+ */
69
+ export function compareTime({ t1, t2, maxClockSkew }) {
70
+ const ms1 = Number(t1);
71
+ const ms2 = Number(t2);
72
+ // `maxClockSkew` is in seconds, so transform to milliseconds
73
+ if (Math.abs(ms1 - ms2) < maxClockSkew * 1000) {
74
+ // times are equal within the max clock skew
75
+ return 0;
76
+ }
77
+ return ms1 < ms2 ? -1 : 1;
78
+ }
79
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,kBAAkB,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,oBAAoB,MAAM,4CAA4C,CAAA;AAIlF,MAAM,CAAC,MAAM,0BAA0B,GACrC,kBAAkB,CAAC,SAAS,CAAC,0BAA0B,CAAA;AACzD,MAAM,CAAC,MAAM,0BAA0B,GACrC,oBAAoB,CAAC,SAAS,CAAC,WAAW,CAAA;AAE5C,4BAA4B;AAC5B,8BAA8B;AAC9B,qDAAqD;AACrD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,MAAM,CACjC,8BAA8B;IAC5B,kBAAkB;IAClB,2BAA2B;IAC3B,wEAAwE;IACxE,gDAAgD,CACnD,CAAA;AAED,+CAA+C;AAC/C,mBAAmB;AACnB,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAS;IAC5C,0BAA0B;IAC1B,0BAA0B;CAC3B,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,OAAO,EAGR;IACC,kDAAkD;IAClD,IAAI,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAW,CAAC,KAAK,K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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3B,CAAC"}
@@ -0,0 +1,279 @@
1
+ import type { DocumentLoader, LinkedDataProof, LinkedDataSignature, ProofPurpose } from '@interop/jsonld-signatures';
2
+ import type { IVerifiableCredential, IVerifiablePresentation } from '@interop/data-integrity-core';
3
+ import { CredentialIssuancePurpose } from './CredentialIssuancePurpose.js';
4
+ export { dateRegex } from './helpers.js';
5
+ export declare const defaultDocumentLoader: DocumentLoader;
6
+ export { CredentialIssuancePurpose };
7
+ /** A verifiable credential. */
8
+ export type VerifiableCredential = IVerifiableCredential;
9
+ /** A verifiable presentation. */
10
+ export type VerifiablePresentation = IVerifiablePresentation;
11
+ /** A verifiable presentation (signed or unsigned). */
12
+ export type Presentation = IVerifiablePresentation;
13
+ /** A single entry in a fine-grained verification result `log`. */
14
+ export interface LogEntry {
15
+ /** Check identifier (for example `valid_signature`). */
16
+ id: string;
17
+ /** Whether the check passed. */
18
+ valid: boolean;
19
+ }
20
+ /** The result of verifying a single credential. */
21
+ export interface VerifyCredentialResult {
22
+ /** True if verified, false if not. */
23
+ verified: boolean;
24
+ /** Credential status check result. */
25
+ statusResult?: any;
26
+ /** Per-proof verification results. */
27
+ results?: any[];
28
+ /** Fine-grained check log. */
29
+ log?: LogEntry[];
30
+ /** The source credential, present when `includeCredentials` is `true`. */
31
+ credential?: VerifiableCredential;
32
+ /** The verified credential's id. */
33
+ credentialId?: string;
34
+ /** Set if verification failed. */
35
+ error?: Error;
36
+ }
37
+ /** The result of verifying a presentation. */
38
+ export interface VerifyPresentationResult {
39
+ /** True if verified, false if not. */
40
+ verified: boolean;
41
+ /** Presentation proof result. */
42
+ presentationResult?: any;
43
+ /** Per-credential verification results. */
44
+ credentialResults?: VerifyCredentialResult[];
45
+ /** Present on the error and unsigned-presentation return paths. */
46
+ results?: any[];
47
+ /** Set if verification failed. */
48
+ error?: Error;
49
+ }
50
+ /** A function for checking credential status. */
51
+ export type CheckStatus = (options: any) => Promise<any>;
52
+ /** Options for {@link issue}. */
53
+ export interface IssueCredentialOptions {
54
+ credential?: VerifiableCredential;
55
+ suite?: LinkedDataSignature;
56
+ purpose?: ProofPurpose;
57
+ documentLoader?: DocumentLoader;
58
+ now?: string | Date;
59
+ maxClockSkew?: number;
60
+ }
61
+ /** Options for {@link derive}. */
62
+ export interface DeriveOptions {
63
+ verifiableCredential?: VerifiableCredential;
64
+ suite?: LinkedDataProof;
65
+ documentLoader?: DocumentLoader;
66
+ }
67
+ /** Options for {@link verifyCredential}. */
68
+ export interface VerifyCredentialOptions {
69
+ credential?: VerifiableCredential;
70
+ suite?: LinkedDataProof | LinkedDataProof[];
71
+ purpose?: ProofPurpose;
72
+ controller?: object;
73
+ documentLoader?: DocumentLoader;
74
+ checkStatus?: CheckStatus;
75
+ now?: string | Date;
76
+ maxClockSkew?: number;
77
+ }
78
+ /** Options for {@link verify}. */
79
+ export interface VerifyPresentationOptions {
80
+ presentation?: VerifiablePresentation;
81
+ suite?: LinkedDataProof | LinkedDataProof[];
82
+ unsignedPresentation?: boolean;
83
+ presentationPurpose?: ProofPurpose;
84
+ challenge?: string;
85
+ controller?: object;
86
+ domain?: string;
87
+ documentLoader?: DocumentLoader;
88
+ checkStatus?: CheckStatus;
89
+ now?: string | Date;
90
+ maxClockSkew?: number;
91
+ includeCredentials?: boolean;
92
+ }
93
+ /** Options for {@link createPresentation}. */
94
+ export interface CreatePresentationOptions {
95
+ verifiableCredential?: VerifiableCredential | VerifiableCredential[];
96
+ id?: string;
97
+ holder?: string;
98
+ now?: string | Date;
99
+ version?: number;
100
+ verify?: boolean;
101
+ maxClockSkew?: number;
102
+ }
103
+ /** Options for {@link signPresentation}. */
104
+ export interface SignPresentationOptions {
105
+ presentation?: Presentation;
106
+ suite?: LinkedDataSignature;
107
+ purpose?: ProofPurpose;
108
+ domain?: string;
109
+ challenge?: string;
110
+ documentLoader?: DocumentLoader;
111
+ }
112
+ /** Options for {@link _checkCredential}. */
113
+ export interface CheckCredentialOptions {
114
+ credential: VerifiableCredential;
115
+ log?: LogEntry[];
116
+ now?: string | Date;
117
+ mode?: string;
118
+ maxClockSkew?: number;
119
+ }
120
+ /**
121
+ * Issues a verifiable credential (by taking a base credential document,
122
+ * and adding a digital signature to it).
123
+ *
124
+ * @param options - The options to use.
125
+ * @param options.credential - Base credential document.
126
+ * @param options.suite - Signature suite (with private key material or an API
127
+ * to use it), passed in to `sign()`.
128
+ * @param options.purpose - A ProofPurpose. If not specified, a default purpose
129
+ * will be created.
130
+ * @param options.documentLoader - A document loader.
131
+ * @param options.now - A string representing date time in ISO 8601 format or an
132
+ * instance of Date. Defaults to current date time.
133
+ * @param options.maxClockSkew - A maximum number of seconds that clocks may be
134
+ * skewed when checking date-times against `now`.
135
+ *
136
+ * @throws {Error} If missing required properties.
137
+ *
138
+ * @returns Resolves on completion.
139
+ */
140
+ export declare function issue({ credential, suite, purpose, documentLoader, now, maxClockSkew }?: IssueCredentialOptions): Promise<VerifiableCredential>;
141
+ /**
142
+ * Derives a proof from the given verifiable credential, resulting in a new
143
+ * verifiable credential. This method is usually used to generate selective
144
+ * disclosure and / or unlinkable proofs.
145
+ *
146
+ * @param options - The options to use.
147
+ * @param options.verifiableCredential - The verifiable credential containing a
148
+ * base proof to derive another proof from.
149
+ * @param options.suite - Derived proof signature suite.
150
+ * @param options.documentLoader - A document loader.
151
+ *
152
+ * @throws {Error} If missing required properties.
153
+ *
154
+ * @returns Resolves on completion.
155
+ */
156
+ export declare function derive({ verifiableCredential, suite, documentLoader }?: DeriveOptions): Promise<VerifiableCredential>;
157
+ /**
158
+ * Verifies a verifiable presentation:
159
+ * - Checks that the presentation is well-formed
160
+ * - Checks the proofs (for example, checks digital signatures against the
161
+ * provided public keys).
162
+ *
163
+ * @param options - The options to use.
164
+ * @param options.presentation - Verifiable presentation, signed or unsigned,
165
+ * that may contain within it a verifiable credential.
166
+ * @param options.suite - One or more signature suites that are supported by the
167
+ * caller's use case. This is an explicit design decision -- the calling code
168
+ * must specify which signature types (ed25519, RSA, etc) are allowed.
169
+ * Although it is expected that the secure resolution/fetching of the public
170
+ * key material (to verify against) is to be handled by the documentLoader,
171
+ * the suite param can optionally include the key directly.
172
+ * @param options.unsignedPresentation - By default, this function assumes that
173
+ * a presentation is signed (and will return an error if a `proof` section is
174
+ * missing). Set this to `true` if you're using an unsigned presentation.
175
+ * @param options.presentationPurpose - Optional proof purpose (a default one
176
+ * will be created if not passed in).
177
+ * @param options.challenge - Required if purpose is not passed in.
178
+ * @param options.controller - A controller.
179
+ * @param options.domain - A domain.
180
+ * @param options.documentLoader - A document loader.
181
+ * @param options.checkStatus - Optional function for checking credential status
182
+ * if `credentialStatus` is present on the credential.
183
+ * @param options.now - A string representing date time in ISO 8601 format or an
184
+ * instance of Date. Defaults to current date time.
185
+ * @param options.maxClockSkew - A maximum number of seconds that clocks may be
186
+ * skewed when checking date-times against `now`.
187
+ * @param options.includeCredentials - Set to `true` to include each verified
188
+ * `credential` in its entry in `credentialResults`. Defaults to `true` to
189
+ * preserve backwards compatibility; set to `false` to omit them.
190
+ *
191
+ * @returns The verification result.
192
+ */
193
+ export declare function verify(options?: VerifyPresentationOptions): Promise<VerifyPresentationResult>;
194
+ /**
195
+ * Verifies a verifiable credential:
196
+ * - Checks that the credential is well-formed
197
+ * - Checks the proofs (for example, checks digital signatures against the
198
+ * provided public keys).
199
+ *
200
+ * @param options - The options.
201
+ * @param options.credential - Verifiable credential.
202
+ * @param options.suite - One or more signature suites that are supported by the
203
+ * caller's use case. This is an explicit design decision -- the calling code
204
+ * must specify which signature types (ed25519, RSA, etc) are allowed.
205
+ * Although it is expected that the secure resolution/fetching of the public
206
+ * key material (to verify against) is to be handled by the documentLoader,
207
+ * the suite param can optionally include the key directly.
208
+ * @param options.purpose - Optional proof purpose (a default one will be
209
+ * created if not passed in).
210
+ * @param options.documentLoader - A document loader.
211
+ * @param options.checkStatus - Optional function for checking credential status
212
+ * if `credentialStatus` is present on the credential.
213
+ * @param options.now - A string representing date time in ISO 8601 format or an
214
+ * instance of Date. Defaults to current date time.
215
+ * @param options.maxClockSkew - A maximum number of seconds that clocks may be
216
+ * skewed when checking date-times against `now`.
217
+ *
218
+ * @returns The verification result.
219
+ */
220
+ export declare function verifyCredential(options?: VerifyCredentialOptions): Promise<VerifyCredentialResult>;
221
+ /**
222
+ * Creates an unsigned presentation from a given verifiable credential.
223
+ *
224
+ * @param options - Options to use.
225
+ * @param options.verifiableCredential - One or more verifiable credential.
226
+ * @param options.id - Optional VP id.
227
+ * @param options.holder - Optional presentation holder url.
228
+ * @param options.now - A string representing date time in ISO 8601 format or an
229
+ * instance of Date. Defaults to current date time.
230
+ * @param options.version - The VC context version to use.
231
+ * @param options.verify - If set to true, throw verification errors for
232
+ * individual VCs (such as when the VC is expired, etc).
233
+ * @param options.maxClockSkew - A maximum number of seconds that clocks may be
234
+ * skewed when checking date-times against `now`.
235
+ *
236
+ * @throws {TypeError} If verifiableCredential param is missing.
237
+ * @throws {Error} If the credential (or the presentation params) are missing
238
+ * required properties.
239
+ *
240
+ * @returns The credential wrapped inside of a VerifiablePresentation.
241
+ */
242
+ export declare function createPresentation({ verifiableCredential, id, holder, now, version, verify, maxClockSkew }?: CreatePresentationOptions): Presentation;
243
+ /**
244
+ * Signs a given presentation.
245
+ *
246
+ * @param options - Options to use.
247
+ * @param options.presentation - A presentation.
248
+ * @param options.suite - Passed in to `sign()`.
249
+ * @param options.purpose - A ProofPurpose. If not specified, a default purpose
250
+ * will be created with the domain and challenge options.
251
+ * @param options.domain - A domain.
252
+ * @param options.challenge - A required challenge.
253
+ * @param options.documentLoader - A document loader.
254
+ *
255
+ * @returns A VerifiablePresentation with a proof.
256
+ */
257
+ export declare function signPresentation(options?: SignPresentationOptions): Promise<VerifiablePresentation>;
258
+ /**
259
+ * @param presentation - An object that could be a presentation.
260
+ *
261
+ * @throws {Error}
262
+ */
263
+ export declare function _checkPresentation(presentation: Presentation): void;
264
+ /**
265
+ * @param options - The options.
266
+ * @param options.credential - An object that could be a VerifiableCredential.
267
+ * @param options.log - Optional events log, for fine-grained verification
268
+ * result reporting.
269
+ * @param options.now - A string representing date time in ISO 8601 format or an
270
+ * instance of Date. Defaults to current date time.
271
+ * @param options.mode - The mode of operation for this validation function,
272
+ * either `issue` or `verify`.
273
+ * @param options.maxClockSkew - A maximum number of seconds that clocks may be
274
+ * skewed when checking date-times against `now`.
275
+ *
276
+ * @throws {Error}
277
+ */
278
+ export declare function _checkCredential({ credential, log, now, mode, maxClockSkew }: CheckCredentialOptions): void;
279
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAEV,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,YAAY,EACb,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAEV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,8BAA8B,CAAA;AAUrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAI1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,eAAO,MAAM,qBAAqB,EAAE,cACQ,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,CAAA;AAEpC,+BAA+B;AAC/B,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAA;AAExD,iCAAiC;AACjC,MAAM,MAAM,sBAAsB,GAAG,uBAAuB,CAAA;AAE5D,sDAAsD;AACtD,MAAM,MAAM,YAAY,GAAG,uBAAuB,CAAA;AAKlD,kEAAkE;AAClE,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,EAAE,EAAE,MAAM,CAAA;IACV,gCAAgC;IAChC,KAAK,EAAE,OAAO,CAAA;CACf;AAED,mDAAmD;AACnD,MAAM,WAAW,sBAAsB;IACrC,sCAAsC;IACtC,QAAQ,EAAE,OAAO,CAAA;IACjB,sCAAsC;IACtC,YAAY,CAAC,EAA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