@ayni.org/credo-ts-didcomm-confirm 0.0.0-stage → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # @ayni.org/credo-ts-didcomm-confirm
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Credo-TS module for the confirm/1.0 DIDComm protocol (Ayni Flow Profile 1.0 §6.6): a yes-or-no with a code the service also shows elsewhere.
4
+
5
+ Part of [credo-ts-ayni-flow](../../README.md); the profile is
6
+ [`v4/ayni-flow-profile/profile.md`](https://github.com/2060-io/ayni-spec/blob/main/v4/ayni-flow-profile/profile.md)
7
+ in `2060-io/ayni-spec`.
8
+
9
+ ```sh
10
+ pnpm add @ayni.org/credo-ts-didcomm-confirm
11
+ ```
12
+
13
+ Peer dependencies: `@credo-ts/core` and `@credo-ts/didcomm` on the 0.8.0 PR 2704 snapshot line.
@@ -0,0 +1,283 @@
1
+ import { AgentContext, BaseEvent, BaseRecord, DependencyManager, EventEmitter, Logger, Module, Query, QueryOptions, RecordTags, Repository, StorageService, TagsBase } from "@credo-ts/core";
2
+ import * as _credo_ts_didcomm0 from "@credo-ts/didcomm";
3
+ import { DidCommConnectionRecord, DidCommConnectionService, DidCommInboundMessageContext, DidCommMessage, DidCommMessageHandler, DidCommMessageHandlerInboundMessage, DidCommMessageSender } from "@credo-ts/didcomm";
4
+
5
+ //#region src/fields.d.ts
6
+ declare const ATTESTATION_METHODS: readonly ["biometric", "passcode", "none"];
7
+ type AttestationMethod = (typeof ATTESTATION_METHODS)[number];
8
+ /** The `request` body of confirm/1.0 (profile §6.6, FLOW-CONFIRM-001): a yes-or-no with a code the service also shows elsewhere. */
9
+ interface ConfirmRequest {
10
+ text: string;
11
+ code: string;
12
+ /** `true` asks for a device-authenticated answer. */
13
+ attested: boolean;
14
+ }
15
+ /** How the person authenticated on the device; `none` is allowed only when `attested` was false. */
16
+ interface Attestation {
17
+ method: AttestationMethod;
18
+ /** ISO 8601 */
19
+ at: string;
20
+ }
21
+ /** The `response` body of confirm/1.0. */
22
+ interface ConfirmResponse {
23
+ confirmed: boolean;
24
+ attestation: Attestation;
25
+ }
26
+ declare class AttestationModel {
27
+ constructor(options?: Attestation);
28
+ method: AttestationMethod;
29
+ at: Date;
30
+ }
31
+ //#endregion
32
+ //#region src/types.d.ts
33
+ /** The protocol roles disclosed through discover-features (profile §3). */
34
+ declare enum ConfirmRole {
35
+ Requester = "requester",
36
+ Confirmer = "confirmer",
37
+ }
38
+ declare enum ConfirmState {
39
+ RequestSent = "request-sent",
40
+ RequestReceived = "request-received",
41
+ ResponseSent = "response-sent",
42
+ ResponseReceived = "response-received",
43
+ Failed = "failed",
44
+ }
45
+ declare enum ConfirmEventTypes {
46
+ ConfirmStateChanged = "ConfirmStateChanged",
47
+ }
48
+ /** Emitted on every state change of a `ConfirmRecord`; `previousState` is null when the record is created. */
49
+ interface ConfirmStateChangedEvent extends BaseEvent {
50
+ type: typeof ConfirmEventTypes.ConfirmStateChanged;
51
+ payload: {
52
+ record: ConfirmRecord;
53
+ previousState: ConfirmState | null;
54
+ };
55
+ }
56
+ //#endregion
57
+ //#region src/repository/ConfirmRecord.d.ts
58
+ type DefaultConfirmTags = {
59
+ /** The `@id` of the `request`, the thread id of the exchange. */
60
+ threadId: string;
61
+ /** The flow id (`~thread.pthid`) when the exchange runs inside an ayni-flow. */
62
+ parentThreadId?: string;
63
+ connectionId: string;
64
+ role: ConfirmRole;
65
+ state: ConfirmState;
66
+ };
67
+ type CustomConfirmTags = TagsBase;
68
+ type ConfirmTags = RecordTags<ConfirmRecord>;
69
+ interface ConfirmStorageProps {
70
+ id?: string;
71
+ createdAt?: Date;
72
+ threadId: string;
73
+ parentThreadId?: string;
74
+ connectionId: string;
75
+ role: ConfirmRole;
76
+ state: ConfirmState;
77
+ request: ConfirmRequest;
78
+ response?: ConfirmResponse;
79
+ errorCode?: string;
80
+ errorDescription?: string;
81
+ tags?: CustomConfirmTags;
82
+ }
83
+ /** One `https://didcomm.org/confirm/1.0` exchange, written on both sides. */
84
+ declare class ConfirmRecord extends BaseRecord<DefaultConfirmTags, CustomConfirmTags> {
85
+ static readonly type = "ConfirmRecord";
86
+ readonly type = "ConfirmRecord";
87
+ threadId: string;
88
+ parentThreadId?: string;
89
+ connectionId: string;
90
+ role: ConfirmRole;
91
+ state: ConfirmState;
92
+ /** The `request` as sent or received. */
93
+ request: ConfirmRequest;
94
+ /** The `response` as sent or received. */
95
+ response?: ConfirmResponse;
96
+ /** Set with state `failed`: why the exchange failed (`malformed` when the peer's message broke a rule of the profile). */
97
+ errorCode?: string;
98
+ errorDescription?: string;
99
+ constructor(props: ConfirmStorageProps);
100
+ getTags(): DefaultConfirmTags & CustomConfirmTags;
101
+ /** The flow id, when the exchange runs inside an ayni-flow. */
102
+ get flowId(): string | undefined;
103
+ assertState(expected: ConfirmState | ConfirmState[]): void;
104
+ assertRole(expected: ConfirmRole): void;
105
+ }
106
+ //#endregion
107
+ //#region src/repository/ConfirmRepository.d.ts
108
+ declare class ConfirmRepository extends Repository<ConfirmRecord> {
109
+ constructor(storageService: StorageService<ConfirmRecord>, eventEmitter: EventEmitter);
110
+ /** The record of a `request` id. */
111
+ findByThreadId(agentContext: AgentContext, threadId: string): Promise<ConfirmRecord | null>;
112
+ /** The exchanges that ran inside one ayni-flow. */
113
+ findByParentThreadId(agentContext: AgentContext, parentThreadId: string): Promise<ConfirmRecord[]>;
114
+ findByConnectionId(agentContext: AgentContext, connectionId: string): Promise<ConfirmRecord[]>;
115
+ }
116
+ //#endregion
117
+ //#region src/messages/ConfirmProtocol.d.ts
118
+ /** PIURI of the protocol, Ayni Flow Profile 1.0 §6.6. */
119
+ declare const CONFIRM_PROTOCOL_URI = "https://didcomm.org/confirm/1.0";
120
+ declare const CONFIRM_REQUEST_TYPE = "https://didcomm.org/confirm/1.0/request";
121
+ declare const CONFIRM_RESPONSE_TYPE = "https://didcomm.org/confirm/1.0/response";
122
+ //#endregion
123
+ //#region src/messages/ConfirmRequestMessage.d.ts
124
+ interface ConfirmRequestMessageOptions extends ConfirmRequest {
125
+ id?: string;
126
+ /** The flow id when the request runs inside an ayni-flow (`~thread.pthid`). */
127
+ parentThreadId?: string;
128
+ }
129
+ /** `confirm/1.0/request` (profile §6.6). */
130
+ declare class ConfirmRequestMessage extends DidCommMessage {
131
+ constructor(options: ConfirmRequestMessageOptions);
132
+ static readonly type: _credo_ts_didcomm0.ParsedMessageType;
133
+ readonly type: string;
134
+ text: string;
135
+ code: string;
136
+ attested: boolean;
137
+ toRequest(): ConfirmRequest;
138
+ }
139
+ //#endregion
140
+ //#region src/messages/ConfirmResponseMessage.d.ts
141
+ interface ConfirmResponseMessageOptions extends ConfirmResponse {
142
+ id?: string;
143
+ /** The `@id` of the request being answered (`~thread.thid`). */
144
+ threadId: string;
145
+ parentThreadId?: string;
146
+ }
147
+ /** `confirm/1.0/response` (profile §6.6). */
148
+ declare class ConfirmResponseMessage extends DidCommMessage {
149
+ constructor(options: ConfirmResponseMessageOptions);
150
+ static readonly type: _credo_ts_didcomm0.ParsedMessageType;
151
+ readonly type: string;
152
+ confirmed: boolean;
153
+ attestation: AttestationModel;
154
+ toResponse(): ConfirmResponse;
155
+ }
156
+ //#endregion
157
+ //#region src/services/ConfirmService.d.ts
158
+ interface CreateConfirmRequestOptions {
159
+ connection: DidCommConnectionRecord;
160
+ /** The flow id when the exchange runs inside an ayni-flow (`~thread.pthid`). */
161
+ parentThreadId?: string;
162
+ request: ConfirmRequest;
163
+ }
164
+ /** State machine of one `https://didcomm.org/confirm/1.0` exchange; builds the wire messages, never sends them (sending is `ConfirmApi`). */
165
+ declare class ConfirmService {
166
+ private readonly repository;
167
+ private readonly eventEmitter;
168
+ private readonly logger;
169
+ constructor(repository: ConfirmRepository, eventEmitter: EventEmitter, logger: Logger);
170
+ /** Builds a `request` after checking it against the profile and records it sent. */
171
+ createRequest(agentContext: AgentContext, options: CreateConfirmRequestOptions): Promise<{
172
+ message: ConfirmRequestMessage;
173
+ record: ConfirmRecord;
174
+ }>;
175
+ /** Receives a `request`; a replay is ignored. A request that breaks a rule of the profile is recorded `failed` (`malformed`). */
176
+ processRequest(messageContext: DidCommInboundMessageContext<ConfirmRequestMessage>): Promise<ConfirmRecord | null>;
177
+ /** Builds the `response` of a received request after checking it against the profile, and records it sent. */
178
+ createResponse(agentContext: AgentContext, record: ConfirmRecord, response: ConfirmResponse): Promise<{
179
+ message: ConfirmResponseMessage;
180
+ record: ConfirmRecord;
181
+ }>;
182
+ /**
183
+ * Receives the `response` of a request we sent. A response that breaks a rule of the profile (for example an
184
+ * attestation `none` on an attested request) fails the exchange with `errorCode` `malformed`; the host sends the flow's
185
+ * problem report.
186
+ */
187
+ processResponse(messageContext: DidCommInboundMessageContext<ConfirmResponseMessage>): Promise<ConfirmRecord | null>;
188
+ /** Records a failure decided by the host (for example the person declined, or the flow was refused). */
189
+ fail(agentContext: AgentContext, record: ConfirmRecord, code: string, description?: string): Promise<ConfirmRecord>;
190
+ getById(agentContext: AgentContext, id: string): Promise<ConfirmRecord>;
191
+ findById(agentContext: AgentContext, id: string): Promise<ConfirmRecord | null>;
192
+ getByThreadId(agentContext: AgentContext, threadId: string): Promise<ConfirmRecord>;
193
+ findByThreadId(agentContext: AgentContext, threadId: string): Promise<ConfirmRecord | null>;
194
+ findByParentThreadId(agentContext: AgentContext, parentThreadId: string): Promise<ConfirmRecord[]>;
195
+ findAllByQuery(agentContext: AgentContext, query: Query<ConfirmRecord>, queryOptions?: QueryOptions): Promise<ConfirmRecord[]>;
196
+ private updateState;
197
+ private emitStateChanged;
198
+ }
199
+ //#endregion
200
+ //#region src/ConfirmApi.d.ts
201
+ interface SendConfirmRequestOptions {
202
+ connectionId: string;
203
+ /** The flow id when the exchange runs inside an ayni-flow: set as `~thread.pthid` on every message (profile §2). */
204
+ parentThreadId?: string;
205
+ request: ConfirmRequest;
206
+ }
207
+ interface RespondConfirmOptions {
208
+ /** The `@id` of the request being answered. */
209
+ threadId: string;
210
+ response: ConfirmResponse;
211
+ }
212
+ /** `https://didcomm.org/confirm/1.0` (Ayni Flow Profile 1.0 §6.6). */
213
+ declare class ConfirmApi {
214
+ private readonly agentContext;
215
+ private readonly service;
216
+ private readonly messageSender;
217
+ private readonly connectionService;
218
+ constructor(agentContext: AgentContext, service: ConfirmService, messageSender: DidCommMessageSender, connectionService: DidCommConnectionService);
219
+ /** Sends a `request`; the record's `threadId` is the request id the response answers. */
220
+ request(options: SendConfirmRequestOptions): Promise<ConfirmRecord>;
221
+ /** Answers a received request with the `response` (profile §6.6); throws when the response breaks a rule of the profile. */
222
+ respond(options: RespondConfirmOptions): Promise<ConfirmRecord>;
223
+ /** Records a failure decided by the host (the person declined, the flow was refused...). */
224
+ fail(threadId: string, code: string, description?: string): Promise<ConfirmRecord>;
225
+ getById(id: string): Promise<ConfirmRecord>;
226
+ findById(id: string): Promise<ConfirmRecord | null>;
227
+ getByThreadId(threadId: string): Promise<ConfirmRecord>;
228
+ findByThreadId(threadId: string): Promise<ConfirmRecord | null>;
229
+ /** The exchanges that ran inside one ayni-flow. */
230
+ findByFlowId(flowId: string): Promise<ConfirmRecord[]>;
231
+ findAllByQuery(query: Query<ConfirmRecord>, queryOptions?: QueryOptions): Promise<ConfirmRecord[]>;
232
+ private send;
233
+ }
234
+ //#endregion
235
+ //#region src/ConfirmModuleConfig.d.ts
236
+ interface ConfirmModuleConfigOptions {
237
+ /**
238
+ * The roles this agent plays, disclosed through discover-features (profile §3). The Ayni app discloses
239
+ * `confirmer`; a Verifiable Service discloses `requester`. A service may NOT open a kind whose
240
+ * carrier protocol the holder did not disclose (FLOW-CAP-003), so disclose only what you implement.
241
+ */
242
+ roles: ConfirmRole[];
243
+ }
244
+ declare class ConfirmModuleConfig {
245
+ private readonly options;
246
+ constructor(options: ConfirmModuleConfigOptions);
247
+ get roles(): ConfirmRole[];
248
+ }
249
+ //#endregion
250
+ //#region src/ConfirmModule.d.ts
251
+ /** Credo module for `https://didcomm.org/confirm/1.0` (Ayni Flow Profile 1.0 §6.6). */
252
+ declare class ConfirmModule implements Module {
253
+ readonly api: typeof ConfirmApi;
254
+ readonly config: ConfirmModuleConfig;
255
+ constructor(options: ConfirmModuleConfigOptions);
256
+ register(dependencyManager: DependencyManager): void;
257
+ initialize(agentContext: AgentContext): Promise<void>;
258
+ }
259
+ //#endregion
260
+ //#region src/handlers/ConfirmRequestHandler.d.ts
261
+ declare class ConfirmRequestHandler implements DidCommMessageHandler {
262
+ private readonly service;
263
+ supportedMessages: (typeof ConfirmRequestMessage)[];
264
+ constructor(service: ConfirmService);
265
+ handle(messageContext: DidCommMessageHandlerInboundMessage<ConfirmRequestHandler>): Promise<undefined>;
266
+ }
267
+ //#endregion
268
+ //#region src/handlers/ConfirmResponseHandler.d.ts
269
+ declare class ConfirmResponseHandler implements DidCommMessageHandler {
270
+ private readonly service;
271
+ supportedMessages: (typeof ConfirmResponseMessage)[];
272
+ constructor(service: ConfirmService);
273
+ handle(messageContext: DidCommMessageHandlerInboundMessage<ConfirmResponseHandler>): Promise<undefined>;
274
+ }
275
+ //#endregion
276
+ //#region src/validation.d.ts
277
+ /** The rules of profile §6.6 / FLOW-CONFIRM-001 on a request; returns the first violation or undefined. */
278
+ declare function validateRequest(request: ConfirmRequest): string | undefined;
279
+ /** On a response: `attestation.method` may be `none` only when `attested` was false (profile §6.5 applies to confirm, §10). */
280
+ declare function validateResponse(request: ConfirmRequest, response: ConfirmResponse): string | undefined;
281
+ //#endregion
282
+ export { ATTESTATION_METHODS, Attestation, AttestationMethod, AttestationModel, CONFIRM_PROTOCOL_URI, CONFIRM_REQUEST_TYPE, CONFIRM_RESPONSE_TYPE, ConfirmApi, ConfirmEventTypes, ConfirmModule, ConfirmModuleConfig, type ConfirmModuleConfigOptions, ConfirmRecord, ConfirmRepository, ConfirmRequest, ConfirmRequestHandler, ConfirmRequestMessage, ConfirmRequestMessageOptions, ConfirmResponse, ConfirmResponseHandler, ConfirmResponseMessage, ConfirmResponseMessageOptions, ConfirmRole, ConfirmService, ConfirmState, ConfirmStateChangedEvent, ConfirmStorageProps, ConfirmTags, CreateConfirmRequestOptions, CustomConfirmTags, DefaultConfirmTags, type RespondConfirmOptions, type SendConfirmRequestOptions, validateRequest, validateResponse };
283
+ //# sourceMappingURL=index.d.ts.map
package/build/index.js ADDED
@@ -0,0 +1,533 @@
1
+ import { AgentContext, BaseRecord, CredoError, DateTransformer, EventEmitter, InjectionSymbols, Repository, inject, injectable, utils } from "@credo-ts/core";
2
+ import { DidCommConnectionService, DidCommFeatureRegistry, DidCommMessage, DidCommMessageHandlerRegistry, DidCommMessageSender, DidCommProtocol, IsValidMessageType, getOutboundDidCommMessageContext, parseMessageType } from "@credo-ts/didcomm";
3
+ import { IsBoolean, IsDate, IsIn, IsString, ValidateNested } from "class-validator";
4
+ import { Type } from "class-transformer";
5
+
6
+ //#region src/messages/ConfirmProtocol.ts
7
+ /** PIURI of the protocol, Ayni Flow Profile 1.0 §6.6. */
8
+ const CONFIRM_PROTOCOL_URI = "https://didcomm.org/confirm/1.0";
9
+ const CONFIRM_REQUEST_TYPE = `${CONFIRM_PROTOCOL_URI}/request`;
10
+ const CONFIRM_RESPONSE_TYPE = `${CONFIRM_PROTOCOL_URI}/response`;
11
+
12
+ //#endregion
13
+ //#region \0@oxc-project+runtime@0.99.0/helpers/decorateMetadata.js
14
+ function __decorateMetadata(k, v) {
15
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
16
+ }
17
+
18
+ //#endregion
19
+ //#region \0@oxc-project+runtime@0.99.0/helpers/decorate.js
20
+ function __decorate(decorators, target, key, desc) {
21
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
22
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
23
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
24
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
25
+ }
26
+
27
+ //#endregion
28
+ //#region src/messages/ConfirmRequestMessage.ts
29
+ /** `confirm/1.0/request` (profile §6.6). */
30
+ var ConfirmRequestMessage = class ConfirmRequestMessage extends DidCommMessage {
31
+ constructor(options) {
32
+ super();
33
+ this.type = ConfirmRequestMessage.type.messageTypeUri;
34
+ if (options) {
35
+ this.id = options.id ?? this.generateId();
36
+ this.setThread({
37
+ threadId: this.id,
38
+ parentThreadId: options.parentThreadId
39
+ });
40
+ this.text = options.text;
41
+ this.code = options.code;
42
+ this.attested = options.attested;
43
+ }
44
+ }
45
+ toRequest() {
46
+ return {
47
+ text: this.text,
48
+ code: this.code,
49
+ attested: this.attested
50
+ };
51
+ }
52
+ };
53
+ ConfirmRequestMessage.type = parseMessageType(CONFIRM_REQUEST_TYPE);
54
+ __decorate([IsValidMessageType(ConfirmRequestMessage.type), __decorateMetadata("design:type", Object)], ConfirmRequestMessage.prototype, "type", void 0);
55
+ __decorate([IsString(), __decorateMetadata("design:type", String)], ConfirmRequestMessage.prototype, "text", void 0);
56
+ __decorate([IsString(), __decorateMetadata("design:type", String)], ConfirmRequestMessage.prototype, "code", void 0);
57
+ __decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], ConfirmRequestMessage.prototype, "attested", void 0);
58
+
59
+ //#endregion
60
+ //#region src/fields.ts
61
+ var _ref$4;
62
+ const ATTESTATION_METHODS = [
63
+ "biometric",
64
+ "passcode",
65
+ "none"
66
+ ];
67
+ var AttestationModel = class {
68
+ constructor(options) {
69
+ if (options) {
70
+ this.method = options.method;
71
+ this.at = new Date(options.at);
72
+ }
73
+ }
74
+ };
75
+ __decorate([IsIn(ATTESTATION_METHODS), __decorateMetadata("design:type", Object)], AttestationModel.prototype, "method", void 0);
76
+ __decorate([
77
+ IsDate(),
78
+ DateTransformer(),
79
+ __decorateMetadata("design:type", typeof (_ref$4 = typeof Date !== "undefined" && Date) === "function" ? _ref$4 : Object)
80
+ ], AttestationModel.prototype, "at", void 0);
81
+
82
+ //#endregion
83
+ //#region src/messages/ConfirmResponseMessage.ts
84
+ var _ref$3;
85
+ /** `confirm/1.0/response` (profile §6.6). */
86
+ var ConfirmResponseMessage = class ConfirmResponseMessage extends DidCommMessage {
87
+ constructor(options) {
88
+ super();
89
+ this.type = ConfirmResponseMessage.type.messageTypeUri;
90
+ if (options) {
91
+ this.id = options.id ?? this.generateId();
92
+ this.setThread({
93
+ threadId: options.threadId,
94
+ parentThreadId: options.parentThreadId
95
+ });
96
+ this.confirmed = options.confirmed;
97
+ this.attestation = new AttestationModel(options.attestation);
98
+ }
99
+ }
100
+ toResponse() {
101
+ return {
102
+ confirmed: this.confirmed,
103
+ attestation: {
104
+ method: this.attestation.method,
105
+ at: this.attestation.at.toISOString()
106
+ }
107
+ };
108
+ }
109
+ };
110
+ ConfirmResponseMessage.type = parseMessageType(CONFIRM_RESPONSE_TYPE);
111
+ __decorate([IsValidMessageType(ConfirmResponseMessage.type), __decorateMetadata("design:type", Object)], ConfirmResponseMessage.prototype, "type", void 0);
112
+ __decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], ConfirmResponseMessage.prototype, "confirmed", void 0);
113
+ __decorate([
114
+ ValidateNested(),
115
+ Type(() => AttestationModel),
116
+ __decorateMetadata("design:type", typeof (_ref$3 = typeof AttestationModel !== "undefined" && AttestationModel) === "function" ? _ref$3 : Object)
117
+ ], ConfirmResponseMessage.prototype, "attestation", void 0);
118
+
119
+ //#endregion
120
+ //#region src/types.ts
121
+ /** The protocol roles disclosed through discover-features (profile §3). */
122
+ let ConfirmRole = /* @__PURE__ */ function(ConfirmRole$1) {
123
+ ConfirmRole$1["Requester"] = "requester";
124
+ ConfirmRole$1["Confirmer"] = "confirmer";
125
+ return ConfirmRole$1;
126
+ }({});
127
+ let ConfirmState = /* @__PURE__ */ function(ConfirmState$1) {
128
+ ConfirmState$1["RequestSent"] = "request-sent";
129
+ ConfirmState$1["RequestReceived"] = "request-received";
130
+ ConfirmState$1["ResponseSent"] = "response-sent";
131
+ ConfirmState$1["ResponseReceived"] = "response-received";
132
+ ConfirmState$1["Failed"] = "failed";
133
+ return ConfirmState$1;
134
+ }({});
135
+ let ConfirmEventTypes = /* @__PURE__ */ function(ConfirmEventTypes$1) {
136
+ ConfirmEventTypes$1["ConfirmStateChanged"] = "ConfirmStateChanged";
137
+ return ConfirmEventTypes$1;
138
+ }({});
139
+
140
+ //#endregion
141
+ //#region src/repository/ConfirmRecord.ts
142
+ /** One `https://didcomm.org/confirm/1.0` exchange, written on both sides. */
143
+ var ConfirmRecord = class ConfirmRecord extends BaseRecord {
144
+ constructor(props) {
145
+ super();
146
+ this.type = ConfirmRecord.type;
147
+ if (props) {
148
+ this.id = props.id ?? utils.uuid();
149
+ this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
150
+ this.threadId = props.threadId;
151
+ this.parentThreadId = props.parentThreadId;
152
+ this.connectionId = props.connectionId;
153
+ this.role = props.role;
154
+ this.state = props.state;
155
+ this.request = props.request;
156
+ this.response = props.response;
157
+ this.errorCode = props.errorCode;
158
+ this.errorDescription = props.errorDescription;
159
+ this._tags = props.tags ?? {};
160
+ }
161
+ }
162
+ getTags() {
163
+ return {
164
+ ...this._tags,
165
+ threadId: this.threadId,
166
+ parentThreadId: this.parentThreadId,
167
+ connectionId: this.connectionId,
168
+ role: this.role,
169
+ state: this.state
170
+ };
171
+ }
172
+ /** The flow id, when the exchange runs inside an ayni-flow. */
173
+ get flowId() {
174
+ return this.parentThreadId;
175
+ }
176
+ assertState(expected) {
177
+ const states = Array.isArray(expected) ? expected : [expected];
178
+ if (!states.includes(this.state)) throw new CredoError(`confirm: exchange '${this.threadId}' is in state ${this.state}, expected ${states.join(" | ")}`);
179
+ }
180
+ assertRole(expected) {
181
+ if (this.role !== expected) throw new CredoError(`confirm: exchange '${this.threadId}' has role ${this.role}, expected ${expected}`);
182
+ }
183
+ };
184
+ ConfirmRecord.type = "ConfirmRecord";
185
+
186
+ //#endregion
187
+ //#region \0@oxc-project+runtime@0.99.0/helpers/decorateParam.js
188
+ function __decorateParam(paramIndex, decorator) {
189
+ return function(target, key) {
190
+ decorator(target, key, paramIndex);
191
+ };
192
+ }
193
+
194
+ //#endregion
195
+ //#region src/repository/ConfirmRepository.ts
196
+ var _ref$2;
197
+ let ConfirmRepository = class ConfirmRepository$1 extends Repository {
198
+ constructor(storageService, eventEmitter) {
199
+ super(ConfirmRecord, storageService, eventEmitter);
200
+ }
201
+ /** The record of a `request` id. */
202
+ findByThreadId(agentContext, threadId) {
203
+ return this.findSingleByQuery(agentContext, { threadId });
204
+ }
205
+ /** The exchanges that ran inside one ayni-flow. */
206
+ findByParentThreadId(agentContext, parentThreadId) {
207
+ return this.findByQuery(agentContext, { parentThreadId });
208
+ }
209
+ findByConnectionId(agentContext, connectionId) {
210
+ return this.findByQuery(agentContext, { connectionId });
211
+ }
212
+ };
213
+ ConfirmRepository = __decorate([
214
+ injectable(),
215
+ __decorateParam(0, inject(InjectionSymbols.StorageService)),
216
+ __decorateMetadata("design:paramtypes", [Object, typeof (_ref$2 = typeof EventEmitter !== "undefined" && EventEmitter) === "function" ? _ref$2 : Object])
217
+ ], ConfirmRepository);
218
+
219
+ //#endregion
220
+ //#region src/validation.ts
221
+ /** The rules of profile §6.6 / FLOW-CONFIRM-001 on a request; returns the first violation or undefined. */
222
+ function validateRequest(request) {
223
+ if (typeof request.text !== "string" || !request.text) return "text is required";
224
+ if (typeof request.code !== "string" || !request.code) return "code is required";
225
+ if (typeof request.attested !== "boolean") return "attested must be a boolean";
226
+ }
227
+ /** On a response: `attestation.method` may be `none` only when `attested` was false (profile §6.5 applies to confirm, §10). */
228
+ function validateResponse(request, response) {
229
+ if (typeof response.confirmed !== "boolean") return "confirmed must be a boolean";
230
+ if (!response.attestation) return "attestation is required";
231
+ if (request.attested && response.attestation.method === "none") return "attestation.method 'none' is not allowed on an attested request";
232
+ if (typeof response.attestation.at !== "string" || Number.isNaN(Date.parse(response.attestation.at))) return "attestation.at is invalid";
233
+ }
234
+
235
+ //#endregion
236
+ //#region src/services/ConfirmService.ts
237
+ var _ref$1, _ref2$1;
238
+ let ConfirmService = class ConfirmService$1 {
239
+ constructor(repository, eventEmitter, logger) {
240
+ this.repository = repository;
241
+ this.eventEmitter = eventEmitter;
242
+ this.logger = logger;
243
+ }
244
+ /** Builds a `request` after checking it against the profile and records it sent. */
245
+ async createRequest(agentContext, options) {
246
+ const invalid = validateRequest(options.request);
247
+ if (invalid) throw new CredoError(`confirm: invalid request: ${invalid}`);
248
+ const message = new ConfirmRequestMessage({
249
+ ...options.request,
250
+ parentThreadId: options.parentThreadId
251
+ });
252
+ const record = new ConfirmRecord({
253
+ threadId: message.id,
254
+ parentThreadId: options.parentThreadId,
255
+ connectionId: options.connection.id,
256
+ role: ConfirmRole.Requester,
257
+ state: ConfirmState.RequestSent,
258
+ request: options.request
259
+ });
260
+ await this.repository.save(agentContext, record);
261
+ this.emitStateChanged(agentContext, record, null);
262
+ return {
263
+ message,
264
+ record
265
+ };
266
+ }
267
+ /** Receives a `request`; a replay is ignored. A request that breaks a rule of the profile is recorded `failed` (`malformed`). */
268
+ async processRequest(messageContext) {
269
+ const { message, agentContext } = messageContext;
270
+ const connection = messageContext.assertReadyConnection();
271
+ if (await this.repository.findByThreadId(agentContext, message.id)) {
272
+ this.logger.debug(`confirm: ignoring replayed request '${message.id}'`);
273
+ return null;
274
+ }
275
+ const request = message.toRequest();
276
+ const invalid = validateRequest(request);
277
+ const record = new ConfirmRecord({
278
+ threadId: message.id,
279
+ parentThreadId: message.thread?.parentThreadId,
280
+ connectionId: connection.id,
281
+ role: ConfirmRole.Confirmer,
282
+ state: invalid ? ConfirmState.Failed : ConfirmState.RequestReceived,
283
+ request,
284
+ ...invalid ? {
285
+ errorCode: "malformed",
286
+ errorDescription: invalid
287
+ } : {}
288
+ });
289
+ if (invalid) this.logger.warn(`confirm: request '${message.id}' is malformed: ${invalid}`);
290
+ await this.repository.save(agentContext, record);
291
+ this.emitStateChanged(agentContext, record, null);
292
+ return record;
293
+ }
294
+ /** Builds the `response` of a received request after checking it against the profile, and records it sent. */
295
+ async createResponse(agentContext, record, response) {
296
+ record.assertRole(ConfirmRole.Confirmer);
297
+ record.assertState(ConfirmState.RequestReceived);
298
+ const invalid = validateResponse(record.request, response);
299
+ if (invalid) throw new CredoError(`confirm: invalid response: ${invalid}`);
300
+ const message = new ConfirmResponseMessage({
301
+ ...response,
302
+ threadId: record.threadId,
303
+ parentThreadId: record.parentThreadId
304
+ });
305
+ record.response = response;
306
+ await this.updateState(agentContext, record, ConfirmState.ResponseSent);
307
+ return {
308
+ message,
309
+ record
310
+ };
311
+ }
312
+ /**
313
+ * Receives the `response` of a request we sent. A response that breaks a rule of the profile (for example an
314
+ * attestation `none` on an attested request) fails the exchange with `errorCode` `malformed`; the host sends the flow's
315
+ * problem report.
316
+ */
317
+ async processResponse(messageContext) {
318
+ const { message, agentContext } = messageContext;
319
+ const connection = messageContext.assertReadyConnection();
320
+ const record = await this.repository.findByThreadId(agentContext, message.threadId);
321
+ if (!record) {
322
+ this.logger.debug(`confirm: ignoring response to unknown request '${message.threadId}'`);
323
+ return null;
324
+ }
325
+ if (record.connectionId !== connection.id) {
326
+ this.logger.warn(`confirm: ignoring response to '${message.threadId}' from another connection`);
327
+ return null;
328
+ }
329
+ if (record.state !== ConfirmState.RequestSent) {
330
+ this.logger.debug(`confirm: ignoring response to '${message.threadId}' in state ${record.state}`);
331
+ return null;
332
+ }
333
+ const response = message.toResponse();
334
+ record.response = response;
335
+ const invalid = validateResponse(record.request, response);
336
+ if (invalid) {
337
+ this.logger.warn(`confirm: response to '${message.threadId}' is malformed: ${invalid}`);
338
+ record.errorCode = "malformed";
339
+ record.errorDescription = invalid;
340
+ await this.updateState(agentContext, record, ConfirmState.Failed);
341
+ return record;
342
+ }
343
+ await this.updateState(agentContext, record, ConfirmState.ResponseReceived);
344
+ return record;
345
+ }
346
+ /** Records a failure decided by the host (for example the person declined, or the flow was refused). */
347
+ async fail(agentContext, record, code, description) {
348
+ record.errorCode = code;
349
+ record.errorDescription = description;
350
+ await this.updateState(agentContext, record, ConfirmState.Failed);
351
+ return record;
352
+ }
353
+ getById(agentContext, id) {
354
+ return this.repository.getById(agentContext, id);
355
+ }
356
+ findById(agentContext, id) {
357
+ return this.repository.findById(agentContext, id);
358
+ }
359
+ async getByThreadId(agentContext, threadId) {
360
+ const record = await this.repository.findByThreadId(agentContext, threadId);
361
+ if (!record) throw new CredoError(`confirm: no exchange '${threadId}'`);
362
+ return record;
363
+ }
364
+ findByThreadId(agentContext, threadId) {
365
+ return this.repository.findByThreadId(agentContext, threadId);
366
+ }
367
+ findByParentThreadId(agentContext, parentThreadId) {
368
+ return this.repository.findByParentThreadId(agentContext, parentThreadId);
369
+ }
370
+ findAllByQuery(agentContext, query, queryOptions) {
371
+ return this.repository.findByQuery(agentContext, query, queryOptions);
372
+ }
373
+ async updateState(agentContext, record, state) {
374
+ const previousState = record.state;
375
+ record.state = state;
376
+ await this.repository.update(agentContext, record);
377
+ this.emitStateChanged(agentContext, record, previousState);
378
+ }
379
+ emitStateChanged(agentContext, record, previousState) {
380
+ this.eventEmitter.emit(agentContext, {
381
+ type: ConfirmEventTypes.ConfirmStateChanged,
382
+ payload: {
383
+ record: record.clone(),
384
+ previousState
385
+ }
386
+ });
387
+ }
388
+ };
389
+ ConfirmService = __decorate([
390
+ injectable(),
391
+ __decorateParam(2, inject(InjectionSymbols.Logger)),
392
+ __decorateMetadata("design:paramtypes", [
393
+ typeof (_ref$1 = typeof ConfirmRepository !== "undefined" && ConfirmRepository) === "function" ? _ref$1 : Object,
394
+ typeof (_ref2$1 = typeof EventEmitter !== "undefined" && EventEmitter) === "function" ? _ref2$1 : Object,
395
+ Object
396
+ ])
397
+ ], ConfirmService);
398
+
399
+ //#endregion
400
+ //#region src/ConfirmApi.ts
401
+ var _ref, _ref2, _ref3, _ref4;
402
+ let ConfirmApi = class ConfirmApi$1 {
403
+ constructor(agentContext, service, messageSender, connectionService) {
404
+ this.agentContext = agentContext;
405
+ this.service = service;
406
+ this.messageSender = messageSender;
407
+ this.connectionService = connectionService;
408
+ }
409
+ /** Sends a `request`; the record's `threadId` is the request id the response answers. */
410
+ async request(options) {
411
+ const connection = await this.connectionService.getById(this.agentContext, options.connectionId);
412
+ connection.assertReady();
413
+ const { message, record } = await this.service.createRequest(this.agentContext, {
414
+ connection,
415
+ parentThreadId: options.parentThreadId,
416
+ request: options.request
417
+ });
418
+ await this.send(connection.id, message, record);
419
+ return record;
420
+ }
421
+ /** Answers a received request with the `response` (profile §6.6); throws when the response breaks a rule of the profile. */
422
+ async respond(options) {
423
+ const record = await this.service.getByThreadId(this.agentContext, options.threadId);
424
+ const { message } = await this.service.createResponse(this.agentContext, record, options.response);
425
+ await this.send(record.connectionId, message, record);
426
+ return record;
427
+ }
428
+ /** Records a failure decided by the host (the person declined, the flow was refused...). */
429
+ async fail(threadId, code, description) {
430
+ const record = await this.service.getByThreadId(this.agentContext, threadId);
431
+ return this.service.fail(this.agentContext, record, code, description);
432
+ }
433
+ getById(id) {
434
+ return this.service.getById(this.agentContext, id);
435
+ }
436
+ findById(id) {
437
+ return this.service.findById(this.agentContext, id);
438
+ }
439
+ getByThreadId(threadId) {
440
+ return this.service.getByThreadId(this.agentContext, threadId);
441
+ }
442
+ findByThreadId(threadId) {
443
+ return this.service.findByThreadId(this.agentContext, threadId);
444
+ }
445
+ /** The exchanges that ran inside one ayni-flow. */
446
+ findByFlowId(flowId) {
447
+ return this.service.findByParentThreadId(this.agentContext, flowId);
448
+ }
449
+ findAllByQuery(query, queryOptions) {
450
+ return this.service.findAllByQuery(this.agentContext, query, queryOptions);
451
+ }
452
+ async send(connectionId, message, associatedRecord) {
453
+ const connectionRecord = await this.connectionService.getById(this.agentContext, connectionId);
454
+ const outbound = await getOutboundDidCommMessageContext(this.agentContext, {
455
+ message,
456
+ connectionRecord,
457
+ associatedRecord
458
+ });
459
+ await this.messageSender.sendMessage(outbound);
460
+ }
461
+ };
462
+ ConfirmApi = __decorate([injectable(), __decorateMetadata("design:paramtypes", [
463
+ typeof (_ref = typeof AgentContext !== "undefined" && AgentContext) === "function" ? _ref : Object,
464
+ typeof (_ref2 = typeof ConfirmService !== "undefined" && ConfirmService) === "function" ? _ref2 : Object,
465
+ typeof (_ref3 = typeof DidCommMessageSender !== "undefined" && DidCommMessageSender) === "function" ? _ref3 : Object,
466
+ typeof (_ref4 = typeof DidCommConnectionService !== "undefined" && DidCommConnectionService) === "function" ? _ref4 : Object
467
+ ])], ConfirmApi);
468
+
469
+ //#endregion
470
+ //#region src/ConfirmModuleConfig.ts
471
+ var ConfirmModuleConfig = class {
472
+ constructor(options) {
473
+ if (!options?.roles?.length) throw new Error("confirm: ConfirmModule needs at least one role");
474
+ this.options = options;
475
+ }
476
+ get roles() {
477
+ return this.options.roles;
478
+ }
479
+ };
480
+
481
+ //#endregion
482
+ //#region src/handlers/ConfirmRequestHandler.ts
483
+ var ConfirmRequestHandler = class {
484
+ constructor(service) {
485
+ this.service = service;
486
+ this.supportedMessages = [ConfirmRequestMessage];
487
+ }
488
+ async handle(messageContext) {
489
+ await this.service.processRequest(messageContext);
490
+ }
491
+ };
492
+
493
+ //#endregion
494
+ //#region src/handlers/ConfirmResponseHandler.ts
495
+ var ConfirmResponseHandler = class {
496
+ constructor(service) {
497
+ this.service = service;
498
+ this.supportedMessages = [ConfirmResponseMessage];
499
+ }
500
+ async handle(messageContext) {
501
+ await this.service.processResponse(messageContext);
502
+ }
503
+ };
504
+
505
+ //#endregion
506
+ //#region src/ConfirmModule.ts
507
+ /** Credo module for `https://didcomm.org/confirm/1.0` (Ayni Flow Profile 1.0 §6.6). */
508
+ var ConfirmModule = class {
509
+ constructor(options) {
510
+ this.api = ConfirmApi;
511
+ this.config = new ConfirmModuleConfig(options);
512
+ }
513
+ register(dependencyManager) {
514
+ dependencyManager.registerInstance(ConfirmModuleConfig, this.config);
515
+ dependencyManager.registerContextScoped(ConfirmApi);
516
+ dependencyManager.registerSingleton(ConfirmRepository);
517
+ dependencyManager.registerSingleton(ConfirmService);
518
+ }
519
+ async initialize(agentContext) {
520
+ const messageHandlerRegistry = agentContext.dependencyManager.resolve(DidCommMessageHandlerRegistry);
521
+ const featureRegistry = agentContext.dependencyManager.resolve(DidCommFeatureRegistry);
522
+ const service = agentContext.dependencyManager.resolve(ConfirmService);
523
+ messageHandlerRegistry.registerMessageHandlers([new ConfirmRequestHandler(service), new ConfirmResponseHandler(service)]);
524
+ featureRegistry.register(new DidCommProtocol({
525
+ id: CONFIRM_PROTOCOL_URI,
526
+ roles: this.config.roles
527
+ }));
528
+ }
529
+ };
530
+
531
+ //#endregion
532
+ export { ATTESTATION_METHODS, AttestationModel, CONFIRM_PROTOCOL_URI, CONFIRM_REQUEST_TYPE, CONFIRM_RESPONSE_TYPE, ConfirmApi, ConfirmEventTypes, ConfirmModule, ConfirmModuleConfig, ConfirmRecord, ConfirmRepository, ConfirmRequestHandler, ConfirmRequestMessage, ConfirmResponseHandler, ConfirmResponseMessage, ConfirmRole, ConfirmService, ConfirmState, validateRequest, validateResponse };
533
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ConfirmRepository","storageService: StorageService<ConfirmRecord>","ConfirmService","repository: ConfirmRepository","eventEmitter: EventEmitter","logger: Logger","ConfirmApi","agentContext: AgentContext","service: ConfirmService","messageSender: DidCommMessageSender","connectionService: DidCommConnectionService","service: ConfirmService","service: ConfirmService"],"sources":["../src/messages/ConfirmProtocol.ts","../src/messages/ConfirmRequestMessage.ts","../src/fields.ts","../src/messages/ConfirmResponseMessage.ts","../src/types.ts","../src/repository/ConfirmRecord.ts","../src/repository/ConfirmRepository.ts","../src/validation.ts","../src/services/ConfirmService.ts","../src/ConfirmApi.ts","../src/ConfirmModuleConfig.ts","../src/handlers/ConfirmRequestHandler.ts","../src/handlers/ConfirmResponseHandler.ts","../src/ConfirmModule.ts"],"sourcesContent":["/** PIURI of the protocol, Ayni Flow Profile 1.0 §6.6. */\nexport const CONFIRM_PROTOCOL_URI = 'https://didcomm.org/confirm/1.0'\nexport const CONFIRM_REQUEST_TYPE = `${CONFIRM_PROTOCOL_URI}/request`\nexport const CONFIRM_RESPONSE_TYPE = `${CONFIRM_PROTOCOL_URI}/response`\n","import { DidCommMessage, IsValidMessageType, parseMessageType } from '@credo-ts/didcomm'\nimport { IsBoolean, IsString } from 'class-validator'\n\nimport type { ConfirmRequest } from '../fields'\nimport { CONFIRM_REQUEST_TYPE } from './ConfirmProtocol'\n\nexport interface ConfirmRequestMessageOptions extends ConfirmRequest {\n id?: string\n /** The flow id when the request runs inside an ayni-flow (`~thread.pthid`). */\n parentThreadId?: string\n}\n\n/** `confirm/1.0/request` (profile §6.6). */\nexport class ConfirmRequestMessage extends DidCommMessage {\n public constructor(options: ConfirmRequestMessageOptions) {\n super()\n\n if (options) {\n this.id = options.id ?? this.generateId()\n this.setThread({ threadId: this.id, parentThreadId: options.parentThreadId })\n this.text = options.text\n this.code = options.code\n this.attested = options.attested\n }\n }\n\n public static readonly type = parseMessageType(CONFIRM_REQUEST_TYPE)\n @IsValidMessageType(ConfirmRequestMessage.type)\n public readonly type = ConfirmRequestMessage.type.messageTypeUri\n\n @IsString()\n public text!: string\n\n @IsString()\n public code!: string\n\n @IsBoolean()\n public attested!: boolean\n\n public toRequest(): ConfirmRequest {\n return { text: this.text, code: this.code, attested: this.attested }\n }\n}\n","import { DateTransformer } from '@credo-ts/core'\nimport { IsDate, IsIn } from 'class-validator'\n\nexport const ATTESTATION_METHODS = ['biometric', 'passcode', 'none'] as const\nexport type AttestationMethod = (typeof ATTESTATION_METHODS)[number]\n\n/** The `request` body of confirm/1.0 (profile §6.6, FLOW-CONFIRM-001): a yes-or-no with a code the service also shows elsewhere. */\nexport interface ConfirmRequest {\n text: string\n code: string\n /** `true` asks for a device-authenticated answer. */\n attested: boolean\n}\n\n/** How the person authenticated on the device; `none` is allowed only when `attested` was false. */\nexport interface Attestation {\n method: AttestationMethod\n /** ISO 8601 */\n at: string\n}\n\n/** The `response` body of confirm/1.0. */\nexport interface ConfirmResponse {\n confirmed: boolean\n attestation: Attestation\n}\n\nexport class AttestationModel {\n public constructor(options?: Attestation) {\n if (options) {\n this.method = options.method\n this.at = new Date(options.at)\n }\n }\n\n @IsIn(ATTESTATION_METHODS)\n public method!: AttestationMethod\n\n @IsDate()\n @DateTransformer()\n public at!: Date\n}\n","import { DidCommMessage, IsValidMessageType, parseMessageType } from '@credo-ts/didcomm'\nimport { Type } from 'class-transformer'\nimport { IsBoolean, ValidateNested } from 'class-validator'\n\nimport { AttestationModel, type ConfirmResponse } from '../fields'\nimport { CONFIRM_RESPONSE_TYPE } from './ConfirmProtocol'\n\nexport interface ConfirmResponseMessageOptions extends ConfirmResponse {\n id?: string\n /** The `@id` of the request being answered (`~thread.thid`). */\n threadId: string\n parentThreadId?: string\n}\n\n/** `confirm/1.0/response` (profile §6.6). */\nexport class ConfirmResponseMessage extends DidCommMessage {\n public constructor(options: ConfirmResponseMessageOptions) {\n super()\n\n if (options) {\n this.id = options.id ?? this.generateId()\n this.setThread({ threadId: options.threadId, parentThreadId: options.parentThreadId })\n this.confirmed = options.confirmed\n this.attestation = new AttestationModel(options.attestation)\n }\n }\n\n public static readonly type = parseMessageType(CONFIRM_RESPONSE_TYPE)\n @IsValidMessageType(ConfirmResponseMessage.type)\n public readonly type = ConfirmResponseMessage.type.messageTypeUri\n\n @IsBoolean()\n public confirmed!: boolean\n\n @ValidateNested()\n @Type(() => AttestationModel)\n public attestation!: AttestationModel\n\n public toResponse(): ConfirmResponse {\n return {\n confirmed: this.confirmed,\n attestation: { method: this.attestation.method, at: this.attestation.at.toISOString() },\n }\n }\n}\n","import type { BaseEvent } from '@credo-ts/core'\nimport type { ConfirmRecord } from './repository/ConfirmRecord'\n\nexport * from './fields'\n\n/** The protocol roles disclosed through discover-features (profile §3). */\nexport enum ConfirmRole {\n Requester = 'requester',\n Confirmer = 'confirmer',\n}\n\nexport enum ConfirmState {\n RequestSent = 'request-sent',\n RequestReceived = 'request-received',\n ResponseSent = 'response-sent',\n ResponseReceived = 'response-received',\n Failed = 'failed',\n}\n\nexport enum ConfirmEventTypes {\n ConfirmStateChanged = 'ConfirmStateChanged',\n}\n\n/** Emitted on every state change of a `ConfirmRecord`; `previousState` is null when the record is created. */\nexport interface ConfirmStateChangedEvent extends BaseEvent {\n type: typeof ConfirmEventTypes.ConfirmStateChanged\n payload: {\n record: ConfirmRecord\n previousState: ConfirmState | null\n }\n}\n","import type { RecordTags, TagsBase } from '@credo-ts/core'\n\nimport { BaseRecord, CredoError, utils } from '@credo-ts/core'\n\nimport type { ConfirmRequest, ConfirmResponse } from '../fields'\nimport { ConfirmRole, ConfirmState } from '../types'\n\nexport type DefaultConfirmTags = {\n /** The `@id` of the `request`, the thread id of the exchange. */\n threadId: string\n /** The flow id (`~thread.pthid`) when the exchange runs inside an ayni-flow. */\n parentThreadId?: string\n connectionId: string\n role: ConfirmRole\n state: ConfirmState\n}\n\nexport type CustomConfirmTags = TagsBase\n\nexport type ConfirmTags = RecordTags<ConfirmRecord>\n\nexport interface ConfirmStorageProps {\n id?: string\n createdAt?: Date\n threadId: string\n parentThreadId?: string\n connectionId: string\n role: ConfirmRole\n state: ConfirmState\n request: ConfirmRequest\n response?: ConfirmResponse\n errorCode?: string\n errorDescription?: string\n tags?: CustomConfirmTags\n}\n\n/** One `https://didcomm.org/confirm/1.0` exchange, written on both sides. */\nexport class ConfirmRecord extends BaseRecord<DefaultConfirmTags, CustomConfirmTags> {\n public static readonly type = 'ConfirmRecord'\n public readonly type = ConfirmRecord.type\n\n public threadId!: string\n public parentThreadId?: string\n public connectionId!: string\n public role!: ConfirmRole\n public state!: ConfirmState\n\n /** The `request` as sent or received. */\n public request!: ConfirmRequest\n\n /** The `response` as sent or received. */\n public response?: ConfirmResponse\n\n /** Set with state `failed`: why the exchange failed (`malformed` when the peer's message broke a rule of the profile). */\n public errorCode?: string\n public errorDescription?: string\n\n public constructor(props: ConfirmStorageProps) {\n super()\n\n if (props) {\n this.id = props.id ?? utils.uuid()\n this.createdAt = props.createdAt ?? new Date()\n this.threadId = props.threadId\n this.parentThreadId = props.parentThreadId\n this.connectionId = props.connectionId\n this.role = props.role\n this.state = props.state\n this.request = props.request\n this.response = props.response\n this.errorCode = props.errorCode\n this.errorDescription = props.errorDescription\n this._tags = props.tags ?? {}\n }\n }\n\n public getTags(): DefaultConfirmTags & CustomConfirmTags {\n return {\n ...this._tags,\n threadId: this.threadId,\n parentThreadId: this.parentThreadId,\n connectionId: this.connectionId,\n role: this.role,\n state: this.state,\n }\n }\n\n /** The flow id, when the exchange runs inside an ayni-flow. */\n public get flowId(): string | undefined {\n return this.parentThreadId\n }\n\n public assertState(expected: ConfirmState | ConfirmState[]): void {\n const states = Array.isArray(expected) ? expected : [expected]\n if (!states.includes(this.state)) {\n throw new CredoError(\n `confirm: exchange '${this.threadId}' is in state ${this.state}, expected ${states.join(' | ')}`\n )\n }\n }\n\n public assertRole(expected: ConfirmRole): void {\n if (this.role !== expected) {\n throw new CredoError(`confirm: exchange '${this.threadId}' has role ${this.role}, expected ${expected}`)\n }\n }\n}\n","import type { AgentContext, StorageService } from '@credo-ts/core'\n\nimport { EventEmitter, InjectionSymbols, inject, injectable, Repository } from '@credo-ts/core'\n\nimport { ConfirmRecord } from './ConfirmRecord'\n\n@injectable()\nexport class ConfirmRepository extends Repository<ConfirmRecord> {\n public constructor(\n @inject(InjectionSymbols.StorageService) storageService: StorageService<ConfirmRecord>,\n eventEmitter: EventEmitter\n ) {\n super(ConfirmRecord, storageService, eventEmitter)\n }\n\n /** The record of a `request` id. */\n public findByThreadId(agentContext: AgentContext, threadId: string) {\n return this.findSingleByQuery(agentContext, { threadId })\n }\n\n /** The exchanges that ran inside one ayni-flow. */\n public findByParentThreadId(agentContext: AgentContext, parentThreadId: string) {\n return this.findByQuery(agentContext, { parentThreadId })\n }\n\n public findByConnectionId(agentContext: AgentContext, connectionId: string) {\n return this.findByQuery(agentContext, { connectionId })\n }\n}\n","import type { ConfirmRequest, ConfirmResponse } from './fields'\n\n/** The rules of profile §6.6 / FLOW-CONFIRM-001 on a request; returns the first violation or undefined. */\nexport function validateRequest(request: ConfirmRequest): string | undefined {\n if (typeof request.text !== 'string' || !request.text) return 'text is required'\n if (typeof request.code !== 'string' || !request.code) return 'code is required'\n if (typeof request.attested !== 'boolean') return 'attested must be a boolean'\n return undefined\n}\n\n/** On a response: `attestation.method` may be `none` only when `attested` was false (profile §6.5 applies to confirm, §10). */\nexport function validateResponse(request: ConfirmRequest, response: ConfirmResponse): string | undefined {\n if (typeof response.confirmed !== 'boolean') return 'confirmed must be a boolean'\n if (!response.attestation) return 'attestation is required'\n if (request.attested && response.attestation.method === 'none') {\n return \"attestation.method 'none' is not allowed on an attested request\"\n }\n if (typeof response.attestation.at !== 'string' || Number.isNaN(Date.parse(response.attestation.at))) {\n return 'attestation.at is invalid'\n }\n return undefined\n}\n","import type { AgentContext, Logger, Query, QueryOptions } from '@credo-ts/core'\nimport { CredoError, EventEmitter, InjectionSymbols, inject, injectable } from '@credo-ts/core'\nimport type { DidCommConnectionRecord, DidCommInboundMessageContext } from '@credo-ts/didcomm'\n\nimport type { ConfirmRequest, ConfirmResponse } from '../fields'\nimport { ConfirmRequestMessage, ConfirmResponseMessage } from '../messages'\nimport { ConfirmRecord, ConfirmRepository } from '../repository'\nimport { ConfirmEventTypes, ConfirmRole, ConfirmState, type ConfirmStateChangedEvent } from '../types'\nimport { validateRequest, validateResponse } from '../validation'\n\nexport interface CreateConfirmRequestOptions {\n connection: DidCommConnectionRecord\n /** The flow id when the exchange runs inside an ayni-flow (`~thread.pthid`). */\n parentThreadId?: string\n request: ConfirmRequest\n}\n\n/** State machine of one `https://didcomm.org/confirm/1.0` exchange; builds the wire messages, never sends them (sending is `ConfirmApi`). */\n@injectable()\nexport class ConfirmService {\n public constructor(\n private readonly repository: ConfirmRepository,\n private readonly eventEmitter: EventEmitter,\n @inject(InjectionSymbols.Logger) private readonly logger: Logger\n ) {}\n\n /** Builds a `request` after checking it against the profile and records it sent. */\n public async createRequest(\n agentContext: AgentContext,\n options: CreateConfirmRequestOptions\n ): Promise<{ message: ConfirmRequestMessage; record: ConfirmRecord }> {\n const invalid = validateRequest(options.request)\n if (invalid) throw new CredoError(`confirm: invalid request: ${invalid}`)\n\n const message = new ConfirmRequestMessage({ ...options.request, parentThreadId: options.parentThreadId })\n const record = new ConfirmRecord({\n threadId: message.id,\n parentThreadId: options.parentThreadId,\n connectionId: options.connection.id,\n role: ConfirmRole.Requester,\n state: ConfirmState.RequestSent,\n request: options.request,\n })\n await this.repository.save(agentContext, record)\n this.emitStateChanged(agentContext, record, null)\n return { message, record }\n }\n\n /** Receives a `request`; a replay is ignored. A request that breaks a rule of the profile is recorded `failed` (`malformed`). */\n public async processRequest(\n messageContext: DidCommInboundMessageContext<ConfirmRequestMessage>\n ): Promise<ConfirmRecord | null> {\n const { message, agentContext } = messageContext\n const connection = messageContext.assertReadyConnection()\n\n const existing = await this.repository.findByThreadId(agentContext, message.id)\n if (existing) {\n this.logger.debug(`confirm: ignoring replayed request '${message.id}'`)\n return null\n }\n\n const request = message.toRequest()\n const invalid = validateRequest(request)\n const record = new ConfirmRecord({\n threadId: message.id,\n parentThreadId: message.thread?.parentThreadId,\n connectionId: connection.id,\n role: ConfirmRole.Confirmer,\n state: invalid ? ConfirmState.Failed : ConfirmState.RequestReceived,\n request,\n ...(invalid ? { errorCode: 'malformed', errorDescription: invalid } : {}),\n })\n if (invalid) this.logger.warn(`confirm: request '${message.id}' is malformed: ${invalid}`)\n await this.repository.save(agentContext, record)\n this.emitStateChanged(agentContext, record, null)\n return record\n }\n\n /** Builds the `response` of a received request after checking it against the profile, and records it sent. */\n public async createResponse(\n agentContext: AgentContext,\n record: ConfirmRecord,\n response: ConfirmResponse\n ): Promise<{ message: ConfirmResponseMessage; record: ConfirmRecord }> {\n record.assertRole(ConfirmRole.Confirmer)\n record.assertState(ConfirmState.RequestReceived)\n\n const invalid = validateResponse(record.request, response)\n if (invalid) throw new CredoError(`confirm: invalid response: ${invalid}`)\n\n const message = new ConfirmResponseMessage({\n ...response,\n threadId: record.threadId,\n parentThreadId: record.parentThreadId,\n })\n record.response = response\n await this.updateState(agentContext, record, ConfirmState.ResponseSent)\n return { message, record }\n }\n\n /**\n * Receives the `response` of a request we sent. A response that breaks a rule of the profile (for example an\n * attestation `none` on an attested request) fails the exchange with `errorCode` `malformed`; the host sends the flow's\n * problem report.\n */\n public async processResponse(\n messageContext: DidCommInboundMessageContext<ConfirmResponseMessage>\n ): Promise<ConfirmRecord | null> {\n const { message, agentContext } = messageContext\n const connection = messageContext.assertReadyConnection()\n\n const record = await this.repository.findByThreadId(agentContext, message.threadId)\n if (!record) {\n this.logger.debug(`confirm: ignoring response to unknown request '${message.threadId}'`)\n return null\n }\n if (record.connectionId !== connection.id) {\n this.logger.warn(`confirm: ignoring response to '${message.threadId}' from another connection`)\n return null\n }\n if (record.state !== ConfirmState.RequestSent) {\n this.logger.debug(`confirm: ignoring response to '${message.threadId}' in state ${record.state}`)\n return null\n }\n\n const response = message.toResponse()\n record.response = response\n const invalid = validateResponse(record.request, response)\n if (invalid) {\n this.logger.warn(`confirm: response to '${message.threadId}' is malformed: ${invalid}`)\n record.errorCode = 'malformed'\n record.errorDescription = invalid\n await this.updateState(agentContext, record, ConfirmState.Failed)\n return record\n }\n await this.updateState(agentContext, record, ConfirmState.ResponseReceived)\n return record\n }\n\n /** Records a failure decided by the host (for example the person declined, or the flow was refused). */\n public async fail(\n agentContext: AgentContext,\n record: ConfirmRecord,\n code: string,\n description?: string\n ): Promise<ConfirmRecord> {\n record.errorCode = code\n record.errorDescription = description\n await this.updateState(agentContext, record, ConfirmState.Failed)\n return record\n }\n\n public getById(agentContext: AgentContext, id: string) {\n return this.repository.getById(agentContext, id)\n }\n\n public findById(agentContext: AgentContext, id: string) {\n return this.repository.findById(agentContext, id)\n }\n\n public async getByThreadId(agentContext: AgentContext, threadId: string): Promise<ConfirmRecord> {\n const record = await this.repository.findByThreadId(agentContext, threadId)\n if (!record) throw new CredoError(`confirm: no exchange '${threadId}'`)\n return record\n }\n\n public findByThreadId(agentContext: AgentContext, threadId: string) {\n return this.repository.findByThreadId(agentContext, threadId)\n }\n\n public findByParentThreadId(agentContext: AgentContext, parentThreadId: string) {\n return this.repository.findByParentThreadId(agentContext, parentThreadId)\n }\n\n public findAllByQuery(agentContext: AgentContext, query: Query<ConfirmRecord>, queryOptions?: QueryOptions) {\n return this.repository.findByQuery(agentContext, query, queryOptions)\n }\n\n private async updateState(agentContext: AgentContext, record: ConfirmRecord, state: ConfirmState): Promise<void> {\n const previousState = record.state\n record.state = state\n await this.repository.update(agentContext, record)\n this.emitStateChanged(agentContext, record, previousState)\n }\n\n private emitStateChanged(agentContext: AgentContext, record: ConfirmRecord, previousState: ConfirmState | null) {\n this.eventEmitter.emit<ConfirmStateChangedEvent>(agentContext, {\n type: ConfirmEventTypes.ConfirmStateChanged,\n payload: { record: record.clone(), previousState },\n })\n }\n}\n","import type { Query, QueryOptions } from '@credo-ts/core'\nimport { AgentContext, injectable } from '@credo-ts/core'\nimport type { DidCommMessage } from '@credo-ts/didcomm'\nimport { DidCommConnectionService, DidCommMessageSender, getOutboundDidCommMessageContext } from '@credo-ts/didcomm'\n\nimport type { ConfirmRequest, ConfirmResponse } from './fields'\nimport type { ConfirmRecord } from './repository'\nimport { ConfirmService } from './services'\n\nexport interface SendConfirmRequestOptions {\n connectionId: string\n /** The flow id when the exchange runs inside an ayni-flow: set as `~thread.pthid` on every message (profile §2). */\n parentThreadId?: string\n request: ConfirmRequest\n}\n\nexport interface RespondConfirmOptions {\n /** The `@id` of the request being answered. */\n threadId: string\n response: ConfirmResponse\n}\n\n/** `https://didcomm.org/confirm/1.0` (Ayni Flow Profile 1.0 §6.6). */\n@injectable()\nexport class ConfirmApi {\n public constructor(\n private readonly agentContext: AgentContext,\n private readonly service: ConfirmService,\n private readonly messageSender: DidCommMessageSender,\n private readonly connectionService: DidCommConnectionService\n ) {}\n\n /** Sends a `request`; the record's `threadId` is the request id the response answers. */\n public async request(options: SendConfirmRequestOptions): Promise<ConfirmRecord> {\n const connection = await this.connectionService.getById(this.agentContext, options.connectionId)\n connection.assertReady()\n\n const { message, record } = await this.service.createRequest(this.agentContext, {\n connection,\n parentThreadId: options.parentThreadId,\n request: options.request,\n })\n await this.send(connection.id, message, record)\n return record\n }\n\n /** Answers a received request with the `response` (profile §6.6); throws when the response breaks a rule of the profile. */\n public async respond(options: RespondConfirmOptions): Promise<ConfirmRecord> {\n const record = await this.service.getByThreadId(this.agentContext, options.threadId)\n const { message } = await this.service.createResponse(this.agentContext, record, options.response)\n await this.send(record.connectionId, message, record)\n return record\n }\n\n /** Records a failure decided by the host (the person declined, the flow was refused...). */\n public async fail(threadId: string, code: string, description?: string): Promise<ConfirmRecord> {\n const record = await this.service.getByThreadId(this.agentContext, threadId)\n return this.service.fail(this.agentContext, record, code, description)\n }\n\n public getById(id: string): Promise<ConfirmRecord> {\n return this.service.getById(this.agentContext, id)\n }\n\n public findById(id: string): Promise<ConfirmRecord | null> {\n return this.service.findById(this.agentContext, id)\n }\n\n public getByThreadId(threadId: string): Promise<ConfirmRecord> {\n return this.service.getByThreadId(this.agentContext, threadId)\n }\n\n public findByThreadId(threadId: string): Promise<ConfirmRecord | null> {\n return this.service.findByThreadId(this.agentContext, threadId)\n }\n\n /** The exchanges that ran inside one ayni-flow. */\n public findByFlowId(flowId: string): Promise<ConfirmRecord[]> {\n return this.service.findByParentThreadId(this.agentContext, flowId)\n }\n\n public findAllByQuery(query: Query<ConfirmRecord>, queryOptions?: QueryOptions): Promise<ConfirmRecord[]> {\n return this.service.findAllByQuery(this.agentContext, query, queryOptions)\n }\n\n private async send(connectionId: string, message: DidCommMessage, associatedRecord: ConfirmRecord): Promise<void> {\n const connectionRecord = await this.connectionService.getById(this.agentContext, connectionId)\n const outbound = await getOutboundDidCommMessageContext(this.agentContext, {\n message,\n connectionRecord,\n associatedRecord,\n })\n await this.messageSender.sendMessage(outbound)\n }\n}\n","import { ConfirmRole } from './types'\n\nexport interface ConfirmModuleConfigOptions {\n /**\n * The roles this agent plays, disclosed through discover-features (profile §3). The Ayni app discloses\n * `confirmer`; a Verifiable Service discloses `requester`. A service may NOT open a kind whose\n * carrier protocol the holder did not disclose (FLOW-CAP-003), so disclose only what you implement.\n */\n roles: ConfirmRole[]\n}\n\nexport class ConfirmModuleConfig {\n private readonly options: ConfirmModuleConfigOptions\n\n public constructor(options: ConfirmModuleConfigOptions) {\n if (!options?.roles?.length) {\n throw new Error('confirm: ConfirmModule needs at least one role')\n }\n this.options = options\n }\n\n public get roles(): ConfirmRole[] {\n return this.options.roles\n }\n}\n","import type { DidCommMessageHandler, DidCommMessageHandlerInboundMessage } from '@credo-ts/didcomm'\n\nimport { ConfirmRequestMessage } from '../messages'\nimport type { ConfirmService } from '../services'\n\nexport class ConfirmRequestHandler implements DidCommMessageHandler {\n public supportedMessages = [ConfirmRequestMessage]\n\n public constructor(private readonly service: ConfirmService) {}\n\n public async handle(messageContext: DidCommMessageHandlerInboundMessage<ConfirmRequestHandler>) {\n await this.service.processRequest(messageContext)\n return undefined\n }\n}\n","import type { DidCommMessageHandler, DidCommMessageHandlerInboundMessage } from '@credo-ts/didcomm'\n\nimport { ConfirmResponseMessage } from '../messages'\nimport type { ConfirmService } from '../services'\n\nexport class ConfirmResponseHandler implements DidCommMessageHandler {\n public supportedMessages = [ConfirmResponseMessage]\n\n public constructor(private readonly service: ConfirmService) {}\n\n public async handle(messageContext: DidCommMessageHandlerInboundMessage<ConfirmResponseHandler>) {\n await this.service.processResponse(messageContext)\n return undefined\n }\n}\n","import type { AgentContext, DependencyManager, Module } from '@credo-ts/core'\n\nimport { DidCommFeatureRegistry, DidCommMessageHandlerRegistry, DidCommProtocol } from '@credo-ts/didcomm'\n\nimport { ConfirmApi } from './ConfirmApi'\nimport { ConfirmModuleConfig, type ConfirmModuleConfigOptions } from './ConfirmModuleConfig'\nimport { ConfirmRequestHandler, ConfirmResponseHandler } from './handlers'\nimport { CONFIRM_PROTOCOL_URI } from './messages'\nimport { ConfirmRepository } from './repository'\nimport { ConfirmService } from './services'\n\n/** Credo module for `https://didcomm.org/confirm/1.0` (Ayni Flow Profile 1.0 §6.6). */\nexport class ConfirmModule implements Module {\n public readonly api = ConfirmApi\n public readonly config: ConfirmModuleConfig\n\n public constructor(options: ConfirmModuleConfigOptions) {\n this.config = new ConfirmModuleConfig(options)\n }\n\n public register(dependencyManager: DependencyManager): void {\n dependencyManager.registerInstance(ConfirmModuleConfig, this.config)\n dependencyManager.registerContextScoped(ConfirmApi)\n dependencyManager.registerSingleton(ConfirmRepository)\n dependencyManager.registerSingleton(ConfirmService)\n }\n\n public async initialize(agentContext: AgentContext): Promise<void> {\n const messageHandlerRegistry = agentContext.dependencyManager.resolve(DidCommMessageHandlerRegistry)\n const featureRegistry = agentContext.dependencyManager.resolve(DidCommFeatureRegistry)\n const service = agentContext.dependencyManager.resolve(ConfirmService)\n\n messageHandlerRegistry.registerMessageHandlers([\n new ConfirmRequestHandler(service),\n new ConfirmResponseHandler(service),\n ])\n featureRegistry.register(new DidCommProtocol({ id: CONFIRM_PROTOCOL_URI, roles: this.config.roles }))\n }\n}\n"],"mappings":";;;;;;;AACA,MAAa,uBAAuB;AACpC,MAAa,uBAAuB,GAAG,qBAAqB;AAC5D,MAAa,wBAAwB,GAAG,qBAAqB;;;;;;;;;;;;;;;;;;;;ACU7D,IAAa,wBAAb,MAAa,8BAA8B,eAAe;CACxD,AAAO,YAAY,SAAuC;AACxD,SAAO;OAaO,OAAO,sBAAsB,KAAK;AAXhD,MAAI,SAAS;AACX,QAAK,KAAK,QA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B;EAAzB;OAF7B,oBAAoB,CAAC,sBAAsB;;CAIlD,MAAa,OAAO,gBAA4E;AAC9F,QAAM,KAAK,QAAQ,eAAe,eAAe;;;;;;ACNrD,IAAa,yBAAb,MAAqE;CAGnE,AAAO,YAAY,AAAiBC,SAAyB;EAAzB;OAF7B,oBAAoB,CAAC,uBAAuB;;CAInD,MAAa,OAAO,gBAA6E;AAC/F,QAAM,KAAK,QAAQ,gBAAgB,eAAe;;;;;;;ACCtD,IAAa,gBAAb,MAA6C;CAI3C,AAAO,YAAY,SAAqC;OAHxC,MAAM;AAIpB,OAAK,SAAS,IAAI,oBAAoB,QAAQ;;CAGhD,AAAO,SAAS,mBAA4C;AAC1D,oBAAkB,iBAAiB,qBAAqB,KAAK,OAAO;AACpE,oBAAkB,sBAAsB,WAAW;AACnD,oBAAkB,kBAAkB,kBAAkB;AACtD,oBAAkB,kBAAkB,eAAe;;CAGrD,MAAa,WAAW,cAA2C;EACjE,MAAM,yBAAyB,aAAa,kBAAkB,QAAQ,8BAA8B;EACpG,MAAM,kBAAkB,aAAa,kBAAkB,QAAQ,uBAAuB;EACtF,MAAM,UAAU,aAAa,kBAAkB,QAAQ,eAAe;AAEtE,yBAAuB,wBAAwB,CAC7C,IAAI,sBAAsB,QAAQ,EAClC,IAAI,uBAAuB,QAAQ,CACpC,CAAC;AACF,kBAAgB,SAAS,IAAI,gBAAgB;GAAE,IAAI;GAAsB,OAAO,KAAK,OAAO;GAAO,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@ayni.org/credo-ts-didcomm-confirm",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "type": "module",
4
+ "version": "0.1.2",
5
+ "main": "./build/index.js",
6
+ "module": "./build/index.js",
7
+ "types": "./build/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./build/index.d.ts",
11
+ "default": "./build/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "build"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "license": "Apache-2.0",
21
+ "description": "Credo-TS module for the confirm/1.0 DIDComm protocol (Ayni Flow Profile 1.0 §6.6): a yes-or-no with a code the service also shows elsewhere",
22
+ "homepage": "https://github.com/2060-io/credo-ts-ayni-flow/tree/main/packages/confirm",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/2060-io/credo-ts-ayni-flow",
26
+ "directory": "packages/confirm"
27
+ },
28
+ "dependencies": {
29
+ "class-transformer": "0.5.1",
30
+ "class-validator": "^0.14.3"
31
+ },
32
+ "peerDependencies": {
33
+ "@credo-ts/core": ">=0.8.0-pr-2704-20261026000000 <0.9.0",
34
+ "@credo-ts/didcomm": ">=0.8.0-pr-2704-20261026000000 <0.9.0"
35
+ },
36
+ "devDependencies": {
37
+ "@credo-ts/core": "0.8.0-pr-2704-20261029165313",
38
+ "@credo-ts/didcomm": "0.8.0-pr-2704-20261029165313"
39
+ },
40
+ "scripts": {
41
+ "build": "tsdown --config ./tsdown.config.ts",
42
+ "clean": "rimraf ./build",
43
+ "compile": "tsc -p tsconfig.build.json"
44
+ }
6
45
  }