@verana-labs/vs-agent-sdk 2.0.0-dev.37 → 2.0.0-dev.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/build/agent/VsAgent.d.ts +3 -0
  2. package/build/agent/VsAgent.js +3 -23
  3. package/build/agent/VsAgent.js.map +1 -1
  4. package/build/agent/createVsAgent.d.ts +2 -0
  5. package/build/agent/createVsAgent.js +1 -0
  6. package/build/agent/createVsAgent.js.map +1 -1
  7. package/build/blockchain/handlers/selfIssuanceHandlers.d.ts +2 -2
  8. package/build/blockchain/handlers/selfIssuanceHandlers.js +3 -3
  9. package/build/blockchain/handlers/selfIssuanceHandlers.js.map +1 -1
  10. package/build/blockchain/handlers/stateMutations.d.ts +3 -3
  11. package/build/blockchain/handlers/stateMutations.js +29 -13
  12. package/build/blockchain/handlers/stateMutations.js.map +1 -1
  13. package/build/bootstrap/EcsBootstrapService.d.ts +1 -0
  14. package/build/bootstrap/EcsBootstrapService.js +14 -3
  15. package/build/bootstrap/EcsBootstrapService.js.map +1 -1
  16. package/build/utils/ecsClaims.d.ts +47 -0
  17. package/build/utils/ecsClaims.js +120 -0
  18. package/build/utils/ecsClaims.js.map +1 -0
  19. package/build/utils/index.d.ts +1 -0
  20. package/build/utils/index.js +1 -0
  21. package/build/utils/index.js.map +1 -1
  22. package/build/utils/selfIssuedEcsCredential.d.ts +4 -0
  23. package/build/utils/selfIssuedEcsCredential.js +140 -0
  24. package/build/utils/selfIssuedEcsCredential.js.map +1 -0
  25. package/build/utils/setupSelfTr.d.ts +2 -57
  26. package/build/utils/setupSelfTr.js +8 -286
  27. package/build/utils/setupSelfTr.js.map +1 -1
  28. package/build/utils/trustCredentialStore.d.ts +9 -9
  29. package/build/utils/trustCredentialStore.js +28 -75
  30. package/build/utils/trustCredentialStore.js.map +1 -1
  31. package/build/vtFlow/VtFlowOrchestrator.js +1 -1
  32. package/build/vtFlow/VtFlowOrchestrator.js.map +1 -1
  33. package/package.json +3 -3
@@ -0,0 +1,47 @@
1
+ import type { Logger } from '@credo-ts/core';
2
+ export interface EcsClaims {
3
+ localResources?: Record<string, string>;
4
+ org?: Record<string, string | undefined>;
5
+ persona?: Record<string, string | undefined>;
6
+ service?: Record<string, string | undefined>;
7
+ }
8
+ export declare const ECS_CLAIMS_VARIABLES: {
9
+ readonly org: {
10
+ readonly name: "ECS_CLAIMS_ORG_NAME";
11
+ readonly logoUri: "ECS_CLAIMS_ORG_LOGO_URI";
12
+ readonly registryId: "ECS_CLAIMS_ORG_REGISTRY_ID";
13
+ readonly registryUri: "ECS_CLAIMS_ORG_REGISTRY_URI";
14
+ readonly address: "ECS_CLAIMS_ORG_ADDRESS";
15
+ readonly countryCode: "ECS_CLAIMS_ORG_COUNTRY_CODE";
16
+ readonly legalJurisdiction: "ECS_CLAIMS_ORG_LEGAL_JURISDICTION";
17
+ readonly organizationKind: "ECS_CLAIMS_ORG_ORGANIZATION_KIND";
18
+ readonly lei: "ECS_CLAIMS_ORG_LEI";
19
+ };
20
+ readonly persona: {
21
+ readonly name: "ECS_CLAIMS_PERSONA_NAME";
22
+ readonly description: "ECS_CLAIMS_PERSONA_DESCRIPTION";
23
+ readonly descriptionFormat: "ECS_CLAIMS_PERSONA_DESCRIPTION_FORMAT";
24
+ readonly avatarUri: "ECS_CLAIMS_PERSONA_AVATAR_URI";
25
+ readonly controllerCountryCode: "ECS_CLAIMS_PERSONA_CONTROLLER_COUNTRY_CODE";
26
+ readonly controllerJurisdiction: "ECS_CLAIMS_PERSONA_CONTROLLER_JURISDICTION";
27
+ };
28
+ readonly service: {
29
+ readonly name: "ECS_CLAIMS_SERVICE_NAME";
30
+ readonly type: "ECS_CLAIMS_SERVICE_TYPE";
31
+ readonly description: "ECS_CLAIMS_SERVICE_DESCRIPTION";
32
+ readonly descriptionFormat: "ECS_CLAIMS_SERVICE_DESCRIPTION_FORMAT";
33
+ readonly logoUri: "ECS_CLAIMS_SERVICE_LOGO_URI";
34
+ readonly minimumAgeRequired: "ECS_CLAIMS_SERVICE_MINIMUM_AGE_REQUIRED";
35
+ readonly termsAndConditionsUri: "ECS_CLAIMS_SERVICE_TERMS_AND_CONDITIONS_URI";
36
+ readonly privacyPolicyUri: "ECS_CLAIMS_SERVICE_PRIVACY_POLICY_URI";
37
+ };
38
+ };
39
+ export declare function readEcsClaimsFromEnv(): Required<Pick<EcsClaims, 'org' | 'persona' | 'service'>>;
40
+ export declare function digestOf(content: string): string;
41
+ export declare function digestOfUri(uri: string, variable: string, logger?: Logger): Promise<string>;
42
+ /**
43
+ * Compose the claims of one ECS credential from the configured variables, deriving `id` and
44
+ * every paired `*DigestSri`. Returns undefined when the operator configured no claim, so the
45
+ * caller can omit the `claims` field entirely.
46
+ */
47
+ export declare function composeEcsClaims(claims: EcsClaims, schemaKey: string, logger?: Logger): Promise<Record<string, unknown> | undefined>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ECS_CLAIMS_VARIABLES = void 0;
7
+ exports.readEcsClaimsFromEnv = readEcsClaimsFromEnv;
8
+ exports.digestOf = digestOf;
9
+ exports.digestOfUri = digestOfUri;
10
+ exports.composeEcsClaims = composeEcsClaims;
11
+ const crypto_1 = require("crypto");
12
+ const axios_1 = __importDefault(require("axios"));
13
+ // the URI claim each derived digest claim is computed from
14
+ const DIGEST_OF = {
15
+ logoDigestSri: 'logoUri',
16
+ avatarDigestSri: 'avatarUri',
17
+ termsAndConditionsDigestSri: 'termsAndConditionsUri',
18
+ privacyPolicyDigestSri: 'privacyPolicyUri',
19
+ };
20
+ // [VSA-VTI-CFG-ENV-ECS] variable of each claim the agent reads
21
+ exports.ECS_CLAIMS_VARIABLES = {
22
+ org: {
23
+ name: 'ECS_CLAIMS_ORG_NAME',
24
+ logoUri: 'ECS_CLAIMS_ORG_LOGO_URI',
25
+ registryId: 'ECS_CLAIMS_ORG_REGISTRY_ID',
26
+ registryUri: 'ECS_CLAIMS_ORG_REGISTRY_URI',
27
+ address: 'ECS_CLAIMS_ORG_ADDRESS',
28
+ countryCode: 'ECS_CLAIMS_ORG_COUNTRY_CODE',
29
+ legalJurisdiction: 'ECS_CLAIMS_ORG_LEGAL_JURISDICTION',
30
+ organizationKind: 'ECS_CLAIMS_ORG_ORGANIZATION_KIND',
31
+ lei: 'ECS_CLAIMS_ORG_LEI',
32
+ },
33
+ persona: {
34
+ name: 'ECS_CLAIMS_PERSONA_NAME',
35
+ description: 'ECS_CLAIMS_PERSONA_DESCRIPTION',
36
+ descriptionFormat: 'ECS_CLAIMS_PERSONA_DESCRIPTION_FORMAT',
37
+ avatarUri: 'ECS_CLAIMS_PERSONA_AVATAR_URI',
38
+ controllerCountryCode: 'ECS_CLAIMS_PERSONA_CONTROLLER_COUNTRY_CODE',
39
+ controllerJurisdiction: 'ECS_CLAIMS_PERSONA_CONTROLLER_JURISDICTION',
40
+ },
41
+ service: {
42
+ name: 'ECS_CLAIMS_SERVICE_NAME',
43
+ type: 'ECS_CLAIMS_SERVICE_TYPE',
44
+ description: 'ECS_CLAIMS_SERVICE_DESCRIPTION',
45
+ descriptionFormat: 'ECS_CLAIMS_SERVICE_DESCRIPTION_FORMAT',
46
+ logoUri: 'ECS_CLAIMS_SERVICE_LOGO_URI',
47
+ minimumAgeRequired: 'ECS_CLAIMS_SERVICE_MINIMUM_AGE_REQUIRED',
48
+ termsAndConditionsUri: 'ECS_CLAIMS_SERVICE_TERMS_AND_CONDITIONS_URI',
49
+ privacyPolicyUri: 'ECS_CLAIMS_SERVICE_PRIVACY_POLICY_URI',
50
+ },
51
+ };
52
+ function readEcsClaimsFromEnv() {
53
+ const read = (variables) => Object.fromEntries(Object.entries(variables).map(([claim, name]) => { var _a; return [claim, ((_a = process.env[name]) === null || _a === void 0 ? void 0 : _a.trim()) || undefined]; }));
54
+ return {
55
+ org: read(exports.ECS_CLAIMS_VARIABLES.org),
56
+ persona: read(exports.ECS_CLAIMS_VARIABLES.persona),
57
+ service: read(exports.ECS_CLAIMS_VARIABLES.service),
58
+ };
59
+ }
60
+ const DIGEST_TIMEOUT_MS = 5000;
61
+ const DIGEST_ATTEMPTS = 4;
62
+ const DIGEST_BASE_DELAY_MS = 500;
63
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
64
+ // Generate a SHA-384 digest for the given content
65
+ function digestOf(content) {
66
+ return `sha384-${(0, crypto_1.createHash)('sha384').update(content).digest('base64')}`;
67
+ }
68
+ async function digestOfUri(uri, variable, logger) {
69
+ let lastError;
70
+ for (let attempt = 1; attempt <= DIGEST_ATTEMPTS; attempt++) {
71
+ try {
72
+ const response = await axios_1.default.get(uri, { responseType: 'arraybuffer', timeout: DIGEST_TIMEOUT_MS });
73
+ return `sha384-${(0, crypto_1.createHash)('sha384').update(Buffer.from(response.data)).digest('base64')}`;
74
+ }
75
+ catch (error) {
76
+ lastError = error;
77
+ if (attempt < DIGEST_ATTEMPTS)
78
+ await sleep(DIGEST_BASE_DELAY_MS * 2 ** (attempt - 1));
79
+ }
80
+ }
81
+ const message = `cannot compute the digest of ${variable} (${uri}): ${lastError === null || lastError === void 0 ? void 0 : lastError.message}`;
82
+ logger === null || logger === void 0 ? void 0 : logger.error(`[ecs-claims] ${message}`);
83
+ throw new Error(message);
84
+ }
85
+ const GROUP_OF = {
86
+ 'ecs-service': 'service',
87
+ 'ecs-persona': 'persona',
88
+ 'ecs-org': 'org',
89
+ };
90
+ const groupOf = (claims, schemaKey) => {
91
+ const group = GROUP_OF[schemaKey];
92
+ return group ? claims[group] : undefined;
93
+ };
94
+ /**
95
+ * Compose the claims of one ECS credential from the configured variables, deriving `id` and
96
+ * every paired `*DigestSri`. Returns undefined when the operator configured no claim, so the
97
+ * caller can omit the `claims` field entirely.
98
+ */
99
+ async function composeEcsClaims(claims, schemaKey, logger) {
100
+ var _a;
101
+ const configured = groupOf(claims, schemaKey);
102
+ const set = Object.entries(configured !== null && configured !== void 0 ? configured : {}).filter(([, v]) => v !== undefined && v !== '');
103
+ if (set.length === 0)
104
+ return undefined;
105
+ const composed = {};
106
+ for (const [claim, value] of set) {
107
+ composed[claim] = claim === 'minimumAgeRequired' ? Number(value) : value;
108
+ }
109
+ for (const [digestClaim, uriClaim] of Object.entries(DIGEST_OF)) {
110
+ const uri = composed[uriClaim];
111
+ if (typeof uri !== 'string')
112
+ continue;
113
+ const group = GROUP_OF[schemaKey];
114
+ const variable = (group && exports.ECS_CLAIMS_VARIABLES[group][uriClaim]) || uriClaim;
115
+ const local = (_a = claims.localResources) === null || _a === void 0 ? void 0 : _a[uri];
116
+ composed[digestClaim] = local ? digestOf(local) : await digestOfUri(uri, variable, logger);
117
+ }
118
+ return composed;
119
+ }
120
+ //# sourceMappingURL=ecsClaims.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecsClaims.js","sourceRoot":"","sources":["../../src/utils/ecsClaims.ts"],"names":[],"mappings":";;;;;;AAyDA,oDAUC;AASD,4BAEC;AAED,kCAcC;AAkBD,4CAsBC;AApID,mCAAmC;AAEnC,kDAAyB;AAYzB,2DAA2D;AAC3D,MAAM,SAAS,GAA2B;IACxC,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,WAAW;IAC5B,2BAA2B,EAAE,uBAAuB;IACpD,sBAAsB,EAAE,kBAAkB;CAC3C,CAAA;AAED,+DAA+D;AAClD,QAAA,oBAAoB,GAAG;IAClC,GAAG,EAAE;QACH,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,yBAAyB;QAClC,UAAU,EAAE,4BAA4B;QACxC,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,wBAAwB;QACjC,WAAW,EAAE,6BAA6B;QAC1C,iBAAiB,EAAE,mCAAmC;QACtD,gBAAgB,EAAE,kCAAkC;QACpD,GAAG,EAAE,oBAAoB;KAC1B;IACD,OAAO,EAAE;QACP,IAAI,E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ACjC,MAAM,QAAQ,GAAG,CAAC,KAAK,IAAK,4BAAoB,CAAC,KAAK,CAA4B,CAAC,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAA;QACzG,MAAM,KAAK,GAAG,MAAA,MAAM,CAAC,cAAc,0CAAG,GAAG,CAAC,CAAA;QAC1C,QAAQ,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC5F,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export * from './agent';
2
2
  export * from './data';
3
+ export * from './ecsClaims';
3
4
  export * from './setupSelfTr';
4
5
  export * from './trustCredentialStore';
5
6
  export * from './util';
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./agent"), exports);
18
18
  __exportStar(require("./data"), exports);
19
+ __exportStar(require("./ecsClaims"), exports);
19
20
  __exportStar(require("./setupSelfTr"), exports);
20
21
  __exportStar(require("./trustCredentialStore"), exports);
21
22
  __exportStar(require("./util"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,yCAAsB;AACtB,gDAA6B;AAC7B,yDAAsC;AACtC,yCAAsB;AACtB,kDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,yCAAsB;AACtB,8CAA2B;AAC3B,gDAA6B;AAC7B,yDAAsC;AACtC,yCAAsB;AACtB,kDAA+B"}
@@ -0,0 +1,4 @@
1
+ import { W3cCredentialSchema } from '@credo-ts/core';
2
+ import { VsAgent } from '../agent/VsAgent';
3
+ import { EcsClaims } from './ecsClaims';
4
+ export declare function publishSelfIssuedEcsPresentation(agent: VsAgent, id: string, ecsSchemas: Record<string, string>, schemaKey: string, type: string[], credentialSchema: W3cCredentialSchema, ecsClaims: EcsClaims, beforePublish?: (verifiablePresentation: any) => Promise<void>): Promise<any>;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publishSelfIssuedEcsPresentation = publishSelfIssuedEcsPresentation;
4
+ const core_1 = require("@credo-ts/core");
5
+ const setupSelfTr_1 = require("./setupSelfTr");
6
+ const buildIntegrityData = (data) => {
7
+ return (0, setupSelfTr_1.generateDigestSRI)(JSON.stringify((0, setupSelfTr_1.sortKeysDeep)(data)));
8
+ };
9
+ function storedCredentialIsCurrent(credential, credentialSchemaId, did, didRecord) {
10
+ var _a, _b, _c;
11
+ if (!credential)
12
+ return false;
13
+ const issuer = typeof credential.issuer === 'string' ? credential.issuer : (_a = credential.issuer) === null || _a === void 0 ? void 0 : _a.id;
14
+ if (issuer !== did)
15
+ return false;
16
+ const schema = Array.isArray(credential.credentialSchema)
17
+ ? credential.credentialSchema[0]
18
+ : credential.credentialSchema;
19
+ if ((schema === null || schema === void 0 ? void 0 : schema.id) !== credentialSchemaId)
20
+ return false;
21
+ const proofs = !credential.proof
22
+ ? []
23
+ : Array.isArray(credential.proof)
24
+ ? credential.proof
25
+ : [credential.proof];
26
+ if (proofs.length === 0)
27
+ return false;
28
+ const assertionMethods = new Set(((_c = (_b = didRecord.didDocument) === null || _b === void 0 ? void 0 : _b.assertionMethod) !== null && _c !== void 0 ? _c : []).map(entry => typeof entry === 'string' ? entry : entry.id));
29
+ return proofs.every(proof => !!proof.verificationMethod && assertionMethods.has(proof.verificationMethod));
30
+ }
31
+ async function signSelfIssuedEcsCredential(agent, didRecord, type, claims, credentialSchema, presentation) {
32
+ const unsignedCredential = (0, setupSelfTr_1.createCredential)({
33
+ id: agent.did,
34
+ type,
35
+ issuer: agent.did,
36
+ credentialSubject: { id: agent.did, claims },
37
+ });
38
+ unsignedCredential.credentialSchema = credentialSchema;
39
+ const verificationMethodId = (0, setupSelfTr_1.getVerificationMethodId)(agent.config.logger, didRecord);
40
+ const signedCredential = await (0, setupSelfTr_1.signerW3c)(agent, unsignedCredential, verificationMethodId);
41
+ presentation.verifiableCredential = [signedCredential];
42
+ return await (0, setupSelfTr_1.signerW3c)(agent, presentation, verificationMethodId);
43
+ }
44
+ async function publishSelfIssuedEcsPresentation(agent, id, ecsSchemas, schemaKey, type, credentialSchema, ecsClaims, beforePublish) {
45
+ var _a, _b, _c, _d, _e, _f, _g;
46
+ if (!agent.did)
47
+ throw Error('The DID must be set up');
48
+ const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did });
49
+ const didDocument = didRecord.didDocument;
50
+ if (!didDocument)
51
+ throw Error('The DID Document must be set up');
52
+ const claims = await (0, setupSelfTr_1.getClaims)(agent.config.logger, ecsSchemas, { id: agent.did }, schemaKey, ecsClaims);
53
+ const didDocumentServiceId = `${agent.did}#${(0, setupSelfTr_1.linkedVpFragment)(schemaKey)}`;
54
+ const integrityData = buildIntegrityData({ id, type, credentialSchema, claims });
55
+ const record = (_a = didRecord.metadata.get('_vt/vtc')) !== null && _a !== void 0 ? _a : {};
56
+ const metadata = record[credentialSchema.id];
57
+ const superseded = Object.entries(record).some(([storedSchemaId, entry]) => {
58
+ var _a;
59
+ return storedSchemaId !== credentialSchema.id &&
60
+ ((_a = entry === null || entry === void 0 ? void 0 : entry.verifiablePresentation) === null || _a === void 0 ? void 0 : _a.id) === id &&
61
+ (entry === null || entry === void 0 ? void 0 : entry.attached) !== false;
62
+ });
63
+ const attached = ((_b = metadata === null || metadata === void 0 ? void 0 : metadata.attached) !== null && _b !== void 0 ? _b : true) && !superseded;
64
+ if ((metadata === null || metadata === void 0 ? void 0 : metadata.integrityData) === integrityData &&
65
+ storedCredentialIsCurrent(metadata === null || metadata === void 0 ? void 0 : metadata.credential, credentialSchema.id, agent.did, didRecord)) {
66
+ // the presentation is already public, so a failed beforePublish step still needs a retry here
67
+ if (attached)
68
+ await (beforePublish === null || beforePublish === void 0 ? void 0 : beforePublish(metadata.verifiablePresentation));
69
+ return metadata.verifiablePresentation;
70
+ }
71
+ const presentation = (0, setupSelfTr_1.createPresentation)({
72
+ id,
73
+ holder: agent.did,
74
+ verifiableCredential: [],
75
+ });
76
+ const verifiablePresentation = await signSelfIssuedEcsCredential(agent, didRecord, type, claims, credentialSchema, presentation);
77
+ // nothing is persisted yet, so a failure here leaves no public presentation behind
78
+ if (attached)
79
+ await (beforePublish === null || beforePublish === void 0 ? void 0 : beforePublish(verifiablePresentation));
80
+ // Update linked VP when the presentation has changed
81
+ if (attached)
82
+ didDocument.service = (_c = didDocument.service) === null || _c === void 0 ? void 0 : _c.map(s => {
83
+ if (typeof s.serviceEndpoint !== 'string')
84
+ return s;
85
+ if (s.serviceEndpoint.includes(schemaKey) && s.id !== `${agent.did}#whois`) {
86
+ s.id = didDocumentServiceId;
87
+ s.serviceEndpoint = id;
88
+ }
89
+ return s;
90
+ });
91
+ // Resolvers only discover the credential through the [VT-CRED-W3C-LINKED-VP] fragment, and
92
+ // #whois does not match it. The rename above only covers documents that already carry the
93
+ // service, so publish it here when nothing declared it yet.
94
+ let didDocumentChanged = false;
95
+ if (attached && !((_d = didDocument.service) === null || _d === void 0 ? void 0 : _d.some(s => s.id === didDocumentServiceId))) {
96
+ didDocument.service = [
97
+ ...((_e = didDocument.service) !== null && _e !== void 0 ? _e : []),
98
+ new core_1.DidDocumentService({
99
+ id: didDocumentServiceId,
100
+ serviceEndpoint: id,
101
+ type: 'LinkedVerifiablePresentation',
102
+ }),
103
+ ];
104
+ didDocumentChanged = true;
105
+ }
106
+ const whoisId = `${agent.did}#whois`;
107
+ if (attached && schemaKey === 'ecs-service') {
108
+ const whois = (_f = didDocument.service) === null || _f === void 0 ? void 0 : _f.find(s => s.id === whoisId);
109
+ if (whois) {
110
+ if (whois.serviceEndpoint !== id) {
111
+ whois.serviceEndpoint = id;
112
+ didDocumentChanged = true;
113
+ }
114
+ }
115
+ else {
116
+ didDocument.service = [
117
+ ...((_g = didDocument.service) !== null && _g !== void 0 ? _g : []),
118
+ new core_1.DidDocumentService({ id: whoisId, serviceEndpoint: id, type: 'LinkedVerifiablePresentation' }),
119
+ ];
120
+ didDocumentChanged = true;
121
+ }
122
+ }
123
+ const credential = Array.isArray(verifiablePresentation.verifiableCredential)
124
+ ? verifiablePresentation.verifiableCredential[0]
125
+ : verifiablePresentation.verifiableCredential;
126
+ record[credentialSchema.id] = {
127
+ credential,
128
+ verifiablePresentation,
129
+ didDocumentServiceId,
130
+ integrityData,
131
+ attached,
132
+ };
133
+ didRecord.metadata.set('_vt/vtc', record);
134
+ await agent.context.dependencyManager.resolve(core_1.DidRepository).update(agent.context, didRecord);
135
+ if (didDocumentChanged) {
136
+ await agent.dids.update({ did: didRecord.did, didDocument });
137
+ }
138
+ return verifiablePresentation;
139
+ }
140
+ //# sourceMappingURL=selfIssuedEcsCredential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selfIssuedEcsCredential.js","sourceRoot":"","sources":["../../src/utils/selfIssuedEcsCredential.ts"],"names":[],"mappings":";;AAqFA,4EA2GC;AAhMD,yCAQuB;AAIvB,+CASsB;AAEtB,MAAM,kBAAkB,GAAG,CAAC,IAA6B,EAAE,EAAE;IAC3D,OAAO,IAAA,+BAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,IAAA,0BAAY,EAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC,CAAA;AAQD,SAAS,yBAAyB,CAChC,UAAkD,EAClD,kBAA0B,EAC1B,GAAW,EACX,SAAoB;;IAEpB,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAA;IAE7B,MAAM,MAAM,GAAG,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,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ACD,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IACzC,MAAM,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,oBAAa,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC7F,IAAI,kBAAkB,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,sBAAsB,CAAA;AAC/B,CAAC"}
@@ -1,42 +1,11 @@
1
1
  import { W3cCredential, W3cPresentation, W3cCredentialSchema, W3cCredentialSubject, W3cJsonLdVerifiableCredential, W3cJsonLdVerifiablePresentation, W3cCredentialOptions, DidRecord, W3cPresentationOptions, Logger } from '@credo-ts/core';
2
2
  import { AnySchemaObject } from 'ajv/dist/2020';
3
3
  import { VsAgent } from '../agent/VsAgent';
4
- export interface SelfTrDefaults {
5
- agentLabel: string;
6
- serviceLogoUri: string;
7
- serviceLogoDigestSri?: string;
8
- serviceType: string;
9
- serviceDescription: string;
10
- serviceMinimumAgeRequired: number;
11
- serviceTermsAndConditions: string;
12
- serviceTermsAndConditionsDigestSri?: string;
13
- servicePrivacyPolicy: string;
14
- servicePrivacyPolicyDigestSri?: string;
15
- orgRegistryId: string;
16
- orgRegistryUri: string;
17
- orgAddress: string;
18
- orgOrganizationKind: string;
19
- orgCountryCode: string;
20
- }
21
- export declare const presentations: {
22
- name: string;
23
- schemaUrl: string;
24
- }[];
25
- export declare const credentials: {
26
- name: string;
27
- credUrl: string;
28
- schemaUrl: string;
29
- }[];
4
+ import { EcsClaims } from './ecsClaims';
30
5
  export declare const createJsonSchema: W3cCredentialSchema;
31
6
  export declare const createJsonSubjectRef: (id: string) => W3cCredentialSubject;
32
7
  export declare const linkedVpFragment: (schemaKey: string) => string;
33
- export declare const mapToSelfTr: (url: string, publicApiBaseUrl: string) => string;
34
8
  export declare const sortKeysDeep: (value: unknown) => unknown;
35
- export declare const setupSelfTr: ({ agent, publicApiBaseUrl, defaults, }: {
36
- agent: VsAgent;
37
- publicApiBaseUrl: string;
38
- defaults: SelfTrDefaults;
39
- }) => Promise<void>;
40
9
  export declare function createCredential(options: Partial<W3cCredentialOptions>): W3cCredential;
41
10
  /**
42
11
  * Signs a W3C Verifiable Credential or Presentation using the provided agent and verification method.
@@ -51,25 +20,6 @@ export declare function createCredential(options: Partial<W3cCredentialOptions>)
51
20
  */
52
21
  export declare function signerW3c(agent: VsAgent, obj: W3cCredential, verificationMethod: string): Promise<W3cJsonLdVerifiableCredential>;
53
22
  export declare function signerW3c(agent: VsAgent, obj: W3cPresentation, verificationMethod: string): Promise<W3cJsonLdVerifiablePresentation>;
54
- /**
55
- * Generates and signs a verifiable presentation containing a verifiable credential.
56
- * Stores the signed presentation and its integrity metadata in the DID record.
57
- *
58
- * - Retrieves and validates claims for the agent's DID.
59
- * - Computes an integrity digest for the claims.
60
- * - If a presentation with the same integrity already exists in the DID metadata, it is returned.
61
- * - Otherwise, a new presentation is created, signed, and stored in the DID metadata.
62
- *
63
- * @param agent - The VsAgent instance used for signing and DID management.
64
- * @param logger - Logger instance for logging operations.
65
- * @param ecsSchemas - Map of ECS schemas for validation.
66
- * @param schemaKey - Unique identifier for the presentation type and metadata key.
67
- * @param type - Array of credential types to include.
68
- * @param credentialSchema - Schema definition for the credential.
69
- * @param beforePublish - Step that must succeed before a linked presentation counts as published.
70
- * @returns The signed verifiable presentation, with integrity metadata.
71
- */
72
- export declare function generateVerifiablePresentation(agent: VsAgent, id: string, ecsSchemas: Record<string, string>, schemaKey: string, type: string[], credentialSchema: W3cCredentialSchema, defaults: SelfTrDefaults, beforePublish?: (verifiablePresentation: any) => Promise<void>): Promise<any>;
73
23
  export declare function createPresentation(options: Partial<W3cPresentationOptions>): W3cPresentation;
74
24
  /**
75
25
  * Retrieves and validates claims for a credential subject.
@@ -82,7 +32,7 @@ export declare function createPresentation(options: Partial<W3cPresentationOptio
82
32
  * @returns The validated claims object.
83
33
  * @throws If claims are invalid or schema is missing.
84
34
  */
85
- export declare function getClaims(logger: Logger, ecsSchemas: Record<string, string>, { id, claims }: W3cCredentialSubject, schemaKey: string, defaults: SelfTrDefaults): Promise<Record<string, unknown>>;
35
+ export declare function getClaims(logger: Logger, ecsSchemas: Record<string, string>, { id }: W3cCredentialSubject, schemaKey: string, ecsClaims: EcsClaims): Promise<Record<string, unknown>>;
86
36
  /**
87
37
  * Validate a validateSchema object against the corresponding AJV schema.
88
38
  * Throws an Error if the schema is missing or validation fails.
@@ -109,9 +59,4 @@ export declare function addDigestSRI<T extends object>(id?: string, data?: T, ec
109
59
  * @returns The SRI digest string.
110
60
  */
111
61
  export declare function generateDigestSRI(content: string, algorithm?: string): string;
112
- /**
113
- * Digest of the resource a credential references. Throws rather than attest content it could
114
- * not read: a wrong digestSRI is a false integrity claim in a signed credential.
115
- */
116
- export declare function urlDigestSri(url: string): Promise<string>;
117
62
  export declare function getVerificationMethodId(logger: Logger, didRecord: DidRecord): string;