@keetanetwork/anchor 0.0.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.
Files changed (76) hide show
  1. package/.done +0 -0
  2. package/LICENSE +35 -0
  3. package/client/index.d.ts +10 -0
  4. package/client/index.d.ts.map +1 -0
  5. package/client/index.js +11 -0
  6. package/client/index.js.map +1 -0
  7. package/config.d.ts +10 -0
  8. package/config.d.ts.map +1 -0
  9. package/config.js +36 -0
  10. package/config.js.map +1 -0
  11. package/lib/certificates.d.ts +106 -0
  12. package/lib/certificates.d.ts.map +1 -0
  13. package/lib/certificates.js +463 -0
  14. package/lib/certificates.js.map +1 -0
  15. package/lib/encrypted-container.d.ts +106 -0
  16. package/lib/encrypted-container.d.ts.map +1 -0
  17. package/lib/encrypted-container.js +594 -0
  18. package/lib/encrypted-container.js.map +1 -0
  19. package/lib/index.d.ts +5 -0
  20. package/lib/index.d.ts.map +1 -0
  21. package/lib/index.js +5 -0
  22. package/lib/index.js.map +1 -0
  23. package/lib/log/common.d.ts +35 -0
  24. package/lib/log/common.d.ts.map +1 -0
  25. package/lib/log/common.js +19 -0
  26. package/lib/log/common.js.map +1 -0
  27. package/lib/log/index.d.ts +59 -0
  28. package/lib/log/index.d.ts.map +1 -0
  29. package/lib/log/index.js +207 -0
  30. package/lib/log/index.js.map +1 -0
  31. package/lib/log/target_console.d.ts +13 -0
  32. package/lib/log/target_console.d.ts.map +1 -0
  33. package/lib/log/target_console.js +44 -0
  34. package/lib/log/target_console.js.map +1 -0
  35. package/lib/resolver.d.ts +308 -0
  36. package/lib/resolver.d.ts.map +1 -0
  37. package/lib/resolver.js +1429 -0
  38. package/lib/resolver.js.map +1 -0
  39. package/lib/utils/array.d.ts +10 -0
  40. package/lib/utils/array.d.ts.map +1 -0
  41. package/lib/utils/array.js +12 -0
  42. package/lib/utils/array.js.map +1 -0
  43. package/lib/utils/asn1.d.ts +13 -0
  44. package/lib/utils/asn1.d.ts.map +1 -0
  45. package/lib/utils/asn1.js +8 -0
  46. package/lib/utils/asn1.js.map +1 -0
  47. package/lib/utils/buffer.d.ts +4 -0
  48. package/lib/utils/buffer.d.ts.map +1 -0
  49. package/lib/utils/buffer.js +3 -0
  50. package/lib/utils/buffer.js.map +1 -0
  51. package/lib/utils/crypto.d.ts +4 -0
  52. package/lib/utils/crypto.d.ts.map +1 -0
  53. package/lib/utils/crypto.js +4 -0
  54. package/lib/utils/crypto.js.map +1 -0
  55. package/lib/utils/index.d.ts +5 -0
  56. package/lib/utils/index.d.ts.map +1 -0
  57. package/lib/utils/index.js +5 -0
  58. package/lib/utils/index.js.map +1 -0
  59. package/lib/utils/json.d.ts +8 -0
  60. package/lib/utils/json.d.ts.map +1 -0
  61. package/lib/utils/json.js +164 -0
  62. package/lib/utils/json.js.map +1 -0
  63. package/lib/utils/never.d.ts +8 -0
  64. package/lib/utils/never.d.ts.map +1 -0
  65. package/lib/utils/never.js +14 -0
  66. package/lib/utils/never.js.map +1 -0
  67. package/npm-shrinkwrap.json +16517 -0
  68. package/package.json +42 -0
  69. package/services/kyc/client.d.ts +139 -0
  70. package/services/kyc/client.d.ts.map +1 -0
  71. package/services/kyc/client.js +390 -0
  72. package/services/kyc/client.js.map +1 -0
  73. package/services/kyc/common.d.ts +65 -0
  74. package/services/kyc/common.d.ts.map +1 -0
  75. package/services/kyc/common.js +2 -0
  76. package/services/kyc/common.js.map +1 -0
@@ -0,0 +1,1429 @@
1
+ import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
2
+ import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
3
+ import * as KeetaNetClient from '@keetanetwork/keetanet-client';
4
+ import CurrencyInfo from '@keetanetwork/currency-info';
5
+ import { assertNever } from './utils/never.js';
6
+ import { Buffer } from './utils/buffer.js';
7
+ import crypto from './utils/crypto.js';
8
+ import { createIs, createAssert } from 'typia';
9
+ function convertToCurrencySearchCanonical(input) {
10
+ if (CurrencyInfo.Currency.isCurrencyCode(input)) {
11
+ return (input);
12
+ }
13
+ else if (CurrencyInfo.Currency.isISOCurrencyNumber(input)) {
14
+ input = new CurrencyInfo.Currency(input);
15
+ }
16
+ return (input.code);
17
+ }
18
+ function convertToCountrySearchCanonical(input) {
19
+ if (CurrencyInfo.Country.isCountryCode(input)) {
20
+ return (input);
21
+ }
22
+ else if (CurrencyInfo.Country.isISOCountryNumber(input)) {
23
+ input = new CurrencyInfo.Country(input);
24
+ }
25
+ return (input.code);
26
+ }
27
+ /**
28
+ * Check if a value is an ExternalURL
29
+ */
30
+ const isExternalURL = (() => { const _io0 = input => "2b828e33-2692-46e9-817e-9b93d63f28fd" === input.external && "string" === typeof input.url; return input => "object" === typeof input && null !== input && _io0(input); })();
31
+ ;
32
+ ;
33
+ ;
34
+ ;
35
+ /*
36
+ * Access token to share with the Metadata object to allow it to
37
+ * access the mutable stats object.
38
+ */
39
+ const statsAccessToken = Symbol('statsAccessToken');
40
+ const assertServiceMetadata = (() => { const _io0 = input => "2b828e33-2692-46e9-817e-9b93d63f28fd" === input.external && "string" === typeof input.url; const _io1 = input => null !== input.version && undefined !== input.version && ("number" === typeof input.version || "object" === typeof input.version && null !== input.version && _io0(input.version)) && ("object" === typeof input.services && null !== input.services && false === Array.isArray(input.services) && _iu1(input.services)); const _io2 = input => (undefined === input.banking || "object" === typeof input.banking && null !== input.banking && false === Array.isArray(input.banking) && _iu2(input.banking)) && (undefined === input.kyc || "object" === typeof input.kyc && null !== input.kyc && false === Array.isArray(input.kyc) && _iu3(input.kyc)) && (undefined === input.fx || "object" === typeof input.fx && null !== input.fx && _iu4(input.fx)) && (undefined === input.inbound || "object" === typeof input.inbound && null !== input.inbound && false === Array.isArray(input.inbound) && _iu5(input.inbound)) && (undefined === input.outbound || "object" === typeof input.outbound && null !== input.outbound && false === Array.isArray(input.outbound) && _iu6(input.outbound)) && (undefined === input.cards || "object" === typeof input.cards && null !== input.cards && false === Array.isArray(input.cards) && _iu7(input.cards)); const _io3 = input => Object.keys(input).every(key => {
41
+ const value = input[key];
42
+ if (undefined === value)
43
+ return true;
44
+ return "object" === typeof value && null !== value && _iu8(value);
45
+ }); const _io4 = input => "object" === typeof input.operations && null !== input.operations && false === Array.isArray(input.operations) && _iu9(input.operations) && (null !== input.currencyCodes && undefined !== input.currencyCodes && (Array.isArray(input.currencyCodes) && input.currencyCodes.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io0(elem))) || "object" === typeof input.currencyCodes && null !== input.currencyCodes && _io0(input.currencyCodes))) && (null !== input.countryCodes && undefined !== input.countryCodes && (Array.isArray(input.countryCodes) && input.countryCodes.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io0(elem))) || "object" === typeof input.countryCodes && null !== input.countryCodes && _io0(input.countryCodes))) && (null !== input.kycProviders && (undefined === input.kycProviders || (Array.isArray(input.kycProviders) && input.kycProviders.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io0(elem))) || "object" === typeof input.kycProviders && null !== input.kycProviders && _io0(input.kycProviders)))); const _io5 = input => null !== input.createAccount && (undefined === input.createAccount || "string" === typeof input.createAccount || "object" === typeof input.createAccount && null !== input.createAccount && _io0(input.createAccount)); const _io6 = input => Object.keys(input).every(key => {
46
+ const value = input[key];
47
+ if (undefined === value)
48
+ return true;
49
+ return "object" === typeof value && null !== value && _iu10(value);
50
+ }); const _io7 = input => "object" === typeof input.operations && null !== input.operations && false === Array.isArray(input.operations) && _iu11(input.operations) && (null !== input.countryCodes && (undefined === input.countryCodes || (Array.isArray(input.countryCodes) && input.countryCodes.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io0(elem))) || "object" === typeof input.countryCodes && null !== input.countryCodes && _io0(input.countryCodes)))) && (null !== input.ca && undefined !== input.ca && ("string" === typeof input.ca || "object" === typeof input.ca && null !== input.ca && _io0(input.ca))); const _io8 = input => null !== input.checkLocality && (undefined === input.checkLocality || "string" === typeof input.checkLocality || "object" === typeof input.checkLocality && null !== input.checkLocality && _io0(input.checkLocality)) && (null !== input.getEstimate && (undefined === input.getEstimate || "string" === typeof input.getEstimate || "object" === typeof input.getEstimate && null !== input.getEstimate && _io0(input.getEstimate))) && (null !== input.createVerification && (undefined === input.createVerification || "string" === typeof input.createVerification || "object" === typeof input.createVerification && null !== input.createVerification && _io0(input.createVerification))) && (null !== input.getCertificates && (undefined === input.getCertificates || "string" === typeof input.getCertificates || "object" === typeof input.getCertificates && null !== input.getCertificates && _io0(input.getCertificates))); const _io9 = input => null !== input.inputCurrencyCodes && undefined !== input.inputCurrencyCodes && (Array.isArray(input.inputCurrencyCodes) && input.inputCurrencyCodes.every(elem => "object" === typeof elem && null !== elem && _iu0(elem)) || "object" === typeof input.inputCurrencyCodes && null !== input.inputCurrencyCodes && _io0(input.inputCurrencyCodes)); const _io10 = input => null !== input.outputCurrencyCodes && undefined !== input.outputCurrencyCodes && (Array.isArray(input.outputCurrencyCodes) && input.outputCurrencyCodes.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io0(elem))) || "object" === typeof input.outputCurrencyCodes && null !== input.outputCurrencyCodes && _io0(input.outputCurrencyCodes)) && (null !== input.kycProviders && undefined !== input.kycProviders && (Array.isArray(input.kycProviders) && input.kycProviders.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io0(elem))) || "object" === typeof input.kycProviders && null !== input.kycProviders && _io0(input.kycProviders))); const _io11 = input => null !== input.workInProgress && (undefined === input.workInProgress || true === input.workInProgress || "object" === typeof input.workInProgress && null !== input.workInProgress && _io0(input.workInProgress)); const _io12 = input => null !== input.workInProgress && (undefined === input.workInProgress || true === input.workInProgress || "object" === typeof input.workInProgress && null !== input.workInProgress && _io0(input.workInProgress)); const _io13 = input => null !== input.workInProgress && (undefined === input.workInProgress || true === input.workInProgress || "object" === typeof input.workInProgress && null !== input.workInProgress && _io0(input.workInProgress)); const _iu0 = input => (() => {
51
+ if (undefined !== input.external)
52
+ return _io0(input);
53
+ else if (undefined !== input.outputCurrencyCodes)
54
+ return _io10(input);
55
+ else
56
+ return false;
57
+ })(); const _iu1 = input => (() => {
58
+ if (undefined !== input.external)
59
+ return _io0(input);
60
+ else
61
+ return _io2(input);
62
+ })(); const _iu2 = input => (() => {
63
+ if (undefined !== input.external)
64
+ return _io0(input);
65
+ else
66
+ return _io3(input);
67
+ })(); const _iu3 = input => (() => {
68
+ if (undefined !== input.external)
69
+ return _io0(input);
70
+ else
71
+ return _io6(input);
72
+ })(); const _iu4 = input => (() => {
73
+ if (undefined !== input.external)
74
+ return _io0(input);
75
+ else if (undefined !== input.inputCurrencyCodes)
76
+ return _io9(input);
77
+ else
78
+ return false;
79
+ })(); const _iu5 = input => (() => {
80
+ if (undefined !== input.external)
81
+ return _io0(input);
82
+ else
83
+ return _io11(input);
84
+ })(); const _iu6 = input => (() => {
85
+ if (undefined !== input.external)
86
+ return _io0(input);
87
+ else
88
+ return _io12(input);
89
+ })(); const _iu7 = input => (() => {
90
+ if (undefined !== input.external)
91
+ return _io0(input);
92
+ else
93
+ return _io13(input);
94
+ })(); const _iu8 = input => (() => {
95
+ if (undefined !== input.external)
96
+ return _io0(input);
97
+ else if (undefined !== input.operations)
98
+ return _io4(input);
99
+ else
100
+ return false;
101
+ })(); const _iu9 = input => (() => {
102
+ if (undefined !== input.external)
103
+ return _io0(input);
104
+ else
105
+ return _io5(input);
106
+ })(); const _iu10 = input => (() => {
107
+ if (undefined !== input.external)
108
+ return _io0(input);
109
+ else if (undefined !== input.operations)
110
+ return _io7(input);
111
+ else
112
+ return false;
113
+ })(); const _iu11 = input => (() => {
114
+ if (undefined !== input.external)
115
+ return _io0(input);
116
+ else
117
+ return _io8(input);
118
+ })(); const _iu12 = input => (() => {
119
+ if (undefined !== input.external)
120
+ return _io0(input);
121
+ else if (undefined !== input.version)
122
+ return _io1(input);
123
+ else
124
+ return false;
125
+ })(); const _ao0 = (input, _path, _exceptionable = true) => ("2b828e33-2692-46e9-817e-9b93d63f28fd" === input.external || __typia_transform__assertGuard._assertGuard(_exceptionable, {
126
+ method: "createAssert",
127
+ path: _path + ".external",
128
+ expected: "\"2b828e33-2692-46e9-817e-9b93d63f28fd\"",
129
+ value: input.external
130
+ }, _errorFactory)) && ("string" === typeof input.url || __typia_transform__assertGuard._assertGuard(_exceptionable, {
131
+ method: "createAssert",
132
+ path: _path + ".url",
133
+ expected: "string",
134
+ value: input.url
135
+ }, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => (null !== input.version || __typia_transform__assertGuard._assertGuard(_exceptionable, {
136
+ method: "createAssert",
137
+ path: _path + ".version",
138
+ expected: "(ExternalURL | number)",
139
+ value: input.version
140
+ }, _errorFactory)) && (undefined !== input.version || __typia_transform__assertGuard._assertGuard(_exceptionable, {
141
+ method: "createAssert",
142
+ path: _path + ".version",
143
+ expected: "(ExternalURL | number)",
144
+ value: input.version
145
+ }, _errorFactory)) && ("number" === typeof input.version || ("object" === typeof input.version && null !== input.version || __typia_transform__assertGuard._assertGuard(_exceptionable, {
146
+ method: "createAssert",
147
+ path: _path + ".version",
148
+ expected: "(ExternalURL | number)",
149
+ value: input.version
150
+ }, _errorFactory)) && _ao0(input.version, _path + ".version", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
151
+ method: "createAssert",
152
+ path: _path + ".version",
153
+ expected: "(ExternalURL | number)",
154
+ value: input.version
155
+ }, _errorFactory)) && (("object" === typeof input.services && null !== input.services && false === Array.isArray(input.services) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
156
+ method: "createAssert",
157
+ path: _path + ".services",
158
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>)",
159
+ value: input.services
160
+ }, _errorFactory)) && _au1(input.services, _path + ".services", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
161
+ method: "createAssert",
162
+ path: _path + ".services",
163
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>)",
164
+ value: input.services
165
+ }, _errorFactory)); const _ao2 = (input, _path, _exceptionable = true) => (undefined === input.banking || ("object" === typeof input.banking && null !== input.banking && false === Array.isArray(input.banking) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
166
+ method: "createAssert",
167
+ path: _path + ".banking",
168
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o1 | undefined)",
169
+ value: input.banking
170
+ }, _errorFactory)) && _au2(input.banking, _path + ".banking", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
171
+ method: "createAssert",
172
+ path: _path + ".banking",
173
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o1 | undefined)",
174
+ value: input.banking
175
+ }, _errorFactory)) && (undefined === input.kyc || ("object" === typeof input.kyc && null !== input.kyc && false === Array.isArray(input.kyc) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
176
+ method: "createAssert",
177
+ path: _path + ".kyc",
178
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o4 | undefined)",
179
+ value: input.kyc
180
+ }, _errorFactory)) && _au3(input.kyc, _path + ".kyc", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
181
+ method: "createAssert",
182
+ path: _path + ".kyc",
183
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o4 | undefined)",
184
+ value: input.kyc
185
+ }, _errorFactory)) && (undefined === input.fx || ("object" === typeof input.fx && null !== input.fx || __typia_transform__assertGuard._assertGuard(_exceptionable, {
186
+ method: "createAssert",
187
+ path: _path + ".fx",
188
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o7 | undefined)",
189
+ value: input.fx
190
+ }, _errorFactory)) && _au4(input.fx, _path + ".fx", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
191
+ method: "createAssert",
192
+ path: _path + ".fx",
193
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o7 | undefined)",
194
+ value: input.fx
195
+ }, _errorFactory)) && (undefined === input.inbound || ("object" === typeof input.inbound && null !== input.inbound && false === Array.isArray(input.inbound) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
196
+ method: "createAssert",
197
+ path: _path + ".inbound",
198
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o9 | undefined)",
199
+ value: input.inbound
200
+ }, _errorFactory)) && _au5(input.inbound, _path + ".inbound", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
201
+ method: "createAssert",
202
+ path: _path + ".inbound",
203
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o9 | undefined)",
204
+ value: input.inbound
205
+ }, _errorFactory)) && (undefined === input.outbound || ("object" === typeof input.outbound && null !== input.outbound && false === Array.isArray(input.outbound) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
206
+ method: "createAssert",
207
+ path: _path + ".outbound",
208
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o10 | undefined)",
209
+ value: input.outbound
210
+ }, _errorFactory)) && _au6(input.outbound, _path + ".outbound", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
211
+ method: "createAssert",
212
+ path: _path + ".outbound",
213
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o10 | undefined)",
214
+ value: input.outbound
215
+ }, _errorFactory)) && (undefined === input.cards || ("object" === typeof input.cards && null !== input.cards && false === Array.isArray(input.cards) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
216
+ method: "createAssert",
217
+ path: _path + ".cards",
218
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o11 | undefined)",
219
+ value: input.cards
220
+ }, _errorFactory)) && _au7(input.cards, _path + ".cards", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
221
+ method: "createAssert",
222
+ path: _path + ".cards",
223
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o11 | undefined)",
224
+ value: input.cards
225
+ }, _errorFactory)); const _ao3 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every(key => {
226
+ const value = input[key];
227
+ if (undefined === value)
228
+ return true;
229
+ return ("object" === typeof value && null !== value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
230
+ method: "createAssert",
231
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
232
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o2)",
233
+ value: value
234
+ }, _errorFactory)) && _au8(value, _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key), true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
235
+ method: "createAssert",
236
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
237
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o2)",
238
+ value: value
239
+ }, _errorFactory);
240
+ }); const _ao4 = (input, _path, _exceptionable = true) => (("object" === typeof input.operations && null !== input.operations && false === Array.isArray(input.operations) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
241
+ method: "createAssert",
242
+ path: _path + ".operations",
243
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o3)",
244
+ value: input.operations
245
+ }, _errorFactory)) && _au9(input.operations, _path + ".operations", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
246
+ method: "createAssert",
247
+ path: _path + ".operations",
248
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o3)",
249
+ value: input.operations
250
+ }, _errorFactory)) && ((null !== input.currencyCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
251
+ method: "createAssert",
252
+ path: _path + ".currencyCodes",
253
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
254
+ value: input.currencyCodes
255
+ }, _errorFactory)) && (undefined !== input.currencyCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
256
+ method: "createAssert",
257
+ path: _path + ".currencyCodes",
258
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
259
+ value: input.currencyCodes
260
+ }, _errorFactory)) && (Array.isArray(input.currencyCodes) && input.currencyCodes.every((elem, _index8) => (null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
261
+ method: "createAssert",
262
+ path: _path + ".currencyCodes[" + _index8 + "]",
263
+ expected: "(ExternalURL | string)",
264
+ value: elem
265
+ }, _errorFactory)) && (undefined !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
266
+ method: "createAssert",
267
+ path: _path + ".currencyCodes[" + _index8 + "]",
268
+ expected: "(ExternalURL | string)",
269
+ value: elem
270
+ }, _errorFactory)) && ("string" === typeof elem || ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
271
+ method: "createAssert",
272
+ path: _path + ".currencyCodes[" + _index8 + "]",
273
+ expected: "(ExternalURL | string)",
274
+ value: elem
275
+ }, _errorFactory)) && _ao0(elem, _path + ".currencyCodes[" + _index8 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
276
+ method: "createAssert",
277
+ path: _path + ".currencyCodes[" + _index8 + "]",
278
+ expected: "(ExternalURL | string)",
279
+ value: elem
280
+ }, _errorFactory))) || "object" === typeof input.currencyCodes && null !== input.currencyCodes && _ao0(input.currencyCodes, _path + ".currencyCodes", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
281
+ method: "createAssert",
282
+ path: _path + ".currencyCodes",
283
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
284
+ value: input.currencyCodes
285
+ }, _errorFactory) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
286
+ method: "createAssert",
287
+ path: _path + ".currencyCodes",
288
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
289
+ value: input.currencyCodes
290
+ }, _errorFactory))) && ((null !== input.countryCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
291
+ method: "createAssert",
292
+ path: _path + ".countryCodes",
293
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
294
+ value: input.countryCodes
295
+ }, _errorFactory)) && (undefined !== input.countryCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
296
+ method: "createAssert",
297
+ path: _path + ".countryCodes",
298
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
299
+ value: input.countryCodes
300
+ }, _errorFactory)) && (Array.isArray(input.countryCodes) && input.countryCodes.every((elem, _index9) => (null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
301
+ method: "createAssert",
302
+ path: _path + ".countryCodes[" + _index9 + "]",
303
+ expected: "(ExternalURL | string)",
304
+ value: elem
305
+ }, _errorFactory)) && (undefined !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
306
+ method: "createAssert",
307
+ path: _path + ".countryCodes[" + _index9 + "]",
308
+ expected: "(ExternalURL | string)",
309
+ value: elem
310
+ }, _errorFactory)) && ("string" === typeof elem || ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
311
+ method: "createAssert",
312
+ path: _path + ".countryCodes[" + _index9 + "]",
313
+ expected: "(ExternalURL | string)",
314
+ value: elem
315
+ }, _errorFactory)) && _ao0(elem, _path + ".countryCodes[" + _index9 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
316
+ method: "createAssert",
317
+ path: _path + ".countryCodes[" + _index9 + "]",
318
+ expected: "(ExternalURL | string)",
319
+ value: elem
320
+ }, _errorFactory))) || "object" === typeof input.countryCodes && null !== input.countryCodes && _ao0(input.countryCodes, _path + ".countryCodes", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
321
+ method: "createAssert",
322
+ path: _path + ".countryCodes",
323
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
324
+ value: input.countryCodes
325
+ }, _errorFactory) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
326
+ method: "createAssert",
327
+ path: _path + ".countryCodes",
328
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
329
+ value: input.countryCodes
330
+ }, _errorFactory))) && ((null !== input.kycProviders || __typia_transform__assertGuard._assertGuard(_exceptionable, {
331
+ method: "createAssert",
332
+ path: _path + ".kycProviders",
333
+ expected: "(Array<string | ExternalURL> | ExternalURL | undefined)",
334
+ value: input.kycProviders
335
+ }, _errorFactory)) && (undefined === input.kycProviders || (Array.isArray(input.kycProviders) && input.kycProviders.every((elem, _index10) => (null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
336
+ method: "createAssert",
337
+ path: _path + ".kycProviders[" + _index10 + "]",
338
+ expected: "(ExternalURL | string)",
339
+ value: elem
340
+ }, _errorFactory)) && (undefined !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
341
+ method: "createAssert",
342
+ path: _path + ".kycProviders[" + _index10 + "]",
343
+ expected: "(ExternalURL | string)",
344
+ value: elem
345
+ }, _errorFactory)) && ("string" === typeof elem || ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
346
+ method: "createAssert",
347
+ path: _path + ".kycProviders[" + _index10 + "]",
348
+ expected: "(ExternalURL | string)",
349
+ value: elem
350
+ }, _errorFactory)) && _ao0(elem, _path + ".kycProviders[" + _index10 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
351
+ method: "createAssert",
352
+ path: _path + ".kycProviders[" + _index10 + "]",
353
+ expected: "(ExternalURL | string)",
354
+ value: elem
355
+ }, _errorFactory))) || "object" === typeof input.kycProviders && null !== input.kycProviders && _ao0(input.kycProviders, _path + ".kycProviders", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
356
+ method: "createAssert",
357
+ path: _path + ".kycProviders",
358
+ expected: "(Array<string | ExternalURL> | ExternalURL | undefined)",
359
+ value: input.kycProviders
360
+ }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
361
+ method: "createAssert",
362
+ path: _path + ".kycProviders",
363
+ expected: "(Array<string | ExternalURL> | ExternalURL | undefined)",
364
+ value: input.kycProviders
365
+ }, _errorFactory))); const _ao5 = (input, _path, _exceptionable = true) => (null !== input.createAccount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
366
+ method: "createAssert",
367
+ path: _path + ".createAccount",
368
+ expected: "(ExternalURL | string | undefined)",
369
+ value: input.createAccount
370
+ }, _errorFactory)) && (undefined === input.createAccount || "string" === typeof input.createAccount || ("object" === typeof input.createAccount && null !== input.createAccount || __typia_transform__assertGuard._assertGuard(_exceptionable, {
371
+ method: "createAssert",
372
+ path: _path + ".createAccount",
373
+ expected: "(ExternalURL | string | undefined)",
374
+ value: input.createAccount
375
+ }, _errorFactory)) && _ao0(input.createAccount, _path + ".createAccount", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
376
+ method: "createAssert",
377
+ path: _path + ".createAccount",
378
+ expected: "(ExternalURL | string | undefined)",
379
+ value: input.createAccount
380
+ }, _errorFactory)); const _ao6 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every(key => {
381
+ const value = input[key];
382
+ if (undefined === value)
383
+ return true;
384
+ return ("object" === typeof value && null !== value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
385
+ method: "createAssert",
386
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
387
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o5)",
388
+ value: value
389
+ }, _errorFactory)) && _au10(value, _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key), true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
390
+ method: "createAssert",
391
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
392
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o5)",
393
+ value: value
394
+ }, _errorFactory);
395
+ }); const _ao7 = (input, _path, _exceptionable = true) => (("object" === typeof input.operations && null !== input.operations && false === Array.isArray(input.operations) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
396
+ method: "createAssert",
397
+ path: _path + ".operations",
398
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o6)",
399
+ value: input.operations
400
+ }, _errorFactory)) && _au11(input.operations, _path + ".operations", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
401
+ method: "createAssert",
402
+ path: _path + ".operations",
403
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o6)",
404
+ value: input.operations
405
+ }, _errorFactory)) && ((null !== input.countryCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
406
+ method: "createAssert",
407
+ path: _path + ".countryCodes",
408
+ expected: "(Array<string | ExternalURL> | ExternalURL | undefined)",
409
+ value: input.countryCodes
410
+ }, _errorFactory)) && (undefined === input.countryCodes || (Array.isArray(input.countryCodes) && input.countryCodes.every((elem, _index11) => (null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
411
+ method: "createAssert",
412
+ path: _path + ".countryCodes[" + _index11 + "]",
413
+ expected: "(ExternalURL | string)",
414
+ value: elem
415
+ }, _errorFactory)) && (undefined !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
416
+ method: "createAssert",
417
+ path: _path + ".countryCodes[" + _index11 + "]",
418
+ expected: "(ExternalURL | string)",
419
+ value: elem
420
+ }, _errorFactory)) && ("string" === typeof elem || ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
421
+ method: "createAssert",
422
+ path: _path + ".countryCodes[" + _index11 + "]",
423
+ expected: "(ExternalURL | string)",
424
+ value: elem
425
+ }, _errorFactory)) && _ao0(elem, _path + ".countryCodes[" + _index11 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
426
+ method: "createAssert",
427
+ path: _path + ".countryCodes[" + _index11 + "]",
428
+ expected: "(ExternalURL | string)",
429
+ value: elem
430
+ }, _errorFactory))) || "object" === typeof input.countryCodes && null !== input.countryCodes && _ao0(input.countryCodes, _path + ".countryCodes", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
431
+ method: "createAssert",
432
+ path: _path + ".countryCodes",
433
+ expected: "(Array<string | ExternalURL> | ExternalURL | undefined)",
434
+ value: input.countryCodes
435
+ }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
436
+ method: "createAssert",
437
+ path: _path + ".countryCodes",
438
+ expected: "(Array<string | ExternalURL> | ExternalURL | undefined)",
439
+ value: input.countryCodes
440
+ }, _errorFactory))) && ((null !== input.ca || __typia_transform__assertGuard._assertGuard(_exceptionable, {
441
+ method: "createAssert",
442
+ path: _path + ".ca",
443
+ expected: "(ExternalURL | string)",
444
+ value: input.ca
445
+ }, _errorFactory)) && (undefined !== input.ca || __typia_transform__assertGuard._assertGuard(_exceptionable, {
446
+ method: "createAssert",
447
+ path: _path + ".ca",
448
+ expected: "(ExternalURL | string)",
449
+ value: input.ca
450
+ }, _errorFactory)) && ("string" === typeof input.ca || ("object" === typeof input.ca && null !== input.ca || __typia_transform__assertGuard._assertGuard(_exceptionable, {
451
+ method: "createAssert",
452
+ path: _path + ".ca",
453
+ expected: "(ExternalURL | string)",
454
+ value: input.ca
455
+ }, _errorFactory)) && _ao0(input.ca, _path + ".ca", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
456
+ method: "createAssert",
457
+ path: _path + ".ca",
458
+ expected: "(ExternalURL | string)",
459
+ value: input.ca
460
+ }, _errorFactory))); const _ao8 = (input, _path, _exceptionable = true) => (null !== input.checkLocality || __typia_transform__assertGuard._assertGuard(_exceptionable, {
461
+ method: "createAssert",
462
+ path: _path + ".checkLocality",
463
+ expected: "(ExternalURL | string | undefined)",
464
+ value: input.checkLocality
465
+ }, _errorFactory)) && (undefined === input.checkLocality || "string" === typeof input.checkLocality || ("object" === typeof input.checkLocality && null !== input.checkLocality || __typia_transform__assertGuard._assertGuard(_exceptionable, {
466
+ method: "createAssert",
467
+ path: _path + ".checkLocality",
468
+ expected: "(ExternalURL | string | undefined)",
469
+ value: input.checkLocality
470
+ }, _errorFactory)) && _ao0(input.checkLocality, _path + ".checkLocality", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
471
+ method: "createAssert",
472
+ path: _path + ".checkLocality",
473
+ expected: "(ExternalURL | string | undefined)",
474
+ value: input.checkLocality
475
+ }, _errorFactory)) && ((null !== input.getEstimate || __typia_transform__assertGuard._assertGuard(_exceptionable, {
476
+ method: "createAssert",
477
+ path: _path + ".getEstimate",
478
+ expected: "(ExternalURL | string | undefined)",
479
+ value: input.getEstimate
480
+ }, _errorFactory)) && (undefined === input.getEstimate || "string" === typeof input.getEstimate || ("object" === typeof input.getEstimate && null !== input.getEstimate || __typia_transform__assertGuard._assertGuard(_exceptionable, {
481
+ method: "createAssert",
482
+ path: _path + ".getEstimate",
483
+ expected: "(ExternalURL | string | undefined)",
484
+ value: input.getEstimate
485
+ }, _errorFactory)) && _ao0(input.getEstimate, _path + ".getEstimate", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
486
+ method: "createAssert",
487
+ path: _path + ".getEstimate",
488
+ expected: "(ExternalURL | string | undefined)",
489
+ value: input.getEstimate
490
+ }, _errorFactory))) && ((null !== input.createVerification || __typia_transform__assertGuard._assertGuard(_exceptionable, {
491
+ method: "createAssert",
492
+ path: _path + ".createVerification",
493
+ expected: "(ExternalURL | string | undefined)",
494
+ value: input.createVerification
495
+ }, _errorFactory)) && (undefined === input.createVerification || "string" === typeof input.createVerification || ("object" === typeof input.createVerification && null !== input.createVerification || __typia_transform__assertGuard._assertGuard(_exceptionable, {
496
+ method: "createAssert",
497
+ path: _path + ".createVerification",
498
+ expected: "(ExternalURL | string | undefined)",
499
+ value: input.createVerification
500
+ }, _errorFactory)) && _ao0(input.createVerification, _path + ".createVerification", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
501
+ method: "createAssert",
502
+ path: _path + ".createVerification",
503
+ expected: "(ExternalURL | string | undefined)",
504
+ value: input.createVerification
505
+ }, _errorFactory))) && ((null !== input.getCertificates || __typia_transform__assertGuard._assertGuard(_exceptionable, {
506
+ method: "createAssert",
507
+ path: _path + ".getCertificates",
508
+ expected: "(ExternalURL | string | undefined)",
509
+ value: input.getCertificates
510
+ }, _errorFactory)) && (undefined === input.getCertificates || "string" === typeof input.getCertificates || ("object" === typeof input.getCertificates && null !== input.getCertificates || __typia_transform__assertGuard._assertGuard(_exceptionable, {
511
+ method: "createAssert",
512
+ path: _path + ".getCertificates",
513
+ expected: "(ExternalURL | string | undefined)",
514
+ value: input.getCertificates
515
+ }, _errorFactory)) && _ao0(input.getCertificates, _path + ".getCertificates", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
516
+ method: "createAssert",
517
+ path: _path + ".getCertificates",
518
+ expected: "(ExternalURL | string | undefined)",
519
+ value: input.getCertificates
520
+ }, _errorFactory))); const _ao9 = (input, _path, _exceptionable = true) => (null !== input.inputCurrencyCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
521
+ method: "createAssert",
522
+ path: _path + ".inputCurrencyCodes",
523
+ expected: "(Array<ExternalURL | ToJSONValuizableObject<{ outputCurrencyCodes: string[]; kycProviders: string[]; }>> | ExternalURL)",
524
+ value: input.inputCurrencyCodes
525
+ }, _errorFactory)) && (undefined !== input.inputCurrencyCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
526
+ method: "createAssert",
527
+ path: _path + ".inputCurrencyCodes",
528
+ expected: "(Array<ExternalURL | ToJSONValuizableObject<{ outputCurrencyCodes: string[]; kycProviders: string[]; }>> | ExternalURL)",
529
+ value: input.inputCurrencyCodes
530
+ }, _errorFactory)) && (Array.isArray(input.inputCurrencyCodes) && input.inputCurrencyCodes.every((elem, _index12) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
531
+ method: "createAssert",
532
+ path: _path + ".inputCurrencyCodes[" + _index12 + "]",
533
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o8)",
534
+ value: elem
535
+ }, _errorFactory)) && _au0(elem, _path + ".inputCurrencyCodes[" + _index12 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
536
+ method: "createAssert",
537
+ path: _path + ".inputCurrencyCodes[" + _index12 + "]",
538
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o8)",
539
+ value: elem
540
+ }, _errorFactory)) || "object" === typeof input.inputCurrencyCodes && null !== input.inputCurrencyCodes && _ao0(input.inputCurrencyCodes, _path + ".inputCurrencyCodes", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
541
+ method: "createAssert",
542
+ path: _path + ".inputCurrencyCodes",
543
+ expected: "(Array<ExternalURL | ToJSONValuizableObject<{ outputCurrencyCodes: string[]; kycProviders: string[]; }>> | ExternalURL)",
544
+ value: input.inputCurrencyCodes
545
+ }, _errorFactory) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
546
+ method: "createAssert",
547
+ path: _path + ".inputCurrencyCodes",
548
+ expected: "(Array<ExternalURL | ToJSONValuizableObject<{ outputCurrencyCodes: string[]; kycProviders: string[]; }>> | ExternalURL)",
549
+ value: input.inputCurrencyCodes
550
+ }, _errorFactory)); const _ao10 = (input, _path, _exceptionable = true) => (null !== input.outputCurrencyCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
551
+ method: "createAssert",
552
+ path: _path + ".outputCurrencyCodes",
553
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
554
+ value: input.outputCurrencyCodes
555
+ }, _errorFactory)) && (undefined !== input.outputCurrencyCodes || __typia_transform__assertGuard._assertGuard(_exceptionable, {
556
+ method: "createAssert",
557
+ path: _path + ".outputCurrencyCodes",
558
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
559
+ value: input.outputCurrencyCodes
560
+ }, _errorFactory)) && (Array.isArray(input.outputCurrencyCodes) && input.outputCurrencyCodes.every((elem, _index13) => (null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
561
+ method: "createAssert",
562
+ path: _path + ".outputCurrencyCodes[" + _index13 + "]",
563
+ expected: "(ExternalURL | string)",
564
+ value: elem
565
+ }, _errorFactory)) && (undefined !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
566
+ method: "createAssert",
567
+ path: _path + ".outputCurrencyCodes[" + _index13 + "]",
568
+ expected: "(ExternalURL | string)",
569
+ value: elem
570
+ }, _errorFactory)) && ("string" === typeof elem || ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
571
+ method: "createAssert",
572
+ path: _path + ".outputCurrencyCodes[" + _index13 + "]",
573
+ expected: "(ExternalURL | string)",
574
+ value: elem
575
+ }, _errorFactory)) && _ao0(elem, _path + ".outputCurrencyCodes[" + _index13 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
576
+ method: "createAssert",
577
+ path: _path + ".outputCurrencyCodes[" + _index13 + "]",
578
+ expected: "(ExternalURL | string)",
579
+ value: elem
580
+ }, _errorFactory))) || "object" === typeof input.outputCurrencyCodes && null !== input.outputCurrencyCodes && _ao0(input.outputCurrencyCodes, _path + ".outputCurrencyCodes", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
581
+ method: "createAssert",
582
+ path: _path + ".outputCurrencyCodes",
583
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
584
+ value: input.outputCurrencyCodes
585
+ }, _errorFactory) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
586
+ method: "createAssert",
587
+ path: _path + ".outputCurrencyCodes",
588
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
589
+ value: input.outputCurrencyCodes
590
+ }, _errorFactory)) && ((null !== input.kycProviders || __typia_transform__assertGuard._assertGuard(_exceptionable, {
591
+ method: "createAssert",
592
+ path: _path + ".kycProviders",
593
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
594
+ value: input.kycProviders
595
+ }, _errorFactory)) && (undefined !== input.kycProviders || __typia_transform__assertGuard._assertGuard(_exceptionable, {
596
+ method: "createAssert",
597
+ path: _path + ".kycProviders",
598
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
599
+ value: input.kycProviders
600
+ }, _errorFactory)) && (Array.isArray(input.kycProviders) && input.kycProviders.every((elem, _index14) => (null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
601
+ method: "createAssert",
602
+ path: _path + ".kycProviders[" + _index14 + "]",
603
+ expected: "(ExternalURL | string)",
604
+ value: elem
605
+ }, _errorFactory)) && (undefined !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
606
+ method: "createAssert",
607
+ path: _path + ".kycProviders[" + _index14 + "]",
608
+ expected: "(ExternalURL | string)",
609
+ value: elem
610
+ }, _errorFactory)) && ("string" === typeof elem || ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
611
+ method: "createAssert",
612
+ path: _path + ".kycProviders[" + _index14 + "]",
613
+ expected: "(ExternalURL | string)",
614
+ value: elem
615
+ }, _errorFactory)) && _ao0(elem, _path + ".kycProviders[" + _index14 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
616
+ method: "createAssert",
617
+ path: _path + ".kycProviders[" + _index14 + "]",
618
+ expected: "(ExternalURL | string)",
619
+ value: elem
620
+ }, _errorFactory))) || "object" === typeof input.kycProviders && null !== input.kycProviders && _ao0(input.kycProviders, _path + ".kycProviders", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
621
+ method: "createAssert",
622
+ path: _path + ".kycProviders",
623
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
624
+ value: input.kycProviders
625
+ }, _errorFactory) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
626
+ method: "createAssert",
627
+ path: _path + ".kycProviders",
628
+ expected: "(Array<string | ExternalURL> | ExternalURL)",
629
+ value: input.kycProviders
630
+ }, _errorFactory))); const _ao11 = (input, _path, _exceptionable = true) => (null !== input.workInProgress || __typia_transform__assertGuard._assertGuard(_exceptionable, {
631
+ method: "createAssert",
632
+ path: _path + ".workInProgress",
633
+ expected: "(ExternalURL | true | undefined)",
634
+ value: input.workInProgress
635
+ }, _errorFactory)) && (undefined === input.workInProgress || true === input.workInProgress || ("object" === typeof input.workInProgress && null !== input.workInProgress || __typia_transform__assertGuard._assertGuard(_exceptionable, {
636
+ method: "createAssert",
637
+ path: _path + ".workInProgress",
638
+ expected: "(ExternalURL | true | undefined)",
639
+ value: input.workInProgress
640
+ }, _errorFactory)) && _ao0(input.workInProgress, _path + ".workInProgress", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
641
+ method: "createAssert",
642
+ path: _path + ".workInProgress",
643
+ expected: "(ExternalURL | true | undefined)",
644
+ value: input.workInProgress
645
+ }, _errorFactory)); const _ao12 = (input, _path, _exceptionable = true) => (null !== input.workInProgress || __typia_transform__assertGuard._assertGuard(_exceptionable, {
646
+ method: "createAssert",
647
+ path: _path + ".workInProgress",
648
+ expected: "(ExternalURL | true | undefined)",
649
+ value: input.workInProgress
650
+ }, _errorFactory)) && (undefined === input.workInProgress || true === input.workInProgress || ("object" === typeof input.workInProgress && null !== input.workInProgress || __typia_transform__assertGuard._assertGuard(_exceptionable, {
651
+ method: "createAssert",
652
+ path: _path + ".workInProgress",
653
+ expected: "(ExternalURL | true | undefined)",
654
+ value: input.workInProgress
655
+ }, _errorFactory)) && _ao0(input.workInProgress, _path + ".workInProgress", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
656
+ method: "createAssert",
657
+ path: _path + ".workInProgress",
658
+ expected: "(ExternalURL | true | undefined)",
659
+ value: input.workInProgress
660
+ }, _errorFactory)); const _ao13 = (input, _path, _exceptionable = true) => (null !== input.workInProgress || __typia_transform__assertGuard._assertGuard(_exceptionable, {
661
+ method: "createAssert",
662
+ path: _path + ".workInProgress",
663
+ expected: "(ExternalURL | true | undefined)",
664
+ value: input.workInProgress
665
+ }, _errorFactory)) && (undefined === input.workInProgress || true === input.workInProgress || ("object" === typeof input.workInProgress && null !== input.workInProgress || __typia_transform__assertGuard._assertGuard(_exceptionable, {
666
+ method: "createAssert",
667
+ path: _path + ".workInProgress",
668
+ expected: "(ExternalURL | true | undefined)",
669
+ value: input.workInProgress
670
+ }, _errorFactory)) && _ao0(input.workInProgress, _path + ".workInProgress", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
671
+ method: "createAssert",
672
+ path: _path + ".workInProgress",
673
+ expected: "(ExternalURL | true | undefined)",
674
+ value: input.workInProgress
675
+ }, _errorFactory)); const _au0 = (input, _path, _exceptionable = true) => (() => {
676
+ if (undefined !== input.external)
677
+ return _ao0(input, _path, true && _exceptionable);
678
+ else if (undefined !== input.outputCurrencyCodes)
679
+ return _ao10(input, _path, true && _exceptionable);
680
+ else
681
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
682
+ method: "createAssert",
683
+ path: _path,
684
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o8)",
685
+ value: input
686
+ }, _errorFactory);
687
+ })(); const _au1 = (input, _path, _exceptionable = true) => (() => {
688
+ if (undefined !== input.external)
689
+ return _ao0(input, _path, true && _exceptionable);
690
+ else
691
+ return _ao2(input, _path, true && _exceptionable);
692
+ })(); const _au2 = (input, _path, _exceptionable = true) => (() => {
693
+ if (undefined !== input.external)
694
+ return _ao0(input, _path, true && _exceptionable);
695
+ else
696
+ return _ao3(input, _path, true && _exceptionable);
697
+ })(); const _au3 = (input, _path, _exceptionable = true) => (() => {
698
+ if (undefined !== input.external)
699
+ return _ao0(input, _path, true && _exceptionable);
700
+ else
701
+ return _ao6(input, _path, true && _exceptionable);
702
+ })(); const _au4 = (input, _path, _exceptionable = true) => (() => {
703
+ if (undefined !== input.external)
704
+ return _ao0(input, _path, true && _exceptionable);
705
+ else if (undefined !== input.inputCurrencyCodes)
706
+ return _ao9(input, _path, true && _exceptionable);
707
+ else
708
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
709
+ method: "createAssert",
710
+ path: _path,
711
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o7)",
712
+ value: input
713
+ }, _errorFactory);
714
+ })(); const _au5 = (input, _path, _exceptionable = true) => (() => {
715
+ if (undefined !== input.external)
716
+ return _ao0(input, _path, true && _exceptionable);
717
+ else
718
+ return _ao11(input, _path, true && _exceptionable);
719
+ })(); const _au6 = (input, _path, _exceptionable = true) => (() => {
720
+ if (undefined !== input.external)
721
+ return _ao0(input, _path, true && _exceptionable);
722
+ else
723
+ return _ao12(input, _path, true && _exceptionable);
724
+ })(); const _au7 = (input, _path, _exceptionable = true) => (() => {
725
+ if (undefined !== input.external)
726
+ return _ao0(input, _path, true && _exceptionable);
727
+ else
728
+ return _ao13(input, _path, true && _exceptionable);
729
+ })(); const _au8 = (input, _path, _exceptionable = true) => (() => {
730
+ if (undefined !== input.external)
731
+ return _ao0(input, _path, true && _exceptionable);
732
+ else if (undefined !== input.operations)
733
+ return _ao4(input, _path, true && _exceptionable);
734
+ else
735
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
736
+ method: "createAssert",
737
+ path: _path,
738
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o2)",
739
+ value: input
740
+ }, _errorFactory);
741
+ })(); const _au9 = (input, _path, _exceptionable = true) => (() => {
742
+ if (undefined !== input.external)
743
+ return _ao0(input, _path, true && _exceptionable);
744
+ else
745
+ return _ao5(input, _path, true && _exceptionable);
746
+ })(); const _au10 = (input, _path, _exceptionable = true) => (() => {
747
+ if (undefined !== input.external)
748
+ return _ao0(input, _path, true && _exceptionable);
749
+ else if (undefined !== input.operations)
750
+ return _ao7(input, _path, true && _exceptionable);
751
+ else
752
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
753
+ method: "createAssert",
754
+ path: _path,
755
+ expected: "(ExternalURL | ToJSONValuizableObject<__type>.o5)",
756
+ value: input
757
+ }, _errorFactory);
758
+ })(); const _au11 = (input, _path, _exceptionable = true) => (() => {
759
+ if (undefined !== input.external)
760
+ return _ao0(input, _path, true && _exceptionable);
761
+ else
762
+ return _ao8(input, _path, true && _exceptionable);
763
+ })(); const _au12 = (input, _path, _exceptionable = true) => (() => {
764
+ if (undefined !== input.external)
765
+ return _ao0(input, _path, true && _exceptionable);
766
+ else if (undefined !== input.version)
767
+ return _ao1(input, _path, true && _exceptionable);
768
+ else
769
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
770
+ method: "createAssert",
771
+ path: _path,
772
+ expected: "(ExternalURL | ToJSONValuizableObject<ServiceMetadata>)",
773
+ value: input
774
+ }, _errorFactory);
775
+ })(); const __is = input => "object" === typeof input && null !== input && _iu12(input); let _errorFactory; return (input, errorFactory) => {
776
+ if (false === __is(input)) {
777
+ _errorFactory = errorFactory;
778
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
779
+ method: "createAssert",
780
+ path: _path + "",
781
+ expected: "(ExternalURL | ToJSONValuizableObject<ServiceMetadata>)",
782
+ value: input
783
+ }, _errorFactory)) && _au12(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
784
+ method: "createAssert",
785
+ path: _path + "",
786
+ expected: "(ExternalURL | ToJSONValuizableObject<ServiceMetadata>)",
787
+ value: input
788
+ }, _errorFactory))(input, "$input", true);
789
+ }
790
+ return input;
791
+ }; })();
792
+ class Metadata {
793
+ #cache;
794
+ #trustedCAs;
795
+ #client;
796
+ #logger;
797
+ #url;
798
+ #resolver;
799
+ #stats;
800
+ seenURLs;
801
+ static instanceTypeID = 'Metadata:c85b3d67-9548-4042-9862-f6e6677690ac';
802
+ static isInstance(value) {
803
+ if (typeof value !== 'object' || value === null) {
804
+ return (false);
805
+ }
806
+ if (!('instanceID' in value)) {
807
+ return (false);
808
+ }
809
+ return (value.instanceID === Metadata.instanceTypeID);
810
+ }
811
+ static formatMetadata(metadata) {
812
+ return (Buffer.from(JSON.stringify(metadata)).toString('base64'));
813
+ }
814
+ /**
815
+ * Assert that the supplied value is a valid Metadata Root Object
816
+ */
817
+ static assertMetadata(value) {
818
+ assertServiceMetadata(value);
819
+ }
820
+ constructor(url, config) {
821
+ /*
822
+ * Define an "instanceTypeID" as an unenumerable property to
823
+ * ensure that we can identify this object as an instance of
824
+ * Metadata, but we do not need to serialize it.
825
+ */
826
+ Object.defineProperty(this, 'instanceTypeID', {
827
+ value: Metadata.instanceTypeID,
828
+ enumerable: false
829
+ });
830
+ this.#url = new URL(url);
831
+ this.#cache = {
832
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
833
+ instance: config.cache?.instance ?? new Map(),
834
+ positiveTTL: config.cache?.positiveTTL ?? 60 * 1000,
835
+ negativeTTL: config.cache?.negativeTTL ?? 5 * 1000
836
+ };
837
+ this.#trustedCAs = config.trustedCAs;
838
+ this.#client = config.client;
839
+ this.#logger = config.logger;
840
+ this.#resolver = config.resolver;
841
+ this.#stats = this.#resolver._mutableStats(statsAccessToken);
842
+ if (config.parent !== undefined) {
843
+ this.seenURLs = config.parent.seenURLs;
844
+ }
845
+ else {
846
+ this.seenURLs = new Set();
847
+ }
848
+ }
849
+ async parseMetadata(metadata) {
850
+ /*
851
+ * JSON.parse() will always return a JSONSerializable,
852
+ * and not `unknown`, so we can safely cast it.
853
+ */
854
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
855
+ const retval = await this.resolveValue(JSON.parse(metadata));
856
+ return (retval);
857
+ }
858
+ async readKeetaNetURL(url) {
859
+ const accountString = url.hostname;
860
+ const path = url.pathname;
861
+ this.#stats.keetanet.reads++;
862
+ if (path !== '/metadata') {
863
+ throw (new Error(`Unsupported path: ${path}`));
864
+ }
865
+ let account;
866
+ try {
867
+ account = KeetaNetClient.lib.Account.fromPublicKeyString(accountString);
868
+ }
869
+ catch {
870
+ return ('');
871
+ }
872
+ const accountInfo = await this.#client.getAccountInfo(account);
873
+ const metadata = Buffer.from(accountInfo.info.metadata, 'base64').toString('utf-8');
874
+ if (metadata === '') {
875
+ return ('');
876
+ }
877
+ this.#logger?.debug(`Resolver:${this.#resolver.id}`, 'Account info for', accountString, '=', accountInfo.info);
878
+ const retval = await this.parseMetadata(metadata);
879
+ return (retval);
880
+ }
881
+ async readHTTPSURL(url) {
882
+ this.#stats.https.reads++;
883
+ const results = await fetch(url.toString(), {
884
+ method: 'GET',
885
+ headers: {
886
+ 'Accept': 'application/json'
887
+ }
888
+ });
889
+ if (!results.ok) {
890
+ throw (new Error(`Error HTTP status ${results.status} ${results.statusText} for ${url.toString()}`));
891
+ }
892
+ if (results.status === 204) {
893
+ /*
894
+ * 204 No Content is a valid response, so we return an empty
895
+ * object.
896
+ */
897
+ return ({});
898
+ }
899
+ if (results.status !== 200) {
900
+ throw (new Error(`Unexpected HTTP status ${results.status} for ${url.toString()}`));
901
+ }
902
+ const metadata = JSON.stringify(await results.json());
903
+ this.#logger?.debug(`Resolver:${this.#resolver.id}`, 'Read URL', url.toString(), ':', metadata);
904
+ const retval = await this.parseMetadata(metadata);
905
+ return (retval);
906
+ }
907
+ async readURL(url) {
908
+ this.#stats.reads++;
909
+ const cacheKey = url.toString();
910
+ /*
911
+ * To ensure any circular references are handled correctly, we
912
+ * keep track of a chain of accessed URLs. If we see the same
913
+ * URL twice, then we have a circular reference.
914
+ */
915
+ if (this.seenURLs.has(cacheKey)) {
916
+ return ('');
917
+ }
918
+ this.seenURLs.add(cacheKey);
919
+ /*
920
+ * Verify that the cache entry is still valid. If it is not,
921
+ * then remove it from the cache.
922
+ */
923
+ let cacheVal = this.#cache.instance.get(cacheKey);
924
+ if (this.#cache.instance.has(cacheKey) && cacheVal !== undefined) {
925
+ if (cacheVal.expires < new Date()) {
926
+ this.#cache.instance.delete(cacheKey);
927
+ cacheVal = undefined;
928
+ }
929
+ }
930
+ if (cacheVal !== undefined) {
931
+ this.#stats.cache.hit++;
932
+ if (cacheVal.pass) {
933
+ return (cacheVal.value);
934
+ }
935
+ else {
936
+ throw (cacheVal.error);
937
+ }
938
+ }
939
+ this.#stats.cache.miss++;
940
+ let retval;
941
+ try {
942
+ const protocol = url.protocol;
943
+ if (protocol === 'keetanet:') {
944
+ retval = await this.readKeetaNetURL(url);
945
+ }
946
+ else if (protocol === 'https:') {
947
+ retval = await this.readHTTPSURL(url);
948
+ }
949
+ else {
950
+ this.#stats.unsupported.reads++;
951
+ throw (new Error(`Unsupported protocol: ${protocol}`));
952
+ }
953
+ }
954
+ catch (readError) {
955
+ this.#cache.instance.set(cacheKey, {
956
+ pass: false,
957
+ error: readError,
958
+ expires: new Date(Date.now() + this.#cache.negativeTTL)
959
+ });
960
+ this.#logger?.debug(`Resolver:${this.#resolver.id}`, 'Read URL', url.toString(), 'failed:', readError);
961
+ throw (readError);
962
+ }
963
+ this.#logger?.debug(`Resolver:${this.#resolver.id}`, 'Read URL', url.toString(), ':', retval);
964
+ this.#cache.instance.set(cacheKey, {
965
+ pass: true,
966
+ value: retval,
967
+ expires: new Date(Date.now() + this.#cache.positiveTTL)
968
+ });
969
+ return (retval);
970
+ }
971
+ async resolveValue(value) {
972
+ if (value === undefined) {
973
+ return (value);
974
+ }
975
+ /*
976
+ * If the value passed in is a reference to an external URL, then
977
+ * we need to read that URL (and continue to resolve it).
978
+ */
979
+ if (isExternalURL(value)) {
980
+ const url = new URL(value.url);
981
+ const retval = await this.readURL(url);
982
+ return (await this.resolveValue(retval));
983
+ }
984
+ return (value);
985
+ }
986
+ assertValuizableKind(input, expect) {
987
+ switch (expect) {
988
+ case 'any':
989
+ return (input);
990
+ case 'object':
991
+ if (typeof input !== 'object') {
992
+ throw (new Error(`expected an object, got ${typeof input}`));
993
+ }
994
+ if (input === null) {
995
+ throw (new Error('expected an object, got null'));
996
+ }
997
+ if (Array.isArray(input)) {
998
+ throw (new Error('expected an object, got an array'));
999
+ }
1000
+ return (input);
1001
+ case 'array':
1002
+ if (!Array.isArray(input)) {
1003
+ throw (new Error(`expected an array, got ${typeof input}`));
1004
+ }
1005
+ return (input);
1006
+ case 'primitive':
1007
+ if ((typeof input === 'object' && input !== null) || input === undefined) {
1008
+ throw (new Error(`expected a primitive, got ${typeof input}`));
1009
+ }
1010
+ return (input);
1011
+ case 'string':
1012
+ case 'number':
1013
+ case 'boolean':
1014
+ if (typeof input !== expect) {
1015
+ throw (new Error(`expected a ${expect}, got ${typeof input}`));
1016
+ }
1017
+ return (input);
1018
+ default:
1019
+ assertNever(expect);
1020
+ }
1021
+ }
1022
+ async valuize(value) {
1023
+ if (typeof value === 'object' && value !== null) {
1024
+ let newValue;
1025
+ if (Array.isArray(value)) {
1026
+ newValue = [];
1027
+ }
1028
+ else {
1029
+ newValue = {};
1030
+ }
1031
+ for (const key in value) {
1032
+ /*
1033
+ * Since `key` is the index of the array or
1034
+ * object, it is safe to use it to index
1035
+ * into the array or object.
1036
+ */
1037
+ // @ts-ignore
1038
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1039
+ const keyValue = value[key];
1040
+ if (isExternalURL(keyValue)) {
1041
+ const newMetadataObject = new Metadata(keyValue.url, {
1042
+ trustedCAs: this.#trustedCAs,
1043
+ client: this.#client,
1044
+ logger: this.#logger,
1045
+ resolver: this.#resolver,
1046
+ cache: this.#cache,
1047
+ parent: this
1048
+ });
1049
+ const newValuizableObject = newMetadataObject.value.bind(newMetadataObject);
1050
+ if (Array.isArray(newValue)) {
1051
+ throw (new Error('internal error: newValue is an array, but it should be an object since it is an external field, which can only be an object'));
1052
+ }
1053
+ newValue[key] = newValuizableObject;
1054
+ }
1055
+ else {
1056
+ /*
1057
+ * This is safe because `assertValuizableKind` will
1058
+ * ensure the correct output type
1059
+ */
1060
+ // @ts-ignore
1061
+ const newValueEntry = async (expect = 'any') => {
1062
+ const retval = this.assertValuizableKind(await this.valuize(keyValue), expect);
1063
+ return (retval);
1064
+ };
1065
+ /*
1066
+ * TypeScript doesn't track that `key`
1067
+ * is a valid index regardless of the
1068
+ * type of `newValue` is an array or an
1069
+ * object, so we need to use `@ts-ignore`
1070
+ */
1071
+ // @ts-ignore
1072
+ newValue[key] = newValueEntry;
1073
+ }
1074
+ }
1075
+ return (newValue);
1076
+ }
1077
+ else {
1078
+ return (value);
1079
+ }
1080
+ }
1081
+ async value(expect = 'any') {
1082
+ const value = await this.readURL(this.#url);
1083
+ const retval = this.assertValuizableKind(await this.valuize(value), expect);
1084
+ return (retval);
1085
+ }
1086
+ }
1087
+ function assertValidCountryCodes(input) {
1088
+ if (typeof input !== 'object' || input === null) {
1089
+ throw (new Error(`Expected an object, got ${typeof input}`));
1090
+ }
1091
+ if (!('countryCodes' in input)) {
1092
+ throw (new Error('Expected "countryCodes" to be present, but it was not found'));
1093
+ }
1094
+ if (typeof input.countryCodes !== 'function' && !Array.isArray(input.countryCodes)) {
1095
+ throw (new Error(`Expected "countryCodes" to be an array | function, got ${typeof input.countryCodes}`));
1096
+ }
1097
+ if (Array.isArray(input.countryCodes)) {
1098
+ for (const countryCode of input.countryCodes) {
1099
+ if (typeof countryCode !== 'string') {
1100
+ throw (new Error(`Expected "countryCodes" to be an array of strings, got ${typeof countryCode}`));
1101
+ }
1102
+ }
1103
+ }
1104
+ }
1105
+ function assertValidOptionalCountryCodes(input) {
1106
+ if (typeof input !== 'object' || input === null) {
1107
+ throw (new Error(`Expected an object, got ${typeof input}`));
1108
+ }
1109
+ if (!('countryCodes' in input)) {
1110
+ return;
1111
+ }
1112
+ assertValidCountryCodes(input);
1113
+ }
1114
+ function assertValidCurrencyCodes(input) {
1115
+ if (typeof input !== 'object' || input === null) {
1116
+ throw (new Error(`Expected an object, got ${typeof input}`));
1117
+ }
1118
+ if (!('currencyCodes' in input)) {
1119
+ throw (new Error('Expected "currencyCodes" to be present, but it was not found'));
1120
+ }
1121
+ if (typeof input.currencyCodes !== 'function' && !Array.isArray(input.currencyCodes)) {
1122
+ throw (new Error(`Expected "currencyCodes" to be an array | function, got ${typeof input.currencyCodes}`));
1123
+ }
1124
+ if (Array.isArray(input.currencyCodes)) {
1125
+ for (const currencyCode of input.currencyCodes) {
1126
+ if (typeof currencyCode !== 'string') {
1127
+ throw (new Error(`Expected "currencyCodes" to be an array of strings, got ${typeof currencyCode}`));
1128
+ }
1129
+ }
1130
+ }
1131
+ }
1132
+ function assertValidOperationsBanking(input) {
1133
+ if (typeof input !== 'object' || input === null) {
1134
+ throw (new Error(`Expected an object, got ${typeof input}`));
1135
+ }
1136
+ if (!('operations' in input)) {
1137
+ throw (new Error('Expected "operations" key in KYC service, but it was not found'));
1138
+ }
1139
+ if ((typeof input.operations !== 'object' || input.operations === null) && typeof input.operations !== 'function') {
1140
+ throw (new Error(`Expected "operations" to be an object | function, got ${typeof input.operations}`));
1141
+ }
1142
+ if (typeof input.operations !== 'function') {
1143
+ for (const [operation, operationValue] of Object.entries(input.operations)) {
1144
+ if (typeof operation !== 'string') {
1145
+ throw (new Error(`Expected "operations" to be an object with string keys, got ${typeof operation}`));
1146
+ }
1147
+ if (typeof operationValue !== 'string') {
1148
+ throw (new Error(`Expected "operations.${operation}" to be a string, got ${typeof operationValue}`));
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
+ function assertValidOperationsKYC(input) {
1154
+ assertValidOperationsBanking(input);
1155
+ }
1156
+ function assertValidOptionalKYCProviders(input) {
1157
+ if (typeof input !== 'object' || input === null) {
1158
+ throw (new Error(`Expected an object, got ${typeof input}`));
1159
+ }
1160
+ if ('kycProviders' in input) {
1161
+ if (typeof input.kycProviders !== 'function' && !Array.isArray(input.kycProviders)) {
1162
+ throw (new Error(`Expected "kycProviders" to be an array | function, got ${typeof input.kycProviders}`));
1163
+ }
1164
+ if (Array.isArray(input.kycProviders)) {
1165
+ for (const kycProvider of input.kycProviders) {
1166
+ if (typeof kycProvider !== 'string') {
1167
+ throw (new Error(`Expected "kycProviders" to be an array of strings, got ${typeof kycProvider}`));
1168
+ }
1169
+ }
1170
+ }
1171
+ }
1172
+ }
1173
+ function assertValidCA(input) {
1174
+ if (typeof input !== 'object' || input === null) {
1175
+ throw (new Error(`Expected an object, got ${typeof input}`));
1176
+ }
1177
+ if (!('ca' in input)) {
1178
+ throw (new Error('Expected "ca" key in KYC service, but it was not found'));
1179
+ }
1180
+ if (typeof input.ca !== 'string' && typeof input.ca !== 'function') {
1181
+ throw (new Error(`Expected "ca" to be a string | function, got ${typeof input.ca}`));
1182
+ }
1183
+ }
1184
+ const assertResolverLookupBankingResult = function (input) {
1185
+ assertValidOperationsBanking(input);
1186
+ assertValidCountryCodes(input);
1187
+ assertValidCurrencyCodes(input);
1188
+ assertValidOptionalKYCProviders(input);
1189
+ return (input);
1190
+ };
1191
+ const assertResolverLookupKYCResult = function (input) {
1192
+ assertValidOperationsKYC(input);
1193
+ assertValidOptionalCountryCodes(input);
1194
+ assertValidCA(input);
1195
+ return (input);
1196
+ };
1197
+ class Resolver {
1198
+ #root;
1199
+ #trustedCAs;
1200
+ #client;
1201
+ #logger;
1202
+ #stats;
1203
+ #metadataCache;
1204
+ id;
1205
+ static Metadata = Metadata;
1206
+ constructor(config) {
1207
+ this.#root = config.root;
1208
+ this.#trustedCAs = config.trustedCAs;
1209
+ this.#logger = config.logger;
1210
+ this.#metadataCache = {
1211
+ ...config.cache,
1212
+ instance: new Map()
1213
+ };
1214
+ this.id = config.id ?? crypto.randomUUID();
1215
+ this.#logger?.debug(`Resolver:${this.id}`, 'Creating resolver with root account', this.#root.publicKeyString.get());
1216
+ if (KeetaNetClient.Client.isInstance(config.client)) {
1217
+ this.#client = config.client;
1218
+ }
1219
+ else {
1220
+ this.#client = config.client.client;
1221
+ }
1222
+ this.#stats = {
1223
+ keetanet: {
1224
+ reads: 0
1225
+ },
1226
+ https: {
1227
+ reads: 0
1228
+ },
1229
+ unsupported: {
1230
+ reads: 0
1231
+ },
1232
+ reads: 0,
1233
+ cache: {
1234
+ hit: 0,
1235
+ miss: 0
1236
+ }
1237
+ };
1238
+ }
1239
+ /** @internal */
1240
+ _mutableStats(accessToken) {
1241
+ if (accessToken !== statsAccessToken) {
1242
+ throw (new Error('Invalid access token'));
1243
+ }
1244
+ return (this.#stats);
1245
+ }
1246
+ get stats() {
1247
+ return (structuredClone(this.#stats));
1248
+ }
1249
+ async lookupBankingServices(bankingServices, criteria) {
1250
+ if (bankingServices === undefined) {
1251
+ return (undefined);
1252
+ }
1253
+ const retval = {};
1254
+ for (const checkBankingServiceID in bankingServices) {
1255
+ try {
1256
+ const checkBankingService = await bankingServices[checkBankingServiceID]?.('object');
1257
+ if (checkBankingService === undefined) {
1258
+ continue;
1259
+ }
1260
+ if (!('operations' in checkBankingService)) {
1261
+ continue;
1262
+ }
1263
+ if (criteria.currencyCodes !== undefined) {
1264
+ const currencyCodes = await checkBankingService.currencyCodes?.('array') ?? [];
1265
+ const checkBankingServiceCurrencyCodes = await Promise.all(currencyCodes.map(async function (item) {
1266
+ return (await item?.('primitive'));
1267
+ }));
1268
+ let acceptable = true;
1269
+ for (const checkCurrencyCode of criteria.currencyCodes) {
1270
+ const checkCurrencyCodeCanonical = convertToCurrencySearchCanonical(checkCurrencyCode);
1271
+ if (!checkBankingServiceCurrencyCodes.includes(checkCurrencyCodeCanonical)) {
1272
+ acceptable = false;
1273
+ break;
1274
+ }
1275
+ }
1276
+ if (!acceptable) {
1277
+ continue;
1278
+ }
1279
+ }
1280
+ if (criteria.countryCodes !== undefined) {
1281
+ const countryCodes = await checkBankingService.countryCodes?.('array') ?? [];
1282
+ const checkBankingServiceCountryCodes = await Promise.all(countryCodes.map(async function (item) {
1283
+ return (await item?.('primitive'));
1284
+ }));
1285
+ this.#logger?.debug(`Resolver:${this.id}`, 'Checking country codes:', criteria.countryCodes, 'against', checkBankingServiceCountryCodes, 'for', checkBankingServiceID);
1286
+ let acceptable = true;
1287
+ for (const checkCountryCode of criteria.countryCodes) {
1288
+ const checkCountryCodeCanonical = convertToCountrySearchCanonical(checkCountryCode);
1289
+ if (!checkBankingServiceCountryCodes.includes(checkCountryCodeCanonical)) {
1290
+ acceptable = false;
1291
+ break;
1292
+ }
1293
+ }
1294
+ if (!acceptable) {
1295
+ continue;
1296
+ }
1297
+ }
1298
+ retval[checkBankingServiceID] = assertResolverLookupBankingResult(checkBankingService);
1299
+ }
1300
+ catch (checkBankingServiceError) {
1301
+ this.#logger?.debug(`Resolver:${this.id}`, 'Error checking banking service', checkBankingServiceID, ':', checkBankingServiceError, ' -- ignoring');
1302
+ }
1303
+ }
1304
+ if (Object.keys(retval).length === 0) {
1305
+ /*
1306
+ * If we didn't find any banking services, then we return
1307
+ * undefined to indicate that no services were found.
1308
+ */
1309
+ return (undefined);
1310
+ }
1311
+ return (retval);
1312
+ }
1313
+ async lookupKYCServices(kycServices, criteria) {
1314
+ if (kycServices === undefined) {
1315
+ return (undefined);
1316
+ }
1317
+ const retval = {};
1318
+ for (const checkKYCServiceID in kycServices) {
1319
+ try {
1320
+ const checkKYCService = await kycServices[checkKYCServiceID]?.('object');
1321
+ if (checkKYCService === undefined) {
1322
+ continue;
1323
+ }
1324
+ if (!('operations' in checkKYCService)) {
1325
+ continue;
1326
+ }
1327
+ if (criteria.countryCodes !== undefined) {
1328
+ let acceptable = true;
1329
+ /*
1330
+ * If the KYC service does not have a countryCodes
1331
+ * property, then it can validate accounts in any
1332
+ * country, so we skip this check.
1333
+ */
1334
+ if ('countryCodes' in checkKYCService) {
1335
+ const countryCodes = await checkKYCService.countryCodes?.('array') ?? [];
1336
+ const checkKYCServiceCountryCodes = await Promise.all(countryCodes.map(async function (item) {
1337
+ return (await item?.('string'));
1338
+ }));
1339
+ this.#logger?.debug(`Resolver:${this.id}`, 'Checking country codes:', criteria.countryCodes, 'against', checkKYCServiceCountryCodes, 'for', checkKYCServiceID);
1340
+ for (const checkCountryCode of criteria.countryCodes) {
1341
+ const checkCountryCodeCanonical = convertToCountrySearchCanonical(checkCountryCode);
1342
+ if (!checkKYCServiceCountryCodes.includes(checkCountryCodeCanonical)) {
1343
+ acceptable = false;
1344
+ break;
1345
+ }
1346
+ }
1347
+ }
1348
+ if (!acceptable) {
1349
+ continue;
1350
+ }
1351
+ }
1352
+ retval[checkKYCServiceID] = assertResolverLookupKYCResult(checkKYCService);
1353
+ }
1354
+ catch (checkKYCServiceError) {
1355
+ this.#logger?.debug(`Resolver:${this.id}`, 'Error checking KYC service', checkKYCServiceID, ':', checkKYCServiceError, ' -- ignoring');
1356
+ }
1357
+ }
1358
+ if (Object.keys(retval).length === 0) {
1359
+ /*
1360
+ * If we didn't find any banking services, then we return
1361
+ * undefined to indicate that no services were found.
1362
+ */
1363
+ return (undefined);
1364
+ }
1365
+ return (retval);
1366
+ }
1367
+ async lookup(service, criteria) {
1368
+ const rootURL = new URL(`keetanet://${this.#root.publicKeyString.get()}/metadata`);
1369
+ const metadata = new Metadata(rootURL, {
1370
+ trustedCAs: this.#trustedCAs,
1371
+ client: this.#client,
1372
+ logger: this.#logger,
1373
+ resolver: this,
1374
+ cache: this.#metadataCache
1375
+ });
1376
+ const rootMetadata = await metadata.value('object');
1377
+ this.#logger?.debug(`Resolver:${this.id}`, 'Root Metadata:', rootMetadata);
1378
+ if (!('version' in rootMetadata)) {
1379
+ throw (new Error('Root metadata is missing "version" property'));
1380
+ }
1381
+ const rootMetadataVersion = await rootMetadata.version?.('primitive');
1382
+ if (rootMetadataVersion !== 1) {
1383
+ throw (new Error(`Unsupported metadata version: ${rootMetadataVersion}`));
1384
+ }
1385
+ /*
1386
+ * Get the services object
1387
+ */
1388
+ const definedServicesProperty = rootMetadata.services;
1389
+ if (definedServicesProperty === undefined) {
1390
+ throw (new Error('Root metadata is missing "services" property'));
1391
+ }
1392
+ const definedServices = await definedServicesProperty('object');
1393
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1394
+ const args = { service, criteria };
1395
+ this.#logger?.debug(`Resolver:${this.id}`, 'Looking up', args.service, 'with criteria:', args.criteria, 'in', definedServices);
1396
+ switch (args.service) {
1397
+ case 'banking': {
1398
+ const currentCriteria = args.criteria;
1399
+ const bankingServices = await definedServices.banking?.('object');
1400
+ this.#logger?.debug(`Resolver:${this.id}`, 'Banking Services:', bankingServices);
1401
+ return (await this.lookupBankingServices(bankingServices, currentCriteria));
1402
+ }
1403
+ case 'kyc': {
1404
+ const currentCriteria = args.criteria;
1405
+ const kycServices = await definedServices.kyc?.('object');
1406
+ this.#logger?.debug(`Resolver:${this.id}`, 'KYC Services:', kycServices);
1407
+ return (await this.lookupKYCServices(kycServices, currentCriteria));
1408
+ }
1409
+ case 'fx':
1410
+ case 'inbound':
1411
+ case 'outbound':
1412
+ case 'cards':
1413
+ throw (new Error('not implemented'));
1414
+ default:
1415
+ assertNever(args);
1416
+ }
1417
+ }
1418
+ clearCache() {
1419
+ this.#metadataCache.instance.clear();
1420
+ this.#stats.cache.hit = 0;
1421
+ this.#stats.cache.miss = 0;
1422
+ this.#stats.https.reads = 0;
1423
+ this.#stats.keetanet.reads = 0;
1424
+ this.#stats.unsupported.reads = 0;
1425
+ this.#stats.reads = 0;
1426
+ }
1427
+ }
1428
+ export default Resolver;
1429
+ //# sourceMappingURL=resolver.js.map