@sphereon/ssi-types 0.11.1-unstable.151 → 0.11.1-unstable.152

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 (41) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +20 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/mapper/credential-mapper.d.ts +45 -0
  6. package/dist/mapper/credential-mapper.d.ts.map +1 -0
  7. package/dist/mapper/credential-mapper.js +386 -0
  8. package/dist/mapper/credential-mapper.js.map +1 -0
  9. package/dist/mapper/index.d.ts +2 -0
  10. package/dist/mapper/index.d.ts.map +1 -0
  11. package/dist/mapper/index.js +18 -0
  12. package/dist/mapper/index.js.map +1 -0
  13. package/dist/types/did.d.ts +36 -0
  14. package/dist/types/did.d.ts.map +1 -0
  15. package/dist/types/did.js +76 -0
  16. package/dist/types/did.js.map +1 -0
  17. package/dist/types/generic.d.ts +7 -0
  18. package/dist/types/generic.d.ts.map +1 -0
  19. package/dist/types/generic.js +3 -0
  20. package/dist/types/generic.js.map +1 -0
  21. package/dist/types/index.d.ts +5 -0
  22. package/dist/types/index.d.ts.map +1 -0
  23. package/dist/types/index.js +21 -0
  24. package/dist/types/index.js.map +1 -0
  25. package/dist/types/pex.d.ts +36 -0
  26. package/dist/types/pex.d.ts.map +1 -0
  27. package/dist/types/pex.js +3 -0
  28. package/dist/types/pex.js.map +1 -0
  29. package/dist/types/vc.d.ts +245 -0
  30. package/dist/types/vc.d.ts.map +1 -0
  31. package/dist/types/vc.js +17 -0
  32. package/dist/types/vc.js.map +1 -0
  33. package/dist/utils/index.d.ts +2 -0
  34. package/dist/utils/index.d.ts.map +1 -0
  35. package/dist/utils/index.js +18 -0
  36. package/dist/utils/index.js.map +1 -0
  37. package/dist/utils/object.d.ts +7 -0
  38. package/dist/utils/object.d.ts.map +1 -0
  39. package/dist/utils/object.js +21 -0
  40. package/dist/utils/object.js.map +1 -0
  41. package/package.json +2 -2
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './utils';
3
+ export * from './mapper';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./utils"), exports);
19
+ __exportStar(require("./mapper"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,0CAAuB;AACvB,2CAAwB"}
@@ -0,0 +1,45 @@
1
+ import { DocumentFormat, IPresentation, IVerifiableCredential, IVerifiablePresentation, JwtDecodedVerifiableCredential, JwtDecodedVerifiablePresentation, OriginalVerifiableCredential, OriginalVerifiablePresentation, W3CVerifiableCredential, W3CVerifiablePresentation, WrappedVerifiableCredential, WrappedVerifiablePresentation } from '../types';
2
+ export declare class CredentialMapper {
3
+ static decodeVerifiablePresentation(presentation: OriginalVerifiablePresentation): JwtDecodedVerifiablePresentation | IVerifiablePresentation;
4
+ static decodeVerifiableCredential(credential: OriginalVerifiableCredential): JwtDecodedVerifiableCredential | IVerifiableCredential;
5
+ static toWrappedVerifiablePresentation(originalPresentation: OriginalVerifiablePresentation, opts?: {
6
+ maxTimeSkewInMS?: number;
7
+ }): WrappedVerifiablePresentation;
8
+ static toWrappedVerifiableCredentials(verifiableCredentials: OriginalVerifiableCredential[], opts?: {
9
+ maxTimeSkewInMS?: number;
10
+ }): WrappedVerifiableCredential[];
11
+ static toWrappedVerifiableCredential(verifiableCredential: OriginalVerifiableCredential, opts?: {
12
+ maxTimeSkewInMS?: number;
13
+ }): WrappedVerifiableCredential;
14
+ static isJwtEncoded(original: OriginalVerifiableCredential | OriginalVerifiablePresentation): boolean;
15
+ private static isJsonLdAsString;
16
+ static isJwtDecodedCredential(original: OriginalVerifiableCredential): boolean;
17
+ static isJwtDecodedPresentation(original: OriginalVerifiablePresentation): boolean;
18
+ static jwtEncodedPresentationToUniformPresentation(jwt: string, makeCredentialsUniform?: boolean, opts?: {
19
+ maxTimeSkewInMS?: number;
20
+ }): IPresentation;
21
+ static jwtDecodedPresentationToUniformPresentation(decoded: JwtDecodedVerifiablePresentation, makeCredentialsUniform?: boolean, opts?: {
22
+ maxTimeSkewInMS?: number;
23
+ }): IVerifiablePresentation;
24
+ static toUniformCredential(verifiableCredential: OriginalVerifiableCredential, opts?: {
25
+ maxTimeSkewInMS?: number;
26
+ }): IVerifiableCredential;
27
+ static toUniformPresentation(presentation: OriginalVerifiablePresentation, opts?: {
28
+ maxTimeSkewInMS?: number;
29
+ addContextIfMissing?: boolean;
30
+ }): IVerifiablePresentation;
31
+ static jwtEncodedCredentialToUniformCredential(jwt: string, opts?: {
32
+ maxTimeSkewInMS?: number;
33
+ }): IVerifiableCredential;
34
+ static jwtDecodedCredentialToUniformCredential(decoded: JwtDecodedVerifiableCredential, opts?: {
35
+ maxTimeSkewInMS?: number;
36
+ }): IVerifiableCredential;
37
+ static toExternalVerifiableCredential(verifiableCredential: any): IVerifiableCredential;
38
+ static storedCredentialToOriginalFormat(credential: W3CVerifiableCredential): W3CVerifiableCredential;
39
+ static storedPresentationToOriginalFormat(presentation: W3CVerifiablePresentation): W3CVerifiablePresentation;
40
+ static toCompactJWT(jwtDocument: W3CVerifiableCredential | JwtDecodedVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiablePresentation | string): string;
41
+ static detectDocumentType(document: W3CVerifiableCredential | W3CVerifiablePresentation | JwtDecodedVerifiableCredential | JwtDecodedVerifiablePresentation): DocumentFormat;
42
+ private static hasJWTProofType;
43
+ private static getFirstProof;
44
+ }
45
+ //# sourceMappingURL=credential-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-mapper.d.ts","sourceRoot":"","sources":["../../src/mapper/credential-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,aAAa,EAIb,qBAAqB,EACrB,uBAAuB,EACvB,8BAA8B,EAC9B,gCAAgC,EAEhC,4BAA4B,EAC5B,8BAA8B,EAG9B,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,UAAU,CAAA;AAIjB,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,4BAA4B,CAAC,YAAY,EAAE,8BAA8B,GAAG,gCAAgC,GAAG,uBAAuB;IAsB7I,MAAM,CAAC,0BAA0B,CAAC,UAAU,EAAE,4BAA4B,GAAG,8BAA8B,GAAG,qBAAqB;IAqBnI,MAAM,CAAC,+BAA+B,CACpC,oBAAoB,EAAE,8BAA8B,EACpD,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,GAClC,6BAA6B;IA4ChC,MAAM,CAAC,8BAA8B,CACnC,qBAAqB,EAAE,4BAA4B,EAAE,EACrD,IAAI,CAAC,EAAE;QAAE,eAA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AAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,GAClC,qBAAqB;IA2ExB,MAAM,CAAC,8BAA8B,CAAC,oBAAoB,EAAE,GAAG,GAAG,qBAAqB;IAsCvF,MAAM,CAAC,gCAAgC,CAAC,UAAU,EAAE,uBAAuB,GAAG,uBAAuB;IAYrG,MAAM,CAAC,kCAAkC,CAAC,YAAY,EAAE,yBAAyB,GAAG,yBAAyB;IAY7G,MAAM,CAAC,YAAY,CACjB,WAAW,EAAE,uBAAuB,GAAG,8BAA8B,GAAG,yBAAyB,GAAG,gCAAgC,GAAG,MAAM,GAC5I,MAAM;IAqBT,MAAM,CAAC,kBAAkB,CACvB,QAAQ,EAAE,uBAAuB,GAAG,yBAAyB,GAAG,8BAA8B,GAAG,gCAAgC,GAChI,cAAc;IAejB,OAAO,CAAC,MAAM,CAAC,eAAe;IAS9B,OAAO,CAAC,MAAM,CAAC,aAAa;CAS7B"}
@@ -0,0 +1,386 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.CredentialMapper = void 0;
18
+ const types_1 = require("../types");
19
+ const jwt_decode_1 = __importDefault(require("jwt-decode"));
20
+ const utils_1 = require("../utils");
21
+ class CredentialMapper {
22
+ static decodeVerifiablePresentation(presentation) {
23
+ var _a;
24
+ if (CredentialMapper.isJwtEncoded(presentation)) {
25
+ const payload = (0, jwt_decode_1.default)(presentation);
26
+ const header = (0, jwt_decode_1.default)(presentation, { header: true });
27
+ payload.vp.proof = {
28
+ type: types_1.IProofType.JwtProof2020,
29
+ created: payload.nbf,
30
+ proofPurpose: types_1.IProofPurpose.authentication,
31
+ verificationMethod: (_a = header['kid']) !== null && _a !== void 0 ? _a : payload.iss,
32
+ jwt: presentation,
33
+ };
34
+ return payload;
35
+ }
36
+ else if (CredentialMapper.isJwtDecodedPresentation(presentation)) {
37
+ return presentation;
38
+ }
39
+ else if (CredentialMapper.isJsonLdAsString(presentation)) {
40
+ return JSON.parse(presentation);
41
+ }
42
+ else {
43
+ return presentation;
44
+ }
45
+ }
46
+ static decodeVerifiableCredential(credential) {
47
+ var _a;
48
+ if (CredentialMapper.isJwtEncoded(credential)) {
49
+ const payload = (0, jwt_decode_1.default)(credential);
50
+ const header = (0, jwt_decode_1.default)(credential, { header: true });
51
+ payload.vc.proof = {
52
+ type: types_1.IProofType.JwtProof2020,
53
+ created: payload.nbf,
54
+ proofPurpose: types_1.IProofPurpose.authentication,
55
+ verificationMethod: (_a = header['kid']) !== null && _a !== void 0 ? _a : payload.iss,
56
+ jwt: credential,
57
+ };
58
+ return payload;
59
+ }
60
+ else if (CredentialMapper.isJwtDecodedCredential(credential)) {
61
+ return credential;
62
+ }
63
+ else if (CredentialMapper.isJsonLdAsString(credential)) {
64
+ return JSON.parse(credential);
65
+ }
66
+ else {
67
+ return credential;
68
+ }
69
+ }
70
+ static toWrappedVerifiablePresentation(originalPresentation, opts) {
71
+ const proof = CredentialMapper.getFirstProof(originalPresentation);
72
+ const original = typeof originalPresentation !== 'string' && CredentialMapper.hasJWTProofType(originalPresentation) ? proof === null || proof === void 0 ? void 0 : proof.jwt : originalPresentation;
73
+ if (!original) {
74
+ throw Error('Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof');
75
+ }
76
+ const decoded = CredentialMapper.decodeVerifiablePresentation(original);
77
+ const isJwtEncoded = CredentialMapper.isJwtEncoded(original);
78
+ const isJwtDecoded = CredentialMapper.isJwtDecodedPresentation(original);
79
+ const type = isJwtEncoded ? types_1.OriginalType.JWT_ENCODED : isJwtDecoded ? types_1.OriginalType.JWT_DECODED : types_1.OriginalType.JSONLD;
80
+ const format = isJwtDecoded || isJwtEncoded ? 'jwt_vp' : 'ldp_vp';
81
+ let vp;
82
+ if (isJwtEncoded || isJwtDecoded) {
83
+ vp = CredentialMapper.jwtDecodedPresentationToUniformPresentation(decoded, false, opts);
84
+ }
85
+ else {
86
+ vp = decoded;
87
+ }
88
+ if (!vp || !('verifiableCredential' in vp) || !vp.verifiableCredential || vp.verifiableCredential.length === 0) {
89
+ throw Error(`VP needs to have at least one verifiable credential at this point`);
90
+ }
91
+ const vcs = CredentialMapper.toWrappedVerifiableCredentials(vp.verifiableCredential /*.map(value => value.original)*/, opts);
92
+ const presentation = Object.assign(Object.assign({}, vp), { verifiableCredential: vcs });
93
+ return {
94
+ type,
95
+ format,
96
+ original,
97
+ decoded,
98
+ presentation,
99
+ vcs,
100
+ };
101
+ }
102
+ static toWrappedVerifiableCredentials(verifiableCredentials, opts) {
103
+ return verifiableCredentials.map((vc) => CredentialMapper.toWrappedVerifiableCredential(vc, opts));
104
+ }
105
+ static toWrappedVerifiableCredential(verifiableCredential, opts) {
106
+ var _a;
107
+ const proof = CredentialMapper.getFirstProof(verifiableCredential);
108
+ const original = CredentialMapper.hasJWTProofType(verifiableCredential) && proof ? (_a = proof.jwt) !== null && _a !== void 0 ? _a : verifiableCredential : verifiableCredential;
109
+ if (!original) {
110
+ throw Error('Could not determine original credential, probably it was a converted JWT credential, that is now missing the JWT value in the proof');
111
+ }
112
+ const decoded = CredentialMapper.decodeVerifiableCredential(original);
113
+ const isJwtEncoded = CredentialMapper.isJwtEncoded(original);
114
+ const isJwtDecoded = CredentialMapper.isJwtDecodedCredential(original);
115
+ const type = isJwtEncoded ? types_1.OriginalType.JWT_ENCODED : isJwtDecoded ? types_1.OriginalType.JWT_DECODED : types_1.OriginalType.JSONLD;
116
+ const credential = isJwtEncoded || isJwtDecoded
117
+ ? CredentialMapper.jwtDecodedCredentialToUniformCredential(decoded, opts)
118
+ : decoded;
119
+ const format = isJwtEncoded || isJwtDecoded ? 'jwt_vc' : 'ldp_vc';
120
+ return {
121
+ original,
122
+ decoded,
123
+ format,
124
+ type,
125
+ credential,
126
+ };
127
+ }
128
+ static isJwtEncoded(original) {
129
+ return utils_1.ObjectUtils.isString(original) && original.startsWith('ey');
130
+ }
131
+ static isJsonLdAsString(original) {
132
+ return utils_1.ObjectUtils.isString(original) && original.includes('@context');
133
+ }
134
+ static isJwtDecodedCredential(original) {
135
+ return original['vc'] !== undefined && original['iss'] !== undefined;
136
+ }
137
+ static isJwtDecodedPresentation(original) {
138
+ return original['vp'] !== undefined && original['iss'] !== undefined;
139
+ }
140
+ static jwtEncodedPresentationToUniformPresentation(jwt, makeCredentialsUniform = true, opts) {
141
+ return CredentialMapper.jwtDecodedPresentationToUniformPresentation((0, jwt_decode_1.default)(jwt), makeCredentialsUniform, opts);
142
+ }
143
+ static jwtDecodedPresentationToUniformPresentation(decoded, makeCredentialsUniform = true, opts) {
144
+ const { iss, aud, jti, vp } = decoded, rest = __rest(decoded, ["iss", "aud", "jti", "vp"]);
145
+ const presentation = Object.assign(Object.assign({}, rest), vp);
146
+ if (makeCredentialsUniform) {
147
+ if (!vp.verifiableCredential) {
148
+ throw Error('Verifiable Presentation should have a verifiable credential at this point');
149
+ }
150
+ presentation.verifiableCredential = vp.verifiableCredential.map((vc) => CredentialMapper.toUniformCredential(vc, opts));
151
+ }
152
+ if (iss) {
153
+ const holder = presentation.holder;
154
+ if (holder) {
155
+ if (holder !== iss) {
156
+ throw new Error(`Inconsistent holders between JWT claim (${iss}) and VC value (${holder})`);
157
+ }
158
+ }
159
+ presentation.holder = iss;
160
+ }
161
+ if (aud) {
162
+ const verifier = presentation.verifier;
163
+ if (verifier) {
164
+ if (verifier !== aud) {
165
+ throw new Error(`Inconsistent holders between JWT claim (${aud}) and VC value (${verifier})`);
166
+ }
167
+ }
168
+ presentation.verifier = aud;
169
+ }
170
+ if (jti) {
171
+ const id = presentation.id;
172
+ if (id && id !== jti) {
173
+ throw new Error(`Inconsistent VP ids between JWT claim (${jti}) and VP value (${id})`);
174
+ }
175
+ presentation.id = jti;
176
+ }
177
+ return presentation;
178
+ }
179
+ static toUniformCredential(verifiableCredential, opts) {
180
+ var _a;
181
+ const original = typeof verifiableCredential !== 'string' && CredentialMapper.hasJWTProofType(verifiableCredential)
182
+ ? (_a = CredentialMapper.getFirstProof(verifiableCredential)) === null || _a === void 0 ? void 0 : _a.jwt
183
+ : verifiableCredential;
184
+ if (!original) {
185
+ throw Error('Could not determine original credential from passed in credential. Probably because a JWT proof type was present, but now is not available anymore');
186
+ }
187
+ const decoded = CredentialMapper.decodeVerifiableCredential(original);
188
+ const isJwtEncoded = CredentialMapper.isJwtEncoded(original);
189
+ const isJwtDecoded = CredentialMapper.isJwtDecodedCredential(original);
190
+ if (isJwtDecoded || isJwtEncoded) {
191
+ return CredentialMapper.jwtDecodedCredentialToUniformCredential(decoded, opts);
192
+ }
193
+ else {
194
+ return decoded;
195
+ }
196
+ }
197
+ static toUniformPresentation(presentation, opts) {
198
+ var _a;
199
+ const proof = CredentialMapper.getFirstProof(presentation);
200
+ const original = typeof presentation !== 'string' && CredentialMapper.hasJWTProofType(presentation) ? proof === null || proof === void 0 ? void 0 : proof.jwt : presentation;
201
+ if (!original) {
202
+ throw Error('Could not determine original presentation, probably it was a converted JWT presentation, that is now missing the JWT value in the proof');
203
+ }
204
+ const decoded = CredentialMapper.decodeVerifiablePresentation(original);
205
+ const isJwtEncoded = CredentialMapper.isJwtEncoded(original);
206
+ const isJwtDecoded = CredentialMapper.isJwtDecodedPresentation(original);
207
+ const uniformPresentation = isJwtEncoded || isJwtDecoded
208
+ ? CredentialMapper.jwtDecodedPresentationToUniformPresentation(decoded, false)
209
+ : decoded;
210
+ // At time of writing Velocity Networks does not conform to specification. Adding bare minimum @context section to stop parsers from crashing and whatnot
211
+ if ((opts === null || opts === void 0 ? void 0 : opts.addContextIfMissing) && !uniformPresentation['@context']) {
212
+ uniformPresentation['@context'] = ['https://www.w3.org/2018/credentials/v1'];
213
+ }
214
+ uniformPresentation.verifiableCredential = (_a = uniformPresentation.verifiableCredential) === null || _a === void 0 ? void 0 : _a.map((vc) => CredentialMapper.toUniformCredential(vc, opts)); // We cast it because we IPresentation needs a VC. The internal Credential doesn't have the required Proof anymore (that is intended)
215
+ return uniformPresentation;
216
+ }
217
+ static jwtEncodedCredentialToUniformCredential(jwt, opts) {
218
+ return CredentialMapper.jwtDecodedCredentialToUniformCredential((0, jwt_decode_1.default)(jwt), opts);
219
+ }
220
+ static jwtDecodedCredentialToUniformCredential(decoded, opts) {
221
+ const { exp, nbf, iss, vc, sub, jti } = decoded, rest = __rest(decoded, ["exp", "nbf", "iss", "vc", "sub", "jti"]);
222
+ const credential = Object.assign(Object.assign({}, rest), vc);
223
+ const maxSkewInMS = (opts === null || opts === void 0 ? void 0 : opts.maxTimeSkewInMS) !== undefined ? opts.maxTimeSkewInMS : 999;
224
+ if (exp) {
225
+ const expDate = credential.expirationDate;
226
+ const jwtExp = parseInt(exp.toString());
227
+ // fix seconds to millisecond for the date
228
+ const expDateAsStr = jwtExp < 9999999999 ? new Date(jwtExp * 1000).toISOString().replace(/\.000Z/, 'Z') : new Date(jwtExp).toISOString();
229
+ if (expDate && expDate !== expDateAsStr) {
230
+ const diff = Math.abs(new Date(expDateAsStr).getTime() - new Date(expDate).getTime());
231
+ if (!maxSkewInMS || diff > maxSkewInMS) {
232
+ throw new Error(`Inconsistent expiration dates between JWT claim (${expDateAsStr}) and VC value (${expDate})`);
233
+ }
234
+ }
235
+ credential.expirationDate = expDateAsStr;
236
+ }
237
+ if (nbf) {
238
+ const issuanceDate = credential.issuanceDate;
239
+ const jwtNbf = parseInt(nbf.toString());
240
+ // fix seconds to millisecs for the date
241
+ const nbfDateAsStr = jwtNbf < 9999999999 ? new Date(jwtNbf * 1000).toISOString().replace(/\.000Z/, 'Z') : new Date(jwtNbf).toISOString();
242
+ if (issuanceDate && issuanceDate !== nbfDateAsStr) {
243
+ const diff = Math.abs(new Date(nbfDateAsStr).getTime() - new Date(issuanceDate).getTime());
244
+ if (!maxSkewInMS || diff > maxSkewInMS) {
245
+ throw new Error(`Inconsistent issuance dates between JWT claim (${nbfDateAsStr}) and VC value (${issuanceDate})`);
246
+ }
247
+ }
248
+ credential.issuanceDate = nbfDateAsStr;
249
+ }
250
+ if (iss) {
251
+ const issuer = credential.issuer;
252
+ if (issuer) {
253
+ if (typeof issuer === 'string') {
254
+ if (issuer !== iss) {
255
+ throw new Error(`Inconsistent issuers between JWT claim (${iss}) and VC value (${issuer})`);
256
+ }
257
+ }
258
+ else {
259
+ if (issuer.id !== iss) {
260
+ throw new Error(`Inconsistent issuers between JWT claim (${iss}) and VC value (${issuer.id})`);
261
+ }
262
+ }
263
+ }
264
+ else {
265
+ credential.issuer = iss;
266
+ }
267
+ }
268
+ if (sub) {
269
+ const subjects = Array.isArray(credential.credentialSubject) ? credential.credentialSubject : [credential.credentialSubject];
270
+ for (let i = 0; i < subjects.length; i++) {
271
+ const csId = subjects[i].id;
272
+ if (csId && csId !== sub) {
273
+ throw new Error(`Inconsistent credential subject ids between JWT claim (${sub}) and VC value (${csId})`);
274
+ }
275
+ Array.isArray(credential.credentialSubject) ? (credential.credentialSubject[i].id = sub) : (credential.credentialSubject.id = sub);
276
+ }
277
+ }
278
+ if (jti) {
279
+ const id = credential.id;
280
+ if (id && id !== jti) {
281
+ throw new Error(`Inconsistent credential ids between JWT claim (${jti}) and VC value (${id})`);
282
+ }
283
+ credential.id = jti;
284
+ }
285
+ return credential;
286
+ }
287
+ static toExternalVerifiableCredential(verifiableCredential) {
288
+ let proof;
289
+ if (verifiableCredential.proof) {
290
+ if (!verifiableCredential.proof.type) {
291
+ throw new Error('Verifiable credential proof is missing a type');
292
+ }
293
+ if (!verifiableCredential.proof.created) {
294
+ throw new Error('Verifiable credential proof is missing a created date');
295
+ }
296
+ if (!verifiableCredential.proof.proofPurpose) {
297
+ throw new Error('Verifiable credential proof is missing a proof purpose');
298
+ }
299
+ if (!verifiableCredential.proof.verificationMethod) {
300
+ throw new Error('Verifiable credential proof is missing a verification method');
301
+ }
302
+ proof = Object.assign(Object.assign({}, verifiableCredential.proof), { type: verifiableCredential.proof.type, created: verifiableCredential.proof.created, proofPurpose: verifiableCredential.proof.proofPurpose, verificationMethod: verifiableCredential.proof.verificationMethod });
303
+ }
304
+ return Object.assign(Object.assign({}, verifiableCredential), { type: verifiableCredential.type
305
+ ? typeof verifiableCredential.type === 'string'
306
+ ? [verifiableCredential.type]
307
+ : verifiableCredential.type
308
+ : ['VerifiableCredential'], proof });
309
+ }
310
+ static storedCredentialToOriginalFormat(credential) {
311
+ const type = CredentialMapper.detectDocumentType(credential);
312
+ if (typeof credential === 'string') {
313
+ if (type === 0 /* DocumentFormat.JWT */) {
314
+ return CredentialMapper.toCompactJWT(credential);
315
+ }
316
+ else if (type === 1 /* DocumentFormat.JSONLD */) {
317
+ return JSON.parse(credential);
318
+ }
319
+ }
320
+ return credential;
321
+ }
322
+ static storedPresentationToOriginalFormat(presentation) {
323
+ const type = CredentialMapper.detectDocumentType(presentation);
324
+ if (typeof presentation === 'string') {
325
+ if (type === 0 /* DocumentFormat.JWT */) {
326
+ return CredentialMapper.toCompactJWT(presentation);
327
+ }
328
+ else if (type === 1 /* DocumentFormat.JSONLD */) {
329
+ return JSON.parse(presentation);
330
+ }
331
+ }
332
+ return presentation;
333
+ }
334
+ static toCompactJWT(jwtDocument) {
335
+ if (!jwtDocument || CredentialMapper.detectDocumentType(jwtDocument) !== 0 /* DocumentFormat.JWT */) {
336
+ throw Error('Cannot convert non JWT credential to JWT');
337
+ }
338
+ if (typeof jwtDocument === 'string') {
339
+ return jwtDocument;
340
+ }
341
+ let proof;
342
+ if ('vp' in jwtDocument) {
343
+ proof = jwtDocument.vp.proof;
344
+ }
345
+ else if ('vc' in jwtDocument) {
346
+ proof = jwtDocument.vc.proof;
347
+ }
348
+ else {
349
+ proof = Array.isArray(jwtDocument.proof) ? jwtDocument.proof[0].jwt : jwtDocument.proof.jwt;
350
+ }
351
+ if (!proof) {
352
+ throw Error(`Could not get JWT from supplied document`);
353
+ }
354
+ return proof;
355
+ }
356
+ static detectDocumentType(document) {
357
+ if (typeof document === 'string') {
358
+ return this.isJsonLdAsString(document) ? 1 /* DocumentFormat.JSONLD */ : 0 /* DocumentFormat.JWT */;
359
+ }
360
+ const proofs = 'vc' in document ? document.vc.proof : 'vp' in document ? document.vp.proof : document.proof;
361
+ const proof = Array.isArray(proofs) ? proofs[0] : proofs;
362
+ if (proof === null || proof === void 0 ? void 0 : proof.jwt) {
363
+ return 0 /* DocumentFormat.JWT */;
364
+ }
365
+ else if ((proof === null || proof === void 0 ? void 0 : proof.type) === 'EthereumEip712Signature2021') {
366
+ return 2 /* DocumentFormat.EIP712 */;
367
+ }
368
+ return 1 /* DocumentFormat.JSONLD */;
369
+ }
370
+ static hasJWTProofType(document) {
371
+ var _a;
372
+ if (typeof document === 'string') {
373
+ return false;
374
+ }
375
+ return !!((_a = CredentialMapper.getFirstProof(document)) === null || _a === void 0 ? void 0 : _a.jwt);
376
+ }
377
+ static getFirstProof(document) {
378
+ if (!document || typeof document === 'string') {
379
+ return undefined;
380
+ }
381
+ const proofs = 'vc' in document ? document.vc.proof : 'vp' in document ? document.vp.proof : document.proof;
382
+ return Array.isArray(proofs) ? proofs[0] : proofs;
383
+ }
384
+ }
385
+ exports.CredentialMapper = CredentialMapper;
386
+ //# sourceMappingURL=credential-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-mapper.js","sourceRoot":"","sources":["../../src/mapper/credential-mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oCAmBiB;AACjB,4DAAmC;AACnC,oCAAsC;AAEtC,MAAa,gBAAgB;IAC3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O,QAAQ,KAAK,QAAQ,EAAE;YAC7C,OAAO,SAAS,CAAA;SACjB;QACD,MAAM,MAAM,GAAG,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAyB,QAAS,CAAC,KAAK,CAAA;QACpI,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IACnD,CAAC;CACF;AA/cD,4CA+cC"}
@@ -0,0 +1,2 @@
1
+ export * from './credential-mapper';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mapper/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./credential-mapper"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mapper/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC"}
@@ -0,0 +1,36 @@
1
+ export declare enum IProofPurpose {
2
+ verificationMethod = "verificationMethod",
3
+ assertionMethod = "assertionMethod",
4
+ authentication = "authentication",
5
+ keyAgreement = "keyAgreement",
6
+ contractAgreement = "contactAgreement",
7
+ capabilityInvocation = "capabilityInvocation",
8
+ capabilityDelegation = "capabilityDelegation"
9
+ }
10
+ export declare enum IProofType {
11
+ Ed25519Signature2018 = "Ed25519Signature2018",
12
+ Ed25519Signature2020 = "Ed25519Signature2020",
13
+ EcdsaSecp256k1Signature2019 = "EcdsaSecp256k1Signature2019",
14
+ EcdsaSecp256k1RecoverySignature2020 = "EcdsaSecp256k1RecoverySignature2020",
15
+ JsonWebSignature2020 = "JsonWebSignature2020",
16
+ RsaSignature2018 = "RsaSignature2018",
17
+ GpgSignature2020 = "GpgSignature2020",
18
+ JcsEd25519Signature2020 = "JcsEd25519Signature2020",
19
+ BbsBlsSignatureProof2020 = "BbsBlsSignatureProof2020",
20
+ BbsBlsBoundSignatureProof2020 = "BbsBlsBoundSignatureProof2020",
21
+ JwtProof2020 = "JwtProof2020"
22
+ }
23
+ export interface IParsedDID {
24
+ did: string;
25
+ didUrl: string;
26
+ method: string;
27
+ id: string;
28
+ path?: string;
29
+ fragment?: string;
30
+ query?: string;
31
+ params?: {
32
+ [index: string]: string;
33
+ };
34
+ }
35
+ export declare const parseDid: (did: string) => IParsedDID;
36
+ //# sourceMappingURL=did.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../../src/types/did.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,kBAAkB,uBAAuB;IACzC,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,iBAAiB,qBAAqB;IACtC,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;CAC9C;AAED,oBAAY,UAAU;IACpB,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,2BAA2B,gCAAgC;IAC3D,mCAAmC,wCAAwC;IAC3E,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IACrC,gBAAgB,qBAAqB;IACrC,uBAAuB,4BAA4B;IACnD,wBAAwB,6BAA6B;IACrD,6BAA6B,kCAAkC;IAC/D,YAAY,iBAAiB;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE;QACP,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KACxB,CAAA;CACF;AAED,eAAO,MAAM,QAAQ,QAAS,MAAM,KAAG,UAOtC,CAAA"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseDid = exports.IProofType = exports.IProofPurpose = void 0;
4
+ var IProofPurpose;
5
+ (function (IProofPurpose) {
6
+ IProofPurpose["verificationMethod"] = "verificationMethod";
7
+ IProofPurpose["assertionMethod"] = "assertionMethod";
8
+ IProofPurpose["authentication"] = "authentication";
9
+ IProofPurpose["keyAgreement"] = "keyAgreement";
10
+ IProofPurpose["contractAgreement"] = "contactAgreement";
11
+ IProofPurpose["capabilityInvocation"] = "capabilityInvocation";
12
+ IProofPurpose["capabilityDelegation"] = "capabilityDelegation";
13
+ })(IProofPurpose = exports.IProofPurpose || (exports.IProofPurpose = {}));
14
+ var IProofType;
15
+ (function (IProofType) {
16
+ IProofType["Ed25519Signature2018"] = "Ed25519Signature2018";
17
+ IProofType["Ed25519Signature2020"] = "Ed25519Signature2020";
18
+ IProofType["EcdsaSecp256k1Signature2019"] = "EcdsaSecp256k1Signature2019";
19
+ IProofType["EcdsaSecp256k1RecoverySignature2020"] = "EcdsaSecp256k1RecoverySignature2020";
20
+ IProofType["JsonWebSignature2020"] = "JsonWebSignature2020";
21
+ IProofType["RsaSignature2018"] = "RsaSignature2018";
22
+ IProofType["GpgSignature2020"] = "GpgSignature2020";
23
+ IProofType["JcsEd25519Signature2020"] = "JcsEd25519Signature2020";
24
+ IProofType["BbsBlsSignatureProof2020"] = "BbsBlsSignatureProof2020";
25
+ IProofType["BbsBlsBoundSignatureProof2020"] = "BbsBlsBoundSignatureProof2020";
26
+ IProofType["JwtProof2020"] = "JwtProof2020";
27
+ })(IProofType = exports.IProofType || (exports.IProofType = {}));
28
+ const parseDid = (did) => {
29
+ const parsedDid = parse(did);
30
+ if (parsedDid === null) {
31
+ throw new Error('invalid did');
32
+ }
33
+ return parsedDid;
34
+ };
35
+ exports.parseDid = parseDid;
36
+ const parse = (didUrl) => {
37
+ const PCT_ENCODED = '(?:%[0-9a-fA-F]{2})';
38
+ const ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`;
39
+ const METHOD = '([a-z0-9]+)';
40
+ const METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`;
41
+ const PARAM_CHAR = '[a-zA-Z0-9_.:%-]';
42
+ const PARAM = `;${PARAM_CHAR}+=${PARAM_CHAR}*`;
43
+ const PARAMS = `((${PARAM})*)`;
44
+ const PATH = `(/[^#?]*)?`;
45
+ const QUERY = `([?][^#]*)?`;
46
+ const FRAGMENT = `(#.*)?`;
47
+ const DID_MATCHER = new RegExp(`^did:${METHOD}:${METHOD_ID}${PARAMS}${PATH}${QUERY}${FRAGMENT}$`);
48
+ if (didUrl === '' || !didUrl)
49
+ return null;
50
+ const sections = didUrl.match(DID_MATCHER);
51
+ if (sections) {
52
+ const parts = {
53
+ did: `did:${sections[1]}:${sections[2]}`,
54
+ method: sections[1],
55
+ id: sections[2],
56
+ didUrl,
57
+ };
58
+ if (sections[4]) {
59
+ const params = sections[4].slice(1).split(';');
60
+ parts.params = {};
61
+ for (const p of params) {
62
+ const kv = p.split('=');
63
+ parts.params[kv[0]] = kv[1];
64
+ }
65
+ }
66
+ if (sections[6])
67
+ parts.path = sections[6];
68
+ if (sections[7])
69
+ parts.query = sections[7].slice(1);
70
+ if (sections[8])
71
+ parts.fragment = sections[8].slice(1);
72
+ return parts;
73
+ }
74
+ return null;
75
+ };
76
+ //# sourceMappingURL=did.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did.js","sourceRoot":"","sources":["../../src/types/did.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,0DAAyC,CAAA;IACzC,oDAAmC,CAAA;IACnC,kDAAiC,CAAA;IACjC,8CAA6B,CAAA;IAC7B,uDAAsC,CAAA;IACtC,8DAA6C,CAAA;IAC7C,8DAA6C,CAAA;AAC/C,CAAC,EARW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAQxB;AAED,IAAY,UAYX;AAZD,WAAY,UAAU;IACpB,2DAA6C,CAAA;IAC7C,2DAA6C,CAAA;IAC7C,yEAA2D,CAAA;IAC3D,yFAA2E,CAAA;IAC3E,2DAA6C,CAAA;IAC7C,mDAAqC,CAAA;IACrC,mDAAqC,CAAA;IACrC,iEAAmD,CAAA;IACnD,mEAAqD,CAAA;IACrD,6EAA+D,CAAA;IAC/D,2CAA6B,CAAA;AAC/B,CAAC,EAZW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAYrB;AAeM,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAc,EAAE;IAClD,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,SAAS,KAAK,IAAI,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;KAC/B;IAED,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAPY,QAAA,QAAQ,YAOpB;AAED,M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AC,IAAI,MAAM,EAAE;gBACtB,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;gBACvB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;aAC5B;SACF;QACD,IAAI,QAAQ,CAAC,CAAC,CAAC;YAAE,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QACzC,IAAI,QAAQ,CAAC,CAAC,CAAC;YAAE,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACnD,IAAI,QAAQ,CAAC,CAAC,CAAC;YAAE,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACtD,OAAO,KAAK,CAAA;KACb;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Accept a Type or a Promise of that Type.
3
+ *
4
+ * @internal
5
+ */
6
+ export type OrPromise<T> = T | Promise<T>;
7
+ //# sourceMappingURL=generic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/types/generic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.js","sourceRoot":"","sources":["../../src/types/generic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export * from './did';
2
+ export * from './pex';
3
+ export * from './vc';
4
+ export * from './generic';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,OAAO,CAAA;AACrB,cAAc,MAAM,CAAA;AACpB,cAAc,WAAW,CAAA"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./did"), exports);
18
+ __exportStar(require("./pex"), exports);
19
+ __exportStar(require("./vc"), exports);
20
+ __exportStar(require("./generic"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,wCAAqB;AACrB,uCAAoB;AACpB,4CAAyB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * It expresses how the inputs are presented as proofs to a Verifier.
3
+ */
4
+ export interface PresentationSubmission {
5
+ /**
6
+ * A UUID or some other unique ID to identify this Presentation Submission
7
+ */
8
+ id: string;
9
+ /**
10
+ * A UUID or some other unique ID to identify this Presentation Definition
11
+ */
12
+ definition_id: string;
13
+ /**
14
+ * List of descriptors of how the claims are being mapped to presentation definition
15
+ */
16
+ descriptor_map: Array<Descriptor>;
17
+ }
18
+ /**
19
+ * descriptor map laying out the structure of the presentation submission.
20
+ */
21
+ export interface Descriptor {
22
+ /**
23
+ * ID to identify the descriptor from Presentation Definition Input Descriptor it coresponds to.
24
+ */
25
+ id: string;
26
+ /**
27
+ * The path where the verifiable credential is located in the presentation submission json
28
+ */
29
+ path: string;
30
+ path_nested?: Descriptor;
31
+ /**
32
+ * The Proof or JWT algorith that the proof is in
33
+ */
34
+ format: string;
35
+ }
36
+ //# sourceMappingURL=pex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pex.d.ts","sourceRoot":"","sources":["../../src/types/pex.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=pex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pex.js","sourceRoot":"","sources":["../../src/types/pex.ts"],"names":[],"mappings":""}
@@ -0,0 +1,245 @@
1
+ import { PresentationSubmission } from './pex';
2
+ import { IProofPurpose, IProofType } from './did';
3
+ export type AdditionalClaims = Record<string, any>;
4
+ export type IIssuerId = string;
5
+ export interface ICredential {
6
+ '@context': ICredentialContextType | ICredentialContextType[];
7
+ type: string[];
8
+ credentialSchema?: undefined | ICredentialSchemaType | ICredentialSchemaType[];
9
+ issuer: IIssuerId | IIssuer;
10
+ issuanceDate: string;
11
+ credentialSubject: (ICredentialSubject & AdditionalClaims) | (ICredentialSubject & AdditionalClaims)[];
12
+ expirationDate?: string;
13
+ id?: string;
14
+ credentialStatus?: ICredentialStatus;
15
+ description?: string;
16
+ name?: string;
17
+ [x: string]: any;
18
+ }
19
+ export interface ICredentialSubject {
20
+ id?: string;
21
+ }
22
+ export type ICredentialContextType = (ICredentialContext & AdditionalClaims) | string;
23
+ export interface ICredentialContext {
24
+ name?: string;
25
+ did?: string;
26
+ }
27
+ export type ICredentialSchemaType = ICredentialSchema | string;
28
+ export interface ICredentialSchema {
29
+ id: string;
30
+ type?: string;
31
+ }
32
+ export interface IProof {
33
+ type: IProofType | string;
34
+ created: string;
35
+ proofPurpose: IProofPurpose | string;
36
+ verificationMethod: string;
37
+ challenge?: string;
38
+ domain?: string;
39
+ proofValue?: string;
40
+ jws?: string;
41
+ jwt?: string;
42
+ nonce?: string;
43
+ requiredRevealStatements?: string[];
44
+ [x: string]: any;
45
+ }
46
+ export interface ICredentialStatus {
47
+ id: string;
48
+ type: string;
49
+ }
50
+ export interface IIssuer {
51
+ id: string;
52
+ [x: string]: any;
53
+ }
54
+ export interface IHasProof {
55
+ proof: IProof | IProof[];
56
+ }
57
+ export type IVerifiableCredential = ICredential & IHasProof;
58
+ /**
59
+ * Represents a Json Web Token in compact form.
60
+ */
61
+ export type CompactJWT = string;
62
+ /**
63
+ * Represents a signed Verifiable Credential (includes proof), in either JSON or compact JWT format.
64
+ * See {@link https://www.w3.org/TR/vc-data-model/#credentials | VC data model}
65
+ * See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats}
66
+ */
67
+ export type W3CVerifiableCredential = IVerifiableCredential | CompactJWT;
68
+ export interface IPresentation {
69
+ id?: string;
70
+ '@context': ICredentialContextType | ICredentialContextType[];
71
+ type?: string | string[];
72
+ verifiableCredential?: W3CVerifiableCredential[];
73
+ presentation_submission?: PresentationSubmission;
74
+ holder?: string;
75
+ verifier?: string;
76
+ [x: string]: any;
77
+ }
78
+ export type IVerifiablePresentation = IPresentation & IHasProof;
79
+ /**
80
+ * Represents a signed Verifiable Presentation (includes proof), in either JSON or compact JWT format.
81
+ * See {@link https://www.w3.org/TR/vc-data-model/#presentations | VC data model}
82
+ * See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats}
83
+ */
84
+ export type W3CVerifiablePresentation = IVerifiablePresentation | CompactJWT;
85
+ export interface WrappedVerifiableCredential {
86
+ /**
87
+ * Original VC that we've received
88
+ */
89
+ original: OriginalVerifiableCredential;
90
+ /**
91
+ * In case of JWT credential it will be the decoded version. In other cases it will be the same as original one
92
+ */
93
+ decoded: JwtDecodedVerifiableCredential | IVerifiableCredential;
94
+ /**
95
+ * Type of this credential. Supported types are json-ld and jwt (decoded/encoded)
96
+ */
97
+ type: OriginalType;
98
+ /**
99
+ * The claim format, typically used during exchange transport protocols
100
+ */
101
+ format: CredentialFormat;
102
+ /**
103
+ * Internal stable representation of a Credential
104
+ */
105
+ credential: IVerifiableCredential;
106
+ }
107
+ export interface WrappedVerifiablePresentation {
108
+ /**
109
+ * Original VP that we've received
110
+ */
111
+ original: OriginalVerifiablePresentation;
112
+ /**
113
+ * In case of JWT VP it will be the decoded version. In other cases it will be the same as original one
114
+ */
115
+ decoded: JwtDecodedVerifiablePresentation | IVerifiablePresentation;
116
+ /**
117
+ * Type of this Presentation. Supported types are json-ld and jwt (decoded/encoded)
118
+ */
119
+ type: OriginalType;
120
+ /**
121
+ * The claim format, typically used during exchange transport protocols
122
+ */
123
+ format: PresentationFormat;
124
+ /**
125
+ * Internal stable representation of a Presentation without proofs, created based on https://www.w3.org/TR/vc-data-model/#jwt-decoding
126
+ */
127
+ presentation: UniformVerifiablePresentation;
128
+ /**
129
+ * Wrapped Verifiable Credentials belonging to the Presentation
130
+ */
131
+ vcs: WrappedVerifiableCredential[];
132
+ }
133
+ export declare enum OriginalType {
134
+ JSONLD = "json-ld",
135
+ JWT_ENCODED = "jwt-encoded",
136
+ JWT_DECODED = "jwt-decoded"
137
+ }
138
+ export interface UniformVerifiablePresentation {
139
+ '@context': ICredentialContextType | ICredentialContextType[];
140
+ type: string | string[];
141
+ verifiableCredential: WrappedVerifiableCredential[];
142
+ presentation_submission?: PresentationSubmission;
143
+ holder?: string;
144
+ }
145
+ export interface JwtDecodedVerifiableCredential {
146
+ vc: IVerifiableCredential;
147
+ exp: string;
148
+ iss: string;
149
+ nbf: string;
150
+ sub: string;
151
+ jti: string;
152
+ [x: string]: any;
153
+ }
154
+ export interface JwtDecodedVerifiablePresentation {
155
+ vp: IVerifiablePresentation;
156
+ exp: string;
157
+ iss: string;
158
+ nbf: string;
159
+ sub: string;
160
+ jti: string;
161
+ aud: string;
162
+ iat: string;
163
+ [x: string]: any;
164
+ }
165
+ export type CredentialFormat = 'jwt' | 'ldp' | 'jwt_vc' | 'ldp_vc' | string;
166
+ export type PresentationFormat = 'jwt' | 'ldp' | 'jwt_vp' | 'ldp_vp' | string;
167
+ export type ClaimFormat = CredentialFormat | PresentationFormat;
168
+ export type OriginalVerifiableCredential = W3CVerifiableCredential | JwtDecodedVerifiableCredential;
169
+ export type OriginalVerifiablePresentation = W3CVerifiablePresentation | JwtDecodedVerifiablePresentation;
170
+ export type Original = OriginalVerifiablePresentation | OriginalVerifiableCredential;
171
+ export declare const enum DocumentFormat {
172
+ JWT = 0,
173
+ JSONLD = 1,
174
+ EIP712 = 2
175
+ }
176
+ export declare const JWT_PROOF_TYPE_2020 = "JwtProof2020";
177
+ export interface IVerifyStatusResult {
178
+ verified: boolean;
179
+ /**
180
+ * Optional Error object for the
181
+ * but currently the machine readable errors are not exported from DID-JWT package to be imported here
182
+ */
183
+ error?: IError | undefined;
184
+ /**
185
+ * Other options can be specified for verification.
186
+ * They will be forwarded to the lower level modules. that performt the checks
187
+ */
188
+ [x: string]: any;
189
+ }
190
+ export interface IVerifyResult {
191
+ /**
192
+ * This value is used to transmit the global result of verification.
193
+ */
194
+ verified: boolean;
195
+ results?: [
196
+ {
197
+ credential?: ICredential;
198
+ presentation?: IPresentation;
199
+ verified: boolean;
200
+ error?: IError;
201
+ log: [{
202
+ id: string;
203
+ valid: boolean;
204
+ }];
205
+ }
206
+ ];
207
+ statusResult?: IVerifyStatusResult;
208
+ /**
209
+ * Optional Error object for the
210
+ * but currently the machine readable errors are not exported from DID-JWT package to be imported here
211
+ */
212
+ error?: IError | undefined;
213
+ /**
214
+ * Other options can be specified for verification.
215
+ * They will be forwarded to the lower level modules. that performt the checks
216
+ */
217
+ [x: string]: any;
218
+ }
219
+ /**
220
+ * An error object, which can contain a code.
221
+ * @beta
222
+ */
223
+ export interface IError {
224
+ name?: string;
225
+ errors?: IError[];
226
+ /**
227
+ * The details of the error being thrown or forwarded
228
+ */
229
+ message?: string;
230
+ /**
231
+ * The stack of the error
232
+ */
233
+ stack?: string | string[];
234
+ details?: IErrorDetails;
235
+ /**
236
+ * The code for the error being throw
237
+ */
238
+ errorCode?: string;
239
+ }
240
+ export interface IErrorDetails {
241
+ code?: string;
242
+ url?: string;
243
+ cause?: IError;
244
+ }
245
+ //# sourceMappingURL=vc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vc.d.ts","sourceRoot":"","sources":["../../src/types/vc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEjD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAElD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAA;IAC7D,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,gBAAgB,CAAC,EAAE,SAAS,GAAG,qBAAqB,GAAG,qBAAqB,EAAE,CAAA;IAE9E,MAAM,EAAE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G;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAE1B;;;OAGG;IACH,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAEzB,OAAO,CAAC,EAAE,aAAa,CAAA;IAEvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JWT_PROOF_TYPE_2020 = exports.DocumentFormat = exports.OriginalType = void 0;
4
+ var OriginalType;
5
+ (function (OriginalType) {
6
+ OriginalType["JSONLD"] = "json-ld";
7
+ OriginalType["JWT_ENCODED"] = "jwt-encoded";
8
+ OriginalType["JWT_DECODED"] = "jwt-decoded";
9
+ })(OriginalType = exports.OriginalType || (exports.OriginalType = {}));
10
+ var DocumentFormat;
11
+ (function (DocumentFormat) {
12
+ DocumentFormat[DocumentFormat["JWT"] = 0] = "JWT";
13
+ DocumentFormat[DocumentFormat["JSONLD"] = 1] = "JSONLD";
14
+ DocumentFormat[DocumentFormat["EIP712"] = 2] = "EIP712";
15
+ })(DocumentFormat = exports.DocumentFormat || (exports.DocumentFormat = {}));
16
+ exports.JWT_PROOF_TYPE_2020 = 'JwtProof2020';
17
+ //# sourceMappingURL=vc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vc.js","sourceRoot":"","sources":["../../src/types/vc.ts"],"names":[],"mappings":";;;AAkKA,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,kCAAkB,CAAA;IAClB,2CAA2B,CAAA;IAC3B,2CAA2B,CAAA;AAC7B,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AA0CD,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC9B,iDAAG,CAAA;IACH,uDAAM,CAAA;IACN,uDAAM,CAAA;AACR,CAAC,EAJiB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAI/B;AAEY,QAAA,mBAAmB,GAAG,cAAc,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './object';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./object"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB"}
@@ -0,0 +1,7 @@
1
+ export declare class ObjectUtils {
2
+ static asArray(value: unknown): any[];
3
+ static isObject(value: unknown): boolean;
4
+ static isUrlAbsolute(url: string): void;
5
+ static isString(value: unknown): boolean;
6
+ }
7
+ //# sourceMappingURL=object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;WACR,OAAO,CAAC,KAAK,EAAE,OAAO;WAItB,QAAQ,CAAC,KAAK,EAAE,OAAO;WAIvB,aAAa,CAAC,GAAG,EAAE,MAAM;WAMzB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;CAGhD"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObjectUtils = void 0;
4
+ class ObjectUtils {
5
+ static asArray(value) {
6
+ return Array.isArray(value) ? value : [value];
7
+ }
8
+ static isObject(value) {
9
+ return Object.prototype.toString.call(value) === '[object Object]';
10
+ }
11
+ static isUrlAbsolute(url) {
12
+ // regex to check for absolute IRI (starting scheme and ':') or blank node IRI
13
+ const isAbsoluteRegex = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/;
14
+ ObjectUtils.isString(url) && isAbsoluteRegex.test(url);
15
+ }
16
+ static isString(value) {
17
+ return typeof value === 'string' || Object.prototype.toString.call(value) === '[object String]';
18
+ }
19
+ }
20
+ exports.ObjectUtils = ObjectUtils;
21
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IACf,MAAM,CAAC,OAAO,CAAC,KAAc;QAClC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IAC/C,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,KAAc;QACnC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAA;IACpE,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,GAAW;QACrC,8EAA8E;QAC9E,MAAM,eAAe,GAAG,sCAAsC,CAAA;QAC9D,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxD,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,KAAc;QACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAA;IACjG,CAAC;CACF;AAlBD,kCAkBC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-types",
3
3
  "description": "SSI Common Types",
4
- "version": "0.11.1-unstable.151+5f89d1a",
4
+ "version": "0.11.1-unstable.152+e1924a1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
@@ -41,5 +41,5 @@
41
41
  "Verifiable Credentials",
42
42
  "DIDs"
43
43
  ],
44
- "gitHead": "5f89d1a73bc8cc2102c2def36821bea2c88ee350"
44
+ "gitHead": "e1924a1e5c4b336718ed0e6ddd5dbe8fcc767507"
45
45
  }