@verana-labs/vs-agent-sdk 2.0.0-dev.36 → 2.0.0-dev.37
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.
|
@@ -4,5 +4,6 @@ import type { ResolverConfig } from '@verana-labs/verre';
|
|
|
4
4
|
export interface AssertVerifiableServiceOptions {
|
|
5
5
|
verifiablePublicRegistries: NonNullable<ResolverConfig['verifiablePublicRegistries']>;
|
|
6
6
|
logger?: BaseLogger;
|
|
7
|
+
positiveTtlMs?: number;
|
|
7
8
|
}
|
|
8
9
|
export declare function assertVerifiableService(options: AssertVerifiableServiceOptions): VtFlowAssertVerifiableServiceHook;
|
|
@@ -2,21 +2,60 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertVerifiableService = assertVerifiableService;
|
|
4
4
|
const verre_1 = require("@verana-labs/verre");
|
|
5
|
+
class VerdictCache {
|
|
6
|
+
constructor(positiveTtlMs = 5 * 60000) {
|
|
7
|
+
this.positiveTtlMs = positiveTtlMs;
|
|
8
|
+
this.map = new Map();
|
|
9
|
+
}
|
|
10
|
+
get(key) {
|
|
11
|
+
const entry = this.map.get(key);
|
|
12
|
+
if (!entry)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (Date.now() > entry.expiresAt) {
|
|
15
|
+
this.map.delete(key);
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return entry.value;
|
|
19
|
+
}
|
|
20
|
+
set(key, value) {
|
|
21
|
+
const entry = { value, expiresAt: Date.now() + this.positiveTtlMs };
|
|
22
|
+
this.map.set(key, entry);
|
|
23
|
+
void value.then(resolution => {
|
|
24
|
+
if (this.map.get(key) !== entry)
|
|
25
|
+
return;
|
|
26
|
+
if (resolution.verified && resolution.outcome === verre_1.TrustResolutionOutcome.VERIFIED)
|
|
27
|
+
return;
|
|
28
|
+
this.map.delete(key);
|
|
29
|
+
}, () => {
|
|
30
|
+
if (this.map.get(key) === entry)
|
|
31
|
+
this.map.delete(key);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
delete(key) {
|
|
35
|
+
this.map.delete(key);
|
|
36
|
+
}
|
|
37
|
+
clear() {
|
|
38
|
+
this.map.clear();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
5
41
|
// VS-CONN-VS gate: delegates trust resolution to `@verana-labs/verre` (`resolveDID`)
|
|
6
42
|
function assertVerifiableService(options) {
|
|
7
|
-
|
|
43
|
+
const cache = new VerdictCache(options.positiveTtlMs);
|
|
8
44
|
return async ({ agentContext, peerDid }) => {
|
|
9
45
|
var _a, _b;
|
|
10
46
|
const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : agentContext.config.logger;
|
|
11
47
|
try {
|
|
12
|
-
|
|
48
|
+
const source = cache.get(peerDid) ? 'cache' : 'fresh';
|
|
13
49
|
const { verified, outcome, metadata } = await (0, verre_1.resolveDID)(peerDid, {
|
|
14
50
|
verifiablePublicRegistries: options.verifiablePublicRegistries,
|
|
15
51
|
cache,
|
|
16
52
|
});
|
|
17
53
|
const trusted = verified && outcome === verre_1.TrustResolutionOutcome.VERIFIED;
|
|
18
54
|
if (!trusted) {
|
|
19
|
-
logger.warn(`[vt-flow] VS-CONN-VS rejected '${peerDid}': verified=${verified} outcome=${outcome} ${(_b = metadata === null || metadata === void 0 ? void 0 : metadata.errorMessage) !== null && _b !== void 0 ? _b : ''}`);
|
|
55
|
+
logger.warn(`[vt-flow] VS-CONN-VS rejected '${peerDid}': verified=${verified} outcome=${outcome} source=${source} ${(_b = metadata === null || metadata === void 0 ? void 0 : metadata.errorMessage) !== null && _b !== void 0 ? _b : ''}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
logger.debug(`[vt-flow] VS-CONN-VS accepted '${peerDid}' source=${source}`);
|
|
20
59
|
}
|
|
21
60
|
return trusted;
|
|
22
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertVerifiableService.js","sourceRoot":"","sources":["../../src/vtFlow/assertVerifiableService.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"assertVerifiableService.js","sourceRoot":"","sources":["../../src/vtFlow/assertVerifiableService.ts"],"names":[],"mappings":";;AAoDA,0DA0BC;AA1ED,8CAAuE;AAQvE,MAAM,YAAY;IAGhB,YAA2B,gBAAwB,CAAC,GAAG,KAAM;QAAlC,kBAAa,GAAb,aAAa,CAAqB;QAFrD,QAAG,GAAG,IAAI,GAAG,EAAkE,CAAA;IAEvB,CAAC;IAE1D,GAAG,CAAC,GAAW;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC/B,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAA;QAC5B,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACpB,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAA;IACpB,CAAC;IAEM,GAAG,CAAC,GAAW,EAAE,KAA+B;QACrD,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACnE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACxB,KAAK,KAAK,CAAC,IAAI,CACb,UAAU,CAAC,EAAE;YACX,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK;gBAAE,OAAM;YACvC,IAAI,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,OAAO,KAAK,8BAAsB,CAAC,QAAQ;gBAAE,OAAM;YACzF,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC,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C;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,kCAAkC,OAAO,YAAY,MAAM,EAAE,CAAC,CAAA;YAC7E,CAAC;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,+CAA+C,OAAO,MAAO,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;YACnG,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"default": "./build/index.js"
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
|
-
"version": "2.0.0-dev.
|
|
12
|
+
"version": "2.0.0-dev.37",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "https://github.com/verana-labs/vs-agent"
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"@cosmjs/proto-signing": "^0.32.3",
|
|
30
30
|
"@cosmjs/stargate": "^0.32.3",
|
|
31
31
|
"@cosmjs/tendermint-rpc": "^0.32.4",
|
|
32
|
-
"@credo-ts/anoncreds": "0.7.1-pr-2704-
|
|
33
|
-
"@credo-ts/askar": "0.7.1-pr-2704-
|
|
34
|
-
"@credo-ts/core": "0.7.1-pr-2704-
|
|
35
|
-
"@credo-ts/didcomm": "0.7.1-pr-2704-
|
|
36
|
-
"@credo-ts/webvh": "0.7.1-pr-2704-
|
|
32
|
+
"@credo-ts/anoncreds": "0.7.1-pr-2704-20260901064803",
|
|
33
|
+
"@credo-ts/askar": "0.7.1-pr-2704-20260901064803",
|
|
34
|
+
"@credo-ts/core": "0.7.1-pr-2704-20260901064803",
|
|
35
|
+
"@credo-ts/didcomm": "0.7.1-pr-2704-20260901064803",
|
|
36
|
+
"@credo-ts/webvh": "0.7.1-pr-2704-20260901064803",
|
|
37
37
|
"@hyperledger/anoncreds-nodejs": "^0.4.0",
|
|
38
38
|
"@openwallet-foundation/askar-nodejs": "^0.6.0",
|
|
39
39
|
"@verana-labs/verana-types": "0.10.2",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"didwebvh-ts": "^2.8.0",
|
|
46
46
|
"express": "^4.18.1",
|
|
47
47
|
"tsyringe": "4.8.0",
|
|
48
|
-
"@verana-labs/credo-ts-didcomm-vt-flow": "2.0.0-dev.
|
|
49
|
-
"@verana-labs/vs-agent-model": "2.0.0-dev.
|
|
48
|
+
"@verana-labs/credo-ts-didcomm-vt-flow": "2.0.0-dev.37",
|
|
49
|
+
"@verana-labs/vs-agent-model": "2.0.0-dev.37"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@credo-ts/core": "0.7.1-pr-2704-
|
|
53
|
-
"@credo-ts/node": "0.7.1-pr-2704-
|
|
52
|
+
"@credo-ts/core": "0.7.1-pr-2704-20260901064803",
|
|
53
|
+
"@credo-ts/node": "0.7.1-pr-2704-20260901064803"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"testcontainers": "^12.0.3",
|