@verana-labs/vs-agent-plugin-mrtd 1.10.1
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 +201 -0
- package/build/events/MrtdEvents.d.ts +3 -0
- package/build/events/MrtdEvents.js +71 -0
- package/build/events/MrtdEvents.js.map +1 -0
- package/build/handlers/MrtdMessageHandler.d.ts +13 -0
- package/build/handlers/MrtdMessageHandler.js +116 -0
- package/build/handlers/MrtdMessageHandler.js.map +1 -0
- package/build/index.d.ts +13 -0
- package/build/index.js +23 -0
- package/build/index.js.map +1 -0
- package/build/model/EMrtdDataRequestMessage.d.ts +6 -0
- package/build/model/EMrtdDataRequestMessage.js +20 -0
- package/build/model/EMrtdDataRequestMessage.js.map +1 -0
- package/build/model/EMrtdDataSubmitMessage.d.ts +43 -0
- package/build/model/EMrtdDataSubmitMessage.js +119 -0
- package/build/model/EMrtdDataSubmitMessage.js.map +1 -0
- package/build/model/MrtdSubmitState.d.ts +6 -0
- package/build/model/MrtdSubmitState.js +11 -0
- package/build/model/MrtdSubmitState.js.map +1 -0
- package/build/model/MrzDataRequestMessage.d.ts +6 -0
- package/build/model/MrzDataRequestMessage.js +20 -0
- package/build/model/MrzDataRequestMessage.js.map +1 -0
- package/build/model/MrzDataSubmitMessage.d.ts +14 -0
- package/build/model/MrzDataSubmitMessage.js +22 -0
- package/build/model/MrzDataSubmitMessage.js.map +1 -0
- package/build/nestjs/MrtdPlugin.d.ts +3 -0
- package/build/nestjs/MrtdPlugin.js +17 -0
- package/build/nestjs/MrtdPlugin.js.map +1 -0
- package/build/sdk/setupMrtdProtocol.d.ts +13 -0
- package/build/sdk/setupMrtdProtocol.js +17 -0
- package/build/sdk/setupMrtdProtocol.js.map +1 -0
- package/build/types.d.ts +5 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/package.json +45 -0
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.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mrtdEvents = void 0;
|
|
4
|
+
const credo_ts_didcomm_mrtd_1 = require("@2060.io/credo-ts-didcomm-mrtd");
|
|
5
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
6
|
+
const vs_agent_sdk_1 = require("@verana-labs/vs-agent-sdk");
|
|
7
|
+
const EMrtdDataSubmitMessage_1 = require("../model/EMrtdDataSubmitMessage");
|
|
8
|
+
const MrtdSubmitState_1 = require("../model/MrtdSubmitState");
|
|
9
|
+
const MrzDataSubmitMessage_1 = require("../model/MrzDataSubmitMessage");
|
|
10
|
+
const getRecordId = async (agent, id) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const record = await agent.genericRecords.findById(id);
|
|
13
|
+
return (_a = record === null || record === void 0 ? void 0 : record.getTag('messageId')) !== null && _a !== void 0 ? _a : id;
|
|
14
|
+
};
|
|
15
|
+
const sendMrtdEvent = async (agent, message, timestamp, config) => {
|
|
16
|
+
await (0, vs_agent_sdk_1.sendWebhookEvent)(config.webhookUrl + '/message-received', new vs_agent_model_1.MessageReceived({ timestamp, message }), config.logger);
|
|
17
|
+
};
|
|
18
|
+
const mrtdEvents = (agent, config) => {
|
|
19
|
+
agent.events.on(credo_ts_didcomm_mrtd_1.MrtdEventTypes.MrzDataReceived, async ({ payload }) => {
|
|
20
|
+
const { connection, mrzData, threadId } = payload;
|
|
21
|
+
const msg = new MrzDataSubmitMessage_1.MrzDataSubmitMessage({
|
|
22
|
+
connectionId: connection.id,
|
|
23
|
+
threadId,
|
|
24
|
+
state: MrtdSubmitState_1.MrtdSubmitState.Submitted,
|
|
25
|
+
mrzData,
|
|
26
|
+
});
|
|
27
|
+
msg.id = await getRecordId(agent, msg.id);
|
|
28
|
+
await sendMrtdEvent(agent, msg, msg.timestamp, config);
|
|
29
|
+
});
|
|
30
|
+
agent.events.on(credo_ts_didcomm_mrtd_1.MrtdEventTypes.EMrtdDataReceived, async ({ payload }) => {
|
|
31
|
+
const { connection, dataGroups, threadId } = payload;
|
|
32
|
+
const msg = new EMrtdDataSubmitMessage_1.EMrtdDataSubmitMessage({
|
|
33
|
+
connectionId: connection.id,
|
|
34
|
+
threadId,
|
|
35
|
+
state: MrtdSubmitState_1.MrtdSubmitState.Submitted,
|
|
36
|
+
dataGroups,
|
|
37
|
+
});
|
|
38
|
+
msg.id = await getRecordId(agent, msg.id);
|
|
39
|
+
await sendMrtdEvent(agent, msg, msg.timestamp, config);
|
|
40
|
+
});
|
|
41
|
+
// MRTD problem reports
|
|
42
|
+
agent.events.on(credo_ts_didcomm_mrtd_1.MrtdEventTypes.MrtdProblemReport, async ({ payload }) => {
|
|
43
|
+
const { connection, description, threadId } = payload;
|
|
44
|
+
const stateMap = {
|
|
45
|
+
'e.p.emrtd-refused': MrtdSubmitState_1.MrtdSubmitState.Declined,
|
|
46
|
+
'e.p.emrtd-timeout': MrtdSubmitState_1.MrtdSubmitState.Timeout,
|
|
47
|
+
'e.p.mrz-refused': MrtdSubmitState_1.MrtdSubmitState.Declined,
|
|
48
|
+
'e.p.mrz-timeout': MrtdSubmitState_1.MrtdSubmitState.Timeout,
|
|
49
|
+
};
|
|
50
|
+
if ([credo_ts_didcomm_mrtd_1.MrtdProblemReportReason.EmrtdRefused, credo_ts_didcomm_mrtd_1.MrtdProblemReportReason.EmrtdTimeout].includes(description.code)) {
|
|
51
|
+
const msg = new EMrtdDataSubmitMessage_1.EMrtdDataSubmitMessage({
|
|
52
|
+
connectionId: connection.id,
|
|
53
|
+
threadId,
|
|
54
|
+
state: stateMap[description.code],
|
|
55
|
+
});
|
|
56
|
+
msg.id = await getRecordId(agent, msg.id);
|
|
57
|
+
await sendMrtdEvent(agent, msg, msg.timestamp, config);
|
|
58
|
+
}
|
|
59
|
+
else if ([credo_ts_didcomm_mrtd_1.MrtdProblemReportReason.MrzRefused, credo_ts_didcomm_mrtd_1.MrtdProblemReportReason.MrzTimeout].includes(description.code)) {
|
|
60
|
+
const msg = new MrzDataSubmitMessage_1.MrzDataSubmitMessage({
|
|
61
|
+
connectionId: connection.id,
|
|
62
|
+
threadId,
|
|
63
|
+
state: stateMap[description.code],
|
|
64
|
+
});
|
|
65
|
+
msg.id = await getRecordId(agent, msg.id);
|
|
66
|
+
await sendMrtdEvent(agent, msg, msg.timestamp, config);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
exports.mrtdEvents = mrtdEvents;
|
|
71
|
+
//# sourceMappingURL=MrtdEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrtdEvents.js","sourceRoot":"","sources":["../../src/events/MrtdEvents.ts"],"names":[],"mappings":";;;AAEA,0EAMuC;AACvC,gEAA0E;AAC1E,4DAAqE;AAErE,4EAAwE;AACxE,8DAA0D;AAC1D,wEAAoE;AAEpE,MAAM,WAAW,GAAG,KAAK,EAAE,KAAmB,EAAE,EAAU,EAAmB,EAAE;;IAC7E,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACtD,OAAO,MAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,WAAW,CAAY,mCAAI,EAAE,CAAA;AACtD,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,KAAK,EACzB,KAAmB,EACnB,OAAoB,EACpB,SAAe,EACf,MAA2B,EAC3B,EAAE;IACF,MAAM,IAAA,+BAAgB,EACpB,MAAM,CAA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AC,IAA+B,CAAC;aAC7D,CAAC,CAAA;YACF,GAAG,CAAC,EAAE,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;YACzC,MAAM,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QACxD,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAlEY,QAAA,UAAU,cAkEtB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MessageHandler } from '@verana-labs/vs-agent-sdk';
|
|
2
|
+
import { DidCommConnectionRecord } from '@credo-ts/didcomm';
|
|
3
|
+
import { IBaseMessage, MessageType } from '@verana-labs/vs-agent-model';
|
|
4
|
+
import { VsAgent } from '@verana-labs/vs-agent-sdk';
|
|
5
|
+
export declare class MrtdMessageHandler implements MessageHandler {
|
|
6
|
+
readonly supportedTypes: MessageType[];
|
|
7
|
+
readonly openApiExamples: Record<string, {
|
|
8
|
+
summary: string;
|
|
9
|
+
description: string;
|
|
10
|
+
value: object;
|
|
11
|
+
}>;
|
|
12
|
+
handle(agent: VsAgent<any>, message: IBaseMessage, connection: DidCommConnectionRecord): Promise<string | undefined>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MrtdMessageHandler = void 0;
|
|
10
|
+
const core_1 = require("@credo-ts/core");
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
13
|
+
const EMrtdDataRequestMessage_1 = require("../model/EMrtdDataRequestMessage");
|
|
14
|
+
const MrzDataRequestMessage_1 = require("../model/MrzDataRequestMessage");
|
|
15
|
+
let MrtdMessageHandler = class MrtdMessageHandler {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.supportedTypes = [
|
|
18
|
+
vs_agent_model_1.MessageType.MrzDataRequestMessage,
|
|
19
|
+
vs_agent_model_1.MessageType.EMrtdDataRequestMessage,
|
|
20
|
+
];
|
|
21
|
+
this.openApiExamples = {
|
|
22
|
+
emrtdDataRequest: {
|
|
23
|
+
summary: 'eMRTD Data Request',
|
|
24
|
+
description: '#### eMRTD Data Request\n\nRequest the other party to read and provide eMRTD (Electronic Machine Readable Travel Document) data from a compatible electronic document.',
|
|
25
|
+
value: { type: 'emrtd-data-request' },
|
|
26
|
+
},
|
|
27
|
+
emrtdDataSubmit: {
|
|
28
|
+
summary: 'eMRTD Data Submit',
|
|
29
|
+
description: "#### eMRTD Data Submit\n\nSubmit data retrieved from an electronic Machine Readable Travel Document. This message may be sent either individually or as a response to an eMRTD Data Request.\n\nThe state can be one of 'submitted', 'declined', 'timeout' or 'error', depending on how the flow went. The latter is used for unspecified errors (e.g. User Agent not capable of handling the request).",
|
|
30
|
+
value: { type: 'emrtd-data-submit', state: 'MrtdSubmitState', dataGroups: 'EMrtdData' },
|
|
31
|
+
},
|
|
32
|
+
mrzDataRequest: {
|
|
33
|
+
summary: 'MRZ Data Request',
|
|
34
|
+
description: '#### MRZ Data Request\n\nRequest the other party to provide the Machine Readable Zone string from a valid ID document.',
|
|
35
|
+
value: { type: 'mrz-data-request' },
|
|
36
|
+
},
|
|
37
|
+
mrzDataSubmit: {
|
|
38
|
+
summary: 'MRZ Data Submit',
|
|
39
|
+
description: `
|
|
40
|
+
#### MRZ Data Submit
|
|
41
|
+
|
|
42
|
+
Submit Machine Readable Zone data. This message may be sent either individually or as a response to a MRZ Data Request.
|
|
43
|
+
|
|
44
|
+
The state can be one of \`submitted\`, \`declined\`, \`timeout\` or \`error\`, depending on how the flow went. The latter is used for unspecified errors (e.g. User Agent not capable of handling the request).
|
|
45
|
+
|
|
46
|
+
\`MrzData\` is a JSON object with two basic fields:
|
|
47
|
+
|
|
48
|
+
- \`raw\`: contains the raw data as sent by the other party (either an array of lines or a single string containing all lines, separated by \\n).
|
|
49
|
+
- \`parsed\`: interprets the contents and classifies the document in a format from ICAO 9303 document (TD1, TD2, TD3, etc.).
|
|
50
|
+
|
|
51
|
+
Example:
|
|
52
|
+
|
|
53
|
+
\`\`\`json
|
|
54
|
+
{
|
|
55
|
+
"raw": [
|
|
56
|
+
"I<UTOD23145890<1233<<<<<<<<<<<",
|
|
57
|
+
"7408122F1204159UTO<<<<<<<<<<<6",
|
|
58
|
+
"ERIKSSON<<ANNA<MARIA<<<<<<<<<<"
|
|
59
|
+
],
|
|
60
|
+
"parsed": {
|
|
61
|
+
"valid": false,
|
|
62
|
+
"fields": {
|
|
63
|
+
"documentCode": "I",
|
|
64
|
+
"issuingState": null,
|
|
65
|
+
"documentNumber": "D23145890123",
|
|
66
|
+
"documentNumberCheckDigit": "3",
|
|
67
|
+
"optional1": "1233",
|
|
68
|
+
"birthDate": "740812",
|
|
69
|
+
"birthDateCheckDigit": "2",
|
|
70
|
+
"sex": "female",
|
|
71
|
+
"expirationDate": "120415",
|
|
72
|
+
"expirationDateCheckDigit": "9",
|
|
73
|
+
"nationality": null,
|
|
74
|
+
"optional2": "",
|
|
75
|
+
"compositeCheckDigit": null,
|
|
76
|
+
"lastName": "ERIKSSON",
|
|
77
|
+
"firstName": "ANNA MARIA"
|
|
78
|
+
},
|
|
79
|
+
"format": "TD1"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
\`\`\`
|
|
83
|
+
|
|
84
|
+
More info about the meaning of each field (and validity) can be found in [MRZ](https://github.com/cheminfo/mrz), the underlying library we are using for MRZ parsing.
|
|
85
|
+
`,
|
|
86
|
+
value: { type: 'mrz-data-submit', state: 'MrtdSubmitState', mrzData: 'MrzData' },
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async handle(agent, message, connection) {
|
|
91
|
+
const messageType = message.type;
|
|
92
|
+
let messageId;
|
|
93
|
+
if (messageType === MrzDataRequestMessage_1.MrzDataRequestMessage.type) {
|
|
94
|
+
const msg = core_1.JsonTransformer.fromJSON(message, MrzDataRequestMessage_1.MrzDataRequestMessage);
|
|
95
|
+
const requestMrz = await agent.modules.mrtd.requestMrzString({
|
|
96
|
+
connectionId: connection.id,
|
|
97
|
+
parentThreadId: msg.threadId,
|
|
98
|
+
});
|
|
99
|
+
messageId = requestMrz.messageId;
|
|
100
|
+
}
|
|
101
|
+
else if (messageType === EMrtdDataRequestMessage_1.EMrtdDataRequestMessage.type) {
|
|
102
|
+
const msg = core_1.JsonTransformer.fromJSON(message, EMrtdDataRequestMessage_1.EMrtdDataRequestMessage);
|
|
103
|
+
const requestEMrtdData = await agent.modules.mrtd.requestEMrtdData({
|
|
104
|
+
connectionId: connection.id,
|
|
105
|
+
parentThreadId: msg.threadId,
|
|
106
|
+
});
|
|
107
|
+
messageId = requestEMrtdData.messageId;
|
|
108
|
+
}
|
|
109
|
+
return messageId;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
exports.MrtdMessageHandler = MrtdMessageHandler;
|
|
113
|
+
exports.MrtdMessageHandler = MrtdMessageHandler = __decorate([
|
|
114
|
+
(0, common_1.Injectable)()
|
|
115
|
+
], MrtdMessageHandler);
|
|
116
|
+
//# sourceMappingURL=MrtdMessageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrtdMessageHandler.js","sourceRoot":"","sources":["../../src/handlers/MrtdMessage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6CAAqB,CAAC,CAAA;YACpE,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC;gBAC3D,YAAY,EAAE,UAAU,CAAC,EAAE;gBAC3B,cAAc,EAAE,GAAG,CAAC,QAAQ;aAC7B,CAAC,CAAA;YACF,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;QAClC,CAAC;aAAM,IAAI,WAAW,KAAK,iDAAuB,CAAC,IAAI,EAAE,CAAC;YACxD,MAAM,GAAG,GAAG,sBAAe,CAAC,QAAQ,CAAC,OAAO,EAAE,iDAAuB,CAAC,CAAA;YACtE,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC;gBACjE,YAAY,EAAE,UAAU,CAAC,EAAE;gBAC3B,cAAc,EAAE,GAAG,CAAC,QAAQ;aAC7B,CAAC,CAAA;YACF,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAA;QACxC,CAAC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;CACF,CAAA;AAxGY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAwG9B"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { setupMrtdProtocol } from './sdk/setupMrtdProtocol';
|
|
2
|
+
export type { MrtdSdkPlugin, MrtdPluginOptions } from './sdk/setupMrtdProtocol';
|
|
3
|
+
export { MrtdPlugin } from './nestjs/MrtdPlugin';
|
|
4
|
+
export { MrtdMessageHandler } from './handlers/MrtdMessageHandler';
|
|
5
|
+
export { mrtdEvents } from './events/MrtdEvents';
|
|
6
|
+
export type { MrtdAgentModules } from './types';
|
|
7
|
+
export { MrtdSubmitState } from './model/MrtdSubmitState';
|
|
8
|
+
export { MrzDataRequestMessage } from './model/MrzDataRequestMessage';
|
|
9
|
+
export { MrzDataSubmitMessage } from './model/MrzDataSubmitMessage';
|
|
10
|
+
export type { MrzDataSubmitMessageOptions } from './model/MrzDataSubmitMessage';
|
|
11
|
+
export { EMrtdDataRequestMessage } from './model/EMrtdDataRequestMessage';
|
|
12
|
+
export { EMrtdDataSubmitMessage } from './model/EMrtdDataSubmitMessage';
|
|
13
|
+
export type { EMrtdDataSubmitMessageOptions, EMrtdRawData } from './model/EMrtdDataSubmitMessage';
|
package/build/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EMrtdDataSubmitMessage = exports.EMrtdDataRequestMessage = exports.MrzDataSubmitMessage = exports.MrzDataRequestMessage = exports.MrtdSubmitState = exports.mrtdEvents = exports.MrtdMessageHandler = exports.MrtdPlugin = exports.setupMrtdProtocol = void 0;
|
|
4
|
+
var setupMrtdProtocol_1 = require("./sdk/setupMrtdProtocol");
|
|
5
|
+
Object.defineProperty(exports, "setupMrtdProtocol", { enumerable: true, get: function () { return setupMrtdProtocol_1.setupMrtdProtocol; } });
|
|
6
|
+
var MrtdPlugin_1 = require("./nestjs/MrtdPlugin");
|
|
7
|
+
Object.defineProperty(exports, "MrtdPlugin", { enumerable: true, get: function () { return MrtdPlugin_1.MrtdPlugin; } });
|
|
8
|
+
var MrtdMessageHandler_1 = require("./handlers/MrtdMessageHandler");
|
|
9
|
+
Object.defineProperty(exports, "MrtdMessageHandler", { enumerable: true, get: function () { return MrtdMessageHandler_1.MrtdMessageHandler; } });
|
|
10
|
+
var MrtdEvents_1 = require("./events/MrtdEvents");
|
|
11
|
+
Object.defineProperty(exports, "mrtdEvents", { enumerable: true, get: function () { return MrtdEvents_1.mrtdEvents; } });
|
|
12
|
+
// Model types
|
|
13
|
+
var MrtdSubmitState_1 = require("./model/MrtdSubmitState");
|
|
14
|
+
Object.defineProperty(exports, "MrtdSubmitState", { enumerable: true, get: function () { return MrtdSubmitState_1.MrtdSubmitState; } });
|
|
15
|
+
var MrzDataRequestMessage_1 = require("./model/MrzDataRequestMessage");
|
|
16
|
+
Object.defineProperty(exports, "MrzDataRequestMessage", { enumerable: true, get: function () { return MrzDataRequestMessage_1.MrzDataRequestMessage; } });
|
|
17
|
+
var MrzDataSubmitMessage_1 = require("./model/MrzDataSubmitMessage");
|
|
18
|
+
Object.defineProperty(exports, "MrzDataSubmitMessage", { enumerable: true, get: function () { return MrzDataSubmitMessage_1.MrzDataSubmitMessage; } });
|
|
19
|
+
var EMrtdDataRequestMessage_1 = require("./model/EMrtdDataRequestMessage");
|
|
20
|
+
Object.defineProperty(exports, "EMrtdDataRequestMessage", { enumerable: true, get: function () { return EMrtdDataRequestMessage_1.EMrtdDataRequestMessage; } });
|
|
21
|
+
var EMrtdDataSubmitMessage_1 = require("./model/EMrtdDataSubmitMessage");
|
|
22
|
+
Object.defineProperty(exports, "EMrtdDataSubmitMessage", { enumerable: true, get: function () { return EMrtdDataSubmitMessage_1.EMrtdDataSubmitMessage; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,sHAAA,iBAAiB,OAAA;AAG1B,kDAAgD;AAAvC,wGAAA,UAAU,OAAA;AAEnB,oEAAkE;AAAzD,wHAAA,kBAAkB,OAAA;AAE3B,kDAAgD;AAAvC,wGAAA,UAAU,OAAA;AAInB,cAAc;AACd,2DAAyD;AAAhD,kHAAA,eAAe,OAAA;AACxB,uEAAqE;AAA5D,8HAAA,qBAAqB,OAAA;AAC9B,qEAAmE;AAA1D,4HAAA,oBAAoB,OAAA;AAE7B,2EAAyE;AAAhE,kIAAA,uBAAuB,OAAA;AAChC,yEAAuE;AAA9D,gIAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BaseMessage, BaseMessageOptions, MessageType } from '@verana-labs/vs-agent-model';
|
|
2
|
+
export declare class EMrtdDataRequestMessage extends BaseMessage {
|
|
3
|
+
constructor(options: BaseMessageOptions);
|
|
4
|
+
readonly type = MessageType.EMrtdDataRequestMessage;
|
|
5
|
+
static readonly type = MessageType.EMrtdDataRequestMessage;
|
|
6
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EMrtdDataRequestMessage = void 0;
|
|
4
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
5
|
+
class EMrtdDataRequestMessage extends vs_agent_model_1.BaseMessage {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
super();
|
|
9
|
+
this.type = EMrtdDataRequestMessage.type;
|
|
10
|
+
if (options) {
|
|
11
|
+
this.id = (_a = options.id) !== null && _a !== void 0 ? _a : this.generateId();
|
|
12
|
+
this.threadId = options.threadId;
|
|
13
|
+
this.timestamp = (_b = options.timestamp) !== null && _b !== void 0 ? _b : new Date();
|
|
14
|
+
this.connectionId = options.connectionId;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.EMrtdDataRequestMessage = EMrtdDataRequestMessage;
|
|
19
|
+
EMrtdDataRequestMessage.type = vs_agent_model_1.MessageType.EMrtdDataRequestMessage;
|
|
20
|
+
//# sourceMappingURL=EMrtdDataRequestMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EMrtdDataRequestMessage.js","sourceRoot":"","sources":["../../src/model/EMrtdDataRequestMessage.ts"],"names":[],"mappings":";;;AAAA,gEAA0F;AAE1F,MAAa,uBAAwB,SAAQ,4BAAW;IACtD,YAAmB,OAA2B;;QAC5C,KAAK,EAAE,CAAA;QAUO,SAAI,GAAG,uBAAuB,CAAC,IAAI,CAAA;QARjD,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,GAAG,MAAA,OAAO,CAAC,EAAE,mCAAI,IAAI,CAAC,UAAU,EAAE,CAAA;YACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;YAChC,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAI,IAAI,EAAE,CAAA;YAChD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;QAC1C,CAAC;IACH,CAAC;;AAVH,0DAcC;AADwB,4BAAI,GAAG,4BAAW,CAAC,uBAAuB,AAAtC,CAAsC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EMrtdData, SodVerification } from '@2060.io/credo-ts-didcomm-mrtd';
|
|
2
|
+
import { BaseMessage, BaseMessageOptions, MessageType } from '@verana-labs/vs-agent-model';
|
|
3
|
+
import { MrtdSubmitState } from './MrtdSubmitState';
|
|
4
|
+
export type EMrtdRawData = {
|
|
5
|
+
raw: Record<string, string>;
|
|
6
|
+
processed: {
|
|
7
|
+
documentType: string;
|
|
8
|
+
documentNumber?: string;
|
|
9
|
+
issuingState?: string;
|
|
10
|
+
dateOfBirth?: string;
|
|
11
|
+
dateOfExpiry?: string;
|
|
12
|
+
sex?: string;
|
|
13
|
+
nationality?: string;
|
|
14
|
+
lastName?: string;
|
|
15
|
+
firstName?: string;
|
|
16
|
+
mrzOptionalData?: string;
|
|
17
|
+
faceImages: string[];
|
|
18
|
+
nameOfHolder?: string;
|
|
19
|
+
otherNames?: string[];
|
|
20
|
+
personalNumber?: string;
|
|
21
|
+
placeOfBirth?: string[];
|
|
22
|
+
permanentAddress?: string[];
|
|
23
|
+
telephone?: string;
|
|
24
|
+
profession?: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
personalSummary?: string;
|
|
27
|
+
custodyInformation?: string;
|
|
28
|
+
mrzString?: string;
|
|
29
|
+
};
|
|
30
|
+
verification?: SodVerification;
|
|
31
|
+
};
|
|
32
|
+
export interface EMrtdDataSubmitMessageOptions extends BaseMessageOptions {
|
|
33
|
+
state: MrtdSubmitState;
|
|
34
|
+
dataGroups?: EMrtdData;
|
|
35
|
+
}
|
|
36
|
+
export declare class EMrtdDataSubmitMessage extends BaseMessage {
|
|
37
|
+
constructor(options: EMrtdDataSubmitMessageOptions);
|
|
38
|
+
readonly type = MessageType.EMrtdDataSubmitMessage;
|
|
39
|
+
static readonly type = MessageType.EMrtdDataSubmitMessage;
|
|
40
|
+
state: MrtdSubmitState;
|
|
41
|
+
dataGroups?: EMrtdRawData;
|
|
42
|
+
parseDataGroups({ raw, parsed, verification }: EMrtdData): EMrtdRawData | undefined;
|
|
43
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EMrtdDataSubmitMessage = void 0;
|
|
37
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
38
|
+
const Mrz = __importStar(require("mrz"));
|
|
39
|
+
class EMrtdDataSubmitMessage extends vs_agent_model_1.BaseMessage {
|
|
40
|
+
constructor(options) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
super();
|
|
43
|
+
this.type = EMrtdDataSubmitMessage.type;
|
|
44
|
+
if (options) {
|
|
45
|
+
this.id = (_a = options.id) !== null && _a !== void 0 ? _a : this.generateId();
|
|
46
|
+
this.threadId = options.threadId;
|
|
47
|
+
this.timestamp = (_b = options.timestamp) !== null && _b !== void 0 ? _b : new Date();
|
|
48
|
+
this.connectionId = options.connectionId;
|
|
49
|
+
if (options.dataGroups) {
|
|
50
|
+
this.dataGroups = this.parseDataGroups(options.dataGroups);
|
|
51
|
+
}
|
|
52
|
+
this.state = options.state;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
parseDataGroups({ raw, parsed, verification }) {
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
57
|
+
if (!parsed || !parsed.fields)
|
|
58
|
+
return this.dataGroups;
|
|
59
|
+
const dataUrls = parsed.fields.images.map(image => {
|
|
60
|
+
const faceMimeType = image.imageType === 1 ? 'image/jp2' : 'image/jpeg';
|
|
61
|
+
return `data:${faceMimeType};base64,${Buffer.from(image.imageData).toString('base64')}`;
|
|
62
|
+
});
|
|
63
|
+
const mrzString = parsed.fields.mrzData;
|
|
64
|
+
const formattedMrz = (len => {
|
|
65
|
+
switch (len) {
|
|
66
|
+
case 88:
|
|
67
|
+
return mrzString.slice(0, 44) + '\n' + mrzString.slice(44);
|
|
68
|
+
case 72:
|
|
69
|
+
return mrzString.slice(0, 36) + '\n' + mrzString.slice(36);
|
|
70
|
+
case 90:
|
|
71
|
+
return mrzString.slice(0, 30) + '\n' + mrzString.slice(30, 60) + '\n' + mrzString.slice(60);
|
|
72
|
+
case 30:
|
|
73
|
+
return mrzString;
|
|
74
|
+
case 18:
|
|
75
|
+
return mrzString.slice(0, 9) + '\n' + mrzString.slice(9);
|
|
76
|
+
default:
|
|
77
|
+
throw new Error(`Unrecognized MRZ length: ${len}`);
|
|
78
|
+
}
|
|
79
|
+
})(mrzString.length);
|
|
80
|
+
const parsedMrz = Mrz.parse(formattedMrz);
|
|
81
|
+
const rawSex = (_a = parsedMrz.fields.sex) !== null && _a !== void 0 ? _a : undefined;
|
|
82
|
+
const birthDateFromAdditionalPersonalData = (_b = parsed.fields.additionalPersonalData) === null || _b === void 0 ? void 0 : _b.fullDateOfBirth;
|
|
83
|
+
const dateOfBirth = !birthDateFromAdditionalPersonalData || birthDateFromAdditionalPersonalData.toString().length < 6
|
|
84
|
+
? parsedMrz.fields.birthDate
|
|
85
|
+
: birthDateFromAdditionalPersonalData === null || birthDateFromAdditionalPersonalData === void 0 ? void 0 : birthDateFromAdditionalPersonalData.toString();
|
|
86
|
+
const newEmrtdData = {
|
|
87
|
+
raw: raw,
|
|
88
|
+
processed: {
|
|
89
|
+
documentType: parsedMrz.format,
|
|
90
|
+
documentNumber: (_c = parsedMrz.documentNumber) !== null && _c !== void 0 ? _c : undefined,
|
|
91
|
+
issuingState: (_d = parsedMrz.fields.issuingState) !== null && _d !== void 0 ? _d : undefined,
|
|
92
|
+
dateOfExpiry: (0, vs_agent_model_1.convertShortDate)(parsedMrz.fields.expirationDate, true),
|
|
93
|
+
sex: rawSex ? rawSex.charAt(0).toUpperCase() : undefined,
|
|
94
|
+
nationality: (_e = parsedMrz.fields.nationality) !== null && _e !== void 0 ? _e : undefined,
|
|
95
|
+
lastName: (_f = parsedMrz.fields.lastName) !== null && _f !== void 0 ? _f : undefined,
|
|
96
|
+
firstName: (_g = parsedMrz.fields.firstName) !== null && _g !== void 0 ? _g : undefined,
|
|
97
|
+
mrzOptionalData: (_h = parsedMrz.fields.optional1) !== null && _h !== void 0 ? _h : undefined,
|
|
98
|
+
faceImages: dataUrls,
|
|
99
|
+
nameOfHolder: (_k = (_j = parsed.fields.additionalPersonalData) === null || _j === void 0 ? void 0 : _j.nameOfHolder) !== null && _k !== void 0 ? _k : `${parsedMrz.fields.lastName} ${parsedMrz.fields.firstName}`,
|
|
100
|
+
dateOfBirth: (0, vs_agent_model_1.convertShortDate)(dateOfBirth, false),
|
|
101
|
+
otherNames: (_l = parsed.fields.additionalPersonalData) === null || _l === void 0 ? void 0 : _l.otherNames,
|
|
102
|
+
personalNumber: (_m = parsed.fields.additionalPersonalData) === null || _m === void 0 ? void 0 : _m.personalNumber,
|
|
103
|
+
placeOfBirth: (_o = parsed.fields.additionalPersonalData) === null || _o === void 0 ? void 0 : _o.placeOfBirth,
|
|
104
|
+
permanentAddress: (_p = parsed.fields.additionalPersonalData) === null || _p === void 0 ? void 0 : _p.permanentAddress,
|
|
105
|
+
telephone: (_q = parsed.fields.additionalPersonalData) === null || _q === void 0 ? void 0 : _q.telephone,
|
|
106
|
+
profession: (_r = parsed.fields.additionalPersonalData) === null || _r === void 0 ? void 0 : _r.profession,
|
|
107
|
+
title: (_s = parsed.fields.additionalPersonalData) === null || _s === void 0 ? void 0 : _s.title,
|
|
108
|
+
personalSummary: (_t = parsed.fields.additionalPersonalData) === null || _t === void 0 ? void 0 : _t.personalSummary,
|
|
109
|
+
custodyInformation: (_u = parsed.fields.additionalPersonalData) === null || _u === void 0 ? void 0 : _u.custodyInformation,
|
|
110
|
+
mrzString: parsed.fields.mrzData,
|
|
111
|
+
},
|
|
112
|
+
verification,
|
|
113
|
+
};
|
|
114
|
+
return newEmrtdData;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.EMrtdDataSubmitMessage = EMrtdDataSubmitMessage;
|
|
118
|
+
EMrtdDataSubmitMessage.type = vs_agent_model_1.MessageType.EMrtdDataSubmitMessage;
|
|
119
|
+
//# sourceMappingURL=EMrtdDataSubmitMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EMrtdDataSubmitMessage.js","sourceRoot":"","sources":["../../src/model/EMrtdDataSubmitMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gEAA4G;AAC5G,yCAA0B;AAsC1B,MAAa,sBAAuB,SAAQ,4BAAW;IACrD,YAAmB,OAAsC;;QACvD,KAAK,EAAE,CAAA;QAcO,SAAI,GAAG,sBAAsB,CAAC,IAAI,CAAA;QAZhD,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,GAAG,MAAA,OAAO,CAAC,EAAE,mCAAI,IAAI,CAAC,UAAU,EAAE,CAAA;YACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;YAChC,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAI,IAAI,EAAE,CAAA;YAChD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;YACxC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;YAC5D,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QAC5B,CAAC;IACH,CAAC;IASM,eAAe,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAa;;QAC7D,IAAI,CAAC,MAAM,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perty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MrtdSubmitState = void 0;
|
|
4
|
+
var MrtdSubmitState;
|
|
5
|
+
(function (MrtdSubmitState) {
|
|
6
|
+
MrtdSubmitState["Submitted"] = "submitted";
|
|
7
|
+
MrtdSubmitState["Declined"] = "declined";
|
|
8
|
+
MrtdSubmitState["Timeout"] = "timeout";
|
|
9
|
+
MrtdSubmitState["Error"] = "error";
|
|
10
|
+
})(MrtdSubmitState || (exports.MrtdSubmitState = MrtdSubmitState = {}));
|
|
11
|
+
//# sourceMappingURL=MrtdSubmitState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrtdSubmitState.js","sourceRoot":"","sources":["../../src/model/MrtdSubmitState.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,wCAAqB,CAAA;IACrB,sCAAmB,CAAA;IACnB,kCAAe,CAAA;AACjB,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BaseMessage, BaseMessageOptions, MessageType } from '@verana-labs/vs-agent-model';
|
|
2
|
+
export declare class MrzDataRequestMessage extends BaseMessage {
|
|
3
|
+
constructor(options: BaseMessageOptions);
|
|
4
|
+
readonly type = MessageType.MrzDataRequestMessage;
|
|
5
|
+
static readonly type = MessageType.MrzDataRequestMessage;
|
|
6
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MrzDataRequestMessage = void 0;
|
|
4
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
5
|
+
class MrzDataRequestMessage extends vs_agent_model_1.BaseMessage {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
super();
|
|
9
|
+
this.type = MrzDataRequestMessage.type;
|
|
10
|
+
if (options) {
|
|
11
|
+
this.id = (_a = options.id) !== null && _a !== void 0 ? _a : this.generateId();
|
|
12
|
+
this.threadId = options.threadId;
|
|
13
|
+
this.timestamp = (_b = options.timestamp) !== null && _b !== void 0 ? _b : new Date();
|
|
14
|
+
this.connectionId = options.connectionId;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.MrzDataRequestMessage = MrzDataRequestMessage;
|
|
19
|
+
MrzDataRequestMessage.type = vs_agent_model_1.MessageType.MrzDataRequestMessage;
|
|
20
|
+
//# sourceMappingURL=MrzDataRequestMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrzDataRequestMessage.js","sourceRoot":"","sources":["../../src/model/MrzDataRequestMessage.ts"],"names":[],"mappings":";;;AAAA,gEAA0F;AAE1F,MAAa,qBAAsB,SAAQ,4BAAW;IACpD,YAAmB,OAA2B;;QAC5C,KAAK,EAAE,CAAA;QAUO,SAAI,GAAG,qBAAqB,CAAC,IAAI,CAAA;QAR/C,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,GAAG,MAAA,OAAO,CAAC,EAAE,mCAAI,IAAI,CAAC,UAAU,EAAE,CAAA;YACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;YAChC,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAI,IAAI,EAAE,CAAA;YAChD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;QAC1C,CAAC;IACH,CAAC;;AAVH,sDAcC;AADwB,0BAAI,GAAG,4BAAW,CAAC,qBAAqB,AAApC,CAAoC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MrzData } from '@2060.io/credo-ts-didcomm-mrtd';
|
|
2
|
+
import { BaseMessage, BaseMessageOptions, MessageType } from '@verana-labs/vs-agent-model';
|
|
3
|
+
import { MrtdSubmitState } from './MrtdSubmitState';
|
|
4
|
+
export interface MrzDataSubmitMessageOptions extends BaseMessageOptions {
|
|
5
|
+
state: MrtdSubmitState;
|
|
6
|
+
mrzData?: MrzData;
|
|
7
|
+
}
|
|
8
|
+
export declare class MrzDataSubmitMessage extends BaseMessage {
|
|
9
|
+
constructor(options: MrzDataSubmitMessageOptions);
|
|
10
|
+
readonly type = MessageType.MrzDataSubmitMessage;
|
|
11
|
+
static readonly type = MessageType.MrzDataSubmitMessage;
|
|
12
|
+
mrzData?: MrzData;
|
|
13
|
+
state: MrtdSubmitState;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MrzDataSubmitMessage = void 0;
|
|
4
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
5
|
+
class MrzDataSubmitMessage extends vs_agent_model_1.BaseMessage {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
super();
|
|
9
|
+
this.type = MrzDataSubmitMessage.type;
|
|
10
|
+
if (options) {
|
|
11
|
+
this.id = (_a = options.id) !== null && _a !== void 0 ? _a : this.generateId();
|
|
12
|
+
this.threadId = options.threadId;
|
|
13
|
+
this.timestamp = (_b = options.timestamp) !== null && _b !== void 0 ? _b : new Date();
|
|
14
|
+
this.connectionId = options.connectionId;
|
|
15
|
+
this.mrzData = options.mrzData;
|
|
16
|
+
this.state = options.state;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.MrzDataSubmitMessage = MrzDataSubmitMessage;
|
|
21
|
+
MrzDataSubmitMessage.type = vs_agent_model_1.MessageType.MrzDataSubmitMessage;
|
|
22
|
+
//# sourceMappingURL=MrzDataSubmitMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrzDataSubmitMessage.js","sourceRoot":"","sources":["../../src/model/MrzDataSubmitMessage.ts"],"names":[],"mappings":";;;AACA,gEAA0F;AAS1F,MAAa,oBAAqB,SAAQ,4BAAW;IACnD,YAAmB,OAAoC;;QACrD,KAAK,EAAE,CAAA;QAYO,SAAI,GAAG,oBAAoB,CAAC,IAAI,CAAA;QAV9C,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,GAAG,MAAA,OAAO,CAAC,EAAE,mCAAI,IAAI,CAAC,UAAU,EAAE,CAAA;YACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;YAChC,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAI,IAAI,EAAE,CAAA;YAChD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;YACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;YAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QAC5B,CAAC;IACH,CAAC;;AAZH,oDAoBC;AALwB,yBAAI,GAAG,4BAAW,CAAC,oBAAoB,AAAnC,CAAmC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MrtdPlugin = void 0;
|
|
4
|
+
const MrtdEvents_1 = require("../events/MrtdEvents");
|
|
5
|
+
const MrtdMessageHandler_1 = require("../handlers/MrtdMessageHandler");
|
|
6
|
+
const setupMrtdProtocol_1 = require("../sdk/setupMrtdProtocol");
|
|
7
|
+
const MrtdPlugin = (options) => ({
|
|
8
|
+
name: 'mrtd',
|
|
9
|
+
credoPlugin: (0, setupMrtdProtocol_1.setupMrtdProtocol)(options),
|
|
10
|
+
providers: [MrtdMessageHandler_1.MrtdMessageHandler],
|
|
11
|
+
messageHandlers: [MrtdMessageHandler_1.MrtdMessageHandler],
|
|
12
|
+
registerEvents: (agent, config) => {
|
|
13
|
+
(0, MrtdEvents_1.mrtdEvents)(agent, config);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
exports.MrtdPlugin = MrtdPlugin;
|
|
17
|
+
//# sourceMappingURL=MrtdPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrtdPlugin.js","sourceRoot":"","sources":["../../src/nestjs/MrtdPlugin.ts"],"names":[],"mappings":";;;AAEA,qDAAiD;AACjD,uEAAmE;AACnE,gEAA+E;AAExE,MAAM,UAAU,GAAG,CAAC,OAA2B,EAAqB,EAAE,CAAC,CAAC;IAC7E,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,IAAA,qCAAiB,EAAC,OAAO,CAAC;IACvC,SAAS,EAAE,CAAC,uCAAkB,CAAC;IAC/B,eAAe,EAAE,CAAC,uCAAkB,CAAC;IACrC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAChC,IAAA,uBAAU,EAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAC3B,CAAC;CACF,CAAC,CAAA;AARW,QAAA,UAAU,cAQrB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MrtdAgentModules } from '../types';
|
|
2
|
+
export interface MrtdPluginOptions {
|
|
3
|
+
masterListCscaLocation?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface MrtdSdkPlugin {
|
|
6
|
+
modules: Pick<MrtdAgentModules, 'mrtd'>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Sets up the eMRTD (electronic passport / travel document) DIDComm protocol module.
|
|
10
|
+
* This is kept as a separate plugin because it introduces native binary dependencies.
|
|
11
|
+
* Must be used together with setupBaseDidComm().
|
|
12
|
+
*/
|
|
13
|
+
export declare function setupMrtdProtocol(options?: MrtdPluginOptions): MrtdSdkPlugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupMrtdProtocol = setupMrtdProtocol;
|
|
4
|
+
const credo_ts_didcomm_mrtd_1 = require("@2060.io/credo-ts-didcomm-mrtd");
|
|
5
|
+
/**
|
|
6
|
+
* Sets up the eMRTD (electronic passport / travel document) DIDComm protocol module.
|
|
7
|
+
* This is kept as a separate plugin because it introduces native binary dependencies.
|
|
8
|
+
* Must be used together with setupBaseDidComm().
|
|
9
|
+
*/
|
|
10
|
+
function setupMrtdProtocol(options) {
|
|
11
|
+
return {
|
|
12
|
+
modules: {
|
|
13
|
+
mrtd: new credo_ts_didcomm_mrtd_1.DidCommMrtdModule({ masterListCscaLocation: options === null || options === void 0 ? void 0 : options.masterListCscaLocation }),
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=setupMrtdProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupMrtdProtocol.js","sourceRoot":"","sources":["../../src/sdk/setupMrtdProtocol.ts"],"names":[],"mappings":";;AAiBA,8CAMC;AAvBD,0EAAkE;AAYlE;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,OAA2B;IAC3D,OAAO;QACL,OAAO,EAAE;YACP,IAAI,EAAE,IAAI,yCAAiB,CAAC,EAAE,sBAAsB,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,sBAAsB,EAAE,CAAC;SACzF;KACF,CAAA;AACH,CAAC"}
|
package/build/types.d.ts
ADDED
package/build/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@verana-labs/vs-agent-plugin-mrtd",
|
|
3
|
+
"main": "build/index",
|
|
4
|
+
"types": "build/index",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./build/index.d.ts",
|
|
8
|
+
"require": "./build/index.js",
|
|
9
|
+
"default": "./build/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"version": "1.10.1",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/verana-labs/vs-agent"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"build"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"description": "MRTD DIDComm plugin for VS Agent",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@2060.io/credo-ts-didcomm-mrtd": "0.1.1",
|
|
27
|
+
"@credo-ts/core": "0.7.0-alpha-20260410113934",
|
|
28
|
+
"@credo-ts/didcomm": "0.7.0-alpha-20260410113934",
|
|
29
|
+
"@nestjs/common": "^10.0.0",
|
|
30
|
+
"@types/node-tlv": "^1.5.4",
|
|
31
|
+
"mrz": "^4.2.0",
|
|
32
|
+
"@verana-labs/vs-agent-sdk": "1.10.1",
|
|
33
|
+
"@verana-labs/vs-agent-model": "1.10.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@credo-ts/core": "0.7.0-alpha-20260410113934"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "pnpm run clean && pnpm run compile",
|
|
40
|
+
"clean": "rimraf -rf ./build",
|
|
41
|
+
"compile": "tsc -p tsconfig.build.json",
|
|
42
|
+
"version": "pnpm version --allow-same-version",
|
|
43
|
+
"test": "vitest"
|
|
44
|
+
}
|
|
45
|
+
}
|