@verana-labs/vs-agent-sdk 1.12.0-dev.1 → 1.12.0-dev.11
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 +7 -26
- package/build/agent/VsAgent.d.ts +6 -0
- package/build/agent/VsAgent.js +14 -4
- package/build/agent/VsAgent.js.map +1 -1
- package/build/agent/createVsAgent.d.ts +1 -0
- package/build/agent/createVsAgent.js +1 -0
- package/build/agent/createVsAgent.js.map +1 -1
- package/build/blockchain/IndexerWebSocketService.d.ts +0 -4
- package/build/blockchain/IndexerWebSocketService.js +30 -30
- package/build/blockchain/IndexerWebSocketService.js.map +1 -1
- package/build/blockchain/VeranaChainService.d.ts +14 -15
- package/build/blockchain/VeranaChainService.js +122 -63
- package/build/blockchain/VeranaChainService.js.map +1 -1
- package/build/blockchain/VeranaHelpers.js +2 -2
- package/build/blockchain/VeranaHelpers.js.map +1 -1
- package/build/blockchain/VeranaIndexerService.d.ts +3 -4
- package/build/blockchain/VeranaIndexerService.js +8 -19
- package/build/blockchain/VeranaIndexerService.js.map +1 -1
- package/build/blockchain/handlers/IndexerHandlerRegistry.d.ts +1 -0
- package/build/blockchain/handlers/IndexerHandlerRegistry.js.map +1 -1
- package/build/blockchain/handlers/defaultHandlers.js +37 -32
- package/build/blockchain/handlers/defaultHandlers.js.map +1 -1
- package/build/blockchain/handlers/stateMutations.d.ts +12 -4
- package/build/blockchain/handlers/stateMutations.js +103 -28
- package/build/blockchain/handlers/stateMutations.js.map +1 -1
- package/build/blockchain/types.d.ts +189 -49
- package/build/blockchain/types.js +8 -1
- package/build/blockchain/types.js.map +1 -1
- package/build/credentials/FullTailsFileService.d.ts +4 -4
- package/build/credentials/FullTailsFileService.js +78 -71
- package/build/credentials/FullTailsFileService.js.map +1 -1
- package/build/did/adminApiService.d.ts +2 -0
- package/build/did/adminApiService.js +17 -0
- package/build/did/adminApiService.js.map +1 -0
- package/build/index.d.ts +4 -4
- package/build/index.js +9 -6
- package/build/index.js.map +1 -1
- package/build/plugins/setupBaseDidComm.d.ts +3 -1
- package/build/plugins/setupBaseDidComm.js +3 -1
- package/build/plugins/setupBaseDidComm.js.map +1 -1
- package/build/types.d.ts +1 -0
- package/build/types.js +2 -1
- package/build/types.js.map +1 -1
- package/build/utils/trustCredentialStore.js +2 -0
- package/build/utils/trustCredentialStore.js.map +1 -1
- package/build/vtFlow/VtFlowOrchestrator.d.ts +38 -0
- package/build/vtFlow/VtFlowOrchestrator.js +247 -0
- package/build/vtFlow/VtFlowOrchestrator.js.map +1 -0
- package/build/vtFlow/assertVerifiableService.d.ts +8 -0
- package/build/vtFlow/assertVerifiableService.js +28 -0
- package/build/vtFlow/assertVerifiableService.js.map +1 -0
- package/build/vtFlow/credentialDigest.d.ts +3 -0
- package/build/vtFlow/credentialDigest.js +23 -0
- package/build/vtFlow/credentialDigest.js.map +1 -0
- package/build/vtFlow/index.d.ts +2 -0
- package/build/vtFlow/index.js +19 -0
- package/build/vtFlow/index.js.map +1 -0
- package/package.json +15 -11
|
@@ -7,8 +7,25 @@ const stargate_1 = require("@cosmjs/stargate");
|
|
|
7
7
|
const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
8
8
|
const verana_types_1 = require("@verana-labs/verana-types");
|
|
9
9
|
const types_1 = require("./types");
|
|
10
|
-
const { QueryClientImpl:
|
|
11
|
-
const {
|
|
10
|
+
const { QueryClientImpl: PpQueryClientImpl, QueryFindParticipantsWithDIDRequest, } = require('@verana-labs/verana-types/codec/verana/pp/v1/query');
|
|
11
|
+
const { MsgSetParticipantOPToValidated, MsgCreateOrUpdateParticipantSession, MsgTriggerResolver, } = require('@verana-labs/verana-types/codec/verana/pp/v1/tx');
|
|
12
|
+
// ParticipantRole.HOLDER (x/pp/types); the only role whose vs_operator may send TriggerResolver (chain Path 1).
|
|
13
|
+
const PARTICIPANT_ROLE_HOLDER = 6;
|
|
14
|
+
function mapParticipant(p) {
|
|
15
|
+
var _a;
|
|
16
|
+
return {
|
|
17
|
+
id: p.id,
|
|
18
|
+
schemaId: p.schemaId,
|
|
19
|
+
role: p.role,
|
|
20
|
+
did: p.did,
|
|
21
|
+
corporation: p.corporationId != null ? String(p.corporationId) : '',
|
|
22
|
+
validatorParticipantId: p.validatorParticipantId,
|
|
23
|
+
opState: p.opState,
|
|
24
|
+
opSummaryDigest: (_a = p.opSummaryDigest) !== null && _a !== void 0 ? _a : '',
|
|
25
|
+
revoked: p.revoked,
|
|
26
|
+
slashed: p.slashed,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
12
29
|
class VeranaChainService {
|
|
13
30
|
constructor(config) {
|
|
14
31
|
this.config = config;
|
|
@@ -19,106 +36,148 @@ class VeranaChainService {
|
|
|
19
36
|
get getChainId() {
|
|
20
37
|
return this.chainId;
|
|
21
38
|
}
|
|
39
|
+
get corporation() {
|
|
40
|
+
return this.corporationAddress;
|
|
41
|
+
}
|
|
42
|
+
get autoTriggerResolverEnabled() {
|
|
43
|
+
return this.config.autoTriggerResolver !== false;
|
|
44
|
+
}
|
|
22
45
|
async start() {
|
|
46
|
+
var _a;
|
|
23
47
|
const { rpcUrl, mnemonic, chainId, logger, gasPrice } = this.config;
|
|
24
48
|
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
|
|
25
49
|
prefix: types_1.VERANA_BECH32_PREFIX,
|
|
26
50
|
});
|
|
27
51
|
const [account] = await wallet.getAccounts();
|
|
28
52
|
this.operatorAddress = account.address;
|
|
53
|
+
this.corporationAddress = (_a = this.config.corporationAddress) !== null && _a !== void 0 ? _a : account.address;
|
|
29
54
|
logger.info(`[VeranaChain] vs_operator address: ${this.operatorAddress} (fund this address with VNA to enable on-chain operations)`);
|
|
30
55
|
const cometClient = await (0, tendermint_rpc_1.connectComet)(rpcUrl);
|
|
31
56
|
this.signingClient = await stargate_1.SigningStargateClient.createWithSigner(cometClient, wallet, {
|
|
32
57
|
registry: (0, verana_types_1.createVeranaRegistry)(),
|
|
33
58
|
aminoTypes: (0, verana_types_1.createVeranaAminoTypes)(),
|
|
34
|
-
gasPrice: stargate_1.GasPrice.fromString(gasPrice !== null && gasPrice !== void 0 ? gasPrice : '
|
|
59
|
+
gasPrice: stargate_1.GasPrice.fromString(gasPrice !== null && gasPrice !== void 0 ? gasPrice : '1uvna'),
|
|
35
60
|
});
|
|
36
61
|
this.chainId = await this.signingClient.getChainId();
|
|
37
62
|
if (chainId && this.chainId !== chainId) {
|
|
38
63
|
throw new Error(`[VeranaChain] Chain ID mismatch: expected "${chainId}", got "${this.chainId}"`);
|
|
39
64
|
}
|
|
40
65
|
logger.info(`[VeranaChain] Connected to chain: ${this.chainId}`);
|
|
66
|
+
// FIXME(verana setValidated->AUTHZ-CHECK-3): validating needs an OperatorAuthorization and the session
|
|
67
|
+
// needs a mutually-exclusive VSOperatorAuthorization, so when configured the agent signs the session
|
|
68
|
+
// with a second account. Remove once both are authorized under one vs_operator.
|
|
69
|
+
if (this.config.sessionOperatorMnemonic) {
|
|
70
|
+
const sessionWallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(this.config.sessionOperatorMnemonic, {
|
|
71
|
+
prefix: types_1.VERANA_BECH32_PREFIX,
|
|
72
|
+
});
|
|
73
|
+
const [sessionAccount] = await sessionWallet.getAccounts();
|
|
74
|
+
this.sessionOperatorAddress = sessionAccount.address;
|
|
75
|
+
this.sessionSigningClient = await stargate_1.SigningStargateClient.createWithSigner(cometClient, sessionWallet, {
|
|
76
|
+
registry: (0, verana_types_1.createVeranaRegistry)(),
|
|
77
|
+
aminoTypes: (0, verana_types_1.createVeranaAminoTypes)(),
|
|
78
|
+
gasPrice: stargate_1.GasPrice.fromString(gasPrice !== null && gasPrice !== void 0 ? gasPrice : '1uvna'),
|
|
79
|
+
});
|
|
80
|
+
logger.info(`[VeranaChain] session vs_operator: ${this.sessionOperatorAddress}`);
|
|
81
|
+
}
|
|
41
82
|
const queryClient = new stargate_1.QueryClient(cometClient);
|
|
42
83
|
const rpc = (0, stargate_1.createProtobufRpcClient)(queryClient);
|
|
43
|
-
this.
|
|
44
|
-
}
|
|
45
|
-
// Query API (No signed)
|
|
46
|
-
async getPermission(id) {
|
|
47
|
-
return this.permQuery.GetPermission({ id });
|
|
48
|
-
}
|
|
49
|
-
async findPermissionsWithDID(params) {
|
|
50
|
-
var _a;
|
|
51
|
-
const result = await this.permQuery.FindPermissionsWithDID(params);
|
|
52
|
-
return (_a = result.permissions) !== null && _a !== void 0 ? _a : [];
|
|
53
|
-
}
|
|
54
|
-
async getPermissionSession(uuid) {
|
|
55
|
-
return this.permQuery.GetPermissionSession({ id: uuid });
|
|
56
|
-
}
|
|
57
|
-
// Transaction API (Signed)
|
|
58
|
-
async startPermissionVP(params) {
|
|
59
|
-
const value = MsgStartPermissionVP.fromPartial({
|
|
60
|
-
creator: this.operatorAddress,
|
|
61
|
-
type: params.type,
|
|
62
|
-
validatorPermId: params.validatorPermId,
|
|
63
|
-
country: params.country,
|
|
64
|
-
did: params.did,
|
|
65
|
-
validationFees: params.validationFees,
|
|
66
|
-
});
|
|
67
|
-
const result = await this.broadcastMsg(verana_types_1.veranaTypeUrls.MsgStartPermissionVP, value);
|
|
68
|
-
return { txHash: result.transactionHash };
|
|
84
|
+
this.ppQuery = new PpQueryClientImpl(rpc);
|
|
69
85
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
const result = await this.broadcastMsg(verana_types_1.veranaTypeUrls.MsgRenewPermissionVP, value);
|
|
76
|
-
return { txHash: result.transactionHash };
|
|
86
|
+
// Query API (unsigned)
|
|
87
|
+
async getParticipant(id) {
|
|
88
|
+
const result = await this.ppQuery.GetParticipant({ id });
|
|
89
|
+
return result.participant ? mapParticipant(result.participant) : undefined;
|
|
77
90
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
// Transaction API (signed)
|
|
92
|
+
async setParticipantOPToValidated(params) {
|
|
93
|
+
var _a, _b, _c, _d, _e;
|
|
94
|
+
const value = MsgSetParticipantOPToValidated.fromPartial({
|
|
95
|
+
corporation: this.corporationAddress,
|
|
96
|
+
operator: this.operatorAddress,
|
|
81
97
|
id: params.id,
|
|
82
98
|
effectiveUntil: params.effectiveUntil,
|
|
83
|
-
validationFees: params.validationFees,
|
|
84
|
-
issuanceFees: params.issuanceFees,
|
|
85
|
-
verificationFees: params.verificationFees,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
verificationFeeDiscount: params.verificationFeeDiscount,
|
|
99
|
+
validationFees: (_a = params.validationFees) !== null && _a !== void 0 ? _a : 0,
|
|
100
|
+
issuanceFees: (_b = params.issuanceFees) !== null && _b !== void 0 ? _b : 0,
|
|
101
|
+
verificationFees: (_c = params.verificationFees) !== null && _c !== void 0 ? _c : 0,
|
|
102
|
+
opSummaryDigest: params.opSummaryDigest,
|
|
103
|
+
issuanceFeeDiscount: (_d = params.issuanceFeeDiscount) !== null && _d !== void 0 ? _d : 0,
|
|
104
|
+
verificationFeeDiscount: (_e = params.verificationFeeDiscount) !== null && _e !== void 0 ? _e : 0,
|
|
90
105
|
});
|
|
91
|
-
const result = await this.broadcastMsg(verana_types_1.veranaTypeUrls.
|
|
106
|
+
const result = await this.broadcastMsg(verana_types_1.veranaTypeUrls.MsgSetParticipantOPToValidated, value);
|
|
92
107
|
return { txHash: result.transactionHash };
|
|
93
108
|
}
|
|
94
|
-
async
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
async createOrUpdateParticipantSession(params) {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
// FIXME(verana setValidated->AUTHZ-CHECK-3): sign the session with the VSOA account when configured.
|
|
112
|
+
const operator = (_a = this.sessionOperatorAddress) !== null && _a !== void 0 ? _a : this.operatorAddress;
|
|
113
|
+
const value = MsgCreateOrUpdateParticipantSession.fromPartial({
|
|
114
|
+
corporation: this.corporationAddress,
|
|
115
|
+
operator,
|
|
116
|
+
id: params.id,
|
|
117
|
+
issuerParticipantId: params.issuerParticipantId,
|
|
118
|
+
verifierParticipantId: params.verifierParticipantId,
|
|
119
|
+
agentParticipantId: params.agentParticipantId,
|
|
120
|
+
walletAgentParticipantId: params.walletAgentParticipantId,
|
|
121
|
+
digest: params.digest,
|
|
98
122
|
});
|
|
99
|
-
const result = await this.broadcastMsg(verana_types_1.veranaTypeUrls.
|
|
123
|
+
const result = await this.broadcastMsg(verana_types_1.veranaTypeUrls.MsgCreateOrUpdateParticipantSession, value, (_b = this.sessionSigningClient) !== null && _b !== void 0 ? _b : this.signingClient, operator);
|
|
100
124
|
return { txHash: result.transactionHash };
|
|
101
125
|
}
|
|
102
|
-
async
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
async findActiveHolderParticipantIdByDid(did) {
|
|
127
|
+
var _a;
|
|
128
|
+
// fromPartial fills the unused fields with defaults so the request encodes correctly.
|
|
129
|
+
const request = QueryFindParticipantsWithDIDRequest.fromPartial({ did });
|
|
130
|
+
const { participants } = await this.ppQuery.FindParticipantsWithDID(request);
|
|
131
|
+
return (_a = participants.find(p => p.did === did && p.role === PARTICIPANT_ROLE_HOLDER && !p.revoked && !p.slashed)) === null || _a === void 0 ? void 0 : _a.id;
|
|
132
|
+
}
|
|
133
|
+
async triggerResolver(participantId) {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
const operator = (_a = this.sessionOperatorAddress) !== null && _a !== void 0 ? _a : this.operatorAddress;
|
|
136
|
+
const value = MsgTriggerResolver.fromPartial({
|
|
137
|
+
corporation: this.corporationAddress,
|
|
138
|
+
operator,
|
|
139
|
+
id: participantId,
|
|
110
140
|
});
|
|
111
|
-
const result = await this.broadcastMsg(verana_types_1.veranaTypeUrls.
|
|
141
|
+
const result = await this.broadcastMsg(verana_types_1.veranaTypeUrls.MsgTriggerResolver, value, (_b = this.sessionSigningClient) !== null && _b !== void 0 ? _b : this.signingClient, operator);
|
|
112
142
|
return { txHash: result.transactionHash };
|
|
113
143
|
}
|
|
114
|
-
async broadcastMsg(typeUrl, value) {
|
|
144
|
+
async broadcastMsg(typeUrl, value, client = this.signingClient, signer = this.operatorAddress) {
|
|
115
145
|
const msg = { typeUrl, value };
|
|
116
146
|
this.config.logger.debug(`[VeranaChain] Broadcasting ${typeUrl}`);
|
|
117
|
-
const result = await
|
|
147
|
+
const result = await client.signAndBroadcast(signer, [msg], 'auto');
|
|
118
148
|
(0, stargate_1.assertIsDeliverTxSuccess)(result);
|
|
119
149
|
this.config.logger.info(`[VeranaChain] Tx success: ${result.transactionHash}`);
|
|
120
150
|
return result;
|
|
121
151
|
}
|
|
152
|
+
async extractIdFromEvent(txHashOrResult, eventType, attrKey) {
|
|
153
|
+
let events;
|
|
154
|
+
let txRef;
|
|
155
|
+
if (typeof txHashOrResult === 'string') {
|
|
156
|
+
const tx = await this.signingClient.getTx(txHashOrResult);
|
|
157
|
+
if (!tx) {
|
|
158
|
+
throw new Error(`[VeranaChain] tx ${txHashOrResult} not found`);
|
|
159
|
+
}
|
|
160
|
+
events = tx.events;
|
|
161
|
+
txRef = txHashOrResult;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
events = txHashOrResult.events;
|
|
165
|
+
txRef = txHashOrResult.transactionHash;
|
|
166
|
+
}
|
|
167
|
+
const event = events.find(e => e.type === eventType);
|
|
168
|
+
if (!event) {
|
|
169
|
+
throw new Error(`[VeranaChain] tx ${txRef} missing '${eventType}' event`);
|
|
170
|
+
}
|
|
171
|
+
const attr = event.attributes.find(a => a.key === attrKey);
|
|
172
|
+
if (!attr) {
|
|
173
|
+
throw new Error(`[VeranaChain] tx ${txRef} missing '${attrKey}' in '${eventType}' event`);
|
|
174
|
+
}
|
|
175
|
+
const id = Number(attr.value);
|
|
176
|
+
if (!Number.isFinite(id)) {
|
|
177
|
+
throw new Error(`[VeranaChain] tx ${txRef} has non-numeric ${attrKey}=${attr.value}`);
|
|
178
|
+
}
|
|
179
|
+
return id;
|
|
180
|
+
}
|
|
122
181
|
}
|
|
123
182
|
exports.VeranaChainService = VeranaChainService;
|
|
124
183
|
//# sourceMappingURL=VeranaChainService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VeranaChainService.js","sourceRoot":"","sources":["../../src/blockchain/VeranaChainService.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,yDAA+D;AAC/D,+CAOyB;AACzB,2DAAqD;AACrD,4DAAwG;
|
|
1
|
+
{"version":3,"file":"VeranaChainService.js","sourceRoot":"","sources":["../../src/blockchain/VeranaChainService.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,yDAA+D;AAC/D,+CAOyB;AACzB,2DAAqD;AACrD,4DAAwG;AAExG,mCAQgB;AAEhB,MAAM,EACJ,eAAe,EAAE,iBAAiB,EAClC,mCAAmC,GACpC,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAA;AACjE,MAAM,EACJ,8BAA8B,EAC9B,mCAAmC,EACnC,kBAAkB,GACnB,GAAG,OAAO,CAAC,iDAAiD,CAAC,CAAA;AAE9D,gHAAgH;AAChH,MAAM,uBAAuB,GAAG,CAAC,CAAA;AAEjC,SAAS,cAAc,CAAC,CAAiB;;IACvC,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,WAAW,EAAE,CAAC,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE;QACnE,sBAAsB,EAAE,CAAC,CAAC,sBAAsB;QAChD,OAAO,EAAE,CAAC,CAAC,OAA4C;QACvD,eAAe,EAAE,MAAA,CAAC,CAAC,eAAe,mCAAI,EAAE;QACxC,OAAO,EAAE,CAAC,CAAC,OA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 0,
|
|
8
|
-
|
|
8
|
+
ecosystems: {},
|
|
9
9
|
credentialSchemas: {},
|
|
10
|
-
|
|
10
|
+
participants: {},
|
|
11
11
|
});
|
|
12
12
|
async function loadSyncState(agent) {
|
|
13
13
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VeranaHelpers.js","sourceRoot":"","sources":["../../src/blockchain/VeranaHelpers.ts"],"names":[],"mappings":";;AAaA,sCAIC;AAED,sCAQC;AAvBD,mCAAoD;AAEpD,MAAM,UAAU,GAAG,GAAoB,EAAE,CAAC,CAAC;IACzC,eAAe,EAAE,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"VeranaHelpers.js","sourceRoot":"","sources":["../../src/blockchain/VeranaHelpers.ts"],"names":[],"mappings":";;AAaA,sCAIC;AAED,sCAQC;AAvBD,mCAAoD;AAEpD,MAAM,UAAU,GAAG,GAAoB,EAAE,CAAC,CAAC;IACzC,eAAe,EAAE,CAAC;IAClB,UAAU,EAAE,EAAE;IACd,iBAAiB,EAAE,EAAE;IACrB,YAAY,EAAE,EAAE;CACjB,CAAC,CAAA;AAEK,KAAK,UAAU,aAAa,CAAC,KAAc;;IAChD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,iBAAS,CAAC,CAAA;IAC7D,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,EAAE,CAAA;IAChC,OAAO,MAAC,MAAM,CAAC,OAAsC,mCAAI,UAAU,EAAE,CAAA;AACvE,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,KAAc,EAAE,KAAsB;IACxE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,iBAAS,CAAC,CAAA;IAC/D,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,OAAO,GAAG,KAA8B,CAAA;QACjD,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC7C,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,iBAAS,EAAE,OAAO,EAAE,KAA8B,EAAE,CAAC,CAAA;IAC7F,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { CredentialSchemaDto,
|
|
1
|
+
import { CredentialSchemaDto, EcosystemDto, IndexerEventsResponse, ParticipantDto, VeranaIdxConfig } from './types';
|
|
2
2
|
export declare class VeranaIndexerService {
|
|
3
3
|
private readonly config;
|
|
4
4
|
private readonly baseUrl;
|
|
5
5
|
constructor(config: VeranaIdxConfig);
|
|
6
|
-
getChanges(blockHeight: number): Promise<IndexerChangesResponse>;
|
|
7
6
|
getEvents(agentDid: string, afterBlockHeight?: number, limit?: number): Promise<IndexerEventsResponse>;
|
|
8
|
-
|
|
7
|
+
getEcosystem(id: string | number): Promise<EcosystemDto>;
|
|
9
8
|
getCredentialSchema(id: string | number): Promise<CredentialSchemaDto>;
|
|
10
|
-
|
|
9
|
+
getParticipant(id: string | number): Promise<ParticipantDto>;
|
|
11
10
|
}
|
|
@@ -7,36 +7,25 @@ class VeranaIndexerService {
|
|
|
7
7
|
this.config = config;
|
|
8
8
|
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
9
9
|
}
|
|
10
|
-
async getChanges(blockHeight) {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
this.config.logger.debug(`[VeranaIndexer] getChanges block=${blockHeight}`);
|
|
13
|
-
const url = `${this.baseUrl}/verana/indexer/v1/changes/${blockHeight}`;
|
|
14
|
-
const data = await (0, util_1.fetchJson)(url);
|
|
15
|
-
return {
|
|
16
|
-
block_height: Number((_a = data['block_height']) !== null && _a !== void 0 ? _a : blockHeight),
|
|
17
|
-
next_change_at: data['next_change_at'] != null ? Number(data['next_change_at']) : null,
|
|
18
|
-
activity: ((_b = data['activity']) !== null && _b !== void 0 ? _b : []),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
10
|
async getEvents(agentDid, afterBlockHeight = 0, limit = 500) {
|
|
22
11
|
this.config.logger.debug(`[VeranaIndexer] getEvents after_block=${afterBlockHeight}`);
|
|
23
12
|
const url = `${this.baseUrl}/verana/indexer/v1/events?did=${encodeURIComponent(agentDid)}&after_block_height=${afterBlockHeight}&limit=${limit}`;
|
|
24
13
|
return (0, util_1.fetchJson)(url);
|
|
25
14
|
}
|
|
26
|
-
async
|
|
27
|
-
this.config.logger.debug(`[VeranaIndexer]
|
|
28
|
-
const data = await (0, util_1.fetchJson)(`${this.baseUrl}/verana/
|
|
29
|
-
return data.
|
|
15
|
+
async getEcosystem(id) {
|
|
16
|
+
this.config.logger.debug(`[VeranaIndexer] getEcosystem id=${id}`);
|
|
17
|
+
const data = await (0, util_1.fetchJson)(`${this.baseUrl}/verana/ec/v1/get/${id}`);
|
|
18
|
+
return data.ecosystem;
|
|
30
19
|
}
|
|
31
20
|
async getCredentialSchema(id) {
|
|
32
21
|
this.config.logger.debug(`[VeranaIndexer] getCredentialSchema id=${id}`);
|
|
33
22
|
const data = await (0, util_1.fetchJson)(`${this.baseUrl}/verana/cs/v1/get/${id}`);
|
|
34
23
|
return data.schema;
|
|
35
24
|
}
|
|
36
|
-
async
|
|
37
|
-
this.config.logger.debug(`[VeranaIndexer]
|
|
38
|
-
const data = await (0, util_1.fetchJson)(`${this.baseUrl}/verana/
|
|
39
|
-
return data.
|
|
25
|
+
async getParticipant(id) {
|
|
26
|
+
this.config.logger.debug(`[VeranaIndexer] getParticipant id=${id}`);
|
|
27
|
+
const data = await (0, util_1.fetchJson)(`${this.baseUrl}/verana/pp/v1/get/${id}`);
|
|
28
|
+
return data.participant;
|
|
40
29
|
}
|
|
41
30
|
}
|
|
42
31
|
exports.VeranaIndexerService = VeranaIndexerService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VeranaIndexerService.js","sourceRoot":"","sources":["../../src/blockchain/VeranaIndexerService.ts"],"names":[],"mapp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ACpB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAmB;QACtC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;QACnE,MAAM,IAAI,GAAG,MAAM,IAAA,gBAAS,EAAkC,GAAG,IAAI,CAAC,OAAO,qBAAqB,EAAE,EAAE,CAAC,CAAA;QACvG,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;CACF;AA9BD,oDA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexerHandlerRegistry.js","sourceRoot":"","sources":["../../../src/blockchain/handlers/IndexerHandlerRegistry.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"IndexerHandlerRegistry.js","sourceRoot":"","sources":["../../../src/blockchain/handlers/IndexerHandlerRegistry.ts"],"names":[],"mappings":";;;AAgBA;;;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"}
|
|
@@ -9,30 +9,30 @@ const stateMutations_1 = require("./stateMutations");
|
|
|
9
9
|
*/
|
|
10
10
|
exports.defaultHandlers = [
|
|
11
11
|
{
|
|
12
|
-
msg: '
|
|
12
|
+
msg: 'CreateNewEcosystem',
|
|
13
13
|
handle: async (activity, ctx) => {
|
|
14
|
-
(0, stateMutations_1.
|
|
15
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
14
|
+
(0, stateMutations_1.upsertEcosystem)(ctx.state, activity);
|
|
15
|
+
ctx.agent.config.logger.info(`[IndexerWS] CreateNewEcosystem entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
msg: '
|
|
19
|
+
msg: 'UpdateEcosystem',
|
|
20
20
|
handle: async (activity, ctx) => {
|
|
21
|
-
(0, stateMutations_1.
|
|
22
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
21
|
+
(0, stateMutations_1.upsertEcosystem)(ctx.state, activity);
|
|
22
|
+
ctx.agent.config.logger.info(`[IndexerWS] UpdateEcosystem entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
msg: 'AddGovernanceFrameworkDocument',
|
|
27
27
|
handle: async (activity, ctx) => {
|
|
28
|
-
(0, stateMutations_1.
|
|
28
|
+
(0, stateMutations_1.upsertEcosystem)(ctx.state, activity);
|
|
29
29
|
ctx.agent.config.logger.info(`[IndexerWS] AddGovernanceFrameworkDocument entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
msg: 'IncreaseActiveGFVersion',
|
|
34
34
|
handle: async (activity, ctx) => {
|
|
35
|
-
(0, stateMutations_1.
|
|
35
|
+
(0, stateMutations_1.bumpActiveVersion)(ctx.state, activity);
|
|
36
36
|
ctx.agent.config.logger.info(`[IndexerWS] IncreaseActiveGFVersion entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
37
37
|
},
|
|
38
38
|
},
|
|
@@ -59,62 +59,67 @@ exports.defaultHandlers = [
|
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
|
-
msg: '
|
|
62
|
+
msg: 'StartParticipantOP',
|
|
63
63
|
handle: async (activity, ctx) => {
|
|
64
|
-
(0, stateMutations_1.
|
|
65
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
64
|
+
(0, stateMutations_1.upsertParticipant)(ctx.state, activity, { opState: 'PENDING' });
|
|
65
|
+
ctx.agent.config.logger.info(`[IndexerWS] StartParticipantOP entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
66
|
+
await (0, stateMutations_1.startParticipantOPAutoFlow)(ctx.agent, activity);
|
|
66
67
|
},
|
|
67
68
|
},
|
|
68
69
|
{
|
|
69
|
-
msg: '
|
|
70
|
+
msg: 'RenewParticipantOP',
|
|
70
71
|
handle: async (activity, ctx) => {
|
|
71
|
-
(0, stateMutations_1.
|
|
72
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
72
|
+
(0, stateMutations_1.upsertParticipant)(ctx.state, activity, { opState: 'PENDING' });
|
|
73
|
+
ctx.agent.config.logger.info(`[IndexerWS] RenewParticipantOP entity=${activity.entity_id} block=${ctx.block_height} — TODO §5.1: progress credential acquisition flow (applicant renewal)`);
|
|
73
74
|
},
|
|
74
75
|
},
|
|
75
76
|
{
|
|
76
|
-
msg: '
|
|
77
|
+
msg: 'SetParticipantOPToValidated',
|
|
77
78
|
handle: async (activity, ctx) => {
|
|
78
|
-
(0, stateMutations_1.
|
|
79
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
79
|
+
(0, stateMutations_1.upsertParticipant)(ctx.state, activity, { opState: 'VALIDATED' });
|
|
80
|
+
ctx.agent.config.logger.info(`[IndexerWS] SetParticipantOPToValidated participant=${activity.entity_id} block=${ctx.block_height}`);
|
|
81
|
+
await (0, stateMutations_1.markVtFlowRecordsValidated)(ctx.agent, String(activity.entity_id));
|
|
80
82
|
},
|
|
81
83
|
},
|
|
82
84
|
{
|
|
83
|
-
msg: '
|
|
85
|
+
msg: 'SetParticipantEffectiveUntil',
|
|
84
86
|
handle: async (activity, ctx) => {
|
|
85
87
|
var _a;
|
|
86
|
-
(0, stateMutations_1.
|
|
88
|
+
(0, stateMutations_1.upsertParticipant)(ctx.state, activity, {
|
|
87
89
|
effectiveUntil: String((_a = activity.changes['effective_until']) !== null && _a !== void 0 ? _a : ''),
|
|
88
90
|
});
|
|
89
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
91
|
+
ctx.agent.config.logger.info(`[IndexerWS] SetParticipantEffectiveUntil entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
90
92
|
},
|
|
91
93
|
},
|
|
92
94
|
{
|
|
93
|
-
msg: '
|
|
95
|
+
msg: 'RevokeParticipant',
|
|
94
96
|
handle: async (activity, ctx) => {
|
|
95
|
-
(0, stateMutations_1.
|
|
96
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
97
|
+
(0, stateMutations_1.upsertParticipant)(ctx.state, activity, { revoked: true });
|
|
98
|
+
ctx.agent.config.logger.info(`[IndexerWS] RevokeParticipant entity=${activity.entity_id} block=${ctx.block_height} — TODO §7.2: remove linked VP from DID doc + delete credential`);
|
|
99
|
+
await (0, stateMutations_1.setVtFlowRecordsParticipantRevoked)(ctx.agent, String(activity.entity_id));
|
|
97
100
|
},
|
|
98
101
|
},
|
|
99
102
|
{
|
|
100
|
-
msg: '
|
|
103
|
+
msg: 'SlashParticipantTrustDeposit',
|
|
101
104
|
handle: async (activity, ctx) => {
|
|
102
|
-
(0, stateMutations_1.
|
|
103
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
105
|
+
(0, stateMutations_1.upsertParticipant)(ctx.state, activity, { slashed: true });
|
|
106
|
+
ctx.agent.config.logger.info(`[IndexerWS] SlashParticipantTrustDeposit participant=${activity.entity_id} block=${ctx.block_height}`);
|
|
107
|
+
await (0, stateMutations_1.setVtFlowRecordsParticipantSlashed)(ctx.agent, String(activity.entity_id));
|
|
104
108
|
},
|
|
105
109
|
},
|
|
106
110
|
{
|
|
107
|
-
msg: '
|
|
111
|
+
msg: 'RepayParticipantSlashedTrustDeposit',
|
|
108
112
|
handle: async (activity, ctx) => {
|
|
109
|
-
(0, stateMutations_1.
|
|
110
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
113
|
+
(0, stateMutations_1.upsertParticipant)(ctx.state, activity, { slashed: false });
|
|
114
|
+
ctx.agent.config.logger.info(`[IndexerWS] RepayParticipantSlashedTrustDeposit entity=${activity.entity_id} block=${ctx.block_height}`);
|
|
111
115
|
},
|
|
112
116
|
},
|
|
113
117
|
{
|
|
114
|
-
msg: '
|
|
118
|
+
msg: 'CancelParticipantOPLastRequest',
|
|
115
119
|
handle: async (activity, ctx) => {
|
|
116
|
-
(0, stateMutations_1.
|
|
117
|
-
ctx.agent.config.logger.info(`[IndexerWS]
|
|
120
|
+
(0, stateMutations_1.upsertParticipant)(ctx.state, activity, {});
|
|
121
|
+
ctx.agent.config.logger.info(`[IndexerWS] CancelParticipantOPLastRequest participant=${activity.entity_id} block=${ctx.block_height}`);
|
|
122
|
+
await (0, stateMutations_1.terminateVtFlowRecordsByApplicant)(ctx.agent, String(activity.entity_id));
|
|
118
123
|
},
|
|
119
124
|
},
|
|
120
125
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultHandlers.js","sourceRoot":"","sources":["../../../src/blockchain/handlers/defaultHandlers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"defaultHandlers.js","sourceRoot":"","sources":["../../../src/blockchain/handlers/defaultHandlers.ts"],"names":[],"mappings":";;;AAoKA,gFAIC;AAxKD,qEAAsF;AACtF,qDAWyB;AAEzB;;GAEG;AACU,QAAA,eAAe,GAA0B;IACpD;QACE,GAAG,EAAE,oBAAoB;QACzB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE;YAC9B,IAAA,gCAAe,EAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YACpC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC1B,yCAAyC,QAAQ,CAAC,SAAS,UAAU,GAAG,CAAC,YAAY,EAAE,CACxF,CAAA;QACH,CAAC;KACF;IACD;QACE,GAAG,EAAE,iBAAiB;QACtB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE;YAC9B,IAAA,gCAAe,EAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YACpC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC1B,sCAAsC,QAAQ,CAAC,SAAS,UAAU,GAAG,CAAC,YAAY,EAAE,CACrF,CAAA;QACH,CAAC;KACF;IACD;QACE,GAAG,EAAE,gCAAgC;QACrC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE;YAC9B,IAAA,gCAAe,EAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YACpC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC1B,qDAAqD,QAAQ,CAAC,SAAS,UAAU,GAAG,CAAC,YAAY,EAAE,CACpG,CAAA;QACH,CAAC;KACF;IACD;QACE,GAAG,EAAE,yBAAyB;QAC9B,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,G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
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { AgentContext } from '@credo-ts/core';
|
|
2
|
+
import { VtFlowRecord, VtFlowService } from '@verana-labs/credo-ts-didcomm-vt-flow';
|
|
1
3
|
import { VsAgent } from '../../agent/VsAgent';
|
|
2
4
|
import { IndexerActivity, VeranaSyncState } from '../types';
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
+
export declare function upsertEcosystem(state: VeranaSyncState, activity: IndexerActivity): void;
|
|
6
|
+
export declare function bumpActiveVersion(state: VeranaSyncState, activity: IndexerActivity): void;
|
|
5
7
|
export declare function upsertCredentialSchema(state: VeranaSyncState, activity: IndexerActivity): void;
|
|
6
|
-
export declare function
|
|
7
|
-
|
|
8
|
+
export declare function upsertParticipant(state: VeranaSyncState, activity: IndexerActivity, overrides?: {
|
|
9
|
+
opState?: string;
|
|
8
10
|
revoked?: boolean;
|
|
9
11
|
slashed?: boolean;
|
|
10
12
|
effectiveUntil?: string;
|
|
11
13
|
}): void;
|
|
14
|
+
export declare function reconcileVtFlowRecordsForParticipant(agent: VsAgent, participantId: string, reconcile: (record: VtFlowRecord, service: VtFlowService, agentContext: AgentContext) => Promise<string | null>, errorLabel: string): Promise<void>;
|
|
15
|
+
export declare function markVtFlowRecordsValidated(agent: VsAgent, participantId: string): Promise<void>;
|
|
16
|
+
export declare function setVtFlowRecordsParticipantRevoked(agent: VsAgent, participantId: string): Promise<void>;
|
|
17
|
+
export declare function setVtFlowRecordsParticipantSlashed(agent: VsAgent, participantId: string): Promise<void>;
|
|
18
|
+
export declare function terminateVtFlowRecordsByApplicant(agent: VsAgent, participantId: string): Promise<void>;
|
|
19
|
+
export declare function startParticipantOPAutoFlow(agent: VsAgent, activity: IndexerActivity): Promise<void>;
|
|
12
20
|
export declare function publishVtjscIfOwner(state: VeranaSyncState, agent: VsAgent, schemaEntityId: string): Promise<void>;
|