@verana-labs/vs-agent-client 2.0.0-dev.7 → 2.0.0-dev.72
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 +60 -111
- package/build/ApiClient.d.ts +12 -39
- package/build/ApiClient.js +13 -40
- package/build/ApiClient.js.map +1 -1
- package/build/api/AgentApi.d.ts +9 -0
- package/build/api/AgentApi.js +19 -0
- package/build/api/AgentApi.js.map +1 -0
- package/build/api/AnoncredsApi.d.ts +15 -0
- package/build/api/AnoncredsApi.js +37 -0
- package/build/api/AnoncredsApi.js.map +1 -0
- package/build/api/AuthApi.d.ts +8 -0
- package/build/api/AuthApi.js +16 -0
- package/build/api/AuthApi.js.map +1 -0
- package/build/api/DidcommApi.d.ts +40 -0
- package/build/api/DidcommApi.js +112 -0
- package/build/api/DidcommApi.js.map +1 -0
- package/build/api/VtApi.d.ts +17 -0
- package/build/api/VtApi.js +51 -0
- package/build/api/VtApi.js.map +1 -0
- package/build/events.d.ts +7 -0
- package/build/events.js +51 -0
- package/build/events.js.map +1 -0
- package/build/http.d.ts +19 -0
- package/build/http.js +61 -0
- package/build/http.js.map +1 -0
- package/build/index.d.ts +7 -3
- package/build/index.js +7 -3
- package/build/index.js.map +1 -1
- package/build/types/agent.d.ts +10 -0
- package/build/types/agent.js +3 -0
- package/build/types/agent.js.map +1 -0
- package/build/types/anoncreds.d.ts +48 -0
- package/build/types/anoncreds.js +3 -0
- package/build/types/anoncreds.js.map +1 -0
- package/build/types/auth.d.ts +17 -0
- package/build/types/auth.js +3 -0
- package/build/types/auth.js.map +1 -0
- package/build/types/common.d.ts +33 -0
- package/build/types/common.js +3 -0
- package/build/types/common.js.map +1 -0
- package/build/types/didcomm.d.ts +246 -0
- package/build/types/didcomm.js +3 -0
- package/build/types/didcomm.js.map +1 -0
- package/build/types/events.d.ts +189 -0
- package/build/types/events.js +3 -0
- package/build/types/events.js.map +1 -0
- package/build/types/index.d.ts +7 -1
- package/build/types/index.js +7 -1
- package/build/types/index.js.map +1 -1
- package/build/types/vt.d.ts +116 -0
- package/build/types/vt.js +3 -0
- package/build/types/vt.js.map +1 -0
- package/package.json +3 -15
- package/build/handlers/ExpressEventHandler.d.ts +0 -71
- package/build/handlers/ExpressEventHandler.js +0 -102
- package/build/handlers/ExpressEventHandler.js.map +0 -1
- package/build/handlers/index.d.ts +0 -1
- package/build/handlers/index.js +0 -18
- package/build/handlers/index.js.map +0 -1
- package/build/services/CredentialTypeService.d.ts +0 -19
- package/build/services/CredentialTypeService.js +0 -66
- package/build/services/CredentialTypeService.js.map +0 -1
- package/build/services/InvitationService.d.ts +0 -16
- package/build/services/InvitationService.js +0 -56
- package/build/services/InvitationService.js.map +0 -1
- package/build/services/MessageService.d.ts +0 -18
- package/build/services/MessageService.js +0 -57
- package/build/services/MessageService.js.map +0 -1
- package/build/services/RevocationRegistryService.d.ts +0 -18
- package/build/services/RevocationRegistryService.js +0 -58
- package/build/services/RevocationRegistryService.js.map +0 -1
- package/build/services/TrustCredentialService.d.ts +0 -33
- package/build/services/TrustCredentialService.js +0 -75
- package/build/services/TrustCredentialService.js.map +0 -1
- package/build/services/index.d.ts +0 -5
- package/build/services/index.js +0 -22
- package/build/services/index.js.map +0 -1
- package/build/types/enums.d.ts +0 -3
- package/build/types/enums.js +0 -9
- package/build/types/enums.js.map +0 -1
- package/build/utils/HttpUtils.d.ts +0 -4
- package/build/utils/HttpUtils.js +0 -18
- package/build/utils/HttpUtils.js.map +0 -1
- package/build/utils/index.d.ts +0 -1
- package/build/utils/index.js +0 -18
- package/build/utils/index.js.map +0 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { CredentialState, DidExchangeState, ProofState, VtFlowState } from './common';
|
|
2
|
+
import { BasicMessageRecord, ConnectionRecord, CredentialExchangeRecord, MessageReactionAction, MessageState, PresentationRecord, ProfilePicture, SharedMediaItem } from './didcomm';
|
|
3
|
+
import { VtFlowRecord } from './vt';
|
|
4
|
+
export type ConnectionStateUpdatedData = ConnectionRecord & {
|
|
5
|
+
previousState: DidExchangeState | null;
|
|
6
|
+
};
|
|
7
|
+
export type PresentationStateUpdatedData = PresentationRecord & {
|
|
8
|
+
previousState: ProofState | null;
|
|
9
|
+
};
|
|
10
|
+
export type CredentialExchangeStateUpdatedData = CredentialExchangeRecord & {
|
|
11
|
+
previousState: CredentialState | null;
|
|
12
|
+
};
|
|
13
|
+
export type VtFlowStateUpdatedData = VtFlowRecord & {
|
|
14
|
+
previousState: VtFlowState | null;
|
|
15
|
+
};
|
|
16
|
+
export interface MessageReceiptsReceivedData {
|
|
17
|
+
connectionId: string;
|
|
18
|
+
receipts?: {
|
|
19
|
+
messageId: string;
|
|
20
|
+
state: MessageState;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
export interface MessageReactionsReceivedData {
|
|
25
|
+
connectionId: string;
|
|
26
|
+
reactions?: {
|
|
27
|
+
messageId: string;
|
|
28
|
+
emoji: string;
|
|
29
|
+
action: MessageReactionAction;
|
|
30
|
+
timestamp: string;
|
|
31
|
+
}[];
|
|
32
|
+
}
|
|
33
|
+
export interface ReceivedUserProfile {
|
|
34
|
+
displayName?: string;
|
|
35
|
+
displayPicture?: ProfilePicture | null | '';
|
|
36
|
+
displayIcon?: ProfilePicture | null | '';
|
|
37
|
+
description?: string;
|
|
38
|
+
preferredLanguage?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ProfileReceivedData {
|
|
41
|
+
connectionId: string;
|
|
42
|
+
threadId?: string;
|
|
43
|
+
profile: ReceivedUserProfile;
|
|
44
|
+
sendBackYours: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface RequestProfileReceivedData {
|
|
47
|
+
connectionId: string;
|
|
48
|
+
threadId: string;
|
|
49
|
+
query?: string[];
|
|
50
|
+
}
|
|
51
|
+
export interface ShareMediaReceivedData {
|
|
52
|
+
connectionId: string;
|
|
53
|
+
threadId?: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
items?: (SharedMediaItem & {
|
|
56
|
+
id: string;
|
|
57
|
+
})[];
|
|
58
|
+
}
|
|
59
|
+
export interface RequestMediaReceivedData {
|
|
60
|
+
connectionId: string;
|
|
61
|
+
threadId: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
itemIds: string[];
|
|
64
|
+
}
|
|
65
|
+
export interface CallOfferReceivedData {
|
|
66
|
+
connectionId: string;
|
|
67
|
+
threadId: string;
|
|
68
|
+
callType: string;
|
|
69
|
+
parameters: Record<string, unknown>;
|
|
70
|
+
description?: string;
|
|
71
|
+
offerStartTime?: string;
|
|
72
|
+
offerExpirationTime?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface CallAcceptReceivedData {
|
|
75
|
+
connectionId: string;
|
|
76
|
+
threadId: string;
|
|
77
|
+
parameters: Record<string, unknown>;
|
|
78
|
+
}
|
|
79
|
+
export interface CallThreadData {
|
|
80
|
+
connectionId: string;
|
|
81
|
+
threadId: string;
|
|
82
|
+
}
|
|
83
|
+
export interface MenuRequestReceivedData {
|
|
84
|
+
connectionId: string;
|
|
85
|
+
threadId: string;
|
|
86
|
+
}
|
|
87
|
+
export interface PerformReceivedData {
|
|
88
|
+
connectionId: string;
|
|
89
|
+
threadId: string;
|
|
90
|
+
name: string;
|
|
91
|
+
params?: Record<string, string>;
|
|
92
|
+
}
|
|
93
|
+
export interface AnswerReceivedData {
|
|
94
|
+
connectionId: string;
|
|
95
|
+
threadId: string;
|
|
96
|
+
response: string;
|
|
97
|
+
}
|
|
98
|
+
export interface MrzDataReceivedData {
|
|
99
|
+
connectionId: string;
|
|
100
|
+
threadId: string;
|
|
101
|
+
mrzData: {
|
|
102
|
+
raw: string | string[];
|
|
103
|
+
parsed: {
|
|
104
|
+
format?: string;
|
|
105
|
+
fields: Partial<Record<string, string | null>>;
|
|
106
|
+
valid: boolean;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export interface EmrtdDataReceivedData {
|
|
111
|
+
connectionId: string;
|
|
112
|
+
threadId: string;
|
|
113
|
+
dataGroups: {
|
|
114
|
+
raw: Record<string, string>;
|
|
115
|
+
parsed: {
|
|
116
|
+
fields?: Record<string, unknown>;
|
|
117
|
+
valid: boolean;
|
|
118
|
+
};
|
|
119
|
+
verification?: {
|
|
120
|
+
authenticity: boolean;
|
|
121
|
+
integrity: boolean;
|
|
122
|
+
details?: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export type MrtdProblemReportReason = 'e.p.mrz-refused' | 'e.p.emrtd-refused' | 'e.p.mrz-timeout' | 'e.p.emrtd-timeout';
|
|
127
|
+
export interface MrtdProblemReportReceivedData {
|
|
128
|
+
connectionId: string;
|
|
129
|
+
threadId: string;
|
|
130
|
+
reason: MrtdProblemReportReason;
|
|
131
|
+
}
|
|
132
|
+
export interface VprNotificationPayload {
|
|
133
|
+
module: string;
|
|
134
|
+
action: string;
|
|
135
|
+
messageType: string;
|
|
136
|
+
txIndex: number;
|
|
137
|
+
messageIndex: number;
|
|
138
|
+
sender: string;
|
|
139
|
+
relatedDids: string[];
|
|
140
|
+
entityType?: string;
|
|
141
|
+
entityId?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface VprNotificationData {
|
|
144
|
+
timestamp: string;
|
|
145
|
+
eventType: string;
|
|
146
|
+
did: string;
|
|
147
|
+
blockHeight: number;
|
|
148
|
+
txHash: string;
|
|
149
|
+
payload: VprNotificationPayload;
|
|
150
|
+
changes?: Record<string, unknown>;
|
|
151
|
+
}
|
|
152
|
+
export interface EventDataMap {
|
|
153
|
+
'didcomm.connections.state-updated': ConnectionStateUpdatedData;
|
|
154
|
+
'didcomm.basic-messages.message-received': BasicMessageRecord;
|
|
155
|
+
'didcomm.receipts.message-receipts-received': MessageReceiptsReceivedData;
|
|
156
|
+
'didcomm.reactions.message-reactions-received': MessageReactionsReceivedData;
|
|
157
|
+
'didcomm.user-profile.profile-received': ProfileReceivedData;
|
|
158
|
+
'didcomm.user-profile.request-profile-received': RequestProfileReceivedData;
|
|
159
|
+
'didcomm.media-sharing.share-media-received': ShareMediaReceivedData;
|
|
160
|
+
'didcomm.media-sharing.request-media-received': RequestMediaReceivedData;
|
|
161
|
+
'didcomm.calls.call-offer-received': CallOfferReceivedData;
|
|
162
|
+
'didcomm.calls.call-accept-received': CallAcceptReceivedData;
|
|
163
|
+
'didcomm.calls.call-reject-received': CallThreadData;
|
|
164
|
+
'didcomm.calls.call-end-received': CallThreadData;
|
|
165
|
+
'didcomm.action-menu.menu-request-received': MenuRequestReceivedData;
|
|
166
|
+
'didcomm.action-menu.perform-received': PerformReceivedData;
|
|
167
|
+
'didcomm.question-answer.answer-received': AnswerReceivedData;
|
|
168
|
+
'didcomm.mrtd.mrz-data-received': MrzDataReceivedData;
|
|
169
|
+
'didcomm.mrtd.emrtd-data-received': EmrtdDataReceivedData;
|
|
170
|
+
'didcomm.mrtd.problem-report-received': MrtdProblemReportReceivedData;
|
|
171
|
+
'didcomm.presentations.state-updated': PresentationStateUpdatedData;
|
|
172
|
+
'didcomm.credential-exchanges.state-updated': CredentialExchangeStateUpdatedData;
|
|
173
|
+
'vt.flows.state-updated': VtFlowStateUpdatedData;
|
|
174
|
+
'vpr.notification': VprNotificationData;
|
|
175
|
+
}
|
|
176
|
+
export type EventType = keyof EventDataMap;
|
|
177
|
+
export type EventEnvelope<T extends EventType = EventType> = T extends EventType ? {
|
|
178
|
+
id: string;
|
|
179
|
+
type: T;
|
|
180
|
+
timestamp: string;
|
|
181
|
+
data: EventDataMap[T];
|
|
182
|
+
} : never;
|
|
183
|
+
export interface UnknownEventEnvelope {
|
|
184
|
+
id: string;
|
|
185
|
+
type: string;
|
|
186
|
+
timestamp: string;
|
|
187
|
+
data: unknown;
|
|
188
|
+
}
|
|
189
|
+
export type EventHandlerFn<T extends EventType> = (data: EventDataMap[T], envelope: EventEnvelope<T>) => void | Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":""}
|
package/build/types/index.d.ts
CHANGED
package/build/types/index.js
CHANGED
|
@@ -14,5 +14,11 @@ 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
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./agent"), exports);
|
|
18
|
+
__exportStar(require("./anoncreds"), exports);
|
|
19
|
+
__exportStar(require("./auth"), exports);
|
|
20
|
+
__exportStar(require("./common"), exports);
|
|
21
|
+
__exportStar(require("./didcomm"), exports);
|
|
22
|
+
__exportStar(require("./events"), exports);
|
|
23
|
+
__exportStar(require("./vt"), exports);
|
|
18
24
|
//# sourceMappingURL=index.js.map
|
package/build/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,8CAA2B;AAC3B,yCAAsB;AACtB,2CAAwB;AACxB,4CAAyB;AACzB,2CAAwB;AACxB,uCAAoB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { PaginationQuery, VtConnectionState, VtFlowRole, VtFlowState, VtFlowVariant } from './common';
|
|
2
|
+
export type VtFlowPendingAction = 'APPLICANT' | 'VALIDATOR' | 'AGENT' | 'CHAIN' | 'NONE';
|
|
3
|
+
export interface VtFlowOobLink {
|
|
4
|
+
url: string;
|
|
5
|
+
description: string;
|
|
6
|
+
expiresAt?: string;
|
|
7
|
+
at: string;
|
|
8
|
+
}
|
|
9
|
+
export interface VtFlowMessage {
|
|
10
|
+
type: 'oob-link' | 'validating' | 'problem-report';
|
|
11
|
+
text?: string;
|
|
12
|
+
at: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface VtFlowTx {
|
|
16
|
+
hash?: string;
|
|
17
|
+
submittedAt?: string;
|
|
18
|
+
height?: number;
|
|
19
|
+
status: 'SUBMITTED' | 'SUCCEEDED' | 'FAILED';
|
|
20
|
+
reason?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface VtFlowValidation {
|
|
24
|
+
decidedAt: string;
|
|
25
|
+
submission: 'AGENT' | 'OPERATOR';
|
|
26
|
+
validationFees?: number;
|
|
27
|
+
issuanceFees?: number;
|
|
28
|
+
verificationFees?: number;
|
|
29
|
+
issuanceFeeDiscount?: number;
|
|
30
|
+
verificationFeeDiscount?: number;
|
|
31
|
+
effectiveUntil?: string;
|
|
32
|
+
opSummaryDigest?: string;
|
|
33
|
+
tx?: VtFlowTx;
|
|
34
|
+
}
|
|
35
|
+
export interface VtFlowRecord {
|
|
36
|
+
id: string;
|
|
37
|
+
participantSessionId: string;
|
|
38
|
+
flowState: VtFlowState;
|
|
39
|
+
connectionState: VtConnectionState;
|
|
40
|
+
role: VtFlowRole;
|
|
41
|
+
variant: VtFlowVariant;
|
|
42
|
+
threadId: string;
|
|
43
|
+
connectionId: string;
|
|
44
|
+
agentParticipantId: string;
|
|
45
|
+
walletAgentParticipantId: string;
|
|
46
|
+
peerDid?: string;
|
|
47
|
+
applicantParticipantId?: string;
|
|
48
|
+
validatorParticipantId?: string;
|
|
49
|
+
schemaId?: string;
|
|
50
|
+
claims?: Record<string, unknown>;
|
|
51
|
+
proofs?: unknown[];
|
|
52
|
+
oobLink?: VtFlowOobLink;
|
|
53
|
+
messages: VtFlowMessage[];
|
|
54
|
+
pendingAction: VtFlowPendingAction;
|
|
55
|
+
validation?: VtFlowValidation;
|
|
56
|
+
issuance?: {
|
|
57
|
+
tx?: VtFlowTx;
|
|
58
|
+
};
|
|
59
|
+
credentialExchangeRecordId?: string;
|
|
60
|
+
credentialId?: string;
|
|
61
|
+
credentialDigest?: string;
|
|
62
|
+
subprotocolThid?: string;
|
|
63
|
+
errorMessage?: string;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
lastEventAt: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ListFlowsQuery extends PaginationQuery {
|
|
69
|
+
role?: VtFlowRole;
|
|
70
|
+
connectionState?: VtConnectionState;
|
|
71
|
+
flowState?: VtFlowState;
|
|
72
|
+
peerDid?: string;
|
|
73
|
+
applicantParticipantId?: string;
|
|
74
|
+
validatorParticipantId?: string;
|
|
75
|
+
schemaId?: string;
|
|
76
|
+
participantSessionId?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface EditClaimsBody {
|
|
79
|
+
claims: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
export interface SendOobLinkBody {
|
|
82
|
+
url: string;
|
|
83
|
+
description: string;
|
|
84
|
+
expiresAt?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface StartValidationBody {
|
|
87
|
+
comment?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface ValidateFlowBody {
|
|
90
|
+
validationFees?: number;
|
|
91
|
+
issuanceFees?: number;
|
|
92
|
+
verificationFees?: number;
|
|
93
|
+
issuanceFeeDiscount?: number;
|
|
94
|
+
verificationFeeDiscount?: number;
|
|
95
|
+
effectiveUntil?: string;
|
|
96
|
+
opSummaryDigest?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface RejectFlowBody {
|
|
99
|
+
code?: 'vt-flow.validation-refused' | 'vt-flow.session-terminated' | 'vt-flow.oob-expired';
|
|
100
|
+
description: string;
|
|
101
|
+
}
|
|
102
|
+
export type ServiceEndpointValue = string | Record<string, unknown> | Array<string | Record<string, unknown>>;
|
|
103
|
+
export interface ServiceEndpoint {
|
|
104
|
+
id: string;
|
|
105
|
+
type: string;
|
|
106
|
+
serviceEndpoint: ServiceEndpointValue;
|
|
107
|
+
}
|
|
108
|
+
export interface AddServiceEndpointBody {
|
|
109
|
+
type: string;
|
|
110
|
+
serviceEndpoint: ServiceEndpointValue;
|
|
111
|
+
id?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface UpdateServiceEndpointBody {
|
|
114
|
+
type?: string;
|
|
115
|
+
serviceEndpoint?: ServiceEndpointValue;
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vt.js","sourceRoot":"","sources":["../../src/types/vt.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@verana-labs/vs-agent-client",
|
|
3
3
|
"main": "build/index",
|
|
4
4
|
"types": "build/index",
|
|
5
|
-
"version": "2.0.0-dev.
|
|
5
|
+
"version": "2.0.0-dev.72",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/verana-labs/vs-agent"
|
|
@@ -14,20 +14,8 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"class-validator": "0.14.1",
|
|
20
|
-
"express": "^4.18.1",
|
|
21
|
-
"tslog": "^4.8.2",
|
|
22
|
-
"@verana-labs/vs-agent-model": "2.0.0-dev.7"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@nestjs/common": "^10.0.0",
|
|
26
|
-
"@types/express": "^4.17.13",
|
|
27
|
-
"ts-node-dev": "^2.0.0"
|
|
28
|
-
},
|
|
29
|
-
"peerDependencies": {
|
|
30
|
-
"@credo-ts/core": "0.7.1-pr-2704-20260630143332"
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18"
|
|
31
19
|
},
|
|
32
20
|
"scripts": {
|
|
33
21
|
"build": "pnpm run clean && pnpm run compile",
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Express, Request, Response } from 'express';
|
|
2
|
-
type Handler = (req: Request, res: Response) => Promise<void>;
|
|
3
|
-
/**
|
|
4
|
-
* `ExpressEventHandler` class for defining express event handling methods.
|
|
5
|
-
* Extend this class in other projects to implement specific endpoint handlers
|
|
6
|
-
* for different types of events. Each method is mapped to an HTTP POST endpoint
|
|
7
|
-
* with a specified route on express structure
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* Extend `EventHandler` in your subclass and implement each method to
|
|
11
|
-
* handle incoming events as per the business requirements.
|
|
12
|
-
*/
|
|
13
|
-
export declare class ExpressEventHandler {
|
|
14
|
-
private app;
|
|
15
|
-
constructor(app: Express);
|
|
16
|
-
/**
|
|
17
|
-
* Handles the event for updating the state of a connection.
|
|
18
|
-
*
|
|
19
|
-
* Endpoint: POST `/connection-state-updated`
|
|
20
|
-
* Expected Payload: an `Event` object containing the connection state update details.
|
|
21
|
-
*
|
|
22
|
-
* @param {Event} event - The event object containing the connection state update details.
|
|
23
|
-
* @throws {Error} Throws an error if not implemented by subclass.
|
|
24
|
-
* @example
|
|
25
|
-
* const event = {
|
|
26
|
-
* type: "connection-state-updated",
|
|
27
|
-
* connectionId: "e2037401-aa91-4302-8927-ac07f06d9d60",
|
|
28
|
-
* invitationId: "2232eb0f-643b-4a00-b014-3d1d85b8f4de",
|
|
29
|
-
* state: "completed",
|
|
30
|
-
* }
|
|
31
|
-
*/
|
|
32
|
-
connectionState(handler: Handler): void;
|
|
33
|
-
/**
|
|
34
|
-
* Handles the event for updating the state of a message.
|
|
35
|
-
*
|
|
36
|
-
* Endpoint: POST `/message-state-updated`
|
|
37
|
-
* Expected Payload: an `Event` object containing the new message state details.
|
|
38
|
-
*
|
|
39
|
-
* @param {Event} event - The event object containing the message state update details.
|
|
40
|
-
* @throws {Error} Throws an error if not implemented by subclass.
|
|
41
|
-
* @example
|
|
42
|
-
* const event = {
|
|
43
|
-
* type: "message-state-updated",
|
|
44
|
-
* messageId: "12345",
|
|
45
|
-
* state: "delivered",
|
|
46
|
-
* timestamp: "2023-10-01T12:00:00Z",
|
|
47
|
-
* connectionId: "conn123"
|
|
48
|
-
* }
|
|
49
|
-
*/
|
|
50
|
-
messageStateUpdated(handler: Handler): void;
|
|
51
|
-
/**
|
|
52
|
-
* Handles the event when a new message is received.
|
|
53
|
-
*
|
|
54
|
-
* Endpoint: POST `/message-received`
|
|
55
|
-
* Expected Payload: an `Event` object containing the message details.
|
|
56
|
-
*
|
|
57
|
-
* @param {Event} event - The event object containing the message details.
|
|
58
|
-
* @throws {Error} Throws an error if not implemented by subclass.
|
|
59
|
-
* @example
|
|
60
|
-
* const event = {
|
|
61
|
-
* type: "message-received",
|
|
62
|
-
* message: {
|
|
63
|
-
* type: text,
|
|
64
|
-
* content: "test"
|
|
65
|
-
* },
|
|
66
|
-
* timestamp: "2023-10-01T12:00:00Z",
|
|
67
|
-
* }
|
|
68
|
-
*/
|
|
69
|
-
messageReceived(handler: Handler): void;
|
|
70
|
-
}
|
|
71
|
-
export {};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExpressEventHandler = void 0;
|
|
4
|
-
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
5
|
-
/**
|
|
6
|
-
* `ExpressEventHandler` class for defining express event handling methods.
|
|
7
|
-
* Extend this class in other projects to implement specific endpoint handlers
|
|
8
|
-
* for different types of events. Each method is mapped to an HTTP POST endpoint
|
|
9
|
-
* with a specified route on express structure
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* Extend `EventHandler` in your subclass and implement each method to
|
|
13
|
-
* handle incoming events as per the business requirements.
|
|
14
|
-
*/
|
|
15
|
-
class ExpressEventHandler {
|
|
16
|
-
constructor(app) {
|
|
17
|
-
this.app = app;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Handles the event for updating the state of a connection.
|
|
21
|
-
*
|
|
22
|
-
* Endpoint: POST `/connection-state-updated`
|
|
23
|
-
* Expected Payload: an `Event` object containing the connection state update details.
|
|
24
|
-
*
|
|
25
|
-
* @param {Event} event - The event object containing the connection state update details.
|
|
26
|
-
* @throws {Error} Throws an error if not implemented by subclass.
|
|
27
|
-
* @example
|
|
28
|
-
* const event = {
|
|
29
|
-
* type: "connection-state-updated",
|
|
30
|
-
* connectionId: "e2037401-aa91-4302-8927-ac07f06d9d60",
|
|
31
|
-
* invitationId: "2232eb0f-643b-4a00-b014-3d1d85b8f4de",
|
|
32
|
-
* state: "completed",
|
|
33
|
-
* }
|
|
34
|
-
*/
|
|
35
|
-
connectionState(handler) {
|
|
36
|
-
this.app.post(`/${vs_agent_model_1.EventType.ConnectionStateUpdated}`, async (req, res) => {
|
|
37
|
-
try {
|
|
38
|
-
await handler(req, res);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
res.status(500).json({ message: 'Internal Server Error', error });
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Handles the event for updating the state of a message.
|
|
47
|
-
*
|
|
48
|
-
* Endpoint: POST `/message-state-updated`
|
|
49
|
-
* Expected Payload: an `Event` object containing the new message state details.
|
|
50
|
-
*
|
|
51
|
-
* @param {Event} event - The event object containing the message state update details.
|
|
52
|
-
* @throws {Error} Throws an error if not implemented by subclass.
|
|
53
|
-
* @example
|
|
54
|
-
* const event = {
|
|
55
|
-
* type: "message-state-updated",
|
|
56
|
-
* messageId: "12345",
|
|
57
|
-
* state: "delivered",
|
|
58
|
-
* timestamp: "2023-10-01T12:00:00Z",
|
|
59
|
-
* connectionId: "conn123"
|
|
60
|
-
* }
|
|
61
|
-
*/
|
|
62
|
-
messageStateUpdated(handler) {
|
|
63
|
-
this.app.post(`/${vs_agent_model_1.EventType.MessageStateUpdated}`, async (req, res) => {
|
|
64
|
-
try {
|
|
65
|
-
await handler(req, res);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
res.status(500).json({ message: 'Internal Server Error', error });
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Handles the event when a new message is received.
|
|
74
|
-
*
|
|
75
|
-
* Endpoint: POST `/message-received`
|
|
76
|
-
* Expected Payload: an `Event` object containing the message details.
|
|
77
|
-
*
|
|
78
|
-
* @param {Event} event - The event object containing the message details.
|
|
79
|
-
* @throws {Error} Throws an error if not implemented by subclass.
|
|
80
|
-
* @example
|
|
81
|
-
* const event = {
|
|
82
|
-
* type: "message-received",
|
|
83
|
-
* message: {
|
|
84
|
-
* type: text,
|
|
85
|
-
* content: "test"
|
|
86
|
-
* },
|
|
87
|
-
* timestamp: "2023-10-01T12:00:00Z",
|
|
88
|
-
* }
|
|
89
|
-
*/
|
|
90
|
-
messageReceived(handler) {
|
|
91
|
-
this.app.post(`/${vs_agent_model_1.EventType.MessageReceived}`, async (req, res) => {
|
|
92
|
-
try {
|
|
93
|
-
await handler(req, res);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
res.status(500).json({ message: 'Internal Server Error', error });
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.ExpressEventHandler = ExpressEventHandler;
|
|
102
|
-
//# sourceMappingURL=ExpressEventHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressEventHandler.js","sourceRoot":"","sources":["../../src/handlers/ExpressEventHandler.ts"],"names":[],"mappings":";;;AAAA,gEAAuD;AAKvD;;;;;;;;;GASG;AACH,MAAa,mBAAmB;IAG9B,YAAY,GAAY;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,eAAe,CAAC,OAAgB;QACrC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,0BAAS,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;YAC1F,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;YACzB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,CAAA;YACnE,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACI,mBAAmB,CAAC,OAAgB;QACzC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,0BAAS,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;YACvF,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;YACzB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,CAAA;YACnE,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,eAAe,CAAC,OAAgB;QACrC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,0BAAS,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;YACnF,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;YACzB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,CAAA;YACnE,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAvFD,kDAuFC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ExpressEventHandler';
|
package/build/handlers/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = 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("./ExpressEventHandler"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { CredentialTypeInfo, CredentialTypeResult, ImportCredentialTypeOptions } from '@verana-labs/vs-agent-model';
|
|
2
|
-
import { ApiVersion } from '../types/enums';
|
|
3
|
-
/**
|
|
4
|
-
* `CredentialTypeService` class for managing credential types and interacting with
|
|
5
|
-
* the available endpoints related to credential types in the Agent Service.
|
|
6
|
-
*
|
|
7
|
-
* This class provides methods for querying, creating, and managing credential types.
|
|
8
|
-
* For a list of available endpoints and functionality, refer to the methods within this class.
|
|
9
|
-
*/
|
|
10
|
-
export declare class CredentialTypeService {
|
|
11
|
-
private baseURL;
|
|
12
|
-
private version;
|
|
13
|
-
private url;
|
|
14
|
-
constructor(baseURL: string, version: ApiVersion);
|
|
15
|
-
import(importData: ImportCredentialTypeOptions): Promise<CredentialTypeInfo>;
|
|
16
|
-
export(credentialTypeId: string): Promise<unknown>;
|
|
17
|
-
create(credentialType: CredentialTypeInfo): Promise<CredentialTypeInfo>;
|
|
18
|
-
getAll(): Promise<CredentialTypeResult[]>;
|
|
19
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// src/services/CredentialTypeService.ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.CredentialTypeService = void 0;
|
|
5
|
-
const tslog_1 = require("tslog");
|
|
6
|
-
const logger = new tslog_1.Logger({
|
|
7
|
-
name: 'CredentialTypeService',
|
|
8
|
-
type: 'pretty',
|
|
9
|
-
prettyLogTemplate: '{{logLevelName}} [{{name}}]: ',
|
|
10
|
-
});
|
|
11
|
-
/**
|
|
12
|
-
* `CredentialTypeService` class for managing credential types and interacting with
|
|
13
|
-
* the available endpoints related to credential types in the Agent Service.
|
|
14
|
-
*
|
|
15
|
-
* This class provides methods for querying, creating, and managing credential types.
|
|
16
|
-
* For a list of available endpoints and functionality, refer to the methods within this class.
|
|
17
|
-
*/
|
|
18
|
-
class CredentialTypeService {
|
|
19
|
-
constructor(baseURL, version) {
|
|
20
|
-
this.baseURL = baseURL;
|
|
21
|
-
this.version = version;
|
|
22
|
-
this.url = `${this.baseURL.replace(/\/$/, '')}/${this.version}/credential-types`;
|
|
23
|
-
}
|
|
24
|
-
async import(importData) {
|
|
25
|
-
logger.info(`Importing credential type ${importData.id}`);
|
|
26
|
-
const response = await fetch(`${this.url}/import`, {
|
|
27
|
-
method: 'POST',
|
|
28
|
-
body: JSON.stringify(importData),
|
|
29
|
-
headers: { accept: 'application/json', 'Content-Type': 'application/json' },
|
|
30
|
-
});
|
|
31
|
-
if (!response.ok)
|
|
32
|
-
throw new Error(`Cannot import credential type: status ${response.status}`);
|
|
33
|
-
return (await response.json());
|
|
34
|
-
}
|
|
35
|
-
async export(credentialTypeId) {
|
|
36
|
-
logger.info(`Exporting credential type ${credentialTypeId}`);
|
|
37
|
-
const response = await fetch(`${this.url}/export/${encodeURIComponent(credentialTypeId)}`, {
|
|
38
|
-
method: 'GET',
|
|
39
|
-
headers: { accept: 'application/json' },
|
|
40
|
-
});
|
|
41
|
-
if (!response.ok)
|
|
42
|
-
throw new Error(`Cannot export credential type: status ${response.status}}`);
|
|
43
|
-
return await response.json();
|
|
44
|
-
}
|
|
45
|
-
async create(credentialType) {
|
|
46
|
-
const response = await fetch(`${this.url}`, {
|
|
47
|
-
method: 'POST',
|
|
48
|
-
headers: { 'Content-Type': 'application/json' },
|
|
49
|
-
body: JSON.stringify(credentialType),
|
|
50
|
-
});
|
|
51
|
-
return (await response.json());
|
|
52
|
-
}
|
|
53
|
-
async getAll() {
|
|
54
|
-
const response = await fetch(this.url, {
|
|
55
|
-
method: 'GET',
|
|
56
|
-
headers: { accept: 'application/json', 'Content-Type': 'application/json' },
|
|
57
|
-
});
|
|
58
|
-
const types = await response.json();
|
|
59
|
-
if (!Array.isArray(types)) {
|
|
60
|
-
throw new Error('Invalid response from VS Agent');
|
|
61
|
-
}
|
|
62
|
-
return types.map(value => value);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.CredentialTypeService = CredentialTypeService;
|
|
66
|
-
//# sourceMappingURL=CredentialTypeService.js.map
|