@sphereon/ssi-types 0.8.0 → 0.8.1-next.114

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.
@@ -1 +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,WAAW,WAAW;IAE1B,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IAExB,YAAY,EAAE,MAAM,CAAA;IAEpB,iBAAiB,EAAE,kBAAkB,CAAA;IAErC,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,sBAAsB,EAAE,GAAG,sBAAsB,CAAA;IAC7D,gBAAgB,CAAC,EAAE,iBAAiB,CAAA;IACpC,gBAAgB,CAAC,EAAE,SAAS,GAAG,qBAAqB,GAAG,qBAAqB,EAAE,CAAA;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,EAAE,CAAA;IAEd,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAA;IAEX,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,oBAAY,sBAAsB,GAAG,kBAAkB,GAAG,MAAM,CAAA;AAEhE,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,oBAAY,qBAAqB,GAAG,iBAAiB,GAAG,MAAM,CAAA;AAE9D,MAA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A;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IAEX,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED,MAAM,WAAW,gCAAgC;IAC/C,EAAE,EAAE,uBAAuB,CAAA;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IAEX,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;AAC3E,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;AAC7E,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,kBAAkB,CAAA;AAE/D,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,GAAG,8BAA8B,CAAA;AACnG,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,GAAG,gCAAgC,CAAA;AACzG,MAAM,MAAM,QAAQ,GAAG,8BAA8B,GAAG,4BAA4B,CAAA"}
package/dist/types/vc.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VerifiableDataExchangeType = void 0;
4
- var VerifiableDataExchangeType;
5
- (function (VerifiableDataExchangeType) {
6
- VerifiableDataExchangeType[VerifiableDataExchangeType["JSONLD"] = 0] = "JSONLD";
7
- VerifiableDataExchangeType[VerifiableDataExchangeType["JWT_ENCODED"] = 1] = "JWT_ENCODED";
8
- VerifiableDataExchangeType[VerifiableDataExchangeType["JWT_DECODED"] = 2] = "JWT_DECODED";
9
- })(VerifiableDataExchangeType = exports.VerifiableDataExchangeType || (exports.VerifiableDataExchangeType = {}));
3
+ 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
10
  //# sourceMappingURL=vc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vc.js","sourceRoot":"","sources":["../../src/types/vc.ts"],"names":[],"mappings":";;;AAkHA,IAAY,0BAIX;AAJD,WAAY,0BAA0B;IACpC,+EAAM,CAAA;IACN,yFAAW,CAAA;IACX,yFAAW,CAAA;AACb,CAAC,EAJW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAIrC"}
1
+ {"version":3,"file":"vc.js","sourceRoot":"","sources":["../../src/types/vc.ts"],"names":[],"mappings":";;;AAgKA,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,kCAAkB,CAAA;IAClB,2CAA2B,CAAA;IAC3B,2CAA2B,CAAA;AAC7B,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB"}
@@ -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,13 +1,20 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-types",
3
3
  "description": "SSI Common Types",
4
- "version": "0.8.0",
4
+ "version": "0.8.1-next.114+62debd9",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc --build"
9
9
  },
10
+ "dependencies": {
11
+ "jwt-decode": "^3.1.2"
12
+ },
10
13
  "devDependencies": {
14
+ "@types/jest": "^27.0.2",
15
+ "jest": "^27.3.1",
16
+ "prettier": "^2.4.1",
17
+ "ts-jest": "^27.0.7",
11
18
  "typescript": "4.6.4"
12
19
  },
13
20
  "files": [
@@ -23,6 +30,12 @@
23
30
  "repository": "git@github.com:Sphereon-OpenSource/ssi-sdk.git",
24
31
  "author": "Sphereon <dev@sphereon.com>",
25
32
  "license": "Apache-2.0",
26
- "keywords": [],
27
- "gitHead": "1032feb5588568edfbca0110f3ff9e6c38894135"
33
+ "keywords": [
34
+ "SSI",
35
+ "Common Credential Types",
36
+ "Credential Mapping",
37
+ "Verifiable Credentials",
38
+ "DIDs"
39
+ ],
40
+ "gitHead": "62debd972f51a3f1ad90e922115eed4c2f56cefb"
28
41
  }
package/src/index.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from './types'
2
+ export * from './utils'
3
+ export * from './mapper'
@@ -0,0 +1,275 @@
1
+ import {
2
+ ICredential,
3
+ IPresentation,
4
+ IVerifiableCredential,
5
+ IVerifiablePresentation,
6
+ JwtDecodedVerifiableCredential,
7
+ JwtDecodedVerifiablePresentation,
8
+ OriginalType,
9
+ OriginalVerifiableCredential,
10
+ OriginalVerifiablePresentation,
11
+ PresentationFormat,
12
+ WrappedVerifiableCredential,
13
+ WrappedVerifiablePresentation,
14
+ } from '../types'
15
+ import jwt_decode from 'jwt-decode'
16
+ import { ObjectUtils } from '../utils'
17
+
18
+ export class CredentialMapper {
19
+ static decodeVerifiablePresentation(presentation: OriginalVerifiablePresentation): JwtDecodedVerifiablePresentation | IVerifiablePresentation {
20
+ if (CredentialMapper.isJwtEncoded(presentation)) {
21
+ return jwt_decode(presentation as string) as JwtDecodedVerifiablePresentation
22
+ } else if (CredentialMapper.isJwtDecodedPresentation(presentation)) {
23
+ return presentation as JwtDecodedVerifiablePresentation
24
+ } else if (CredentialMapper.isJsonLdString(presentation)) {
25
+ return JSON.parse(presentation as string) as IVerifiablePresentation
26
+ } else {
27
+ return presentation as IVerifiablePresentation
28
+ }
29
+ }
30
+
31
+ static decodeVerifiableCredential(credential: OriginalVerifiableCredential): JwtDecodedVerifiableCredential | IVerifiableCredential {
32
+ if (CredentialMapper.isJwtEncoded(credential)) {
33
+ return jwt_decode(credential as string) as JwtDecodedVerifiableCredential
34
+ } else if (CredentialMapper.isJwtDecodedCredential(credential)) {
35
+ return credential as JwtDecodedVerifiableCredential
36
+ } else if (CredentialMapper.isJsonLdString(credential)) {
37
+ return JSON.parse(credential as string) as IVerifiableCredential
38
+ } else {
39
+ return credential as IVerifiableCredential
40
+ }
41
+ }
42
+
43
+ static toWrappedVerifiablePresentation(
44
+ presentation: OriginalVerifiablePresentation,
45
+ opts?: { maxTimeSkewInMS?: number }
46
+ ): WrappedVerifiablePresentation {
47
+ const original = presentation
48
+ const isJwtEncoded: boolean = CredentialMapper.isJwtEncoded(original)
49
+ const isJwtDecoded: boolean = CredentialMapper.isJwtDecodedPresentation(original)
50
+
51
+ const type = isJwtEncoded ? OriginalType.JWT_ENCODED : isJwtDecoded ? OriginalType.JWT_DECODED : OriginalType.JSONLD
52
+ const format: PresentationFormat = isJwtDecoded || isJwtEncoded ? 'jwt_vp' : 'ldp_vp'
53
+ const decoded = CredentialMapper.decodeVerifiablePresentation(original)
54
+ const vp: IPresentation =
55
+ isJwtEncoded || isJwtDecoded
56
+ ? CredentialMapper.jwtDecodedPresentationToUniformPresentation(decoded as JwtDecodedVerifiablePresentation, false, opts)
57
+ : (decoded as IPresentation)
58
+ const vcs: WrappedVerifiableCredential[] = CredentialMapper.toWrappedVerifiableCredentials(vp.verifiableCredential, opts)
59
+
60
+ // todo: We probably want to add proofs as well
61
+ return {
62
+ type,
63
+ format,
64
+ original,
65
+ decoded,
66
+ presentation: {
67
+ ...vp,
68
+ verifiableCredential: vcs, // We overwrite the credentials with wrapped versions, making it an InternalVerifiablePresentation. Note: we keep the singular key name of the vc data model
69
+ },
70
+ vcs,
71
+ }
72
+ }
73
+
74
+ static toWrappedVerifiableCredentials(
75
+ verifiableCredentials: OriginalVerifiableCredential[],
76
+ opts?: { maxTimeSkewInMS?: number }
77
+ ): WrappedVerifiableCredential[] {
78
+ return verifiableCredentials.map((vc) => CredentialMapper.toWrappedVerifiableCredential(vc, opts))
79
+ }
80
+
81
+ static toWrappedVerifiableCredential(
82
+ verifiableCredential: OriginalVerifiableCredential,
83
+ opts?: { maxTimeSkewInMS?: number }
84
+ ): WrappedVerifiableCredential {
85
+ const original = verifiableCredential
86
+
87
+ const decoded = CredentialMapper.decodeVerifiableCredential(verifiableCredential)
88
+
89
+ const isJwtEncoded = CredentialMapper.isJwtEncoded(original)
90
+ const isJwtDecoded = CredentialMapper.isJwtDecodedCredential(original)
91
+ const type = isJwtEncoded ? OriginalType.JWT_ENCODED : isJwtDecoded ? OriginalType.JWT_DECODED : OriginalType.JSONLD
92
+
93
+ const credential =
94
+ isJwtDecoded || isJwtDecoded
95
+ ? CredentialMapper.jwtDecodedCredentialToUniformCredential(decoded as JwtDecodedVerifiableCredential, opts)
96
+ : (decoded as ICredential)
97
+ const format = isJwtDecoded || isJwtDecoded ? 'jwt_vc' : 'ldp_vc'
98
+ //todo: We probably want to add proofs as well
99
+ return {
100
+ original,
101
+ decoded,
102
+ format,
103
+ type,
104
+ credential,
105
+ }
106
+ }
107
+
108
+ public static isJwtEncoded(original: OriginalVerifiableCredential | OriginalVerifiablePresentation) {
109
+ return ObjectUtils.isString(original) && (original as string).startsWith('ey')
110
+ }
111
+
112
+ private static isJsonLdString(original: OriginalVerifiableCredential | OriginalVerifiablePresentation) {
113
+ return ObjectUtils.isString(original) && (original as string).includes('@context')
114
+ }
115
+
116
+ public static isJwtDecodedCredential(original: OriginalVerifiableCredential): boolean {
117
+ return (<JwtDecodedVerifiableCredential>original)['vc'] !== undefined && (<JwtDecodedVerifiableCredential>original)['iss'] !== undefined
118
+ }
119
+
120
+ public static isJwtDecodedPresentation(original: OriginalVerifiablePresentation): boolean {
121
+ return (<JwtDecodedVerifiablePresentation>original)['vp'] !== undefined && (<JwtDecodedVerifiablePresentation>original)['iss'] !== undefined
122
+ }
123
+
124
+ static jwtEncodedPresentationToUniformPresentation(
125
+ jwt: string,
126
+ makeCredentialsUniform: boolean = true,
127
+ opts?: { maxTimeSkewInMS?: number }
128
+ ): IPresentation {
129
+ return CredentialMapper.jwtDecodedPresentationToUniformPresentation(jwt_decode(jwt), makeCredentialsUniform, opts)
130
+ }
131
+
132
+ static jwtDecodedPresentationToUniformPresentation(
133
+ decoded: JwtDecodedVerifiablePresentation,
134
+ makeCredentialsUniform: boolean = true,
135
+ opts?: { maxTimeSkewInMS?: number }
136
+ ): IPresentation {
137
+ const presentation: IPresentation = {
138
+ ...(decoded.vp as IPresentation),
139
+ }
140
+ if (makeCredentialsUniform) {
141
+ presentation.verifiableCredential = decoded.vp.verifiableCredential.map((vc) =>
142
+ CredentialMapper.toUniformCredential(vc, opts)
143
+ ) as IVerifiableCredential[] // We cast it because we IPresentation needs a VC. The internal Credential doesn't have the required Proof anymore (that is intended)
144
+ }
145
+ // Since this is a presentation, we delete any proof just to be sure (should not occur on JWT, but better safe than sorry)
146
+ delete presentation.proof
147
+
148
+ if (decoded.iss) {
149
+ const holder = presentation.holder
150
+ if (holder) {
151
+ if (holder !== decoded.iss) {
152
+ throw new Error(`Inconsistent holders between JWT claim (${decoded.iss}) and VC value (${holder})`)
153
+ }
154
+ }
155
+ presentation.holder = decoded.iss
156
+ }
157
+ if (decoded.jti) {
158
+ const id = presentation.id
159
+ if (id && id !== decoded.jti) {
160
+ throw new Error(`Inconsistent VP ids between JWT claim (${decoded.jti}) and VP value (${id})`)
161
+ }
162
+ presentation.id = decoded.jti
163
+ }
164
+ return presentation
165
+ }
166
+
167
+ static toUniformCredential(verifiableCredential: OriginalVerifiableCredential, opts?: { maxTimeSkewInMS?: number }): ICredential {
168
+ const original = verifiableCredential
169
+ const decoded = CredentialMapper.decodeVerifiableCredential(verifiableCredential)
170
+
171
+ const isJwtEncoded: boolean = CredentialMapper.isJwtEncoded(original)
172
+ const isJwtDecoded: boolean = CredentialMapper.isJwtDecodedCredential(original)
173
+
174
+ if (isJwtDecoded || isJwtEncoded) {
175
+ return CredentialMapper.jwtDecodedCredentialToUniformCredential(decoded as JwtDecodedVerifiableCredential, opts)
176
+ } else {
177
+ return decoded as ICredential
178
+ }
179
+ }
180
+
181
+ static toUniformPresentation(presentation: OriginalVerifiablePresentation, opts?: { maxTimeSkewInMS?: number }): IPresentation {
182
+ const original = presentation
183
+ const decoded = CredentialMapper.decodeVerifiablePresentation(original)
184
+ const isJwtEncoded: boolean = CredentialMapper.isJwtEncoded(original)
185
+ const isJwtDecoded: boolean = CredentialMapper.isJwtDecodedPresentation(original)
186
+ const uniformPresentation =
187
+ isJwtEncoded || isJwtDecoded
188
+ ? CredentialMapper.jwtDecodedPresentationToUniformPresentation(decoded as JwtDecodedVerifiablePresentation, false)
189
+ : (decoded as IPresentation)
190
+ uniformPresentation.verifiableCredential = uniformPresentation.verifiableCredential?.map((vc) =>
191
+ CredentialMapper.toUniformCredential(vc, opts)
192
+ ) as IVerifiableCredential[] // We cast it because we IPresentation needs a VC. The internal Credential doesn't have the required Proof anymore (that is intended)
193
+ return uniformPresentation
194
+ }
195
+
196
+ static jwtEncodedCredentialToUniformCredential(jwt: string, opts?: { maxTimeSkewInMS?: number }): ICredential {
197
+ return CredentialMapper.jwtDecodedCredentialToUniformCredential(jwt_decode(jwt), opts)
198
+ }
199
+
200
+ static jwtDecodedCredentialToUniformCredential(decoded: JwtDecodedVerifiableCredential, opts?: { maxTimeSkewInMS?: number }): ICredential {
201
+ const credential: ICredential = {
202
+ ...(decoded.vc as ICredential),
203
+ }
204
+ // Since this is a credential, we delete any proof just to be sure (should not occur on JWT, but better safe than sorry)
205
+ delete credential.proof
206
+
207
+ const maxSkewInMS = opts?.maxTimeSkewInMS !== undefined ? opts.maxTimeSkewInMS : 999
208
+
209
+ if (decoded.exp) {
210
+ const expDate = credential.expirationDate
211
+ const jwtExp = parseInt(decoded.exp.toString())
212
+ // fix seconds to millisecs for the date
213
+ const expDateAsStr = jwtExp < 9999999999 ? new Date(jwtExp * 1000).toISOString().replace(/\.000Z/, 'Z') : new Date(jwtExp).toISOString()
214
+ if (expDate && expDate !== expDateAsStr) {
215
+ const diff = Math.abs(new Date(expDateAsStr).getTime() - new Date(expDate).getTime())
216
+ if (!maxSkewInMS || diff > maxSkewInMS) {
217
+ throw new Error(`Inconsistent expiration dates between JWT claim (${expDateAsStr}) and VC value (${expDate})`)
218
+ }
219
+ }
220
+ credential.expirationDate = expDateAsStr
221
+ }
222
+
223
+ if (decoded.nbf) {
224
+ const issuanceDate = credential.issuanceDate
225
+ const jwtNbf = parseInt(decoded.nbf.toString())
226
+ // fix seconds to millisecs for the date
227
+ const nbfDateAsStr = jwtNbf < 9999999999 ? new Date(jwtNbf * 1000).toISOString().replace(/\.000Z/, 'Z') : new Date(jwtNbf).toISOString()
228
+ if (issuanceDate && issuanceDate !== nbfDateAsStr) {
229
+ const diff = Math.abs(new Date(nbfDateAsStr).getTime() - new Date(issuanceDate).getTime())
230
+ if (!maxSkewInMS || diff > maxSkewInMS) {
231
+ throw new Error(`Inconsistent issuance dates between JWT claim (${nbfDateAsStr}) and VC value (${issuanceDate})`)
232
+ }
233
+ }
234
+ credential.issuanceDate = nbfDateAsStr
235
+ }
236
+
237
+ if (decoded.iss) {
238
+ const issuer = credential.issuer
239
+ if (issuer) {
240
+ if (typeof issuer === 'string') {
241
+ if (issuer !== decoded.iss) {
242
+ throw new Error(`Inconsistent issuers between JWT claim (${decoded.iss}) and VC value (${issuer})`)
243
+ }
244
+ } else {
245
+ if (issuer.id !== decoded.iss) {
246
+ throw new Error(`Inconsistent issuers between JWT claim (${decoded.iss}) and VC value (${issuer.id})`)
247
+ }
248
+ }
249
+ } else {
250
+ credential.issuer = decoded.iss
251
+ }
252
+ }
253
+
254
+ if (decoded.sub) {
255
+ const subjects = Array.isArray(credential.credentialSubject) ? credential.credentialSubject : [credential.credentialSubject]
256
+ for (let i = 0; i < subjects.length; i++) {
257
+ const csId = subjects[i].id
258
+ if (csId && csId !== decoded.sub) {
259
+ throw new Error(`Inconsistent credential subject ids between JWT claim (${decoded.sub}) and VC value (${csId})`)
260
+ }
261
+ Array.isArray(credential.credentialSubject)
262
+ ? (credential.credentialSubject[i].id = decoded.sub)
263
+ : (credential.credentialSubject.id = decoded.sub)
264
+ }
265
+ }
266
+ if (decoded.jti) {
267
+ const id = credential.id
268
+ if (id && id !== decoded.jti) {
269
+ throw new Error(`Inconsistent credential ids between JWT claim (${decoded.jti}) and VC value (${id})`)
270
+ }
271
+ credential.id = decoded.jti
272
+ }
273
+ return credential
274
+ }
275
+ }
@@ -0,0 +1 @@
1
+ export * from './credential-mapper'
package/src/types/did.ts CHANGED
@@ -33,3 +33,51 @@ export interface IParsedDID {
33
33
  [index: string]: string
34
34
  }
35
35
  }
36
+
37
+ export const parseDid = (did: string): IParsedDID => {
38
+ const parsedDid = parse(did)
39
+ if (parsedDid === null) {
40
+ throw new Error('invalid did')
41
+ }
42
+
43
+ return parsedDid
44
+ }
45
+
46
+ const parse = (didUrl: string): IParsedDID | null => {
47
+ const PCT_ENCODED = '(?:%[0-9a-fA-F]{2})'
48
+ const ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`
49
+ const METHOD = '([a-z0-9]+)'
50
+ const METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`
51
+ const PARAM_CHAR = '[a-zA-Z0-9_.:%-]'
52
+ const PARAM = `;${PARAM_CHAR}+=${PARAM_CHAR}*`
53
+ const PARAMS = `((${PARAM})*)`
54
+ const PATH = `(/[^#?]*)?`
55
+ const QUERY = `([?][^#]*)?`
56
+ const FRAGMENT = `(#.*)?`
57
+ const DID_MATCHER = new RegExp(`^did:${METHOD}:${METHOD_ID}${PARAMS}${PATH}${QUERY}${FRAGMENT}$`)
58
+
59
+ if (didUrl === '' || !didUrl) return null
60
+ const sections = didUrl.match(DID_MATCHER)
61
+ if (sections) {
62
+ const parts: IParsedDID = {
63
+ did: `did:${sections[1]}:${sections[2]}`,
64
+ method: sections[1],
65
+ id: sections[2],
66
+ didUrl,
67
+ }
68
+ if (sections[4]) {
69
+ const params = sections[4].slice(1).split(';')
70
+ parts.params = {}
71
+ for (const p of params) {
72
+ const kv = p.split('=')
73
+ parts.params[kv[0]] = kv[1]
74
+ }
75
+ }
76
+ if (sections[6]) parts.path = sections[6]
77
+ if (sections[7]) parts.query = sections[7].slice(1)
78
+ if (sections[8]) parts.fragment = sections[8].slice(1)
79
+ return parts
80
+ }
81
+
82
+ return null
83
+ }
package/src/types/pex.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * It express how the inputs presented as proofs to a Verifier.
2
+ * It expresses how the inputs are presented as proofs to a Verifier.
3
3
  */
4
4
  export interface PresentationSubmission {
5
5
  /**
@@ -16,18 +16,6 @@ export interface PresentationSubmission {
16
16
  descriptor_map: Array<Descriptor>
17
17
  }
18
18
 
19
- /**
20
- * Presentation Echange API
21
- * Presentation Exchange API
22
- *
23
- * The version of the OpenAPI document: 1.1.0
24
- *
25
- *
26
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
27
- * https://openapi-generator.tech
28
- * Do not edit the class manually.
29
- */
30
-
31
19
  /**
32
20
  * descriptor map laying out the structure of the presentation submission.
33
21
  */