@authme/id-recognition 2.2.1-rc.1 → 2.2.1-rc.3
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/index.cjs +263 -0
- package/index.js +219 -0
- package/package.json +10 -12
- package/src/index.d.ts +7 -6
- package/src/lib/data-access/api.d.ts +19 -19
- package/src/lib/data-access/index.d.ts +1 -1
- package/src/lib/enum/id-recognition.enum.d.ts +29 -29
- package/src/lib/enum/index.d.ts +1 -1
- package/src/lib/interface/id-recognition-type.interface.d.ts +74 -74
- package/src/lib/interface/index.d.ts +1 -1
- package/src/lib/model/dto.model.d.ts +17 -17
- package/src/lib/model/id-type.enum.d.ts +13 -13
- package/src/lib/model/index.d.ts +2 -2
- package/src/lib/modules-id-recognition-feature-id-recognition.d.ts +18 -18
- package/src/lib/util.d.ts +7 -7
- package/src/lib/version.d.ts +1 -0
- package/CHANGELOG.md +0 -206
- package/src/index.js +0 -10
- package/src/index.js.map +0 -1
- package/src/lib/data-access/api.js +0 -72
- package/src/lib/data-access/api.js.map +0 -1
- package/src/lib/data-access/index.js +0 -5
- package/src/lib/data-access/index.js.map +0 -1
- package/src/lib/enum/id-recognition.enum.js +0 -44
- package/src/lib/enum/id-recognition.enum.js.map +0 -1
- package/src/lib/enum/index.js +0 -5
- package/src/lib/enum/index.js.map +0 -1
- package/src/lib/interface/id-recognition-type.interface.js +0 -3
- package/src/lib/interface/id-recognition-type.interface.js.map +0 -1
- package/src/lib/interface/index.js +0 -5
- package/src/lib/interface/index.js.map +0 -1
- package/src/lib/model/dto.model.js +0 -3
- package/src/lib/model/dto.model.js.map +0 -1
- package/src/lib/model/id-type.enum.js +0 -29
- package/src/lib/model/id-type.enum.js.map +0 -1
- package/src/lib/model/index.js +0 -6
- package/src/lib/model/index.js.map +0 -1
- package/src/lib/modules-id-recognition-feature-id-recognition.js +0 -45
- package/src/lib/modules-id-recognition-feature-id-recognition.js.map +0 -1
- package/src/lib/util.js +0 -72
- package/src/lib/util.js.map +0 -1
package/index.cjs
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var engine = require('@authme/engine');
|
|
6
|
+
require('core-js/modules/es.array.iterator.js');
|
|
7
|
+
require('core-js/modules/es.object.from-entries.js');
|
|
8
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
+
var core = require('@authme/core');
|
|
10
|
+
require('core-js/modules/es.symbol.description.js');
|
|
11
|
+
|
|
12
|
+
exports.ResourceImageType = void 0;
|
|
13
|
+
(function (ResourceImageType) {
|
|
14
|
+
ResourceImageType["Recognition"] = "Recognition";
|
|
15
|
+
ResourceImageType["Fraud"] = "Fraud";
|
|
16
|
+
ResourceImageType["Manual"] = "Manual";
|
|
17
|
+
})(exports.ResourceImageType || (exports.ResourceImageType = {}));
|
|
18
|
+
exports.CountryCode = void 0;
|
|
19
|
+
(function (CountryCode) {
|
|
20
|
+
CountryCode["TWN"] = "TWN";
|
|
21
|
+
})(exports.CountryCode || (exports.CountryCode = {}));
|
|
22
|
+
exports.IdRecognitionCardType = void 0;
|
|
23
|
+
(function (IdRecognitionCardType) {
|
|
24
|
+
IdRecognitionCardType["IDCard"] = "IDCard";
|
|
25
|
+
IdRecognitionCardType["DriverLicense"] = "DriverLicense";
|
|
26
|
+
IdRecognitionCardType["HealthCard"] = "HealthCard";
|
|
27
|
+
IdRecognitionCardType["ResidentCard"] = "ResidentCard";
|
|
28
|
+
IdRecognitionCardType["Passport"] = "Passport";
|
|
29
|
+
})(exports.IdRecognitionCardType || (exports.IdRecognitionCardType = {}));
|
|
30
|
+
exports.ServerSideEAuthMeCardClass = void 0;
|
|
31
|
+
(function (ServerSideEAuthMeCardClass) {
|
|
32
|
+
ServerSideEAuthMeCardClass["Invalid"] = "Invalid";
|
|
33
|
+
ServerSideEAuthMeCardClass["Unknown"] = "UnknownCard";
|
|
34
|
+
ServerSideEAuthMeCardClass["Passport"] = "Passport";
|
|
35
|
+
ServerSideEAuthMeCardClass["TWN_IDCard_Front"] = "TWN_IDCard_Front";
|
|
36
|
+
ServerSideEAuthMeCardClass["TWN_IDCard_Back"] = "TWN_IDCard_Back";
|
|
37
|
+
ServerSideEAuthMeCardClass["TWN_DriverLicense_Front"] = "TWN_DriverLicense_Front";
|
|
38
|
+
ServerSideEAuthMeCardClass["TWN_DriverLicense_Back"] = "TWN_DriverLicense_Back";
|
|
39
|
+
ServerSideEAuthMeCardClass["TWN_ResidentCard_Front"] = "TWN_ResidentCard_Front";
|
|
40
|
+
ServerSideEAuthMeCardClass["TWN_ResidentCard_Back"] = "TWN_ResidentCard_Back";
|
|
41
|
+
ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
|
|
42
|
+
ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
|
|
43
|
+
})(exports.ServerSideEAuthMeCardClass || (exports.ServerSideEAuthMeCardClass = {}));
|
|
44
|
+
|
|
45
|
+
class CardOCR extends engine.AuthmeEngineModuleBase {
|
|
46
|
+
constructor(engine$1) {
|
|
47
|
+
super(engine$1);
|
|
48
|
+
this.type = engine.EAuthMeCardClass.Invalid;
|
|
49
|
+
this.moduleName = engine.EngineModule.CardOCR;
|
|
50
|
+
}
|
|
51
|
+
setType(type) {
|
|
52
|
+
this.type = type;
|
|
53
|
+
return this.engine.run(this.moduleName, 'setType', {
|
|
54
|
+
type
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getType() {
|
|
58
|
+
return this.type;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
|
|
62
|
+
constructor(engine$1) {
|
|
63
|
+
super(engine$1);
|
|
64
|
+
this.moduleName = engine.EngineModule.IdCardAntiFraud;
|
|
65
|
+
}
|
|
66
|
+
setStage(stageList) {
|
|
67
|
+
const stageStrList = stageList.map(x => x.split('_')[1]);
|
|
68
|
+
return this.engine.run(this.moduleName, 'setStage', stageStrList);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
class MRZService extends engine.AuthmeEngineModuleBase {
|
|
72
|
+
constructor(engine$1) {
|
|
73
|
+
super(engine$1);
|
|
74
|
+
this.moduleName = engine.EngineModule.PassportService;
|
|
75
|
+
}
|
|
76
|
+
getFinalResult() {
|
|
77
|
+
return this.engine.run(this.moduleName, 'getFinalResult');
|
|
78
|
+
}
|
|
79
|
+
toJson(params) {
|
|
80
|
+
return this.engine.run(this.moduleName, 'toJson', params);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
exports.IdType = void 0;
|
|
85
|
+
(function (IdType) {
|
|
86
|
+
IdType["IdCard"] = "IDCard";
|
|
87
|
+
IdType["DriverLicense"] = "DriverLicense";
|
|
88
|
+
IdType["HealthCard"] = "HealthCard";
|
|
89
|
+
IdType["Passport"] = "Passport";
|
|
90
|
+
})(exports.IdType || (exports.IdType = {}));
|
|
91
|
+
const IdTypeConfig = {
|
|
92
|
+
[exports.IdType.IdCard]: {
|
|
93
|
+
front: true,
|
|
94
|
+
back: true
|
|
95
|
+
},
|
|
96
|
+
[exports.IdType.Passport]: {
|
|
97
|
+
front: true,
|
|
98
|
+
back: true
|
|
99
|
+
},
|
|
100
|
+
[exports.IdType.HealthCard]: {
|
|
101
|
+
front: true,
|
|
102
|
+
back: false
|
|
103
|
+
},
|
|
104
|
+
[exports.IdType.DriverLicense]: {
|
|
105
|
+
front: true,
|
|
106
|
+
back: true
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const CardTypeMapping = {
|
|
111
|
+
[exports.IdRecognitionCardType.IDCard]: [engine.EAuthMeCardClass.TWN_IDCard_Front, engine.EAuthMeCardClass.TWN_IDCard_Back],
|
|
112
|
+
[exports.IdRecognitionCardType.HealthCard]: [engine.EAuthMeCardClass.TWN_HealthCard_Front],
|
|
113
|
+
[exports.IdRecognitionCardType.Passport]: [engine.EAuthMeCardClass.Passport],
|
|
114
|
+
[exports.IdRecognitionCardType.ResidentCard]: [engine.EAuthMeCardClass.TWN_ResidentCard_Front, engine.EAuthMeCardClass.TWN_ResidentCard_Back],
|
|
115
|
+
[exports.IdRecognitionCardType.DriverLicense]: [engine.EAuthMeCardClass.TWN_DriverLicense_Front, engine.EAuthMeCardClass.TWN_DriverLicense_Back]
|
|
116
|
+
};
|
|
117
|
+
const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'name', 'gender', 'dateOfBirth', 'idNumber', 'dateOfIssue', 'issueCity', 'issueReason', 'father', 'mother', 'spouse', 'militaryService', 'placeOfBirth', 'serialNumber', 'expiry', 'controlNo', 'type', 'condition', 'address', 'country', 'documentNumber', 'documentType', 'nationality', 'expiryDate'].map((value, index) => [value, index]));
|
|
118
|
+
function getCardSubTypes(type, country) {
|
|
119
|
+
return CardTypeMapping[type];
|
|
120
|
+
}
|
|
121
|
+
function getRecognitionColumnOrder(column) {
|
|
122
|
+
var _a;
|
|
123
|
+
return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
|
|
124
|
+
}
|
|
125
|
+
const twoWayAuthmeCardClassMap = (() => {
|
|
126
|
+
const map = Object.fromEntries(Object.entries(exports.ServerSideEAuthMeCardClass).map(([key, value]) => [`EAuthMeCardClass_${key}`, value]));
|
|
127
|
+
const inverted = Object.fromEntries(Object.entries(map).map(([key, value]) => [value, key]));
|
|
128
|
+
return {
|
|
129
|
+
toServer(clientEnum) {
|
|
130
|
+
return map[clientEnum];
|
|
131
|
+
},
|
|
132
|
+
toClient(serverEnum) {
|
|
133
|
+
return inverted[serverEnum];
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
})();
|
|
137
|
+
|
|
138
|
+
function init(type, country, needConfirm) {
|
|
139
|
+
const body = {
|
|
140
|
+
scanType: type === exports.IdRecognitionCardType.Passport ? type : `${country}_${type}`,
|
|
141
|
+
cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
|
|
142
|
+
needConfirm
|
|
143
|
+
};
|
|
144
|
+
return core.sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
|
|
145
|
+
body: JSON.stringify(body)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function initScanDocument(scanId, cardType) {
|
|
149
|
+
const body = {
|
|
150
|
+
scanId,
|
|
151
|
+
cardType
|
|
152
|
+
};
|
|
153
|
+
return core.sendRequest('/api/identity-verification/id-recognition/v3/init-scan-doc', 'POST', {
|
|
154
|
+
body: JSON.stringify(body)
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function recognition(documentId, file) {
|
|
158
|
+
const formData = new FormData();
|
|
159
|
+
formData.append('scanDocumentId', documentId);
|
|
160
|
+
formData.append('image', file);
|
|
161
|
+
return core.sendRequest('/api/identity-verification/id-recognition/v3/recognize', 'POST', {
|
|
162
|
+
body: formData,
|
|
163
|
+
contentType: 'multipart/form-data'
|
|
164
|
+
}).catch(error => {
|
|
165
|
+
var _a, _b, _c;
|
|
166
|
+
if (error instanceof core.AuthmeError && ((_c = (_b = (_a = error.cause) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.code) === 'AuthMe.IDRecognition:000201') {
|
|
167
|
+
return {
|
|
168
|
+
retry: true,
|
|
169
|
+
details: {}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
throw error;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function saveResourceImage(documentId, type, file) {
|
|
176
|
+
const formData = new FormData();
|
|
177
|
+
formData.append('scanDocumentId', documentId);
|
|
178
|
+
formData.append('type', type);
|
|
179
|
+
formData.append('image', file);
|
|
180
|
+
return core.sendRequest('/api/identity-verification/id-recognition/v3/upload-image', 'POST', {
|
|
181
|
+
body: formData,
|
|
182
|
+
contentType: 'multipart/form-data'
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function finishScanDocument(documentId, details, fraud) {
|
|
186
|
+
const body = {
|
|
187
|
+
scanDocumentId: documentId,
|
|
188
|
+
details,
|
|
189
|
+
fraud
|
|
190
|
+
};
|
|
191
|
+
return core.sendRequest('/api/identity-verification/id-recognition/v3/finish-scan-doc', 'POST', {
|
|
192
|
+
body: JSON.stringify(body)
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function confirmScan(scanId, details) {
|
|
196
|
+
const body = {
|
|
197
|
+
scanId,
|
|
198
|
+
details
|
|
199
|
+
};
|
|
200
|
+
return core.sendRequest('/api/identity-verification/id-recognition/v3/confirm-scan', 'POST', {
|
|
201
|
+
body: JSON.stringify(body)
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
var name = "@authme/id-recognition";
|
|
206
|
+
var version$1 = "2.2.1-rc.3";
|
|
207
|
+
var peerDependencies = {
|
|
208
|
+
"core-js": "^3.6.0"
|
|
209
|
+
};
|
|
210
|
+
var packageInfo = {
|
|
211
|
+
name: name,
|
|
212
|
+
version: version$1,
|
|
213
|
+
peerDependencies: peerDependencies
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
var _a;
|
|
217
|
+
var _b, _c;
|
|
218
|
+
const version = packageInfo.version;
|
|
219
|
+
(_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
|
|
220
|
+
window[Symbol.for('authme-sdk')][packageInfo.name] = version;
|
|
221
|
+
|
|
222
|
+
Object.defineProperty(exports, 'EAuthMeCardClass', {
|
|
223
|
+
enumerable: true,
|
|
224
|
+
get: function () { return engine.EAuthMeCardClass; }
|
|
225
|
+
});
|
|
226
|
+
Object.defineProperty(exports, 'EAuthMeCardMatchStatus', {
|
|
227
|
+
enumerable: true,
|
|
228
|
+
get: function () { return engine.EAuthMeCardMatchStatus; }
|
|
229
|
+
});
|
|
230
|
+
Object.defineProperty(exports, 'EAuthMeCardOCRStatus', {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function () { return engine.EAuthMeCardOCRStatus; }
|
|
233
|
+
});
|
|
234
|
+
Object.defineProperty(exports, 'EAuthMeIDCardAntiFraudStage', {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
get: function () { return engine.EAuthMeIDCardAntiFraudStage; }
|
|
237
|
+
});
|
|
238
|
+
Object.defineProperty(exports, 'EAuthMeIDCardAntiFraudStatus', {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
get: function () { return engine.EAuthMeIDCardAntiFraudStatus; }
|
|
241
|
+
});
|
|
242
|
+
Object.defineProperty(exports, 'EAuthMeMRZRecogStatus', {
|
|
243
|
+
enumerable: true,
|
|
244
|
+
get: function () { return engine.EAuthMeMRZRecogStatus; }
|
|
245
|
+
});
|
|
246
|
+
Object.defineProperty(exports, 'EAuthMePassportServiceStatus', {
|
|
247
|
+
enumerable: true,
|
|
248
|
+
get: function () { return engine.EAuthMePassportServiceStatus; }
|
|
249
|
+
});
|
|
250
|
+
exports.CardOCR = CardOCR;
|
|
251
|
+
exports.IdCardAntiFraudService = IdCardAntiFraudService;
|
|
252
|
+
exports.IdTypeConfig = IdTypeConfig;
|
|
253
|
+
exports.MRZService = MRZService;
|
|
254
|
+
exports.confirmScan = confirmScan;
|
|
255
|
+
exports.finishScanDocument = finishScanDocument;
|
|
256
|
+
exports.getCardSubTypes = getCardSubTypes;
|
|
257
|
+
exports.getRecognitionColumnOrder = getRecognitionColumnOrder;
|
|
258
|
+
exports.init = init;
|
|
259
|
+
exports.initScanDocument = initScanDocument;
|
|
260
|
+
exports.recognition = recognition;
|
|
261
|
+
exports.saveResourceImage = saveResourceImage;
|
|
262
|
+
exports.twoWayAuthmeCardClassMap = twoWayAuthmeCardClassMap;
|
|
263
|
+
exports.version = version;
|
package/index.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { AuthmeEngineModuleBase, EAuthMeCardClass, EngineModule } from '@authme/engine';
|
|
2
|
+
export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMePassportServiceStatus } from '@authme/engine';
|
|
3
|
+
import 'core-js/modules/es.array.iterator.js';
|
|
4
|
+
import 'core-js/modules/es.object.from-entries.js';
|
|
5
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
6
|
+
import { sendRequest, AuthmeError } from '@authme/core';
|
|
7
|
+
import 'core-js/modules/es.symbol.description.js';
|
|
8
|
+
|
|
9
|
+
var ResourceImageType;
|
|
10
|
+
(function (ResourceImageType) {
|
|
11
|
+
ResourceImageType["Recognition"] = "Recognition";
|
|
12
|
+
ResourceImageType["Fraud"] = "Fraud";
|
|
13
|
+
ResourceImageType["Manual"] = "Manual";
|
|
14
|
+
})(ResourceImageType || (ResourceImageType = {}));
|
|
15
|
+
var CountryCode;
|
|
16
|
+
(function (CountryCode) {
|
|
17
|
+
CountryCode["TWN"] = "TWN";
|
|
18
|
+
})(CountryCode || (CountryCode = {}));
|
|
19
|
+
var IdRecognitionCardType;
|
|
20
|
+
(function (IdRecognitionCardType) {
|
|
21
|
+
IdRecognitionCardType["IDCard"] = "IDCard";
|
|
22
|
+
IdRecognitionCardType["DriverLicense"] = "DriverLicense";
|
|
23
|
+
IdRecognitionCardType["HealthCard"] = "HealthCard";
|
|
24
|
+
IdRecognitionCardType["ResidentCard"] = "ResidentCard";
|
|
25
|
+
IdRecognitionCardType["Passport"] = "Passport";
|
|
26
|
+
})(IdRecognitionCardType || (IdRecognitionCardType = {}));
|
|
27
|
+
var ServerSideEAuthMeCardClass;
|
|
28
|
+
(function (ServerSideEAuthMeCardClass) {
|
|
29
|
+
ServerSideEAuthMeCardClass["Invalid"] = "Invalid";
|
|
30
|
+
ServerSideEAuthMeCardClass["Unknown"] = "UnknownCard";
|
|
31
|
+
ServerSideEAuthMeCardClass["Passport"] = "Passport";
|
|
32
|
+
ServerSideEAuthMeCardClass["TWN_IDCard_Front"] = "TWN_IDCard_Front";
|
|
33
|
+
ServerSideEAuthMeCardClass["TWN_IDCard_Back"] = "TWN_IDCard_Back";
|
|
34
|
+
ServerSideEAuthMeCardClass["TWN_DriverLicense_Front"] = "TWN_DriverLicense_Front";
|
|
35
|
+
ServerSideEAuthMeCardClass["TWN_DriverLicense_Back"] = "TWN_DriverLicense_Back";
|
|
36
|
+
ServerSideEAuthMeCardClass["TWN_ResidentCard_Front"] = "TWN_ResidentCard_Front";
|
|
37
|
+
ServerSideEAuthMeCardClass["TWN_ResidentCard_Back"] = "TWN_ResidentCard_Back";
|
|
38
|
+
ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
|
|
39
|
+
ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
|
|
40
|
+
})(ServerSideEAuthMeCardClass || (ServerSideEAuthMeCardClass = {}));
|
|
41
|
+
|
|
42
|
+
class CardOCR extends AuthmeEngineModuleBase {
|
|
43
|
+
constructor(engine) {
|
|
44
|
+
super(engine);
|
|
45
|
+
this.type = EAuthMeCardClass.Invalid;
|
|
46
|
+
this.moduleName = EngineModule.CardOCR;
|
|
47
|
+
}
|
|
48
|
+
setType(type) {
|
|
49
|
+
this.type = type;
|
|
50
|
+
return this.engine.run(this.moduleName, 'setType', {
|
|
51
|
+
type
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getType() {
|
|
55
|
+
return this.type;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
class IdCardAntiFraudService extends AuthmeEngineModuleBase {
|
|
59
|
+
constructor(engine) {
|
|
60
|
+
super(engine);
|
|
61
|
+
this.moduleName = EngineModule.IdCardAntiFraud;
|
|
62
|
+
}
|
|
63
|
+
setStage(stageList) {
|
|
64
|
+
const stageStrList = stageList.map(x => x.split('_')[1]);
|
|
65
|
+
return this.engine.run(this.moduleName, 'setStage', stageStrList);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
class MRZService extends AuthmeEngineModuleBase {
|
|
69
|
+
constructor(engine) {
|
|
70
|
+
super(engine);
|
|
71
|
+
this.moduleName = EngineModule.PassportService;
|
|
72
|
+
}
|
|
73
|
+
getFinalResult() {
|
|
74
|
+
return this.engine.run(this.moduleName, 'getFinalResult');
|
|
75
|
+
}
|
|
76
|
+
toJson(params) {
|
|
77
|
+
return this.engine.run(this.moduleName, 'toJson', params);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var IdType;
|
|
82
|
+
(function (IdType) {
|
|
83
|
+
IdType["IdCard"] = "IDCard";
|
|
84
|
+
IdType["DriverLicense"] = "DriverLicense";
|
|
85
|
+
IdType["HealthCard"] = "HealthCard";
|
|
86
|
+
IdType["Passport"] = "Passport";
|
|
87
|
+
})(IdType || (IdType = {}));
|
|
88
|
+
const IdTypeConfig = {
|
|
89
|
+
[IdType.IdCard]: {
|
|
90
|
+
front: true,
|
|
91
|
+
back: true
|
|
92
|
+
},
|
|
93
|
+
[IdType.Passport]: {
|
|
94
|
+
front: true,
|
|
95
|
+
back: true
|
|
96
|
+
},
|
|
97
|
+
[IdType.HealthCard]: {
|
|
98
|
+
front: true,
|
|
99
|
+
back: false
|
|
100
|
+
},
|
|
101
|
+
[IdType.DriverLicense]: {
|
|
102
|
+
front: true,
|
|
103
|
+
back: true
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const CardTypeMapping = {
|
|
108
|
+
[IdRecognitionCardType.IDCard]: [EAuthMeCardClass.TWN_IDCard_Front, EAuthMeCardClass.TWN_IDCard_Back],
|
|
109
|
+
[IdRecognitionCardType.HealthCard]: [EAuthMeCardClass.TWN_HealthCard_Front],
|
|
110
|
+
[IdRecognitionCardType.Passport]: [EAuthMeCardClass.Passport],
|
|
111
|
+
[IdRecognitionCardType.ResidentCard]: [EAuthMeCardClass.TWN_ResidentCard_Front, EAuthMeCardClass.TWN_ResidentCard_Back],
|
|
112
|
+
[IdRecognitionCardType.DriverLicense]: [EAuthMeCardClass.TWN_DriverLicense_Front, EAuthMeCardClass.TWN_DriverLicense_Back]
|
|
113
|
+
};
|
|
114
|
+
const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'name', 'gender', 'dateOfBirth', 'idNumber', 'dateOfIssue', 'issueCity', 'issueReason', 'father', 'mother', 'spouse', 'militaryService', 'placeOfBirth', 'serialNumber', 'expiry', 'controlNo', 'type', 'condition', 'address', 'country', 'documentNumber', 'documentType', 'nationality', 'expiryDate'].map((value, index) => [value, index]));
|
|
115
|
+
function getCardSubTypes(type, country) {
|
|
116
|
+
return CardTypeMapping[type];
|
|
117
|
+
}
|
|
118
|
+
function getRecognitionColumnOrder(column) {
|
|
119
|
+
var _a;
|
|
120
|
+
return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
|
|
121
|
+
}
|
|
122
|
+
const twoWayAuthmeCardClassMap = (() => {
|
|
123
|
+
const map = Object.fromEntries(Object.entries(ServerSideEAuthMeCardClass).map(([key, value]) => [`EAuthMeCardClass_${key}`, value]));
|
|
124
|
+
const inverted = Object.fromEntries(Object.entries(map).map(([key, value]) => [value, key]));
|
|
125
|
+
return {
|
|
126
|
+
toServer(clientEnum) {
|
|
127
|
+
return map[clientEnum];
|
|
128
|
+
},
|
|
129
|
+
toClient(serverEnum) {
|
|
130
|
+
return inverted[serverEnum];
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
})();
|
|
134
|
+
|
|
135
|
+
function init(type, country, needConfirm) {
|
|
136
|
+
const body = {
|
|
137
|
+
scanType: type === IdRecognitionCardType.Passport ? type : `${country}_${type}`,
|
|
138
|
+
cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
|
|
139
|
+
needConfirm
|
|
140
|
+
};
|
|
141
|
+
return sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
|
|
142
|
+
body: JSON.stringify(body)
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function initScanDocument(scanId, cardType) {
|
|
146
|
+
const body = {
|
|
147
|
+
scanId,
|
|
148
|
+
cardType
|
|
149
|
+
};
|
|
150
|
+
return sendRequest('/api/identity-verification/id-recognition/v3/init-scan-doc', 'POST', {
|
|
151
|
+
body: JSON.stringify(body)
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function recognition(documentId, file) {
|
|
155
|
+
const formData = new FormData();
|
|
156
|
+
formData.append('scanDocumentId', documentId);
|
|
157
|
+
formData.append('image', file);
|
|
158
|
+
return sendRequest('/api/identity-verification/id-recognition/v3/recognize', 'POST', {
|
|
159
|
+
body: formData,
|
|
160
|
+
contentType: 'multipart/form-data'
|
|
161
|
+
}).catch(error => {
|
|
162
|
+
var _a, _b, _c;
|
|
163
|
+
if (error instanceof AuthmeError && ((_c = (_b = (_a = error.cause) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.code) === 'AuthMe.IDRecognition:000201') {
|
|
164
|
+
return {
|
|
165
|
+
retry: true,
|
|
166
|
+
details: {}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
throw error;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function saveResourceImage(documentId, type, file) {
|
|
173
|
+
const formData = new FormData();
|
|
174
|
+
formData.append('scanDocumentId', documentId);
|
|
175
|
+
formData.append('type', type);
|
|
176
|
+
formData.append('image', file);
|
|
177
|
+
return sendRequest('/api/identity-verification/id-recognition/v3/upload-image', 'POST', {
|
|
178
|
+
body: formData,
|
|
179
|
+
contentType: 'multipart/form-data'
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function finishScanDocument(documentId, details, fraud) {
|
|
183
|
+
const body = {
|
|
184
|
+
scanDocumentId: documentId,
|
|
185
|
+
details,
|
|
186
|
+
fraud
|
|
187
|
+
};
|
|
188
|
+
return sendRequest('/api/identity-verification/id-recognition/v3/finish-scan-doc', 'POST', {
|
|
189
|
+
body: JSON.stringify(body)
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function confirmScan(scanId, details) {
|
|
193
|
+
const body = {
|
|
194
|
+
scanId,
|
|
195
|
+
details
|
|
196
|
+
};
|
|
197
|
+
return sendRequest('/api/identity-verification/id-recognition/v3/confirm-scan', 'POST', {
|
|
198
|
+
body: JSON.stringify(body)
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var name = "@authme/id-recognition";
|
|
203
|
+
var version$1 = "2.2.1-rc.3";
|
|
204
|
+
var peerDependencies = {
|
|
205
|
+
"core-js": "^3.6.0"
|
|
206
|
+
};
|
|
207
|
+
var packageInfo = {
|
|
208
|
+
name: name,
|
|
209
|
+
version: version$1,
|
|
210
|
+
peerDependencies: peerDependencies
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
var _a;
|
|
214
|
+
var _b, _c;
|
|
215
|
+
const version = packageInfo.version;
|
|
216
|
+
(_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
|
|
217
|
+
window[Symbol.for('authme-sdk')][packageInfo.name] = version;
|
|
218
|
+
|
|
219
|
+
export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, ResourceImageType, ServerSideEAuthMeCardClass, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, recognition, saveResourceImage, twoWayAuthmeCardClassMap, version };
|
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authme/id-recognition",
|
|
3
|
-
"version": "2.2.1-rc.
|
|
4
|
-
"main": "./src/index.js",
|
|
5
|
-
"typings": "./src/index.d.ts",
|
|
6
|
-
"dependencies": {},
|
|
3
|
+
"version": "2.2.1-rc.3",
|
|
7
4
|
"peerDependencies": {
|
|
8
|
-
"
|
|
9
|
-
"@authme/
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
"core-js": "^3.6.0",
|
|
6
|
+
"@authme/core": "2.2.1-rc.3",
|
|
7
|
+
"@authme/engine": "2.2.1-rc.3"
|
|
8
|
+
},
|
|
9
|
+
"module": "./index.js",
|
|
10
|
+
"main": "./index.cjs",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"types": "./src/index.d.ts",
|
|
13
|
+
"dependencies": {}
|
|
16
14
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from './lib/modules-id-recognition-feature-id-recognition';
|
|
2
|
-
export * from './lib/model';
|
|
3
|
-
export * from './lib/enum';
|
|
4
|
-
export * from './lib/interface';
|
|
5
|
-
export * from './lib/util';
|
|
6
|
-
export * from './lib/data-access';
|
|
1
|
+
export * from './lib/modules-id-recognition-feature-id-recognition';
|
|
2
|
+
export * from './lib/model';
|
|
3
|
+
export * from './lib/enum';
|
|
4
|
+
export * from './lib/interface';
|
|
5
|
+
export * from './lib/util';
|
|
6
|
+
export * from './lib/data-access';
|
|
7
|
+
export { version } from './lib/version';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { CountryCode, IdRecognitionCardType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
|
|
2
|
-
import { InitScanResponse } from '../model';
|
|
3
|
-
export declare function init(type: IdRecognitionCardType, country: CountryCode, needConfirm: boolean): Promise<InitScanResponse>;
|
|
4
|
-
export declare function initScanDocument(scanId: string, cardType: `${ServerSideEAuthMeCardClass}`): Promise<{
|
|
5
|
-
scanDocumentId: string;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function recognition(documentId: string, file: Blob): Promise<{
|
|
8
|
-
retry?: boolean;
|
|
9
|
-
details: {
|
|
10
|
-
[key: string]: string | null;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
13
|
-
export declare function saveResourceImage(documentId: string, type: ResourceImageType, file: Blob): Promise<any>;
|
|
14
|
-
export declare function finishScanDocument(documentId: string, details: {
|
|
15
|
-
[key: string]: string | null;
|
|
16
|
-
}, fraud: boolean | null): Promise<any>;
|
|
17
|
-
export declare function confirmScan(scanId: string, details: {
|
|
18
|
-
[key: string]: string | null;
|
|
19
|
-
}): Promise<any>;
|
|
1
|
+
import { CountryCode, IdRecognitionCardType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
|
|
2
|
+
import { InitScanResponse } from '../model';
|
|
3
|
+
export declare function init(type: IdRecognitionCardType, country: CountryCode, needConfirm: boolean): Promise<InitScanResponse>;
|
|
4
|
+
export declare function initScanDocument(scanId: string, cardType: `${ServerSideEAuthMeCardClass}`): Promise<{
|
|
5
|
+
scanDocumentId: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function recognition(documentId: string, file: Blob): Promise<{
|
|
8
|
+
retry?: boolean;
|
|
9
|
+
details: {
|
|
10
|
+
[key: string]: string | null;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export declare function saveResourceImage(documentId: string, type: ResourceImageType, file: Blob): Promise<any>;
|
|
14
|
+
export declare function finishScanDocument(documentId: string, details: {
|
|
15
|
+
[key: string]: string | null;
|
|
16
|
+
}, fraud: boolean | null): Promise<any>;
|
|
17
|
+
export declare function confirmScan(scanId: string, details: {
|
|
18
|
+
[key: string]: string | null;
|
|
19
|
+
}): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './api';
|
|
1
|
+
export * from './api';
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMePassportServiceStatus, } from '@authme/engine';
|
|
2
|
-
export declare enum ResourceImageType {
|
|
3
|
-
Recognition = "Recognition",
|
|
4
|
-
Fraud = "Fraud",
|
|
5
|
-
Manual = "Manual"
|
|
6
|
-
}
|
|
7
|
-
export declare enum CountryCode {
|
|
8
|
-
TWN = "TWN"
|
|
9
|
-
}
|
|
10
|
-
export declare enum IdRecognitionCardType {
|
|
11
|
-
IDCard = "IDCard",
|
|
12
|
-
DriverLicense = "DriverLicense",
|
|
13
|
-
HealthCard = "HealthCard",
|
|
14
|
-
ResidentCard = "ResidentCard",
|
|
15
|
-
Passport = "Passport"
|
|
16
|
-
}
|
|
17
|
-
export declare enum ServerSideEAuthMeCardClass {
|
|
18
|
-
Invalid = "Invalid",
|
|
19
|
-
Unknown = "UnknownCard",
|
|
20
|
-
Passport = "Passport",
|
|
21
|
-
TWN_IDCard_Front = "TWN_IDCard_Front",
|
|
22
|
-
TWN_IDCard_Back = "TWN_IDCard_Back",
|
|
23
|
-
TWN_DriverLicense_Front = "TWN_DriverLicense_Front",
|
|
24
|
-
TWN_DriverLicense_Back = "TWN_DriverLicense_Back",
|
|
25
|
-
TWN_ResidentCard_Front = "TWN_ResidentCard_Front",
|
|
26
|
-
TWN_ResidentCard_Back = "TWN_ResidentCard_Back",
|
|
27
|
-
TWN_HealthCard_Front = "TWN_HealthCard_Front",
|
|
28
|
-
TWN_VehiclesLicense_Front = "TWN_VehiclesLicense_Front"
|
|
29
|
-
}
|
|
1
|
+
export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMePassportServiceStatus, } from '@authme/engine';
|
|
2
|
+
export declare enum ResourceImageType {
|
|
3
|
+
Recognition = "Recognition",
|
|
4
|
+
Fraud = "Fraud",
|
|
5
|
+
Manual = "Manual"
|
|
6
|
+
}
|
|
7
|
+
export declare enum CountryCode {
|
|
8
|
+
TWN = "TWN"
|
|
9
|
+
}
|
|
10
|
+
export declare enum IdRecognitionCardType {
|
|
11
|
+
IDCard = "IDCard",
|
|
12
|
+
DriverLicense = "DriverLicense",
|
|
13
|
+
HealthCard = "HealthCard",
|
|
14
|
+
ResidentCard = "ResidentCard",
|
|
15
|
+
Passport = "Passport"
|
|
16
|
+
}
|
|
17
|
+
export declare enum ServerSideEAuthMeCardClass {
|
|
18
|
+
Invalid = "Invalid",
|
|
19
|
+
Unknown = "UnknownCard",
|
|
20
|
+
Passport = "Passport",
|
|
21
|
+
TWN_IDCard_Front = "TWN_IDCard_Front",
|
|
22
|
+
TWN_IDCard_Back = "TWN_IDCard_Back",
|
|
23
|
+
TWN_DriverLicense_Front = "TWN_DriverLicense_Front",
|
|
24
|
+
TWN_DriverLicense_Back = "TWN_DriverLicense_Back",
|
|
25
|
+
TWN_ResidentCard_Front = "TWN_ResidentCard_Front",
|
|
26
|
+
TWN_ResidentCard_Back = "TWN_ResidentCard_Back",
|
|
27
|
+
TWN_HealthCard_Front = "TWN_HealthCard_Front",
|
|
28
|
+
TWN_VehiclesLicense_Front = "TWN_VehiclesLicense_Front"
|
|
29
|
+
}
|
package/src/lib/enum/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './id-recognition.enum';
|
|
1
|
+
export * from './id-recognition.enum';
|