@verana-labs/vs-agent-sdk 1.12.0-dev.1 → 1.12.0-dev.10
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 +2 -0
- package/build/agent/VsAgent.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/index.d.ts +3 -4
- package/build/index.js +7 -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/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
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { BaseLogger } from '@credo-ts/core';
|
|
2
|
+
export declare enum ValidationState {
|
|
3
|
+
UNSPECIFIED = 0,
|
|
4
|
+
PENDING = 1,
|
|
5
|
+
VALIDATED = 2,
|
|
6
|
+
TERMINATED = 3
|
|
7
|
+
}
|
|
8
|
+
export interface Participant {
|
|
9
|
+
id: number;
|
|
10
|
+
schemaId: number;
|
|
11
|
+
role: number;
|
|
12
|
+
did: string;
|
|
13
|
+
corporation: string;
|
|
14
|
+
validatorParticipantId: number;
|
|
15
|
+
opState?: ValidationState;
|
|
16
|
+
opSummaryDigest: string;
|
|
17
|
+
revoked: Date | undefined;
|
|
18
|
+
slashed: Date | undefined;
|
|
19
|
+
}
|
|
2
20
|
export declare const VERANA_BECH32_PREFIX = "verana";
|
|
3
21
|
export declare const RECORD_ID = "verana-blockchain-sync-state";
|
|
4
22
|
export type IndexerEventRecord = {
|
|
@@ -18,14 +36,33 @@ export type IndexerEventRecord = {
|
|
|
18
36
|
related_dids: string[];
|
|
19
37
|
entity_type?: string;
|
|
20
38
|
entity_id?: string;
|
|
39
|
+
corporation_id?: number;
|
|
40
|
+
related_corporation_ids?: number[];
|
|
21
41
|
};
|
|
22
42
|
};
|
|
43
|
+
export interface IndexerReadyMessage {
|
|
44
|
+
type: 'ready';
|
|
45
|
+
block: number;
|
|
46
|
+
blockTime: string;
|
|
47
|
+
blockIntervalMs: number;
|
|
48
|
+
}
|
|
49
|
+
export interface IndexerBlockMessage {
|
|
50
|
+
type: 'block';
|
|
51
|
+
block: number;
|
|
52
|
+
blockTime: string;
|
|
53
|
+
events: IndexerEventRecord[];
|
|
54
|
+
}
|
|
55
|
+
export interface IndexerSubscribeMessage {
|
|
56
|
+
action: 'subscribe';
|
|
57
|
+
dids?: string[];
|
|
58
|
+
corporationId?: number;
|
|
59
|
+
}
|
|
23
60
|
export interface IndexerEventsResponse {
|
|
24
61
|
events: IndexerEventRecord[];
|
|
25
62
|
count: number;
|
|
26
63
|
after_block_height: number;
|
|
27
64
|
}
|
|
28
|
-
export type IndexerEntityType = '
|
|
65
|
+
export type IndexerEntityType = 'Ecosystem' | 'CredentialSchema' | 'Participant' | 'ParticipantSession' | 'TrustDeposit';
|
|
29
66
|
export interface IndexerActivity {
|
|
30
67
|
timestamp: string;
|
|
31
68
|
block_height: string | number;
|
|
@@ -44,29 +81,29 @@ export interface VeranaIdxConfig {
|
|
|
44
81
|
baseUrl: string;
|
|
45
82
|
logger: BaseLogger;
|
|
46
83
|
}
|
|
47
|
-
export interface
|
|
84
|
+
export interface SyncedEcosystem {
|
|
48
85
|
id: number;
|
|
49
86
|
did: string;
|
|
50
|
-
|
|
87
|
+
corporationId: number;
|
|
51
88
|
archived: boolean;
|
|
52
|
-
|
|
89
|
+
activeVersion?: number;
|
|
53
90
|
lastModifiedBlock: number;
|
|
54
91
|
}
|
|
55
92
|
export interface SyncedCredentialSchema {
|
|
56
93
|
id: number;
|
|
57
|
-
|
|
94
|
+
ecosystemId: number;
|
|
58
95
|
jsonSchema: string;
|
|
59
96
|
issuerMode?: string;
|
|
60
97
|
verifierMode?: string;
|
|
61
98
|
archived: boolean;
|
|
62
99
|
lastModifiedBlock: number;
|
|
63
100
|
}
|
|
64
|
-
export interface
|
|
101
|
+
export interface SyncedParticipant {
|
|
65
102
|
id: number;
|
|
66
103
|
schemaId: number;
|
|
67
104
|
did: string;
|
|
68
|
-
|
|
69
|
-
|
|
105
|
+
role: number;
|
|
106
|
+
opState?: string;
|
|
70
107
|
effectiveUntil?: string;
|
|
71
108
|
revoked: boolean;
|
|
72
109
|
slashed: boolean;
|
|
@@ -74,49 +111,62 @@ export interface SyncedPermission {
|
|
|
74
111
|
}
|
|
75
112
|
export interface VeranaSyncState {
|
|
76
113
|
lastBlockHeight: number;
|
|
77
|
-
|
|
114
|
+
ecosystems: Record<string, SyncedEcosystem>;
|
|
78
115
|
credentialSchemas: Record<string, SyncedCredentialSchema>;
|
|
79
|
-
|
|
116
|
+
participants: Record<string, SyncedParticipant>;
|
|
80
117
|
}
|
|
81
|
-
export interface
|
|
118
|
+
export interface EcosystemDto {
|
|
82
119
|
id: number;
|
|
83
120
|
did: string;
|
|
84
|
-
|
|
121
|
+
corporation_id: number;
|
|
85
122
|
archived: string | null;
|
|
86
|
-
|
|
123
|
+
active_version?: number;
|
|
87
124
|
}
|
|
88
125
|
export interface CredentialSchemaDto {
|
|
89
126
|
id: number;
|
|
90
|
-
|
|
127
|
+
ecosystem_id: number;
|
|
91
128
|
json_schema: string;
|
|
92
|
-
|
|
93
|
-
|
|
129
|
+
issuer_onboarding_mode?: string;
|
|
130
|
+
verifier_onboarding_mode?: string;
|
|
94
131
|
archived: string | null;
|
|
95
132
|
created: string;
|
|
96
133
|
modified: string;
|
|
97
134
|
}
|
|
98
|
-
export interface
|
|
135
|
+
export interface ParticipantDto {
|
|
99
136
|
id: number;
|
|
100
137
|
schema_id: number;
|
|
101
138
|
did: string | null;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
vp_state?: string;
|
|
139
|
+
role: string;
|
|
140
|
+
op_state?: string;
|
|
105
141
|
revoked: string | null;
|
|
106
142
|
slashed: string | null;
|
|
107
143
|
effective_until?: string;
|
|
108
144
|
modified: string;
|
|
145
|
+
validator_participant_id?: number | null;
|
|
146
|
+
op_summary_digest?: string;
|
|
109
147
|
}
|
|
110
|
-
export interface
|
|
111
|
-
|
|
112
|
-
|
|
148
|
+
export interface RawParticipant {
|
|
149
|
+
id: number;
|
|
150
|
+
schemaId: number;
|
|
151
|
+
role: number;
|
|
152
|
+
did: string;
|
|
153
|
+
corporationId?: number;
|
|
154
|
+
validatorParticipantId: number;
|
|
155
|
+
opState?: number;
|
|
156
|
+
opSummaryDigest?: string;
|
|
157
|
+
revoked: Date | undefined;
|
|
158
|
+
slashed: Date | undefined;
|
|
159
|
+
}
|
|
160
|
+
export interface ParticipantQueryClient {
|
|
161
|
+
GetParticipant(req: {
|
|
162
|
+
id: number;
|
|
113
163
|
}): Promise<{
|
|
114
|
-
|
|
164
|
+
participant?: RawParticipant;
|
|
115
165
|
}>;
|
|
116
|
-
|
|
117
|
-
|
|
166
|
+
FindParticipantsWithDID(req: object): Promise<{
|
|
167
|
+
participants: RawParticipant[];
|
|
118
168
|
}>;
|
|
119
|
-
|
|
169
|
+
GetParticipantSession(req: {
|
|
120
170
|
id: string;
|
|
121
171
|
}): Promise<{
|
|
122
172
|
session?: unknown;
|
|
@@ -128,31 +178,121 @@ export interface VeranaChainConfig {
|
|
|
128
178
|
mnemonic: string;
|
|
129
179
|
logger: BaseLogger;
|
|
130
180
|
gasPrice?: string;
|
|
181
|
+
corporationAddress?: string;
|
|
182
|
+
autoTriggerResolver?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* FIXME(verana setValidated->AUTHZ-CHECK-3): temporary. On the current chain, validating a participant
|
|
185
|
+
* (OperatorAuthorization) and creating its session (VSOperatorAuthorization) need two mutually-exclusive
|
|
186
|
+
* account permissions, so one account cannot do both. When set, the session is signed by this second
|
|
187
|
+
* account. Remove once the chain authorizes both under one vs_operator (AUTHZ-CHECK-3).
|
|
188
|
+
*/
|
|
189
|
+
sessionOperatorMnemonic?: string;
|
|
131
190
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
191
|
+
/** Wrapper for optional uint64 values per `verana.pp.v1.OptionalUInt64`. */
|
|
192
|
+
export interface OptionalUInt64 {
|
|
193
|
+
value: number;
|
|
194
|
+
}
|
|
195
|
+
export interface StartParticipantOPParams {
|
|
196
|
+
role: number;
|
|
197
|
+
validatorParticipantId: number;
|
|
136
198
|
did: string;
|
|
137
|
-
validationFees?:
|
|
138
|
-
|
|
139
|
-
|
|
199
|
+
validationFees?: OptionalUInt64;
|
|
200
|
+
issuanceFees?: OptionalUInt64;
|
|
201
|
+
verificationFees?: OptionalUInt64;
|
|
140
202
|
}
|
|
141
|
-
export interface
|
|
142
|
-
id:
|
|
203
|
+
export interface SetParticipantOPToValidatedParams {
|
|
204
|
+
id: number;
|
|
143
205
|
effectiveUntil?: Date;
|
|
144
|
-
validationFees
|
|
145
|
-
issuanceFees
|
|
146
|
-
verificationFees
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
export interface
|
|
206
|
+
validationFees?: number;
|
|
207
|
+
issuanceFees?: number;
|
|
208
|
+
verificationFees?: number;
|
|
209
|
+
opSummaryDigest: string;
|
|
210
|
+
issuanceFeeDiscount?: number;
|
|
211
|
+
verificationFeeDiscount?: number;
|
|
212
|
+
corporation?: string;
|
|
213
|
+
}
|
|
214
|
+
export interface CreateOrUpdateParticipantSessionParams {
|
|
153
215
|
id: string;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
216
|
+
issuerParticipantId?: number;
|
|
217
|
+
verifierParticipantId?: number;
|
|
218
|
+
agentParticipantId: number;
|
|
219
|
+
walletAgentParticipantId: number;
|
|
220
|
+
digest?: string;
|
|
221
|
+
corporation?: string;
|
|
222
|
+
}
|
|
223
|
+
export interface Coin {
|
|
224
|
+
denom: string;
|
|
225
|
+
amount: string;
|
|
226
|
+
}
|
|
227
|
+
export interface DurationParam {
|
|
228
|
+
seconds: number;
|
|
229
|
+
nanos?: number;
|
|
230
|
+
}
|
|
231
|
+
export interface GrantOperatorAuthorizationParams {
|
|
232
|
+
grantee: string;
|
|
233
|
+
msgTypes: string[];
|
|
234
|
+
expiration?: Date;
|
|
235
|
+
authzSpendLimit?: Coin[];
|
|
236
|
+
authzSpendLimitPeriod?: DurationParam;
|
|
237
|
+
withFeegrant?: boolean;
|
|
238
|
+
feegrantSpendLimit?: Coin[];
|
|
239
|
+
feegrantSpendLimitPeriod?: DurationParam;
|
|
240
|
+
feeSpendLimit?: Coin[];
|
|
241
|
+
}
|
|
242
|
+
export interface RevokeOperatorAuthorizationParams {
|
|
243
|
+
grantee: string;
|
|
244
|
+
}
|
|
245
|
+
export interface CreateEcosystemParams {
|
|
246
|
+
did: string;
|
|
247
|
+
language: string;
|
|
248
|
+
docUrl: string;
|
|
249
|
+
docDigestSri: string;
|
|
250
|
+
aka?: string;
|
|
251
|
+
}
|
|
252
|
+
export interface ArchiveEcosystemParams {
|
|
253
|
+
ecosystemId: number;
|
|
254
|
+
archive: boolean;
|
|
255
|
+
}
|
|
256
|
+
/** Wrapper for optional uint32 values per `verana.cs.v1.OptionalUInt32`. */
|
|
257
|
+
export interface OptionalUInt32 {
|
|
258
|
+
value: number;
|
|
259
|
+
}
|
|
260
|
+
export interface CreateCredentialSchemaParams {
|
|
261
|
+
ecosystemId: number;
|
|
262
|
+
jsonSchema: string;
|
|
263
|
+
issuerOnboardingMode?: number;
|
|
264
|
+
verifierOnboardingMode?: number;
|
|
265
|
+
holderOnboardingMode?: number;
|
|
266
|
+
pricingAssetType?: number;
|
|
267
|
+
pricingAsset?: string;
|
|
268
|
+
digestAlgorithm?: string;
|
|
269
|
+
issuerGrantorValidationValidityPeriod?: OptionalUInt32;
|
|
270
|
+
verifierGrantorValidationValidityPeriod?: OptionalUInt32;
|
|
271
|
+
issuerValidationValidityPeriod?: OptionalUInt32;
|
|
272
|
+
verifierValidationValidityPeriod?: OptionalUInt32;
|
|
273
|
+
holderValidationValidityPeriod?: OptionalUInt32;
|
|
274
|
+
}
|
|
275
|
+
export interface CreateRootParticipantParams {
|
|
276
|
+
schemaId: number;
|
|
277
|
+
did: string;
|
|
278
|
+
effectiveFrom?: Date;
|
|
279
|
+
effectiveUntil?: Date;
|
|
280
|
+
validationFees?: number;
|
|
281
|
+
issuanceFees?: number;
|
|
282
|
+
verificationFees?: number;
|
|
283
|
+
}
|
|
284
|
+
export interface SelfCreateParticipantParams {
|
|
285
|
+
role: number;
|
|
286
|
+
validatorParticipantId: number;
|
|
287
|
+
did: string;
|
|
288
|
+
effectiveFrom?: Date;
|
|
289
|
+
effectiveUntil?: Date;
|
|
290
|
+
validationFees?: number;
|
|
291
|
+
verificationFees?: number;
|
|
292
|
+
vsOperator?: string;
|
|
293
|
+
vsOperatorAuthzEnabled?: boolean;
|
|
294
|
+
vsOperatorAuthzSpendLimit?: Coin[];
|
|
295
|
+
vsOperatorAuthzWithFeegrant?: boolean;
|
|
296
|
+
vsOperatorAuthzFeeSpendLimit?: Coin[];
|
|
297
|
+
vsOperatorAuthzSpendPeriod?: DurationParam;
|
|
158
298
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RECORD_ID = exports.VERANA_BECH32_PREFIX = void 0;
|
|
3
|
+
exports.RECORD_ID = exports.VERANA_BECH32_PREFIX = exports.ValidationState = void 0;
|
|
4
|
+
var ValidationState;
|
|
5
|
+
(function (ValidationState) {
|
|
6
|
+
ValidationState[ValidationState["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
7
|
+
ValidationState[ValidationState["PENDING"] = 1] = "PENDING";
|
|
8
|
+
ValidationState[ValidationState["VALIDATED"] = 2] = "VALIDATED";
|
|
9
|
+
ValidationState[ValidationState["TERMINATED"] = 3] = "TERMINATED";
|
|
10
|
+
})(ValidationState || (exports.ValidationState = ValidationState = {}));
|
|
4
11
|
exports.VERANA_BECH32_PREFIX = 'verana';
|
|
5
12
|
exports.RECORD_ID = 'verana-blockchain-sync-state';
|
|
6
13
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/blockchain/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/blockchain/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,mEAAe,CAAA;IACf,2DAAW,CAAA;IACX,+DAAa,CAAA;IACb,iEAAc,CAAA;AAChB,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B;AAeY,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAC/B,QAAA,SAAS,GAAG,8BAA8B,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { AnonCredsRevocationRegistryDefinition } from '@credo-ts/anoncreds';
|
|
2
2
|
import type { AgentContext } from '@credo-ts/core';
|
|
3
3
|
import { BasicTailsFileService } from '@credo-ts/anoncreds';
|
|
4
|
+
export declare function isValidTailsFileName(name: string): boolean;
|
|
5
|
+
export declare function getTailsDirectoryPath(agentContext: AgentContext): string;
|
|
6
|
+
export declare function migrateLegacyTailsFiles(agentContext: AgentContext): void;
|
|
4
7
|
export declare class FullTailsFileService extends BasicTailsFileService {
|
|
5
8
|
private tailsServerBaseUrl;
|
|
6
9
|
constructor(options: {
|
|
7
|
-
tailsDirectoryPath?: string;
|
|
8
10
|
tailsServerBaseUrl: string;
|
|
9
11
|
});
|
|
10
12
|
uploadTailsFile(agentContext: AgentContext, options: {
|
|
@@ -13,6 +15,4 @@ export declare class FullTailsFileService extends BasicTailsFileService {
|
|
|
13
15
|
tailsFileUrl: string;
|
|
14
16
|
}>;
|
|
15
17
|
}
|
|
16
|
-
export declare
|
|
17
|
-
export declare const tailsIndex: Record<string, string>;
|
|
18
|
-
export declare function deleteTailsEntry(tailsFileUrl: string): void;
|
|
18
|
+
export declare function deleteTailsFile(agentContext: AgentContext, tailsFileUrl: string): void;
|
|
@@ -3,90 +3,97 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
6
|
+
exports.FullTailsFileService = void 0;
|
|
7
|
+
exports.isValidTailsFileName = isValidTailsFileName;
|
|
8
|
+
exports.getTailsDirectoryPath = getTailsDirectoryPath;
|
|
9
|
+
exports.migrateLegacyTailsFiles = migrateLegacyTailsFiles;
|
|
10
|
+
exports.deleteTailsFile = deleteTailsFile;
|
|
8
11
|
const anoncreds_1 = require("@credo-ts/anoncreds");
|
|
9
12
|
const core_1 = require("@credo-ts/core");
|
|
10
13
|
const crypto_1 = require("crypto");
|
|
11
14
|
const fs_1 = __importDefault(require("fs"));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
async uploadTailsFile(agentContext, options) {
|
|
18
|
-
const revocationRegistryDefinition = options.revocationRegistryDefinition;
|
|
19
|
-
const localTailsFilePath = revocationRegistryDefinition.value.tailsLocation;
|
|
20
|
-
const tailsFileId = core_1.utils.uuid();
|
|
21
|
-
try {
|
|
22
|
-
await saveTailsFile(localTailsFilePath, tailsFileId, agentContext.config.logger);
|
|
23
|
-
agentContext.config.logger.info('Tails file processed successfully!');
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
agentContext.config.logger.error(`Failed to process tails file: ${error.message}`);
|
|
27
|
-
}
|
|
28
|
-
return { tailsFileUrl: `${this.tailsServerBaseUrl}/${encodeURIComponent(tailsFileId)}` };
|
|
29
|
-
}
|
|
15
|
+
const os_1 = __importDefault(require("os"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const tailsFileNamePattern = /^[A-Za-z0-9-]+$/;
|
|
18
|
+
function isValidTailsFileName(name) {
|
|
19
|
+
return tailsFileNamePattern.test(name);
|
|
30
20
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
function getTailsDirectoryPath(agentContext) {
|
|
22
|
+
if (process.env.TAILS_DIRECTORY_PATH)
|
|
23
|
+
return process.env.TAILS_DIRECTORY_PATH;
|
|
24
|
+
const fileSystem = agentContext.dependencyManager.resolve(core_1.InjectionSymbols.FileSystem);
|
|
25
|
+
return path_1.default.join(fileSystem.dataPath, 'tails');
|
|
36
26
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
// Copy uuid tails files from earlier locations (TAILS_DIRECTORY_PATH, ~/.afj/tails, the old cwd ./tails) into the current dir so URLs published before the hash-based change still resolve.
|
|
28
|
+
// TODO (last legacy version: v1.12.0-dev.8): Remove this once the last release using the legacy configuration is no longer supported.
|
|
29
|
+
function migrateLegacyTailsFiles(agentContext) {
|
|
30
|
+
const directory = getTailsDirectoryPath(agentContext);
|
|
31
|
+
const legacyDirectories = [
|
|
32
|
+
process.env.TAILS_DIRECTORY_PATH,
|
|
33
|
+
path_1.default.join(os_1.default.homedir(), '.afj', 'tails'),
|
|
34
|
+
path_1.default.resolve('tails'),
|
|
35
|
+
];
|
|
36
|
+
for (const legacyDirectory of new Set(legacyDirectories.filter((d) => Boolean(d)))) {
|
|
41
37
|
try {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
const legacyIndexPath = path_1.default.join(legacyDirectory, 'index.json');
|
|
39
|
+
if (!fs_1.default.existsSync(legacyIndexPath))
|
|
40
|
+
continue;
|
|
41
|
+
const legacyIndex = JSON.parse(fs_1.default.readFileSync(legacyIndexPath, 'utf-8'));
|
|
42
|
+
fs_1.default.mkdirSync(directory, { recursive: true });
|
|
43
|
+
let migrated = 0;
|
|
44
|
+
for (const [tailsFileId, hash] of Object.entries(legacyIndex)) {
|
|
45
|
+
if (!isValidTailsFileName(tailsFileId) || !isValidTailsFileName(hash))
|
|
46
|
+
continue;
|
|
47
|
+
const source = path_1.default.join(legacyDirectory, hash);
|
|
48
|
+
const destination = path_1.default.join(directory, tailsFileId);
|
|
49
|
+
if (!fs_1.default.existsSync(source) || fs_1.default.existsSync(destination))
|
|
50
|
+
continue;
|
|
51
|
+
const tempPath = path_1.default.join(directory, `.${tailsFileId}.${process.pid}.${(0, crypto_1.randomBytes)(8).toString('hex')}.tmp`);
|
|
52
|
+
try {
|
|
53
|
+
fs_1.default.copyFileSync(source, tempPath);
|
|
54
|
+
fs_1.default.renameSync(tempPath, destination);
|
|
55
|
+
migrated++;
|
|
56
|
+
}
|
|
57
|
+
catch (fileError) {
|
|
58
|
+
try {
|
|
59
|
+
fs_1.default.unlinkSync(tempPath);
|
|
60
|
+
}
|
|
61
|
+
catch (_a) { }
|
|
62
|
+
agentContext.config.logger.warn(`Legacy tails file ${tailsFileId} skipped: ${fileError.message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (migrated > 0)
|
|
66
|
+
agentContext.config.logger.info(`Migrated ${migrated} legacy tails file(s) from ${legacyDirectory}`);
|
|
51
67
|
}
|
|
52
68
|
catch (error) {
|
|
53
|
-
|
|
69
|
+
agentContext.config.logger.warn(`Legacy tails migration skipped for ${legacyDirectory}: ${error.message}`);
|
|
54
70
|
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function deleteTailsEntry(tailsFileUrl) {
|
|
58
|
-
var _a;
|
|
59
|
-
const tailsFileId = decodeURIComponent((_a = tailsFileUrl.split('/').pop()) !== null && _a !== void 0 ? _a : '');
|
|
60
|
-
if (!tailsFileId || !exports.tailsIndex[tailsFileId])
|
|
61
|
-
return;
|
|
62
|
-
const hash = exports.tailsIndex[tailsFileId];
|
|
63
|
-
delete exports.tailsIndex[tailsFileId];
|
|
64
|
-
fs_1.default.writeFileSync(indexFilePath, JSON.stringify(exports.tailsIndex));
|
|
65
|
-
const stillReferenced = Object.values(exports.tailsIndex).includes(hash);
|
|
66
|
-
if (!stillReferenced) {
|
|
67
|
-
const filePath = `${exports.baseFilePath}/${hash}`;
|
|
68
|
-
if (fs_1.default.existsSync(filePath))
|
|
69
|
-
fs_1.default.unlinkSync(filePath);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (!tailsFileId)
|
|
77
|
-
throw new Error('Missing tailsFileId');
|
|
78
|
-
if (exports.tailsIndex[tailsFileId])
|
|
79
|
-
throw new Error(`There is already an entry for: ${tailsFileId}`);
|
|
80
|
-
const hash = await fileHash(localFilePath);
|
|
81
|
-
const destinationPath = `${exports.baseFilePath}/${hash}`;
|
|
82
|
-
if (fs_1.default.existsSync(destinationPath)) {
|
|
83
|
-
logger.warn('Tails file already exists');
|
|
73
|
+
class FullTailsFileService extends anoncreds_1.BasicTailsFileService {
|
|
74
|
+
constructor(options) {
|
|
75
|
+
super();
|
|
76
|
+
this.tailsServerBaseUrl = options.tailsServerBaseUrl;
|
|
84
77
|
}
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
async uploadTailsFile(agentContext, options) {
|
|
79
|
+
const { tailsLocation, tailsHash } = options.revocationRegistryDefinition.value;
|
|
80
|
+
const directory = getTailsDirectoryPath(agentContext);
|
|
81
|
+
await fs_1.default.promises.mkdir(directory, { recursive: true });
|
|
82
|
+
const destination = path_1.default.join(directory, tailsHash);
|
|
83
|
+
if (!fs_1.default.existsSync(destination))
|
|
84
|
+
await fs_1.default.promises.copyFile(tailsLocation, destination);
|
|
85
|
+
agentContext.config.logger.info(`Stored tails file ${tailsHash}`);
|
|
86
|
+
return { tailsFileUrl: `${this.tailsServerBaseUrl}/${encodeURIComponent(tailsHash)}` };
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
}
|
|
89
|
+
exports.FullTailsFileService = FullTailsFileService;
|
|
90
|
+
function deleteTailsFile(agentContext, tailsFileUrl) {
|
|
91
|
+
var _a;
|
|
92
|
+
const tailsHash = decodeURIComponent((_a = tailsFileUrl.split('/').pop()) !== null && _a !== void 0 ? _a : '');
|
|
93
|
+
if (!isValidTailsFileName(tailsHash))
|
|
94
|
+
return;
|
|
95
|
+
const filePath = path_1.default.join(getTailsDirectoryPath(agentContext), tailsHash);
|
|
96
|
+
if (fs_1.default.existsSync(filePath))
|
|
97
|
+
fs_1.default.unlinkSync(filePath);
|
|
91
98
|
}
|
|
92
99
|
//# sourceMappingURL=FullTailsFileService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullTailsFileService.js","sourceRoot":"","sources":["../../src/credentials/FullTailsFileService.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"FullTailsFileService.js","sourceRoot":"","sources":["../../src/credentials/FullTailsFileService.ts"],"names":[],"mappings":";;;;;;AAYA,oDAEC;AAED,sDAIC;AAID,0DA6CC;AA2BD,0CAMC;AAnGD,mDAA2D;AAC3D,yCAAiD;AACjD,mCAAoC;AACpC,4CAAmB;AACnB,4CAAmB;AACnB,gDAAuB;AAEvB,MAAM,oBAAoB,GAAG,iBAAiB,CAAA;AAE9C,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxC,CAAC;AAED,SAAgB,qBAAqB,CAAC,YAA0B;IAC9D,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;IAC7E,MAAM,UAAU,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAa,uBAAgB,CAAC,UAAU,CAAC,CAAA;IAClG,OAAO,cAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AAChD,CAAC;AAED,4LAA4L;AAC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
|
|
2
|
-
export
|
|
2
|
+
export * from './types';
|
|
3
3
|
export * from './events';
|
|
4
4
|
export { setupBaseDidComm } from './plugins/setupBaseDidComm';
|
|
5
5
|
export type { BaseDidCommPlugin, BaseDidCommPluginOptions } from './plugins/setupBaseDidComm';
|
|
6
|
-
export type { VsAgentNestPlugin, MessageHandler } from './types';
|
|
7
|
-
export { MESSAGE_HANDLERS } from './types';
|
|
8
6
|
export { CachedWebDidResolver } from './did/CachedWebDidResolver';
|
|
9
7
|
export { WebDidRegistrar } from './did/WebDidRegistrar';
|
|
10
8
|
export { getLegacyDidDocument } from './did/legacyDidWeb';
|
|
11
9
|
export { HttpInboundTransport, HttpTransportSession } from './transports/HttpInboundTransport';
|
|
12
10
|
export { VsAgentWsInboundTransport, WebSocketTransportSession } from './transports/VsAgentWsInboundTransport';
|
|
13
11
|
export { VsAgentWsOutboundTransport } from './transports/VsAgentWsOutboundTransport';
|
|
14
|
-
export { FullTailsFileService,
|
|
12
|
+
export { FullTailsFileService, getTailsDirectoryPath, deleteTailsFile, isValidTailsFileName, migrateLegacyTailsFiles, } from './credentials/FullTailsFileService';
|
|
15
13
|
export * from './utils';
|
|
16
14
|
export * from './blockchain';
|
|
15
|
+
export * from './vtFlow';
|
package/build/index.js
CHANGED
|
@@ -14,16 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.migrateLegacyTailsFiles = exports.isValidTailsFileName = exports.deleteTailsFile = exports.getTailsDirectoryPath = exports.FullTailsFileService = exports.VsAgentWsOutboundTransport = exports.WebSocketTransportSession = exports.VsAgentWsInboundTransport = exports.HttpTransportSession = exports.HttpInboundTransport = exports.getLegacyDidDocument = exports.WebDidRegistrar = exports.CachedWebDidResolver = exports.setupBaseDidComm = void 0;
|
|
18
18
|
// Agent
|
|
19
19
|
__exportStar(require("./agent"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
20
21
|
// Events
|
|
21
22
|
__exportStar(require("./events"), exports);
|
|
22
23
|
// Plugins
|
|
23
24
|
var setupBaseDidComm_1 = require("./plugins/setupBaseDidComm");
|
|
24
25
|
Object.defineProperty(exports, "setupBaseDidComm", { enumerable: true, get: function () { return setupBaseDidComm_1.setupBaseDidComm; } });
|
|
25
|
-
var types_1 = require("./types");
|
|
26
|
-
Object.defineProperty(exports, "MESSAGE_HANDLERS", { enumerable: true, get: function () { return types_1.MESSAGE_HANDLERS; } });
|
|
27
26
|
// DID utilities
|
|
28
27
|
var CachedWebDidResolver_1 = require("./did/CachedWebDidResolver");
|
|
29
28
|
Object.defineProperty(exports, "CachedWebDidResolver", { enumerable: true, get: function () { return CachedWebDidResolver_1.CachedWebDidResolver; } });
|
|
@@ -43,10 +42,12 @@ Object.defineProperty(exports, "VsAgentWsOutboundTransport", { enumerable: true,
|
|
|
43
42
|
// Credentials
|
|
44
43
|
var FullTailsFileService_1 = require("./credentials/FullTailsFileService");
|
|
45
44
|
Object.defineProperty(exports, "FullTailsFileService", { enumerable: true, get: function () { return FullTailsFileService_1.FullTailsFileService; } });
|
|
46
|
-
Object.defineProperty(exports, "
|
|
47
|
-
Object.defineProperty(exports, "
|
|
48
|
-
Object.defineProperty(exports, "
|
|
45
|
+
Object.defineProperty(exports, "getTailsDirectoryPath", { enumerable: true, get: function () { return FullTailsFileService_1.getTailsDirectoryPath; } });
|
|
46
|
+
Object.defineProperty(exports, "deleteTailsFile", { enumerable: true, get: function () { return FullTailsFileService_1.deleteTailsFile; } });
|
|
47
|
+
Object.defineProperty(exports, "isValidTailsFileName", { enumerable: true, get: function () { return FullTailsFileService_1.isValidTailsFileName; } });
|
|
48
|
+
Object.defineProperty(exports, "migrateLegacyTailsFiles", { enumerable: true, get: function () { return FullTailsFileService_1.migrateLegacyTailsFiles; } });
|
|
49
49
|
// Utils
|
|
50
50
|
__exportStar(require("./utils"), exports);
|
|
51
51
|
__exportStar(require("./blockchain"), exports);
|
|
52
|
+
__exportStar(require("./vtFlow"), exports);
|
|
52
53
|
//# 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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,0CAAuB;AACvB,0CAAuB;AAEvB,SAAS;AACT,2CAAwB;AAExB,UAAU;AACV,+DAA6D;AAApD,oHAAA,gBAAgB,OAAA;AAGzB,gBAAgB;AAChB,mEAAiE;AAAxD,4HAAA,oBAAoB,OAAA;AAC7B,yDAAuD;AAA9C,kHAAA,eAAe,OAAA;AACxB,mDAAyD;AAAhD,oHAAA,oBAAoB,OAAA;AAE7B,aAAa;AACb,0EAA8F;AAArF,4HAAA,oBAAoB,OAAA;AAAE,4HAAA,oBAAoB,OAAA;AACnD,oFAA6G;AAApG,sIAAA,yBAAyB,OAAA;AAAE,sIAAA,yBAAyB,OAAA;AAC7D,sFAAoF;AAA3E,wIAAA,0BAA0B,OAAA;AAEnC,cAAc;AACd,2EAM2C;AALzC,4HAAA,oBAAoB,OAAA;AACpB,6HAAA,qBAAqB,OAAA;AACrB,uHAAA,eAAe,OAAA;AACf,4HAAA,oBAAoB,OAAA;AACpB,+HAAA,uBAAuB,OAAA;AAGzB,QAAQ;AACR,0CAAuB;AAEvB,+CAA4B;AAC5B,2CAAwB"}
|