@keetanetwork/anchor 0.0.14 → 0.0.15
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 +29 -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/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/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 +76 -216
- package/package.json +2 -2
- package/services/asset-movement/common.js +7 -7
- package/services/kyc/iso20022.generated.d.ts +77 -26
- package/services/kyc/iso20022.generated.d.ts.map +1 -1
- package/services/kyc/iso20022.generated.js +168 -86
- package/services/kyc/iso20022.generated.js.map +1 -1
- package/services/kyc/oids.generated.d.ts +27 -6
- package/services/kyc/oids.generated.d.ts.map +1 -1
- package/services/kyc/oids.generated.js +43 -10
- package/services/kyc/oids.generated.js.map +1 -1
- package/services/kyc/utils/generate-kyc-schema.js +262 -74
- 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)) {
|
|
@@ -498,9 +620,20 @@ function generateIso20022Types() {
|
|
|
498
620
|
throw (new Error(`Sensitive attribute ${name} has no defined type.`));
|
|
499
621
|
}
|
|
500
622
|
const baseType = resolveToBaseType(config.type);
|
|
501
|
-
|
|
623
|
+
const baseTypeSnake = toSnakeCase(baseType);
|
|
624
|
+
const isExtensionType = oidSchema.extensions[baseTypeSnake]?.fields ?? oidSchema.extensions[baseType]?.fields;
|
|
625
|
+
if (isExtensionType) {
|
|
626
|
+
schemaRef = `${baseType}Schema`;
|
|
627
|
+
}
|
|
628
|
+
else if (baseType === 'GeneralizedTime') {
|
|
502
629
|
schemaRef = 'ASN1.ValidateASN1.IsDate';
|
|
503
630
|
}
|
|
631
|
+
else if (baseType === 'OCTET STRING') {
|
|
632
|
+
schemaRef = 'ASN1.ValidateASN1.IsOctetString';
|
|
633
|
+
}
|
|
634
|
+
else if (baseType === 'OBJECT IDENTIFIER') {
|
|
635
|
+
schemaRef = 'ASN1.ValidateASN1.IsOID';
|
|
636
|
+
}
|
|
504
637
|
else {
|
|
505
638
|
schemaRef = `{ type: 'string', kind: 'utf8' }`;
|
|
506
639
|
}
|
|
@@ -605,7 +738,12 @@ function main(argv) {
|
|
|
605
738
|
if (undefined === value)
|
|
606
739
|
return true;
|
|
607
740
|
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
|
|
741
|
+
}); 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 => {
|
|
742
|
+
const value = input[key];
|
|
743
|
+
if (undefined === value)
|
|
744
|
+
return true;
|
|
745
|
+
return "object" === typeof value && null !== value && _io24(value);
|
|
746
|
+
}); 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
747
|
method: "typia.assert",
|
|
610
748
|
path: _path + ".algorithms",
|
|
611
749
|
expected: "__type",
|
|
@@ -664,9 +802,9 @@ function main(argv) {
|
|
|
664
802
|
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
665
803
|
expected: "Array<number>",
|
|
666
804
|
value: value
|
|
667
|
-
}, _errorFactory)) && value.every((elem,
|
|
805
|
+
}, _errorFactory)) && value.every((elem, _index12) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
668
806
|
method: "typia.assert",
|
|
669
|
-
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key) + "[" +
|
|
807
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key) + "[" + _index12 + "]",
|
|
670
808
|
expected: "number",
|
|
671
809
|
value: elem
|
|
672
810
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -695,9 +833,9 @@ function main(argv) {
|
|
|
695
833
|
path: _path + ".oid",
|
|
696
834
|
expected: "Array<number>",
|
|
697
835
|
value: input.oid
|
|
698
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
836
|
+
}, _errorFactory)) && input.oid.every((elem, _index13) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
699
837
|
method: "typia.assert",
|
|
700
|
-
path: _path + ".oid[" +
|
|
838
|
+
path: _path + ".oid[" + _index13 + "]",
|
|
701
839
|
expected: "number",
|
|
702
840
|
value: elem
|
|
703
841
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -750,9 +888,9 @@ function main(argv) {
|
|
|
750
888
|
path: _path + ".field_order",
|
|
751
889
|
expected: "(Array<string> | undefined)",
|
|
752
890
|
value: input.field_order
|
|
753
|
-
}, _errorFactory)) && input.field_order.every((elem,
|
|
891
|
+
}, _errorFactory)) && input.field_order.every((elem, _index14) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
754
892
|
method: "typia.assert",
|
|
755
|
-
path: _path + ".field_order[" +
|
|
893
|
+
path: _path + ".field_order[" + _index14 + "]",
|
|
756
894
|
expected: "string",
|
|
757
895
|
value: elem
|
|
758
896
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -865,9 +1003,9 @@ function main(argv) {
|
|
|
865
1003
|
path: _path + ".oid",
|
|
866
1004
|
expected: "Array<number>",
|
|
867
1005
|
value: input.oid
|
|
868
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1006
|
+
}, _errorFactory)) && input.oid.every((elem, _index15) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
869
1007
|
method: "typia.assert",
|
|
870
|
-
path: _path + ".oid[" +
|
|
1008
|
+
path: _path + ".oid[" + _index15 + "]",
|
|
871
1009
|
expected: "number",
|
|
872
1010
|
value: elem
|
|
873
1011
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -905,9 +1043,9 @@ function main(argv) {
|
|
|
905
1043
|
path: _path + ".oid",
|
|
906
1044
|
expected: "Array<number>",
|
|
907
1045
|
value: input.oid
|
|
908
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1046
|
+
}, _errorFactory)) && input.oid.every((elem, _index16) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
909
1047
|
method: "typia.assert",
|
|
910
|
-
path: _path + ".oid[" +
|
|
1048
|
+
path: _path + ".oid[" + _index16 + "]",
|
|
911
1049
|
expected: "number",
|
|
912
1050
|
value: elem
|
|
913
1051
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -920,9 +1058,9 @@ function main(argv) {
|
|
|
920
1058
|
path: _path + ".values",
|
|
921
1059
|
expected: "Array<string>",
|
|
922
1060
|
value: input.values
|
|
923
|
-
}, _errorFactory)) && input.values.every((elem,
|
|
1061
|
+
}, _errorFactory)) && input.values.every((elem, _index17) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
924
1062
|
method: "typia.assert",
|
|
925
|
-
path: _path + ".values[" +
|
|
1063
|
+
path: _path + ".values[" + _index17 + "]",
|
|
926
1064
|
expected: "string",
|
|
927
1065
|
value: elem
|
|
928
1066
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -955,9 +1093,9 @@ function main(argv) {
|
|
|
955
1093
|
path: _path + ".oid",
|
|
956
1094
|
expected: "Array<number>",
|
|
957
1095
|
value: input.oid
|
|
958
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1096
|
+
}, _errorFactory)) && input.oid.every((elem, _index18) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
959
1097
|
method: "typia.assert",
|
|
960
|
-
path: _path + ".oid[" +
|
|
1098
|
+
path: _path + ".oid[" + _index18 + "]",
|
|
961
1099
|
expected: "number",
|
|
962
1100
|
value: elem
|
|
963
1101
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -1020,9 +1158,9 @@ function main(argv) {
|
|
|
1020
1158
|
path: _path + ".oid",
|
|
1021
1159
|
expected: "Array<number>",
|
|
1022
1160
|
value: input.oid
|
|
1023
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1161
|
+
}, _errorFactory)) && input.oid.every((elem, _index19) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1024
1162
|
method: "typia.assert",
|
|
1025
|
-
path: _path + ".oid[" +
|
|
1163
|
+
path: _path + ".oid[" + _index19 + "]",
|
|
1026
1164
|
expected: "number",
|
|
1027
1165
|
value: elem
|
|
1028
1166
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -1045,9 +1183,9 @@ function main(argv) {
|
|
|
1045
1183
|
path: _path + ".field_order",
|
|
1046
1184
|
expected: "(Array<string> | undefined)",
|
|
1047
1185
|
value: input.field_order
|
|
1048
|
-
}, _errorFactory)) && input.field_order.every((elem,
|
|
1186
|
+
}, _errorFactory)) && input.field_order.every((elem, _index20) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1049
1187
|
method: "typia.assert",
|
|
1050
|
-
path: _path + ".field_order[" +
|
|
1188
|
+
path: _path + ".field_order[" + _index20 + "]",
|
|
1051
1189
|
expected: "string",
|
|
1052
1190
|
value: elem
|
|
1053
1191
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -1100,20 +1238,20 @@ function main(argv) {
|
|
|
1100
1238
|
expected: "__type.o20",
|
|
1101
1239
|
value: value
|
|
1102
1240
|
}, _errorFactory);
|
|
1103
|
-
}); const _ao22 = (input, _path, _exceptionable = true) => ((Array.isArray(input.oid) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1241
|
+
}); const _ao22 = (input, _path, _exceptionable = true) => (undefined === input.oid || (Array.isArray(input.oid) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1104
1242
|
method: "typia.assert",
|
|
1105
1243
|
path: _path + ".oid",
|
|
1106
|
-
expected: "Array<number>",
|
|
1244
|
+
expected: "(Array<number> | undefined)",
|
|
1107
1245
|
value: input.oid
|
|
1108
|
-
}, _errorFactory)) && input.oid.every((elem,
|
|
1246
|
+
}, _errorFactory)) && input.oid.every((elem, _index21) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1109
1247
|
method: "typia.assert",
|
|
1110
|
-
path: _path + ".oid[" +
|
|
1248
|
+
path: _path + ".oid[" + _index21 + "]",
|
|
1111
1249
|
expected: "number",
|
|
1112
1250
|
value: elem
|
|
1113
1251
|
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1114
1252
|
method: "typia.assert",
|
|
1115
1253
|
path: _path + ".oid",
|
|
1116
|
-
expected: "Array<number>",
|
|
1254
|
+
expected: "(Array<number> | undefined)",
|
|
1117
1255
|
value: input.oid
|
|
1118
1256
|
}, _errorFactory)) && (undefined === input.type || "string" === typeof input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1119
1257
|
method: "typia.assert",
|
|
@@ -1125,11 +1263,61 @@ function main(argv) {
|
|
|
1125
1263
|
path: _path + ".description",
|
|
1126
1264
|
expected: "string",
|
|
1127
1265
|
value: input.description
|
|
1128
|
-
}, _errorFactory)) && ("string" === typeof input.reference || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1266
|
+
}, _errorFactory)) && (undefined === input.reference || "string" === typeof input.reference || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1129
1267
|
method: "typia.assert",
|
|
1130
1268
|
path: _path + ".reference",
|
|
1131
|
-
expected: "string",
|
|
1269
|
+
expected: "(string | undefined)",
|
|
1132
1270
|
value: input.reference
|
|
1271
|
+
}, _errorFactory)) && (undefined === input.fields || ("object" === typeof input.fields && null !== input.fields && false === Array.isArray(input.fields) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1272
|
+
method: "typia.assert",
|
|
1273
|
+
path: _path + ".fields",
|
|
1274
|
+
expected: "(__type.o21 | undefined)",
|
|
1275
|
+
value: input.fields
|
|
1276
|
+
}, _errorFactory)) && _ao23(input.fields, _path + ".fields", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1277
|
+
method: "typia.assert",
|
|
1278
|
+
path: _path + ".fields",
|
|
1279
|
+
expected: "(__type.o21 | undefined)",
|
|
1280
|
+
value: input.fields
|
|
1281
|
+
}, _errorFactory)) && (undefined === input.field_order || (Array.isArray(input.field_order) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1282
|
+
method: "typia.assert",
|
|
1283
|
+
path: _path + ".field_order",
|
|
1284
|
+
expected: "(Array<string> | undefined)",
|
|
1285
|
+
value: input.field_order
|
|
1286
|
+
}, _errorFactory)) && input.field_order.every((elem, _index22) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1287
|
+
method: "typia.assert",
|
|
1288
|
+
path: _path + ".field_order[" + _index22 + "]",
|
|
1289
|
+
expected: "string",
|
|
1290
|
+
value: elem
|
|
1291
|
+
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1292
|
+
method: "typia.assert",
|
|
1293
|
+
path: _path + ".field_order",
|
|
1294
|
+
expected: "(Array<string> | undefined)",
|
|
1295
|
+
value: input.field_order
|
|
1296
|
+
}, _errorFactory)); const _ao23 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every(key => {
|
|
1297
|
+
const value = input[key];
|
|
1298
|
+
if (undefined === value)
|
|
1299
|
+
return true;
|
|
1300
|
+
return ("object" === typeof value && null !== value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1301
|
+
method: "typia.assert",
|
|
1302
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
1303
|
+
expected: "__type.o22",
|
|
1304
|
+
value: value
|
|
1305
|
+
}, _errorFactory)) && _ao24(value, _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key), true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1306
|
+
method: "typia.assert",
|
|
1307
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
1308
|
+
expected: "__type.o22",
|
|
1309
|
+
value: value
|
|
1310
|
+
}, _errorFactory);
|
|
1311
|
+
}); const _ao24 = (input, _path, _exceptionable = true) => ("string" === typeof input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1312
|
+
method: "typia.assert",
|
|
1313
|
+
path: _path + ".type",
|
|
1314
|
+
expected: "string",
|
|
1315
|
+
value: input.type
|
|
1316
|
+
}, _errorFactory)) && (undefined === input.optional || "boolean" === typeof input.optional || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
1317
|
+
method: "typia.assert",
|
|
1318
|
+
path: _path + ".optional",
|
|
1319
|
+
expected: "(boolean | undefined)",
|
|
1320
|
+
value: input.optional
|
|
1133
1321
|
}, _errorFactory)); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
1134
1322
|
if (false === __is(input)) {
|
|
1135
1323
|
_errorFactory = errorFactory;
|