@sphereon/ssi-sdk.credential-store 0.29.0 → 0.29.1-next.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/CredentialStore.d.ts +2 -0
- package/dist/agent/CredentialStore.d.ts.map +1 -1
- package/dist/agent/CredentialStore.js +21 -7
- package/dist/agent/CredentialStore.js.map +1 -1
- package/dist/ssi-sdk.credential-store.d.ts +17 -5
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types/ICredentialStore.d.ts +14 -7
- package/dist/types/ICredentialStore.d.ts.map +1 -1
- package/dist/types/ICredentialStore.js +11 -0
- package/dist/types/ICredentialStore.js.map +1 -1
- package/package.json +5 -5
- package/plugin.schema.json +49 -11
- package/src/agent/CredentialStore.ts +19 -7
- package/src/types/ICredentialStore.ts +29 -8
|
@@ -39,6 +39,8 @@ export declare class CredentialStore implements IAgentPlugin {
|
|
|
39
39
|
* @param args
|
|
40
40
|
*/
|
|
41
41
|
private crsGetCredentialsByClaimsCount;
|
|
42
|
+
private secureParse;
|
|
42
43
|
private toUniqueCredentials;
|
|
44
|
+
private generateDigest;
|
|
43
45
|
}
|
|
44
46
|
//# sourceMappingURL=CredentialStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialStore.d.ts","sourceRoot":"","sources":["../../src/agent/CredentialStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"CredentialStore.d.ts","sourceRoot":"","sources":["../../src/agent/CredentialStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAUL,gBAAgB,EAMjB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,8BAA8B,EAAgD,MAAM,8BAA8B,CAAA;AAG3H,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,MAAM,CAWhD,CAAA;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,YAAY;IAClD,QAAQ,CAAC,MAAM,MAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAWjC;IAED,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgC;gBAE1C,OAAO,EAAE;QAAE,KAAK,EAAE,8BAA8B,CAAA;KAAE;IAI9D,gDAAgD;YAClC,gBAAgB;IAI9B,qDAAqD;YACvC,wBAAwB;IAItC,gDAAgD;YAClC,gBAAgB;IAM9B,iDAAiD;YACnC,iBAAiB;IAM/B,gEAAgE;YAClD,gCAAgC;IAU9C,uDAAuD;YACzC,uBAAuB;IAKrC,mDAAmD;YACrC,mBAAmB;IAIjC,oDAAoD;YACtC,oBAAoB;IAYlC;;;OAGG;YACW,yBAAyB;IA8DvC,OAAO,CAAC,sBAAsB;IA2B9B;;;OAGG;YACW,8BAA8B;IAK5C,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,mBAAmB;IAqC3B,OAAO,CAAC,cAAc,CAErB;CACF"}
|
|
@@ -8,8 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.CredentialStore = exports.credentialStoreMethods = void 0;
|
|
16
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
13
17
|
const index_1 = require("../index");
|
|
14
18
|
// Exposing the methods here for any REST implementation
|
|
15
19
|
exports.credentialStoreMethods = [
|
|
@@ -42,12 +46,16 @@ class CredentialStore {
|
|
|
42
46
|
crsGetCredentialsByClaims: this.crsGetCredentialsByClaims.bind(this),
|
|
43
47
|
crsGetCredentialsByClaimsCount: this.crsGetCredentialsByClaimsCount.bind(this),
|
|
44
48
|
};
|
|
49
|
+
this.generateDigest = (data, algorithm) => {
|
|
50
|
+
return new Uint8Array(crypto_1.default.createHash(algorithm).update(data).digest());
|
|
51
|
+
};
|
|
45
52
|
this.store = options.store;
|
|
46
53
|
}
|
|
47
54
|
/** {@inheritDoc ICRManager.crmAddCredential} */
|
|
48
55
|
crsAddCredential(args) {
|
|
49
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
|
|
57
|
+
var _a, _b;
|
|
58
|
+
return yield this.store.addCredential(Object.assign(Object.assign({}, args.credential), { opts: Object.assign(Object.assign({}, args.opts), { hasher: (_b = (_a = args.opts) === null || _a === void 0 ? void 0 : _a.hasher) !== null && _b !== void 0 ? _b : this.generateDigest }) }));
|
|
51
59
|
});
|
|
52
60
|
}
|
|
53
61
|
/** {@inheritDoc ICRManager.updateCredentialState} */
|
|
@@ -211,6 +219,12 @@ class CredentialStore {
|
|
|
211
219
|
return credentialsByClaims.length; // FIXME ?
|
|
212
220
|
});
|
|
213
221
|
}
|
|
222
|
+
secureParse(original) {
|
|
223
|
+
if (original.includes('~')) {
|
|
224
|
+
return original;
|
|
225
|
+
}
|
|
226
|
+
return JSON.parse(original);
|
|
227
|
+
}
|
|
214
228
|
toUniqueCredentials(credentials) {
|
|
215
229
|
return Object.values(credentials.reduce((accumulator, credential) => {
|
|
216
230
|
var _a, _b, _c, _d;
|
|
@@ -220,21 +234,21 @@ class CredentialStore {
|
|
|
220
234
|
};
|
|
221
235
|
switch (credential.documentType) {
|
|
222
236
|
case index_1.DocumentType.VC:
|
|
223
|
-
uniqueCredential.originalVerifiableCredential =
|
|
224
|
-
uniqueCredential.uniformVerifiableCredential =
|
|
237
|
+
uniqueCredential.originalVerifiableCredential = this.secureParse(credential.rawDocument);
|
|
238
|
+
uniqueCredential.uniformVerifiableCredential = this.secureParse(credential.uniformDocument);
|
|
225
239
|
uniqueCredential.id = (_a = uniqueCredential.uniformVerifiableCredential) === null || _a === void 0 ? void 0 : _a.id;
|
|
226
240
|
break;
|
|
227
241
|
case index_1.DocumentType.VP:
|
|
228
|
-
uniqueCredential.originalVerifiablePresentation =
|
|
229
|
-
uniqueCredential.uniformVerifiablePresentation =
|
|
242
|
+
uniqueCredential.originalVerifiablePresentation = this.secureParse(credential.rawDocument);
|
|
243
|
+
uniqueCredential.uniformVerifiablePresentation = this.secureParse(credential.uniformDocument);
|
|
230
244
|
uniqueCredential.id = (_b = uniqueCredential.uniformVerifiablePresentation) === null || _b === void 0 ? void 0 : _b.id;
|
|
231
245
|
break;
|
|
232
246
|
case index_1.DocumentType.P:
|
|
233
|
-
uniqueCredential.originalPresentation =
|
|
247
|
+
uniqueCredential.originalPresentation = this.secureParse(credential.rawDocument);
|
|
234
248
|
uniqueCredential.id = (_c = uniqueCredential.originalPresentation) === null || _c === void 0 ? void 0 : _c.id;
|
|
235
249
|
break;
|
|
236
250
|
case index_1.DocumentType.C:
|
|
237
|
-
uniqueCredential.originalCredential =
|
|
251
|
+
uniqueCredential.originalCredential = this.secureParse(credential.rawDocument);
|
|
238
252
|
uniqueCredential.id = (_d = uniqueCredential.originalCredential) === null || _d === void 0 ? void 0 : _d.id;
|
|
239
253
|
break;
|
|
240
254
|
// TODO CBOR support
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialStore.js","sourceRoot":"","sources":["../../src/agent/CredentialStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CredentialStore.js","sourceRoot":"","sources":["../../src/agent/CredentialStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAA2B;AAC3B,oCAgBiB;AAGjB,wDAAwD;AAC3C,QAAA,sBAAsB,GAAkB;IACnD,kBAAkB;IAClB,0BAA0B;IAC1B,kBAAkB;IAClB,mBAAmB;IACnB,qBAAqB;IACrB,sBAAsB;IACtB,yBAAyB;IACzB,kCAAkC;IAClC,2BAA2B;IAC3B,gCAAgC;CACjC,CAAA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,gBAAgB,CAAC,kBAAkB,0CAAE,EAAE,CAAA;oBAC7D,MAAK;gBACP,oBAAoB;YACtB,CAAC;YACD,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAA;YAC/C,OAAO,WAAW,CAAA;QACpB,CAAC,EACD,EAA6C,CAC9C,CACF,CAAA;IACH,CAAC;CAKF;AArOD,0CAqOC"}
|
|
@@ -6,7 +6,7 @@ import { CredentialStateType } from '@sphereon/ssi-sdk.data-store';
|
|
|
6
6
|
import { DigitalCredential } from '@sphereon/ssi-sdk.data-store';
|
|
7
7
|
import { DocumentType as DocumentType_2 } from '@sphereon/ssi-sdk.data-store';
|
|
8
8
|
import { FindDigitalCredentialArgs } from '@sphereon/ssi-sdk.data-store';
|
|
9
|
-
import {
|
|
9
|
+
import { Hasher } from '@sphereon/ssi-types';
|
|
10
10
|
import { IAgentContext } from '@veramo/core';
|
|
11
11
|
import { IAgentPlugin } from '@veramo/core';
|
|
12
12
|
import { ICredential } from '@sphereon/ssi-types';
|
|
@@ -14,17 +14,28 @@ import { IPluginMethodMap } from '@veramo/core';
|
|
|
14
14
|
import { IPresentation } from '@sphereon/ssi-types';
|
|
15
15
|
import { ISimpleLogger } from '@sphereon/ssi-types';
|
|
16
16
|
import { IVerifiableCredential } from '@sphereon/ssi-types';
|
|
17
|
-
import { NonPersistedDigitalCredential } from '@sphereon/ssi-sdk.data-store
|
|
17
|
+
import { NonPersistedDigitalCredential } from '@sphereon/ssi-sdk.data-store';
|
|
18
18
|
import { OriginalVerifiableCredential } from '@sphereon/ssi-types';
|
|
19
19
|
import { OriginalVerifiablePresentation } from '@sphereon/ssi-types';
|
|
20
20
|
import { UpdateCredentialStateArgs } from '@sphereon/ssi-sdk.data-store';
|
|
21
21
|
|
|
22
22
|
export declare type AddCredentialArgs = {
|
|
23
23
|
credential: AddDigitalCredential;
|
|
24
|
+
opts?: {
|
|
25
|
+
maxTimeSkewInMS?: number;
|
|
26
|
+
hasher?: Hasher;
|
|
27
|
+
};
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
export declare type AddDigitalCredential = Omit<NonPersistedDigitalCredential, 'id' | 'documentType' | 'documentFormat' | 'uniformDocument' | 'hash' | 'createdAt' | 'lastUpdatedAt' | 'validFrom' | 'validUntil'>;
|
|
27
31
|
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param context
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare function contextHasCredentialStore(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialStore>;
|
|
38
|
+
|
|
28
39
|
export { CredentialCorrelationType }
|
|
29
40
|
|
|
30
41
|
export { CredentialDocumentFormat }
|
|
@@ -79,7 +90,9 @@ export declare class CredentialStore implements IAgentPlugin {
|
|
|
79
90
|
* @param args
|
|
80
91
|
*/
|
|
81
92
|
private crsGetCredentialsByClaimsCount;
|
|
93
|
+
private secureParse;
|
|
82
94
|
private toUniqueCredentials;
|
|
95
|
+
private generateDigest;
|
|
83
96
|
}
|
|
84
97
|
|
|
85
98
|
export declare const credentialStoreMethods: Array<string>;
|
|
@@ -125,7 +138,7 @@ export declare type GetCredentialArgs = {
|
|
|
125
138
|
};
|
|
126
139
|
|
|
127
140
|
export declare type GetCredentialsArgs = {
|
|
128
|
-
filter:
|
|
141
|
+
filter: FindDigitalCredentialArgs;
|
|
129
142
|
};
|
|
130
143
|
|
|
131
144
|
export declare type GetCredentialsByClaimsArgs = {
|
|
@@ -167,8 +180,7 @@ export declare interface ICredentialStore extends IPluginMethodMap {
|
|
|
167
180
|
crsGetUniqueCredentials(args: GetCredentialsArgs): Promise<Array<UniqueDigitalCredential>>;
|
|
168
181
|
/**
|
|
169
182
|
* Find one credential by id or hash
|
|
170
|
-
* @param
|
|
171
|
-
* @param idOrHash
|
|
183
|
+
* @param args
|
|
172
184
|
*/
|
|
173
185
|
crsGetUniqueCredentialByIdOrHash(args: GetCredentialsByIdOrHashArgs): Promise<OptionalUniqueDigitalCredential>;
|
|
174
186
|
/**
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { CredentialRole, DigitalCredential, FindDigitalCredentialArgs, NonPersistedDigitalCredential, UpdateCredentialStateArgs } from '@sphereon/ssi-sdk.data-store';
|
|
2
|
+
import { Hasher, ICredential, IPresentation, IVerifiableCredential, OriginalVerifiableCredential, OriginalVerifiablePresentation } from '@sphereon/ssi-types';
|
|
1
3
|
import { IAgentContext, IPluginMethodMap } from '@veramo/core';
|
|
2
|
-
import { CredentialRole, DigitalCredential, UpdateCredentialStateArgs } from '@sphereon/ssi-sdk.data-store';
|
|
3
|
-
import { FindDigitalCredentialArgs } from '@sphereon/ssi-sdk.data-store/dist/types/digitalCredential/IAbstractDigitalCredentialStore';
|
|
4
|
-
import { NonPersistedDigitalCredential } from '@sphereon/ssi-sdk.data-store/dist/types/digitalCredential/digitalCredential';
|
|
5
4
|
import { FindClaimsArgs } from './claims';
|
|
6
|
-
|
|
5
|
+
export type { UpdateCredentialStateArgs };
|
|
7
6
|
export interface ICredentialStore extends IPluginMethodMap {
|
|
8
7
|
/**
|
|
9
8
|
* Add a new credential.
|
|
@@ -32,8 +31,7 @@ export interface ICredentialStore extends IPluginMethodMap {
|
|
|
32
31
|
crsGetUniqueCredentials(args: GetCredentialsArgs): Promise<Array<UniqueDigitalCredential>>;
|
|
33
32
|
/**
|
|
34
33
|
* Find one credential by id or hash
|
|
35
|
-
* @param
|
|
36
|
-
* @param idOrHash
|
|
34
|
+
* @param args
|
|
37
35
|
*/
|
|
38
36
|
crsGetUniqueCredentialByIdOrHash(args: GetCredentialsByIdOrHashArgs): Promise<OptionalUniqueDigitalCredential>;
|
|
39
37
|
/**
|
|
@@ -57,6 +55,12 @@ export interface ICredentialStore extends IPluginMethodMap {
|
|
|
57
55
|
*/
|
|
58
56
|
crsDeleteCredentials(args: DeleteCredentialsArgs): Promise<number>;
|
|
59
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param context
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare function contextHasCredentialStore(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialStore>;
|
|
60
64
|
export type GetCredentialArgs = {
|
|
61
65
|
id: string;
|
|
62
66
|
};
|
|
@@ -81,8 +85,11 @@ export type DeleteCredentialsArgs = GetCredentialsArgs;
|
|
|
81
85
|
export type AddDigitalCredential = Omit<NonPersistedDigitalCredential, 'id' | 'documentType' | 'documentFormat' | 'uniformDocument' | 'hash' | 'createdAt' | 'lastUpdatedAt' | 'validFrom' | 'validUntil'>;
|
|
82
86
|
export type AddCredentialArgs = {
|
|
83
87
|
credential: AddDigitalCredential;
|
|
88
|
+
opts?: {
|
|
89
|
+
maxTimeSkewInMS?: number;
|
|
90
|
+
hasher?: Hasher;
|
|
91
|
+
};
|
|
84
92
|
};
|
|
85
|
-
export type { UpdateCredentialStateArgs } from '@sphereon/ssi-sdk.data-store';
|
|
86
93
|
export interface UniqueDigitalCredential {
|
|
87
94
|
hash: string;
|
|
88
95
|
id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICredentialStore.d.ts","sourceRoot":"","sources":["../../src/types/ICredentialStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ICredentialStore.d.ts","sourceRoot":"","sources":["../../src/types/ICredentialStore.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,yBAAyB,EAC1B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,4BAA4B,EAC5B,8BAA8B,EAC/B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAEzC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6BAA6B,CAAC,EAAE,qBAAqB,CAAA;CACtD;AAED,MAAM,MAAM,+BAA+B,GAAG,uBAAuB,GAAG,SAAS,CAAA;AAEjF,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contextHasCredentialStore = void 0;
|
|
4
|
+
const ssi_sdk_agent_config_1 = require("@sphereon/ssi-sdk.agent-config");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param context
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
function contextHasCredentialStore(context) {
|
|
11
|
+
return (0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'crsGetCredential');
|
|
12
|
+
}
|
|
13
|
+
exports.contextHasCredentialStore = contextHasCredentialStore;
|
|
3
14
|
//# sourceMappingURL=ICredentialStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICredentialStore.js","sourceRoot":"","sources":["../../src/types/ICredentialStore.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ICredentialStore.js","sourceRoot":"","sources":["../../src/types/ICredentialStore.ts"],"names":[],"mappings":";;;AAAA,yEAAiE;AAmFjE;;;;GAIG;AACH,SAAgB,yBAAyB,CAAC,OAAwC;IAChF,OAAO,IAAA,uCAAgB,EAAC,OAAO,EAAE,kBAAkB,CAAC,CAAA;AACtD,CAAC;AAFD,8DAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.credential-store",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.1-next.104+f55b05ba",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@sphereon/pex": "^4.0.1",
|
|
19
19
|
"@sphereon/pex-models": "^2.2.4",
|
|
20
|
-
"@sphereon/ssi-sdk.data-store": "0.29.
|
|
20
|
+
"@sphereon/ssi-sdk.data-store": "0.29.1-next.104+f55b05ba",
|
|
21
21
|
"cross-fetch": "^3.1.8",
|
|
22
22
|
"debug": "^4.3.4",
|
|
23
23
|
"typeorm": "^0.3.20",
|
|
24
24
|
"uuid": "^9.0.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@sphereon/ssi-sdk.agent-config": "0.29.
|
|
28
|
-
"@sphereon/ssi-types": "0.29.
|
|
27
|
+
"@sphereon/ssi-sdk.agent-config": "0.29.1-next.104+f55b05ba",
|
|
28
|
+
"@sphereon/ssi-types": "0.29.1-next.104+f55b05ba",
|
|
29
29
|
"@types/uuid": "^9.0.8",
|
|
30
30
|
"@veramo/remote-client": "4.2.0",
|
|
31
31
|
"@veramo/remote-server": "4.2.0"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"Veramo",
|
|
51
51
|
"Credential Manager"
|
|
52
52
|
],
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "f55b05baa77e2a8acb72d5e74f3db710ef898958"
|
|
54
54
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
"properties": {
|
|
8
8
|
"credential": {
|
|
9
9
|
"$ref": "#/components/schemas/AddDigitalCredential"
|
|
10
|
+
},
|
|
11
|
+
"opts": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {
|
|
14
|
+
"maxTimeSkewInMS": {
|
|
15
|
+
"type": "number"
|
|
16
|
+
},
|
|
17
|
+
"hasher": {
|
|
18
|
+
"$ref": "#/components/schemas/Hasher"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
10
21
|
}
|
|
11
22
|
},
|
|
12
23
|
"required": [
|
|
@@ -69,7 +80,11 @@
|
|
|
69
80
|
},
|
|
70
81
|
"CredentialCorrelationType": {
|
|
71
82
|
"type": "string",
|
|
72
|
-
"
|
|
83
|
+
"enum": [
|
|
84
|
+
"DID",
|
|
85
|
+
"X509_CN",
|
|
86
|
+
"URL"
|
|
87
|
+
]
|
|
73
88
|
},
|
|
74
89
|
"CredentialStateType": {
|
|
75
90
|
"type": "string",
|
|
@@ -79,6 +94,28 @@
|
|
|
79
94
|
"EXPIRED"
|
|
80
95
|
]
|
|
81
96
|
},
|
|
97
|
+
"Hasher": {
|
|
98
|
+
"$comment": "(data: string, alg: string) => Uint8Array",
|
|
99
|
+
"type": "object",
|
|
100
|
+
"properties": {
|
|
101
|
+
"namedArgs": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"properties": {
|
|
104
|
+
"data": {
|
|
105
|
+
"type": "string"
|
|
106
|
+
},
|
|
107
|
+
"alg": {
|
|
108
|
+
"type": "string"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"required": [
|
|
112
|
+
"data",
|
|
113
|
+
"alg"
|
|
114
|
+
],
|
|
115
|
+
"additionalProperties": false
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
82
119
|
"DigitalCredential": {
|
|
83
120
|
"type": "object",
|
|
84
121
|
"properties": {
|
|
@@ -667,7 +704,8 @@
|
|
|
667
704
|
"JcsEd25519Signature2020",
|
|
668
705
|
"BbsBlsSignatureProof2020",
|
|
669
706
|
"BbsBlsBoundSignatureProof2020",
|
|
670
|
-
"JwtProof2020"
|
|
707
|
+
"JwtProof2020",
|
|
708
|
+
"SdJwtProof2024"
|
|
671
709
|
]
|
|
672
710
|
},
|
|
673
711
|
"IProofPurpose": {
|
|
@@ -980,7 +1018,7 @@
|
|
|
980
1018
|
"additionalProperties": {
|
|
981
1019
|
"anyOf": [
|
|
982
1020
|
{
|
|
983
|
-
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-
|
|
1021
|
+
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797"
|
|
984
1022
|
},
|
|
985
1023
|
{
|
|
986
1024
|
"not": {}
|
|
@@ -991,7 +1029,7 @@
|
|
|
991
1029
|
{
|
|
992
1030
|
"type": "array",
|
|
993
1031
|
"items": {
|
|
994
|
-
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-
|
|
1032
|
+
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797"
|
|
995
1033
|
}
|
|
996
1034
|
}
|
|
997
1035
|
]
|
|
@@ -1022,7 +1060,7 @@
|
|
|
1022
1060
|
"additionalProperties": {
|
|
1023
1061
|
"anyOf": [
|
|
1024
1062
|
{
|
|
1025
|
-
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-
|
|
1063
|
+
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797"
|
|
1026
1064
|
},
|
|
1027
1065
|
{
|
|
1028
1066
|
"not": {}
|
|
@@ -1033,7 +1071,7 @@
|
|
|
1033
1071
|
{
|
|
1034
1072
|
"type": "array",
|
|
1035
1073
|
"items": {
|
|
1036
|
-
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-
|
|
1074
|
+
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797"
|
|
1037
1075
|
}
|
|
1038
1076
|
}
|
|
1039
1077
|
]
|
|
@@ -1043,7 +1081,7 @@
|
|
|
1043
1081
|
}
|
|
1044
1082
|
]
|
|
1045
1083
|
},
|
|
1046
|
-
"alias-pes_sd-jwt-vc.d.ts-
|
|
1084
|
+
"alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797": {
|
|
1047
1085
|
"anyOf": [
|
|
1048
1086
|
{
|
|
1049
1087
|
"type": "string"
|
|
@@ -1059,7 +1097,7 @@
|
|
|
1059
1097
|
"additionalProperties": {
|
|
1060
1098
|
"anyOf": [
|
|
1061
1099
|
{
|
|
1062
|
-
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-
|
|
1100
|
+
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797"
|
|
1063
1101
|
},
|
|
1064
1102
|
{
|
|
1065
1103
|
"not": {}
|
|
@@ -1070,7 +1108,7 @@
|
|
|
1070
1108
|
{
|
|
1071
1109
|
"type": "array",
|
|
1072
1110
|
"items": {
|
|
1073
|
-
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-
|
|
1111
|
+
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797"
|
|
1074
1112
|
}
|
|
1075
1113
|
}
|
|
1076
1114
|
]
|
|
@@ -1142,7 +1180,7 @@
|
|
|
1142
1180
|
"additionalProperties": {
|
|
1143
1181
|
"anyOf": [
|
|
1144
1182
|
{
|
|
1145
|
-
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-
|
|
1183
|
+
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797"
|
|
1146
1184
|
},
|
|
1147
1185
|
{
|
|
1148
1186
|
"not": {}
|
|
@@ -1153,7 +1191,7 @@
|
|
|
1153
1191
|
{
|
|
1154
1192
|
"type": "array",
|
|
1155
1193
|
"items": {
|
|
1156
|
-
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-
|
|
1194
|
+
"$ref": "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-158-267-pes_sd-jwt-vc.d.ts-0-7797"
|
|
1157
1195
|
}
|
|
1158
1196
|
},
|
|
1159
1197
|
{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IAgentPlugin } from '@veramo/core'
|
|
2
|
+
import crypto from 'crypto'
|
|
2
3
|
import {
|
|
3
4
|
AddCredentialArgs,
|
|
4
5
|
credentialIdOrHashFilter,
|
|
@@ -58,7 +59,7 @@ export class CredentialStore implements IAgentPlugin {
|
|
|
58
59
|
|
|
59
60
|
/** {@inheritDoc ICRManager.crmAddCredential} */
|
|
60
61
|
private async crsAddCredential(args: AddCredentialArgs): Promise<DigitalCredential> {
|
|
61
|
-
return await this.store.addCredential(args.credential)
|
|
62
|
+
return await this.store.addCredential({ ...args.credential, opts: { ...args.opts, hasher: args.opts?.hasher ?? this.generateDigest } })
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
/** {@inheritDoc ICRManager.updateCredentialState} */
|
|
@@ -217,6 +218,13 @@ export class CredentialStore implements IAgentPlugin {
|
|
|
217
218
|
return credentialsByClaims.length // FIXME ?
|
|
218
219
|
}
|
|
219
220
|
|
|
221
|
+
private secureParse<Type>(original: string): Type {
|
|
222
|
+
if (original.includes('~')) {
|
|
223
|
+
return original as Type
|
|
224
|
+
}
|
|
225
|
+
return JSON.parse(original)
|
|
226
|
+
}
|
|
227
|
+
|
|
220
228
|
private toUniqueCredentials(credentials: Array<DigitalCredential>): Array<UniqueDigitalCredential> {
|
|
221
229
|
return Object.values(
|
|
222
230
|
credentials.reduce(
|
|
@@ -227,21 +235,21 @@ export class CredentialStore implements IAgentPlugin {
|
|
|
227
235
|
}
|
|
228
236
|
switch (credential.documentType) {
|
|
229
237
|
case DocumentType.VC:
|
|
230
|
-
uniqueCredential.originalVerifiableCredential =
|
|
231
|
-
uniqueCredential.uniformVerifiableCredential =
|
|
238
|
+
uniqueCredential.originalVerifiableCredential = this.secureParse(credential.rawDocument)
|
|
239
|
+
uniqueCredential.uniformVerifiableCredential = this.secureParse(credential.uniformDocument)
|
|
232
240
|
uniqueCredential.id = uniqueCredential.uniformVerifiableCredential?.id
|
|
233
241
|
break
|
|
234
242
|
case DocumentType.VP:
|
|
235
|
-
uniqueCredential.originalVerifiablePresentation =
|
|
236
|
-
uniqueCredential.uniformVerifiablePresentation =
|
|
243
|
+
uniqueCredential.originalVerifiablePresentation = this.secureParse(credential.rawDocument)
|
|
244
|
+
uniqueCredential.uniformVerifiablePresentation = this.secureParse(credential.uniformDocument)
|
|
237
245
|
uniqueCredential.id = uniqueCredential.uniformVerifiablePresentation?.id
|
|
238
246
|
break
|
|
239
247
|
case DocumentType.P:
|
|
240
|
-
uniqueCredential.originalPresentation =
|
|
248
|
+
uniqueCredential.originalPresentation = this.secureParse(credential.rawDocument)
|
|
241
249
|
uniqueCredential.id = uniqueCredential.originalPresentation?.id
|
|
242
250
|
break
|
|
243
251
|
case DocumentType.C:
|
|
244
|
-
uniqueCredential.originalCredential =
|
|
252
|
+
uniqueCredential.originalCredential = this.secureParse(credential.rawDocument)
|
|
245
253
|
uniqueCredential.id = uniqueCredential.originalCredential?.id
|
|
246
254
|
break
|
|
247
255
|
// TODO CBOR support
|
|
@@ -253,4 +261,8 @@ export class CredentialStore implements IAgentPlugin {
|
|
|
253
261
|
),
|
|
254
262
|
)
|
|
255
263
|
}
|
|
264
|
+
|
|
265
|
+
private generateDigest = (data: string, algorithm: string): Uint8Array => {
|
|
266
|
+
return new Uint8Array(crypto.createHash(algorithm).update(data).digest())
|
|
267
|
+
}
|
|
256
268
|
}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
+
import {
|
|
3
|
+
CredentialRole,
|
|
4
|
+
DigitalCredential,
|
|
5
|
+
FindDigitalCredentialArgs,
|
|
6
|
+
NonPersistedDigitalCredential,
|
|
7
|
+
UpdateCredentialStateArgs,
|
|
8
|
+
} from '@sphereon/ssi-sdk.data-store'
|
|
9
|
+
import {
|
|
10
|
+
Hasher,
|
|
11
|
+
ICredential,
|
|
12
|
+
IPresentation,
|
|
13
|
+
IVerifiableCredential,
|
|
14
|
+
OriginalVerifiableCredential,
|
|
15
|
+
OriginalVerifiablePresentation,
|
|
16
|
+
} from '@sphereon/ssi-types'
|
|
1
17
|
import { IAgentContext, IPluginMethodMap } from '@veramo/core'
|
|
2
|
-
import { CredentialRole, DigitalCredential, UpdateCredentialStateArgs } from '@sphereon/ssi-sdk.data-store'
|
|
3
|
-
import { FindDigitalCredentialArgs } from '@sphereon/ssi-sdk.data-store/dist/types/digitalCredential/IAbstractDigitalCredentialStore'
|
|
4
|
-
import { NonPersistedDigitalCredential } from '@sphereon/ssi-sdk.data-store/dist/types/digitalCredential/digitalCredential'
|
|
5
18
|
import { FindClaimsArgs } from './claims'
|
|
6
|
-
|
|
19
|
+
|
|
20
|
+
export type { UpdateCredentialStateArgs } // TODO create a local copy?
|
|
7
21
|
|
|
8
22
|
export interface ICredentialStore extends IPluginMethodMap {
|
|
9
23
|
/**
|
|
@@ -38,8 +52,7 @@ export interface ICredentialStore extends IPluginMethodMap {
|
|
|
38
52
|
|
|
39
53
|
/**
|
|
40
54
|
* Find one credential by id or hash
|
|
41
|
-
* @param
|
|
42
|
-
* @param idOrHash
|
|
55
|
+
* @param args
|
|
43
56
|
*/
|
|
44
57
|
crsGetUniqueCredentialByIdOrHash(args: GetCredentialsByIdOrHashArgs): Promise<OptionalUniqueDigitalCredential>
|
|
45
58
|
|
|
@@ -68,6 +81,15 @@ export interface ICredentialStore extends IPluginMethodMap {
|
|
|
68
81
|
crsDeleteCredentials(args: DeleteCredentialsArgs): Promise<number>
|
|
69
82
|
}
|
|
70
83
|
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @param context
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
export function contextHasCredentialStore(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialStore> {
|
|
90
|
+
return contextHasPlugin(context, 'crsGetCredential')
|
|
91
|
+
}
|
|
92
|
+
|
|
71
93
|
export type GetCredentialArgs = {
|
|
72
94
|
id: string
|
|
73
95
|
}
|
|
@@ -98,10 +120,9 @@ export type AddDigitalCredential = Omit<
|
|
|
98
120
|
|
|
99
121
|
export type AddCredentialArgs = {
|
|
100
122
|
credential: AddDigitalCredential
|
|
123
|
+
opts?: { maxTimeSkewInMS?: number; hasher?: Hasher }
|
|
101
124
|
}
|
|
102
125
|
|
|
103
|
-
export type { UpdateCredentialStateArgs } from '@sphereon/ssi-sdk.data-store' // TODO create a local copy?
|
|
104
|
-
|
|
105
126
|
export interface UniqueDigitalCredential {
|
|
106
127
|
hash: string
|
|
107
128
|
id?: string
|