@sphereon/ssi-sdk.wellknown-did-issuer 0.33.1-feature.vcdm2.4 → 0.33.1-feature.vcdm2.tsup.18
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/index.cjs +620 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +116 -0
- package/dist/index.d.ts +112 -8
- package/dist/index.js +581 -11
- package/dist/index.js.map +1 -1
- package/package.json +27 -15
- package/src/agent/WellKnownDidIssuer.ts +2 -0
- package/dist/agent/WellKnownDidIssuer.d.ts +0 -35
- package/dist/agent/WellKnownDidIssuer.d.ts.map +0 -1
- package/dist/agent/WellKnownDidIssuer.js +0 -188
- package/dist/agent/WellKnownDidIssuer.js.map +0 -1
- package/dist/entities/DidConfigurationResourceEntity.d.ts +0 -14
- package/dist/entities/DidConfigurationResourceEntity.d.ts.map +0 -1
- package/dist/entities/DidConfigurationResourceEntity.js +0 -101
- package/dist/entities/DidConfigurationResourceEntity.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/migrations/generic/1-CreateWellknownDidIssuer.d.ts +0 -7
- package/dist/migrations/generic/1-CreateWellknownDidIssuer.d.ts.map +0 -1
- package/dist/migrations/generic/1-CreateWellknownDidIssuer.js +0 -50
- package/dist/migrations/generic/1-CreateWellknownDidIssuer.js.map +0 -1
- package/dist/migrations/generic/index.d.ts +0 -10
- package/dist/migrations/generic/index.d.ts.map +0 -1
- package/dist/migrations/generic/index.js +0 -10
- package/dist/migrations/generic/index.js.map +0 -1
- package/dist/migrations/index.d.ts +0 -2
- package/dist/migrations/index.d.ts.map +0 -1
- package/dist/migrations/index.js +0 -2
- package/dist/migrations/index.js.map +0 -1
- package/dist/migrations/internal-migrations-ormconfig.d.ts +0 -7
- package/dist/migrations/internal-migrations-ormconfig.d.ts.map +0 -1
- package/dist/migrations/internal-migrations-ormconfig.js +0 -27
- package/dist/migrations/internal-migrations-ormconfig.js.map +0 -1
- package/dist/migrations/postgres/1661165115000-CreateWellknownDidIssuer.d.ts +0 -7
- package/dist/migrations/postgres/1661165115000-CreateWellknownDidIssuer.d.ts.map +0 -1
- package/dist/migrations/postgres/1661165115000-CreateWellknownDidIssuer.js +0 -12
- package/dist/migrations/postgres/1661165115000-CreateWellknownDidIssuer.js.map +0 -1
- package/dist/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.d.ts +0 -7
- package/dist/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.d.ts.map +0 -1
- package/dist/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.js +0 -12
- package/dist/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.js.map +0 -1
- package/dist/types/IWellKnownDidIssuer.d.ts +0 -51
- package/dist/types/IWellKnownDidIssuer.d.ts.map +0 -1
- package/dist/types/IWellKnownDidIssuer.js +0 -2
- package/dist/types/IWellKnownDidIssuer.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
|
|
34
|
+
// plugin.schema.json
|
|
35
|
+
var require_plugin_schema = __commonJS({
|
|
36
|
+
"plugin.schema.json"(exports2, module2) {
|
|
37
|
+
module2.exports = {
|
|
38
|
+
IWellKnownDidIssuer: {
|
|
39
|
+
components: {
|
|
40
|
+
schemas: {
|
|
41
|
+
IIssueDidConfigurationResourceArgs: {
|
|
42
|
+
type: "object",
|
|
43
|
+
properties: {
|
|
44
|
+
issuances: {
|
|
45
|
+
type: "array",
|
|
46
|
+
items: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
additionalProperties: true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
credentialIssuance: {
|
|
54
|
+
type: "string"
|
|
55
|
+
},
|
|
56
|
+
save: {
|
|
57
|
+
type: "boolean"
|
|
58
|
+
},
|
|
59
|
+
additionalProperties: false
|
|
60
|
+
},
|
|
61
|
+
required: ["issuances", "credentialIssuance"],
|
|
62
|
+
description: "Arguments needed for {@link IWellKnownDidIssuer.addLinkedDomainsService } "
|
|
63
|
+
},
|
|
64
|
+
IIssueDomainLinkageCredentialArgs: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: {
|
|
67
|
+
did: {
|
|
68
|
+
type: "string"
|
|
69
|
+
},
|
|
70
|
+
origin: {
|
|
71
|
+
type: "string"
|
|
72
|
+
},
|
|
73
|
+
serviceId: {
|
|
74
|
+
type: "string"
|
|
75
|
+
},
|
|
76
|
+
issuanceDate: {
|
|
77
|
+
type: "date"
|
|
78
|
+
},
|
|
79
|
+
expirationDate: {
|
|
80
|
+
type: "date"
|
|
81
|
+
},
|
|
82
|
+
save: {
|
|
83
|
+
type: "boolean"
|
|
84
|
+
},
|
|
85
|
+
options: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
additionalProperties: true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
credentialIssuance: {
|
|
92
|
+
type: "string"
|
|
93
|
+
},
|
|
94
|
+
additionalProperties: false
|
|
95
|
+
},
|
|
96
|
+
required: ["did", "origin", "expirationDate", "options"],
|
|
97
|
+
description: "Arguments needed for {@link IWellKnownDidIssuer.issueDomainLinkageCredential } "
|
|
98
|
+
},
|
|
99
|
+
IGetDidConfigurationResourceArgs: {
|
|
100
|
+
type: "object",
|
|
101
|
+
properties: {
|
|
102
|
+
origin: {
|
|
103
|
+
type: "string"
|
|
104
|
+
},
|
|
105
|
+
additionalProperties: false
|
|
106
|
+
},
|
|
107
|
+
required: ["origin"],
|
|
108
|
+
description: "Arguments needed for {@link IWellKnownDidIssuer.getDidConfigurationResource } "
|
|
109
|
+
},
|
|
110
|
+
IAddLinkedDomainsServiceArgs: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
did: {
|
|
114
|
+
type: "string"
|
|
115
|
+
},
|
|
116
|
+
origin: {
|
|
117
|
+
type: "string"
|
|
118
|
+
},
|
|
119
|
+
serviceId: {
|
|
120
|
+
type: "string"
|
|
121
|
+
},
|
|
122
|
+
additionalProperties: false
|
|
123
|
+
},
|
|
124
|
+
required: ["did", "origin"],
|
|
125
|
+
description: "Arguments needed for {@link IWellKnownDidIssuer.addLinkedDomainsService } "
|
|
126
|
+
},
|
|
127
|
+
ISaveDidConfigurationResourceArgs: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
origin: {
|
|
131
|
+
type: "string"
|
|
132
|
+
},
|
|
133
|
+
didConfigurationResource: {
|
|
134
|
+
type: "object",
|
|
135
|
+
properties: {
|
|
136
|
+
additionalProperties: true
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
additionalProperties: false
|
|
140
|
+
},
|
|
141
|
+
required: ["did", "origin"],
|
|
142
|
+
description: "Arguments needed for {@link IWellKnownDidIssuer.saveDidConfigurationResource } "
|
|
143
|
+
},
|
|
144
|
+
IRemoveCredentialIssuanceArgs: {
|
|
145
|
+
type: "object",
|
|
146
|
+
properties: {
|
|
147
|
+
origin: {
|
|
148
|
+
callbackName: "string"
|
|
149
|
+
},
|
|
150
|
+
additionalProperties: false
|
|
151
|
+
},
|
|
152
|
+
required: ["callbackName"],
|
|
153
|
+
description: "Arguments needed for {@link IWellKnownDidIssuer.removeCredentialIssuance } "
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
methods: {
|
|
157
|
+
addLinkedDomainsService: {
|
|
158
|
+
description: "Adds a LinkedDomains service to the DID",
|
|
159
|
+
arguments: {
|
|
160
|
+
$ref: "#/components/schemas/IAddLinkedDomainsServiceArgs"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
getDidConfigurationResource: {
|
|
164
|
+
description: "Retrieves a DID configuration resource from the database",
|
|
165
|
+
arguments: {
|
|
166
|
+
$ref: "#/components/schemas/IGetDidConfigurationResourceArgs"
|
|
167
|
+
},
|
|
168
|
+
returnType: "object"
|
|
169
|
+
},
|
|
170
|
+
issueDidConfigurationResource: {
|
|
171
|
+
description: "Issues a DID configuration resource",
|
|
172
|
+
arguments: {
|
|
173
|
+
$ref: "#/components/schemas/IAddLinkedDomainsServiceArgs"
|
|
174
|
+
},
|
|
175
|
+
returnType: "object"
|
|
176
|
+
},
|
|
177
|
+
issueDomainLinkageCredential: {
|
|
178
|
+
description: "Retrieves a domain linkage credential",
|
|
179
|
+
arguments: {
|
|
180
|
+
$ref: "#/components/schemas/IIssueDomainLinkageCredentialArgs"
|
|
181
|
+
},
|
|
182
|
+
returnType: "object"
|
|
183
|
+
},
|
|
184
|
+
removeCredentialIssuance: {
|
|
185
|
+
description: "Removes a registered callback",
|
|
186
|
+
arguments: {
|
|
187
|
+
$ref: "#/components/schemas/IRemoveCredentialIssuanceArgs"
|
|
188
|
+
},
|
|
189
|
+
returnType: "boolean"
|
|
190
|
+
},
|
|
191
|
+
saveDidConfigurationResource: {
|
|
192
|
+
description: "Saves a DID configuration resource to the database",
|
|
193
|
+
arguments: {
|
|
194
|
+
$ref: "#/components/schemas/ISaveDidConfigurationResourceArgs"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// src/index.ts
|
|
205
|
+
var index_exports = {};
|
|
206
|
+
__export(index_exports, {
|
|
207
|
+
DidConfigurationResourceEntity: () => DidConfigurationResourceEntity,
|
|
208
|
+
WellKnownDidIssuer: () => WellKnownDidIssuer,
|
|
209
|
+
WellknownDidIssuerEntities: () => WellknownDidIssuerEntities,
|
|
210
|
+
WellknownDidIssuerMigrations: () => WellknownDidIssuerMigrations,
|
|
211
|
+
schema: () => schema
|
|
212
|
+
});
|
|
213
|
+
module.exports = __toCommonJS(index_exports);
|
|
214
|
+
|
|
215
|
+
// src/entities/DidConfigurationResourceEntity.ts
|
|
216
|
+
var import_data_store = require("@veramo/data-store");
|
|
217
|
+
var import_utils = require("@veramo/utils");
|
|
218
|
+
var import_typeorm = require("typeorm");
|
|
219
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
220
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
221
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
222
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
223
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
224
|
+
}
|
|
225
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
226
|
+
function _ts_metadata(k, v) {
|
|
227
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
228
|
+
}
|
|
229
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
230
|
+
var DidConfigurationResourceEntity = class extends import_typeorm.BaseEntity {
|
|
231
|
+
static {
|
|
232
|
+
__name(this, "DidConfigurationResourceEntity");
|
|
233
|
+
}
|
|
234
|
+
origin;
|
|
235
|
+
context;
|
|
236
|
+
// TODO cascade of delete should be true when the VC is only attached to one DID configuration resource
|
|
237
|
+
linkedDids;
|
|
238
|
+
createdAt;
|
|
239
|
+
lastUpdatedAt;
|
|
240
|
+
};
|
|
241
|
+
_ts_decorate([
|
|
242
|
+
(0, import_typeorm.PrimaryColumn)({
|
|
243
|
+
nullable: false
|
|
244
|
+
}),
|
|
245
|
+
_ts_metadata("design:type", String)
|
|
246
|
+
], DidConfigurationResourceEntity.prototype, "origin", void 0);
|
|
247
|
+
_ts_decorate([
|
|
248
|
+
(0, import_typeorm.Column)({
|
|
249
|
+
nullable: false
|
|
250
|
+
}),
|
|
251
|
+
_ts_metadata("design:type", String)
|
|
252
|
+
], DidConfigurationResourceEntity.prototype, "context", void 0);
|
|
253
|
+
_ts_decorate([
|
|
254
|
+
(0, import_typeorm.ManyToMany)(() => import_data_store.Credential, (credential) => credential.hash, {
|
|
255
|
+
nullable: false,
|
|
256
|
+
cascade: true,
|
|
257
|
+
onDelete: "NO ACTION"
|
|
258
|
+
}),
|
|
259
|
+
(0, import_typeorm.JoinTable)({
|
|
260
|
+
name: "DidConfigurationResourceCredentials"
|
|
261
|
+
}),
|
|
262
|
+
_ts_metadata("design:type", typeof Array === "undefined" ? Object : Array)
|
|
263
|
+
], DidConfigurationResourceEntity.prototype, "linkedDids", void 0);
|
|
264
|
+
_ts_decorate([
|
|
265
|
+
(0, import_typeorm.CreateDateColumn)({
|
|
266
|
+
name: "created_at",
|
|
267
|
+
nullable: false
|
|
268
|
+
}),
|
|
269
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
270
|
+
], DidConfigurationResourceEntity.prototype, "createdAt", void 0);
|
|
271
|
+
_ts_decorate([
|
|
272
|
+
(0, import_typeorm.UpdateDateColumn)({
|
|
273
|
+
name: "last_updated_at",
|
|
274
|
+
nullable: false
|
|
275
|
+
}),
|
|
276
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
277
|
+
], DidConfigurationResourceEntity.prototype, "lastUpdatedAt", void 0);
|
|
278
|
+
DidConfigurationResourceEntity = _ts_decorate([
|
|
279
|
+
(0, import_typeorm.Entity)("DidConfigurationResource")
|
|
280
|
+
], DidConfigurationResourceEntity);
|
|
281
|
+
var didConfigurationResourceFrom = /* @__PURE__ */ __name((didConfigurationResource) => {
|
|
282
|
+
return {
|
|
283
|
+
"@context": didConfigurationResource.context,
|
|
284
|
+
linked_dids: linkedDidsFrom(didConfigurationResource.linkedDids)
|
|
285
|
+
};
|
|
286
|
+
}, "didConfigurationResourceFrom");
|
|
287
|
+
var linkedDidsFrom = /* @__PURE__ */ __name((credentials) => {
|
|
288
|
+
return credentials.map((credential) => credential?.raw?.proof?.type === "JwtProof2020" && typeof credential?.raw?.proof?.jwt === "string" ? credential.raw.proof.jwt : credential.raw);
|
|
289
|
+
}, "linkedDidsFrom");
|
|
290
|
+
var createCredentialEntity = /* @__PURE__ */ __name((vci) => {
|
|
291
|
+
const vc = vci;
|
|
292
|
+
const credential = new import_data_store.Credential();
|
|
293
|
+
credential.context = (0, import_utils.asArray)(vc["@context"]);
|
|
294
|
+
credential.type = (0, import_utils.asArray)(vc.type || []);
|
|
295
|
+
credential.id = vc.id;
|
|
296
|
+
if (vc.issuanceDate) {
|
|
297
|
+
credential.issuanceDate = new Date(vc.issuanceDate);
|
|
298
|
+
}
|
|
299
|
+
if (vc.expirationDate) {
|
|
300
|
+
credential.expirationDate = new Date(vc.expirationDate);
|
|
301
|
+
}
|
|
302
|
+
const issuer = new import_data_store.Identifier();
|
|
303
|
+
issuer.did = (0, import_utils.extractIssuer)(vc);
|
|
304
|
+
credential.issuer = issuer;
|
|
305
|
+
if (vc.credentialSubject.id) {
|
|
306
|
+
const subject = new import_data_store.Identifier();
|
|
307
|
+
subject.did = vc.credentialSubject.id;
|
|
308
|
+
credential.subject = subject;
|
|
309
|
+
}
|
|
310
|
+
credential.claims = [];
|
|
311
|
+
for (const type in vc.credentialSubject) {
|
|
312
|
+
if (vc.credentialSubject.hasOwnProperty(type)) {
|
|
313
|
+
const value = vc.credentialSubject[type];
|
|
314
|
+
if (type !== "id") {
|
|
315
|
+
const isObj = typeof value === "function" || typeof value === "object" && !!value;
|
|
316
|
+
const claim = new import_data_store.Claim();
|
|
317
|
+
claim.hash = (0, import_utils.computeEntryHash)(JSON.stringify(vc) + type);
|
|
318
|
+
claim.type = type;
|
|
319
|
+
claim.value = isObj ? JSON.stringify(value) : value;
|
|
320
|
+
claim.isObj = isObj;
|
|
321
|
+
claim.issuer = credential.issuer;
|
|
322
|
+
claim.subject = credential.subject;
|
|
323
|
+
claim.expirationDate = credential.expirationDate;
|
|
324
|
+
claim.issuanceDate = credential.issuanceDate;
|
|
325
|
+
claim.credentialType = credential.type;
|
|
326
|
+
claim.context = credential.context;
|
|
327
|
+
credential.claims.push(claim);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
credential.raw = vci;
|
|
332
|
+
return credential;
|
|
333
|
+
}, "createCredentialEntity");
|
|
334
|
+
|
|
335
|
+
// src/agent/WellKnownDidIssuer.ts
|
|
336
|
+
var import_ssi_sdk = require("@sphereon/ssi-sdk.credential-store");
|
|
337
|
+
var import_ssi_types = require("@sphereon/ssi-types");
|
|
338
|
+
var import_wellknown_dids_client = require("@sphereon/wellknown-dids-client");
|
|
339
|
+
var import_did_jwt_vc = require("did-jwt-vc");
|
|
340
|
+
var import_uuid = require("uuid");
|
|
341
|
+
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.data-store");
|
|
342
|
+
var WellKnownDidIssuer = class {
|
|
343
|
+
static {
|
|
344
|
+
__name(this, "WellKnownDidIssuer");
|
|
345
|
+
}
|
|
346
|
+
dbConnection;
|
|
347
|
+
schema;
|
|
348
|
+
methods;
|
|
349
|
+
credentialIssuances;
|
|
350
|
+
didConfigurationResourceRelations;
|
|
351
|
+
constructor(dbConnection, args) {
|
|
352
|
+
this.dbConnection = dbConnection;
|
|
353
|
+
this.schema = schema.IWellKnownDidVerifier;
|
|
354
|
+
this.methods = {
|
|
355
|
+
addLinkedDomainsService: this.addLinkedDomainsService.bind(this),
|
|
356
|
+
getDidConfigurationResource: this.getDidConfigurationResource.bind(this),
|
|
357
|
+
issueDidConfigurationResource: this.issueDidConfigurationResource.bind(this),
|
|
358
|
+
issueDomainLinkageCredential: this.issueDomainLinkageCredential.bind(this),
|
|
359
|
+
registerCredentialIssuance: this.registerCredentialIssuance.bind(this),
|
|
360
|
+
removeCredentialIssuance: this.removeCredentialIssuance.bind(this),
|
|
361
|
+
saveDidConfigurationResource: this.saveDidConfigurationResource.bind(this)
|
|
362
|
+
};
|
|
363
|
+
this.didConfigurationResourceRelations = [
|
|
364
|
+
"linkedDids"
|
|
365
|
+
];
|
|
366
|
+
this.credentialIssuances = args && args.credentialIssuances || {};
|
|
367
|
+
}
|
|
368
|
+
/** {@inheritDoc IWellKnownDidIssuer.registerSignatureVerification} */
|
|
369
|
+
async registerCredentialIssuance(args, context) {
|
|
370
|
+
if (this.credentialIssuances[args.callbackName] !== void 0) {
|
|
371
|
+
return Promise.reject(new Error(`Credential issuance with callbackName: ${args.callbackName} already present`));
|
|
372
|
+
}
|
|
373
|
+
this.credentialIssuances[args.callbackName] = args.credentialIssuance;
|
|
374
|
+
}
|
|
375
|
+
/** {@inheritDoc IWellKnownDidIssuer.removeSignatureVerification} */
|
|
376
|
+
async removeCredentialIssuance(args, context) {
|
|
377
|
+
return delete this.credentialIssuances[args.callbackName];
|
|
378
|
+
}
|
|
379
|
+
/** {@inheritDoc IWellKnownDidIssuer.issueDidConfigurationResource} */
|
|
380
|
+
async issueDidConfigurationResource(args, context) {
|
|
381
|
+
if (!args.issuances.every((issuance) => issuance.origin === args.issuances[0].origin)) {
|
|
382
|
+
return Promise.reject(Error("All verifiableCredentials should be issued for the same origin"));
|
|
383
|
+
}
|
|
384
|
+
const addServices = args.issuances.map((issuance) => this.addLinkedDomainsService({
|
|
385
|
+
did: issuance.did,
|
|
386
|
+
origin: issuance.origin,
|
|
387
|
+
serviceId: issuance.serviceId
|
|
388
|
+
}, context));
|
|
389
|
+
return Promise.all(addServices).then(async () => new import_wellknown_dids_client.WellKnownDidIssuer().issueDidConfigurationResource({
|
|
390
|
+
issuances: await this.mapIssuances(args.issuances),
|
|
391
|
+
issueCallback: typeof args.credentialIssuance === "string" ? await this.getCredentialIssuance(args.credentialIssuance) : args.credentialIssuance
|
|
392
|
+
}).then(async (didConfigurationResource) => {
|
|
393
|
+
if (args.save) {
|
|
394
|
+
await this.saveDidConfigurationResource({
|
|
395
|
+
origin: args.issuances[0].origin,
|
|
396
|
+
didConfigurationResource
|
|
397
|
+
}, context);
|
|
398
|
+
}
|
|
399
|
+
return didConfigurationResource;
|
|
400
|
+
}).catch((error) => Promise.reject(Error(`Unable to issue DID configuration resource. Error: ${error.message}`))));
|
|
401
|
+
}
|
|
402
|
+
/** {@inheritDoc IWellKnownDidIssuer.saveDidConfigurationResource} */
|
|
403
|
+
async saveDidConfigurationResource(args, context) {
|
|
404
|
+
const didConfigurationEntity = {
|
|
405
|
+
origin: args.origin,
|
|
406
|
+
context: args.didConfigurationResource["@context"],
|
|
407
|
+
linkedDids: args.didConfigurationResource.linked_dids.map((credential) => createCredentialEntity(this.normalizeCredential(credential)))
|
|
408
|
+
};
|
|
409
|
+
await (await this.dbConnection).getRepository(DidConfigurationResourceEntity).save(didConfigurationEntity, {
|
|
410
|
+
transaction: true
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
/** {@inheritDoc IWellKnownDidIssuer.getDidConfigurationResource} */
|
|
414
|
+
async getDidConfigurationResource(args, context) {
|
|
415
|
+
const result = await (await this.dbConnection).getRepository(DidConfigurationResourceEntity).findOne({
|
|
416
|
+
where: {
|
|
417
|
+
origin: args.origin
|
|
418
|
+
},
|
|
419
|
+
relations: this.didConfigurationResourceRelations
|
|
420
|
+
});
|
|
421
|
+
if (!result) {
|
|
422
|
+
return Promise.reject(Error(`No DID configuration resource found for origin: ${args.origin}`));
|
|
423
|
+
}
|
|
424
|
+
return didConfigurationResourceFrom(result);
|
|
425
|
+
}
|
|
426
|
+
/** {@inheritDoc IWellKnownDidIssuer.issueDomainLinkageCredential} */
|
|
427
|
+
async issueDomainLinkageCredential(args, context) {
|
|
428
|
+
const did = (0, import_ssi_types.parseDid)(args.did).did;
|
|
429
|
+
if (new URL(args.origin).origin !== args.origin) {
|
|
430
|
+
return Promise.reject(Error(`Origin ${args.origin} is not valid`));
|
|
431
|
+
}
|
|
432
|
+
if (new URL(args.origin).protocol !== "https:") {
|
|
433
|
+
return Promise.reject(Error(`Origin ${args.origin} is not a https URL`));
|
|
434
|
+
}
|
|
435
|
+
if (args.issuanceDate && isNaN(Date.parse(args.issuanceDate))) {
|
|
436
|
+
return Promise.reject(Error(`IssuanceDate ${args.issuanceDate} is not a valid date`));
|
|
437
|
+
}
|
|
438
|
+
if (isNaN(Date.parse(args.expirationDate))) {
|
|
439
|
+
return Promise.reject(Error(`ExpirationDate ${args.expirationDate} is not a valid date`));
|
|
440
|
+
}
|
|
441
|
+
const credentialIssuance = typeof args.credentialIssuance === "string" ? await this.getCredentialIssuance(args.credentialIssuance) : args.credentialIssuance;
|
|
442
|
+
return new import_wellknown_dids_client.WellKnownDidIssuer().issueDomainLinkageCredential({
|
|
443
|
+
did,
|
|
444
|
+
origin: args.origin,
|
|
445
|
+
issuanceDate: args.issuanceDate,
|
|
446
|
+
expirationDate: args.expirationDate,
|
|
447
|
+
options: args.options,
|
|
448
|
+
issueCallback: credentialIssuance
|
|
449
|
+
}).then(async (credential) => {
|
|
450
|
+
if (args.save) {
|
|
451
|
+
await this.saveDomainLinkageCredential(credential, context);
|
|
452
|
+
}
|
|
453
|
+
return credential;
|
|
454
|
+
}).catch((error) => Promise.reject(Error(`Unable to issue domain linkage credential for DID: ${did}. Error: ${error.message}`)));
|
|
455
|
+
}
|
|
456
|
+
/** {@inheritDoc IWellKnownDidIssuer.addLinkedDomainsService} */
|
|
457
|
+
async addLinkedDomainsService(args, context) {
|
|
458
|
+
const did = (0, import_ssi_types.parseDid)(args.did).did;
|
|
459
|
+
if (new URL(args.origin).origin !== args.origin) {
|
|
460
|
+
return Promise.reject(Error(`Origin ${args.origin} is not valid`));
|
|
461
|
+
}
|
|
462
|
+
if (new URL(args.origin).protocol !== "https:") {
|
|
463
|
+
return Promise.reject(Error(`Origin ${args.origin} is not a https URL`));
|
|
464
|
+
}
|
|
465
|
+
context.agent.didManagerGet({
|
|
466
|
+
did
|
|
467
|
+
}).catch(() => Promise.reject(Error("DID cannot be found"))).then(async (identifier) => {
|
|
468
|
+
if (!identifier.services || identifier.services.filter(
|
|
469
|
+
// TODO we should also check for the origins in the serviceEndpoint objects when we start supporting multiple origins
|
|
470
|
+
(service) => service.type === import_wellknown_dids_client.ServiceTypesEnum.LINKED_DOMAINS && service.serviceEndpoint === args.origin
|
|
471
|
+
).length === 0) {
|
|
472
|
+
await context.agent.didManagerAddService({
|
|
473
|
+
did: identifier.did,
|
|
474
|
+
service: {
|
|
475
|
+
id: args.serviceId || (0, import_uuid.v4)(),
|
|
476
|
+
type: import_wellknown_dids_client.ServiceTypesEnum.LINKED_DOMAINS,
|
|
477
|
+
// TODO We should support a serviceEndpoint object here when we update to Veramo 3.1.6.next-165 or higher, as then we can support multiple origins
|
|
478
|
+
serviceEndpoint: args.origin
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}).catch((error) => Promise.reject(Error(`Unable to add LinkedDomains service to DID: ${args.did}. Error: ${error.message}`)));
|
|
483
|
+
}
|
|
484
|
+
async getCredentialIssuance(callbackName) {
|
|
485
|
+
if (this.credentialIssuances[callbackName] === void 0) {
|
|
486
|
+
return Promise.reject(new Error(`Credential issuance not found for callbackName: ${callbackName}`));
|
|
487
|
+
}
|
|
488
|
+
return this.credentialIssuances[callbackName];
|
|
489
|
+
}
|
|
490
|
+
async saveDomainLinkageCredential(credential, context) {
|
|
491
|
+
const vc = this.normalizeCredential(credential);
|
|
492
|
+
return context.agent.crsAddCredential({
|
|
493
|
+
credential: {
|
|
494
|
+
rawDocument: JSON.stringify(vc),
|
|
495
|
+
credentialRole: import_ssi_sdk.CredentialRole.ISSUER,
|
|
496
|
+
regulationType: import_ssi_sdk2.RegulationType.NON_REGULATED,
|
|
497
|
+
kmsKeyRef: "FIXME",
|
|
498
|
+
identifierMethod: "did",
|
|
499
|
+
issuerCorrelationId: import_ssi_types.CredentialMapper.issuerCorrelationIdFromIssuerType(vc.issuer),
|
|
500
|
+
issuerCorrelationType: import_ssi_sdk.CredentialCorrelationType.DID,
|
|
501
|
+
subjectCorrelationId: import_ssi_types.CredentialMapper.issuerCorrelationIdFromIssuerType(vc.issuer),
|
|
502
|
+
subjectCorrelationType: import_ssi_sdk.CredentialCorrelationType.DID
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
normalizeCredential(credential) {
|
|
507
|
+
return typeof credential === "string" ? (0, import_did_jwt_vc.normalizeCredential)(credential) : credential;
|
|
508
|
+
}
|
|
509
|
+
async mapIssuances(issuances) {
|
|
510
|
+
const promises = issuances.map(async (issuance) => {
|
|
511
|
+
return {
|
|
512
|
+
...issuance,
|
|
513
|
+
issueCallback: typeof issuance.credentialIssuance === "string" ? await this.getCredentialIssuance(issuance.credentialIssuance) : issuance.credentialIssuance
|
|
514
|
+
};
|
|
515
|
+
});
|
|
516
|
+
return Promise.all(promises);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
// src/migrations/generic/1-CreateWellknownDidIssuer.ts
|
|
521
|
+
var import_debug = __toESM(require("debug"), 1);
|
|
522
|
+
|
|
523
|
+
// src/migrations/postgres/1661165115000-CreateWellknownDidIssuer.ts
|
|
524
|
+
var CreateWellknownDidIssuer1661165115000 = class {
|
|
525
|
+
static {
|
|
526
|
+
__name(this, "CreateWellknownDidIssuer1661165115000");
|
|
527
|
+
}
|
|
528
|
+
name = "CreateWellknownDidIssuer1661165115000";
|
|
529
|
+
async up(queryRunner) {
|
|
530
|
+
await queryRunner.query(`CREATE TABLE "DidConfigurationResource" ("origin" varchar NOT NULL, "context" varchar NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_Origin" PRIMARY KEY ("origin"))`);
|
|
531
|
+
await queryRunner.query(`CREATE TABLE "DidConfigurationResourceCredentials" ("didConfigurationResourceOrigin" varchar NOT NULL, "credentialHash" varchar NOT NULL)`);
|
|
532
|
+
}
|
|
533
|
+
async down(queryRunner) {
|
|
534
|
+
await queryRunner.query(`DROP TABLE "DidConfigurationResource"`);
|
|
535
|
+
await queryRunner.query(`DROP TABLE "DidConfigurationResourceCredentials"`);
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// src/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.ts
|
|
540
|
+
var CreateWellknownDidIssuer1661161799000 = class {
|
|
541
|
+
static {
|
|
542
|
+
__name(this, "CreateWellknownDidIssuer1661161799000");
|
|
543
|
+
}
|
|
544
|
+
name = "CreateWellknownDidIssuer1661161799000";
|
|
545
|
+
async up(queryRunner) {
|
|
546
|
+
await queryRunner.query(`CREATE TABLE "DidConfigurationResource" ("origin" varchar PRIMARY KEY NOT NULL, "context" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
|
547
|
+
await queryRunner.query(`CREATE TABLE "DidConfigurationResourceCredentials" ("didConfigurationResourceOrigin" varchar NOT NULL, "credentialHash" varchar NOT NULL)`);
|
|
548
|
+
}
|
|
549
|
+
async down(queryRunner) {
|
|
550
|
+
await queryRunner.query(`DROP TABLE "DidConfigurationResource"`);
|
|
551
|
+
await queryRunner.query(`DROP TABLE "DidConfigurationResourceCredentials"`);
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
// src/migrations/generic/1-CreateWellknownDidIssuer.ts
|
|
556
|
+
var debug = (0, import_debug.default)("sphereon:ssi-sdk:migrations");
|
|
557
|
+
var CreateWellknownDidIssuer1661162010000 = class {
|
|
558
|
+
static {
|
|
559
|
+
__name(this, "CreateWellknownDidIssuer1661162010000");
|
|
560
|
+
}
|
|
561
|
+
name = "CreateWellknownDidIssuer1661162010000";
|
|
562
|
+
async up(queryRunner) {
|
|
563
|
+
debug("migration: creating well-known DID tables");
|
|
564
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
565
|
+
if (dbType === "postgres") {
|
|
566
|
+
debug("using postgres migration file");
|
|
567
|
+
const mig = new CreateWellknownDidIssuer1661165115000();
|
|
568
|
+
const up = await mig.up(queryRunner);
|
|
569
|
+
debug("Migration statements executed");
|
|
570
|
+
return up;
|
|
571
|
+
} else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
|
|
572
|
+
debug("using sqlite/react-native migration file");
|
|
573
|
+
const mig = new CreateWellknownDidIssuer1661161799000();
|
|
574
|
+
const up = await mig.up(queryRunner);
|
|
575
|
+
debug("Migration statements executed");
|
|
576
|
+
return up;
|
|
577
|
+
} else {
|
|
578
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expor and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
async down(queryRunner) {
|
|
582
|
+
debug("reverting well-known DID tables");
|
|
583
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
584
|
+
if (dbType === "postgres") {
|
|
585
|
+
debug("using postgres migration file");
|
|
586
|
+
const mig = new CreateWellknownDidIssuer1661165115000();
|
|
587
|
+
const down = await mig.down(queryRunner);
|
|
588
|
+
debug("Migration statements executed");
|
|
589
|
+
return down;
|
|
590
|
+
} else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
|
|
591
|
+
debug("using sqlite/react-native migration file");
|
|
592
|
+
const mig = new CreateWellknownDidIssuer1661161799000();
|
|
593
|
+
const down = await mig.down(queryRunner);
|
|
594
|
+
debug("Migration statements executed");
|
|
595
|
+
return down;
|
|
596
|
+
} else {
|
|
597
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expor and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
// src/migrations/generic/index.ts
|
|
603
|
+
var WellknownDidIssuerMigrations = [
|
|
604
|
+
CreateWellknownDidIssuer1661162010000
|
|
605
|
+
];
|
|
606
|
+
|
|
607
|
+
// src/index.ts
|
|
608
|
+
var schema = require_plugin_schema();
|
|
609
|
+
var WellknownDidIssuerEntities = [
|
|
610
|
+
DidConfigurationResourceEntity
|
|
611
|
+
];
|
|
612
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
613
|
+
0 && (module.exports = {
|
|
614
|
+
DidConfigurationResourceEntity,
|
|
615
|
+
WellKnownDidIssuer,
|
|
616
|
+
WellknownDidIssuerEntities,
|
|
617
|
+
WellknownDidIssuerMigrations,
|
|
618
|
+
schema
|
|
619
|
+
});
|
|
620
|
+
//# sourceMappingURL=index.cjs.map
|