@verana-labs/vs-agent-sdk 1.11.0-dev.13 → 1.11.0-dev.15
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/README.md +172 -0
- package/build/blockchain/IndexerWebSocketService.d.ts +11 -2
- package/build/blockchain/IndexerWebSocketService.js +81 -30
- package/build/blockchain/IndexerWebSocketService.js.map +1 -1
- package/build/blockchain/VeranaChainService.d.ts +2 -0
- package/build/blockchain/VeranaChainService.js +7 -4
- package/build/blockchain/VeranaChainService.js.map +1 -1
- package/build/blockchain/VeranaHelpers.d.ts +1 -2
- package/build/blockchain/VeranaHelpers.js +0 -73
- package/build/blockchain/VeranaHelpers.js.map +1 -1
- package/build/blockchain/VeranaIndexerService.d.ts +4 -1
- package/build/blockchain/VeranaIndexerService.js +15 -0
- package/build/blockchain/VeranaIndexerService.js.map +1 -1
- package/build/blockchain/handlers/IndexerHandlerRegistry.d.ts +25 -0
- package/build/blockchain/handlers/IndexerHandlerRegistry.js +34 -0
- package/build/blockchain/handlers/IndexerHandlerRegistry.js.map +1 -0
- package/build/blockchain/handlers/defaultHandlers.d.ts +6 -0
- package/build/blockchain/handlers/defaultHandlers.js +126 -0
- package/build/blockchain/handlers/defaultHandlers.js.map +1 -0
- package/build/blockchain/handlers/index.d.ts +3 -0
- package/build/blockchain/handlers/index.js +20 -0
- package/build/blockchain/handlers/index.js.map +1 -0
- package/build/blockchain/handlers/stateMutations.d.ts +12 -0
- package/build/blockchain/handlers/stateMutations.js +113 -0
- package/build/blockchain/handlers/stateMutations.js.map +1 -0
- package/build/blockchain/index.d.ts +1 -0
- package/build/blockchain/index.js +1 -0
- package/build/blockchain/index.js.map +1 -1
- package/build/blockchain/types.d.ts +50 -2
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/utils/setupSelfTr.d.ts +115 -0
- package/build/utils/setupSelfTr.js +452 -0
- package/build/utils/setupSelfTr.js.map +1 -0
- package/build/utils/trustCredentialStore.d.ts +18 -0
- package/build/utils/trustCredentialStore.js +196 -0
- package/build/utils/trustCredentialStore.js.map +1 -0
- package/package.json +5 -2
|
@@ -0,0 +1,452 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.setupSelfTr = exports.mapToSelfTr = exports.createJsonSubjectRef = exports.createJsonSchema = exports.credentials = exports.presentations = void 0;
|
|
40
|
+
exports.createCredential = createCredential;
|
|
41
|
+
exports.signerW3c = signerW3c;
|
|
42
|
+
exports.generateVerifiablePresentation = generateVerifiablePresentation;
|
|
43
|
+
exports.createPresentation = createPresentation;
|
|
44
|
+
exports.getClaims = getClaims;
|
|
45
|
+
exports.validateSchema = validateSchema;
|
|
46
|
+
exports.addDigestSRI = addDigestSRI;
|
|
47
|
+
exports.generateDigestSRI = generateDigestSRI;
|
|
48
|
+
exports.urlToBase64 = urlToBase64;
|
|
49
|
+
exports.getVerificationMethodId = getVerificationMethodId;
|
|
50
|
+
const core_1 = require("@credo-ts/core");
|
|
51
|
+
// No type definitions available for this library
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
53
|
+
//@ts-ignore
|
|
54
|
+
const jsonld_signatures_1 = require("@digitalcredentials/jsonld-signatures");
|
|
55
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
56
|
+
const _2020_1 = __importDefault(require("ajv/dist/2020"));
|
|
57
|
+
const ajv_formats_1 = __importDefault(require("ajv-formats"));
|
|
58
|
+
const axios_1 = __importStar(require("axios"));
|
|
59
|
+
const crypto_1 = require("crypto");
|
|
60
|
+
const data_1 = require("./data");
|
|
61
|
+
const ajv = new _2020_1.default({ strict: false });
|
|
62
|
+
(0, ajv_formats_1.default)(ajv);
|
|
63
|
+
// Helpers
|
|
64
|
+
exports.presentations = [
|
|
65
|
+
{
|
|
66
|
+
name: 'ecs-service',
|
|
67
|
+
schemaUrl: `ecosystem/schemas-example-service-jsc.json`,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'ecs-org',
|
|
71
|
+
schemaUrl: `ecosystem/schemas-example-org-jsc.json`,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
exports.credentials = [
|
|
75
|
+
{
|
|
76
|
+
name: 'example-service',
|
|
77
|
+
credUrl: `ecosystem/cs/v1/js/ecs-service`,
|
|
78
|
+
schemaUrl: `ecosystem/schemas-example-service-jsc.json`,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'example-org',
|
|
82
|
+
credUrl: `ecosystem/cs/v1/js/ecs-org`,
|
|
83
|
+
schemaUrl: `ecosystem/schemas-example-org-jsc.json`,
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
// Default JSON Schema objects
|
|
87
|
+
exports.createJsonSchema = {
|
|
88
|
+
id: 'https://www.w3.org/ns/credentials/json-schema/v2.json',
|
|
89
|
+
type: 'JsonSchema',
|
|
90
|
+
};
|
|
91
|
+
const createJsonSubjectRef = (id) => ({
|
|
92
|
+
id,
|
|
93
|
+
claims: {
|
|
94
|
+
type: 'JsonSchema',
|
|
95
|
+
jsonSchema: {
|
|
96
|
+
$ref: id,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
exports.createJsonSubjectRef = createJsonSubjectRef;
|
|
101
|
+
const mapToSelfTr = (url, publicApiBaseUrl) => url.replace('ecosystem', `${publicApiBaseUrl}/vt`);
|
|
102
|
+
exports.mapToSelfTr = mapToSelfTr;
|
|
103
|
+
const buildIntegrityData = (data) => {
|
|
104
|
+
return generateDigestSRI(JSON.stringify(data, Object.keys(data).sort()));
|
|
105
|
+
};
|
|
106
|
+
const setupSelfTr = async ({ agent, publicApiBaseUrl, defaults, }) => {
|
|
107
|
+
const ecsSchemas = (0, data_1.getEcsSchemas)(publicApiBaseUrl);
|
|
108
|
+
for (const { name, schemaUrl } of exports.presentations) {
|
|
109
|
+
await generateVerifiablePresentation(agent, `${publicApiBaseUrl}/vt/${name}-c-vp.json`, ecsSchemas, name, ['VerifiableCredential', 'VerifiableTrustCredential'], {
|
|
110
|
+
id: (0, exports.mapToSelfTr)(schemaUrl, publicApiBaseUrl),
|
|
111
|
+
type: 'JsonSchemaCredential',
|
|
112
|
+
}, defaults);
|
|
113
|
+
}
|
|
114
|
+
for (const { name, credUrl, schemaUrl } of exports.credentials) {
|
|
115
|
+
const id = (0, exports.mapToSelfTr)(schemaUrl, publicApiBaseUrl);
|
|
116
|
+
const ref = (0, exports.mapToSelfTr)(credUrl, publicApiBaseUrl);
|
|
117
|
+
await generateVerifiableCredential(agent, id, ecsSchemas, name, ['VerifiableCredential', 'JsonSchemaCredential'], (0, exports.createJsonSubjectRef)(ref), exports.createJsonSchema, defaults);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
exports.setupSelfTr = setupSelfTr;
|
|
121
|
+
/**
|
|
122
|
+
* Generates and signs a verifiable credential using the agent's DID.
|
|
123
|
+
* Stores the signed credential and its integrity metadata in the DID record.
|
|
124
|
+
*
|
|
125
|
+
* - If the claims for the subject are not provided, they are retrieved (default claims) and validated against the schema.
|
|
126
|
+
* - The integrity of the claims is tracked using a Subresource Integrity (SRI) digest.
|
|
127
|
+
* - If a credential with the same integrity already exists in the DID metadata, it is returned directly.
|
|
128
|
+
* - Otherwise, a new credential is created, signed, and stored in the DID metadata.
|
|
129
|
+
* - If a presentation is provided, the signed credential is embedded and a signed presentation is returned.
|
|
130
|
+
*
|
|
131
|
+
* @param agent - The VsAgent instance used for signing and DID management.
|
|
132
|
+
* @param logger - Logger instance for logging operations.
|
|
133
|
+
* @param ecsSchemas - Map of ECS schemas for validation.
|
|
134
|
+
* @param schemaKey - Unique identifier for the credential type and metadata key.
|
|
135
|
+
* @param type - Array of credential types (e.g., ['VerifiableCredential']).
|
|
136
|
+
* @param subject - Subject information, including ID and optional claims.
|
|
137
|
+
* @param credentialSchema - Schema definition for the credential.
|
|
138
|
+
* @param presentation - Optional presentation to include the credential.
|
|
139
|
+
* @returns The signed verifiable credential or presentation, with integrity metadata.
|
|
140
|
+
*/
|
|
141
|
+
async function generateVerifiableCredential(agent, id, ecsSchemas, schemaKey, type, subject, credentialSchema, defaults, presentation) {
|
|
142
|
+
var _a;
|
|
143
|
+
const logger = agent.config.logger;
|
|
144
|
+
const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did });
|
|
145
|
+
const { id: subjectId } = subject;
|
|
146
|
+
let claims = subject.claims;
|
|
147
|
+
if (!claims) {
|
|
148
|
+
claims = await getClaims(logger, ecsSchemas, { id: subjectId }, schemaKey, defaults);
|
|
149
|
+
}
|
|
150
|
+
const integrityData = buildIntegrityData({ id, type, credentialSchema, claims });
|
|
151
|
+
const record = (_a = didRecord.metadata.get('_vt/jsc')) !== null && _a !== void 0 ? _a : {};
|
|
152
|
+
const metadata = record[subjectId];
|
|
153
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.integrityData) === integrityData)
|
|
154
|
+
return metadata.credential;
|
|
155
|
+
const unsignedCredential = createCredential({
|
|
156
|
+
id,
|
|
157
|
+
type,
|
|
158
|
+
issuer: agent.did,
|
|
159
|
+
credentialSubject: {
|
|
160
|
+
id: subjectId,
|
|
161
|
+
claims: presentation ? claims : await addDigestSRI(subjectId, claims, ecsSchemas),
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
unsignedCredential.credentialSchema = presentation
|
|
165
|
+
? credentialSchema
|
|
166
|
+
: await addDigestSRI(credentialSchema.id, credentialSchema, ecsSchemas);
|
|
167
|
+
// Note: this is dependant on DIDComm invitation keys. Not sure if it is fine or we should use a dedicated
|
|
168
|
+
// key for this feature
|
|
169
|
+
const verificationMethodId = getVerificationMethodId(logger, didRecord);
|
|
170
|
+
const signedCredential = await signerW3c(agent, unsignedCredential, verificationMethodId);
|
|
171
|
+
if (presentation) {
|
|
172
|
+
presentation.verifiableCredential = [signedCredential];
|
|
173
|
+
return await signerW3c(agent, presentation, verificationMethodId);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
record[subjectId] = {
|
|
177
|
+
credential: signedCredential.jsonCredential,
|
|
178
|
+
verifiablePresentation: {},
|
|
179
|
+
didDocumentServiceId: '',
|
|
180
|
+
integrityData,
|
|
181
|
+
};
|
|
182
|
+
didRecord.metadata.set('_vt/jsc', record);
|
|
183
|
+
await agent.context.dependencyManager.resolve(core_1.DidRepository).update(agent.context, didRecord);
|
|
184
|
+
return signedCredential.jsonCredential;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function createCredential(options) {
|
|
188
|
+
var _a, _b, _c;
|
|
189
|
+
(_a = options.context) !== null && _a !== void 0 ? _a : (options.context = [
|
|
190
|
+
'https://www.w3.org/2018/credentials/v1',
|
|
191
|
+
'https://www.w3.org/ns/credentials/examples/v2',
|
|
192
|
+
]);
|
|
193
|
+
(_b = options.issuanceDate) !== null && _b !== void 0 ? _b : (options.issuanceDate = new Date().toISOString());
|
|
194
|
+
(_c = options.expirationDate) !== null && _c !== void 0 ? _c : (options.expirationDate = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000).toISOString());
|
|
195
|
+
return new core_1.W3cCredential(options);
|
|
196
|
+
}
|
|
197
|
+
async function signerW3c(agent, obj, verificationMethod) {
|
|
198
|
+
const proofPurpose = new jsonld_signatures_1.purposes.AssertionProofPurpose();
|
|
199
|
+
if (obj instanceof core_1.W3cCredential) {
|
|
200
|
+
return await agent.w3cCredentials.signCredential({
|
|
201
|
+
format: core_1.ClaimFormat.LdpVc,
|
|
202
|
+
credential: obj,
|
|
203
|
+
proofType: 'Ed25519Signature2020',
|
|
204
|
+
verificationMethod,
|
|
205
|
+
proofPurpose,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (obj instanceof core_1.W3cPresentation) {
|
|
209
|
+
return await agent.w3cCredentials.signPresentation({
|
|
210
|
+
format: core_1.ClaimFormat.LdpVp,
|
|
211
|
+
presentation: obj,
|
|
212
|
+
proofType: 'Ed25519Signature2020',
|
|
213
|
+
verificationMethod,
|
|
214
|
+
proofPurpose,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Generates and signs a verifiable presentation containing a verifiable credential.
|
|
220
|
+
* Stores the signed presentation and its integrity metadata in the DID record.
|
|
221
|
+
*
|
|
222
|
+
* - Retrieves and validates claims for the agent's DID.
|
|
223
|
+
* - Computes an integrity digest for the claims.
|
|
224
|
+
* - If a presentation with the same integrity already exists in the DID metadata, it is returned.
|
|
225
|
+
* - Otherwise, a new presentation is created, signed, and stored in the DID metadata.
|
|
226
|
+
*
|
|
227
|
+
* @param agent - The VsAgent instance used for signing and DID management.
|
|
228
|
+
* @param logger - Logger instance for logging operations.
|
|
229
|
+
* @param ecsSchemas - Map of ECS schemas for validation.
|
|
230
|
+
* @param schemaKey - Unique identifier for the presentation type and metadata key.
|
|
231
|
+
* @param type - Array of credential types to include.
|
|
232
|
+
* @param credentialSchema - Schema definition for the credential.
|
|
233
|
+
* @returns The signed verifiable presentation, with integrity metadata.
|
|
234
|
+
*/
|
|
235
|
+
async function generateVerifiablePresentation(agent, id, ecsSchemas, schemaKey, type, credentialSchema, defaults) {
|
|
236
|
+
var _a, _b;
|
|
237
|
+
if (!agent.did)
|
|
238
|
+
throw Error('The DID must be set up');
|
|
239
|
+
const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did });
|
|
240
|
+
const didDocument = didRecord.didDocument;
|
|
241
|
+
if (!didDocument)
|
|
242
|
+
throw Error('The DID Document be set up');
|
|
243
|
+
const claims = await getClaims(agent.config.logger, ecsSchemas, { id: agent.did }, schemaKey, defaults);
|
|
244
|
+
// Use full input for integrityData to ensure update detection
|
|
245
|
+
const didDocumentServiceId = `${agent.did}#vpr-${schemaKey}-c-vp`;
|
|
246
|
+
const integrityData = buildIntegrityData({ id, type, credentialSchema, claims });
|
|
247
|
+
const record = (_a = didRecord.metadata.get('_vt/vtc')) !== null && _a !== void 0 ? _a : {};
|
|
248
|
+
const metadata = record[credentialSchema.id];
|
|
249
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.integrityData) === integrityData && metadata.attached)
|
|
250
|
+
return metadata.verifiablePresentation;
|
|
251
|
+
const presentation = createPresentation({
|
|
252
|
+
id,
|
|
253
|
+
holder: agent.did,
|
|
254
|
+
verifiableCredential: [],
|
|
255
|
+
});
|
|
256
|
+
const verifiablePresentation = await generateVerifiableCredential(agent, agent.did, ecsSchemas, schemaKey, type, { id: agent.did }, credentialSchema, defaults, presentation);
|
|
257
|
+
// Update linked VP when the presentation has changed
|
|
258
|
+
didDocument.service = (_b = didDocument.service) === null || _b === void 0 ? void 0 : _b.map(s => {
|
|
259
|
+
if (typeof s.serviceEndpoint !== 'string')
|
|
260
|
+
return s;
|
|
261
|
+
if (s.serviceEndpoint.includes(schemaKey) && s.id !== `${agent.did}#whois`) {
|
|
262
|
+
s.id = didDocumentServiceId;
|
|
263
|
+
s.serviceEndpoint = id;
|
|
264
|
+
}
|
|
265
|
+
return s;
|
|
266
|
+
});
|
|
267
|
+
const credential = verifiablePresentation.verifiableCredential[0];
|
|
268
|
+
record[credentialSchema.id] = {
|
|
269
|
+
credential,
|
|
270
|
+
verifiablePresentation,
|
|
271
|
+
didDocumentServiceId,
|
|
272
|
+
integrityData,
|
|
273
|
+
attached: true,
|
|
274
|
+
};
|
|
275
|
+
didRecord.metadata.set('_vt/vtc', record);
|
|
276
|
+
await agent.context.dependencyManager.resolve(core_1.DidRepository).update(agent.context, didRecord);
|
|
277
|
+
return verifiablePresentation;
|
|
278
|
+
}
|
|
279
|
+
function createPresentation(options) {
|
|
280
|
+
var _a, _b;
|
|
281
|
+
(_a = options.context) !== null && _a !== void 0 ? _a : (options.context = [
|
|
282
|
+
'https://www.w3.org/2018/credentials/v1',
|
|
283
|
+
'https://www.w3.org/ns/credentials/examples/v2',
|
|
284
|
+
]);
|
|
285
|
+
(_b = options.type) !== null && _b !== void 0 ? _b : (options.type = ['VerifiablePresentation']);
|
|
286
|
+
return new core_1.W3cPresentation(options);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Retrieves and validates claims for a credential subject.
|
|
290
|
+
* If claims are not found, builds default claims based on the schemaKey.
|
|
291
|
+
* Validates claims against the ECS schema for the given schemaKey.
|
|
292
|
+
*
|
|
293
|
+
* @param ecsSchemas - Map of ECS schemas for validation.
|
|
294
|
+
* @param subject - Credential subject, including ID.
|
|
295
|
+
* @param schemaKey - Unique identifier for the credential type.
|
|
296
|
+
* @returns The validated claims object.
|
|
297
|
+
* @throws If claims are invalid or schema is missing.
|
|
298
|
+
*/
|
|
299
|
+
async function getClaims(logger, ecsSchemas, { id, claims }, schemaKey, defaults) {
|
|
300
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
301
|
+
// Default claims fallback
|
|
302
|
+
claims =
|
|
303
|
+
schemaKey === 'ecs-service'
|
|
304
|
+
? {
|
|
305
|
+
name: (_a = claims === null || claims === void 0 ? void 0 : claims.name) !== null && _a !== void 0 ? _a : defaults.agentLabel,
|
|
306
|
+
type: (_b = claims === null || claims === void 0 ? void 0 : claims.type) !== null && _b !== void 0 ? _b : defaults.serviceType,
|
|
307
|
+
description: (_c = claims === null || claims === void 0 ? void 0 : claims.description) !== null && _c !== void 0 ? _c : defaults.serviceDescription,
|
|
308
|
+
logo: await urlToBase64(logger, (_d = claims === null || claims === void 0 ? void 0 : claims.logo) !== null && _d !== void 0 ? _d : defaults.agentInvitationImageUrl, (_e = defaults.fallbackBase64) !== null && _e !== void 0 ? _e : ''),
|
|
309
|
+
minimumAgeRequired: (_f = claims === null || claims === void 0 ? void 0 : claims.minimumAgeRequired) !== null && _f !== void 0 ? _f : defaults.serviceMinimumAgeRequired,
|
|
310
|
+
termsAndConditions: (_g = claims === null || claims === void 0 ? void 0 : claims.termsAndConditions) !== null && _g !== void 0 ? _g : defaults.serviceTermsAndConditions,
|
|
311
|
+
privacyPolicy: (_h = claims === null || claims === void 0 ? void 0 : claims.privacyPolicy) !== null && _h !== void 0 ? _h : defaults.servicePrivacyPolicy,
|
|
312
|
+
}
|
|
313
|
+
: {
|
|
314
|
+
name: (_j = claims === null || claims === void 0 ? void 0 : claims.name) !== null && _j !== void 0 ? _j : defaults.agentLabel,
|
|
315
|
+
logo: await urlToBase64(logger, (_k = claims === null || claims === void 0 ? void 0 : claims.logo) !== null && _k !== void 0 ? _k : defaults.agentInvitationImageUrl, (_l = defaults.fallbackBase64) !== null && _l !== void 0 ? _l : ''),
|
|
316
|
+
registryId: (_m = claims === null || claims === void 0 ? void 0 : claims.registryId) !== null && _m !== void 0 ? _m : defaults.orgRegistryId,
|
|
317
|
+
registryUrl: (_o = claims === null || claims === void 0 ? void 0 : claims.registryUrl) !== null && _o !== void 0 ? _o : defaults.orgRegistryUrl,
|
|
318
|
+
address: (_p = claims === null || claims === void 0 ? void 0 : claims.address) !== null && _p !== void 0 ? _p : defaults.orgAddress,
|
|
319
|
+
type: (_q = claims === null || claims === void 0 ? void 0 : claims.type) !== null && _q !== void 0 ? _q : defaults.orgType,
|
|
320
|
+
countryCode: (_r = claims === null || claims === void 0 ? void 0 : claims.countryCode) !== null && _r !== void 0 ? _r : defaults.orgCountryCode,
|
|
321
|
+
};
|
|
322
|
+
const ecsSchema = ecsSchemas[schemaKey];
|
|
323
|
+
if (!ecsSchema) {
|
|
324
|
+
throw new Error(`Schema not defined in data schemas for schemaKey: ${schemaKey}`);
|
|
325
|
+
}
|
|
326
|
+
const credentialSubject = Object.assign({ id }, claims);
|
|
327
|
+
validateSchema(JSON.parse(ecsSchema), credentialSubject);
|
|
328
|
+
return claims;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Validate a validateSchema object against the corresponding AJV schema.
|
|
332
|
+
* Throws an Error if the schema is missing or validation fails.
|
|
333
|
+
*/
|
|
334
|
+
function validateSchema(ecsSchema, credentialSubject) {
|
|
335
|
+
var _a, _b;
|
|
336
|
+
const validate = ajv.compile((_a = ecsSchema.properties) === null || _a === void 0 ? void 0 : _a.credentialSubject);
|
|
337
|
+
const isValid = validate(credentialSubject);
|
|
338
|
+
if (!isValid) {
|
|
339
|
+
const errorDetails = (_b = validate.errors) === null || _b === void 0 ? void 0 : _b.map(e => ({
|
|
340
|
+
message: e.message,
|
|
341
|
+
path: e.instancePath,
|
|
342
|
+
keyword: e.keyword,
|
|
343
|
+
params: e.params,
|
|
344
|
+
}));
|
|
345
|
+
throw new Error(`Invalid claims for ${ecsSchema.id}: ${JSON.stringify(errorDetails, null, 2)}`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Adds a Subresource Integrity (SRI) digest to the provided data using the schema content
|
|
350
|
+
* fetched from the provided URL or from a local schema map as fallback.
|
|
351
|
+
*
|
|
352
|
+
* @template T - The type of the data object.
|
|
353
|
+
* @param id - The URL of the schema to fetch.
|
|
354
|
+
* @param data - The object to which the digest will be added.
|
|
355
|
+
* @param ecsSchemas - Optional map of local schemas to use as fallback if the fetch fails.
|
|
356
|
+
* @returns A new object combining the original data and a `digestSRI` property.
|
|
357
|
+
* @throws Error if both the fetch and local fallback fail.
|
|
358
|
+
*/
|
|
359
|
+
async function addDigestSRI(id, data, ecsSchemas) {
|
|
360
|
+
if (!id || !data) {
|
|
361
|
+
throw new Error(`id and data has requiered`);
|
|
362
|
+
}
|
|
363
|
+
const response = await fetch((0, vs_agent_model_1.mapToEcosystem)(id));
|
|
364
|
+
const key = id.split('/').pop();
|
|
365
|
+
const fallbackSchema = key && (ecsSchemas === null || ecsSchemas === void 0 ? void 0 : ecsSchemas[key]);
|
|
366
|
+
const schemaContent = response.ok ? await response.text() : fallbackSchema;
|
|
367
|
+
if (!schemaContent) {
|
|
368
|
+
throw new Error(`Failed to fetch schema from ${id}: ${response.status} ${response.statusText}, and no local fallback found.`);
|
|
369
|
+
}
|
|
370
|
+
assertValidSchema(schemaContent, id);
|
|
371
|
+
return Object.assign(Object.assign({}, data), { digestSRI: generateDigestSRI(schemaContent) });
|
|
372
|
+
}
|
|
373
|
+
function assertValidSchema(schemaContent, id) {
|
|
374
|
+
var _a, _b;
|
|
375
|
+
try {
|
|
376
|
+
if (!ajv.validateSchema(JSON.parse(schemaContent))) {
|
|
377
|
+
const reason = (_b = (_a = ajv.errors) === null || _a === void 0 ? void 0 : _a.map(e => e.message).join(', ')) !== null && _b !== void 0 ? _b : 'Invalid schema structure';
|
|
378
|
+
throw new Error(reason);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
const message = error instanceof SyntaxError
|
|
383
|
+
? 'Invalid JSON format'
|
|
384
|
+
: error instanceof Error
|
|
385
|
+
? error.message
|
|
386
|
+
: 'Unknown error';
|
|
387
|
+
throw new Error(`Schema from ${id} is not valid: ${message}`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Generates a SRI digest string for the given content using the specified algorithm.
|
|
392
|
+
* @param content - The content to hash.
|
|
393
|
+
* @param algorithm - The hash algorithm to use (default: sha256).
|
|
394
|
+
* @returns The SRI digest string.
|
|
395
|
+
*/
|
|
396
|
+
function generateDigestSRI(content, algorithm = 'sha384') {
|
|
397
|
+
const hash = (0, crypto_1.createHash)(algorithm).update(content).digest('base64');
|
|
398
|
+
return `${algorithm}-${hash}`;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Converts an image URL to a Base64-encoded data URI string.
|
|
402
|
+
*
|
|
403
|
+
* @param url - The image URL to convert.
|
|
404
|
+
* @returns A Base64 data URI string, or a fallback placeholder if the image cannot be fetched or is invalid.
|
|
405
|
+
*/
|
|
406
|
+
async function urlToBase64(logger, url, fallback) {
|
|
407
|
+
var _a, _b;
|
|
408
|
+
if (!url) {
|
|
409
|
+
logger.warn('No URL provided for image conversion.');
|
|
410
|
+
return fallback;
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
const response = await axios_1.default.get(url, { responseType: 'arraybuffer' });
|
|
414
|
+
const contentType = response.headers['content-type'];
|
|
415
|
+
if (!contentType || !contentType.startsWith('image/')) {
|
|
416
|
+
logger.warn(`The fetched resource is not an image. Content-Type: ${contentType}`);
|
|
417
|
+
return fallback;
|
|
418
|
+
}
|
|
419
|
+
const base64 = Buffer.from(response.data).toString('base64');
|
|
420
|
+
return `data:${contentType};base64,${base64}`;
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
if ((0, axios_1.isAxiosError)(error)) {
|
|
424
|
+
logger.error(`Failed to convert URL to Base64. URL: ${url}. ` +
|
|
425
|
+
`Status: ${(_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 'N/A'}. ` +
|
|
426
|
+
`Message: ${error.message}`);
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
logger.error(`Unexpected error converting URL to Base64: ${error}`);
|
|
430
|
+
}
|
|
431
|
+
return fallback;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function getVerificationMethodId(logger, didRecord) {
|
|
435
|
+
var _a, _b;
|
|
436
|
+
try {
|
|
437
|
+
const verificationMethod = (_b = (_a = didRecord.didDocument) === null || _a === void 0 ? void 0 : _a.verificationMethod) === null || _b === void 0 ? void 0 : _b.find(method => {
|
|
438
|
+
var _a, _b;
|
|
439
|
+
return (method.type === 'Ed25519VerificationKey2020' || method.type === 'Ed25519VerificationKey2018') &&
|
|
440
|
+
method.id === ((_b = (_a = didRecord.didDocument) === null || _a === void 0 ? void 0 : _a.assertionMethod) === null || _b === void 0 ? void 0 : _b[0]);
|
|
441
|
+
});
|
|
442
|
+
if (!verificationMethod) {
|
|
443
|
+
throw new Error('Cannot find a suitable Ed25519Signature2020 verification method in DID Document');
|
|
444
|
+
}
|
|
445
|
+
return verificationMethod.id;
|
|
446
|
+
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
logger.error(`Failed to get verification method ID.`, error);
|
|
449
|
+
throw error;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
//# sourceMappingURL=setupS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,CAAC,IAAI,KAAK,4BAA4B,CAAC;gBAC9F,MAAM,CAAC,EAAE,MAAK,MAAA,MAAA,SAAS,CAAC,WAAW,0CAAE,eAAe,0CAAG,CAAC,CAAC,CAAA,CAAA;SAAA,CAC5D,CAAA;QACD,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAA;QACpG,CAAC;QACD,OAAO,kBAAkB,CAAC,EAAE,CAAA;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAA;QAC5D,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DidRecord, W3cJsonLdVerifiableCredential, W3cJsonLdVerifiablePresentation } from '@credo-ts/core';
|
|
2
|
+
import { VsAgent } from '../agent/VsAgent';
|
|
3
|
+
export declare function findMetadataEntry(didRecord: DidRecord, key: '_vt/vtc' | '_vt/jsc', id?: string, jsonSchemaRef?: string): any;
|
|
4
|
+
export declare function saveMetadataEntry(agent: VsAgent, didRecord: DidRecord, credential: W3cJsonLdVerifiableCredential, verifiablePresentation: W3cJsonLdVerifiablePresentation, didDocumentServiceId: string, key: '_vt/vtc' | '_vt/jsc', publicApiBaseUrl: string): Promise<void>;
|
|
5
|
+
export declare function deleteMetadataEntry(agent: VsAgent, id: string, didRecord: DidRecord, key: '_vt/vtc' | '_vt/jsc', publicApiBaseUrl: string): Promise<{
|
|
6
|
+
schemaId: any;
|
|
7
|
+
} | null>;
|
|
8
|
+
export declare function createVtc(agent: VsAgent, publicApiBaseUrl: string, id: string, credential: W3cJsonLdVerifiableCredential): Promise<W3cJsonLdVerifiablePresentation>;
|
|
9
|
+
export interface CreateJscOptions {
|
|
10
|
+
schemaBaseId: string;
|
|
11
|
+
jsonSchemaRef: string;
|
|
12
|
+
precomputedDigestSRI?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createJsc(agent: VsAgent, publicApiBaseUrl: string, ecsSchemas: Record<string, string>, options: CreateJscOptions): Promise<import("@credo-ts/core").W3cJsonCredential>;
|
|
15
|
+
export declare function removeTrustCredential(agent: VsAgent, publicApiBaseUrl: string, schemaId: string, key: '_vt/jsc' | '_vt/vtc'): Promise<{
|
|
16
|
+
schemaId: any;
|
|
17
|
+
} | null>;
|
|
18
|
+
export declare function getTrustMetadata(didRecord: DidRecord, key: '_vt/vtc' | '_vt/jsc', schemaId?: string): any;
|