@keetanetwork/anchor 0.0.21 → 0.0.23
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/config.d.ts +1 -1
- package/config.d.ts.map +1 -1
- package/config.js +1 -1
- package/config.js.map +1 -1
- package/lib/certificates.d.ts +4 -1
- package/lib/certificates.d.ts.map +1 -1
- package/lib/certificates.js +148 -14
- package/lib/certificates.js.map +1 -1
- package/lib/error.d.ts +35 -0
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +203 -7
- package/lib/error.js.map +1 -1
- package/lib/http-server/common.d.ts +6 -0
- package/lib/http-server/common.d.ts.map +1 -0
- package/lib/http-server/common.js +2 -0
- package/lib/http-server/common.js.map +1 -0
- package/lib/{http-server.d.ts → http-server/index.d.ts} +30 -12
- package/lib/http-server/index.d.ts.map +1 -0
- package/lib/{http-server.js → http-server/index.js} +107 -46
- package/lib/http-server/index.js.map +1 -0
- package/lib/resolver.d.ts +5 -2
- package/lib/resolver.d.ts.map +1 -1
- package/lib/resolver.js +15 -2
- package/lib/resolver.js.map +1 -1
- package/lib/utils/asn1.d.ts +0 -13
- package/lib/utils/asn1.d.ts.map +1 -1
- package/lib/utils/asn1.js +0 -1498
- package/lib/utils/asn1.js.map +1 -1
- package/lib/utils/external.d.ts.map +1 -1
- package/lib/utils/external.js +9 -2
- package/lib/utils/external.js.map +1 -1
- package/npm-shrinkwrap.json +5 -5
- package/package.json +2 -2
- package/services/asset-movement/client.d.ts +1 -0
- package/services/asset-movement/client.d.ts.map +1 -1
- package/services/asset-movement/client.js +13 -9
- package/services/asset-movement/client.js.map +1 -1
- package/services/asset-movement/common.d.ts +1 -1
- package/services/asset-movement/common.d.ts.map +1 -1
- package/services/asset-movement/common.js.map +1 -1
- package/services/asset-movement/server.d.ts +1 -1
- package/services/asset-movement/server.d.ts.map +1 -1
- package/services/asset-movement/server.js +1 -1
- package/services/asset-movement/server.js.map +1 -1
- package/services/fx/common.d.ts +15 -5
- package/services/fx/common.d.ts.map +1 -1
- package/services/fx/common.js +29 -0
- package/services/fx/common.js.map +1 -1
- package/services/fx/server.d.ts +12 -2
- package/services/fx/server.d.ts.map +1 -1
- package/services/fx/server.js +9 -2
- package/services/fx/server.js.map +1 -1
- package/services/kyc/common.d.ts +3 -5
- package/services/kyc/common.d.ts.map +1 -1
- package/services/kyc/common.generated.js +2 -2
- package/services/kyc/common.js +1 -0
- package/services/kyc/common.js.map +1 -1
- package/services/kyc/iso20022.generated.js +54 -54
- package/services/kyc/iso20022.generated.js.map +1 -1
- package/services/kyc/server.d.ts +1 -1
- package/services/kyc/server.d.ts.map +1 -1
- package/services/kyc/server.js +1 -1
- package/services/kyc/server.js.map +1 -1
- package/services/kyc/utils/generate-kyc-schema.js +34 -6
- package/services/kyc/utils/generate-kyc-schema.js.map +1 -1
- package/lib/http-server.d.ts.map +0 -1
- package/lib/http-server.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-kyc-schema.js","sourceRoot":"","sources":["../../../../src/services/kyc/utils/generate-kyc-schema.ts"],"names":[],"mappings":";;;AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqF/B;;GAEG;AACH,IAAI,SAA4B,CAAC;AAEjC,4BAA4B;AAC5B,SAAS,gBAAgB,CAAC,GAAwB;IACjD,OAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACvB,CAAC;AACD,SAAS,cAAc,CAAC,GAAW;IAClC,OAAM,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAS,IAAI;QACzC,OAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACnB,CAAC;AACD,SAAS,YAAY,CAAC,GAAW;IAChC,OAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAAmC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAE/F,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,oBAAoB,EAAE,EAAE,MAAM,CAAC,CAAC;IACjE,EAAE,CAAC,aAAa,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;AACvE,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC","sourcesContent":["#! /usr/bin/env ts-node\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as typia from 'typia';\n\ntype oidSchemaContentsAttribute = {\n\t[key: string]: {\n\t\toid: number[];\n\t\ttype?: string;\n\t\ttoken?: string;\n\t\tdescription: string;\n\t\treference: string;\n\t\tfields?: {\n\t\t\t[key: string]: {\n\t\t\t\ttype: string;\n\t\t\t\toptional?: boolean;\n\t\t\t};\n\t\t};\n\t\tchoices?: {\n\t\t\t[key: string]: {\n\t\t\t\ttype: string;\n\t\t\t};\n\t\t};\n\t\tfield_order?: string[];\n\t};\n}\ntype oidSchemaContents = {\n\talgorithms: {\n\t\t[key: string]: number[]\n\t};\n\tsensitive_attributes: oidSchemaContentsAttribute;\n\tplain_attributes: oidSchemaContentsAttribute;\n\tiso20022_types: {\n\t\tprimitives: {\n\t\t\t[key: string]: {\n\t\t\t\toid: number[];\n\t\t\t\ttype: string;\n\t\t\t\tdescription: string;\n\t\t\t};\n\t\t};\n\t\tenumerations: {\n\t\t\t[key: string]: {\n\t\t\t\toid: number[];\n\t\t\t\tvalues: string[];\n\t\t\t\tdescription: string;\n\t\t\t};\n\t\t};\n\t\tchoices: {\n\t\t\t[key: string]: {\n\t\t\t\toid: number[];\n\t\t\t\tchoices: {\n\t\t\t\t\t[key: string]: {\n\t\t\t\t\t\ttype: string;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\tdescription: string;\n\t\t\t};\n\t\t};\n\t\tsequences: {\n\t\t\t[key: string]: {\n\t\t\t\toid: number[];\n\t\t\t\tfields: {\n\t\t\t\t\t[key: string]: {\n\t\t\t\t\t\ttype: string;\n\t\t\t\t\t\toptional?: boolean;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\tfield_order?: string[];\n\t\t\t\tdescription: string;\n\t\t\t};\n\t\t};\n\t};\n\textensions: {\n\t\t[key: string]: {\n\t\t\toid?: number[];\n\t\t\ttype?: string;\n\t\t\tdescription: string;\n\t\t\treference?: string;\n\t\t\tfields?: {\n\t\t\t\t[key: string]: {\n\t\t\t\t\ttype: string;\n\t\t\t\t\toptional?: boolean;\n\t\t\t\t};\n\t\t\t};\n\t\t\tfield_order?: string[];\n\t\t};\n\t};\n};\n/*\n * Populated in `main` function\n */\nlet oidSchema: oidSchemaContents;\n\n// --- Utility Functions ---\nfunction oidArrayToString(oid: (string | number)[]): string {\n\treturn(oid.join('.'));\n}\nfunction toConstantCase(str: string): string {\n\treturn(str.replace(/[A-Z]/g, function(part) {\n\t\treturn(`_${part}`);\n\t}).toUpperCase());\n}\nfunction toPascalCase(str: string): string {\n\treturn(str.split(/[_-]/).map(function(part) {\n\t\treturn(part.charAt(0).toUpperCase() + part.slice(1));\n\t}).join(''));\n}\nfunction toSnakeCase(str: string): string {\n\treturn(str.replace(/([A-Z])/g, '_$1').toLowerCase().replace(/^_/, ''));\n}\n\n// --- Type Resolution ---\nfunction resolveTypeReference(typeName: string): string {\n\tif (typeName.startsWith('SEQUENCE OF ')) {\n\t\treturn(`${resolveTypeReference(typeName.substring('SEQUENCE OF '.length).trim())}[]`);\n\t}\n\tswitch (typeName.trim()) {\n\t\tcase 'UTF8String':\n\t\tcase 'Utf8String':\n\t\t\treturn('string');\n\t\tcase 'GeneralizedTime':\n\t\t\treturn('Date');\n\t\tcase 'ENUMERATED':\n\t\t\treturn('string');\n\t\tcase 'OBJECT IDENTIFIER':\n\t\t\treturn('ASN1.ASN1OID');\n\t\tcase 'OCTET STRING':\n\t\t\treturn('Buffer');\n\t\tdefault:\n\t\t\treturn(toPascalCase(typeName));\n\t}\n}\n\nfunction resolveToBaseType(typeName: string): string {\n\ttypeName = typeName.trim();\n\n\t// Check if it's a primitive type first\n\tif (/^(UTF8String|Utf8String|GeneralizedTime)$/i.test(typeName)) {\n\t\treturn(typeName);\n\t}\n\n\t// Check if it's defined as a sensitive attribute\n\tconst sensitiveAttr = oidSchema.sensitive_attributes[typeName] ?? Object.values(oidSchema.sensitive_attributes).find(function(attr) {\n\t\treturn(attr.token === typeName);\n\t});\n\n\tif (sensitiveAttr && !sensitiveAttr.fields && !sensitiveAttr.choices) {\n\t\tif (sensitiveAttr.type === undefined) {\n\t\t\tthrow(new Error(`Sensitive attribute ${typeName} has no defined type.`));\n\t\t}\n\t\treturn(resolveToBaseType(sensitiveAttr.type));\n\t}\n\n\t// Check if it's an ISO20022 primitive\n\tconst primitive = oidSchema.iso20022_types.primitives[typeName];\n\tif (primitive) {\n\t\treturn(resolveToBaseType(primitive.type));\n\t}\n\n\t// Otherwise return as-is\n\treturn(typeName);\n}\n\nfunction isEnumerationType(typeName: string): boolean {\n\tconst normalized = toSnakeCase(typeName);\n\treturn(Boolean(\n\t\toidSchema.iso20022_types.enumerations[typeName] ??\n\t\toidSchema.iso20022_types.enumerations[normalized]\n\t));\n}\n\nfunction isSequenceOfChoice(config: { fields: { [key: string]: { optional?: boolean }}}): boolean {\n\tconst hasFields = config.fields && Object.keys(config.fields).length > 0;\n\tconst allOptional = hasFields && Object.values(config.fields).every(function(field) {\n\t\treturn(field.optional);\n\t});\n\treturn(allOptional);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction _ignore_getPrimitiveType(type: string): 'string' | 'date' {\n\tif (type === 'UTF8String' || type === 'Utf8String') {\n\t\treturn('string');\n\t}\n\tif (type === 'GeneralizedTime') {\n\t\treturn('date');\n\t}\n\treturn('string');\n}\n\n// --- Output Generators ---\nfunction genHeader(comment: string) {\n\treturn([\n\t\t'/* eslint-disable */',\n\t\t'/**',\n\t\t` * ${comment}`,\n\t\t' * This file is auto-generated from oids.json.',\n\t\t' */',\n\t\t''\n\t].join('\\n'));\n}\n\nfunction genTypeAlias(name: string, type: string, description: string, oid: string): string {\n\treturn(`/** ${description} */\\n/** OID: ${oid} */\\nexport type ${name} = ${type};\\n`);\n}\n\nfunction genEnumType(name: string, values: string[], description: string, oid: string): string {\n\treturn(`/** ${description} */\\n/** OID: ${oid} */\\nexport type ${name} = ${values.map(function(value) {\n\t\treturn(`'${value}'`);\n\t}).join(' | ')};\\n`);\n}\n\nfunction genInterface(name: string, fields: { [key: string]: { type: string; optional?: boolean }}, description: string, oid: string): string {\n\tconst fieldLines = Object.entries(fields).map(function([fieldName, fieldConfig]) {\n\t\treturn(`\\t${fieldName}${fieldConfig.optional ? '?' : ''}: ${resolveTypeReference(fieldConfig.type)};`);\n\t});\n\treturn(`/** ${description} */\\n/** OID: ${oid} */\\nexport interface ${name} {\\n${fieldLines.join('\\n')}\\n}\\n`);\n}\n\n// Generate TypeScript **types** for sequence-of-choice\nfunction genSequenceOfChoiceTypes(name: string, config: { fields: { [key: string]: { type: string; optional?: boolean }}; field_order?: string[] }): string {\n\tconst typeName = toPascalCase(name);\n\tconst fieldOrder = config.field_order ?? Object.keys(config.fields);\n\tconst choiceEntries = fieldOrder.map(function(fieldName): [string, { type: string; optional?: boolean }] {\n\t\tif (!(fieldName in config.fields) || config.fields[fieldName] === undefined) {\n\t\t\tthrow(new Error(`Field ${fieldName} not found in sequence of choice ${name}`));\n\t\t}\n\t\treturn([fieldName, config.fields[fieldName]]);\n\t});\n\tconst choiceTypes = choiceEntries.map(function([fieldName, fieldConfig], index) {\n\t\tif (fieldConfig === undefined) {\n\t\t\tthrow(new Error(`Field ${fieldName} not found in sequence of choice ${name}`));\n\t\t}\n\t\tconst fieldType = resolveTypeReference(fieldConfig.type);\n\t\tconst choiceTypeName = `${typeName}${toPascalCase(fieldName)}Choice`;\n\t\treturn({\n\t\t\tcode: `export interface ${choiceTypeName} {\\n\\ttag: ${index};\\n\\tname: '${fieldName}';\\n\\tvalue: ${fieldType};\\n}\\n`,\n\t\t\tname: choiceTypeName\n\t\t});\n\t});\n\n\tlet out = '';\n\t// Individual choice interfaces\n\tout += choiceTypes.map(function(choiceInfo) {\n\t\treturn(choiceInfo.code);\n\t}).join('\\n');\n\n\t// Union type\n\tout += `export type ${typeName}Choice =\\n\\t| ${choiceTypes.map(function(choiceInfo) {\n\t\treturn(choiceInfo.name);\n\t}).join('\\n\\t| ')};\\n\\n`;\n\n\t// Main type is array of choices\n\tout += `export type ${typeName} = ${typeName}Choice[];\\n\\n`;\n\n\treturn(out);\n}\n\n// Generate ASN.1 **schema** for sequence-of-choice\nfunction genSequenceOfChoiceSchema(name: string, config: { fields: { [key: string]: { type: string; optional?: boolean }}; field_order?: string[] }): string {\n\tconst typeName = toPascalCase(name);\n\tconst fieldOrder = config.field_order ?? Object.keys(config.fields);\n\tconst choiceEntries = fieldOrder.map(function(fieldName): [string, { type: string; optional?: boolean }] {\n\t\tif (!(fieldName in config.fields) || config.fields[fieldName] === undefined) {\n\t\t\tthrow(new Error(`Field ${fieldName} not found in sequence of choice ${name}`));\n\t\t}\n\t\treturn([fieldName, config.fields[fieldName]]);\n\t});\n\n\tlet out = '';\n\n\t// ASN.1 schema\n\tout += `/** ASN.1 schema for ${typeName} */\\n`;\n\tout += `export const ${typeName}Schema: ASN1.Schema = {\\n\\tsequenceOf: {\\n\\t\\tchoice: [\\n`;\n\tout += choiceEntries.map(function([fieldName, fieldConfig], index) {\n\t\tif (fieldConfig === undefined) {\n\t\t\tthrow(new Error(`Field ${fieldName} not found in sequence of choice ${name}`));\n\t\t}\n\n\t\t// Determine the type for this choice\n\t\tlet fieldType = fieldConfig.type.trim();\n\t\tif (fieldType.startsWith('SEQUENCE OF ')) {\n\t\t\tfieldType = fieldType.substring('SEQUENCE OF '.length).trim();\n\t\t}\n\t\tfieldType = fieldType.replace(/\\[\\]$/, '');\n\n\t\tconst fieldTypePascal = toPascalCase(fieldType);\n\t\tconst fieldTypeSnake = toSnakeCase(fieldType);\n\n\t\t// Check if this is a complex type that has a schema\n\t\tconst isChoice = oidSchema.iso20022_types.choices[fieldTypeSnake] ?? oidSchema.iso20022_types.choices[fieldType];\n\t\tconst isSequence = oidSchema.iso20022_types.sequences[fieldTypeSnake] ?? oidSchema.iso20022_types.sequences[fieldType];\n\t\tconst isSensitiveSequence = oidSchema.sensitive_attributes[fieldTypeSnake]?.fields;\n\t\tconst isSensitiveChoice = oidSchema.sensitive_attributes[fieldTypeSnake]?.choices;\n\t\tconst hasSchema = isChoice ?? isSequence ?? isSensitiveSequence ?? isSensitiveChoice;\n\n\t\tlet contains;\n\t\tif (hasSchema) {\n\t\t\tcontains = `${fieldTypePascal}Schema`;\n\t\t} else {\n\t\t\t// Primitive type\n\t\t\tcontains = `{ type: 'string', kind: 'utf8' }`;\n\t\t}\n\n\t\treturn(`\\t\\t\\t{ type: 'context', kind: 'explicit', value: ${index}, contains: ${contains} }`);\n\t}).join(',\\n');\n\tout += `\\n\\t\\t]\\n\\t}\\n};\\n\\n`;\n\n\t// Field names array\n\tout += `export const ${typeName}Fields = [\\n${fieldOrder.map(function(fieldName){\n\t\treturn(`\\t'${fieldName}'`);\n\t}).join(',\\n')}\\n] as const;\\n\\n`;\n\n\treturn(out);\n}\n\nfunction deleteLastCommaIfFoundGenerator(lines: string[]) {\n\treturn(function deleteLastCommaIfFound() {\n\t\tlet lastLine = lines.pop();\n\t\tif (lastLine === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tif (lastLine.endsWith(',')) {\n\t\t\tlastLine = lastLine.slice(0, -1);\n\t\t}\n\t\tlines.push(lastLine);\n\t});\n}\n\n\n// --- Main Generation ---\nfunction generateOidConstants() {\n\tconst lines = [genHeader('Generated OID Constants')];\n\tconst deleteLastCommaIfFound = deleteLastCommaIfFoundGenerator(lines);\n\n\t// Algorithm OID constants\n\tlines.push('// Algorithm OID constants');\n\tfor (const [name, oid] of Object.entries(oidSchema.algorithms)) {\n\t\tlines.push(`export const ${toConstantCase(name.replace(/-/g, '_'))} = '${oidArrayToString(oid)}';`);\n\t}\n\tlines.push('');\n\n\t// Plain attribute OID constants\n\tlines.push('// Plain attribute OID constants');\n\tfor (const [name, config] of Object.entries(oidSchema.plain_attributes)) {\n\t\tlines.push(`/** ${config.description} */`);\n\t\tlines.push(`/** @see ${config.reference} */`);\n\t\tlines.push(`export const ${toConstantCase(name)} = '${oidArrayToString(config.oid)}';`);\n\t}\n\tlines.push('');\n\n\t// Keeta namespace for sensitive attributes\n\tlines.push('// Keeta-specific OID constants');\n\tlines.push('// eslint-disable-next-line @typescript-eslint/no-namespace');\n\tlines.push('export namespace keeta {');\n\tfor (const [name, config] of Object.entries(oidSchema.extensions)) {\n\t\tlines.push(`\\t/** ${config.description} */`);\n\t\tif (config.reference) {\n\t\t\tlines.push(`\\t/** @see ${config.reference} */`);\n\t\t}\n\t\tif (config.oid) {\n\t\t\tlines.push(`\\texport const ${toConstantCase(name)} = '${oidArrayToString(config.oid)}';`);\n\t\t}\n\t}\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t/** ${config.description} */`);\n\t\tlines.push(`\\t/** @see ${config.reference} */`);\n\t\tlines.push(`\\texport const ${toConstantCase(name)} = '${oidArrayToString(config.oid)}';`);\n\t}\n\tlines.push('}');\n\tlines.push('');\n\n\t// Lookup maps\n\tlines.push('// OID to name lookup maps');\n\tlines.push('export const OID_TO_NAME: { [key: string]: string } = {');\n\tfor (const [name, config] of Object.entries({\n\t\t...oidSchema.plain_attributes,\n\t\t...oidSchema.sensitive_attributes\n\t})) {\n\t\tlines.push(`\\t'${oidArrayToString(config.oid)}': '${name}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('};');\n\tlines.push('');\n\tlines.push('export const NAME_TO_OID: { [key: string]: string } = {');\n\tfor (const [name, config] of Object.entries({\n\t\t...oidSchema.plain_attributes,\n\t\t...oidSchema.sensitive_attributes\n\t})) {\n\t\tlines.push(`\\t'${name}': '${oidArrayToString(config.oid)}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('};');\n\tlines.push('');\n\n\treturn(lines.join('\\n'));\n}\n\nfunction genSequenceSchema(typeName: string, fields: { [key: string]: { type: string; optional?: boolean }}, config: { field_order?: string[] }) {\n\tconst fieldOrder = config?.field_order ?? Object.keys(fields);\n\tconst structFields: { [key: string]: string } = {};\n\n\tfor (const fname of fieldOrder) {\n\t\tconst fcfg = fields[fname];\n\t\tif (!fcfg) {continue;}\n\n\t\t// Resolve to base type to handle aliases\n\t\tconst baseType = resolveToBaseType(fcfg.type);\n\n\t\tlet fieldSchema;\n\t\t// Check if field type is GeneralizedTime (date)\n\t\tif (baseType === 'GeneralizedTime') {\n\t\t\tfieldSchema = 'ASN1.ValidateASN1.IsDate';\n\t\t} else {\n\t\t\t// Check if this is a SEQUENCE OF type directly or via type reference\n\t\t\tlet fieldType = baseType.trim();\n\t\t\tconst isSequenceOf = fieldType.startsWith('SEQUENCE OF ');\n\t\t\tif (isSequenceOf) {\n\t\t\t\tfieldType = fieldType.substring('SEQUENCE OF '.length).trim();\n\t\t\t}\n\n\t\t\tfieldType = fieldType.replace(/\\[\\]$/, '');\n\n\t\t\tconst fieldTypePascal = toPascalCase(fieldType);\n\t\t\tconst fieldTypeSnake = toSnakeCase(fieldType);\n\n\t\t\t// Check if this is a COMPLEX type (not a primitive)\n\t\t\tconst isChoice = oidSchema.iso20022_types.choices[fieldTypeSnake] ?? oidSchema.iso20022_types.choices[fieldType];\n\t\t\tconst isSequence = oidSchema.iso20022_types.sequences[fieldTypeSnake] ?? oidSchema.iso20022_types.sequences[fieldType];\n\t\t\tconst isSensitiveSequence = oidSchema.sensitive_attributes[fieldTypeSnake]?.fields;\n\t\t\tconst isSensitiveChoice = oidSchema.sensitive_attributes[fieldTypeSnake]?.choices;\n\t\t\tconst isExtension = oidSchema.extensions[fieldTypeSnake]?.fields ?? oidSchema.extensions[fieldType]?.fields;\n\n\t\t\tconst hasSchema = isChoice ?? isSequence ?? isSensitiveSequence ?? isSensitiveChoice ?? isExtension;\n\n\t\t\tif (hasSchema) {\n\t\t\t\tfieldSchema = `${fieldTypePascal}Schema`;\n\t\t\t} else {\n\t\t\t\t// Primitive type - use inline schema\n\t\t\t\tif (fieldType === 'OBJECT IDENTIFIER') {\n\t\t\t\t\tfieldSchema = `ASN1.ValidateASN1.IsOID`;\n\t\t\t\t} else if (fieldType === 'OCTET STRING') {\n\t\t\t\t\tfieldSchema = `ASN1.ValidateASN1.IsOctetString`;\n\t\t\t\t} else {\n\t\t\t\t\tfieldSchema = `{ type: 'string', kind: 'utf8' }`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Wrap in sequenceOf if this was a SEQUENCE OF type\n\t\t\tif (isSequenceOf) {\n\t\t\t\tfieldSchema = `{ sequenceOf: ${fieldSchema} }`;\n\t\t\t}\n\t\t}\n\n\t\tif (fcfg.optional) {\n\t\t\tstructFields[fname] = `{ optional: ${fieldSchema} }`;\n\t\t} else {\n\t\t\tstructFields[fname] = fieldSchema;\n\t\t}\n\t}\n\n\tconst containsObject = fieldOrder.map(function(fname) {\n\t\treturn(`\\t\\t${fname}: ${structFields[fname]}`);\n\t}).join(',\\n');\n\n\treturn(`export const ${typeName}Schema: ASN1.Schema = {\\n\\ttype: 'struct',\\n\\tfieldNames: [${fieldOrder.map(f => `'${f}'`).join(', ')}],\\n\\tcontains: {\\n${containsObject}\\n\\t}\\n};`);\n}\n\nfunction generateIso20022Types() {\n\tconst lines = [\n\t\tgenHeader('Generated ISO20022 Type Definitions'),\n\t\t\"import * as ASN1 from '../../lib/utils/asn1.js';\",\n\t\t\"import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\",\n\t\t'type KeetaNetAccount = InstanceType<typeof KeetaNetLib.Account>;',\n\t\t''\n\t];\n\tconst deleteLastCommaIfFound = deleteLastCommaIfFoundGenerator(lines);\n\n\t// Primitives\n\tlines.push('// ISO20022 Primitive Types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.primitives)) {\n\t\tlines.push(genTypeAlias(toPascalCase(name), resolveTypeReference(config.type), config.description, oidArrayToString(config.oid)));\n\t}\n\n\t// Enumerations\n\tlines.push('// ISO20022 Enumeration Types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.enumerations)) {\n\t\tlines.push(genEnumType(toPascalCase(name), config.values, config.description, oidArrayToString(config.oid)));\n\t}\n\n\t// Choices\n\tlines.push('// ISO20022 Choice Types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.choices)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tconst choices = Object.entries(config.choices ?? {});\n\t\tconst hasComplexTypes = choices.some(function([_ignore_choiceName, choiceConfig]) {\n\t\t\tconst choiceType = choiceConfig.type.trim();\n\t\t\treturn(choiceType !== 'UTF8String' && choiceType !== 'string');\n\t\t});\n\t\tif (hasComplexTypes) {\n\t\t\tconst unionTypes = Array.from(new Set(choices.map(function([_ignore_choiceName, choiceConfig]) {\n\t\t\t\treturn(resolveTypeReference(choiceConfig.type.trim()));\n\t\t\t})));\n\t\t\tlines.push(genTypeAlias(typeName, unionTypes.join(' | '), config.description, oidArrayToString(config.oid)));\n\t\t} else {\n\t\t\tlines.push(genTypeAlias(typeName, 'string', config.description, oidArrayToString(config.oid)));\n\t\t}\n\t}\n\n\t// ISO20022 Sequences and Sequence-of-Choice Types\n\tlines.push('// ISO20022 Sequence Types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {\n\t\tif (isSequenceOfChoice(config)) {\n\t\t\tlines.push(genSequenceOfChoiceTypes(name, config));\n\t\t} else {\n\t\t\tlines.push(genInterface(toPascalCase(name), config.fields, config.description, oidArrayToString(config.oid)));\n\t\t}\n\t}\n\tlines.push('');\n\n\t// --- Choice Type Schemas ---\n\tlines.push('// Generated ASN.1 schemas for ISO 20022 choice types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.choices)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tconst choices = Object.entries(config.choices ?? {});\n\n\t\tlines.push(`/** ASN.1 schema for ${typeName} */`);\n\n\t\tif (choices.length === 0) {\n\t\t\t// No choices defined - simple string schema\n\t\t\tlines.push(`export const ${typeName}Schema: ASN1.Schema = { type: 'string', kind: 'utf8' };`);\n\t\t} else {\n\t\t\t// Generate choice schema with context tags to make them differentiable\n\t\t\tconst choiceSchemas = choices.map(function([_ignore_choiceName, choiceConfig], index) {\n\t\t\t\tconst choiceType = choiceConfig.type.trim();\n\t\t\t\tlet containsSchema;\n\n\t\t\t\t// Check if it is a primitive type\n\t\t\t\tif (choiceType === 'UTF8String' || choiceType === 'Utf8String' || choiceType === 'string' || isEnumerationType(choiceType)) {\n\t\t\t\t\tcontainsSchema = `{ type: 'string', kind: 'utf8' }`;\n\t\t\t\t} else {\n\t\t\t\t\t// Complex type - reference its schema\n\t\t\t\t\tconst choiceTypeName = toPascalCase(choiceType);\n\t\t\t\t\tcontainsSchema = `${choiceTypeName}Schema`;\n\t\t\t\t}\n\n\t\t\t\t// Wrap in context tag to make it differentiable\n\t\t\t\treturn(`{ type: 'context', kind: 'explicit', value: ${index}, contains: ${containsSchema} }`);\n\t\t\t});\n\n\t\t\tlines.push(`export const ${typeName}Schema: ASN1.Schema = {`);\n\t\t\tlines.push(`\\tchoice: [`);\n\t\t\tlines.push(`\\t\\t${choiceSchemas.join(',\\n\\t\\t')}`);\n\t\t\tlines.push(`\\t]`);\n\t\t\tlines.push(`};`);\n\t\t}\n\t\tlines.push('');\n\t}\n\n\t// --- Regular Sequence Type Schemas (SECOND - may depend on choice schemas) ---\n\tlines.push('// Generated ASN.1 schemas for ISO 20022 regular sequence types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tif (config.fields && !isSequenceOfChoice(config)) {\n\t\t\tlines.push(`/** ASN.1 schema for ${typeName} */`);\n\t\t\tlines.push(genSequenceSchema(typeName, config.fields, config));\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// --- Sequence-of-Choice Type Schemas (THIRD - depend on regular sequence schemas) ---\n\tlines.push('// Generated ASN.1 schemas for ISO 20022 sequence-of-choice types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {\n\t\tif (isSequenceOfChoice(config)) {\n\t\t\tlines.push(genSequenceOfChoiceSchema(name, config));\n\t\t}\n\t}\n\n\t// --- Choice-Type Sensitive Attribute Schemas ---\n\tlines.push('// Generated ASN.1 schemas for choice-type sensitive attributes');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tif (config.choices) {\n\t\t\tconst choiceSchemas = Object.values(config.choices).map(function(choice) {\n\t\t\t\tconst choiceTypeName = toPascalCase(choice.type.trim());\n\t\t\t\treturn(`${choiceTypeName}Schema`);\n\t\t\t});\n\t\t\tlines.push(`/** ASN.1 schema for ${typeName} */`);\n\t\t\tlines.push(`export const ${typeName}Schema: ASN1.Schema = {`);\n\t\t\tlines.push(`\\tchoice: [`);\n\t\t\tlines.push(`\\t\\t${choiceSchemas.join(',\\n\\t\\t')}`);\n\t\t\tlines.push(`\\t]`);\n\t\t\tlines.push(`};`);\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// Sensitive Attribute Types\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tif (!config.fields && !config.choices) {\n\t\t\t// Primitive type\n\t\t\tlet baseType;\n\t\t\tif (config.type === 'UTF8String' || config.type === 'Utf8String') {\n\t\t\t\tbaseType = 'string';\n\t\t\t} else if (config.type === 'GeneralizedTime') {\n\t\t\t\tbaseType = 'Date';\n\t\t\t} else {\n\t\t\t\tif (config.type === undefined) {\n\t\t\t\t\tthrow(new Error(`Sensitive attribute ${name} has no defined type.`));\n\t\t\t\t}\n\t\t\t\tbaseType = toPascalCase(config.type);\n\t\t\t}\n\t\t\tlines.push(`/** ${config.description} */`);\n\t\t\tlines.push(`/** OID: ${oidArrayToString(config.oid)} */`);\n\t\t\tlines.push(`export type ${typeName} = ${baseType};`);\n\t\t\tlines.push('');\n\t\t} else if (config.fields) {\n\t\t\t// Sequence type\n\t\t\tlines.push(`/** ${config.description} */`);\n\t\t\tlines.push(`/** OID: ${oidArrayToString(config.oid)} */`);\n\t\t\tlines.push(`export interface ${typeName} {`);\n\t\t\tfor (const [fieldName, fieldConfig] of Object.entries(config.fields)) {\n\t\t\t\tconst optional = fieldConfig.optional ? '?' : '';\n\t\t\t\tconst resolvedType = resolveTypeReference(fieldConfig.type);\n\t\t\t\tlines.push(`\\t${fieldName}${optional}: ${resolvedType};`);\n\t\t\t}\n\t\t\tlines.push('}');\n\t\t\tlines.push('');\n\t\t} else if (config.choices) {\n\t\t\t// Choice type\n\t\t\tlines.push(`/** ${config.description} */`);\n\t\t\tlines.push(`/** OID: ${oidArrayToString(config.oid)} */`);\n\t\t\tconst hasComplexTypes = Object.values(config.choices).some(function(choice) {\n\t\t\t\tconst choiceType = choice.type.trim();\n\t\t\t\treturn(choiceType !== 'UTF8String' && choiceType !== 'string');\n\t\t\t});\n\t\t\tif (hasComplexTypes) {\n\t\t\t\tconst unionTypes = Object.values(config.choices).map(function(choice) {\n\t\t\t\t\treturn(toPascalCase(choice.type.trim()));\n\t\t\t\t});\n\t\t\t\tlines.push(`export type ${typeName} = ${unionTypes.join(' | ')};`);\n\t\t\t} else {\n\t\t\t\tlines.push(`export type ${typeName} = string;`);\n\t\t\t}\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// Extension Types with fields\n\tfor (const [name, config] of Object.entries(oidSchema.extensions)) {\n\t\tif (config.fields) {\n\t\t\tconst typeName = toPascalCase(name);\n\t\t\tlines.push(`/** ${config.description} */`);\n\t\t\tif (config.oid) {\n\t\t\t\tlines.push(`/** OID: ${oidArrayToString(config.oid)} */`);\n\t\t\t}\n\t\t\tlines.push(`export interface ${typeName} {`);\n\t\t\tfor (const [fieldName, fieldConfig] of Object.entries(config.fields)) {\n\t\t\t\tconst optional = fieldConfig.optional ? '?' : '';\n\t\t\t\tconst resolvedType = resolveTypeReference(fieldConfig.type);\n\t\t\t\tlines.push(`\\t${fieldName}${optional}: ${resolvedType};`);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * The \"Reference\" type is a special case where we inject\n\t\t\t * some additional attributes when decoding.\n\t\t\t */\n\t\t\tif (typeName === 'Reference') {\n\t\t\t\tlines.push('\\t/**');\n\t\t\t\tlines.push('\\t * TODOC');\n\t\t\t\tlines.push('\\t */');\n\t\t\t\tlines.push('\\t$blob: (principals?: KeetaNetAccount[]) => Promise<Blob>;');\n\t\t\t}\n\t\t\tlines.push('}');\n\t\t\tlines.push('');\n\t\t\t// Schema\n\t\t\tlines.push(genSequenceSchema(typeName, config.fields, config));\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// Token aliases for sensitive attributes\n\tlines.push('// Token aliases for sensitive attributes');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tif (config.token && config.token !== toPascalCase(name)) {\n\t\t\tconst typeName = toPascalCase(name);\n\t\t\tconst tokenName = config.token;\n\t\t\tlines.push(`/** Alias for ${typeName} */`);\n\t\t\tlines.push(`export type ${tokenName} = ${typeName};`);\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// Union type, value map, helper generic\n\tlines.push('/** Union type of all sensitive attribute types */');\n\tlines.push('export type SensitiveAttributeType =');\n\tlines.push(Object.keys(oidSchema.sensitive_attributes).map(function(name) {\n\t\treturn(`\\t| ${toPascalCase(name)}`);\n\t}).join('\\n') + ';');\n\tlines.push('');\n\tlines.push('/** Map of attribute name to acceptable input type for CertificateBuilder.setAttribute */');\n\tlines.push('export interface CertificateAttributeValueMap {');\n\tfor (const [name] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t'${name}': ${toPascalCase(name)};`);\n\t}\n\tlines.push('}');\n\tlines.push('');\n\tlines.push('/** Helper generic to get attribute value type by name */');\n\tlines.push('export type CertificateAttributeValue<Name extends keyof CertificateAttributeValueMap> = CertificateAttributeValueMap[Name];');\n\tlines.push('');\n\n\t// Field arrays and schemas for sequence types\n\t// Sort to ensure dependencies are defined before they're used\n\tconst sensitiveAttrEntries = Object.entries(oidSchema.sensitive_attributes);\n\tconst sortedEntries: [string, typeof sensitiveAttrEntries[0][1]][] = [];\n\tconst processed = new Set<string>();\n\n\tfunction hasDependency(config: typeof sensitiveAttrEntries[0][1], depName: string): boolean {\n\t\tif (!config.fields) {return(false);}\n\t\treturn(Object.values(config.fields).some(field => {\n\t\t\tconst fieldType = field.type.trim();\n\t\t\treturn(fieldType === toPascalCase(depName) || fieldType === depName);\n\t\t}));\n\t}\n\n\t// Process entries, dependencies first\n\twhile (sortedEntries.length < sensitiveAttrEntries.length) {\n\t\tfor (const [name, config] of sensitiveAttrEntries) {\n\t\t\tif (processed.has(name)) {continue;}\n\n\t\t\t// Check if all dependencies are processed\n\t\t\tlet allDepsProcessed = true;\n\t\t\tif (config.fields) {\n\t\t\t\tfor (const [otherName] of sensitiveAttrEntries) {\n\t\t\t\t\tif (otherName === name || processed.has(otherName)) {continue;}\n\t\t\t\t\tif (hasDependency(config, otherName)) {\n\t\t\t\t\t\tallDepsProcessed = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (allDepsProcessed) {\n\t\t\t\tsortedEntries.push([name, config]);\n\t\t\t\tprocessed.add(name);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const [name, config] of sortedEntries) {\n\t\tconst typeName = toPascalCase(name);\n\t\tif (config.fields) {\n\t\t\tconst fieldOrder = config.field_order ?? Object.keys(config.fields);\n\t\t\tlines.push(`export const ${typeName}Fields = [${fieldOrder.map(function(field) {\n\t\t\t\treturn(`'${field}'`);\n\t\t\t}).join(', ')}] as const;`);\n\t\t\tlines.push(genSequenceSchema(typeName, config.fields, config));\n\t\t}\n\t}\n\n\t// OID DB\n\tlines.push('export const CertificateAttributeOIDDB = {');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t'${name}': '${oidArrayToString(config.oid)}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('} as const;');\n\tlines.push('');\n\n\t// Sensitive attribute list\n\tlines.push('export const SENSITIVE_CERTIFICATE_ATTRIBUTES = [');\n\tfor (const name of Object.keys(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t'${name}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('] as const;');\n\tlines.push('');\n\n\tlines.push('export type SensitiveCertificateAttributeNames = typeof SENSITIVE_CERTIFICATE_ATTRIBUTES[number];');\n\tlines.push('');\n\n\t// PascalCase names\n\tlines.push('export const SensitiveCertificateAttributeNames = [');\n\tfor (const name of Object.keys(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t'${toPascalCase(name)}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('] as const;');\n\tlines.push('');\n\n\t// Field name mapping\n\tlines.push('export const CertificateAttributeFieldNames: { readonly [K in keyof typeof CertificateAttributeOIDDB]?: readonly string[] } = {');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tif (config.fields) {\n\t\t\tconst typeName = toPascalCase(name);\n\t\t\tlines.push(`\\t'${name}': ${typeName}Fields,`);\n\t\t}\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('} as const;');\n\tlines.push('');\n\n\t// Complete schema mapping (ONCE, at the end)\n\tlines.push('export const CertificateAttributeSchema: { readonly [K in keyof typeof CertificateAttributeOIDDB]: ASN1.Schema } = {');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tlet schemaRef;\n\t\tif (config.fields) {\n\t\t\tschemaRef = `${typeName}Schema`;\n\t\t} else if (config.choices) {\n\t\t\tschemaRef = `${typeName}Schema`;\n\t\t} else {\n\t\t\tif (config.type === undefined) {\n\t\t\t\tthrow(new Error(`Sensitive attribute ${name} has no defined type.`));\n\t\t\t}\n\t\t\tconst baseType = resolveToBaseType(config.type);\n\t\t\tconst baseTypeSnake = toSnakeCase(baseType);\n\t\t\tconst isExtensionType = oidSchema.extensions[baseTypeSnake]?.fields ?? oidSchema.extensions[baseType]?.fields;\n\t\t\tconst isSensitiveType = oidSchema.sensitive_attributes[toSnakeCase(baseType)]?.fields ?? oidSchema.sensitive_attributes[baseType]?.fields;\n\n\t\t\tif (isSensitiveType) {\n\t\t\t\tschemaRef = `${baseType}Schema`;\n\t\t\t} else if (isExtensionType) {\n\t\t\t\tschemaRef = `${baseType}Schema`;\n\t\t\t} else if (baseType === 'GeneralizedTime') {\n\t\t\t\tschemaRef = 'ASN1.ValidateASN1.IsDate';\n\t\t\t} else if (baseType === 'OCTET STRING') {\n\t\t\t\tschemaRef = 'ASN1.ValidateASN1.IsOctetString';\n\t\t\t} else if (baseType === 'OBJECT IDENTIFIER') {\n\t\t\t\tschemaRef = 'ASN1.ValidateASN1.IsOID';\n\t\t\t} else {\n\t\t\t\tschemaRef = `{ type: 'string', kind: 'utf8' }`;\n\t\t\t}\n\t\t}\n\t\tlines.push(`\\t'${name}': ${schemaRef},`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('} as const;');\n\tlines.push('');\n\n\treturn(lines.join('\\n'));\n}\n\nfunction parseArgs(argv: string[]): { oidsJSONPath: string; oidsOutputPath: string; iso20022OutputPath: string } {\n\tlet oidsJSONPath: string | undefined = undefined;\n\tlet oidsOutputPath: string | undefined = undefined;\n\tlet iso20022OutputPath: string | undefined = undefined;\n\tfor (const arg of argv) {\n\t\tif (arg.startsWith('--oids-json=')) {\n\t\t\toidsJSONPath = arg.substring('--oids-json='.length);\n\t\t}\n\t\tif (arg.startsWith('--oids-output=')) {\n\t\t\toidsOutputPath = arg.substring('--oids-output='.length);\n\t\t}\n\t\tif (arg.startsWith('--iso20022-output=')) {\n\t\t\tiso20022OutputPath = arg.substring('--iso20022-output='.length);\n\t\t}\n\t}\n\n\tif (oidsJSONPath === undefined) {\n\t\tthrow(new Error('Missing required argument: --oids-json=path/to/oids.json'));\n\t}\n\tif (oidsOutputPath === undefined) {\n\t\tthrow(new Error('Missing required argument: --oids-output=path/to/oids.generated.ts'));\n\t}\n\tif (iso20022OutputPath === undefined) {\n\t\tthrow(new Error('Missing required argument: --iso20022-output=path/to/iso20022.generated.ts'));\n\t}\n\tif (!fs.existsSync(oidsJSONPath)) {\n\t\tthrow(new Error(`OID JSON file not found: ${oidsJSONPath}`));\n\t}\n\treturn({\n\t\toidsJSONPath,\n\t\toidsOutputPath,\n\t\tiso20022OutputPath\n\t});\n}\n\n// --- Main ---\nfunction main(argv: string[]): void {\n\tconst {\n\t\toidsJSONPath,\n\t\toidsOutputPath,\n\t\tiso20022OutputPath\n\t} = parseArgs(argv);\n\n\tfs.mkdirSync(path.dirname(oidsOutputPath), { recursive: true });\n\tfs.mkdirSync(path.dirname(iso20022OutputPath), { recursive: true });\n\n\toidSchema = typia.assert<oidSchemaContents>(JSON.parse(fs.readFileSync(oidsJSONPath, 'utf8')));\n\n\tfs.writeFileSync(oidsOutputPath, generateOidConstants(), 'utf8');\n\tfs.writeFileSync(iso20022OutputPath, generateIso20022Types(), 'utf8');\n}\n\nmain(process.argv.slice(2));\n"]}
|
|
1
|
+
{"version":3,"file":"generate-kyc-schema.js","sourceRoot":"","sources":["../../../../src/services/kyc/utils/generate-kyc-schema.ts"],"names":[],"mappings":";;;AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqF/B;;GAEG;AACH,IAAI,SAA4B,CAAC;AAEjC,4BAA4B;AAC5B,SAAS,gBAAgB,CAAC,GAAwB;IACjD,OAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACvB,CAAC;AACD,SAAS,cAAc,CAAC,GAAW;IAClC,OAAM,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAS,IAAI;QACzC,OAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACnB,CAAC;AACD,SAAS,YAAY,CAAC,GAAW;IAChC,OAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,UAAS,IAAI;QACzC,OAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAAmC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAE/F,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,oBAAoB,EAAE,EAAE,MAAM,CAAC,CAAC;IACjE,EAAE,CAAC,aAAa,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;AACvE,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC","sourcesContent":["#! /usr/bin/env ts-node\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as typia from 'typia';\n\ntype oidSchemaContentsAttribute = {\n\t[key: string]: {\n\t\toid: number[];\n\t\ttype?: string;\n\t\ttoken?: string;\n\t\tdescription: string;\n\t\treference: string;\n\t\tfields?: {\n\t\t\t[key: string]: {\n\t\t\t\ttype: string;\n\t\t\t\toptional?: boolean;\n\t\t\t};\n\t\t};\n\t\tchoices?: {\n\t\t\t[key: string]: {\n\t\t\t\ttype: string;\n\t\t\t};\n\t\t};\n\t\tfield_order?: string[];\n\t};\n}\ntype oidSchemaContents = {\n\talgorithms: {\n\t\t[key: string]: number[]\n\t};\n\tsensitive_attributes: oidSchemaContentsAttribute;\n\tplain_attributes: oidSchemaContentsAttribute;\n\tiso20022_types: {\n\t\tprimitives: {\n\t\t\t[key: string]: {\n\t\t\t\toid: number[];\n\t\t\t\ttype: string;\n\t\t\t\tdescription: string;\n\t\t\t};\n\t\t};\n\t\tenumerations: {\n\t\t\t[key: string]: {\n\t\t\t\toid: number[];\n\t\t\t\tvalues: string[];\n\t\t\t\tdescription: string;\n\t\t\t};\n\t\t};\n\t\tchoices: {\n\t\t\t[key: string]: {\n\t\t\t\toid: number[];\n\t\t\t\tchoices: {\n\t\t\t\t\t[key: string]: {\n\t\t\t\t\t\ttype: string;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\tdescription: string;\n\t\t\t};\n\t\t};\n\t\tsequences: {\n\t\t\t[key: string]: {\n\t\t\t\toid: number[];\n\t\t\t\tfields: {\n\t\t\t\t\t[key: string]: {\n\t\t\t\t\t\ttype: string;\n\t\t\t\t\t\toptional?: boolean;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\tfield_order?: string[];\n\t\t\t\tdescription: string;\n\t\t\t};\n\t\t};\n\t};\n\textensions: {\n\t\t[key: string]: {\n\t\t\toid?: number[];\n\t\t\ttype?: string;\n\t\t\tdescription: string;\n\t\t\treference?: string;\n\t\t\tfields?: {\n\t\t\t\t[key: string]: {\n\t\t\t\t\ttype: string;\n\t\t\t\t\toptional?: boolean;\n\t\t\t\t};\n\t\t\t};\n\t\t\tfield_order?: string[];\n\t\t};\n\t};\n};\n/*\n * Populated in `main` function\n */\nlet oidSchema: oidSchemaContents;\n\n// --- Utility Functions ---\nfunction oidArrayToString(oid: (string | number)[]): string {\n\treturn(oid.join('.'));\n}\nfunction toConstantCase(str: string): string {\n\treturn(str.replace(/[A-Z]/g, function(part) {\n\t\treturn(`_${part}`);\n\t}).toUpperCase());\n}\nfunction toPascalCase(str: string): string {\n\treturn(str.split(/[_-]/).map(function(part) {\n\t\treturn(part.charAt(0).toUpperCase() + part.slice(1));\n\t}).join(''));\n}\nfunction toSnakeCase(str: string): string {\n\treturn(str.replace(/([A-Z])/g, '_$1').toLowerCase().replace(/^_/, ''));\n}\n\n// --- Type Resolution ---\nfunction resolveTypeReference(typeName: string): string {\n\tif (typeName.startsWith('SEQUENCE OF ')) {\n\t\treturn(`${resolveTypeReference(typeName.substring('SEQUENCE OF '.length).trim())}[]`);\n\t}\n\tswitch (typeName.trim()) {\n\t\tcase 'UTF8String':\n\t\tcase 'Utf8String':\n\t\t\treturn('string');\n\t\tcase 'GeneralizedTime':\n\t\t\treturn('Date');\n\t\tcase 'ENUMERATED':\n\t\t\treturn('string');\n\t\tcase 'OBJECT IDENTIFIER':\n\t\t\treturn('ASN1.ASN1OID');\n\t\tcase 'OCTET STRING':\n\t\t\treturn('Buffer');\n\t\tdefault:\n\t\t\treturn(toPascalCase(typeName));\n\t}\n}\n\nfunction resolveToBaseType(typeName: string): string {\n\ttypeName = typeName.trim();\n\n\t// Check if it's a primitive type first\n\tif (/^(UTF8String|Utf8String|GeneralizedTime)$/i.test(typeName)) {\n\t\treturn(typeName);\n\t}\n\n\t// Check if it's defined as a sensitive attribute\n\tconst sensitiveAttr = oidSchema.sensitive_attributes[typeName] ?? Object.values(oidSchema.sensitive_attributes).find(function(attr) {\n\t\treturn(attr.token === typeName);\n\t});\n\n\tif (sensitiveAttr && !sensitiveAttr.fields && !sensitiveAttr.choices) {\n\t\tif (sensitiveAttr.type === undefined) {\n\t\t\tthrow(new Error(`Sensitive attribute ${typeName} has no defined type.`));\n\t\t}\n\t\treturn(resolveToBaseType(sensitiveAttr.type));\n\t}\n\n\t// Check if it's an ISO20022 primitive\n\tconst primitive = oidSchema.iso20022_types.primitives[typeName];\n\tif (primitive) {\n\t\treturn(resolveToBaseType(primitive.type));\n\t}\n\n\t// Otherwise return as-is\n\treturn(typeName);\n}\n\nfunction isEnumerationType(typeName: string): boolean {\n\tconst normalized = toSnakeCase(typeName);\n\treturn(Boolean(\n\t\toidSchema.iso20022_types.enumerations[typeName] ??\n\t\toidSchema.iso20022_types.enumerations[normalized]\n\t));\n}\n\nfunction isSequenceOfChoice(config: { fields: { [key: string]: { optional?: boolean }}}): boolean {\n\tconst hasFields = config.fields && Object.keys(config.fields).length > 0;\n\tconst allOptional = hasFields && Object.values(config.fields).every(function(field) {\n\t\treturn(field.optional);\n\t});\n\treturn(allOptional);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction _ignore_getPrimitiveType(type: string): 'string' | 'date' {\n\tif (type === 'UTF8String' || type === 'Utf8String') {\n\t\treturn('string');\n\t}\n\tif (type === 'GeneralizedTime') {\n\t\treturn('date');\n\t}\n\treturn('string');\n}\n\n// --- Output Generators ---\nfunction genHeader(comment: string) {\n\treturn([\n\t\t'/* eslint-disable */',\n\t\t'/**',\n\t\t` * ${comment}`,\n\t\t' * This file is auto-generated from oids.json.',\n\t\t' */',\n\t\t''\n\t].join('\\n'));\n}\n\nfunction genTypeAlias(name: string, type: string, description: string, oid: string): string {\n\treturn(`/** ${description} */\\n/** OID: ${oid} */\\nexport type ${name} = ${type};\\n`);\n}\n\nfunction genEnumType(name: string, values: string[], description: string, oid: string): string {\n\treturn(`/** ${description} */\\n/** OID: ${oid} */\\nexport type ${name} = ${values.map(function(value) {\n\t\treturn(`'${value}'`);\n\t}).join(' | ')};\\n`);\n}\n\nfunction genInterface(name: string, fields: { [key: string]: { type: string; optional?: boolean }}, description: string, oid: string): string {\n\tconst fieldLines = Object.entries(fields).map(function([fieldName, fieldConfig]) {\n\t\treturn(`\\t${fieldName}${fieldConfig.optional ? '?' : ''}: ${resolveTypeReference(fieldConfig.type)};`);\n\t});\n\treturn(`/** ${description} */\\n/** OID: ${oid} */\\nexport interface ${name} {\\n${fieldLines.join('\\n')}\\n}\\n`);\n}\n\n// Generate TypeScript **types** for sequence-of-choice\nfunction genSequenceOfChoiceTypes(name: string, config: { fields: { [key: string]: { type: string; optional?: boolean }}; field_order?: string[] }): string {\n\tconst typeName = toPascalCase(name);\n\tconst fieldOrder = config.field_order ?? Object.keys(config.fields);\n\tconst choiceEntries = fieldOrder.map(function(fieldName): [string, { type: string; optional?: boolean }] {\n\t\tif (!(fieldName in config.fields) || config.fields[fieldName] === undefined) {\n\t\t\tthrow(new Error(`Field ${fieldName} not found in sequence of choice ${name}`));\n\t\t}\n\t\treturn([fieldName, config.fields[fieldName]]);\n\t});\n\tconst choiceTypes = choiceEntries.map(function([fieldName, fieldConfig], index) {\n\t\tif (fieldConfig === undefined) {\n\t\t\tthrow(new Error(`Field ${fieldName} not found in sequence of choice ${name}`));\n\t\t}\n\t\tconst fieldType = resolveTypeReference(fieldConfig.type);\n\t\tconst choiceTypeName = `${typeName}${toPascalCase(fieldName)}Choice`;\n\t\treturn({\n\t\t\tcode: `export interface ${choiceTypeName} {\\n\\ttag: ${index};\\n\\tname: '${fieldName}';\\n\\tvalue: ${fieldType};\\n}\\n`,\n\t\t\tname: choiceTypeName\n\t\t});\n\t});\n\n\tlet out = '';\n\t// Individual choice interfaces\n\tout += choiceTypes.map(function(choiceInfo) {\n\t\treturn(choiceInfo.code);\n\t}).join('\\n');\n\n\t// Union type\n\tout += `export type ${typeName}Choice =\\n\\t| ${choiceTypes.map(function(choiceInfo) {\n\t\treturn(choiceInfo.name);\n\t}).join('\\n\\t| ')};\\n\\n`;\n\n\t// Main type is array of choices\n\tout += `export type ${typeName} = ${typeName}Choice[];\\n\\n`;\n\n\treturn(out);\n}\n\n// Generate ASN.1 **schema** for sequence-of-choice\nfunction genSequenceOfChoiceSchema(name: string, config: { fields: { [key: string]: { type: string; optional?: boolean }}; field_order?: string[] }): string {\n\tconst typeName = toPascalCase(name);\n\tconst fieldOrder = config.field_order ?? Object.keys(config.fields);\n\tconst choiceEntries = fieldOrder.map(function(fieldName): [string, { type: string; optional?: boolean }] {\n\t\tif (!(fieldName in config.fields) || config.fields[fieldName] === undefined) {\n\t\t\tthrow(new Error(`Field ${fieldName} not found in sequence of choice ${name}`));\n\t\t}\n\t\treturn([fieldName, config.fields[fieldName]]);\n\t});\n\n\tlet out = '';\n\n\t// ASN.1 schema\n\tout += `/** ASN.1 schema for ${typeName} */\\n`;\n\tout += `export const ${typeName}Schema: ASN1.Schema = {\\n\\tsequenceOf: {\\n\\t\\tchoice: [\\n`;\n\tout += choiceEntries.map(function([fieldName, fieldConfig], index) {\n\t\tif (fieldConfig === undefined) {\n\t\t\tthrow(new Error(`Field ${fieldName} not found in sequence of choice ${name}`));\n\t\t}\n\n\t\t// Determine the type for this choice\n\t\tlet fieldType = fieldConfig.type.trim();\n\t\tif (fieldType.startsWith('SEQUENCE OF ')) {\n\t\t\tfieldType = fieldType.substring('SEQUENCE OF '.length).trim();\n\t\t}\n\t\tfieldType = fieldType.replace(/\\[\\]$/, '');\n\n\t\tconst fieldTypePascal = toPascalCase(fieldType);\n\t\tconst fieldTypeSnake = toSnakeCase(fieldType);\n\n\t\t// Check if this is a complex type that has a schema\n\t\tconst isChoice = oidSchema.iso20022_types.choices[fieldTypeSnake] ?? oidSchema.iso20022_types.choices[fieldType];\n\t\tconst isSequence = oidSchema.iso20022_types.sequences[fieldTypeSnake] ?? oidSchema.iso20022_types.sequences[fieldType];\n\t\tconst isSensitiveSequence = oidSchema.sensitive_attributes[fieldTypeSnake]?.fields;\n\t\tconst isSensitiveChoice = oidSchema.sensitive_attributes[fieldTypeSnake]?.choices;\n\t\tconst hasSchema = isChoice ?? isSequence ?? isSensitiveSequence ?? isSensitiveChoice;\n\n\t\tlet contains;\n\t\tif (hasSchema) {\n\t\t\tcontains = `${fieldTypePascal}Schema`;\n\t\t} else {\n\t\t\t// Primitive type\n\t\t\tcontains = `{ type: 'string', kind: 'utf8' }`;\n\t\t}\n\n\t\treturn(`\\t\\t\\t{ type: 'context', kind: 'explicit', value: ${index}, contains: ${contains} }`);\n\t}).join(',\\n');\n\tout += `\\n\\t\\t]\\n\\t}\\n};\\n\\n`;\n\n\t// Field names array\n\tout += `export const ${typeName}Fields = [\\n${fieldOrder.map(function(fieldName){\n\t\treturn(`\\t'${fieldName}'`);\n\t}).join(',\\n')}\\n] as const;\\n\\n`;\n\n\treturn(out);\n}\n\nfunction deleteLastCommaIfFoundGenerator(lines: string[]) {\n\treturn(function deleteLastCommaIfFound() {\n\t\tlet lastLine = lines.pop();\n\t\tif (lastLine === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tif (lastLine.endsWith(',')) {\n\t\t\tlastLine = lastLine.slice(0, -1);\n\t\t}\n\t\tlines.push(lastLine);\n\t});\n}\n\n\n// --- Main Generation ---\nfunction generateOidConstants() {\n\tconst lines = [genHeader('Generated OID Constants')];\n\tconst deleteLastCommaIfFound = deleteLastCommaIfFoundGenerator(lines);\n\n\t// Algorithm OID constants\n\tlines.push('// Algorithm OID constants');\n\tfor (const [name, oid] of Object.entries(oidSchema.algorithms)) {\n\t\tlines.push(`export const ${toConstantCase(name.replace(/-/g, '_'))} = '${oidArrayToString(oid)}';`);\n\t}\n\tlines.push('');\n\n\t// Plain attribute OID constants\n\tlines.push('// Plain attribute OID constants');\n\tfor (const [name, config] of Object.entries(oidSchema.plain_attributes)) {\n\t\tlines.push(`/** ${config.description} */`);\n\t\tlines.push(`/** @see ${config.reference} */`);\n\t\tlines.push(`export const ${toConstantCase(name)} = '${oidArrayToString(config.oid)}';`);\n\t}\n\tlines.push('');\n\n\t// Keeta namespace for sensitive attributes\n\tlines.push('// Keeta-specific OID constants');\n\tlines.push('// eslint-disable-next-line @typescript-eslint/no-namespace');\n\tlines.push('export namespace keeta {');\n\tfor (const [name, config] of Object.entries(oidSchema.extensions)) {\n\t\tlines.push(`\\t/** ${config.description} */`);\n\t\tif (config.reference) {\n\t\t\tlines.push(`\\t/** @see ${config.reference} */`);\n\t\t}\n\t\tif (config.oid) {\n\t\t\tlines.push(`\\texport const ${toConstantCase(name)} = '${oidArrayToString(config.oid)}';`);\n\t\t}\n\t}\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t/** ${config.description} */`);\n\t\tlines.push(`\\t/** @see ${config.reference} */`);\n\t\tlines.push(`\\texport const ${toConstantCase(name)} = '${oidArrayToString(config.oid)}';`);\n\t}\n\tlines.push('}');\n\tlines.push('');\n\n\t// Lookup maps\n\tlines.push('// OID to name lookup maps');\n\tlines.push('export const OID_TO_NAME: { [key: string]: string } = {');\n\tfor (const [name, config] of Object.entries({\n\t\t...oidSchema.plain_attributes,\n\t\t...oidSchema.sensitive_attributes\n\t})) {\n\t\tlines.push(`\\t'${oidArrayToString(config.oid)}': '${name}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('};');\n\tlines.push('');\n\tlines.push('export const NAME_TO_OID: { [key: string]: string } = {');\n\tfor (const [name, config] of Object.entries({\n\t\t...oidSchema.plain_attributes,\n\t\t...oidSchema.sensitive_attributes\n\t})) {\n\t\tlines.push(`\\t'${name}': '${oidArrayToString(config.oid)}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('};');\n\tlines.push('');\n\n\treturn(lines.join('\\n'));\n}\n\nfunction genSequenceSchema(typeName: string, fields: { [key: string]: { type: string; optional?: boolean }}, config: { field_order?: string[] }) {\n\tconst fieldOrder = config?.field_order ?? Object.keys(fields);\n\tconst structFields: { [key: string]: { schema: string; optional: boolean; isChoice: boolean }} = {};\n\n\tfor (const fname of fieldOrder) {\n\t\tconst fcfg = fields[fname];\n\t\tif (!fcfg) {continue;}\n\n\t\t// Resolve to base type to handle aliases\n\t\tconst baseType = resolveToBaseType(fcfg.type);\n\n\t\tlet fieldSchema;\n\t\tlet isChoiceType = false;\n\n\t\t// Check if field type is GeneralizedTime (date)\n\t\tif (baseType === 'GeneralizedTime') {\n\t\t\tfieldSchema = 'ASN1.ValidateASN1.IsDate';\n\t\t} else {\n\t\t\t// Check if this is a SEQUENCE OF type directly or via type reference\n\t\t\tlet fieldType = baseType.trim();\n\t\t\tconst isSequenceOf = fieldType.startsWith('SEQUENCE OF ');\n\t\t\tif (isSequenceOf) {\n\t\t\t\tfieldType = fieldType.substring('SEQUENCE OF '.length).trim();\n\t\t\t}\n\n\t\t\tfieldType = fieldType.replace(/\\[\\]$/, '');\n\n\t\t\tconst fieldTypePascal = toPascalCase(fieldType);\n\t\t\tconst fieldTypeSnake = toSnakeCase(fieldType);\n\n\t\t\t// Check if this is a COMPLEX type (not a primitive)\n\t\t\tconst isChoice = oidSchema.iso20022_types.choices[fieldTypeSnake] ?? oidSchema.iso20022_types.choices[fieldType];\n\t\t\tconst isSequence = oidSchema.iso20022_types.sequences[fieldTypeSnake] ?? oidSchema.iso20022_types.sequences[fieldType];\n\t\t\tconst isSensitiveSequence = oidSchema.sensitive_attributes[fieldTypeSnake]?.fields;\n\t\t\tconst isSensitiveChoice = oidSchema.sensitive_attributes[fieldTypeSnake]?.choices;\n\t\t\tconst isExtension = oidSchema.extensions[fieldTypeSnake]?.fields ?? oidSchema.extensions[fieldType]?.fields;\n\n\t\t\tconst hasSchema = isChoice ?? isSequence ?? isSensitiveSequence ?? isSensitiveChoice ?? isExtension;\n\t\t\tisChoiceType = !!(isChoice ?? isSensitiveChoice);\n\n\t\t\tif (hasSchema) {\n\t\t\t\tfieldSchema = `${fieldTypePascal}Schema`;\n\t\t\t} else {\n\t\t\t\t// Primitive type - use inline schema\n\t\t\t\tif (fieldType === 'OBJECT IDENTIFIER') {\n\t\t\t\t\tfieldSchema = `ASN1.ValidateASN1.IsOID`;\n\t\t\t\t} else if (fieldType === 'OCTET STRING') {\n\t\t\t\t\tfieldSchema = `ASN1.ValidateASN1.IsOctetString`;\n\t\t\t\t} else {\n\t\t\t\t\tfieldSchema = `{ type: 'string', kind: 'utf8' }`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Wrap in sequenceOf if this was a SEQUENCE OF type\n\t\t\tif (isSequenceOf) {\n\t\t\t\tfieldSchema = `{ sequenceOf: ${fieldSchema} }`;\n\t\t\t}\n\t\t}\n\n\t\t// Store field metadata\n\t\tstructFields[fname] = {\n\t\t\tschema: fieldSchema,\n\t\t\toptional: fcfg.optional ?? false,\n\t\t\tisChoice: isChoiceType\n\t\t};\n\t}\n\n\t// Check if ANY field is optional - if so, ALL fields need context tags for proper ordering\n\tconst hasAnyOptionalField = fieldOrder.some(function(fname) {\n\t\tconst fieldInfo = structFields[fname];\n\t\treturn(fieldInfo?.optional ?? false);\n\t});\n\n\tconst containsObject = fieldOrder.map(function(fname, index) {\n\t\tconst fieldInfo = structFields[fname];\n\t\tif (!fieldInfo) {\n\t\t\tthrow(new Error(`Field ${fname} not found in structFields`));\n\t\t}\n\n\t\tconst baseSchema = fieldInfo.schema;\n\t\tconst isOptional = fieldInfo.optional;\n\t\tconst isChoiceField = fieldInfo.isChoice;\n\t\tif (hasAnyOptionalField && !isChoiceField) {\n\t\t\tconst wrappedInContext = `{ type: 'context', kind: 'explicit', value: ${index}, contains: ${baseSchema} }`;\n\t\t\tif (isOptional) {\n\t\t\t\treturn(`\\t\\t${fname}: { optional: ${wrappedInContext} }`);\n\t\t\t} else {\n\t\t\t\treturn(`\\t\\t${fname}: ${wrappedInContext}`);\n\t\t\t}\n\t\t} else if (isOptional) {\n\t\t\treturn(`\\t\\t${fname}: { optional: ${baseSchema} }`);\n\t\t} else {\n\t\t\treturn(`\\t\\t${fname}: ${baseSchema}`);\n\t\t}\n\t}).join(',\\n');\n\n\treturn(`export const ${typeName}Schema: ASN1.Schema = {\\n\\ttype: 'struct',\\n\\tfieldNames: [${fieldOrder.map(f => `'${f}'`).join(', ')}],\\n\\tcontains: {\\n${containsObject}\\n\\t}\\n};`);\n}\n\nfunction generateIso20022Types() {\n\tconst lines = [\n\t\tgenHeader('Generated ISO20022 Type Definitions'),\n\t\t\"import * as ASN1 from '../../lib/utils/asn1.js';\",\n\t\t\"import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\",\n\t\t'type KeetaNetAccount = InstanceType<typeof KeetaNetLib.Account>;',\n\t\t''\n\t];\n\tconst deleteLastCommaIfFound = deleteLastCommaIfFoundGenerator(lines);\n\n\t// Primitives\n\tlines.push('// ISO20022 Primitive Types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.primitives)) {\n\t\tlines.push(genTypeAlias(toPascalCase(name), resolveTypeReference(config.type), config.description, oidArrayToString(config.oid)));\n\t}\n\n\t// Enumerations\n\tlines.push('// ISO20022 Enumeration Types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.enumerations)) {\n\t\tlines.push(genEnumType(toPascalCase(name), config.values, config.description, oidArrayToString(config.oid)));\n\t}\n\n\t// Choices\n\tlines.push('// ISO20022 Choice Types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.choices)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tconst choices = Object.entries(config.choices ?? {});\n\t\tconst hasComplexTypes = choices.some(function([_ignore_choiceName, choiceConfig]) {\n\t\t\tconst choiceType = choiceConfig.type.trim();\n\t\t\treturn(choiceType !== 'UTF8String' && choiceType !== 'string');\n\t\t});\n\t\tif (hasComplexTypes) {\n\t\t\tconst unionTypes = Array.from(new Set(choices.map(function([_ignore_choiceName, choiceConfig]) {\n\t\t\t\treturn(resolveTypeReference(choiceConfig.type.trim()));\n\t\t\t})));\n\t\t\tlines.push(genTypeAlias(typeName, unionTypes.join(' | '), config.description, oidArrayToString(config.oid)));\n\t\t} else {\n\t\t\tlines.push(genTypeAlias(typeName, 'string', config.description, oidArrayToString(config.oid)));\n\t\t}\n\t}\n\n\t// ISO20022 Sequences and Sequence-of-Choice Types\n\tlines.push('// ISO20022 Sequence Types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {\n\t\tif (isSequenceOfChoice(config)) {\n\t\t\tlines.push(genSequenceOfChoiceTypes(name, config));\n\t\t} else {\n\t\t\tlines.push(genInterface(toPascalCase(name), config.fields, config.description, oidArrayToString(config.oid)));\n\t\t}\n\t}\n\tlines.push('');\n\n\t// --- Choice Type Schemas ---\n\tlines.push('// Generated ASN.1 schemas for ISO 20022 choice types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.choices)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tconst choices = Object.entries(config.choices ?? {});\n\n\t\tlines.push(`/** ASN.1 schema for ${typeName} */`);\n\n\t\tif (choices.length === 0) {\n\t\t\t// No choices defined - simple string schema\n\t\t\tlines.push(`export const ${typeName}Schema: ASN1.Schema = { type: 'string', kind: 'utf8' };`);\n\t\t} else {\n\t\t\t// Generate choice schema with context tags to make them differentiable\n\t\t\tconst choiceSchemas = choices.map(function([_ignore_choiceName, choiceConfig], index) {\n\t\t\t\tconst choiceType = choiceConfig.type.trim();\n\t\t\t\tlet containsSchema;\n\n\t\t\t\t// Check if it is a primitive type\n\t\t\t\tif (choiceType === 'UTF8String' || choiceType === 'Utf8String' || choiceType === 'string' || isEnumerationType(choiceType)) {\n\t\t\t\t\tcontainsSchema = `{ type: 'string', kind: 'utf8' }`;\n\t\t\t\t} else {\n\t\t\t\t\t// Complex type - reference its schema\n\t\t\t\t\tconst choiceTypeName = toPascalCase(choiceType);\n\t\t\t\t\tcontainsSchema = `${choiceTypeName}Schema`;\n\t\t\t\t}\n\n\t\t\t\t// Wrap in context tag to make it differentiable\n\t\t\t\treturn(`{ type: 'context', kind: 'explicit', value: ${index}, contains: ${containsSchema} }`);\n\t\t\t});\n\n\t\t\tlines.push(`export const ${typeName}Schema: ASN1.Schema = {`);\n\t\t\tlines.push(`\\tchoice: [`);\n\t\t\tlines.push(`\\t\\t${choiceSchemas.join(',\\n\\t\\t')}`);\n\t\t\tlines.push(`\\t]`);\n\t\t\tlines.push(`};`);\n\t\t}\n\t\tlines.push('');\n\t}\n\n\t// --- Regular Sequence Type Schemas (SECOND - may depend on choice schemas) ---\n\tlines.push('// Generated ASN.1 schemas for ISO 20022 regular sequence types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tif (config.fields && !isSequenceOfChoice(config)) {\n\t\t\tlines.push(`/** ASN.1 schema for ${typeName} */`);\n\t\t\tlines.push(genSequenceSchema(typeName, config.fields, config));\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// --- Sequence-of-Choice Type Schemas (THIRD - depend on regular sequence schemas) ---\n\tlines.push('// Generated ASN.1 schemas for ISO 20022 sequence-of-choice types');\n\tfor (const [name, config] of Object.entries(oidSchema.iso20022_types.sequences)) {\n\t\tif (isSequenceOfChoice(config)) {\n\t\t\tlines.push(genSequenceOfChoiceSchema(name, config));\n\t\t}\n\t}\n\n\t// --- Choice-Type Sensitive Attribute Schemas ---\n\tlines.push('// Generated ASN.1 schemas for choice-type sensitive attributes');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tif (config.choices) {\n\t\t\tconst choiceSchemas = Object.values(config.choices).map(function(choice) {\n\t\t\t\tconst choiceTypeName = toPascalCase(choice.type.trim());\n\t\t\t\treturn(`${choiceTypeName}Schema`);\n\t\t\t});\n\t\t\tlines.push(`/** ASN.1 schema for ${typeName} */`);\n\t\t\tlines.push(`export const ${typeName}Schema: ASN1.Schema = {`);\n\t\t\tlines.push(`\\tchoice: [`);\n\t\t\tlines.push(`\\t\\t${choiceSchemas.join(',\\n\\t\\t')}`);\n\t\t\tlines.push(`\\t]`);\n\t\t\tlines.push(`};`);\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// Sensitive Attribute Types\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tif (!config.fields && !config.choices) {\n\t\t\t// Primitive type\n\t\t\tlet baseType;\n\t\t\tif (config.type === 'UTF8String' || config.type === 'Utf8String') {\n\t\t\t\tbaseType = 'string';\n\t\t\t} else if (config.type === 'GeneralizedTime') {\n\t\t\t\tbaseType = 'Date';\n\t\t\t} else {\n\t\t\t\tif (config.type === undefined) {\n\t\t\t\t\tthrow(new Error(`Sensitive attribute ${name} has no defined type.`));\n\t\t\t\t}\n\t\t\t\tbaseType = toPascalCase(config.type);\n\t\t\t}\n\t\t\tlines.push(`/** ${config.description} */`);\n\t\t\tlines.push(`/** OID: ${oidArrayToString(config.oid)} */`);\n\t\t\tlines.push(`export type ${typeName} = ${baseType};`);\n\t\t\tlines.push('');\n\t\t} else if (config.fields) {\n\t\t\t// Sequence type\n\t\t\tlines.push(`/** ${config.description} */`);\n\t\t\tlines.push(`/** OID: ${oidArrayToString(config.oid)} */`);\n\t\t\tlines.push(`export interface ${typeName} {`);\n\t\t\tfor (const [fieldName, fieldConfig] of Object.entries(config.fields)) {\n\t\t\t\tconst optional = fieldConfig.optional ? '?' : '';\n\t\t\t\tconst resolvedType = resolveTypeReference(fieldConfig.type);\n\t\t\t\tlines.push(`\\t${fieldName}${optional}: ${resolvedType};`);\n\t\t\t}\n\t\t\tlines.push('}');\n\t\t\tlines.push('');\n\t\t} else if (config.choices) {\n\t\t\t// Choice type\n\t\t\tlines.push(`/** ${config.description} */`);\n\t\t\tlines.push(`/** OID: ${oidArrayToString(config.oid)} */`);\n\t\t\tconst hasComplexTypes = Object.values(config.choices).some(function(choice) {\n\t\t\t\tconst choiceType = choice.type.trim();\n\t\t\t\treturn(choiceType !== 'UTF8String' && choiceType !== 'string');\n\t\t\t});\n\t\t\tif (hasComplexTypes) {\n\t\t\t\tconst unionTypes = Object.values(config.choices).map(function(choice) {\n\t\t\t\t\treturn(toPascalCase(choice.type.trim()));\n\t\t\t\t});\n\t\t\t\tlines.push(`export type ${typeName} = ${unionTypes.join(' | ')};`);\n\t\t\t} else {\n\t\t\t\tlines.push(`export type ${typeName} = string;`);\n\t\t\t}\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// Extension Types with fields\n\tfor (const [name, config] of Object.entries(oidSchema.extensions)) {\n\t\tif (config.fields) {\n\t\t\tconst typeName = toPascalCase(name);\n\t\t\tlines.push(`/** ${config.description} */`);\n\t\t\tif (config.oid) {\n\t\t\t\tlines.push(`/** OID: ${oidArrayToString(config.oid)} */`);\n\t\t\t}\n\t\t\tlines.push(`export interface ${typeName} {`);\n\t\t\tfor (const [fieldName, fieldConfig] of Object.entries(config.fields)) {\n\t\t\t\tconst optional = fieldConfig.optional ? '?' : '';\n\t\t\t\tconst resolvedType = resolveTypeReference(fieldConfig.type);\n\t\t\t\tlines.push(`\\t${fieldName}${optional}: ${resolvedType};`);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * The \"Reference\" type is a special case where we inject\n\t\t\t * some additional attributes when decoding.\n\t\t\t */\n\t\t\tif (typeName === 'Reference') {\n\t\t\t\tlines.push('\\t/**');\n\t\t\t\tlines.push('\\t * TODOC');\n\t\t\t\tlines.push('\\t */');\n\t\t\t\tlines.push('\\t$blob: (principals?: KeetaNetAccount[]) => Promise<Blob>;');\n\t\t\t}\n\t\t\tlines.push('}');\n\t\t\tlines.push('');\n\t\t\t// Schema\n\t\t\tlines.push(genSequenceSchema(typeName, config.fields, config));\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// Token aliases for sensitive attributes\n\tlines.push('// Token aliases for sensitive attributes');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tif (config.token && config.token !== toPascalCase(name)) {\n\t\t\tconst typeName = toPascalCase(name);\n\t\t\tconst tokenName = config.token;\n\t\t\tlines.push(`/** Alias for ${typeName} */`);\n\t\t\tlines.push(`export type ${tokenName} = ${typeName};`);\n\t\t\tlines.push('');\n\t\t}\n\t}\n\n\t// Union type, value map, helper generic\n\tlines.push('/** Union type of all sensitive attribute types */');\n\tlines.push('export type SensitiveAttributeType =');\n\tlines.push(Object.keys(oidSchema.sensitive_attributes).map(function(name) {\n\t\treturn(`\\t| ${toPascalCase(name)}`);\n\t}).join('\\n') + ';');\n\tlines.push('');\n\tlines.push('/** Map of attribute name to acceptable input type for CertificateBuilder.setAttribute */');\n\tlines.push('export interface CertificateAttributeValueMap {');\n\tfor (const [name] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t'${name}': ${toPascalCase(name)};`);\n\t}\n\tlines.push('}');\n\tlines.push('');\n\tlines.push('/** Helper generic to get attribute value type by name */');\n\tlines.push('export type CertificateAttributeValue<Name extends keyof CertificateAttributeValueMap> = CertificateAttributeValueMap[Name];');\n\tlines.push('');\n\n\t// Field arrays and schemas for sequence types\n\t// Sort to ensure dependencies are defined before they're used\n\tconst sensitiveAttrEntries = Object.entries(oidSchema.sensitive_attributes);\n\tconst sortedEntries: [string, typeof sensitiveAttrEntries[0][1]][] = [];\n\tconst processed = new Set<string>();\n\n\tfunction hasDependency(config: typeof sensitiveAttrEntries[0][1], depName: string): boolean {\n\t\tif (!config.fields) {return(false);}\n\t\treturn(Object.values(config.fields).some(field => {\n\t\t\tconst fieldType = field.type.trim();\n\t\t\treturn(fieldType === toPascalCase(depName) || fieldType === depName);\n\t\t}));\n\t}\n\n\t// Process entries, dependencies first\n\twhile (sortedEntries.length < sensitiveAttrEntries.length) {\n\t\tfor (const [name, config] of sensitiveAttrEntries) {\n\t\t\tif (processed.has(name)) {continue;}\n\n\t\t\t// Check if all dependencies are processed\n\t\t\tlet allDepsProcessed = true;\n\t\t\tif (config.fields) {\n\t\t\t\tfor (const [otherName] of sensitiveAttrEntries) {\n\t\t\t\t\tif (otherName === name || processed.has(otherName)) {continue;}\n\t\t\t\t\tif (hasDependency(config, otherName)) {\n\t\t\t\t\t\tallDepsProcessed = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (allDepsProcessed) {\n\t\t\t\tsortedEntries.push([name, config]);\n\t\t\t\tprocessed.add(name);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const [name, config] of sortedEntries) {\n\t\tconst typeName = toPascalCase(name);\n\t\tif (config.fields) {\n\t\t\tconst fieldOrder = config.field_order ?? Object.keys(config.fields);\n\t\t\tlines.push(`export const ${typeName}Fields = [${fieldOrder.map(function(field) {\n\t\t\t\treturn(`'${field}'`);\n\t\t\t}).join(', ')}] as const;`);\n\t\t\tlines.push(genSequenceSchema(typeName, config.fields, config));\n\t\t}\n\t}\n\n\t// OID DB\n\tlines.push('export const CertificateAttributeOIDDB = {');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t'${name}': '${oidArrayToString(config.oid)}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('} as const;');\n\tlines.push('');\n\n\t// Sensitive attribute list\n\tlines.push('export const SENSITIVE_CERTIFICATE_ATTRIBUTES = [');\n\tfor (const name of Object.keys(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t'${name}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('] as const;');\n\tlines.push('');\n\n\tlines.push('export type SensitiveCertificateAttributeNames = typeof SENSITIVE_CERTIFICATE_ATTRIBUTES[number];');\n\tlines.push('');\n\n\t// PascalCase names\n\tlines.push('export const SensitiveCertificateAttributeNames = [');\n\tfor (const name of Object.keys(oidSchema.sensitive_attributes)) {\n\t\tlines.push(`\\t'${toPascalCase(name)}',`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('] as const;');\n\tlines.push('');\n\n\t// Field name mapping\n\tlines.push('export const CertificateAttributeFieldNames: { readonly [K in keyof typeof CertificateAttributeOIDDB]?: readonly string[] } = {');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tif (config.fields) {\n\t\t\tconst typeName = toPascalCase(name);\n\t\t\tlines.push(`\\t'${name}': ${typeName}Fields,`);\n\t\t}\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('} as const;');\n\tlines.push('');\n\n\t// Complete schema mapping (ONCE, at the end)\n\tlines.push('export const CertificateAttributeSchema: { readonly [K in keyof typeof CertificateAttributeOIDDB]: ASN1.Schema } = {');\n\tfor (const [name, config] of Object.entries(oidSchema.sensitive_attributes)) {\n\t\tconst typeName = toPascalCase(name);\n\t\tlet schemaRef;\n\t\tif (config.fields) {\n\t\t\tschemaRef = `${typeName}Schema`;\n\t\t} else if (config.choices) {\n\t\t\tschemaRef = `${typeName}Schema`;\n\t\t} else {\n\t\t\tif (config.type === undefined) {\n\t\t\t\tthrow(new Error(`Sensitive attribute ${name} has no defined type.`));\n\t\t\t}\n\t\t\tconst baseType = resolveToBaseType(config.type);\n\t\t\tconst baseTypeSnake = toSnakeCase(baseType);\n\t\t\tconst isExtensionType = oidSchema.extensions[baseTypeSnake]?.fields ?? oidSchema.extensions[baseType]?.fields;\n\t\t\tconst isSensitiveType = oidSchema.sensitive_attributes[toSnakeCase(baseType)]?.fields ?? oidSchema.sensitive_attributes[baseType]?.fields;\n\n\t\t\tif (isSensitiveType) {\n\t\t\t\tschemaRef = `${baseType}Schema`;\n\t\t\t} else if (isExtensionType) {\n\t\t\t\tschemaRef = `${baseType}Schema`;\n\t\t\t} else if (baseType === 'GeneralizedTime') {\n\t\t\t\tschemaRef = 'ASN1.ValidateASN1.IsDate';\n\t\t\t} else if (baseType === 'OCTET STRING') {\n\t\t\t\tschemaRef = 'ASN1.ValidateASN1.IsOctetString';\n\t\t\t} else if (baseType === 'OBJECT IDENTIFIER') {\n\t\t\t\tschemaRef = 'ASN1.ValidateASN1.IsOID';\n\t\t\t} else {\n\t\t\t\tschemaRef = `{ type: 'string', kind: 'utf8' }`;\n\t\t\t}\n\t\t}\n\t\tlines.push(`\\t'${name}': ${schemaRef},`);\n\t}\n\tdeleteLastCommaIfFound();\n\tlines.push('} as const;');\n\tlines.push('');\n\n\treturn(lines.join('\\n'));\n}\n\nfunction parseArgs(argv: string[]): { oidsJSONPath: string; oidsOutputPath: string; iso20022OutputPath: string } {\n\tlet oidsJSONPath: string | undefined = undefined;\n\tlet oidsOutputPath: string | undefined = undefined;\n\tlet iso20022OutputPath: string | undefined = undefined;\n\tfor (const arg of argv) {\n\t\tif (arg.startsWith('--oids-json=')) {\n\t\t\toidsJSONPath = arg.substring('--oids-json='.length);\n\t\t}\n\t\tif (arg.startsWith('--oids-output=')) {\n\t\t\toidsOutputPath = arg.substring('--oids-output='.length);\n\t\t}\n\t\tif (arg.startsWith('--iso20022-output=')) {\n\t\t\tiso20022OutputPath = arg.substring('--iso20022-output='.length);\n\t\t}\n\t}\n\n\tif (oidsJSONPath === undefined) {\n\t\tthrow(new Error('Missing required argument: --oids-json=path/to/oids.json'));\n\t}\n\tif (oidsOutputPath === undefined) {\n\t\tthrow(new Error('Missing required argument: --oids-output=path/to/oids.generated.ts'));\n\t}\n\tif (iso20022OutputPath === undefined) {\n\t\tthrow(new Error('Missing required argument: --iso20022-output=path/to/iso20022.generated.ts'));\n\t}\n\tif (!fs.existsSync(oidsJSONPath)) {\n\t\tthrow(new Error(`OID JSON file not found: ${oidsJSONPath}`));\n\t}\n\treturn({\n\t\toidsJSONPath,\n\t\toidsOutputPath,\n\t\tiso20022OutputPath\n\t});\n}\n\n// --- Main ---\nfunction main(argv: string[]): void {\n\tconst {\n\t\toidsJSONPath,\n\t\toidsOutputPath,\n\t\tiso20022OutputPath\n\t} = parseArgs(argv);\n\n\tfs.mkdirSync(path.dirname(oidsOutputPath), { recursive: true });\n\tfs.mkdirSync(path.dirname(iso20022OutputPath), { recursive: true });\n\n\toidSchema = typia.assert<oidSchemaContents>(JSON.parse(fs.readFileSync(oidsJSONPath, 'utf8')));\n\n\tfs.writeFileSync(oidsOutputPath, generateOidConstants(), 'utf8');\n\tfs.writeFileSync(iso20022OutputPath, generateIso20022Types(), 'utf8');\n}\n\nmain(process.argv.slice(2));\n"]}
|
package/lib/http-server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../../src/lib/http-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI7C,eAAO,MAAM,mBAAmB,EAAE,CA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CAAC,IAAI,EAAE,CAAC,CAAC;IACrB,CAAC;CACD","sourcesContent":["import * as http from 'http';\nimport {\n\tKeetaAnchorUserError\n} from './error.js';\nimport type { JSONSerializable } from './utils/json.js';\nimport type { Logger } from './log/index.js';\nimport { Log } from './log/index.js';\nimport { createAssert } from 'typia';\n\nexport const AssertHTTPErrorData: (input: unknown) => { error: string; statusCode?: number; contentType?: string; } = createAssert<{ error: string; statusCode?: number; contentType?: string; }>();\n\n/**\n * The maximum size of a request (128KiB)\n */\nconst MAX_REQUEST_SIZE = 1024 * 128;\n\nexport type Routes = {\n\t[route: string]: (urlParams: Map<string, string>, postData: JSONSerializable | undefined, requestHeaders: http.IncomingHttpHeaders) => Promise<{ output: string | Buffer; statusCode?: number; contentType?: string; headers?: { [headerName: string]: string; }; }>;\n};\n\nexport interface KeetaAnchorHTTPServerConfig {\n\t/**\n\t * The port for the HTTP server to listen on (default is an ephemeral port).\n\t */\n\tport?: number;\n\n\t/**\n\t * Enable debug logging\n\t */\n\tlogger?: Logger;\n};\n\nexport abstract class KeetaNetAnchorHTTPServer<ConfigType extends KeetaAnchorHTTPServerConfig = KeetaAnchorHTTPServerConfig> implements Required<KeetaAnchorHTTPServerConfig> {\n\treadonly port: NonNullable<KeetaAnchorHTTPServerConfig['port']>;\n\treadonly logger: NonNullable<KeetaAnchorHTTPServerConfig['logger']>;\n\t#serverPromise?: Promise<void>;\n\t#server?: http.Server;\n\treadonly #config: ConfigType;\n\n\tconstructor(config: ConfigType) {\n\t\tthis.#config = { ...config };\n\t\tthis.port = config.port ?? 0;\n\t\tthis.logger = config.logger ?? Log.Legacy('ANCHOR');\n\t}\n\n\tprotected abstract initRoutes(config: ConfigType): Promise<Routes>;\n\n\tprivate static routeMatch(requestURL: URL, routeURL: URL): ({ match: true; params: Map<string, string> } | { match: false }) {\n\t\tconst requestURLPaths = requestURL.pathname.split('/');\n\t\tconst routeURLPaths = routeURL.pathname.split('/');\n\n\t\tif (requestURLPaths.length !== routeURLPaths.length) {\n\t\t\treturn({ match: false });\n\t\t}\n\n\t\tconst params = new Map<string, string>();\n\t\tfor (let partIndex = 0; partIndex < requestURLPaths.length; partIndex++) {\n\t\t\tconst requestPath = requestURLPaths[partIndex];\n\t\t\tconst routePath = routeURLPaths[partIndex];\n\n\t\t\tif (routePath === undefined || requestPath === undefined) {\n\t\t\t\treturn({ match: false });\n\t\t\t}\n\n\t\t\tif (routePath.startsWith(':')) {\n\t\t\t\tparams.set(routePath.slice(1), requestPath);\n\t\t\t} else if (requestPath !== routePath) {\n\t\t\t\treturn({ match: false });\n\t\t\t}\n\t\t}\n\n\t\treturn({ match: true, params: params });\n\t}\n\n\tprivate static routeFind(method: string, requestURL: URL, routes: Routes): { route: Routes[keyof Routes]; params: Map<string, string> } | null {\n\t\tfor (const routeKey in routes) {\n\t\t\tconst route = routes[routeKey];\n\t\t\tif (route === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst [routeMethod, ...routePathParts] = routeKey.split(' ');\n\t\t\tconst routePath = `/${routePathParts.join(' ')}`.replace(/^\\/+/, '/');\n\n\t\t\tif (method !== routeMethod) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst routeURL = new URL(routePath, 'http://localhost');\n\t\t\tconst matchResult = this.routeMatch(requestURL, routeURL);\n\t\t\tif (matchResult.match) {\n\t\t\t\treturn({\n\t\t\t\t\troute: route,\n\t\t\t\t\tparams: matchResult.params\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn(null);\n\t}\n\n\tprivate static addCORS(routes: Routes): Routes {\n\t\tconst newRoutes: Routes = {};\n\n\t\tconst validMethods = new Set(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD']);\n\n\t\tconst methodsByPath: { [key: string]: Set<string>; } = {};\n\t\tfor (const routeKey in routes) {\n\t\t\tconst methodAndPath = routeKey.split(' ');\n\t\t\tconst method = methodAndPath[0];\n\t\t\tconst path = methodAndPath.slice(1).join(' ');\n\n\t\t\tif (method === undefined || path === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!validMethods.has(method)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!(path in methodsByPath)) {\n\t\t\t\tmethodsByPath[path] = new Set<string>();\n\t\t\t}\n\n\t\t\tif (methodsByPath[path] === undefined) {\n\t\t\t\tthrow(new Error(`internal error: methodsByPath missing path for ${path}`));\n\t\t\t}\n\n\t\t\tmethodsByPath[path].add(method);\n\t\t}\n\n\t\tconst seenPaths = new Set<string>();\n\t\tfor (const routeKey in routes) {\n\t\t\tconst methodAndPath = routeKey.split(' ');\n\t\t\tconst method = methodAndPath[0];\n\t\t\tconst path = methodAndPath.slice(1).join(' ');\n\n\t\t\tconst routeHandler = routes[routeKey];\n\t\t\tif (routeHandler === undefined) {\n\t\t\t\tthrow(new Error(`internal error: routeHandler missing for routeKey ${routeKey}`));\n\t\t\t}\n\n\t\t\tif (method !== 'ERROR') {\n\t\t\t\tif (method === undefined || path === undefined) {\n\t\t\t\t\tnewRoutes[routeKey] = routeHandler;\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!validMethods.has(method)) {\n\t\t\t\t\tnewRoutes[routeKey] = routeHandler;\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst validMethodsForPath = methodsByPath[path];\n\n\t\t\tlet validMethodsForPathParts: string[] = [];\n\t\t\tif (validMethodsForPath !== undefined) {\n\t\t\t\tvalidMethodsForPath.add('OPTIONS');\n\t\t\t\tvalidMethodsForPathParts = Array.from(validMethodsForPath);\n\t\t\t} else {\n\t\t\t\tvalidMethodsForPathParts = [...Array.from(validMethods), 'OPTIONS'];\n\t\t\t}\n\n\t\t\tnewRoutes[routeKey] = async function(...args: Parameters<typeof routes[keyof typeof routes]>) {\n\t\t\t\tconst retval = await routeHandler(...args);\n\n\t\t\t\t/* Add CORS headers to the response for the original route handler */\n\t\t\t\tif (retval.contentType === 'application/json' || retval.contentType === undefined) {\n\t\t\t\t\tif (!('headers' in retval) || retval.headers === undefined) {\n\t\t\t\t\t\tretval.headers = {};\n\t\t\t\t\t}\n\t\t\t\t\tretval.headers['Access-Control-Allow-Origin'] = '*';\n\t\t\t\t}\n\n\t\t\t\treturn(retval);\n\t\t\t};\n\n\t\t\tif (!seenPaths.has(path) && path !== '' && path !== undefined) {\n\t\t\t\tconst corsRouteKey = `OPTIONS ${path}`;\n\n\t\t\t\tnewRoutes[corsRouteKey] = async function() {\n\t\t\t\t\treturn({\n\t\t\t\t\t\toutput: '',\n\t\t\t\t\t\tstatusCode: 204,\n\t\t\t\t\t\tcontentType: 'text/plain',\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'Access-Control-Allow-Origin': '*',\n\t\t\t\t\t\t\t'Access-Control-Allow-Methods': validMethodsForPathParts.join(', '),\n\t\t\t\t\t\t\t'Access-Control-Allow-Headers': 'Content-Type',\n\t\t\t\t\t\t\t'Access-Control-Max-Age': '86400'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t\tseenPaths.add(path);\n\t\t\t}\n\t\t}\n\n\t\treturn(newRoutes);\n\t}\n\n\tprivate async main(onSetPort?: (port: number) => void): Promise<void> {\n\t\tthis.logger?.debug('KeetaAnchorHTTP.Server', 'Starting HTTP server...');\n\n\t\tconst port = this.port;\n\n\t\tconst routes = KeetaNetAnchorHTTPServer.addCORS({\n\t\t\tERROR: async function(_ignore_params, postData) {\n\t\t\t\tconst errorInfo = AssertHTTPErrorData(postData);\n\n\t\t\t\tconst retval = {\n\t\t\t\t\toutput: errorInfo.error,\n\t\t\t\t\tstatusCode: errorInfo.statusCode ?? 400,\n\t\t\t\t\tcontentType: errorInfo.contentType ?? 'text/plain'\n\t\t\t\t};\n\n\t\t\t\treturn(retval);\n\t\t\t},\n\t\t\t...(await this.initRoutes(this.#config))\n\t\t});\n\n\t\tconst server = new http.Server(async (request, response) => {\n\t\t\tconst url = new URL(request.url ?? '/', `http://${request.headers.host ?? 'localhost'}`);\n\t\t\tconst method = request.method ?? 'GET';\n\n\t\t\t/*\n\t\t\t * Finalize the response by syncing the logger and ending\n\t\t\t * the response.\n\t\t\t */\n\t\t\tconst responseFinalize = async () => {\n\t\t\t\tif ('sync' in this.logger && typeof this.logger.sync === 'function') {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n\t\t\t\t\t\tawait this.logger.sync();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t/* ignore errors */\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tresponse.end();\n\t\t\t};\n\n\t\t\t/*\n\t\t\t * Lookup the route based on the request\n\t\t\t */\n\t\t\tconst requestedRouteAndParams = KeetaNetAnchorHTTPServer.routeFind(method, url, routes);\n\t\t\tif (requestedRouteAndParams === null) {\n\t\t\t\tresponse.statusCode = 404;\n\t\t\t\tresponse.setHeader('Content-Type', 'text/plain');\n\t\t\t\tresponse.write('Not Found');\n\t\t\t\tawait responseFinalize();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Extract the route handler and the parameters from\n\t\t\t * the request\n\t\t\t */\n\t\t\tconst { route, params } = requestedRouteAndParams;\n\n\t\t\t/**\n\t\t\t * Attempt to run the route, catch any errors\n\t\t\t */\n\t\t\tlet result: Awaited<ReturnType<typeof route>> | undefined = undefined;\n\t\t\tlet generatedResult = false;\n\t\t\ttry {\n\t\t\t\t/**\n\t\t\t\t * If POST'ing, read and parse the POST data\n\t\t\t\t */\n\t\t\t\tlet postData: JSONSerializable | undefined;\n\t\t\t\tif (request.method === 'POST') {\n\t\t\t\t\tconst data = await request.map(function(chunk) {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\t\t\t\treturn(Buffer.from(chunk));\n\t\t\t\t\t}).reduce(function(prev, curr) {\n\t\t\t\t\t\tif (prev.length > MAX_REQUEST_SIZE) {\n\t\t\t\t\t\t\tthrow(new Error('Request too large'));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!Buffer.isBuffer(curr)) {\n\t\t\t\t\t\t\tthrow(new Error(`internal error: Current item is not a buffer -- ${typeof curr}`));\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn(Buffer.concat([prev, curr]));\n\t\t\t\t\t}, Buffer.from(''));\n\n\t\t\t\t\tif (request.headers['content-type'] === 'application/json') {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\t\tpostData = JSON.parse(data.toString('utf-8'));\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tthrow(new Error('Invalid JSON data'));\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow(new KeetaAnchorUserError('Unsupported content type'));\n\t\t\t\t\t}\n\t\t\t\t\t/**\n\t\t\t\t\t * Call the route handler\n\t\t\t\t\t */\n\t\t\t\t\tresult = await route(params, postData, request.headers);\n\t\t\t\t} else {\n\t\t\t\t\tresult = await route(params, undefined, request.headers);\n\t\t\t\t}\n\n\t\t\t\tgeneratedResult = true;\n\t\t\t} catch (err) {\n\t\t\t\t/**\n\t\t\t\t * If an error occurs, log it and return an error page\n\t\t\t\t */\n\t\t\t\tthis.logger?.error('KeetaAnchorHTTP.Server', err);\n\n\t\t\t\t/**\n\t\t\t\t * If it is a user error, provide a user-friendly error page\n\t\t\t\t */\n\t\t\t\tconst errorHandlerRoute = routes['ERROR'];\n\t\t\t\tif (errorHandlerRoute !== undefined) {\n\t\t\t\t\tif (KeetaAnchorUserError.isInstance(err)) {\n\t\t\t\t\t\tresult = await errorHandlerRoute(new Map(), err.asErrorResponse('application/json'), request.headers);\n\t\t\t\t\t\tgeneratedResult = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = await errorHandlerRoute(new Map(), {\n\t\t\t\t\t\t\terror: JSON.stringify({ ok: false, error: 'Internal Server Error' }),\n\t\t\t\t\t\t\tstatusCode: 500,\n\t\t\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t\t\t}, request.headers);\n\t\t\t\t\t\tgeneratedResult = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!generatedResult) {\n\t\t\t\t\t/**\n\t\t\t\t\t * Otherwise provide a generic error page\n\t\t\t\t\t */\n\t\t\t\t\tresponse.statusCode = 500;\n\t\t\t\t\tresponse.setHeader('Content-Type', 'text/plain');\n\t\t\t\t\tresponse.write('Internal Server Error');\n\t\t\t\t\tawait responseFinalize();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (result === undefined) {\n\t\t\t\tthrow(new Error('internal error: No result'));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Write the response to the client\n\t\t\t */\n\t\t\tresponse.statusCode = result.statusCode ?? 200;\n\n\t\t\tfor (const headerKey in result.headers ?? {}) {\n\t\t\t\tconst headerValue = result.headers?.[headerKey];\n\t\t\t\tif (headerValue !== undefined) {\n\t\t\t\t\tresponse.setHeader(headerKey, headerValue);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresponse.setHeader('Content-Type', result.contentType ?? 'application/json');\n\t\t\tresponse.write(result.output);\n\t\t\tawait responseFinalize();\n\t\t});\n\t\tthis.#server = server;\n\n\t\t/**\n\t\t * Create a promise to wait for the server to close\n\t\t */\n\t\tconst waiter = new Promise<void>((resolve) => {\n\t\t\tserver.on('close', () => {\n\t\t\t\tthis.logger?.debug('KeetaAnchorHTTP.Server', 'Server closed');\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\n\t\t/**\n\t\t * Start listening on the port\n\t\t */\n\t\tserver.listen(port, () => {\n\t\t\tconst address = server.address();\n\t\t\tif (address !== null && typeof address === 'object') {\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis.port = address.port;\n\t\t\t\tonSetPort?.(this.port);\n\t\t\t}\n\t\t\tthis.logger?.debug('KeetaAnchorHTTP.Server', 'Listening on port:', this.port);\n\t\t});\n\n\t\t/**\n\t\t * Wait for the server to close\n\t\t */\n\t\tawait waiter;\n\t}\n\n\t/**\n\t * Start the HTTP server and wait for it to be fully initialized.\n\t */\n\tasync start(): Promise<void> {\n\t\t/*\n\t\t * Start the server and wait for it to be initialized before returning\n\t\t */\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tthis.#serverPromise = this.main(function() {\n\t\t\t\tresolve();\n\t\t\t}).catch(function(error: unknown) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n\t\t\t\treject(error);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Wait for the server to terminate. This will only resolve once the\n\t * server has been stopped.\n\t */\n\tasync wait(): Promise<void> {\n\t\tawait this.#serverPromise;\n\t}\n\n\t/**\n\t * Stop the HTTP server and wait for it to be fully terminated.\n\t */\n\tasync stop(): Promise<void> {\n\t\tthis.#server?.close();\n\t\t// @ts-ignore\n\t\tthis.#server = undefined;\n\t\tawait this.wait();\n\t}\n\n\t/**\n\t * Get the URL of the server, which can be used to make requests to\n\t * it. This will use \"localhost\" as the hostname and the port that\n\t * the server is listening on.\n\t */\n\tget url(): string {\n\t\tif (this.port === 0 || this.#server === undefined) {\n\t\t\tthrow(new Error('Server not started'));\n\t\t}\n\n\t\treturn(`http://localhost:${this.port}`);\n\t}\n\n\t[Symbol.asyncDispose](): Promise<void> {\n\t\treturn(this.stop());\n\t}\n}\n"]}
|