@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,25 @@
|
|
|
1
|
+
import { VsAgent } from '../../agent';
|
|
2
|
+
import { IndexerActivity, VeranaSyncState } from '../types';
|
|
3
|
+
interface IndexerHandlerContext {
|
|
4
|
+
agent: VsAgent;
|
|
5
|
+
block_height: number;
|
|
6
|
+
operatorAddress: string;
|
|
7
|
+
state: VeranaSyncState;
|
|
8
|
+
}
|
|
9
|
+
export interface IndexerEventHandler<TMsg extends string = string> {
|
|
10
|
+
readonly msg: TMsg;
|
|
11
|
+
handle(activity: IndexerActivity, ctx: IndexerHandlerContext): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Registry for handlers of indexer events. Handlers can be registered/unregistered at runtime
|
|
15
|
+
* and are looked up by the `msg` field of indexer activities.
|
|
16
|
+
*/
|
|
17
|
+
export declare class IndexerHandlerRegistry {
|
|
18
|
+
private handlers;
|
|
19
|
+
register(handler: IndexerEventHandler): void;
|
|
20
|
+
unregister(msg: string): void;
|
|
21
|
+
get(msg: string): IndexerEventHandler | undefined;
|
|
22
|
+
has(msg: string): boolean;
|
|
23
|
+
dispatch(activity: IndexerActivity, ctx: IndexerHandlerContext): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndexerHandlerRegistry = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Registry for handlers of indexer events. Handlers can be registered/unregistered at runtime
|
|
6
|
+
* and are looked up by the `msg` field of indexer activities.
|
|
7
|
+
*/
|
|
8
|
+
class IndexerHandlerRegistry {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.handlers = new Map();
|
|
11
|
+
}
|
|
12
|
+
register(handler) {
|
|
13
|
+
this.handlers.set(handler.msg, handler);
|
|
14
|
+
}
|
|
15
|
+
unregister(msg) {
|
|
16
|
+
this.handlers.delete(msg);
|
|
17
|
+
}
|
|
18
|
+
get(msg) {
|
|
19
|
+
return this.handlers.get(msg);
|
|
20
|
+
}
|
|
21
|
+
has(msg) {
|
|
22
|
+
return this.handlers.has(msg);
|
|
23
|
+
}
|
|
24
|
+
async dispatch(activity, ctx) {
|
|
25
|
+
const h = this.handlers.get(activity.msg);
|
|
26
|
+
if (!h) {
|
|
27
|
+
ctx.agent.config.logger.debug(`[IndexerWS] No handler for msg=${activity.msg}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await h.handle(activity, ctx);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.IndexerHandlerRegistry = IndexerHandlerRegistry;
|
|
34
|
+
//# sourceMappingURL=IndexerHandlerRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexerHandlerRegistry.js","sourceRoot":"","sources":["../../../src/blockchain/handlers/IndexerHandlerRegistry.ts"],"names":[],"mappings":";;;AAeA;;;GAGG;AACH,MAAa,sBAAsB;IAAnC;QACU,aAAQ,GAAG,IAAI,GAAG,EAA+B,CAAA;IA0B3D,CAAC;IAxBC,QAAQ,CAAC,OAA4B;QACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAyB,EAAE,GAA0B;QAClE,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACzC,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;YAC/E,OAAM;QACR,CAAC;QACD,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAC/B,CAAC;CACF;AA3BD,wDA2BC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IndexerEventHandler, IndexerHandlerRegistry } from './IndexerHandlerRegistry';
|
|
2
|
+
/**
|
|
3
|
+
* Default handlers for indexer events emitted by the Verana blockchain.
|
|
4
|
+
*/
|
|
5
|
+
export declare const defaultHandlers: IndexerEventHandler[];
|
|
6
|
+
export declare function buildDefaultIndexerHandlerRegistry(): IndexerHandlerRegistry;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultHandlers = void 0;
|
|
4
|
+
exports.buildDefaultIndexerHandlerRegistry = buildDefaultIndexerHandlerRegistry;
|
|
5
|
+
const IndexerHandlerRegistry_1 = require("./IndexerHandlerRegistry");
|
|
6
|
+
const stateMutations_1 = require("./stateMutations");
|
|
7
|
+
/**
|
|
8
|
+
* Default handlers for indexer events emitted by the Verana blockchain.
|
|
9
|
+
*/
|
|
10
|
+
exports.defaultHandlers = [
|
|
11
|
+
{
|
|
12
|
+
msg: 'CreateNewTrustRegistry',
|
|
13
|
+
handle: async (activity, ctx) => {
|
|
14
|
+
(0, stateMutations_1.upsertTrustRegistry)(ctx.state, activity);
|
|
15
|
+
ctx.agent.config.logger.info(`[IndexerWS] CreateNewTrustRegistry entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
msg: 'UpdateTrustRegistry',
|
|
20
|
+
handle: async (activity, ctx) => {
|
|
21
|
+
(0, stateMutations_1.upsertTrustRegistry)(ctx.state, activity);
|
|
22
|
+
ctx.agent.config.logger.info(`[IndexerWS] UpdateTrustRegistry entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
msg: 'AddGovernanceFrameworkDocument',
|
|
27
|
+
handle: async (activity, ctx) => {
|
|
28
|
+
(0, stateMutations_1.upsertTrustRegistry)(ctx.state, activity);
|
|
29
|
+
ctx.agent.config.logger.info(`[IndexerWS] AddGovernanceFrameworkDocument entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
msg: 'IncreaseActiveGFVersion',
|
|
34
|
+
handle: async (activity, ctx) => {
|
|
35
|
+
(0, stateMutations_1.bumpActiveGfVersion)(ctx.state, activity);
|
|
36
|
+
ctx.agent.config.logger.info(`[IndexerWS] IncreaseActiveGFVersion entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
msg: 'CreateNewCredentialSchema',
|
|
41
|
+
handle: async (activity, ctx) => {
|
|
42
|
+
(0, stateMutations_1.upsertCredentialSchema)(ctx.state, activity);
|
|
43
|
+
ctx.agent.config.logger.info(`[IndexerWS] CreateNewCredentialSchema entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
44
|
+
await (0, stateMutations_1.publishVtjscIfOwner)(ctx.state, ctx.agent, String(activity.entity_id));
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
msg: 'UpdateCredentialSchema',
|
|
49
|
+
handle: async (activity, ctx) => {
|
|
50
|
+
(0, stateMutations_1.upsertCredentialSchema)(ctx.state, activity);
|
|
51
|
+
ctx.agent.config.logger.info(`[IndexerWS] UpdateCredentialSchema entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
msg: 'ArchiveCredentialSchema',
|
|
56
|
+
handle: async (activity, ctx) => {
|
|
57
|
+
(0, stateMutations_1.upsertCredentialSchema)(ctx.state, activity);
|
|
58
|
+
ctx.agent.config.logger.info(`[IndexerWS] ArchiveCredentialSchema entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
msg: 'StartPermissionVP',
|
|
63
|
+
handle: async (activity, ctx) => {
|
|
64
|
+
(0, stateMutations_1.upsertPermission)(ctx.state, activity, { vpState: 'PENDING' });
|
|
65
|
+
ctx.agent.config.logger.info(`[IndexerWS] StartPermissionVP entity=${activity.entity_id} block=${ctx.block_height} — TODO §5.1: progress credential acquisition flow (applicant)`);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
msg: 'RenewPermissionVP',
|
|
70
|
+
handle: async (activity, ctx) => {
|
|
71
|
+
(0, stateMutations_1.upsertPermission)(ctx.state, activity, { vpState: 'PENDING' });
|
|
72
|
+
ctx.agent.config.logger.info(`[IndexerWS] RenewPermissionVP entity=${activity.entity_id} block=${ctx.block_height} — TODO §5.1: progress credential acquisition flow (applicant renewal)`);
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
msg: 'SetPermissionVPToValidated',
|
|
77
|
+
handle: async (activity, ctx) => {
|
|
78
|
+
(0, stateMutations_1.upsertPermission)(ctx.state, activity, { vpState: 'VALIDATED' });
|
|
79
|
+
ctx.agent.config.logger.info(`[IndexerWS] SetPermissionVPToValidated entity=${activity.entity_id} block=${ctx.block_height} — TODO §5.1: progress credential acquisition flow (validator)`);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
msg: 'AdjustPermission',
|
|
84
|
+
handle: async (activity, ctx) => {
|
|
85
|
+
var _a;
|
|
86
|
+
(0, stateMutations_1.upsertPermission)(ctx.state, activity, {
|
|
87
|
+
effectiveUntil: String((_a = activity.changes['effective_until']) !== null && _a !== void 0 ? _a : ''),
|
|
88
|
+
});
|
|
89
|
+
ctx.agent.config.logger.info(`[IndexerWS] AdjustPermission entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
msg: 'RevokePermission',
|
|
94
|
+
handle: async (activity, ctx) => {
|
|
95
|
+
(0, stateMutations_1.upsertPermission)(ctx.state, activity, { revoked: true });
|
|
96
|
+
ctx.agent.config.logger.info(`[IndexerWS] RevokePermission entity=${activity.entity_id} block=${ctx.block_height} — TODO §7.2: remove linked VP from DID doc + delete credential`);
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
msg: 'SlashPermissionTrustDeposit',
|
|
101
|
+
handle: async (activity, ctx) => {
|
|
102
|
+
(0, stateMutations_1.upsertPermission)(ctx.state, activity, { slashed: true });
|
|
103
|
+
ctx.agent.config.logger.info(`[IndexerWS] SlashPermissionTrustDeposit entity=${activity.entity_id} block=${ctx.block_height} — TODO §7.2: clean up associated flow state`);
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
msg: 'RepayPermissionSlashedTrustDeposit',
|
|
108
|
+
handle: async (activity, ctx) => {
|
|
109
|
+
(0, stateMutations_1.upsertPermission)(ctx.state, activity, { slashed: false });
|
|
110
|
+
ctx.agent.config.logger.info(`[IndexerWS] RepayPermissionSlashedTrustDeposit entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
msg: 'CancelPermissionVPLastRequest',
|
|
115
|
+
handle: async (activity, ctx) => {
|
|
116
|
+
(0, stateMutations_1.upsertPermission)(ctx.state, activity, {});
|
|
117
|
+
ctx.agent.config.logger.info(`[IndexerWS] CancelPermissionVPLastRequest entity=${activity.entity_id} block=${ctx.block_height} — TODO §7.2: clean up associated flow state`);
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
function buildDefaultIndexerHandlerRegistry() {
|
|
122
|
+
const r = new IndexerHandlerRegistry_1.IndexerHandlerRegistry();
|
|
123
|
+
exports.defaultHandlers.forEach(h => r.register(h));
|
|
124
|
+
return r;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=defaultHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultHandlers.js","sourceRoot":"","sources":["../../../src/blockchain/handlers/defaultHandlers.ts"],"names":[],"mappings":";;;AAyJA,gFAIC;AA7JD,qEAAsF;AACtF,qDAMyB;AAEzB;;GAEG;AACU,QAAA,eAAe,GAA0B;IACpD;QACE,GAAG,EAAE,wBAAwB;QAC7B,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE;YAC9B,IAAA,oCAAmB,EAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YACxC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC1B,6CAA6C,QAAQ,CAAC,SAAS,UAAU,GAAG,CAAC,YAAY,EAAE,CAC5F,CAAA;QACH,CAAC;KACF;IACD;QACE,GAAG,EAAE,qBAAqB;QAC1B,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE;YAC9B,IAAA,oCAAmB,EAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YACxC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC1B,0CAA0C,QAAQ,CAAC,SAAS,UAAU,GAAG,CAAC,YAAY,EAAE,CACzF,CAAA;QACH,CAAC;KACF;IACD;QACE,GAAG,EAAE,gCAAgC;QAC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 = 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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./defaultHandlers"), exports);
|
|
18
|
+
__exportStar(require("./IndexerHandlerRegistry"), exports);
|
|
19
|
+
__exportStar(require("./stateMutations"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/blockchain/handlers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,2DAAwC;AACxC,mDAAgC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { VsAgent } from '../../agent/VsAgent';
|
|
2
|
+
import { IndexerActivity, VeranaSyncState } from '../types';
|
|
3
|
+
export declare function upsertTrustRegistry(state: VeranaSyncState, activity: IndexerActivity): void;
|
|
4
|
+
export declare function bumpActiveGfVersion(state: VeranaSyncState, activity: IndexerActivity): void;
|
|
5
|
+
export declare function upsertCredentialSchema(state: VeranaSyncState, activity: IndexerActivity): void;
|
|
6
|
+
export declare function upsertPermission(state: VeranaSyncState, activity: IndexerActivity, overrides?: {
|
|
7
|
+
vpState?: string;
|
|
8
|
+
revoked?: boolean;
|
|
9
|
+
slashed?: boolean;
|
|
10
|
+
effectiveUntil?: string;
|
|
11
|
+
}): void;
|
|
12
|
+
export declare function publishVtjscIfOwner(state: VeranaSyncState, agent: VsAgent, schemaEntityId: string): Promise<void>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upsertTrustRegistry = upsertTrustRegistry;
|
|
4
|
+
exports.bumpActiveGfVersion = bumpActiveGfVersion;
|
|
5
|
+
exports.upsertCredentialSchema = upsertCredentialSchema;
|
|
6
|
+
exports.upsertPermission = upsertPermission;
|
|
7
|
+
exports.publishVtjscIfOwner = publishVtjscIfOwner;
|
|
8
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
9
|
+
const data_1 = require("../../utils/data");
|
|
10
|
+
const trustCredentialStore_1 = require("../../utils/trustCredentialStore");
|
|
11
|
+
const DEFAULT_CHAIN_ID = 'vna-testnet-1';
|
|
12
|
+
function upsertTrustRegistry(state, activity) {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14
|
+
const block = Number(activity.block_height) || 0;
|
|
15
|
+
const id = String(activity.entity_id);
|
|
16
|
+
const c = activity.changes;
|
|
17
|
+
const existing = state.trustRegistries[id];
|
|
18
|
+
state.trustRegistries[id] = {
|
|
19
|
+
id: Number(id),
|
|
20
|
+
did: String((_b = (_a = c['did']) !== null && _a !== void 0 ? _a : existing === null || existing === void 0 ? void 0 : existing.did) !== null && _b !== void 0 ? _b : ''),
|
|
21
|
+
controller: String((_d = (_c = c['controller']) !== null && _c !== void 0 ? _c : existing === null || existing === void 0 ? void 0 : existing.controller) !== null && _d !== void 0 ? _d : ''),
|
|
22
|
+
archived: Boolean((_f = (_e = c['archived']) !== null && _e !== void 0 ? _e : existing === null || existing === void 0 ? void 0 : existing.archived) !== null && _f !== void 0 ? _f : false),
|
|
23
|
+
activeGfVersion: existing === null || existing === void 0 ? void 0 : existing.activeGfVersion,
|
|
24
|
+
lastModifiedBlock: block,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function bumpActiveGfVersion(state, activity) {
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
|
+
const block = Number(activity.block_height) || 0;
|
|
30
|
+
const id = String(activity.entity_id);
|
|
31
|
+
const existing = state.trustRegistries[id];
|
|
32
|
+
state.trustRegistries[id] = {
|
|
33
|
+
id: Number(id),
|
|
34
|
+
did: String((_a = existing === null || existing === void 0 ? void 0 : existing.did) !== null && _a !== void 0 ? _a : ''),
|
|
35
|
+
controller: String((_b = existing === null || existing === void 0 ? void 0 : existing.controller) !== null && _b !== void 0 ? _b : ''),
|
|
36
|
+
archived: (_c = existing === null || existing === void 0 ? void 0 : existing.archived) !== null && _c !== void 0 ? _c : false,
|
|
37
|
+
activeGfVersion: ((_d = existing === null || existing === void 0 ? void 0 : existing.activeGfVersion) !== null && _d !== void 0 ? _d : 0) + 1,
|
|
38
|
+
lastModifiedBlock: block,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function upsertCredentialSchema(state, activity) {
|
|
42
|
+
var _a, _b, _c, _d, _e;
|
|
43
|
+
const block = Number(activity.block_height) || 0;
|
|
44
|
+
const id = String(activity.entity_id);
|
|
45
|
+
const c = activity.changes;
|
|
46
|
+
const existing = state.credentialSchemas[id];
|
|
47
|
+
const archivedRaw = c['archived'];
|
|
48
|
+
const archived = archivedRaw !== undefined ? archivedRaw !== null && archivedRaw !== false : ((_a = existing === null || existing === void 0 ? void 0 : existing.archived) !== null && _a !== void 0 ? _a : false);
|
|
49
|
+
state.credentialSchemas[id] = {
|
|
50
|
+
id: Number(id),
|
|
51
|
+
trId: Number((_c = (_b = c['tr_id']) !== null && _b !== void 0 ? _b : existing === null || existing === void 0 ? void 0 : existing.trId) !== null && _c !== void 0 ? _c : 0),
|
|
52
|
+
jsonSchema: String((_e = (_d = c['json_schema']) !== null && _d !== void 0 ? _d : existing === null || existing === void 0 ? void 0 : existing.jsonSchema) !== null && _e !== void 0 ? _e : ''),
|
|
53
|
+
issuerMode: c['issuer_perm_management_mode']
|
|
54
|
+
? String(c['issuer_perm_management_mode'])
|
|
55
|
+
: existing === null || existing === void 0 ? void 0 : existing.issuerMode,
|
|
56
|
+
verifierMode: c['verifier_perm_management_mode']
|
|
57
|
+
? String(c['verifier_perm_management_mode'])
|
|
58
|
+
: existing === null || existing === void 0 ? void 0 : existing.verifierMode,
|
|
59
|
+
archived,
|
|
60
|
+
lastModifiedBlock: block,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function upsertPermission(state, activity, overrides = {}) {
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
65
|
+
const block = Number(activity.block_height) || 0;
|
|
66
|
+
const id = String(activity.entity_id);
|
|
67
|
+
const c = activity.changes;
|
|
68
|
+
const existing = state.permissions[id];
|
|
69
|
+
state.permissions[id] = {
|
|
70
|
+
id: Number(id),
|
|
71
|
+
schemaId: Number((_b = (_a = c['schema_id']) !== null && _a !== void 0 ? _a : existing === null || existing === void 0 ? void 0 : existing.schemaId) !== null && _b !== void 0 ? _b : 0),
|
|
72
|
+
did: String((_d = (_c = c['did']) !== null && _c !== void 0 ? _c : existing === null || existing === void 0 ? void 0 : existing.did) !== null && _d !== void 0 ? _d : ''),
|
|
73
|
+
type: Number((_f = (_e = c['type']) !== null && _e !== void 0 ? _e : existing === null || existing === void 0 ? void 0 : existing.type) !== null && _f !== void 0 ? _f : 0),
|
|
74
|
+
vpState: (_g = overrides.vpState) !== null && _g !== void 0 ? _g : String((_j = (_h = c['vp_state']) !== null && _h !== void 0 ? _h : existing === null || existing === void 0 ? void 0 : existing.vpState) !== null && _j !== void 0 ? _j : ''),
|
|
75
|
+
effectiveUntil: (_l = (_k = overrides.effectiveUntil) !== null && _k !== void 0 ? _k : existing === null || existing === void 0 ? void 0 : existing.effectiveUntil) !== null && _l !== void 0 ? _l : '',
|
|
76
|
+
revoked: (_o = (_m = overrides.revoked) !== null && _m !== void 0 ? _m : existing === null || existing === void 0 ? void 0 : existing.revoked) !== null && _o !== void 0 ? _o : false,
|
|
77
|
+
slashed: (_q = (_p = overrides.slashed) !== null && _p !== void 0 ? _p : existing === null || existing === void 0 ? void 0 : existing.slashed) !== null && _q !== void 0 ? _q : false,
|
|
78
|
+
lastModifiedBlock: block,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async function publishVtjscIfOwner(state, agent, schemaEntityId) {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
const schema = state.credentialSchemas[schemaEntityId];
|
|
84
|
+
if (!schema) {
|
|
85
|
+
agent.config.logger.warn(`[VTJSC] Schema ${schemaEntityId} not found in state`);
|
|
86
|
+
}
|
|
87
|
+
const tr = state.trustRegistries[String(schema.trId)];
|
|
88
|
+
if (!tr) {
|
|
89
|
+
agent.config.logger.warn(`[VTJSC] Trust Registry ${schema.trId} not found in state`);
|
|
90
|
+
}
|
|
91
|
+
const chainId = (_b = (_a = agent.veranaChain) === null || _a === void 0 ? void 0 : _a.getChainId) !== null && _b !== void 0 ? _b : DEFAULT_CHAIN_ID;
|
|
92
|
+
const jsonSchemaRef = `vpr:verana:${chainId}/cs/v1/js/${schema.id}`;
|
|
93
|
+
let digestSRI;
|
|
94
|
+
try {
|
|
95
|
+
digestSRI = await (0, vs_agent_model_1.computeSchemaDigest)(JSON.parse(schema.jsonSchema));
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
agent.config.logger.error(`[VTJSC] Failed to parse/digest schema ${schemaEntityId}`, e);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
await (0, trustCredentialStore_1.createJsc)(agent, agent.publicApiBaseUrl, (0, data_1.getEcsSchemas)(agent.publicApiBaseUrl), {
|
|
103
|
+
schemaBaseId: String(schema.id),
|
|
104
|
+
jsonSchemaRef,
|
|
105
|
+
precomputedDigestSRI: digestSRI,
|
|
106
|
+
});
|
|
107
|
+
agent.config.logger.info(`[VTJSC] Published VTJSC for schema ${schema.id} (TR ${schema.trId}) at block ${state.lastBlockHeight}`);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
agent.config.logger.error(`[VTJSC] Failed to publish VTJSC for schema ${schema.id}`, e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=stateMutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateMutations.js","sourceRoot":"","sources":["../../../src/blockchain/handlers/stateMutations.ts"],"names":[],"mappings":";;AASA,kDAcC;AAED,kDAaC;AAED,wDAuBC;AAED,4CA0BC;AAED,kDAsCC;AAnID,gEAAiE;AAGjE,2CAAgD;AAChD,2EAA4D;AAG5D,MAAM,gBAAgB,GAAG,eAAe,CAAA;AAExC,SAAgB,mBAAmB,CAAC,KAAsB,EAAE,QAAyB;;IACnF,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAChD,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IACrC,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAA;IAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAA;IAE1C,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,GAAG;QAC1B,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;QACd,GAAG,EAAE,MAAM,CAAC,MAAA,MAAA,CAAC,CAAC,KAAK,CAAC,mCAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,mCAAI,EAAE,CAAC;QAC5C,UAAU,EAAE,MAAM,CAAC,MAAA,MAAA,CAAC,CAAC,YAAY,CAAC,mCAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,UAAU,mCAAI,EAAE,CAAC;QACjE,QAAQ,EAAE,OAAO,CAAC,MAAA,MAAA,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AAY,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,aAAa;YACb,oBAAoB,EAAE,SAAS;SAChC,CAAC,CAAA;QACF,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CACtB,sCAAsC,MAAM,CAAC,EAAE,QAAQ,MAAM,CAAC,IAAI,cAAc,KAAK,CAAC,eAAe,EAAE,CACxG,CAAA;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,8CAA8C,MAAM,CAAC,EAAE,EAAE,EAAE,CAAU,CAAC,CAAA;IAClG,CAAC;AACH,CAAC"}
|
|
@@ -19,4 +19,5 @@ __exportStar(require("./VeranaHelpers"), exports);
|
|
|
19
19
|
__exportStar(require("./VeranaChainService"), exports);
|
|
20
20
|
__exportStar(require("./VeranaIndexerService"), exports);
|
|
21
21
|
__exportStar(require("./types"), exports);
|
|
22
|
+
__exportStar(require("./handlers"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blockchain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC;AACzC,kDAA+B;AAC/B,uDAAoC;AACpC,yDAAsC;AACtC,0CAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blockchain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC;AACzC,kDAA+B;AAC/B,uDAAoC;AACpC,yDAAsC;AACtC,0CAAuB;AACvB,6CAA0B"}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import { BaseLogger
|
|
1
|
+
import { BaseLogger } from '@credo-ts/core';
|
|
2
2
|
export declare const VERANA_BECH32_PREFIX = "verana";
|
|
3
3
|
export declare const RECORD_ID = "verana-blockchain-sync-state";
|
|
4
|
+
export type IndexerEventRecord = {
|
|
5
|
+
type: 'indexer-event';
|
|
6
|
+
event_type: string;
|
|
7
|
+
did: string;
|
|
8
|
+
block_height: number;
|
|
9
|
+
tx_hash: string;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
payload: {
|
|
12
|
+
module: string;
|
|
13
|
+
action: string;
|
|
14
|
+
message_type: string;
|
|
15
|
+
tx_index: number;
|
|
16
|
+
message_index: number;
|
|
17
|
+
sender: string;
|
|
18
|
+
related_dids: string[];
|
|
19
|
+
entity_type?: string;
|
|
20
|
+
entity_id?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
4
23
|
export interface IndexerEventsResponse {
|
|
5
|
-
events:
|
|
24
|
+
events: IndexerEventRecord[];
|
|
6
25
|
count: number;
|
|
7
26
|
after_block_height: number;
|
|
8
27
|
}
|
|
@@ -59,6 +78,35 @@ export interface VeranaSyncState {
|
|
|
59
78
|
credentialSchemas: Record<string, SyncedCredentialSchema>;
|
|
60
79
|
permissions: Record<string, SyncedPermission>;
|
|
61
80
|
}
|
|
81
|
+
export interface TrustRegistryDto {
|
|
82
|
+
id: number;
|
|
83
|
+
did: string;
|
|
84
|
+
controller: string;
|
|
85
|
+
archived: string | null;
|
|
86
|
+
active_gf_version?: number;
|
|
87
|
+
}
|
|
88
|
+
export interface CredentialSchemaDto {
|
|
89
|
+
id: number;
|
|
90
|
+
tr_id: number;
|
|
91
|
+
json_schema: string;
|
|
92
|
+
issuer_perm_management_mode?: string;
|
|
93
|
+
verifier_perm_management_mode?: string;
|
|
94
|
+
archived: string | null;
|
|
95
|
+
created: string;
|
|
96
|
+
modified: string;
|
|
97
|
+
}
|
|
98
|
+
export interface PermissionDto {
|
|
99
|
+
id: number;
|
|
100
|
+
schema_id: number;
|
|
101
|
+
did: string | null;
|
|
102
|
+
type: number;
|
|
103
|
+
perm_state: 'ACTIVE' | 'REVOKED' | 'SLASHED' | 'REPAID' | 'EXPIRED' | 'FUTURE' | 'INACTIVE';
|
|
104
|
+
vp_state?: string;
|
|
105
|
+
revoked: string | null;
|
|
106
|
+
slashed: string | null;
|
|
107
|
+
effective_until?: string;
|
|
108
|
+
modified: string;
|
|
109
|
+
}
|
|
62
110
|
export interface PermQueryClient {
|
|
63
111
|
GetPermission(req: {
|
|
64
112
|
id: Long;
|
package/build/index.d.ts
CHANGED
|
@@ -17,4 +17,6 @@ export { webhookListener } from './utils/webhook';
|
|
|
17
17
|
export type { WebhookData } from './utils/webhook';
|
|
18
18
|
export { sendWebhookEvent, sendMessageReceivedEvent } from './utils/webhookEvent';
|
|
19
19
|
export * from './utils/util';
|
|
20
|
+
export * from './utils/setupSelfTr';
|
|
21
|
+
export * from './utils/trustCredentialStore';
|
|
20
22
|
export * from './blockchain';
|
package/build/index.js
CHANGED
|
@@ -57,5 +57,7 @@ var webhookEvent_1 = require("./utils/webhookEvent");
|
|
|
57
57
|
Object.defineProperty(exports, "sendWebhookEvent", { enumerable: true, get: function () { return webhookEvent_1.sendWebhookEvent; } });
|
|
58
58
|
Object.defineProperty(exports, "sendMessageReceivedEvent", { enumerable: true, get: function () { return webhookEvent_1.sendMessageReceivedEvent; } });
|
|
59
59
|
__exportStar(require("./utils/util"), exports);
|
|
60
|
+
__exportStar(require("./utils/setupSelfTr"), exports);
|
|
61
|
+
__exportStar(require("./utils/trustCredentialStore"), exports);
|
|
60
62
|
__exportStar(require("./blockchain"), exports);
|
|
61
63
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,0CAAuB;AAGvB,UAAU;AACV,+DAA6D;AAApD,oHAAA,gBAAgB,OAAA;AAKzB,iCAA0C;AAAjC,yGAAA,gBAAgB,OAAA;AAEzB,gBAAgB;AAChB,mEAAiE;AAAxD,4HAAA,oBAAoB,OAAA;AAC7B,yDAAuD;AAA9C,kHAAA,eAAe,OAAA;AACx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HAAA,oBAAoB,OAAA;AACpB,kHAAA,UAAU,OAAA;AACV,oHAAA,YAAY,OAAA;AACZ,wHAAA,gBAAgB,OAAA;AAGlB,QAAQ;AACR,uCAAwE;AAA/D,yGAAA,gBAAgB,OAAA;AAAE,kGAAA,SAAS,OAAA;AAAE,oGAAA,WAAW,OAAA;AACjD,qCAA4C;AAAnC,qGAAA,aAAa,OAAA;AACtB,2CAAiD;AAAxC,0GAAA,eAAe,OAAA;AAExB,qDAAiF;AAAxE,gHAAA,gBAAgB,OAAA;AAAE,wHAAA,wBAAwB,OAAA;AACnD,+CAA4B;AAC5B,sDAAmC;AACnC,+DAA4C;AAE5C,+CAA4B"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { W3cCredential, W3cPresentation, W3cCredentialSchema, W3cCredentialSubject, W3cJsonLdVerifiableCredential, W3cJsonLdVerifiablePresentation, W3cCredentialOptions, DidRecord, W3cPresentationOptions, Logger } from '@credo-ts/core';
|
|
2
|
+
import { AnySchemaObject } from 'ajv/dist/2020';
|
|
3
|
+
import { VsAgent } from '../agent/VsAgent';
|
|
4
|
+
interface SelfTrDefaults {
|
|
5
|
+
agentLabel: string;
|
|
6
|
+
agentInvitationImageUrl?: string;
|
|
7
|
+
fallbackBase64?: string;
|
|
8
|
+
serviceType: string;
|
|
9
|
+
serviceDescription: string;
|
|
10
|
+
serviceMinimumAgeRequired: number;
|
|
11
|
+
serviceTermsAndConditions: string;
|
|
12
|
+
servicePrivacyPolicy: string;
|
|
13
|
+
orgRegistryId: string;
|
|
14
|
+
orgRegistryUrl: string;
|
|
15
|
+
orgAddress: string;
|
|
16
|
+
orgType: string;
|
|
17
|
+
orgCountryCode: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const presentations: {
|
|
20
|
+
name: string;
|
|
21
|
+
schemaUrl: string;
|
|
22
|
+
}[];
|
|
23
|
+
export declare const credentials: {
|
|
24
|
+
name: string;
|
|
25
|
+
credUrl: string;
|
|
26
|
+
schemaUrl: string;
|
|
27
|
+
}[];
|
|
28
|
+
export declare const createJsonSchema: W3cCredentialSchema;
|
|
29
|
+
export declare const createJsonSubjectRef: (id: string) => W3cCredentialSubject;
|
|
30
|
+
export declare const mapToSelfTr: (url: string, publicApiBaseUrl: string) => string;
|
|
31
|
+
export declare const setupSelfTr: ({ agent, publicApiBaseUrl, defaults, }: {
|
|
32
|
+
agent: VsAgent;
|
|
33
|
+
publicApiBaseUrl: string;
|
|
34
|
+
defaults: SelfTrDefaults;
|
|
35
|
+
}) => Promise<void>;
|
|
36
|
+
export declare function createCredential(options: Partial<W3cCredentialOptions>): W3cCredential;
|
|
37
|
+
/**
|
|
38
|
+
* Signs a W3C Verifiable Credential or Presentation using the provided agent and verification method.
|
|
39
|
+
*
|
|
40
|
+
* The function determines whether the input object is a `W3cCredential` or a `W3cPresentation`,
|
|
41
|
+
* and applies the appropriate signing operation using Linked Data Proofs (`Ed25519Signature2020`).
|
|
42
|
+
*
|
|
43
|
+
* @param agent - The agent instance.
|
|
44
|
+
* @param obj - The credential or presentation object to be signed.
|
|
45
|
+
* @param verificationMethod - The DID verification method used to generate the proof.
|
|
46
|
+
* @returns A signed W3C Verifiable Credential or Presentation in JSON-LD format.
|
|
47
|
+
*/
|
|
48
|
+
export declare function signerW3c(agent: VsAgent, obj: W3cCredential, verificationMethod: string): Promise<W3cJsonLdVerifiableCredential>;
|
|
49
|
+
export declare function signerW3c(agent: VsAgent, obj: W3cPresentation, verificationMethod: string): Promise<W3cJsonLdVerifiablePresentation>;
|
|
50
|
+
/**
|
|
51
|
+
* Generates and signs a verifiable presentation containing a verifiable credential.
|
|
52
|
+
* Stores the signed presentation and its integrity metadata in the DID record.
|
|
53
|
+
*
|
|
54
|
+
* - Retrieves and validates claims for the agent's DID.
|
|
55
|
+
* - Computes an integrity digest for the claims.
|
|
56
|
+
* - If a presentation with the same integrity already exists in the DID metadata, it is returned.
|
|
57
|
+
* - Otherwise, a new presentation is created, signed, and stored in the DID metadata.
|
|
58
|
+
*
|
|
59
|
+
* @param agent - The VsAgent instance used for signing and DID management.
|
|
60
|
+
* @param logger - Logger instance for logging operations.
|
|
61
|
+
* @param ecsSchemas - Map of ECS schemas for validation.
|
|
62
|
+
* @param schemaKey - Unique identifier for the presentation type and metadata key.
|
|
63
|
+
* @param type - Array of credential types to include.
|
|
64
|
+
* @param credentialSchema - Schema definition for the credential.
|
|
65
|
+
* @returns The signed verifiable presentation, with integrity metadata.
|
|
66
|
+
*/
|
|
67
|
+
export declare function generateVerifiablePresentation(agent: VsAgent, id: string, ecsSchemas: Record<string, string>, schemaKey: string, type: string[], credentialSchema: W3cCredentialSchema, defaults: SelfTrDefaults): Promise<any>;
|
|
68
|
+
export declare function createPresentation(options: Partial<W3cPresentationOptions>): W3cPresentation;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves and validates claims for a credential subject.
|
|
71
|
+
* If claims are not found, builds default claims based on the schemaKey.
|
|
72
|
+
* Validates claims against the ECS schema for the given schemaKey.
|
|
73
|
+
*
|
|
74
|
+
* @param ecsSchemas - Map of ECS schemas for validation.
|
|
75
|
+
* @param subject - Credential subject, including ID.
|
|
76
|
+
* @param schemaKey - Unique identifier for the credential type.
|
|
77
|
+
* @returns The validated claims object.
|
|
78
|
+
* @throws If claims are invalid or schema is missing.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getClaims(logger: Logger, ecsSchemas: Record<string, string>, { id, claims }: W3cCredentialSubject, schemaKey: string, defaults: SelfTrDefaults): Promise<Record<string, unknown>>;
|
|
81
|
+
/**
|
|
82
|
+
* Validate a validateSchema object against the corresponding AJV schema.
|
|
83
|
+
* Throws an Error if the schema is missing or validation fails.
|
|
84
|
+
*/
|
|
85
|
+
export declare function validateSchema(ecsSchema: AnySchemaObject, credentialSubject: Record<string, any>): void;
|
|
86
|
+
/**
|
|
87
|
+
* Adds a Subresource Integrity (SRI) digest to the provided data using the schema content
|
|
88
|
+
* fetched from the provided URL or from a local schema map as fallback.
|
|
89
|
+
*
|
|
90
|
+
* @template T - The type of the data object.
|
|
91
|
+
* @param id - The URL of the schema to fetch.
|
|
92
|
+
* @param data - The object to which the digest will be added.
|
|
93
|
+
* @param ecsSchemas - Optional map of local schemas to use as fallback if the fetch fails.
|
|
94
|
+
* @returns A new object combining the original data and a `digestSRI` property.
|
|
95
|
+
* @throws Error if both the fetch and local fallback fail.
|
|
96
|
+
*/
|
|
97
|
+
export declare function addDigestSRI<T extends object>(id?: string, data?: T, ecsSchemas?: Record<string, string>): Promise<T & {
|
|
98
|
+
digestSRI: string;
|
|
99
|
+
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Generates a SRI digest string for the given content using the specified algorithm.
|
|
102
|
+
* @param content - The content to hash.
|
|
103
|
+
* @param algorithm - The hash algorithm to use (default: sha256).
|
|
104
|
+
* @returns The SRI digest string.
|
|
105
|
+
*/
|
|
106
|
+
export declare function generateDigestSRI(content: string, algorithm?: string): string;
|
|
107
|
+
/**
|
|
108
|
+
* Converts an image URL to a Base64-encoded data URI string.
|
|
109
|
+
*
|
|
110
|
+
* @param url - The image URL to convert.
|
|
111
|
+
* @returns A Base64 data URI string, or a fallback placeholder if the image cannot be fetched or is invalid.
|
|
112
|
+
*/
|
|
113
|
+
export declare function urlToBase64(logger: Logger, url: string | undefined, fallback: string): Promise<string>;
|
|
114
|
+
export declare function getVerificationMethodId(logger: Logger, didRecord: DidRecord): string;
|
|
115
|
+
export {};
|