@keetanetwork/anchor 0.0.14 → 0.0.16
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.map +1 -1
- package/lib/certificates.js +20 -100
- package/lib/certificates.js.map +1 -1
- package/lib/http-server.js +1 -1
- package/lib/http-server.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/log/index.d.ts +6 -57
- package/lib/log/index.d.ts.map +1 -1
- package/lib/log/index.js +5 -205
- package/lib/log/index.js.map +1 -1
- package/lib/log/target_console.d.ts +3 -11
- package/lib/log/target_console.d.ts.map +1 -1
- package/lib/log/target_console.js +3 -42
- package/lib/log/target_console.js.map +1 -1
- package/lib/resolver.js +22 -22
- package/lib/uri.d.ts +28 -0
- package/lib/uri.d.ts.map +1 -0
- package/lib/uri.js +100 -0
- package/lib/uri.js.map +1 -0
- package/lib/utils/asn1.d.ts +9 -1
- package/lib/utils/asn1.d.ts.map +1 -1
- package/lib/utils/asn1.js +1413 -0
- package/lib/utils/asn1.js.map +1 -1
- package/lib/utils/buffer.d.ts +1 -1
- package/lib/utils/buffer.d.ts.map +1 -1
- package/lib/utils/buffer.js +8 -2
- package/lib/utils/buffer.js.map +1 -1
- package/lib/utils/external.d.ts +43 -0
- package/lib/utils/external.d.ts.map +1 -0
- package/lib/utils/external.js +115 -0
- package/lib/utils/external.js.map +1 -0
- package/npm-shrinkwrap.json +9 -9
- package/package.json +2 -2
- package/services/asset-movement/common.js +7 -7
- package/services/kyc/iso20022.generated.d.ts +89 -28
- package/services/kyc/iso20022.generated.d.ts.map +1 -1
- package/services/kyc/iso20022.generated.js +191 -88
- package/services/kyc/iso20022.generated.js.map +1 -1
- package/services/kyc/oids.generated.d.ts +24 -9
- package/services/kyc/oids.generated.d.ts.map +1 -1
- package/services/kyc/oids.generated.js +38 -15
- package/services/kyc/oids.generated.js.map +1 -1
- package/services/kyc/utils/generate-kyc-schema.js +305 -75
- package/services/kyc/utils/generate-kyc-schema.js.map +1 -1
- package/lib/log/common.d.ts +0 -35
- package/lib/log/common.d.ts.map +0 -1
- package/lib/log/common.js +0 -19
- package/lib/log/common.js.map +0 -1
|
@@ -38,6 +38,10 @@ function resolveTypeReference(typeName) {
|
|
|
38
38
|
return ('Date');
|
|
39
39
|
case 'ENUMERATED':
|
|
40
40
|
return ('string');
|
|
41
|
+
case 'OBJECT IDENTIFIER':
|
|
42
|
+
return ('ASN1.ASN1OID');
|
|
43
|
+
case 'OCTET STRING':
|
|
44
|
+
return ('Buffer');
|
|
41
45
|
default:
|
|
42
46
|
return (toPascalCase(typeName));
|
|
43
47
|
}
|
|
@@ -66,6 +70,11 @@ function resolveToBaseType(typeName) {
|
|
|
66
70
|
// Otherwise return as-is
|
|
67
71
|
return (typeName);
|
|
68
72
|
}
|
|
73
|
+
function isEnumerationType(typeName) {
|
|
74
|
+
const normalized = toSnakeCase(typeName);
|
|
75
|
+
return (Boolean(oidSchema.iso20022_types.enumerations[typeName] ??
|
|
76
|
+
oidSchema.iso20022_types.enumerations[normalized]));
|
|
77
|
+
}
|
|
69
78
|
function isSequenceOfChoice(config) {
|
|
70
79
|
const hasFields = config.fields && Object.keys(config.fields).length > 0;
|
|
71
80
|
const allOptional = hasFields && Object.values(config.fields).every(function (field) {
|
|
@@ -108,7 +117,8 @@ function genInterface(name, fields, description, oid) {
|
|
|
108
117
|
});
|
|
109
118
|
return (`/** ${description} */\n/** OID: ${oid} */\nexport interface ${name} {\n${fieldLines.join('\n')}\n}\n`);
|
|
110
119
|
}
|
|
111
|
-
|
|
120
|
+
// Generate TypeScript **types** for sequence-of-choice
|
|
121
|
+
function genSequenceOfChoiceTypes(name, config) {
|
|
112
122
|
const typeName = toPascalCase(name);
|
|
113
123
|
const fieldOrder = config.field_order ?? Object.keys(config.fields);
|
|
114
124
|
const choiceEntries = fieldOrder.map(function (fieldName) {
|
|
@@ -139,12 +149,51 @@ function genSequenceOfChoice(name, config) {
|
|
|
139
149
|
}).join('\n\t| ')};\n\n`;
|
|
140
150
|
// Main type is array of choices
|
|
141
151
|
out += `export type ${typeName} = ${typeName}Choice[];\n\n`;
|
|
152
|
+
return (out);
|
|
153
|
+
}
|
|
154
|
+
// Generate ASN.1 **schema** for sequence-of-choice
|
|
155
|
+
function genSequenceOfChoiceSchema(name, config) {
|
|
156
|
+
const typeName = toPascalCase(name);
|
|
157
|
+
const fieldOrder = config.field_order ?? Object.keys(config.fields);
|
|
158
|
+
const choiceEntries = fieldOrder.map(function (fieldName) {
|
|
159
|
+
if (!(fieldName in config.fields) || config.fields[fieldName] === undefined) {
|
|
160
|
+
throw (new Error(`Field ${fieldName} not found in sequence of choice ${name}`));
|
|
161
|
+
}
|
|
162
|
+
return ([fieldName, config.fields[fieldName]]);
|
|
163
|
+
});
|
|
164
|
+
let out = '';
|
|
142
165
|
// ASN.1 schema
|
|
166
|
+
out += `/** ASN.1 schema for ${typeName} */\n`;
|
|
143
167
|
out += `export const ${typeName}Schema: ASN1.Schema = {\n\tsequenceOf: {\n\t\tchoice: [\n`;
|
|
144
|
-
out += choiceEntries.map(function ([
|
|
145
|
-
|
|
168
|
+
out += choiceEntries.map(function ([fieldName, fieldConfig], index) {
|
|
169
|
+
if (fieldConfig === undefined) {
|
|
170
|
+
throw (new Error(`Field ${fieldName} not found in sequence of choice ${name}`));
|
|
171
|
+
}
|
|
172
|
+
// Determine the type for this choice
|
|
173
|
+
let fieldType = fieldConfig.type.trim();
|
|
174
|
+
if (fieldType.startsWith('SEQUENCE OF ')) {
|
|
175
|
+
fieldType = fieldType.substring('SEQUENCE OF '.length).trim();
|
|
176
|
+
}
|
|
177
|
+
fieldType = fieldType.replace(/\[\]$/, '');
|
|
178
|
+
const fieldTypePascal = toPascalCase(fieldType);
|
|
179
|
+
const fieldTypeSnake = toSnakeCase(fieldType);
|
|
180
|
+
// Check if this is a complex type that has a schema
|
|
181
|
+
const isChoice = oidSchema.iso20022_types.choices[fieldTypeSnake] ?? oidSchema.iso20022_types.choices[fieldType];
|
|
182
|
+
const isSequence = oidSchema.iso20022_types.sequences[fieldTypeSnake] ?? oidSchema.iso20022_types.sequences[fieldType];
|
|
183
|
+
const isSensitiveSequence = oidSchema.sensitive_attributes[fieldTypeSnake]?.fields;
|
|
184
|
+
const isSensitiveChoice = oidSchema.sensitive_attributes[fieldTypeSnake]?.choices;
|
|
185
|
+
const hasSchema = isChoice ?? isSequence ?? isSensitiveSequence ?? isSensitiveChoice;
|
|
186
|
+
let contains;
|
|
187
|
+
if (hasSchema) {
|
|
188
|
+
contains = `${fieldTypePascal}Schema`;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// Primitive type
|
|
192
|
+
contains = `{ type: 'string', kind: 'utf8' }`;
|
|
193
|
+
}
|
|
194
|
+
return (`\t\t\t{ type: 'context', kind: 'explicit', value: ${index}, contains: ${contains} }`);
|
|
146
195
|
}).join(',\n');
|
|
147
|
-
out += `\n\t\t]\n\t}\n}
|
|
196
|
+
out += `\n\t\t]\n\t}\n};\n\n`;
|
|
148
197
|
// Field names array
|
|
149
198
|
out += `export const ${typeName}Fields = [\n${fieldOrder.map(function (fieldName) {
|
|
150
199
|
return (`\t'${fieldName}'`);
|
|
@@ -187,8 +236,12 @@ function generateOidConstants() {
|
|
|
187
236
|
lines.push('export namespace keeta {');
|
|
188
237
|
for (const [name, config] of Object.entries(oidSchema.extensions)) {
|
|
189
238
|
lines.push(`\t/** ${config.description} */`);
|
|
190
|
-
|
|
191
|
-
|
|
239
|
+
if (config.reference) {
|
|
240
|
+
lines.push(`\t/** @see ${config.reference} */`);
|
|
241
|
+
}
|
|
242
|
+
if (config.oid) {
|
|
243
|
+
lines.push(`\texport const ${toConstantCase(name)} = '${oidArrayToString(config.oid)}';`);
|
|
244
|
+
}
|
|
192
245
|
}
|
|
193
246
|
for (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {
|
|
194
247
|
lines.push(`\t/** ${config.description} */`);
|
|
@@ -223,52 +276,67 @@ function generateOidConstants() {
|
|
|
223
276
|
}
|
|
224
277
|
function genSequenceSchema(typeName, fields, config) {
|
|
225
278
|
const fieldOrder = config?.field_order ?? Object.keys(fields);
|
|
226
|
-
const
|
|
279
|
+
const structFields = {};
|
|
280
|
+
for (const fname of fieldOrder) {
|
|
227
281
|
const fcfg = fields[fname];
|
|
228
282
|
if (!fcfg) {
|
|
229
|
-
|
|
283
|
+
continue;
|
|
230
284
|
}
|
|
231
285
|
// Resolve to base type to handle aliases
|
|
232
286
|
const baseType = resolveToBaseType(fcfg.type);
|
|
287
|
+
let fieldSchema;
|
|
233
288
|
// Check if field type is GeneralizedTime (date)
|
|
234
289
|
if (baseType === 'GeneralizedTime') {
|
|
235
|
-
|
|
236
|
-
|
|
290
|
+
fieldSchema = 'ASN1.ValidateASN1.IsDate';
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
// Check if this is a SEQUENCE OF type directly or via type reference
|
|
294
|
+
let fieldType = baseType.trim();
|
|
295
|
+
const isSequenceOf = fieldType.startsWith('SEQUENCE OF ');
|
|
296
|
+
if (isSequenceOf) {
|
|
297
|
+
fieldType = fieldType.substring('SEQUENCE OF '.length).trim();
|
|
298
|
+
}
|
|
299
|
+
fieldType = fieldType.replace(/\[\]$/, '');
|
|
300
|
+
const fieldTypePascal = toPascalCase(fieldType);
|
|
301
|
+
const fieldTypeSnake = toSnakeCase(fieldType);
|
|
302
|
+
// Check if this is a COMPLEX type (not a primitive)
|
|
303
|
+
const isChoice = oidSchema.iso20022_types.choices[fieldTypeSnake] ?? oidSchema.iso20022_types.choices[fieldType];
|
|
304
|
+
const isSequence = oidSchema.iso20022_types.sequences[fieldTypeSnake] ?? oidSchema.iso20022_types.sequences[fieldType];
|
|
305
|
+
const isSensitiveSequence = oidSchema.sensitive_attributes[fieldTypeSnake]?.fields;
|
|
306
|
+
const isSensitiveChoice = oidSchema.sensitive_attributes[fieldTypeSnake]?.choices;
|
|
307
|
+
const isExtension = oidSchema.extensions[fieldTypeSnake]?.fields ?? oidSchema.extensions[fieldType]?.fields;
|
|
308
|
+
const hasSchema = isChoice ?? isSequence ?? isSensitiveSequence ?? isSensitiveChoice ?? isExtension;
|
|
309
|
+
if (hasSchema) {
|
|
310
|
+
fieldSchema = `${fieldTypePascal}Schema`;
|
|
237
311
|
}
|
|
238
312
|
else {
|
|
239
|
-
|
|
313
|
+
// Primitive type - use inline schema
|
|
314
|
+
if (fieldType === 'OBJECT IDENTIFIER') {
|
|
315
|
+
fieldSchema = `ASN1.ValidateASN1.IsOID`;
|
|
316
|
+
}
|
|
317
|
+
else if (fieldType === 'OCTET STRING') {
|
|
318
|
+
fieldSchema = `ASN1.ValidateASN1.IsOctetString`;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
fieldSchema = `{ type: 'string', kind: 'utf8' }`;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// Wrap in sequenceOf if this was a SEQUENCE OF type
|
|
325
|
+
if (isSequenceOf) {
|
|
326
|
+
fieldSchema = `{ sequenceOf: ${fieldSchema} }`;
|
|
240
327
|
}
|
|
241
|
-
}
|
|
242
|
-
// Strip SEQUENCE OF prefix and [] suffix to get the base type
|
|
243
|
-
let fieldType = fcfg.type.trim();
|
|
244
|
-
if (fieldType.startsWith('SEQUENCE OF ')) {
|
|
245
|
-
fieldType = fieldType.substring('SEQUENCE OF '.length).trim();
|
|
246
|
-
}
|
|
247
|
-
fieldType = fieldType.replace(/\[\]$/, '');
|
|
248
|
-
const fieldTypePascal = toPascalCase(fieldType);
|
|
249
|
-
const fieldTypeSnake = toSnakeCase(fieldType);
|
|
250
|
-
// Check if this is a COMPLEX type (not a primitive)
|
|
251
|
-
const isChoice = oidSchema.iso20022_types.choices[fieldTypeSnake] ?? oidSchema.iso20022_types.choices[fieldType];
|
|
252
|
-
const isSequence = oidSchema.iso20022_types.sequences[fieldTypeSnake] ?? oidSchema.iso20022_types.sequences[fieldType];
|
|
253
|
-
const isSensitiveSequence = oidSchema.sensitive_attributes[fieldTypeSnake]?.fields;
|
|
254
|
-
const isSensitiveChoice = oidSchema.sensitive_attributes[fieldTypeSnake]?.choices;
|
|
255
|
-
const hasSchema = isChoice ?? isSequence ?? isSensitiveSequence ?? isSensitiveChoice;
|
|
256
|
-
let contains;
|
|
257
|
-
if (hasSchema) {
|
|
258
|
-
contains = `${fieldTypePascal}Schema `;
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
// Primitive type - use inline string schema
|
|
262
|
-
contains = `{ type: 'string', kind: 'utf8' }`;
|
|
263
328
|
}
|
|
264
329
|
if (fcfg.optional) {
|
|
265
|
-
|
|
330
|
+
structFields[fname] = `{ optional: ${fieldSchema} }`;
|
|
266
331
|
}
|
|
267
332
|
else {
|
|
268
|
-
|
|
333
|
+
structFields[fname] = fieldSchema;
|
|
269
334
|
}
|
|
270
|
-
}
|
|
271
|
-
|
|
335
|
+
}
|
|
336
|
+
const containsObject = fieldOrder.map(function (fname) {
|
|
337
|
+
return (`\t\t${fname}: ${structFields[fname]}`);
|
|
338
|
+
}).join(',\n');
|
|
339
|
+
return (`export const ${typeName}Schema: ASN1.Schema = {\n\ttype: 'struct',\n\tfieldNames: [${fieldOrder.map(f => `'${f}'`).join(', ')}],\n\tcontains: {\n${containsObject}\n\t}\n};`);
|
|
272
340
|
}
|
|
273
341
|
function generateIso20022Types() {
|
|
274
342
|
const lines = [genHeader('Generated ISO20022 Type Definitions'), "import * as ASN1 from '../../lib/utils/asn1.js';", ''];
|
|
@@ -293,9 +361,9 @@ function generateIso20022Types() {
|
|
|
293
361
|
return (choiceType !== 'UTF8String' && choiceType !== 'string');
|
|
294
362
|
});
|
|
295
363
|
if (hasComplexTypes) {
|
|
296
|
-
const unionTypes = choices.map(function ([_ignore_choiceName, choiceConfig]) {
|
|
297
|
-
return (
|
|
298
|
-
});
|
|
364
|
+
const unionTypes = Array.from(new Set(choices.map(function ([_ignore_choiceName, choiceConfig]) {
|
|
365
|
+
return (resolveTypeReference(choiceConfig.type.trim()));
|
|
366
|
+
})));
|
|
299
367
|
lines.push(genTypeAlias(typeName, unionTypes.join(' | '), config.description, oidArrayToString(config.oid)));
|
|
300
368
|
}
|
|
301
369
|
else {
|
|
@@ -306,7 +374,7 @@ function generateIso20022Types() {
|
|
|
306
374
|
lines.push('// ISO20022 Sequence Types');
|
|
307
375
|
for (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {
|
|
308
376
|
if (isSequenceOfChoice(config)) {
|
|
309
|
-
lines.push(
|
|
377
|
+
lines.push(genSequenceOfChoiceTypes(name, config));
|
|
310
378
|
}
|
|
311
379
|
else {
|
|
312
380
|
lines.push(genInterface(toPascalCase(name), config.fields, config.description, oidArrayToString(config.oid)));
|
|
@@ -315,15 +383,41 @@ function generateIso20022Types() {
|
|
|
315
383
|
lines.push('');
|
|
316
384
|
// --- Choice Type Schemas ---
|
|
317
385
|
lines.push('// Generated ASN.1 schemas for ISO 20022 choice types');
|
|
318
|
-
|
|
319
|
-
for (const [name, _ignore_config] of Object.entries(oidSchema.iso20022_types.choices)) {
|
|
386
|
+
for (const [name, config] of Object.entries(oidSchema.iso20022_types.choices)) {
|
|
320
387
|
const typeName = toPascalCase(name);
|
|
388
|
+
const choices = Object.entries(config.choices ?? {});
|
|
321
389
|
lines.push(`/** ASN.1 schema for ${typeName} */`);
|
|
322
|
-
|
|
390
|
+
if (choices.length === 0) {
|
|
391
|
+
// No choices defined - simple string schema
|
|
392
|
+
lines.push(`export const ${typeName}Schema: ASN1.Schema = { type: 'string', kind: 'utf8' };`);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
// Generate choice schema with context tags to make them differentiable
|
|
396
|
+
const choiceSchemas = choices.map(function ([_ignore_choiceName, choiceConfig], index) {
|
|
397
|
+
const choiceType = choiceConfig.type.trim();
|
|
398
|
+
let containsSchema;
|
|
399
|
+
// Check if it is a primitive type
|
|
400
|
+
if (choiceType === 'UTF8String' || choiceType === 'Utf8String' || choiceType === 'string' || isEnumerationType(choiceType)) {
|
|
401
|
+
containsSchema = `{ type: 'string', kind: 'utf8' }`;
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
// Complex type - reference its schema
|
|
405
|
+
const choiceTypeName = toPascalCase(choiceType);
|
|
406
|
+
containsSchema = `${choiceTypeName}Schema`;
|
|
407
|
+
}
|
|
408
|
+
// Wrap in context tag to make it differentiable
|
|
409
|
+
return (`{ type: 'context', kind: 'explicit', value: ${index}, contains: ${containsSchema} }`);
|
|
410
|
+
});
|
|
411
|
+
lines.push(`export const ${typeName}Schema: ASN1.Schema = {`);
|
|
412
|
+
lines.push(`\tchoice: [`);
|
|
413
|
+
lines.push(`\t\t${choiceSchemas.join(',\n\t\t')}`);
|
|
414
|
+
lines.push(`\t]`);
|
|
415
|
+
lines.push(`};`);
|
|
416
|
+
}
|
|
323
417
|
lines.push('');
|
|
324
418
|
}
|
|
325
|
-
// --- Sequence Type Schemas ---
|
|
326
|
-
lines.push('// Generated ASN.1 schemas for ISO 20022 sequence types');
|
|
419
|
+
// --- Regular Sequence Type Schemas (SECOND - may depend on choice schemas) ---
|
|
420
|
+
lines.push('// Generated ASN.1 schemas for ISO 20022 regular sequence types');
|
|
327
421
|
for (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {
|
|
328
422
|
const typeName = toPascalCase(name);
|
|
329
423
|
if (config.fields && !isSequenceOfChoice(config)) {
|
|
@@ -332,6 +426,13 @@ function generateIso20022Types() {
|
|
|
332
426
|
lines.push('');
|
|
333
427
|
}
|
|
334
428
|
}
|
|
429
|
+
// --- Sequence-of-Choice Type Schemas (THIRD - depend on regular sequence schemas) ---
|
|
430
|
+
lines.push('// Generated ASN.1 schemas for ISO 20022 sequence-of-choice types');
|
|
431
|
+
for (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {
|
|
432
|
+
if (isSequenceOfChoice(config)) {
|
|
433
|
+
lines.push(genSequenceOfChoiceSchema(name, config));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
335
436
|
// --- Choice-Type Sensitive Attribute Schemas ---
|
|
336
437
|
lines.push('// Generated ASN.1 schemas for choice-type sensitive attributes');
|
|
337
438
|
for (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {
|
|
@@ -346,7 +447,7 @@ function generateIso20022Types() {
|
|
|
346
447
|
lines.push(`\tchoice: [`);
|
|
347
448
|
lines.push(`\t\t${choiceSchemas.join(',\n\t\t')}`);
|
|
348
449
|
lines.push(`\t]`);
|
|
349
|
-
lines.push(`}
|
|
450
|
+
lines.push(`};`);
|
|
350
451
|
lines.push('');
|
|
351
452
|
}
|
|
352
453
|
}
|
|
@@ -406,6 +507,27 @@ function generateIso20022Types() {
|
|
|
406
507
|
lines.push('');
|
|
407
508
|
}
|
|
408
509
|
}
|
|
510
|
+
// Extension Types with fields
|
|
511
|
+
for (const [name, config] of Object.entries(oidSchema.extensions)) {
|
|
512
|
+
if (config.fields) {
|
|
513
|
+
const typeName = toPascalCase(name);
|
|
514
|
+
lines.push(`/** ${config.description} */`);
|
|
515
|
+
if (config.oid) {
|
|
516
|
+
lines.push(`/** OID: ${oidArrayToString(config.oid)} */`);
|
|
517
|
+
}
|
|
518
|
+
lines.push(`export interface ${typeName} {`);
|
|
519
|
+
for (const [fieldName, fieldConfig] of Object.entries(config.fields)) {
|
|
520
|
+
const optional = fieldConfig.optional ? '?' : '';
|
|
521
|
+
const resolvedType = resolveTypeReference(fieldConfig.type);
|
|
522
|
+
lines.push(`\t${fieldName}${optional}: ${resolvedType};`);
|
|
523
|
+
}
|
|
524
|
+
lines.push('}');
|
|
525
|
+
lines.push('');
|
|
526
|
+
// Schema
|
|
527
|
+
lines.push(genSequenceSchema(typeName, config.fields, config));
|
|
528
|
+
lines.push('');
|
|
529
|
+
}
|
|
530
|
+
}
|
|
409
531
|
// Token aliases for sensitive attributes
|
|
410
532
|
lines.push('// Token aliases for sensitive attributes');
|
|
411
533
|
for (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {
|
|
@@ -435,7 +557,45 @@ function generateIso20022Types() {
|
|
|
435
557
|
lines.push('export type CertificateAttributeValue<Name extends keyof CertificateAttributeValueMap> = CertificateAttributeValueMap[Name];');
|
|
436
558
|
lines.push('');
|
|
437
559
|
// Field arrays and schemas for sequence types
|
|
438
|
-
|
|
560
|
+
// Sort to ensure dependencies are defined before they're used
|
|
561
|
+
const sensitiveAttrEntries = Object.entries(oidSchema.sensitive_attributes);
|
|
562
|
+
const sortedEntries = [];
|
|
563
|
+
const processed = new Set();
|
|
564
|
+
function hasDependency(config, depName) {
|
|
565
|
+
if (!config.fields) {
|
|
566
|
+
return (false);
|
|
567
|
+
}
|
|
568
|
+
return (Object.values(config.fields).some(field => {
|
|
569
|
+
const fieldType = field.type.trim();
|
|
570
|
+
return (fieldType === toPascalCase(depName) || fieldType === depName);
|
|
571
|
+
}));
|
|
572
|
+
}
|
|
573
|
+
// Process entries, dependencies first
|
|
574
|
+
while (sortedEntries.length < sensitiveAttrEntries.length) {
|
|
575
|
+
for (const [name, config] of sensitiveAttrEntries) {
|
|
576
|
+
if (processed.has(name)) {
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
// Check if all dependencies are processed
|
|
580
|
+
let allDepsProcessed = true;
|
|
581
|
+
if (config.fields) {
|
|
582
|
+
for (const [otherName] of sensitiveAttrEntries) {
|
|
583
|
+
if (otherName === name || processed.has(otherName)) {
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
if (hasDependency(config, otherName)) {
|
|
587
|
+
allDepsProcessed = false;
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (allDepsProcessed) {
|
|
593
|
+
sortedEntries.push([name, config]);
|
|
594
|
+
processed.add(name);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
for (const [name, config] of sortedEntries) {
|
|
439
599
|
const typeName = toPascalCase(name);
|
|
440
600
|
if (config.fields) {
|
|
441
601
|
const fieldOrder = config.field_order ?? Object.keys(config.fields);
|
|
@@ -498,9 +658,24 @@ function generateIso20022Types() {
|
|
|
498
658
|
throw (new Error(`Sensitive attribute ${name} has no defined type.`));
|
|
499
659
|
}
|
|
500
660
|
const baseType = resolveToBaseType(config.type);
|
|
501
|
-
|
|
661
|
+
const baseTypeSnake = toSnakeCase(baseType);
|
|
662
|
+
const isExtensionType = oidSchema.extensions[baseTypeSnake]?.fields ?? oidSchema.extensions[baseType]?.fields;
|
|
663
|
+
const isSensitiveType = oidSchema.sensitive_attributes[toSnakeCase(baseType)]?.fields ?? oidSchema.sensitive_attributes[baseType]?.fields;
|
|
664
|
+
if (isSensitiveType) {
|
|
665
|
+
schemaRef = `${baseType}Schema`;
|
|
666
|
+
}
|
|
667
|
+
else if (isExtensionType) {
|
|
668
|
+
schemaRef = `${baseType}Schema`;
|
|
669
|
+
}
|
|
670
|
+
else if (baseType === 'GeneralizedTime') {
|
|
502
671
|
schemaRef = 'ASN1.ValidateASN1.IsDate';
|
|
503
672
|
}
|
|
673
|
+
else if (baseType === 'OCTET STRING') {
|
|
674
|
+
schemaRef = 'ASN1.ValidateASN1.IsOctetString';
|
|
675
|
+
}
|
|
676
|
+
else if (baseType === 'OBJECT IDENTIFIER') {
|
|
677
|
+
schemaRef = 'ASN1.ValidateASN1.IsOID';
|
|
678
|
+
}
|
|
504
679
|
else {
|
|
505
680
|
schemaRef = `{ type: 'string', kind: 'utf8' }`;
|
|
506
681
|
}
|
|
@@ -605,7 +780,12 @@ function main(argv) {
|
|
|
605
780
|
if (undefined === value)
|
|
606
781
|
return true;
|
|
607
782
|
return "object" === typeof value && null !== value && _io22(value);
|
|
608
|
-
}); const _io22 = input => Array.isArray(input.oid) && input.oid.every(elem => "number" === typeof elem) && (undefined === input.type || "string" === typeof input.type) && "string" === typeof input.description && "string" === typeof input.reference
|
|
783
|
+
}); const _io22 = input => (undefined === input.oid || Array.isArray(input.oid) && input.oid.every(elem => "number" === typeof elem)) && (undefined === input.type || "string" === typeof input.type) && "string" === typeof input.description && (undefined === input.reference || "string" === typeof input.reference) && (undefined === input.fields || "object" === typeof input.fields && null !== input.fields && false === Array.isArray(input.fields) && _io23(input.fields)) && (undefined === input.field_order || Array.isArray(input.field_order) && input.field_order.every(elem => "string" === typeof elem)); const _io23 = input => Object.keys(input).every(key => {
|
|
784
|
+
const value = input[key];
|
|
785
|
+
if (undefined === value)
|
|
786
|
+
return true;
|
|
787
|
+
return "object" === typeof value && null !== value && _io24(value);
|
|
788
|
+
}); const _io24 = input => "string" === typeof input.type && (undefined === input.optional || "boolean" === typeof input.optional); const _ao0 = (input, _path, _exceptionable = true) => (("object" === typeof input.algorithms && null !== input.algorithms && false === Array.isArray(input.algorithms) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
609
789
|
method: "typia.assert",
|
|
610
790
|
path: _path + ".algorithms",
|
|
611
791
|
expected: "__type",
|
|
@@ -664,9 +844,9 @@ function main(argv) {
|
|
|
664
844
|
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
665
845
|
expected: "Array<number>",
|
|
666
846
|
value: value
|
|
667
|
-
}, _errorFactory)) && value.every((elem,
|
|
847
|
+
}, _errorFactory)) && value.every((elem, _index12) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
668
848
|
method: "typia.assert",
|
|
669
|
-
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key) + "[" +
|
|
849
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key) + "[" + _index12 + "]",
|
|
670
850
|
expected: "number",
|
|
671
851
|
value: elem
|
|
672
852
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -695,9 +875,9 @@ function main(argv) {
|
|
|
695
875
|
path: _path + ".oid",
|
|
696
876
|
expected: "Array<number>",
|
|
697
877
|
value: input.oid
|
|
698
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
878
|
+
}, _errorFactory)) && input.oid.every((elem, _index13) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
699
879
|
method: "typia.assert",
|
|
700
|
-
path: _path + ".oid[" +
|
|
880
|
+
path: _path + ".oid[" + _index13 + "]",
|
|
701
881
|
expected: "number",
|
|
702
882
|
value: elem
|
|
703
883
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -750,9 +930,9 @@ function main(argv) {
|
|
|
750
930
|
path: _path + ".field_order",
|
|
751
931
|
expected: "(Array<string> | undefined)",
|
|
752
932
|
value: input.field_order
|
|
753
|
-
}, _errorFactory)) && input.field_order.every((elem,
|
|
933
|
+
}, _errorFactory)) && input.field_order.every((elem, _index14) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
754
934
|
method: "typia.assert",
|
|
755
|
-
path: _path + ".field_order[" +
|
|
935
|
+
path: _path + ".field_order[" + _index14 + "]",
|
|
756
936
|
expected: "string",
|
|
757
937
|
value: elem
|
|
758
938
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -865,9 +1045,9 @@ function main(argv) {
|
|
|
865
1045
|
path: _path + ".oid",
|
|
866
1046
|
expected: "Array<number>",
|
|
867
1047
|
value: input.oid
|
|
868
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1048
|
+
}, _errorFactory)) && input.oid.every((elem, _index15) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
869
1049
|
method: "typia.assert",
|
|
870
|
-
path: _path + ".oid[" +
|
|
1050
|
+
path: _path + ".oid[" + _index15 + "]",
|
|
871
1051
|
expected: "number",
|
|
872
1052
|
value: elem
|
|
873
1053
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -905,9 +1085,9 @@ function main(argv) {
|
|
|
905
1085
|
path: _path + ".oid",
|
|
906
1086
|
expected: "Array<number>",
|
|
907
1087
|
value: input.oid
|
|
908
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1088
|
+
}, _errorFactory)) && input.oid.every((elem, _index16) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
909
1089
|
method: "typia.assert",
|
|
910
|
-
path: _path + ".oid[" +
|
|
1090
|
+
path: _path + ".oid[" + _index16 + "]",
|
|
911
1091
|
expected: "number",
|
|
912
1092
|
value: elem
|
|
913
1093
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -920,9 +1100,9 @@ function main(argv) {
|
|
|
920
1100
|
path: _path + ".values",
|
|
921
1101
|
expected: "Array<string>",
|
|
922
1102
|
value: input.values
|
|
923
|
-
}, _errorFactory)) && input.values.every((elem,
|
|
1103
|
+
}, _errorFactory)) && input.values.every((elem, _index17) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
924
1104
|
method: "typia.assert",
|
|
925
|
-
path: _path + ".values[" +
|
|
1105
|
+
path: _path + ".values[" + _index17 + "]",
|
|
926
1106
|
expected: "string",
|
|
927
1107
|
value: elem
|
|
928
1108
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -955,9 +1135,9 @@ function main(argv) {
|
|
|
955
1135
|
path: _path + ".oid",
|
|
956
1136
|
expected: "Array<number>",
|
|
957
1137
|
value: input.oid
|
|
958
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1138
|
+
}, _errorFactory)) && input.oid.every((elem, _index18) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
959
1139
|
method: "typia.assert",
|
|
960
|
-
path: _path + ".oid[" +
|
|
1140
|
+
path: _path + ".oid[" + _index18 + "]",
|
|
961
1141
|
expected: "number",
|
|
962
1142
|
value: elem
|
|
963
1143
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -1020,9 +1200,9 @@ function main(argv) {
|
|
|
1020
1200
|
path: _path + ".oid",
|
|
1021
1201
|
expected: "Array<number>",
|
|
1022
1202
|
value: input.oid
|
|
1023
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1203
|
+
}, _errorFactory)) && input.oid.every((elem, _index19) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1024
1204
|
method: "typia.assert",
|
|
1025
|
-
path: _path + ".oid[" +
|
|
1205
|
+
path: _path + ".oid[" + _index19 + "]",
|
|
1026
1206
|
expected: "number",
|
|
1027
1207
|
value: elem
|
|
1028
1208
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -1045,9 +1225,9 @@ function main(argv) {
|
|
|
1045
1225
|
path: _path + ".field_order",
|
|
1046
1226
|
expected: "(Array<string> | undefined)",
|
|
1047
1227
|
value: input.field_order
|
|
1048
|
-
}, _errorFactory)) && input.field_order.every((elem,
|
|
1228
|
+
}, _errorFactory)) && input.field_order.every((elem, _index20) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1049
1229
|
method: "typia.assert",
|
|
1050
|
-
path: _path + ".field_order[" +
|
|
1230
|
+
path: _path + ".field_order[" + _index20 + "]",
|
|
1051
1231
|
expected: "string",
|
|
1052
1232
|
value: elem
|
|
1053
1233
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -1100,20 +1280,20 @@ function main(argv) {
|
|
|
1100
1280
|
expected: "__type.o20",
|
|
1101
1281
|
value: value
|
|
1102
1282
|
}, _errorFactory);
|
|
1103
|
-
}); const _ao22 = (input, _path, _exceptionable = true) => ((Array.isArray(input.oid) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1283
|
+
}); const _ao22 = (input, _path, _exceptionable = true) => (undefined === input.oid || (Array.isArray(input.oid) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1104
1284
|
method: "typia.assert",
|
|
1105
1285
|
path: _path + ".oid",
|
|
1106
|
-
expected: "Array<number>",
|
|
1286
|
+
expected: "(Array<number> | undefined)",
|
|
1107
1287
|
value: input.oid
|
|
1108
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1288
|
+
}, _errorFactory)) && input.oid.every((elem, _index21) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1109
1289
|
method: "typia.assert",
|
|
1110
|
-
path: _path + ".oid[" +
|
|
1290
|
+
path: _path + ".oid[" + _index21 + "]",
|
|
1111
1291
|
expected: "number",
|
|
1112
1292
|
value: elem
|
|
1113
1293
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1114
1294
|
method: "typia.assert",
|
|
1115
1295
|
path: _path + ".oid",
|
|
1116
|
-
expected: "Array<number>",
|
|
1296
|
+
expected: "(Array<number> | undefined)",
|
|
1117
1297
|
value: input.oid
|
|
1118
1298
|
}, _errorFactory)) && (undefined === input.type || "string" === typeof input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1119
1299
|
method: "typia.assert",
|
|
@@ -1125,11 +1305,61 @@ function main(argv) {
|
|
|
1125
1305
|
path: _path + ".description",
|
|
1126
1306
|
expected: "string",
|
|
1127
1307
|
value: input.description
|
|
1128
|
-
}, _errorFactory)) && ("string" === typeof input.reference || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1308
|
+
}, _errorFactory)) && (undefined === input.reference || "string" === typeof input.reference || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1129
1309
|
method: "typia.assert",
|
|
1130
1310
|
path: _path + ".reference",
|
|
1131
|
-
expected: "string",
|
|
1311
|
+
expected: "(string | undefined)",
|
|
1132
1312
|
value: input.reference
|
|
1313
|
+
}, _errorFactory)) && (undefined === input.fields || ("object" === typeof input.fields && null !== input.fields && false === Array.isArray(input.fields) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1314
|
+
method: "typia.assert",
|
|
1315
|
+
path: _path + ".fields",
|
|
1316
|
+
expected: "(__type.o21 | undefined)",
|
|
1317
|
+
value: input.fields
|
|
1318
|
+
}, _errorFactory)) && _ao23(input.fields, _path + ".fields", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1319
|
+
method: "typia.assert",
|
|
1320
|
+
path: _path + ".fields",
|
|
1321
|
+
expected: "(__type.o21 | undefined)",
|
|
1322
|
+
value: input.fields
|
|
1323
|
+
}, _errorFactory)) && (undefined === input.field_order || (Array.isArray(input.field_order) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1324
|
+
method: "typia.assert",
|
|
1325
|
+
path: _path + ".field_order",
|
|
1326
|
+
expected: "(Array<string> | undefined)",
|
|
1327
|
+
value: input.field_order
|
|
1328
|
+
}, _errorFactory)) && input.field_order.every((elem, _index22) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1329
|
+
method: "typia.assert",
|
|
1330
|
+
path: _path + ".field_order[" + _index22 + "]",
|
|
1331
|
+
expected: "string",
|
|
1332
|
+
value: elem
|
|
1333
|
+
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1334
|
+
method: "typia.assert",
|
|
1335
|
+
path: _path + ".field_order",
|
|
1336
|
+
expected: "(Array<string> | undefined)",
|
|
1337
|
+
value: input.field_order
|
|
1338
|
+
}, _errorFactory)); const _ao23 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every(key => {
|
|
1339
|
+
const value = input[key];
|
|
1340
|
+
if (undefined === value)
|
|
1341
|
+
return true;
|
|
1342
|
+
return ("object" === typeof value && null !== value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1343
|
+
method: "typia.assert",
|
|
1344
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
1345
|
+
expected: "__type.o22",
|
|
1346
|
+
value: value
|
|
1347
|
+
}, _errorFactory)) && _ao24(value, _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key), true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1348
|
+
method: "typia.assert",
|
|
1349
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
1350
|
+
expected: "__type.o22",
|
|
1351
|
+
value: value
|
|
1352
|
+
}, _errorFactory);
|
|
1353
|
+
}); const _ao24 = (input, _path, _exceptionable = true) => ("string" === typeof input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1354
|
+
method: "typia.assert",
|
|
1355
|
+
path: _path + ".type",
|
|
1356
|
+
expected: "string",
|
|
1357
|
+
value: input.type
|
|
1358
|
+
}, _errorFactory)) && (undefined === input.optional || "boolean" === typeof input.optional || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1359
|
+
method: "typia.assert",
|
|
1360
|
+
path: _path + ".optional",
|
|
1361
|
+
expected: "(boolean | undefined)",
|
|
1362
|
+
value: input.optional
|
|
1133
1363
|
}, _errorFactory)); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
1134
1364
|
if (false === __is(input)) {
|
|
1135
1365
|
_errorFactory = errorFactory;
|