@keetanetwork/anchor 0.0.12 → 0.0.14
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/lib/certificates.d.ts +83 -21
- package/lib/certificates.d.ts.map +1 -1
- package/lib/certificates.generated.d.ts +3 -0
- package/lib/certificates.generated.d.ts.map +1 -0
- package/lib/certificates.generated.js +120 -0
- package/lib/certificates.generated.js.map +1 -0
- package/lib/certificates.js +579 -117
- package/lib/certificates.js.map +1 -1
- package/lib/http-server.d.ts +2 -1
- package/lib/http-server.d.ts.map +1 -1
- package/lib/http-server.js +4 -4
- package/lib/http-server.js.map +1 -1
- package/lib/resolver.d.ts +2 -1
- package/lib/resolver.d.ts.map +1 -1
- package/lib/resolver.js.map +1 -1
- package/lib/utils/asn1.d.ts +2 -1
- package/lib/utils/asn1.d.ts.map +1 -1
- package/lib/utils/asn1.js.map +1 -1
- package/lib/utils/buffer.d.ts +3 -0
- package/lib/utils/buffer.d.ts.map +1 -1
- package/lib/utils/buffer.js +26 -0
- package/lib/utils/buffer.js.map +1 -1
- package/lib/utils/guards.d.ts +14 -0
- package/lib/utils/guards.d.ts.map +1 -0
- package/lib/utils/guards.js +31 -0
- package/lib/utils/guards.js.map +1 -0
- package/lib/utils/index.d.ts +3 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +3 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/json.d.ts +2 -2
- package/lib/utils/json.d.ts.map +1 -1
- package/lib/utils/json.js.map +1 -1
- package/lib/utils/oid.d.ts +7 -0
- package/lib/utils/oid.d.ts.map +1 -0
- package/lib/utils/oid.js +22 -0
- package/lib/utils/oid.js.map +1 -0
- package/lib/utils/signing.d.ts.map +1 -1
- package/lib/utils/signing.js +26 -2
- package/lib/utils/signing.js.map +1 -1
- package/npm-shrinkwrap.json +2 -8
- package/package.json +1 -2
- package/services/fx/client.d.ts +1 -0
- package/services/fx/client.d.ts.map +1 -1
- package/services/fx/client.js +72 -72
- package/services/fx/client.js.map +1 -1
- package/services/fx/common.d.ts +23 -14
- package/services/fx/common.d.ts.map +1 -1
- package/services/fx/common.js +177 -1
- package/services/fx/common.js.map +1 -1
- package/services/fx/server.d.ts +13 -4
- package/services/fx/server.d.ts.map +1 -1
- package/services/fx/server.js +58 -151
- package/services/fx/server.js.map +1 -1
- package/services/kyc/client.d.ts.map +1 -1
- package/services/kyc/client.js +1 -8
- package/services/kyc/client.js.map +1 -1
- package/services/kyc/common.d.ts +39 -3
- package/services/kyc/common.d.ts.map +1 -1
- package/services/kyc/common.generated.d.ts +5 -0
- package/services/kyc/common.generated.d.ts.map +1 -0
- package/services/kyc/common.generated.js +241 -0
- package/services/kyc/common.generated.js.map +1 -0
- package/services/kyc/common.js +68 -1
- package/services/kyc/common.js.map +1 -1
- package/services/kyc/iso20022.generated.d.ts +285 -0
- package/services/kyc/iso20022.generated.d.ts.map +1 -0
- package/services/kyc/iso20022.generated.js +205 -0
- package/services/kyc/iso20022.generated.js.map +1 -0
- package/services/kyc/oids.generated.d.ts +83 -0
- package/services/kyc/oids.generated.d.ts.map +1 -0
- package/services/kyc/oids.generated.js +130 -0
- package/services/kyc/oids.generated.js.map +1 -0
- package/services/kyc/server.d.ts +141 -0
- package/services/kyc/server.d.ts.map +1 -0
- package/services/kyc/server.js +183 -0
- package/services/kyc/server.js.map +1 -0
- package/services/kyc/utils/generate-kyc-schema.d.ts +3 -0
- package/services/kyc/utils/generate-kyc-schema.d.ts.map +1 -0
- package/services/kyc/utils/generate-kyc-schema.js +1154 -0
- package/services/kyc/utils/generate-kyc-schema.js.map +1 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated OID Constants
|
|
3
|
+
* This file is auto-generated from oids.json.
|
|
4
|
+
*/
|
|
5
|
+
export declare const AES_256_GCM = "2.16.840.1.101.3.4.1.46";
|
|
6
|
+
export declare const AES_256_CBC = "2.16.840.1.101.3.4.1.42";
|
|
7
|
+
export declare const SHA2_256 = "2.16.840.1.101.3.4.2.1";
|
|
8
|
+
export declare const SHA3_256 = "2.16.840.1.101.3.4.2.8";
|
|
9
|
+
/** Postal code OID */
|
|
10
|
+
/** @see https://oidref.com/2.5.5.17 */
|
|
11
|
+
export declare const POSTAL_CODE = "2.5.5.17";
|
|
12
|
+
export declare namespace keeta {
|
|
13
|
+
/** KYC attributes extension for X.509 certificates */
|
|
14
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.0.0 */
|
|
15
|
+
const KYC_ATTRIBUTES = "1.3.6.1.4.1.62675.0.0";
|
|
16
|
+
/** Person's full name */
|
|
17
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0 */
|
|
18
|
+
const FULL_NAME = "1.3.6.1.4.1.62675.1.0";
|
|
19
|
+
/** Person's first name */
|
|
20
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.1 */
|
|
21
|
+
const FIRST_NAME = "1.3.6.1.4.1.62675.1.0.1";
|
|
22
|
+
/** Person's last name */
|
|
23
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.2 */
|
|
24
|
+
const LAST_NAME = "1.3.6.1.4.1.62675.1.0.2";
|
|
25
|
+
/** Person's middle name */
|
|
26
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.3 */
|
|
27
|
+
const MIDDLE_NAME = "1.3.6.1.4.1.62675.1.0.3";
|
|
28
|
+
/** Date of birth */
|
|
29
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.1 */
|
|
30
|
+
const DATE_OF_BIRTH = "1.3.6.1.4.1.62675.1.1";
|
|
31
|
+
/** Physical address */
|
|
32
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2 */
|
|
33
|
+
const ADDRESS = "1.3.6.1.4.1.62675.1.2";
|
|
34
|
+
/** Email address */
|
|
35
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.3 */
|
|
36
|
+
const EMAIL = "1.3.6.1.4.1.62675.1.3";
|
|
37
|
+
/** Phone number */
|
|
38
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.4 */
|
|
39
|
+
const PHONE_NUMBER = "1.3.6.1.4.1.62675.1.4";
|
|
40
|
+
/** Date and place of birth information */
|
|
41
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.5 */
|
|
42
|
+
const DATE_AND_PLACE_OF_BIRTH = "1.3.6.1.4.1.62675.1.5";
|
|
43
|
+
/** Job title */
|
|
44
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.6 */
|
|
45
|
+
const JOB_TITLE = "1.3.6.1.4.1.62675.1.6";
|
|
46
|
+
/** Job responsibility */
|
|
47
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.6.1 */
|
|
48
|
+
const JOB_RESPONSIBILITY = "1.3.6.1.4.1.62675.1.6.1";
|
|
49
|
+
/** Identifier */
|
|
50
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.7 */
|
|
51
|
+
const ID = "1.3.6.1.4.1.62675.1.7";
|
|
52
|
+
/** Issuer identifier */
|
|
53
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.7.1 */
|
|
54
|
+
const ISSUER = "1.3.6.1.4.1.62675.1.7.1";
|
|
55
|
+
/** Entity type (organization or person) */
|
|
56
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.8 */
|
|
57
|
+
const ENTITY_TYPE = "1.3.6.1.4.1.62675.1.8";
|
|
58
|
+
/** Contact details */
|
|
59
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.9 */
|
|
60
|
+
const CONTACT_DETAILS = "1.3.6.1.4.1.62675.1.9";
|
|
61
|
+
/** Nationality */
|
|
62
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.10 */
|
|
63
|
+
const NATIONALITY = "1.3.6.1.4.1.62675.1.10";
|
|
64
|
+
/** Document information */
|
|
65
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2 */
|
|
66
|
+
const DOCUMENT = "1.3.6.1.4.1.62675.1.11";
|
|
67
|
+
/** Driver's license front side document */
|
|
68
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.1 */
|
|
69
|
+
const DOCUMENT_DRIVERS_LICENSE_FRONT = "1.3.6.1.4.1.62675.1.11.0";
|
|
70
|
+
/** Driver's license back side document */
|
|
71
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.2 */
|
|
72
|
+
const DOCUMENT_DRIVERS_LICENSE_BACK = "1.3.6.1.4.1.62675.1.11.1";
|
|
73
|
+
/** Passport document */
|
|
74
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.3 */
|
|
75
|
+
const DOCUMENT_PASSPORT = "1.3.6.1.4.1.62675.1.11.2";
|
|
76
|
+
}
|
|
77
|
+
export declare const OID_TO_NAME: {
|
|
78
|
+
[key: string]: string;
|
|
79
|
+
};
|
|
80
|
+
export declare const NAME_TO_OID: {
|
|
81
|
+
[key: string]: string;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=oids.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oids.generated.d.ts","sourceRoot":"","sources":["../../../src/services/kyc/oids.generated.ts"],"names":[],"mappings":"AACA;;;GAGG;AAGH,eAAO,MAAM,WAAW,4BAA4B,CAAC;AACrD,eAAO,MAAM,WAAW,4BAA4B,CAAC;AACrD,eAAO,MAAM,QAAQ,2BAA2B,CAAC;AACjD,eAAO,MAAM,QAAQ,2BAA2B,CAAC;AAGjD,sBAAsB;AACtB,uCAAuC;AACvC,eAAO,MAAM,WAAW,aAAa,CAAC;AAItC,yBAAiB,KAAK,CAAC;IACtB,sDAAsD;IACtD,0DAA0D;IACnD,MAAM,cAAc,0BAA0B,CAAC;IACtD,yBAAyB;IACzB,0DAA0D;IACnD,MAAM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O,MAAM,WAAW,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAsBhD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAsBhD,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated OID Constants
|
|
4
|
+
* This file is auto-generated from oids.json.
|
|
5
|
+
*/
|
|
6
|
+
// Algorithm OID constants
|
|
7
|
+
export const AES_256_GCM = '2.16.840.1.101.3.4.1.46';
|
|
8
|
+
export const AES_256_CBC = '2.16.840.1.101.3.4.1.42';
|
|
9
|
+
export const SHA2_256 = '2.16.840.1.101.3.4.2.1';
|
|
10
|
+
export const SHA3_256 = '2.16.840.1.101.3.4.2.8';
|
|
11
|
+
// Plain attribute OID constants
|
|
12
|
+
/** Postal code OID */
|
|
13
|
+
/** @see https://oidref.com/2.5.5.17 */
|
|
14
|
+
export const POSTAL_CODE = '2.5.5.17';
|
|
15
|
+
// Keeta-specific OID constants
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
17
|
+
export var keeta;
|
|
18
|
+
(function (keeta) {
|
|
19
|
+
/** KYC attributes extension for X.509 certificates */
|
|
20
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.0.0 */
|
|
21
|
+
keeta.KYC_ATTRIBUTES = '1.3.6.1.4.1.62675.0.0';
|
|
22
|
+
/** Person's full name */
|
|
23
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0 */
|
|
24
|
+
keeta.FULL_NAME = '1.3.6.1.4.1.62675.1.0';
|
|
25
|
+
/** Person's first name */
|
|
26
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.1 */
|
|
27
|
+
keeta.FIRST_NAME = '1.3.6.1.4.1.62675.1.0.1';
|
|
28
|
+
/** Person's last name */
|
|
29
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.2 */
|
|
30
|
+
keeta.LAST_NAME = '1.3.6.1.4.1.62675.1.0.2';
|
|
31
|
+
/** Person's middle name */
|
|
32
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.3 */
|
|
33
|
+
keeta.MIDDLE_NAME = '1.3.6.1.4.1.62675.1.0.3';
|
|
34
|
+
/** Date of birth */
|
|
35
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.1 */
|
|
36
|
+
keeta.DATE_OF_BIRTH = '1.3.6.1.4.1.62675.1.1';
|
|
37
|
+
/** Physical address */
|
|
38
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2 */
|
|
39
|
+
keeta.ADDRESS = '1.3.6.1.4.1.62675.1.2';
|
|
40
|
+
/** Email address */
|
|
41
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.3 */
|
|
42
|
+
keeta.EMAIL = '1.3.6.1.4.1.62675.1.3';
|
|
43
|
+
/** Phone number */
|
|
44
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.4 */
|
|
45
|
+
keeta.PHONE_NUMBER = '1.3.6.1.4.1.62675.1.4';
|
|
46
|
+
/** Date and place of birth information */
|
|
47
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.5 */
|
|
48
|
+
keeta.DATE_AND_PLACE_OF_BIRTH = '1.3.6.1.4.1.62675.1.5';
|
|
49
|
+
/** Job title */
|
|
50
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.6 */
|
|
51
|
+
keeta.JOB_TITLE = '1.3.6.1.4.1.62675.1.6';
|
|
52
|
+
/** Job responsibility */
|
|
53
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.6.1 */
|
|
54
|
+
keeta.JOB_RESPONSIBILITY = '1.3.6.1.4.1.62675.1.6.1';
|
|
55
|
+
/** Identifier */
|
|
56
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.7 */
|
|
57
|
+
keeta.ID = '1.3.6.1.4.1.62675.1.7';
|
|
58
|
+
/** Issuer identifier */
|
|
59
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.7.1 */
|
|
60
|
+
keeta.ISSUER = '1.3.6.1.4.1.62675.1.7.1';
|
|
61
|
+
/** Entity type (organization or person) */
|
|
62
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.8 */
|
|
63
|
+
keeta.ENTITY_TYPE = '1.3.6.1.4.1.62675.1.8';
|
|
64
|
+
/** Contact details */
|
|
65
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.9 */
|
|
66
|
+
keeta.CONTACT_DETAILS = '1.3.6.1.4.1.62675.1.9';
|
|
67
|
+
/** Nationality */
|
|
68
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.10 */
|
|
69
|
+
keeta.NATIONALITY = '1.3.6.1.4.1.62675.1.10';
|
|
70
|
+
/** Document information */
|
|
71
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2 */
|
|
72
|
+
keeta.DOCUMENT = '1.3.6.1.4.1.62675.1.11';
|
|
73
|
+
/** Driver's license front side document */
|
|
74
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.1 */
|
|
75
|
+
keeta.DOCUMENT_DRIVERS_LICENSE_FRONT = '1.3.6.1.4.1.62675.1.11.0';
|
|
76
|
+
/** Driver's license back side document */
|
|
77
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.2 */
|
|
78
|
+
keeta.DOCUMENT_DRIVERS_LICENSE_BACK = '1.3.6.1.4.1.62675.1.11.1';
|
|
79
|
+
/** Passport document */
|
|
80
|
+
/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.3 */
|
|
81
|
+
keeta.DOCUMENT_PASSPORT = '1.3.6.1.4.1.62675.1.11.2';
|
|
82
|
+
})(keeta || (keeta = {}));
|
|
83
|
+
// OID to name lookup maps
|
|
84
|
+
export const OID_TO_NAME = {
|
|
85
|
+
'2.5.5.17': 'postalCode',
|
|
86
|
+
'1.3.6.1.4.1.62675.1.0': 'fullName',
|
|
87
|
+
'1.3.6.1.4.1.62675.1.0.1': 'firstName',
|
|
88
|
+
'1.3.6.1.4.1.62675.1.0.2': 'lastName',
|
|
89
|
+
'1.3.6.1.4.1.62675.1.0.3': 'middleName',
|
|
90
|
+
'1.3.6.1.4.1.62675.1.1': 'dateOfBirth',
|
|
91
|
+
'1.3.6.1.4.1.62675.1.2': 'address',
|
|
92
|
+
'1.3.6.1.4.1.62675.1.3': 'email',
|
|
93
|
+
'1.3.6.1.4.1.62675.1.4': 'phoneNumber',
|
|
94
|
+
'1.3.6.1.4.1.62675.1.5': 'dateAndPlaceOfBirth',
|
|
95
|
+
'1.3.6.1.4.1.62675.1.6': 'jobTitle',
|
|
96
|
+
'1.3.6.1.4.1.62675.1.6.1': 'jobResponsibility',
|
|
97
|
+
'1.3.6.1.4.1.62675.1.7': 'id',
|
|
98
|
+
'1.3.6.1.4.1.62675.1.7.1': 'issuer',
|
|
99
|
+
'1.3.6.1.4.1.62675.1.8': 'entityType',
|
|
100
|
+
'1.3.6.1.4.1.62675.1.9': 'contactDetails',
|
|
101
|
+
'1.3.6.1.4.1.62675.1.10': 'nationality',
|
|
102
|
+
'1.3.6.1.4.1.62675.1.11': 'document',
|
|
103
|
+
'1.3.6.1.4.1.62675.1.11.0': 'documentDriversLicenseFront',
|
|
104
|
+
'1.3.6.1.4.1.62675.1.11.1': 'documentDriversLicenseBack',
|
|
105
|
+
'1.3.6.1.4.1.62675.1.11.2': 'documentPassport'
|
|
106
|
+
};
|
|
107
|
+
export const NAME_TO_OID = {
|
|
108
|
+
'postalCode': '2.5.5.17',
|
|
109
|
+
'fullName': '1.3.6.1.4.1.62675.1.0',
|
|
110
|
+
'firstName': '1.3.6.1.4.1.62675.1.0.1',
|
|
111
|
+
'lastName': '1.3.6.1.4.1.62675.1.0.2',
|
|
112
|
+
'middleName': '1.3.6.1.4.1.62675.1.0.3',
|
|
113
|
+
'dateOfBirth': '1.3.6.1.4.1.62675.1.1',
|
|
114
|
+
'address': '1.3.6.1.4.1.62675.1.2',
|
|
115
|
+
'email': '1.3.6.1.4.1.62675.1.3',
|
|
116
|
+
'phoneNumber': '1.3.6.1.4.1.62675.1.4',
|
|
117
|
+
'dateAndPlaceOfBirth': '1.3.6.1.4.1.62675.1.5',
|
|
118
|
+
'jobTitle': '1.3.6.1.4.1.62675.1.6',
|
|
119
|
+
'jobResponsibility': '1.3.6.1.4.1.62675.1.6.1',
|
|
120
|
+
'id': '1.3.6.1.4.1.62675.1.7',
|
|
121
|
+
'issuer': '1.3.6.1.4.1.62675.1.7.1',
|
|
122
|
+
'entityType': '1.3.6.1.4.1.62675.1.8',
|
|
123
|
+
'contactDetails': '1.3.6.1.4.1.62675.1.9',
|
|
124
|
+
'nationality': '1.3.6.1.4.1.62675.1.10',
|
|
125
|
+
'document': '1.3.6.1.4.1.62675.1.11',
|
|
126
|
+
'documentDriversLicenseFront': '1.3.6.1.4.1.62675.1.11.0',
|
|
127
|
+
'documentDriversLicenseBack': '1.3.6.1.4.1.62675.1.11.1',
|
|
128
|
+
'documentPassport': '1.3.6.1.4.1.62675.1.11.2'
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=oids.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oids.generated.js","sourceRoot":"","sources":["../../../src/services/kyc/oids.generated.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;GAGG;AAEH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,WAAW,GAAG,yBAAyB,CAAC;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,yBAAyB,CAAC;AACrD,MAAM,CAAC,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AACjD,MAAM,CAAC,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAEjD,gCAAgC;AA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B;IACtC,qBAAqB,EAAE,uBAAuB;IAC9C,UAAU,EAAE,uBAAuB;IACnC,mBAAmB,EAAE,yBAAyB;IAC9C,IAAI,EAAE,uBAAuB;IAC7B,QAAQ,EAAE,yBAAyB;IACnC,YAAY,EAAE,uBAAuB;IACrC,gBAAgB,EAAE,uBAAuB;IACzC,aAAa,EAAE,wBAAwB;IACvC,UAAU,EAAE,wBAAwB;IACpC,6BAA6B,EAAE,0BAA0B;IACzD,4BAA4B,EAAE,0BAA0B;IACxD,kBAAkB,EAAE,0BAA0B;CAC9C,CAAC","sourcesContent":["/* eslint-disable */\n/**\n * Generated OID Constants\n * This file is auto-generated from oids.json.\n */\n\n// Algorithm OID constants\nexport const AES_256_GCM = '2.16.840.1.101.3.4.1.46';\nexport const AES_256_CBC = '2.16.840.1.101.3.4.1.42';\nexport const SHA2_256 = '2.16.840.1.101.3.4.2.1';\nexport const SHA3_256 = '2.16.840.1.101.3.4.2.8';\n\n// Plain attribute OID constants\n/** Postal code OID */\n/** @see https://oidref.com/2.5.5.17 */\nexport const POSTAL_CODE = '2.5.5.17';\n\n// Keeta-specific OID constants\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace keeta {\n\t/** KYC attributes extension for X.509 certificates */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.0.0 */\n\texport const KYC_ATTRIBUTES = '1.3.6.1.4.1.62675.0.0';\n\t/** Person's full name */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0 */\n\texport const FULL_NAME = '1.3.6.1.4.1.62675.1.0';\n\t/** Person's first name */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.1 */\n\texport const FIRST_NAME = '1.3.6.1.4.1.62675.1.0.1';\n\t/** Person's last name */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.2 */\n\texport const LAST_NAME = '1.3.6.1.4.1.62675.1.0.2';\n\t/** Person's middle name */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.0.3 */\n\texport const MIDDLE_NAME = '1.3.6.1.4.1.62675.1.0.3';\n\t/** Date of birth */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.1 */\n\texport const DATE_OF_BIRTH = '1.3.6.1.4.1.62675.1.1';\n\t/** Physical address */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2 */\n\texport const ADDRESS = '1.3.6.1.4.1.62675.1.2';\n\t/** Email address */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.3 */\n\texport const EMAIL = '1.3.6.1.4.1.62675.1.3';\n\t/** Phone number */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.4 */\n\texport const PHONE_NUMBER = '1.3.6.1.4.1.62675.1.4';\n\t/** Date and place of birth information */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.5 */\n\texport const DATE_AND_PLACE_OF_BIRTH = '1.3.6.1.4.1.62675.1.5';\n\t/** Job title */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.6 */\n\texport const JOB_TITLE = '1.3.6.1.4.1.62675.1.6';\n\t/** Job responsibility */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.6.1 */\n\texport const JOB_RESPONSIBILITY = '1.3.6.1.4.1.62675.1.6.1';\n\t/** Identifier */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.7 */\n\texport const ID = '1.3.6.1.4.1.62675.1.7';\n\t/** Issuer identifier */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.7.1 */\n\texport const ISSUER = '1.3.6.1.4.1.62675.1.7.1';\n\t/** Entity type (organization or person) */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.8 */\n\texport const ENTITY_TYPE = '1.3.6.1.4.1.62675.1.8';\n\t/** Contact details */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.9 */\n\texport const CONTACT_DETAILS = '1.3.6.1.4.1.62675.1.9';\n\t/** Nationality */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.10 */\n\texport const NATIONALITY = '1.3.6.1.4.1.62675.1.10';\n\t/** Document information */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2 */\n\texport const DOCUMENT = '1.3.6.1.4.1.62675.1.11';\n\t/** Driver's license front side document */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.1 */\n\texport const DOCUMENT_DRIVERS_LICENSE_FRONT = '1.3.6.1.4.1.62675.1.11.0';\n\t/** Driver's license back side document */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.2 */\n\texport const DOCUMENT_DRIVERS_LICENSE_BACK = '1.3.6.1.4.1.62675.1.11.1';\n\t/** Passport document */\n\t/** @see https://oid-base.com/get/1.3.6.1.4.1.62675.1.2.3 */\n\texport const DOCUMENT_PASSPORT = '1.3.6.1.4.1.62675.1.11.2';\n}\n\n// OID to name lookup maps\nexport const OID_TO_NAME: { [key: string]: string } = {\n\t'2.5.5.17': 'postalCode',\n\t'1.3.6.1.4.1.62675.1.0': 'fullName',\n\t'1.3.6.1.4.1.62675.1.0.1': 'firstName',\n\t'1.3.6.1.4.1.62675.1.0.2': 'lastName',\n\t'1.3.6.1.4.1.62675.1.0.3': 'middleName',\n\t'1.3.6.1.4.1.62675.1.1': 'dateOfBirth',\n\t'1.3.6.1.4.1.62675.1.2': 'address',\n\t'1.3.6.1.4.1.62675.1.3': 'email',\n\t'1.3.6.1.4.1.62675.1.4': 'phoneNumber',\n\t'1.3.6.1.4.1.62675.1.5': 'dateAndPlaceOfBirth',\n\t'1.3.6.1.4.1.62675.1.6': 'jobTitle',\n\t'1.3.6.1.4.1.62675.1.6.1': 'jobResponsibility',\n\t'1.3.6.1.4.1.62675.1.7': 'id',\n\t'1.3.6.1.4.1.62675.1.7.1': 'issuer',\n\t'1.3.6.1.4.1.62675.1.8': 'entityType',\n\t'1.3.6.1.4.1.62675.1.9': 'contactDetails',\n\t'1.3.6.1.4.1.62675.1.10': 'nationality',\n\t'1.3.6.1.4.1.62675.1.11': 'document',\n\t'1.3.6.1.4.1.62675.1.11.0': 'documentDriversLicenseFront',\n\t'1.3.6.1.4.1.62675.1.11.1': 'documentDriversLicenseBack',\n\t'1.3.6.1.4.1.62675.1.11.2': 'documentPassport'\n};\n\nexport const NAME_TO_OID: { [key: string]: string } = {\n\t'postalCode': '2.5.5.17',\n\t'fullName': '1.3.6.1.4.1.62675.1.0',\n\t'firstName': '1.3.6.1.4.1.62675.1.0.1',\n\t'lastName': '1.3.6.1.4.1.62675.1.0.2',\n\t'middleName': '1.3.6.1.4.1.62675.1.0.3',\n\t'dateOfBirth': '1.3.6.1.4.1.62675.1.1',\n\t'address': '1.3.6.1.4.1.62675.1.2',\n\t'email': '1.3.6.1.4.1.62675.1.3',\n\t'phoneNumber': '1.3.6.1.4.1.62675.1.4',\n\t'dateAndPlaceOfBirth': '1.3.6.1.4.1.62675.1.5',\n\t'jobTitle': '1.3.6.1.4.1.62675.1.6',\n\t'jobResponsibility': '1.3.6.1.4.1.62675.1.6.1',\n\t'id': '1.3.6.1.4.1.62675.1.7',\n\t'issuer': '1.3.6.1.4.1.62675.1.7.1',\n\t'entityType': '1.3.6.1.4.1.62675.1.8',\n\t'contactDetails': '1.3.6.1.4.1.62675.1.9',\n\t'nationality': '1.3.6.1.4.1.62675.1.10',\n\t'document': '1.3.6.1.4.1.62675.1.11',\n\t'documentDriversLicenseFront': '1.3.6.1.4.1.62675.1.11.0',\n\t'documentDriversLicenseBack': '1.3.6.1.4.1.62675.1.11.1',\n\t'documentPassport': '1.3.6.1.4.1.62675.1.11.2'\n};\n"]}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import KeetaNet from '@keetanetwork/keetanet-client';
|
|
2
|
+
import * as CurrencyInfo from '@keetanetwork/currency-info';
|
|
3
|
+
import * as KeetaAnchorHTTPServer from '../../lib/http-server.js';
|
|
4
|
+
import type { KeetaKYCAnchorCreateVerificationRequest, KeetaKYCAnchorCreateVerificationResponse, KeetaKYCAnchorGetCertificateResponse } from './common.ts';
|
|
5
|
+
import type * as Signing from '../../lib/utils/signing.js';
|
|
6
|
+
import type { ServiceMetadata } from '../../lib/resolver.ts';
|
|
7
|
+
/**
|
|
8
|
+
* The Base certificate type, from the KeetaNet Client
|
|
9
|
+
*
|
|
10
|
+
* The KYC Certificate type is a subclass of this, so it will also work
|
|
11
|
+
*/
|
|
12
|
+
type BaseCertificate = InstanceType<typeof KeetaNet.lib.Utils.Certificate.Certificate>;
|
|
13
|
+
export interface KeetaAnchorKYCServerConfig extends KeetaAnchorHTTPServer.KeetaAnchorHTTPServerConfig {
|
|
14
|
+
/**
|
|
15
|
+
* The data to use for the index page (optional)
|
|
16
|
+
*/
|
|
17
|
+
homepage?: string | (() => Promise<string> | string);
|
|
18
|
+
/**
|
|
19
|
+
* The network client to use for submitting blocks
|
|
20
|
+
*/
|
|
21
|
+
client: {
|
|
22
|
+
client: KeetaNet.Client;
|
|
23
|
+
network: bigint;
|
|
24
|
+
networkAlias: typeof KeetaNet.Client.Config.networksArray[number];
|
|
25
|
+
} | KeetaNet.UserClient;
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for the KYC Anchor
|
|
28
|
+
*
|
|
29
|
+
* The flow for a KYC Anchor is as follows:
|
|
30
|
+
* 1. Client requests a new verification with a country code and
|
|
31
|
+
* account from the KYC Anchor Server
|
|
32
|
+
* 2. KYC Anchor Server responds with a verification ID and a URL
|
|
33
|
+
* to the KYC provider's web URL, including the verification ID
|
|
34
|
+
* 3. Client visits the KYC provider's web URL to complete the
|
|
35
|
+
* verification
|
|
36
|
+
* 4. KYC provider notifies the Anchor server that the
|
|
37
|
+
* verification is complete
|
|
38
|
+
* 5. Client requests the certificate for the verification ID
|
|
39
|
+
* (polling) from the KYC Anchor Server
|
|
40
|
+
* 6. KYC Anchor Server responds with the certificate(s) for the
|
|
41
|
+
* verification ID (if complete, pending if still in progress,
|
|
42
|
+
* an error if failed)
|
|
43
|
+
* 7. Client installs the certificate(s) in their wallet using
|
|
44
|
+
* the KeetaNet Client library
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
* +-------------------+ +---------------------+ +------------------+
|
|
48
|
+
* | Client | | KYC Anchor Server | | KYC Provider |
|
|
49
|
+
* +-------------------+ +---------------------+ +------------------+
|
|
50
|
+
* | | |
|
|
51
|
+
* (1) Create Verification | |
|
|
52
|
+
* countryCode, account ---------------------->| |
|
|
53
|
+
* | | |
|
|
54
|
+
* | (2) Create verification |
|
|
55
|
+
* |----------------------------------- verificationID, providerURL |
|
|
56
|
+
* | | |
|
|
57
|
+
* (3) Open providerURL (with verificationID)------------------------------------>|
|
|
58
|
+
* | | |
|
|
59
|
+
* | | (4) Notify
|
|
60
|
+
* | |<-------- verificationID, verificationStatus, certificates?
|
|
61
|
+
* | |
|
|
62
|
+
* (5) Poll certificate for verificationID --->|
|
|
63
|
+
* | |
|
|
64
|
+
* |<-------------------------- (6) Pending / Certificate(s) / Error
|
|
65
|
+
* | (repeat #5 until complete)
|
|
66
|
+
* |
|
|
67
|
+
* (7) Install certificate(s) in wallet using KeetaNet Client library
|
|
68
|
+
*/
|
|
69
|
+
kyc: {
|
|
70
|
+
/**
|
|
71
|
+
* Notification that a verification has been started (optional)
|
|
72
|
+
*
|
|
73
|
+
* This method can be used to notify the KYC provider that
|
|
74
|
+
* a verification has been started. It can return additional
|
|
75
|
+
* information about the verification, such as the web URL
|
|
76
|
+
* where the user can complete the verification.
|
|
77
|
+
*
|
|
78
|
+
* If this method is not provided, the server will generate
|
|
79
|
+
* a random verification ID and use the `kycProviderURL` from
|
|
80
|
+
* the server configuration, replacing `{id}` with the
|
|
81
|
+
* verification ID.
|
|
82
|
+
*/
|
|
83
|
+
verificationStarted?: (request: KeetaKYCAnchorCreateVerificationRequest) => Promise<Partial<KeetaKYCAnchorCreateVerificationResponse> | undefined>;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieve the certificate for a verification
|
|
86
|
+
*
|
|
87
|
+
* This should return the certificate(s) for the
|
|
88
|
+
* verification ID. If the verification is still
|
|
89
|
+
* in progress, it should throw an `CertificateNotFound`
|
|
90
|
+
* error.
|
|
91
|
+
* If the verification has failed permanently, it should
|
|
92
|
+
* throw a `KeetaAnchorUserError` with an appropriate
|
|
93
|
+
* error message or `VerificationNotFound` if the
|
|
94
|
+
* verification ID is not found.
|
|
95
|
+
*/
|
|
96
|
+
getCertificates: (verificationID: string) => Promise<Extract<KeetaKYCAnchorGetCertificateResponse, {
|
|
97
|
+
ok: true;
|
|
98
|
+
}>['results']>;
|
|
99
|
+
/**
|
|
100
|
+
* Country codes that this KYC provider can service (default is all country codes)
|
|
101
|
+
*/
|
|
102
|
+
countryCodes?: (CurrencyInfo.Country | CurrencyInfo.ISOCountryCode)[];
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* The certificate to use for signing certificates
|
|
106
|
+
*/
|
|
107
|
+
ca: BaseCertificate;
|
|
108
|
+
/**
|
|
109
|
+
* The account to use for signing certificates
|
|
110
|
+
*/
|
|
111
|
+
signer: Signing.SignableAccount;
|
|
112
|
+
/**
|
|
113
|
+
* URL for the KYC Provider (optional)
|
|
114
|
+
*
|
|
115
|
+
* This is the URL that clients will be directed to in order to
|
|
116
|
+
* complete the KYC verification process. It is optional because
|
|
117
|
+
* the `kyc.verificationStarted` method can also return a `webURL`.
|
|
118
|
+
* If both are provided, the URL from `kyc.verificationStarted` takes
|
|
119
|
+
* precedence.
|
|
120
|
+
*/
|
|
121
|
+
kycProviderURL?: string | ((verificationID: string) => string);
|
|
122
|
+
/**
|
|
123
|
+
* Additional routes to add to the server (optional)
|
|
124
|
+
*/
|
|
125
|
+
routes?: KeetaAnchorHTTPServer.Routes;
|
|
126
|
+
}
|
|
127
|
+
export declare class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAnchorHTTPServer<KeetaAnchorKYCServerConfig> implements Required<KeetaAnchorKYCServerConfig> {
|
|
128
|
+
#private;
|
|
129
|
+
readonly homepage: NonNullable<KeetaAnchorKYCServerConfig['homepage']>;
|
|
130
|
+
readonly client: KeetaAnchorKYCServerConfig['client'];
|
|
131
|
+
readonly signer: NonNullable<KeetaAnchorKYCServerConfig['signer']>;
|
|
132
|
+
readonly ca: KeetaAnchorKYCServerConfig['ca'];
|
|
133
|
+
readonly kyc: KeetaAnchorKYCServerConfig['kyc'];
|
|
134
|
+
readonly kycProviderURL: NonNullable<KeetaAnchorKYCServerConfig['kycProviderURL']>;
|
|
135
|
+
readonly routes: NonNullable<KeetaAnchorKYCServerConfig['routes']>;
|
|
136
|
+
constructor(config: KeetaAnchorKYCServerConfig);
|
|
137
|
+
protected initRoutes(config: KeetaAnchorKYCServerConfig): Promise<KeetaAnchorHTTPServer.Routes>;
|
|
138
|
+
serviceMetadata(): Promise<NonNullable<ServiceMetadata['services']['kyc']>[string]>;
|
|
139
|
+
}
|
|
140
|
+
export {};
|
|
141
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/services/kyc/server.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,+BAA+B,CAAC;AACrD,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAE5D,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAIlE,OAAO,KAAK,EACX,uCAAuC,EACvC,wCAAwC,EACxC,oCAAoC,EACpC,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D;;;;GAIG;AACH,KAAK,eAAe,GAAG,YAAY,CAAC,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAEvF,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB,CAA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QAAQ,CAAC,0BAA0B,CAAC;;IAC1K,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC,CAAC;IACvE,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC,QAAQ,CAAC,CAAC;IACtD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnE,QAAQ,CAAC,EAAE,EAAE,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAC9C,QAAQ,CAAC,GAAG,EAAE,0BAA0B,CAAC,KAAK,CAAC,CAAC;IAChD,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,0BAA0B,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACnF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAGvD,MAAM,EAAE,0BAA0B;cAsB9B,UAAU,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC;IAwJ/F,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CAezF"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import KeetaNet from '@keetanetwork/keetanet-client';
|
|
2
|
+
import * as CurrencyInfo from '@keetanetwork/currency-info';
|
|
3
|
+
import * as KeetaAnchorHTTPServer from '../../lib/http-server.js';
|
|
4
|
+
import { KeetaAnchorUserError } from '../../lib/error.js';
|
|
5
|
+
import { assertCreateVerificationRequest, assertCreateVerificationResponse } from './common.generated.js';
|
|
6
|
+
import { verifySignedData } from './common.js';
|
|
7
|
+
const kycProviderURLUndefined = 'NO_KYC_PROVIDER_URL:87f0175c-4d0a-4029-a4f3-ba93ef725654';
|
|
8
|
+
;
|
|
9
|
+
export class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAnchorHTTPServer {
|
|
10
|
+
homepage;
|
|
11
|
+
client;
|
|
12
|
+
signer;
|
|
13
|
+
ca;
|
|
14
|
+
kyc;
|
|
15
|
+
kycProviderURL;
|
|
16
|
+
routes;
|
|
17
|
+
#countryCodes;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
super(config);
|
|
20
|
+
this.homepage = config.homepage ?? '';
|
|
21
|
+
this.client = config.client;
|
|
22
|
+
this.signer = config.signer;
|
|
23
|
+
this.ca = config.ca;
|
|
24
|
+
this.kyc = config.kyc;
|
|
25
|
+
this.routes = config.routes ?? {};
|
|
26
|
+
this.kycProviderURL = config.kycProviderURL ?? kycProviderURLUndefined;
|
|
27
|
+
if (config.kyc.countryCodes) {
|
|
28
|
+
this.#countryCodes = config.kyc.countryCodes.map(function (inputCode) {
|
|
29
|
+
if (CurrencyInfo.Country.isCountryCode(inputCode)) {
|
|
30
|
+
return (new CurrencyInfo.Country(inputCode));
|
|
31
|
+
}
|
|
32
|
+
return (inputCode);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async initRoutes(config) {
|
|
37
|
+
const routes = {};
|
|
38
|
+
/**
|
|
39
|
+
* If a homepage is provided, setup the route for it
|
|
40
|
+
*/
|
|
41
|
+
if ('homepage' in config) {
|
|
42
|
+
routes['GET /'] = async function () {
|
|
43
|
+
let homepageData;
|
|
44
|
+
if (typeof config.homepage === 'string') {
|
|
45
|
+
homepageData = config.homepage;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
if (!config.homepage) {
|
|
49
|
+
throw (new Error('internal error: No homepage function provided'));
|
|
50
|
+
}
|
|
51
|
+
homepageData = await config.homepage();
|
|
52
|
+
}
|
|
53
|
+
return ({
|
|
54
|
+
output: homepageData,
|
|
55
|
+
contentType: 'text/html'
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Begin the KYC verification process
|
|
61
|
+
* with this KYC provider
|
|
62
|
+
*/
|
|
63
|
+
routes['POST /api/createVerification'] = async function (_ignore_params, bodyInput) {
|
|
64
|
+
if (bodyInput === null || typeof bodyInput !== 'object' || !('request' in bodyInput)) {
|
|
65
|
+
throw (new KeetaAnchorUserError('Invalid request'));
|
|
66
|
+
}
|
|
67
|
+
const body = assertCreateVerificationRequest(bodyInput.request);
|
|
68
|
+
const valid = await verifySignedData(body);
|
|
69
|
+
if (!valid) {
|
|
70
|
+
throw (new KeetaAnchorUserError('Invalid signature'));
|
|
71
|
+
}
|
|
72
|
+
/* XXX:TODO: Validate that the nonce is unique (within a reasonable time frame) */
|
|
73
|
+
let response = {};
|
|
74
|
+
if (config.kyc.verificationStarted) {
|
|
75
|
+
response = await config.kyc.verificationStarted(body);
|
|
76
|
+
}
|
|
77
|
+
response ??= {};
|
|
78
|
+
if (response?.ok === false) {
|
|
79
|
+
throw (new KeetaAnchorUserError(response.error ?? 'Unknown error'));
|
|
80
|
+
}
|
|
81
|
+
response.ok = true;
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
throw (new Error('internal error: invalid response'));
|
|
84
|
+
}
|
|
85
|
+
response.id ??= crypto.randomUUID();
|
|
86
|
+
let defaultWebURL;
|
|
87
|
+
if (typeof config.kycProviderURL === 'string') {
|
|
88
|
+
defaultWebURL = config.kycProviderURL.replace('{id}', encodeURIComponent(response.id));
|
|
89
|
+
}
|
|
90
|
+
else if (config.kycProviderURL !== undefined) {
|
|
91
|
+
defaultWebURL = config.kycProviderURL(response.id);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
defaultWebURL = kycProviderURLUndefined;
|
|
95
|
+
}
|
|
96
|
+
response.webURL ??= defaultWebURL;
|
|
97
|
+
if (!response.webURL || response.webURL === kycProviderURLUndefined) {
|
|
98
|
+
throw (new KeetaAnchorUserError('No webURL provided -- cannot proceed with verification'));
|
|
99
|
+
}
|
|
100
|
+
response.expectedCost = {
|
|
101
|
+
min: '0',
|
|
102
|
+
max: '0',
|
|
103
|
+
token: KeetaNet.lib.Account.generateBaseAddresses(config.client.network).baseToken.publicKeyString.get(),
|
|
104
|
+
...response.expectedCost
|
|
105
|
+
};
|
|
106
|
+
const responseValidated = assertCreateVerificationResponse(response);
|
|
107
|
+
return ({
|
|
108
|
+
output: JSON.stringify(responseValidated)
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Request an estimate for a KYC
|
|
113
|
+
* verification (optional)
|
|
114
|
+
*
|
|
115
|
+
* XXX:TODO
|
|
116
|
+
*/
|
|
117
|
+
// if (false) {
|
|
118
|
+
// routes['POST /api/createEstimate'] = async function(_ignore_params, _ignore_body) {
|
|
119
|
+
// throw(new Error('not implemented'));
|
|
120
|
+
// };
|
|
121
|
+
// }
|
|
122
|
+
/**
|
|
123
|
+
* Get the certificate for the
|
|
124
|
+
* KYC verification
|
|
125
|
+
*/
|
|
126
|
+
routes['GET /api/getCertificates/:verificationID'] = async function (params) {
|
|
127
|
+
const verificationID = params.get('verificationID');
|
|
128
|
+
if (verificationID === undefined) {
|
|
129
|
+
throw (new KeetaAnchorUserError('No verification ID provided'));
|
|
130
|
+
}
|
|
131
|
+
const certificates = await config.kyc.getCertificates(verificationID);
|
|
132
|
+
const response = {
|
|
133
|
+
ok: true,
|
|
134
|
+
results: certificates
|
|
135
|
+
};
|
|
136
|
+
return ({
|
|
137
|
+
output: JSON.stringify(response)
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Check if the KYC provider can
|
|
142
|
+
* service a more specific locality
|
|
143
|
+
* (optional)
|
|
144
|
+
*
|
|
145
|
+
* XXX:TODO
|
|
146
|
+
*/
|
|
147
|
+
// if (false) {
|
|
148
|
+
// routes['GET /api/checkLocality'] = async function(_ignore_params, _ignore_body) {
|
|
149
|
+
// throw(new Error('not implemented'));
|
|
150
|
+
// };
|
|
151
|
+
// }
|
|
152
|
+
/**
|
|
153
|
+
* Notification that payment has been received for the KYC verification
|
|
154
|
+
*
|
|
155
|
+
* XXX:TODO
|
|
156
|
+
*/
|
|
157
|
+
// if (false) {
|
|
158
|
+
// routes['POST /api/notifyPayment/:verificationID'] = async function(_ignore_params, _ignore_body) {
|
|
159
|
+
// throw(new Error('not implemented'));
|
|
160
|
+
// };
|
|
161
|
+
// }
|
|
162
|
+
return ({
|
|
163
|
+
...config.routes,
|
|
164
|
+
...routes
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
async serviceMetadata() {
|
|
168
|
+
return ({
|
|
169
|
+
ca: this.ca.toPEM(),
|
|
170
|
+
countryCodes: this.#countryCodes?.map(function (country) {
|
|
171
|
+
return (country.code);
|
|
172
|
+
}) ?? [],
|
|
173
|
+
operations: {
|
|
174
|
+
// checkLocality: (new URL('/api/checkLocality', this.url)).toString(),
|
|
175
|
+
// getEstimate: (new URL('/api/createEstimate', this.url)).toString(),
|
|
176
|
+
// notifyPayment: (new URL('/api/notifyPayment/{id}', this.url)).toString(),
|
|
177
|
+
createVerification: (new URL('/api/createVerification', this.url)).toString(),
|
|
178
|
+
getCertificates: (new URL('/api/getCertificates', this.url)).toString() + '/{id}'
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/services/kyc/server.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,+BAA+B,CAAC;AACrD,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAE5D,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EACN,+BAA+B,EAC/B,gCAAgC,EAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,gBAAgB,EAChB,MAAM,aAAa,CAAC;AAIrB,MAAM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CAAC,EAAE,CAAC,KAAK,EAAE;YACnB,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,UAAS,OAAO;gBACrD,OAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC,CAAC,IAAI,EAAE;YACR,UAAU,EAAE;gBACX,uEAAuE;gBACvE,sEAAsE;gBACtE,4EAA4E;gBAC5E,kBAAkB,EAAE,CAAC,IAAI,GAAG,CAAC,yBAAyB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;gBAC7E,eAAe,EAAE,CAAC,IAAI,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,OAAO;aACjF;SACD,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import KeetaNet from '@keetanetwork/keetanet-client';\nimport * as CurrencyInfo from '@keetanetwork/currency-info';\n\nimport * as KeetaAnchorHTTPServer from '../../lib/http-server.js';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type {\n\tKeetaKYCAnchorCreateVerificationRequest,\n\tKeetaKYCAnchorCreateVerificationResponse,\n\tKeetaKYCAnchorGetCertificateResponse\n} from './common.ts';\nimport {\n\tassertCreateVerificationRequest,\n\tassertCreateVerificationResponse\n} from './common.generated.js';\nimport {\n\tverifySignedData\n} from './common.js';\nimport type * as Signing from '../../lib/utils/signing.js';\nimport type { ServiceMetadata } from '../../lib/resolver.ts';\n\nconst kycProviderURLUndefined = 'NO_KYC_PROVIDER_URL:87f0175c-4d0a-4029-a4f3-ba93ef725654';\n\n/**\n * The Base certificate type, from the KeetaNet Client\n *\n * The KYC Certificate type is a subclass of this, so it will also work\n */\ntype BaseCertificate = InstanceType<typeof KeetaNet.lib.Utils.Certificate.Certificate>;\n\nexport interface KeetaAnchorKYCServerConfig extends KeetaAnchorHTTPServer.KeetaAnchorHTTPServerConfig {\n\t/**\n\t * The data to use for the index page (optional)\n\t */\n\thomepage?: string | (() => Promise<string> | string);\n\n\t/**\n\t * The network client to use for submitting blocks\n\t */\n\tclient: { client: KeetaNet.Client; network: bigint; networkAlias: typeof KeetaNet.Client.Config.networksArray[number] } | KeetaNet.UserClient;\n\n\t/**\n\t * Configuration for the KYC Anchor\n\t *\n\t * The flow for a KYC Anchor is as follows:\n\t * 1. Client requests a new verification with a country code and\n\t * account from the KYC Anchor Server\n\t * 2. KYC Anchor Server responds with a verification ID and a URL\n\t * to the KYC provider's web URL, including the verification ID\n\t * 3. Client visits the KYC provider's web URL to complete the\n\t * verification\n\t * 4. KYC provider notifies the Anchor server that the\n\t * verification is complete\n\t * 5. Client requests the certificate for the verification ID\n\t * (polling) from the KYC Anchor Server\n\t * 6. KYC Anchor Server responds with the certificate(s) for the\n\t * verification ID (if complete, pending if still in progress,\n\t * an error if failed)\n\t * 7. Client installs the certificate(s) in their wallet using\n\t * the KeetaNet Client library\n\t *\n\t *\n\t * +-------------------+ +---------------------+ +------------------+\n\t * | Client | | KYC Anchor Server | | KYC Provider |\n\t * +-------------------+ +---------------------+ +------------------+\n\t * | | |\n\t * (1) Create Verification | |\n\t * countryCode, account ---------------------->| |\n\t * | | |\n\t * | (2) Create verification |\n\t * |----------------------------------- verificationID, providerURL |\n\t * | | |\n\t * (3) Open providerURL (with verificationID)------------------------------------>|\n\t * | | |\n\t * | | (4) Notify\n\t * | |<-------- verificationID, verificationStatus, certificates?\n\t * | |\n\t * (5) Poll certificate for verificationID --->|\n\t * | |\n\t * |<-------------------------- (6) Pending / Certificate(s) / Error\n\t * | (repeat #5 until complete)\n\t * |\n\t * (7) Install certificate(s) in wallet using KeetaNet Client library\n\t */\n\tkyc: {\n\t\t/**\n\t\t * Notification that a verification has been started (optional)\n\t\t *\n\t\t * This method can be used to notify the KYC provider that\n\t\t * a verification has been started. It can return additional\n\t\t * information about the verification, such as the web URL\n\t\t * where the user can complete the verification.\n\t\t *\n\t\t * If this method is not provided, the server will generate\n\t\t * a random verification ID and use the `kycProviderURL` from\n\t\t * the server configuration, replacing `{id}` with the\n\t\t * verification ID.\n\t\t */\n\t\tverificationStarted?: (request: KeetaKYCAnchorCreateVerificationRequest) => Promise<Partial<KeetaKYCAnchorCreateVerificationResponse> | undefined>;\n\n\t\t/**\n\t\t * Retrieve the certificate for a verification\n\t\t *\n\t\t * This should return the certificate(s) for the\n\t\t * verification ID. If the verification is still\n\t\t * in progress, it should throw an `CertificateNotFound`\n\t\t * error.\n\t\t * If the verification has failed permanently, it should\n\t\t * throw a `KeetaAnchorUserError` with an appropriate\n\t\t * error message or `VerificationNotFound` if the\n\t\t * verification ID is not found.\n\t\t */\n\t\tgetCertificates: (verificationID: string) => Promise<Extract<KeetaKYCAnchorGetCertificateResponse, { ok: true; }>['results']>;\n\n\t\t/**\n\t\t * Country codes that this KYC provider can service (default is all country codes)\n\t\t */\n\t\tcountryCodes?: (CurrencyInfo.Country | CurrencyInfo.ISOCountryCode)[];\n\t}\n\n\t/**\n\t * The certificate to use for signing certificates\n\t */\n\tca: BaseCertificate;\n\n\t/**\n\t * The account to use for signing certificates\n\t */\n\tsigner: Signing.SignableAccount;\n\n\t/**\n\t * URL for the KYC Provider (optional)\n\t *\n\t * This is the URL that clients will be directed to in order to\n\t * complete the KYC verification process. It is optional because\n\t * the `kyc.verificationStarted` method can also return a `webURL`.\n\t * If both are provided, the URL from `kyc.verificationStarted` takes\n\t * precedence.\n\t */\n\tkycProviderURL?: string | ((verificationID: string) => string);\n\n\t/**\n\t * Additional routes to add to the server (optional)\n\t */\n\troutes?: KeetaAnchorHTTPServer.Routes;\n};\n\nexport class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorHTTPServer.KeetaNetAnchorHTTPServer<KeetaAnchorKYCServerConfig> implements Required<KeetaAnchorKYCServerConfig> {\n\treadonly homepage: NonNullable<KeetaAnchorKYCServerConfig['homepage']>;\n\treadonly client: KeetaAnchorKYCServerConfig['client'];\n\treadonly signer: NonNullable<KeetaAnchorKYCServerConfig['signer']>;\n\treadonly ca: KeetaAnchorKYCServerConfig['ca'];\n\treadonly kyc: KeetaAnchorKYCServerConfig['kyc'];\n\treadonly kycProviderURL: NonNullable<KeetaAnchorKYCServerConfig['kycProviderURL']>;\n\treadonly routes: NonNullable<KeetaAnchorKYCServerConfig['routes']>;\n\treadonly #countryCodes?: CurrencyInfo.Country[] | undefined;\n\n\tconstructor(config: KeetaAnchorKYCServerConfig) {\n\t\tsuper(config);\n\n\t\tthis.homepage = config.homepage ?? '';\n\t\tthis.client = config.client;\n\t\tthis.signer = config.signer;\n\t\tthis.ca = config.ca;\n\t\tthis.kyc = config.kyc;\n\t\tthis.routes = config.routes ?? {};\n\t\tthis.kycProviderURL = config.kycProviderURL ?? kycProviderURLUndefined;\n\n\t\tif (config.kyc.countryCodes) {\n\t\t\tthis.#countryCodes = config.kyc.countryCodes.map(function(inputCode) {\n\t\t\t\tif (CurrencyInfo.Country.isCountryCode(inputCode)) {\n\t\t\t\t\treturn(new CurrencyInfo.Country(inputCode));\n\t\t\t\t}\n\n\t\t\t\treturn(inputCode);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected async initRoutes(config: KeetaAnchorKYCServerConfig): Promise<KeetaAnchorHTTPServer.Routes> {\n\t\tconst routes: KeetaAnchorHTTPServer.Routes = {};\n\n\t\t/**\n\t\t * If a homepage is provided, setup the route for it\n\t\t */\n\t\tif ('homepage' in config) {\n\t\t\troutes['GET /'] = async function() {\n\t\t\t\tlet homepageData: string;\n\t\t\t\tif (typeof config.homepage === 'string') {\n\t\t\t\t\thomepageData = config.homepage;\n\t\t\t\t} else {\n\t\t\t\t\tif (!config.homepage) {\n\t\t\t\t\t\tthrow(new Error('internal error: No homepage function provided'));\n\t\t\t\t\t}\n\n\t\t\t\t\thomepageData = await config.homepage();\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: homepageData,\n\t\t\t\t\tcontentType: 'text/html'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Begin the KYC verification process\n\t\t * with this KYC provider\n\t\t */\n\t\troutes['POST /api/createVerification'] = async function(_ignore_params, bodyInput) {\n\t\t\tif (bodyInput === null || typeof bodyInput !== 'object' || !('request' in bodyInput)) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Invalid request'));\n\t\t\t}\n\n\t\t\tconst body = assertCreateVerificationRequest(bodyInput.request);\n\t\t\tconst valid = await verifySignedData(body);\n\t\t\tif (!valid) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Invalid signature'));\n\t\t\t}\n\n\t\t\t/* XXX:TODO: Validate that the nonce is unique (within a reasonable time frame) */\n\n\t\t\tlet response: Partial<KeetaKYCAnchorCreateVerificationResponse> | undefined = {};\n\t\t\tif (config.kyc.verificationStarted) {\n\t\t\t\tresponse = await config.kyc.verificationStarted(body);\n\t\t\t}\n\n\t\t\tresponse ??= {};\n\n\t\t\tif (response?.ok === false) {\n\t\t\t\tthrow(new KeetaAnchorUserError(response.error ?? 'Unknown error'));\n\t\t\t}\n\n\t\t\tresponse.ok = true;\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow(new Error('internal error: invalid response'));\n\t\t\t}\n\t\t\tresponse.id ??= crypto.randomUUID();\n\n\t\t\tlet defaultWebURL: string;\n\t\t\tif (typeof config.kycProviderURL === 'string') {\n\t\t\t\tdefaultWebURL = config.kycProviderURL.replace('{id}', encodeURIComponent(response.id));\n\t\t\t} else if (config.kycProviderURL !== undefined) {\n\t\t\t\tdefaultWebURL = config.kycProviderURL(response.id);\n\t\t\t} else {\n\t\t\t\tdefaultWebURL = kycProviderURLUndefined;\n\t\t\t}\n\t\t\tresponse.webURL ??= defaultWebURL;\n\n\t\t\tif (!response.webURL || response.webURL === kycProviderURLUndefined) {\n\t\t\t\tthrow(new KeetaAnchorUserError('No webURL provided -- cannot proceed with verification'));\n\t\t\t}\n\n\t\t\tresponse.expectedCost = {\n\t\t\t\tmin: '0',\n\t\t\t\tmax: '0',\n\t\t\t\ttoken: KeetaNet.lib.Account.generateBaseAddresses(config.client.network).baseToken.publicKeyString.get(),\n\t\t\t\t...response.expectedCost\n\t\t\t};\n\n\t\t\tconst responseValidated = assertCreateVerificationResponse(response);\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(responseValidated)\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Request an estimate for a KYC\n\t\t * verification (optional)\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['POST /api/createEstimate'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\t/**\n\t\t * Get the certificate for the\n\t\t * KYC verification\n\t\t */\n\t\troutes['GET /api/getCertificates/:verificationID'] = async function(params) {\n\t\t\tconst verificationID = params.get('verificationID');\n\t\t\tif (verificationID === undefined) {\n\t\t\t\tthrow(new KeetaAnchorUserError('No verification ID provided'));\n\t\t\t}\n\n\t\t\tconst certificates = await config.kyc.getCertificates(verificationID);\n\n\t\t\tconst response: KeetaKYCAnchorGetCertificateResponse = {\n\t\t\t\tok: true,\n\t\t\t\tresults: certificates\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(response)\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Check if the KYC provider can\n\t\t * service a more specific locality\n\t\t * (optional)\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['GET /api/checkLocality'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\t/**\n\t\t * Notification that payment has been received for the KYC verification\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['POST /api/notifyPayment/:verificationID'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\treturn({\n\t\t\t...config.routes,\n\t\t\t...routes\n\t\t});\n\t}\n\n\tasync serviceMetadata(): Promise<NonNullable<ServiceMetadata['services']['kyc']>[string]> {\n\t\treturn({\n\t\t\tca: this.ca.toPEM(),\n\t\t\tcountryCodes: this.#countryCodes?.map(function(country) {\n\t\t\t\treturn(country.code);\n\t\t\t}) ?? [],\n\t\t\toperations: {\n\t\t\t\t// checkLocality: (new URL('/api/checkLocality', this.url)).toString(),\n\t\t\t\t// getEstimate: (new URL('/api/createEstimate', this.url)).toString(),\n\t\t\t\t// notifyPayment: (new URL('/api/notifyPayment/{id}', this.url)).toString(),\n\t\t\t\tcreateVerification: (new URL('/api/createVerification', this.url)).toString(),\n\t\t\t\tgetCertificates: (new URL('/api/getCertificates', this.url)).toString() + '/{id}'\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-kyc-schema.d.ts","sourceRoot":"","sources":["../../../../src/services/kyc/utils/generate-kyc-schema.ts"],"names":[],"mappings":""}
|