@keetanetwork/anchor 0.0.79 → 0.0.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/lib/anchor-external.d.ts +94 -1
  2. package/lib/anchor-external.d.ts.map +1 -1
  3. package/lib/anchor-external.generated.js +52 -3
  4. package/lib/anchor-external.generated.js.map +1 -1
  5. package/lib/anchor-external.js +126 -3
  6. package/lib/anchor-external.js.map +1 -1
  7. package/lib/anchor-metadata-server.d.ts +15 -2
  8. package/lib/anchor-metadata-server.d.ts.map +1 -1
  9. package/lib/anchor-metadata-server.js +54 -0
  10. package/lib/anchor-metadata-server.js.map +1 -1
  11. package/lib/anchor-status.d.ts +149 -0
  12. package/lib/anchor-status.d.ts.map +1 -0
  13. package/lib/anchor-status.js +93 -0
  14. package/lib/anchor-status.js.map +1 -0
  15. package/lib/chaining.d.ts +2 -1
  16. package/lib/chaining.d.ts.map +1 -1
  17. package/lib/chaining.js +129 -34
  18. package/lib/chaining.js.map +1 -1
  19. package/lib/history.d.ts +405 -0
  20. package/lib/history.d.ts.map +1 -0
  21. package/lib/history.js +723 -0
  22. package/lib/history.js.map +1 -0
  23. package/lib/http-server/common.d.ts +2 -1
  24. package/lib/http-server/common.d.ts.map +1 -1
  25. package/lib/http-server/common.js.map +1 -1
  26. package/lib/http-server/index.d.ts +1 -0
  27. package/lib/http-server/index.d.ts.map +1 -1
  28. package/lib/http-server/index.js +1 -0
  29. package/lib/http-server/index.js.map +1 -1
  30. package/lib/index.d.ts +6 -1
  31. package/lib/index.d.ts.map +1 -1
  32. package/lib/index.js +3 -1
  33. package/lib/index.js.map +1 -1
  34. package/lib/metadata.types.d.ts +3 -0
  35. package/lib/metadata.types.d.ts.map +1 -1
  36. package/lib/metadata.types.js.map +1 -1
  37. package/lib/resolver.d.ts +29 -8
  38. package/lib/resolver.d.ts.map +1 -1
  39. package/lib/resolver.generated.js +546 -456
  40. package/lib/resolver.generated.js.map +1 -1
  41. package/lib/resolver.js +67 -8
  42. package/lib/resolver.js.map +1 -1
  43. package/lib/sensitive-attribute.js +1 -1
  44. package/lib/sensitive-attribute.js.map +1 -1
  45. package/lib/utils/brand.d.ts +5 -0
  46. package/lib/utils/brand.d.ts.map +1 -1
  47. package/lib/utils/brand.js +4 -1
  48. package/lib/utils/brand.js.map +1 -1
  49. package/npm-shrinkwrap.json +12 -19
  50. package/package.json +2 -2
  51. package/services/asset-movement/client.d.ts +18 -2
  52. package/services/asset-movement/client.d.ts.map +1 -1
  53. package/services/asset-movement/client.js +111 -17
  54. package/services/asset-movement/client.js.map +1 -1
  55. package/services/asset-movement/common.d.ts +58 -1
  56. package/services/asset-movement/common.d.ts.map +1 -1
  57. package/services/asset-movement/common.generated.d.ts +2 -1
  58. package/services/asset-movement/common.generated.d.ts.map +1 -1
  59. package/services/asset-movement/common.generated.js +133 -39
  60. package/services/asset-movement/common.generated.js.map +1 -1
  61. package/services/asset-movement/common.js +44 -4
  62. package/services/asset-movement/common.js.map +1 -1
  63. package/services/asset-movement/common.server.generated.d.ts +3 -0
  64. package/services/asset-movement/common.server.generated.d.ts.map +1 -1
  65. package/services/asset-movement/common.server.generated.js +269 -0
  66. package/services/asset-movement/common.server.generated.js.map +1 -1
  67. package/services/asset-movement/lib/location.d.ts.map +1 -1
  68. package/services/asset-movement/lib/location.js +1 -0
  69. package/services/asset-movement/lib/location.js.map +1 -1
  70. package/services/asset-movement/server.d.ts +6 -2
  71. package/services/asset-movement/server.d.ts.map +1 -1
  72. package/services/asset-movement/server.js +57 -3
  73. package/services/asset-movement/server.js.map +1 -1
  74. package/services/asset-movement/status-source.d.ts +32 -0
  75. package/services/asset-movement/status-source.d.ts.map +1 -0
  76. package/services/asset-movement/status-source.js +77 -0
  77. package/services/asset-movement/status-source.js.map +1 -0
  78. package/services/fx/server.d.ts +2 -2
  79. package/services/fx/server.d.ts.map +1 -1
  80. package/services/fx/server.js +2 -1
  81. package/services/fx/server.js.map +1 -1
  82. package/services/kyc/iso20022.generated.js +5 -5
  83. package/services/kyc/iso20022.generated.js.map +1 -1
  84. package/services/kyc/server.d.ts +1 -1
  85. package/services/kyc/server.d.ts.map +1 -1
  86. package/services/kyc/server.js +1 -1
  87. package/services/kyc/server.js.map +1 -1
  88. package/services/kyc/utils/generate-kyc-schema.js +2 -2
  89. package/services/kyc/utils/generate-kyc-schema.js.map +1 -1
  90. package/services/notification/client.js +50 -6
  91. package/services/notification/client.js.map +1 -1
  92. package/services/notification/server.d.ts.map +1 -1
  93. package/services/notification/server.js +4 -1
  94. package/services/notification/server.js.map +1 -1
  95. package/services/storage/client.js +50 -6
  96. package/services/storage/client.js.map +1 -1
  97. package/services/storage/clients/contacts.d.ts +5 -0
  98. package/services/storage/clients/contacts.d.ts.map +1 -1
  99. package/services/storage/clients/contacts.js +20 -9
  100. package/services/storage/clients/contacts.js.map +1 -1
  101. package/services/storage/server.d.ts +1 -1
  102. package/services/storage/server.d.ts.map +1 -1
  103. package/services/storage/server.js +2 -2
  104. package/services/storage/server.js.map +1 -1
  105. package/services/username/client.js +50 -6
  106. package/services/username/client.js.map +1 -1
  107. package/services/username/server.d.ts.map +1 -1
  108. package/services/username/server.js +4 -1
  109. package/services/username/server.js.map +1 -1
@@ -97,7 +97,7 @@ export function encodeForSensitive(name, value) {
97
97
  return (arrayBufferToBuffer(asn1.toBER(false)));
98
98
  }
99
99
  if (value instanceof Date) {
100
- const asn1 = ASN1.JStoASN1(value);
100
+ const asn1 = ASN1.JStoASN1({ type: 'date', kind: 'general', date: value });
101
101
  return (arrayBufferToBuffer(asn1.toBER(false)));
102
102
  }
103
103
  if (typeof value === 'object' && value !== null) {
@@ -1 +1 @@
1
- {"version":3,"file":"sensitive-attribute.js","sourceRoot":"","sources":["../../src/lib/sensitive-attribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,IAAI,MAAM,mCAAmC,CAAC;AAC1D,OAAO,KAAK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KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAE7E,MAAM,kBAAkB,GAA6B;YACpD,aAAa;YACb,EAAE;YACF,oBAAoB;YACpB;gBACC,eAAe;gBACf,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAAE;gBAC7D,iBAAiB;gBACjB,KAAK;gBACL,iEAAiE;gBACjE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;aACzB;YACD,kBAAkB;YAClB;gBACC,oBAAoB;gBACpB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;gBAC1B,uBAAuB;gBACvB,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,EAAE;gBACvE,yDAAyD;gBACzD,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;aACjC;YACD,sDAAsD;YACtD,cAAc;SACd,CAAC;QAEF,MAAM,sBAAsB,GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QACjE,MAAM,YAAY,GAAG,sBAAsB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEzD,MAAM,OAAO,GAAG,UAAS,IAA0B;YAClD,yEAAyE;YACzE,OAAO,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAkC,CAAC;QACxE,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAA+B,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACpG,OAAM,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC","sourcesContent":["import * as KeetaNetClient from '@keetanetwork/keetanet-client';\nimport * as oids from '../services/kyc/oids.generated.js';\nimport * as ASN1 from './utils/asn1.js';\nimport { arrayBufferLikeToBuffer, arrayBufferToBuffer, Buffer, bufferToArrayBuffer } from './utils/buffer.js';\nimport crypto from './utils/crypto.js';\nimport type { SensitiveAttributeType, CertificateAttributeValue , CertificateAttributeOIDDB } from '../services/kyc/iso20022.generated.js';\nimport { CertificateAttributeSchema } from '../services/kyc/iso20022.generated.js';\nimport { getOID, lookupByOID } from './utils/oid.js';\n\n/**\n * Short alias for printing a debug representation of an object\n */\nconst DPO = KeetaNetClient.lib.Utils.Helper.debugPrintableObject.bind(KeetaNetClient.lib.Utils.Helper);\n\n/* ENUM */\ntype AccountKeyAlgorithm = InstanceType<typeof KeetaNetClient.lib.Account>['keyType'];\n\n/**\n * An alias for the KeetaNetAccount type\n */\ntype KeetaNetAccount = ReturnType<typeof KeetaNetClient.lib.Account.fromSeed<AccountKeyAlgorithm>>;\n\n/**\n * Type for certificate attribute names (derived from generated OID database)\n */\nexport type CertificateAttributeNames = keyof typeof CertificateAttributeOIDDB;\n\n/**\n * Sensitive Attribute Schema\n *\n * ASN.1 Schema:\n * SensitiveAttributes DEFINITIONS ::= BEGIN\n * SensitiveAttribute ::= SEQUENCE {\n * version INTEGER { v1(0) },\n * cipher SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * ivOrNonce OCTET STRING,\n * key OCTET STRING\n * },\n * hashedValue SEQUENCE {\n * encryptedSalt OCTET STRING,\n * algorithm OBJECT IDENTIFIER,\n * value OCTET STRING\n * },\n * encryptedValue OCTET STRING\n * }\n * END\n *\n * https://keeta.notion.site/Keeta-KYC-Certificate-Extensions-13e5da848e588042bdcef81fc40458b7\n *\n * @internal\n */\nconst SensitiveAttributeSchemaInternal: [\n\tversion: 0n,\n\tcipher: [\n\t\talgorithm: typeof ASN1.ValidateASN1.IsOID,\n\t\tiv: typeof ASN1.ValidateASN1.IsOctetString,\n\t\tkey: typeof ASN1.ValidateASN1.IsOctetString\n\t],\n\thashedValue: [\n\t\tencryptedSalt: typeof ASN1.ValidateASN1.IsOctetString,\n\t\talgorithm: typeof ASN1.ValidateASN1.IsOID,\n\t\tvalue: typeof ASN1.ValidateASN1.IsOctetString\n\t],\n\tencryptedValue: typeof ASN1.ValidateASN1.IsOctetString\n] = [\n\t0n,\n\t[\n\t\tASN1.ValidateASN1.IsOID,\n\t\tASN1.ValidateASN1.IsOctetString,\n\t\tASN1.ValidateASN1.IsOctetString\n\t],\n\t[\n\t\tASN1.ValidateASN1.IsOctetString,\n\t\tASN1.ValidateASN1.IsOID,\n\t\tASN1.ValidateASN1.IsOctetString\n\t],\n\tASN1.ValidateASN1.IsOctetString\n];\n\n/**\n * The Sensitive Attribute Schema Internal\n *\n * @internal\n */\ntype SensitiveAttributeSchema = ASN1.SchemaMap<typeof SensitiveAttributeSchemaInternal>;\n\n/*\n * Database of permitted algorithms and their OIDs\n */\nconst sensitiveAttributeOIDDB = {\n\t'aes-256-gcm': oids.AES_256_GCM,\n\t'aes-256-cbc': oids.AES_256_CBC,\n\t'sha2-256': oids.SHA2_256,\n\t'sha3-256': oids.SHA3_256,\n\t'sha256': oids.SHA2_256,\n\t'aes256-gcm': oids.AES_256_GCM,\n\t'aes256-cbc': oids.AES_256_CBC\n};\n\n/**\n * Encode an attribute value using its ASN.1 schema\n */\nexport function encodeAttribute(name: CertificateAttributeNames, value: unknown): ArrayBuffer {\n\tconst schema = CertificateAttributeSchema[name];\n\n\tlet encodedJS;\n\ttry {\n\t\tencodedJS = new ASN1.ValidateASN1(schema).fromJavaScriptObject(value);\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tthrow(new Error(`Attribute ${name}: ${message} (value: ${JSON.stringify(DPO(value))})`));\n\t}\n\n\tif (encodedJS === undefined) {\n\t\tthrow(new Error(`Unsupported attribute value for encoding: ${JSON.stringify(DPO(value))}`));\n\t}\n\n\tconst asn1Object = ASN1.JStoASN1(encodedJS);\n\tif (!asn1Object) {\n\t\tthrow(new Error(`Failed to encode value for attribute ${name}`));\n\t}\n\n\treturn(asn1Object.toBER(false));\n}\n\n/**\n * Prepare a value for inclusion in a SensitiveAttribute: pre-encode complex and date types\n */\nexport function encodeForSensitive(\n\tname: CertificateAttributeNames | undefined,\n\tvalue: SensitiveAttributeType | Buffer | ArrayBuffer\n): Buffer {\n\tif (Buffer.isBuffer(value)) { return(value); }\n\tif (value instanceof ArrayBuffer) { return(arrayBufferToBuffer(value)); }\n\tif (typeof value === 'string') {\n\t\tconst asn1 = ASN1.JStoASN1({ type: 'string', kind: 'utf8', value });\n\t\treturn(arrayBufferToBuffer(asn1.toBER(false)));\n\t}\n\n\tif (value instanceof Date) {\n\t\tconst asn1 = ASN1.JStoASN1(value);\n\t\treturn(arrayBufferToBuffer(asn1.toBER(false)));\n\t}\n\n\tif (typeof value === 'object' && value !== null) {\n\t\tif (!name) { throw(new Error('attributeName required for complex types')); }\n\t\tconst encoded = encodeAttribute(name, value);\n\t\treturn(arrayBufferToBuffer(encoded));\n\t}\n\n\treturn(Buffer.from(String(value), 'utf-8'));\n}\n\n/**\n * Check if value is an ASN.1-like wrapper object\n */\nfunction isASN1Wrapper(obj: object): obj is { type: string; value: unknown } {\n\treturn('type' in obj && 'value' in obj && typeof obj.type === 'string');\n}\n\n/**\n * Normalize the result (unwrap ASN.1-like objects)\n */\nfunction normalizeDecodedValue(input: unknown): unknown {\n\tif (input === undefined || input === null || typeof input !== 'object') {\n\t\treturn(input);\n\t}\n\tif (input instanceof Date || Buffer.isBuffer(input) || input instanceof ArrayBuffer) {\n\t\treturn(input);\n\t}\n\tif (Array.isArray(input)) {\n\t\treturn(input.map(item => normalizeDecodedValue(item)));\n\t}\n\t// Unwrap ASN.1-like objects\n\tif (isASN1Wrapper(input)) {\n\t\tif (input.type === 'string' && typeof input.value === 'string') {\n\t\t\treturn(input.value);\n\t\t}\n\t\tif (input.type === 'date' && input.value instanceof Date) {\n\t\t\treturn(input.value);\n\t\t}\n\t}\n\t// Recursively normalize object properties\n\tconst result: { [key: string]: unknown } = {};\n\tfor (const [key, value] of Object.entries(input)) {\n\t\tresult[key] = normalizeDecodedValue(value);\n\t}\n\treturn(result);\n}\n\n/**\n * Decode ASN.1 data using a schema\n *\n * Note: The ASN1 library uses dynamic typing internally, so we consolidate\n * the unsafe operations here rather than scattering them throughout the code.\n */\nfunction decodeWithSchema(buffer: ArrayBuffer, schema: unknown): unknown {\n\t/* eslint-disable\n @typescript-eslint/no-explicit-any,\n @typescript-eslint/consistent-type-assertions,\n\t\t@typescript-eslint/no-unsafe-member-access,\n @typescript-eslint/no-unsafe-call,\n\t\t@typescript-eslint/no-unsafe-assignment\n */\n\tlet decodedASN1: ASN1.ASN1AnyJS | undefined;\n\ttry {\n\t\tdecodedASN1 = new (ASN1.BufferStorageASN1 as any)(buffer, schema).getASN1() as ASN1.ASN1AnyJS;\n\t} catch {\n\t\tdecodedASN1 = ASN1.ASN1toJS(buffer);\n\t}\n\tif (decodedASN1 === undefined) {\n\t\tthrow(new Error('Failed to decode ASN1 data'));\n\t}\n\n\tconst validator = new (ASN1.ValidateASN1 as any)(schema);\n\treturn(validator.toJavaScriptObject(decodedASN1));\n\t/* eslint-enable */\n}\n\n/**\n * GCM cipher helpers - Node's crypto types don't properly type getAuthTag/setAuthTag\n * when using createCipheriv/createDecipheriv, so we use typed wrappers.\n */\n/* eslint-disable @typescript-eslint/consistent-type-assertions -- Reflect.get returns unknown */\nfunction getGCMAuthTag(cipher: ReturnType<typeof crypto.createCipheriv>): Buffer {\n\tconst getAuthTag = Reflect.get(cipher, 'getAuthTag') as (() => Buffer) | undefined;\n\tif (typeof getAuthTag !== 'function') {\n\t\tthrow(new TypeError('getAuthTag is not available on cipher'));\n\t}\n\treturn(getAuthTag.call(cipher));\n}\n\nfunction setGCMAuthTag(decipher: ReturnType<typeof crypto.createDecipheriv>, tag: Buffer): void {\n\tconst setAuthTag = Reflect.get(decipher, 'setAuthTag') as ((tag: Buffer) => void) | undefined;\n\tif (typeof setAuthTag !== 'function') {\n\t\tthrow(new TypeError('setAuthTag is not available on decipher'));\n\t}\n\tsetAuthTag.call(decipher, tag);\n}\n/* eslint-enable @typescript-eslint/consistent-type-assertions */\n\n/**\n * Decode a value from its ASN.1 representation back to the original type\n *\n * @internal\n */\nfunction decodeForSensitive(\n\tname: CertificateAttributeNames,\n\tdata: Buffer | ArrayBuffer\n): unknown {\n\tconst buffer = Buffer.isBuffer(data) ? bufferToArrayBuffer(data) : data;\n\tconst schema: unknown = CertificateAttributeSchema[name];\n\tconst plainObject = decodeWithSchema(buffer, schema);\n\treturn(normalizeDecodedValue(plainObject));\n}\n\nexport type SensitiveAttributeJSON = {\n\tversion: string;\n\tpublicKey: string;\n\tcipher: {\n\t\talgorithm: string;\n\t\tiv: string;\n\t\tkey: string;\n\t};\n\thashedValue: {\n\t\tencryptedSalt: string;\n\t\talgorithm: string;\n\t\tvalue: string;\n\t};\n\tencryptedValue: string;\n};\n\nexport class SensitiveAttribute<T = ArrayBuffer> {\n\tprivate static readonly SensitiveAttributeObjectTypeID = 'c0cc9591-cebb-4441-babe-23739279e3f2';\n\tprivate readonly SensitiveAttributeObjectTypeID!: string;\n\n\treadonly #account: KeetaNetAccount;\n\treadonly #encryptedDER: ArrayBuffer;\n\treadonly #info: ReturnType<SensitiveAttribute<T>['decode']>;\n\treadonly #decoder?: (data: Buffer | ArrayBuffer) => T | Promise<T>;\n\n\tconstructor(\n\t\taccount: KeetaNetAccount,\n\t\tdata: Buffer | ArrayBuffer,\n\t\tdecoder?: (data: Buffer | ArrayBuffer) => T | Promise<T>\n\t) {\n\t\tObject.defineProperty(this, 'SensitiveAttributeObjectTypeID', {\n\t\t\tvalue: SensitiveAttribute.SensitiveAttributeObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\n\t\tthis.#account = account;\n\t\tthis.#encryptedDER = Buffer.isBuffer(data) ? bufferToArrayBuffer(data) : data;\n\t\tthis.#info = this.decode(data);\n\t\tif (decoder) {\n\t\t\tthis.#decoder = decoder;\n\t\t}\n\t}\n\n\t/**\n\t * Check if a value is a SensitiveAttribute instance\n\t */\n\tstatic isInstance(input: unknown): input is SensitiveAttribute<unknown> {\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\treturn(false);\n\t\t}\n\n\t\treturn(Reflect.get(input, 'SensitiveAttributeObjectTypeID') === SensitiveAttribute.SensitiveAttributeObjectTypeID);\n\t}\n\n\t/**\n\t * Get the public key this attribute was encrypted for\n\t */\n\tget publicKey(): string {\n\t\treturn(this.#account.publicKeyString.get());\n\t}\n\n\t/**\n\t * Get the raw encrypted DER for certificate embedding\n\t */\n\ttoDER(): ArrayBuffer {\n\t\treturn(this.#encryptedDER);\n\t}\n\n\tprivate decode(data: Buffer | ArrayBuffer) {\n\t\tif (Buffer.isBuffer(data)) {\n\t\t\tdata = bufferToArrayBuffer(data);\n\t\t}\n\n\t\tlet decodedAttribute;\n\t\ttry {\n\t\t\tconst dataObject = new ASN1.BufferStorageASN1(data, SensitiveAttributeSchemaInternal);\n\t\t\tdecodedAttribute = dataObject.getASN1();\n\t\t} catch {\n\t\t\tconst js = ASN1.ASN1toJS(data);\n\t\t\tthrow(new Error(`SensitiveAttribute.decode: unexpected DER shape ${JSON.stringify(DPO(js))}`));\n\t\t}\n\n\t\tconst decodedVersion = decodedAttribute[0] + 1n;\n\t\tif (decodedVersion !== 1n) {\n\t\t\tthrow(new Error(`Unsupported Sensitive Attribute version (${decodedVersion})`));\n\t\t}\n\n\t\treturn({\n\t\t\tversion: decodedVersion,\n\t\t\tpublicKey: this.#account.publicKeyString.get(),\n\t\t\tcipher: {\n\t\t\t\talgorithm: lookupByOID(decodedAttribute[1][0].oid, sensitiveAttributeOIDDB),\n\t\t\t\tiv: decodedAttribute[1][1],\n\t\t\t\tkey: decodedAttribute[1][2]\n\t\t\t},\n\t\t\thashedValue: {\n\t\t\t\tencryptedSalt: decodedAttribute[2][0],\n\t\t\t\talgorithm: lookupByOID(decodedAttribute[2][1].oid, sensitiveAttributeOIDDB),\n\t\t\t\tvalue: decodedAttribute[2][2]\n\t\t\t},\n\t\t\tencryptedValue: decodedAttribute[3]\n\t\t});\n\t}\n\n\tasync #decryptValue(value: Buffer) {\n\t\tconst decryptedKey = await this.#account.decrypt(bufferToArrayBuffer(this.#info.cipher.key));\n\t\tconst algorithm = this.#info.cipher.algorithm;\n\t\tconst iv = this.#info.cipher.iv;\n\n\t\tconst decipher = crypto.createDecipheriv(algorithm, Buffer.from(decryptedKey), iv);\n\n\t\t// For AES-GCM, extract and set the 16-byte authentication tag\n\t\tif (algorithm === 'aes-256-gcm') {\n\t\t\tconst authTag = value.subarray(-16);\n\t\t\tconst ciphertext = value.subarray(0, -16);\n\n\t\t\tsetGCMAuthTag(decipher, authTag);\n\n\t\t\tconst decrypted = decipher.update(ciphertext);\n\t\t\tdecipher.final(); // Verify auth tag\n\t\t\treturn(decrypted);\n\t\t}\n\n\t\t// For other algorithms (like CBC), just decrypt normally\n\t\tconst decrypted = decipher.update(value);\n\t\tdecipher.final();\n\t\treturn(decrypted);\n\t}\n\n\t/**\n\t * Get the value of the sensitive attribute\n\t *\n\t * This will decrypt the value using the account's private key\n\t * and return the value as an ArrayBuffer\n\t *\n\t * Since sensitive attributes are binary blobs, this returns an\n\t * ArrayBuffer\n\t */\n\tasync get(): Promise<ArrayBuffer> {\n\t\tconst decryptedValue = await this.#decryptValue(arrayBufferLikeToBuffer(this.#info.encryptedValue));\n\t\treturn(bufferToArrayBuffer(decryptedValue));\n\t}\n\n\tasync getValue(): Promise<T> {\n\t\tconst value = await this.get();\n\t\tif (!this.#decoder) {\n\t\t\t/**\n\t\t\t * TypeScript complains that T may not be the correct\n\t\t\t * type here, but gives us no tools to enforce that it\n\t\t\t * is -- it should always be ArrayBuffer if no decoder\n\t\t\t * is provided, but someone could always specify a\n\t\t\t * type parameter in that case and we cannot check\n\t\t\t * that at runtime since T is only a compile-time type.\n\t\t\t */\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\treturn(value as unknown as T);\n\t\t}\n\t\treturn(await this.#decoder(value));\n\t}\n\n\t/**\n\t * Generate a proof that a sensitive attribute is a given value,\n\t * which can be validated by a third party using the certificate\n\t * and the `validateProof` method\n\t */\n\tasync getProof(): Promise<{ value: string; hash: { salt: string }}> {\n\t\tconst value = await this.get();\n\t\tconst salt = await this.#decryptValue(arrayBufferLikeToBuffer(this.#info.hashedValue.encryptedSalt));\n\n\t\treturn({\n\t\t\tvalue: Buffer.from(value).toString('base64'),\n\t\t\thash: {\n\t\t\t\tsalt: salt.toString('base64')\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Validate the proof that a sensitive attribute is a given value\n\t */\n\tasync validateProof(proof: Awaited<ReturnType<this['getProof']>>): Promise<boolean> {\n\t\tconst plaintextValue = Buffer.from(proof.value, 'base64');\n\t\tconst proofSaltBuffer = Buffer.from(proof.hash.salt, 'base64');\n\n\t\tconst publicKeyBuffer = Buffer.from(this.#account.publicKey.get());\n\t\tconst encryptedValue = this.#info.encryptedValue;\n\n\t\tconst hashInput = Buffer.concat([proofSaltBuffer, publicKeyBuffer, encryptedValue, plaintextValue]);\n\t\tconst hashedAndSaltedValue = KeetaNetClient.lib.Utils.Hash.Hash(hashInput);\n\t\tconst hashedAndSaltedValueBuffer = Buffer.from(hashedAndSaltedValue);\n\n\t\treturn(this.#info.hashedValue.value.equals(hashedAndSaltedValueBuffer));\n\t}\n\n\ttoJSON(): SensitiveAttributeJSON {\n\t\tconst info = KeetaNetClient.lib.Utils.Conversion.toJSONSerializable(this.#info);\n\t\treturn(info);\n\t}\n\n\t/**\n\t * Encrypt a value and create a new SensitiveAttribute\n\t */\n\tstatic async create<K extends CertificateAttributeNames>(\n\t\taccount: KeetaNetAccount,\n\t\tname: K,\n\t\tvalue: CertificateAttributeValue<K> | Buffer | ArrayBuffer\n\t): Promise<SensitiveAttribute<CertificateAttributeValue<K>>> {\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tconst encodedValue = encodeForSensitive(name, value as SensitiveAttributeType | Buffer | ArrayBuffer);\n\n\t\tconst salt = crypto.randomBytes(32);\n\n\t\tconst hashingAlgorithm = KeetaNetClient.lib.Utils.Hash.HashFunctionName;\n\t\tconst publicKey = Buffer.from(account.publicKey.get());\n\n\t\tconst cipher = 'aes-256-gcm';\n\t\tconst key = crypto.randomBytes(32);\n\t\tconst nonce = crypto.randomBytes(12);\n\t\tconst encryptedKey = await account.encrypt(bufferToArrayBuffer(key));\n\n\t\tfunction encrypt(input: Buffer) {\n\t\t\tconst cipherObject = crypto.createCipheriv(cipher, key, nonce);\n\t\t\tlet retval = Buffer.concat([cipherObject.update(input), cipherObject.final()]);\n\n\t\t\t// For AES-GCM, append the 16-byte authentication tag\n\t\t\tif (cipher === 'aes-256-gcm') {\n\t\t\t\tretval = Buffer.concat([retval, getGCMAuthTag(cipherObject)]);\n\t\t\t}\n\n\t\t\treturn(retval);\n\t\t}\n\n\t\tconst encryptedValue = encrypt(encodedValue);\n\t\tconst encryptedSalt = encrypt(arrayBufferLikeToBuffer(salt));\n\n\t\tconst saltedValue = Buffer.concat([salt, publicKey, encryptedValue, encodedValue]);\n\t\tconst hashedAndSaltedValue = KeetaNetClient.lib.Utils.Hash.Hash(saltedValue);\n\n\t\tconst attributeStructure: SensitiveAttributeSchema = [\n\t\t\t/* Version */\n\t\t\t0n,\n\t\t\t/* Cipher Details */\n\t\t\t[\n\t\t\t\t/* Algorithm */\n\t\t\t\t{ type: 'oid', oid: getOID(cipher, sensitiveAttributeOIDDB) },\n\t\t\t\t/* IV or Nonce */\n\t\t\t\tnonce,\n\t\t\t\t/* Symmetric key, encrypted with the public key of the account */\n\t\t\t\tBuffer.from(encryptedKey)\n\t\t\t],\n\t\t\t/* Hashed Value */\n\t\t\t[\n\t\t\t\t/* Encrypted Salt */\n\t\t\t\tBuffer.from(encryptedSalt),\n\t\t\t\t/* Hashing Algorithm */\n\t\t\t\t{ type: 'oid', oid: getOID(hashingAlgorithm, sensitiveAttributeOIDDB) },\n\t\t\t\t/* Hash of <Encrypted Salt> || <Public Key> || <Value> */\n\t\t\t\tBuffer.from(hashedAndSaltedValue)\n\t\t\t],\n\t\t\t/* Encrypted Value, encrypted with the Cipher above */\n\t\t\tencryptedValue\n\t\t];\n\n\t\tconst encodedAttributeObject = ASN1.JStoASN1(attributeStructure);\n\t\tconst encryptedDER = encodedAttributeObject.toBER(false);\n\n\t\tconst decoder = function(data: Buffer | ArrayBuffer): CertificateAttributeValue<K> {\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\treturn(decodeForSensitive(name, data) as CertificateAttributeValue<K>);\n\t\t};\n\n\t\tconst result = new SensitiveAttribute<CertificateAttributeValue<K>>(account, encryptedDER, decoder);\n\t\treturn(result);\n\t}\n}\n"]}
1
+ {"version":3,"file":"sensitive-attribute.js","sourceRoot":"","sources":["../../src/lib/sensitive-attribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,IAAI,MAAM,mCAAmC,CAAC;AAC1D,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9G,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErD;;GAEG;AACH,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAevG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,gCAAgC,GAalC;IACH,EAAE;IACF;QACC,IAAI,CAAC,YAAY,CAAC,KAAK;QACvB,IAAI,CAAC,YAAY,CAAC,aAAa;QAC/B,IAAI,CAAC,YAAY,CAAC,aAAa;KAC/B;IACD;QACC,IAAI,CAAC,YAAY,CAAC,aAAa;QAC/B,IAAI,CAAC,YAAY,CAAC,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GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QACjE,MAAM,YAAY,GAAG,sBAAsB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEzD,MAAM,OAAO,GAAG,UAAS,IAA0B;YAClD,yEAAyE;YACzE,OAAO,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAkC,CAAC;QACxE,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAA+B,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACpG,OAAM,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC","sourcesContent":["import * as KeetaNetClient from '@keetanetwork/keetanet-client';\nimport * as oids from '../services/kyc/oids.generated.js';\nimport * as ASN1 from './utils/asn1.js';\nimport { arrayBufferLikeToBuffer, arrayBufferToBuffer, Buffer, bufferToArrayBuffer } from './utils/buffer.js';\nimport crypto from './utils/crypto.js';\nimport type { SensitiveAttributeType, CertificateAttributeValue , CertificateAttributeOIDDB } from '../services/kyc/iso20022.generated.js';\nimport { CertificateAttributeSchema } from '../services/kyc/iso20022.generated.js';\nimport { getOID, lookupByOID } from './utils/oid.js';\n\n/**\n * Short alias for printing a debug representation of an object\n */\nconst DPO = KeetaNetClient.lib.Utils.Helper.debugPrintableObject.bind(KeetaNetClient.lib.Utils.Helper);\n\n/* ENUM */\ntype AccountKeyAlgorithm = InstanceType<typeof KeetaNetClient.lib.Account>['keyType'];\n\n/**\n * An alias for the KeetaNetAccount type\n */\ntype KeetaNetAccount = ReturnType<typeof KeetaNetClient.lib.Account.fromSeed<AccountKeyAlgorithm>>;\n\n/**\n * Type for certificate attribute names (derived from generated OID database)\n */\nexport type CertificateAttributeNames = keyof typeof CertificateAttributeOIDDB;\n\n/**\n * Sensitive Attribute Schema\n *\n * ASN.1 Schema:\n * SensitiveAttributes DEFINITIONS ::= BEGIN\n * SensitiveAttribute ::= SEQUENCE {\n * version INTEGER { v1(0) },\n * cipher SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * ivOrNonce OCTET STRING,\n * key OCTET STRING\n * },\n * hashedValue SEQUENCE {\n * encryptedSalt OCTET STRING,\n * algorithm OBJECT IDENTIFIER,\n * value OCTET STRING\n * },\n * encryptedValue OCTET STRING\n * }\n * END\n *\n * https://keeta.notion.site/Keeta-KYC-Certificate-Extensions-13e5da848e588042bdcef81fc40458b7\n *\n * @internal\n */\nconst SensitiveAttributeSchemaInternal: [\n\tversion: 0n,\n\tcipher: [\n\t\talgorithm: typeof ASN1.ValidateASN1.IsOID,\n\t\tiv: typeof ASN1.ValidateASN1.IsOctetString,\n\t\tkey: typeof ASN1.ValidateASN1.IsOctetString\n\t],\n\thashedValue: [\n\t\tencryptedSalt: typeof ASN1.ValidateASN1.IsOctetString,\n\t\talgorithm: typeof ASN1.ValidateASN1.IsOID,\n\t\tvalue: typeof ASN1.ValidateASN1.IsOctetString\n\t],\n\tencryptedValue: typeof ASN1.ValidateASN1.IsOctetString\n] = [\n\t0n,\n\t[\n\t\tASN1.ValidateASN1.IsOID,\n\t\tASN1.ValidateASN1.IsOctetString,\n\t\tASN1.ValidateASN1.IsOctetString\n\t],\n\t[\n\t\tASN1.ValidateASN1.IsOctetString,\n\t\tASN1.ValidateASN1.IsOID,\n\t\tASN1.ValidateASN1.IsOctetString\n\t],\n\tASN1.ValidateASN1.IsOctetString\n];\n\n/**\n * The Sensitive Attribute Schema Internal\n *\n * @internal\n */\ntype SensitiveAttributeSchema = ASN1.SchemaMap<typeof SensitiveAttributeSchemaInternal>;\n\n/*\n * Database of permitted algorithms and their OIDs\n */\nconst sensitiveAttributeOIDDB = {\n\t'aes-256-gcm': oids.AES_256_GCM,\n\t'aes-256-cbc': oids.AES_256_CBC,\n\t'sha2-256': oids.SHA2_256,\n\t'sha3-256': oids.SHA3_256,\n\t'sha256': oids.SHA2_256,\n\t'aes256-gcm': oids.AES_256_GCM,\n\t'aes256-cbc': oids.AES_256_CBC\n};\n\n/**\n * Encode an attribute value using its ASN.1 schema\n */\nexport function encodeAttribute(name: CertificateAttributeNames, value: unknown): ArrayBuffer {\n\tconst schema = CertificateAttributeSchema[name];\n\n\tlet encodedJS;\n\ttry {\n\t\tencodedJS = new ASN1.ValidateASN1(schema).fromJavaScriptObject(value);\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tthrow(new Error(`Attribute ${name}: ${message} (value: ${JSON.stringify(DPO(value))})`));\n\t}\n\n\tif (encodedJS === undefined) {\n\t\tthrow(new Error(`Unsupported attribute value for encoding: ${JSON.stringify(DPO(value))}`));\n\t}\n\n\tconst asn1Object = ASN1.JStoASN1(encodedJS);\n\tif (!asn1Object) {\n\t\tthrow(new Error(`Failed to encode value for attribute ${name}`));\n\t}\n\n\treturn(asn1Object.toBER(false));\n}\n\n/**\n * Prepare a value for inclusion in a SensitiveAttribute: pre-encode complex and date types\n */\nexport function encodeForSensitive(\n\tname: CertificateAttributeNames | undefined,\n\tvalue: SensitiveAttributeType | Buffer | ArrayBuffer\n): Buffer {\n\tif (Buffer.isBuffer(value)) { return(value); }\n\tif (value instanceof ArrayBuffer) { return(arrayBufferToBuffer(value)); }\n\tif (typeof value === 'string') {\n\t\tconst asn1 = ASN1.JStoASN1({ type: 'string', kind: 'utf8', value });\n\t\treturn(arrayBufferToBuffer(asn1.toBER(false)));\n\t}\n\n\tif (value instanceof Date) {\n\t\tconst asn1 = ASN1.JStoASN1({ type: 'date', kind: 'general', date: value });\n\t\treturn(arrayBufferToBuffer(asn1.toBER(false)));\n\t}\n\n\tif (typeof value === 'object' && value !== null) {\n\t\tif (!name) { throw(new Error('attributeName required for complex types')); }\n\t\tconst encoded = encodeAttribute(name, value);\n\t\treturn(arrayBufferToBuffer(encoded));\n\t}\n\n\treturn(Buffer.from(String(value), 'utf-8'));\n}\n\n/**\n * Check if value is an ASN.1-like wrapper object\n */\nfunction isASN1Wrapper(obj: object): obj is { type: string; value: unknown } {\n\treturn('type' in obj && 'value' in obj && typeof obj.type === 'string');\n}\n\n/**\n * Normalize the result (unwrap ASN.1-like objects)\n */\nfunction normalizeDecodedValue(input: unknown): unknown {\n\tif (input === undefined || input === null || typeof input !== 'object') {\n\t\treturn(input);\n\t}\n\tif (input instanceof Date || Buffer.isBuffer(input) || input instanceof ArrayBuffer) {\n\t\treturn(input);\n\t}\n\tif (Array.isArray(input)) {\n\t\treturn(input.map(item => normalizeDecodedValue(item)));\n\t}\n\t// Unwrap ASN.1-like objects\n\tif (isASN1Wrapper(input)) {\n\t\tif (input.type === 'string' && typeof input.value === 'string') {\n\t\t\treturn(input.value);\n\t\t}\n\t\tif (input.type === 'date' && input.value instanceof Date) {\n\t\t\treturn(input.value);\n\t\t}\n\t}\n\t// Recursively normalize object properties\n\tconst result: { [key: string]: unknown } = {};\n\tfor (const [key, value] of Object.entries(input)) {\n\t\tresult[key] = normalizeDecodedValue(value);\n\t}\n\treturn(result);\n}\n\n/**\n * Decode ASN.1 data using a schema\n *\n * Note: The ASN1 library uses dynamic typing internally, so we consolidate\n * the unsafe operations here rather than scattering them throughout the code.\n */\nfunction decodeWithSchema(buffer: ArrayBuffer, schema: unknown): unknown {\n\t/* eslint-disable\n @typescript-eslint/no-explicit-any,\n @typescript-eslint/consistent-type-assertions,\n\t\t@typescript-eslint/no-unsafe-member-access,\n @typescript-eslint/no-unsafe-call,\n\t\t@typescript-eslint/no-unsafe-assignment\n */\n\tlet decodedASN1: ASN1.ASN1AnyJS | undefined;\n\ttry {\n\t\tdecodedASN1 = new (ASN1.BufferStorageASN1 as any)(buffer, schema).getASN1() as ASN1.ASN1AnyJS;\n\t} catch {\n\t\tdecodedASN1 = ASN1.ASN1toJS(buffer);\n\t}\n\tif (decodedASN1 === undefined) {\n\t\tthrow(new Error('Failed to decode ASN1 data'));\n\t}\n\n\tconst validator = new (ASN1.ValidateASN1 as any)(schema);\n\treturn(validator.toJavaScriptObject(decodedASN1));\n\t/* eslint-enable */\n}\n\n/**\n * GCM cipher helpers - Node's crypto types don't properly type getAuthTag/setAuthTag\n * when using createCipheriv/createDecipheriv, so we use typed wrappers.\n */\n/* eslint-disable @typescript-eslint/consistent-type-assertions -- Reflect.get returns unknown */\nfunction getGCMAuthTag(cipher: ReturnType<typeof crypto.createCipheriv>): Buffer {\n\tconst getAuthTag = Reflect.get(cipher, 'getAuthTag') as (() => Buffer) | undefined;\n\tif (typeof getAuthTag !== 'function') {\n\t\tthrow(new TypeError('getAuthTag is not available on cipher'));\n\t}\n\treturn(getAuthTag.call(cipher));\n}\n\nfunction setGCMAuthTag(decipher: ReturnType<typeof crypto.createDecipheriv>, tag: Buffer): void {\n\tconst setAuthTag = Reflect.get(decipher, 'setAuthTag') as ((tag: Buffer) => void) | undefined;\n\tif (typeof setAuthTag !== 'function') {\n\t\tthrow(new TypeError('setAuthTag is not available on decipher'));\n\t}\n\tsetAuthTag.call(decipher, tag);\n}\n/* eslint-enable @typescript-eslint/consistent-type-assertions */\n\n/**\n * Decode a value from its ASN.1 representation back to the original type\n *\n * @internal\n */\nfunction decodeForSensitive(\n\tname: CertificateAttributeNames,\n\tdata: Buffer | ArrayBuffer\n): unknown {\n\tconst buffer = Buffer.isBuffer(data) ? bufferToArrayBuffer(data) : data;\n\tconst schema: unknown = CertificateAttributeSchema[name];\n\tconst plainObject = decodeWithSchema(buffer, schema);\n\treturn(normalizeDecodedValue(plainObject));\n}\n\nexport type SensitiveAttributeJSON = {\n\tversion: string;\n\tpublicKey: string;\n\tcipher: {\n\t\talgorithm: string;\n\t\tiv: string;\n\t\tkey: string;\n\t};\n\thashedValue: {\n\t\tencryptedSalt: string;\n\t\talgorithm: string;\n\t\tvalue: string;\n\t};\n\tencryptedValue: string;\n};\n\nexport class SensitiveAttribute<T = ArrayBuffer> {\n\tprivate static readonly SensitiveAttributeObjectTypeID = 'c0cc9591-cebb-4441-babe-23739279e3f2';\n\tprivate readonly SensitiveAttributeObjectTypeID!: string;\n\n\treadonly #account: KeetaNetAccount;\n\treadonly #encryptedDER: ArrayBuffer;\n\treadonly #info: ReturnType<SensitiveAttribute<T>['decode']>;\n\treadonly #decoder?: (data: Buffer | ArrayBuffer) => T | Promise<T>;\n\n\tconstructor(\n\t\taccount: KeetaNetAccount,\n\t\tdata: Buffer | ArrayBuffer,\n\t\tdecoder?: (data: Buffer | ArrayBuffer) => T | Promise<T>\n\t) {\n\t\tObject.defineProperty(this, 'SensitiveAttributeObjectTypeID', {\n\t\t\tvalue: SensitiveAttribute.SensitiveAttributeObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\n\t\tthis.#account = account;\n\t\tthis.#encryptedDER = Buffer.isBuffer(data) ? bufferToArrayBuffer(data) : data;\n\t\tthis.#info = this.decode(data);\n\t\tif (decoder) {\n\t\t\tthis.#decoder = decoder;\n\t\t}\n\t}\n\n\t/**\n\t * Check if a value is a SensitiveAttribute instance\n\t */\n\tstatic isInstance(input: unknown): input is SensitiveAttribute<unknown> {\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\treturn(false);\n\t\t}\n\n\t\treturn(Reflect.get(input, 'SensitiveAttributeObjectTypeID') === SensitiveAttribute.SensitiveAttributeObjectTypeID);\n\t}\n\n\t/**\n\t * Get the public key this attribute was encrypted for\n\t */\n\tget publicKey(): string {\n\t\treturn(this.#account.publicKeyString.get());\n\t}\n\n\t/**\n\t * Get the raw encrypted DER for certificate embedding\n\t */\n\ttoDER(): ArrayBuffer {\n\t\treturn(this.#encryptedDER);\n\t}\n\n\tprivate decode(data: Buffer | ArrayBuffer) {\n\t\tif (Buffer.isBuffer(data)) {\n\t\t\tdata = bufferToArrayBuffer(data);\n\t\t}\n\n\t\tlet decodedAttribute;\n\t\ttry {\n\t\t\tconst dataObject = new ASN1.BufferStorageASN1(data, SensitiveAttributeSchemaInternal);\n\t\t\tdecodedAttribute = dataObject.getASN1();\n\t\t} catch {\n\t\t\tconst js = ASN1.ASN1toJS(data);\n\t\t\tthrow(new Error(`SensitiveAttribute.decode: unexpected DER shape ${JSON.stringify(DPO(js))}`));\n\t\t}\n\n\t\tconst decodedVersion = decodedAttribute[0] + 1n;\n\t\tif (decodedVersion !== 1n) {\n\t\t\tthrow(new Error(`Unsupported Sensitive Attribute version (${decodedVersion})`));\n\t\t}\n\n\t\treturn({\n\t\t\tversion: decodedVersion,\n\t\t\tpublicKey: this.#account.publicKeyString.get(),\n\t\t\tcipher: {\n\t\t\t\talgorithm: lookupByOID(decodedAttribute[1][0].oid, sensitiveAttributeOIDDB),\n\t\t\t\tiv: decodedAttribute[1][1],\n\t\t\t\tkey: decodedAttribute[1][2]\n\t\t\t},\n\t\t\thashedValue: {\n\t\t\t\tencryptedSalt: decodedAttribute[2][0],\n\t\t\t\talgorithm: lookupByOID(decodedAttribute[2][1].oid, sensitiveAttributeOIDDB),\n\t\t\t\tvalue: decodedAttribute[2][2]\n\t\t\t},\n\t\t\tencryptedValue: decodedAttribute[3]\n\t\t});\n\t}\n\n\tasync #decryptValue(value: Buffer) {\n\t\tconst decryptedKey = await this.#account.decrypt(bufferToArrayBuffer(this.#info.cipher.key));\n\t\tconst algorithm = this.#info.cipher.algorithm;\n\t\tconst iv = this.#info.cipher.iv;\n\n\t\tconst decipher = crypto.createDecipheriv(algorithm, Buffer.from(decryptedKey), iv);\n\n\t\t// For AES-GCM, extract and set the 16-byte authentication tag\n\t\tif (algorithm === 'aes-256-gcm') {\n\t\t\tconst authTag = value.subarray(-16);\n\t\t\tconst ciphertext = value.subarray(0, -16);\n\n\t\t\tsetGCMAuthTag(decipher, authTag);\n\n\t\t\tconst decrypted = decipher.update(ciphertext);\n\t\t\tdecipher.final(); // Verify auth tag\n\t\t\treturn(decrypted);\n\t\t}\n\n\t\t// For other algorithms (like CBC), just decrypt normally\n\t\tconst decrypted = decipher.update(value);\n\t\tdecipher.final();\n\t\treturn(decrypted);\n\t}\n\n\t/**\n\t * Get the value of the sensitive attribute\n\t *\n\t * This will decrypt the value using the account's private key\n\t * and return the value as an ArrayBuffer\n\t *\n\t * Since sensitive attributes are binary blobs, this returns an\n\t * ArrayBuffer\n\t */\n\tasync get(): Promise<ArrayBuffer> {\n\t\tconst decryptedValue = await this.#decryptValue(arrayBufferLikeToBuffer(this.#info.encryptedValue));\n\t\treturn(bufferToArrayBuffer(decryptedValue));\n\t}\n\n\tasync getValue(): Promise<T> {\n\t\tconst value = await this.get();\n\t\tif (!this.#decoder) {\n\t\t\t/**\n\t\t\t * TypeScript complains that T may not be the correct\n\t\t\t * type here, but gives us no tools to enforce that it\n\t\t\t * is -- it should always be ArrayBuffer if no decoder\n\t\t\t * is provided, but someone could always specify a\n\t\t\t * type parameter in that case and we cannot check\n\t\t\t * that at runtime since T is only a compile-time type.\n\t\t\t */\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\treturn(value as unknown as T);\n\t\t}\n\t\treturn(await this.#decoder(value));\n\t}\n\n\t/**\n\t * Generate a proof that a sensitive attribute is a given value,\n\t * which can be validated by a third party using the certificate\n\t * and the `validateProof` method\n\t */\n\tasync getProof(): Promise<{ value: string; hash: { salt: string }}> {\n\t\tconst value = await this.get();\n\t\tconst salt = await this.#decryptValue(arrayBufferLikeToBuffer(this.#info.hashedValue.encryptedSalt));\n\n\t\treturn({\n\t\t\tvalue: Buffer.from(value).toString('base64'),\n\t\t\thash: {\n\t\t\t\tsalt: salt.toString('base64')\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Validate the proof that a sensitive attribute is a given value\n\t */\n\tasync validateProof(proof: Awaited<ReturnType<this['getProof']>>): Promise<boolean> {\n\t\tconst plaintextValue = Buffer.from(proof.value, 'base64');\n\t\tconst proofSaltBuffer = Buffer.from(proof.hash.salt, 'base64');\n\n\t\tconst publicKeyBuffer = Buffer.from(this.#account.publicKey.get());\n\t\tconst encryptedValue = this.#info.encryptedValue;\n\n\t\tconst hashInput = Buffer.concat([proofSaltBuffer, publicKeyBuffer, encryptedValue, plaintextValue]);\n\t\tconst hashedAndSaltedValue = KeetaNetClient.lib.Utils.Hash.Hash(hashInput);\n\t\tconst hashedAndSaltedValueBuffer = Buffer.from(hashedAndSaltedValue);\n\n\t\treturn(this.#info.hashedValue.value.equals(hashedAndSaltedValueBuffer));\n\t}\n\n\ttoJSON(): SensitiveAttributeJSON {\n\t\tconst info = KeetaNetClient.lib.Utils.Conversion.toJSONSerializable(this.#info);\n\t\treturn(info);\n\t}\n\n\t/**\n\t * Encrypt a value and create a new SensitiveAttribute\n\t */\n\tstatic async create<K extends CertificateAttributeNames>(\n\t\taccount: KeetaNetAccount,\n\t\tname: K,\n\t\tvalue: CertificateAttributeValue<K> | Buffer | ArrayBuffer\n\t): Promise<SensitiveAttribute<CertificateAttributeValue<K>>> {\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tconst encodedValue = encodeForSensitive(name, value as SensitiveAttributeType | Buffer | ArrayBuffer);\n\n\t\tconst salt = crypto.randomBytes(32);\n\n\t\tconst hashingAlgorithm = KeetaNetClient.lib.Utils.Hash.HashFunctionName;\n\t\tconst publicKey = Buffer.from(account.publicKey.get());\n\n\t\tconst cipher = 'aes-256-gcm';\n\t\tconst key = crypto.randomBytes(32);\n\t\tconst nonce = crypto.randomBytes(12);\n\t\tconst encryptedKey = await account.encrypt(bufferToArrayBuffer(key));\n\n\t\tfunction encrypt(input: Buffer) {\n\t\t\tconst cipherObject = crypto.createCipheriv(cipher, key, nonce);\n\t\t\tlet retval = Buffer.concat([cipherObject.update(input), cipherObject.final()]);\n\n\t\t\t// For AES-GCM, append the 16-byte authentication tag\n\t\t\tif (cipher === 'aes-256-gcm') {\n\t\t\t\tretval = Buffer.concat([retval, getGCMAuthTag(cipherObject)]);\n\t\t\t}\n\n\t\t\treturn(retval);\n\t\t}\n\n\t\tconst encryptedValue = encrypt(encodedValue);\n\t\tconst encryptedSalt = encrypt(arrayBufferLikeToBuffer(salt));\n\n\t\tconst saltedValue = Buffer.concat([salt, publicKey, encryptedValue, encodedValue]);\n\t\tconst hashedAndSaltedValue = KeetaNetClient.lib.Utils.Hash.Hash(saltedValue);\n\n\t\tconst attributeStructure: SensitiveAttributeSchema = [\n\t\t\t/* Version */\n\t\t\t0n,\n\t\t\t/* Cipher Details */\n\t\t\t[\n\t\t\t\t/* Algorithm */\n\t\t\t\t{ type: 'oid', oid: getOID(cipher, sensitiveAttributeOIDDB) },\n\t\t\t\t/* IV or Nonce */\n\t\t\t\tnonce,\n\t\t\t\t/* Symmetric key, encrypted with the public key of the account */\n\t\t\t\tBuffer.from(encryptedKey)\n\t\t\t],\n\t\t\t/* Hashed Value */\n\t\t\t[\n\t\t\t\t/* Encrypted Salt */\n\t\t\t\tBuffer.from(encryptedSalt),\n\t\t\t\t/* Hashing Algorithm */\n\t\t\t\t{ type: 'oid', oid: getOID(hashingAlgorithm, sensitiveAttributeOIDDB) },\n\t\t\t\t/* Hash of <Encrypted Salt> || <Public Key> || <Value> */\n\t\t\t\tBuffer.from(hashedAndSaltedValue)\n\t\t\t],\n\t\t\t/* Encrypted Value, encrypted with the Cipher above */\n\t\t\tencryptedValue\n\t\t];\n\n\t\tconst encodedAttributeObject = ASN1.JStoASN1(attributeStructure);\n\t\tconst encryptedDER = encodedAttributeObject.toBER(false);\n\n\t\tconst decoder = function(data: Buffer | ArrayBuffer): CertificateAttributeValue<K> {\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\treturn(decodeForSensitive(name, data) as CertificateAttributeValue<K>);\n\t\t};\n\n\t\tconst result = new SensitiveAttribute<CertificateAttributeValue<K>>(account, encryptedDER, decoder);\n\t\treturn(result);\n\t}\n}\n"]}
@@ -9,4 +9,9 @@ export type Brand<T, BrandName extends string> = T & {
9
9
  * it, since it is unique and cannot be easily created by accident.
10
10
  */
11
11
  export type BrandedString<BrandName extends string> = Brand<symbol, BrandName>;
12
+ /**
13
+ * Brand a string value with a named brand.
14
+ */
15
+ export declare function brandString<BrandName extends string>(input: string | BrandedString<BrandName>): BrandedString<BrandName>;
16
+ export declare function brandString<BrandName extends string>(input: string | BrandedString<BrandName> | undefined): BrandedString<BrandName> | undefined;
12
17
  //# sourceMappingURL=brand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/brand.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,SAAS,SAAS,MAAM,IAAI,CAAC,GAAG;IACpD,QAAQ,EAAE,CAAC,IAAI,SAAS,IAAI,KAAK,CAAC,QAAQ,GAAG,KAAK;CAClD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,SAAS,SAAS,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/brand.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,SAAS,SAAS,MAAM,IAAI,CAAC,GAAG;IACpD,QAAQ,EAAE,CAAC,IAAI,SAAS,IAAI,KAAK,CAAC,QAAQ,GAAG,KAAK;CAClD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,SAAS,SAAS,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE/E;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;AAC1H,wBAAgB,WAAW,CAAC,SAAS,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC"}
@@ -1,2 +1,5 @@
1
- export {};
1
+ export function brandString(input) {
2
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
3
+ return input;
4
+ }
2
5
  //# sourceMappingURL=brand.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"brand.js","sourceRoot":"","sources":["../../../src/lib/utils/brand.ts"],"names":[],"mappings":"","sourcesContent":["export type Brand<T, BrandName extends string> = T & {\n\treadonly [B in BrandName as `__${B}_brand`]: never;\n};\n\n/**\n * A branded string type. This is a string that is branded with a specific\n * type, making it impossible to accidentally mix it with other strings.\n *\n * We pretend that `symbol` is a primitive type for the purposes of branding\n * it, since it is unique and cannot be easily created by accident.\n */\nexport type BrandedString<BrandName extends string> = Brand<symbol, BrandName>;\n"]}
1
+ {"version":3,"file":"brand.js","sourceRoot":"","sources":["../../../src/lib/utils/brand.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,WAAW,CAA2B,KAAoD;IACzG,yEAAyE;IACzE,OAAO,KAA8C,CAAC;AACvD,CAAC","sourcesContent":["export type Brand<T, BrandName extends string> = T & {\n\treadonly [B in BrandName as `__${B}_brand`]: never;\n};\n\n/**\n * A branded string type. This is a string that is branded with a specific\n * type, making it impossible to accidentally mix it with other strings.\n *\n * We pretend that `symbol` is a primitive type for the purposes of branding\n * it, since it is unique and cannot be easily created by accident.\n */\nexport type BrandedString<BrandName extends string> = Brand<symbol, BrandName>;\n\n/**\n * Brand a string value with a named brand.\n */\nexport function brandString<BrandName extends string>(input: string | BrandedString<BrandName>): BrandedString<BrandName>;\nexport function brandString<BrandName extends string>(input: string | BrandedString<BrandName> | undefined): BrandedString<BrandName> | undefined;\nexport function brandString<BrandName extends string>(input: string | BrandedString<BrandName> | undefined): BrandedString<BrandName> | undefined {\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\treturn(input as BrandedString<BrandName> | undefined);\n}\n"]}
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@keetanetwork/anchor",
3
- "version": "0.0.79",
3
+ "version": "0.0.81",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@keetanetwork/anchor",
9
- "version": "0.0.79",
9
+ "version": "0.0.81",
10
10
  "license": "SEE LICENSE IN LICENSE",
11
11
  "dependencies": {
12
12
  "@keetanetwork/currency-info": "1.2.5",
13
- "@keetanetwork/keetanet-client": "0.18.1",
13
+ "@keetanetwork/keetanet-client": "0.18.2",
14
14
  "typia": "9.5.0"
15
15
  },
16
16
  "engines": {
@@ -171,8 +171,8 @@
171
171
  }
172
172
  },
173
173
  "node_modules/@keetanetwork/asn1-napi-rs": {
174
- "version": "1.2.2",
175
- "integrity": "sha512-kwxPBWHJv/VYKYpElhwWTbAlxAxFIQzyJmDxOEApKtqf2r4Lpiuq2RXd2lDkojGPLYVZfXrGTalm4e0b4DaYzA==",
174
+ "version": "1.2.3",
175
+ "integrity": "sha512-3Uao9FFrzAl6SEMHMiTTF2IGqd1c7N9ZAkKECV0g9jrrqxg75yDYsFhbO2X/uYsZaAuGp0cYVoC6JJCTvp/z4A==",
176
176
  "license": "SEE LICENSE IN LICENSE",
177
177
  "optional": true,
178
178
  "engines": {
@@ -185,15 +185,15 @@
185
185
  "license": "ISC"
186
186
  },
187
187
  "node_modules/@keetanetwork/keetanet-client": {
188
- "version": "0.18.1",
189
- "integrity": "sha512-ePGSqX9hHUWw2tsEgWeHukFDSck45B0GVJBpRqx18PYVGB/7XRXz6HVCmL+Oq9V2sC1MDx6Ttermq89nBZeIRQ==",
188
+ "version": "0.18.2",
189
+ "integrity": "sha512-UiuNO74j7EmDGuZkWfNMDb5vnQqLIH5Y68GcTDU6KwK4ZO3DB7WKjUnQMTw1tO4nZidqizgRrT4vUaSzJ0PJPw==",
190
190
  "license": "see LICENSE",
191
191
  "dependencies": {
192
192
  "secp256k1": "5.0.1"
193
193
  },
194
194
  "optionalDependencies": {
195
195
  "@google-cloud/logging": "11.2.0",
196
- "@keetanetwork/asn1-napi-rs": "1.2.2"
196
+ "@keetanetwork/asn1-napi-rs": "1.2.3"
197
197
  }
198
198
  },
199
199
  "node_modules/@opentelemetry/api": {
@@ -244,12 +244,6 @@
244
244
  "license": "BSD-3-Clause",
245
245
  "optional": true
246
246
  },
247
- "node_modules/@protobufjs/inquire": {
248
- "version": "1.1.2",
249
- "integrity": "sha512-pa0vFRuws4wkvaXKK1uXZMAwAX4/t8ANaJo45iw/oQHNQ9q5xUzwgFmVJGXiga2BeN+zpX7Vf9vmsiIa2J+MUw==",
250
- "license": "BSD-3-Clause",
251
- "optional": true
252
- },
253
247
  "node_modules/@protobufjs/path": {
254
248
  "version": "1.1.2",
255
249
  "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==",
@@ -790,8 +784,8 @@
790
784
  }
791
785
  },
792
786
  "node_modules/elliptic/node_modules/bn.js": {
793
- "version": "4.12.3",
794
- "integrity": "sha512-fGTi3gxV/23FTYdAoUtLYp6qySe2KE3teyZitipKNRuVYcBkoP/bB3guXN/XVKUe9mxCHXnc9C4ocyz8OmgN0g==",
787
+ "version": "4.12.4",
788
+ "integrity": "sha512-njR1b+ixG2ufvL9Zn9JGneW+b5GV6jqpYyPPpg4QVt723b5kJPGUczkUyWEH9BwEA74UakJZ43I4FDLBF7ci0g==",
795
789
  "license": "MIT"
796
790
  },
797
791
  "node_modules/encoding": {
@@ -1687,8 +1681,8 @@
1687
1681
  }
1688
1682
  },
1689
1683
  "node_modules/protobufjs": {
1690
- "version": "7.6.3",
1691
- "integrity": "sha512-+k0vdJKNdW+Vu+dYe8tZA/VvQb6XKNWexC6URwBFXxNnjLJz9nQJCemGyNgRAWD+B7+nGNc9qMPGwcD7s4nzUw==",
1684
+ "version": "7.6.4",
1685
+ "integrity": "sha512-RJJPTTpvFfHcWLkIa2JFWK4XvtSzS0yEWDmunqHXli1h3JlkbcQZXDZdcWxv+JK3Xsl5/UFDPZ0iGm7DAengYw==",
1692
1686
  "hasInstallScript": true,
1693
1687
  "license": "BSD-3-Clause",
1694
1688
  "optional": true,
@@ -1699,7 +1693,6 @@
1699
1693
  "@protobufjs/eventemitter": "^1.1.1",
1700
1694
  "@protobufjs/fetch": "^1.1.1",
1701
1695
  "@protobufjs/float": "^1.0.2",
1702
- "@protobufjs/inquire": "^1.1.2",
1703
1696
  "@protobufjs/path": "^1.1.2",
1704
1697
  "@protobufjs/pool": "^1.1.0",
1705
1698
  "@protobufjs/utf8": "^1.1.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keetanetwork/anchor",
3
- "version": "0.0.79",
3
+ "version": "0.0.81",
4
4
  "description": "KeetaNetwork Network Anchor",
5
5
  "main": "client/index.js",
6
6
  "scripts": {
@@ -24,7 +24,7 @@
24
24
  "sideEffects": false,
25
25
  "dependencies": {
26
26
  "@keetanetwork/currency-info": "1.2.5",
27
- "@keetanetwork/keetanet-client": "0.18.1",
27
+ "@keetanetwork/keetanet-client": "0.18.2",
28
28
  "typia": "9.5.0"
29
29
  },
30
30
  "engines": {
@@ -1,7 +1,7 @@
1
1
  import type { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
2
2
  import { getDefaultResolver } from '../../config.js';
3
3
  import type { UserClient as KeetaNetUserClient } from '@keetanetwork/keetanet-client';
4
- import type { KeetaAssetMovementAnchorGetTransferStatusResponse, KeetaAssetMovementAnchorCreatePersistentForwardingResponse, SupportedAssetsMetadata, ProviderSearchInput, KeetaAssetMovementAnchorlistPersistentForwardingTransactionsResponse, KeetaAssetMovementAnchorCreatePersistentForwardingClientRequest, KeetaAssetMovementAnchorInitiateTransferClientRequest, KeetaNetAccount, KeetaAssetMovementAnchorInitiatePersistentForwardingAddressTemplateClientRequest, KeetaAssetMovementAnchorInitiatePersistentForwardingAddressTemplateResponse, KeetaAssetMovementAnchorCreatePersistentForwardingAddressTemplateClientRequest, KeetaAssetMovementAnchorlistTransactionsClientRequest, KeetaAssetMovementAnchorListForwardingAddressTemplateClientRequest, PersistentAddressTemplateData, KeetaAssetMovementAnchorGetTransferStatusClientRequest, KeetaAssetMovementAnchorShareKYCClientRequest, KeetaAssetMovementAnchorListPersistentForwardingClientRequest, KeetaPersistentForwardingAddressDetails, KeetaAssetMovementAnchorInitiateTransferResponse, KeetaAssetMovementAnchorExecuteTransferClientRequest, KeetaAssetMovementAnchorDeactivatePersistentForwardingTemplateResponse, KeetaAssetMovementAnchorDeactivatePersistentForwardingResponse, AnchorTokenLocationMetadata, AnchorCustomLocationMetadata, AssetLocationLike, KeetaAssetMovementAnchorSimulateTransferResponse, KeetaAssetMovementAnchorSimulateTransferClientRequest } from './common.js';
4
+ import type { KeetaAssetMovementAnchorGetTransferStatusResponse, KeetaAssetMovementAnchorCreatePersistentForwardingResponse, SupportedAssetsMetadata, ProviderSearchInput, KeetaAssetMovementAnchorlistPersistentForwardingTransactionsResponse, KeetaAssetMovementAnchorCreatePersistentForwardingClientRequest, KeetaAssetMovementAnchorInitiateTransferClientRequest, KeetaNetAccount, KeetaAssetMovementAnchorInitiatePersistentForwardingAddressTemplateClientRequest, KeetaAssetMovementAnchorInitiatePersistentForwardingAddressTemplateResponse, KeetaAssetMovementAnchorCreatePersistentForwardingAddressTemplateClientRequest, KeetaAssetMovementAnchorlistTransactionsClientRequest, KeetaAssetMovementAnchorListForwardingAddressTemplateClientRequest, PersistentAddressTemplateData, KeetaAssetMovementAnchorGetTransferStatusClientRequest, KeetaAssetMovementAnchorGetAccountStatusClientRequest, KeetaAssetMovementAnchorAccountStatus, KeetaAssetMovementAnchorShareKYCClientRequest, KeetaAssetMovementAnchorListPersistentForwardingClientRequest, KeetaPersistentForwardingAddressDetails, KeetaAssetMovementAnchorInitiateTransferResponse, KeetaAssetMovementAnchorExecuteTransferClientRequest, KeetaAssetMovementAnchorDeactivatePersistentForwardingTemplateResponse, KeetaAssetMovementAnchorDeactivatePersistentForwardingResponse, AnchorTokenLocationMetadata, AnchorCustomLocationMetadata, AssetLocationLike, KeetaAssetMovementAnchorSimulateTransferResponse, KeetaAssetMovementAnchorSimulateTransferClientRequest } from './common.js';
5
5
  import type { Logger } from '../../lib/log/index.ts';
6
6
  import Resolver from "../../lib/resolver.js";
7
7
  import type { ServiceMetadata, ServiceMetadataAuthenticationType, SharedLookupCriteria } from '../../lib/resolver.ts';
@@ -69,6 +69,12 @@ interface KeetaAssetMovementServiceInfo extends SharedAnchorMetadataLegalExtensi
69
69
  };
70
70
  supportedAssets: SupportedAssetsMetadata[];
71
71
  locationMetadata?: AnchorCustomLocationMetadata;
72
+ /**
73
+ * Public key string of the account the anchor signed its service entry
74
+ * with. Present only for signed entries. This is the key external
75
+ * envelopes referencing this anchor are filed under.
76
+ */
77
+ account?: string;
72
78
  }
73
79
  interface KeetaAssetMovementAnchorBaseConfig {
74
80
  client: KeetaNetUserClient;
@@ -98,7 +104,7 @@ declare abstract class BaseKeetaAssetMovementTransfer<Request extends KeetaAsset
98
104
  */
99
105
  declare class KeetaAssetMovementTransfer extends BaseKeetaAssetMovementTransfer<KeetaAssetMovementAnchorInitiateTransferClientRequest, ExtractOk<KeetaAssetMovementAnchorInitiateTransferResponse>> {
100
106
  readonly isSimulation: false;
101
- get transferId(): string;
107
+ get transferID(): string;
102
108
  getTransferStatus(): Promise<ExtractOk<KeetaAssetMovementAnchorGetTransferStatusResponse>>;
103
109
  executeTransfer(input: Omit<KeetaAssetMovementAnchorExecuteTransferClientRequest, 'id'>): Promise<ExtractOk<KeetaAssetMovementAnchorGetTransferStatusResponse>>;
104
110
  }
@@ -124,6 +130,16 @@ export declare class KeetaAssetMovementAnchorProvider extends KeetaAssetMovement
124
130
  simulateTransfer(request: KeetaAssetMovementAnchorSimulateTransferClientRequest): Promise<KeetaAssetMovementSimulatedTransfer>;
125
131
  executeTransfer(request: KeetaAssetMovementAnchorExecuteTransferClientRequest): Promise<ExtractOk<KeetaAssetMovementAnchorGetTransferStatusResponse>>;
126
132
  getTransferStatus(request: KeetaAssetMovementAnchorGetTransferStatusClientRequest): Promise<ExtractOk<KeetaAssetMovementAnchorGetTransferStatusResponse>>;
133
+ /**
134
+ * Check whether the (authenticated) account is ready to use this asset movement provider.
135
+ *
136
+ * Resolves with the account status, mirroring the wire `actionRequired` discriminant:
137
+ * `{ actionRequired: false }` means the account is ready, while `{ actionRequired: true, errors }`
138
+ * lists the actions the account must complete before it can proceed, rehydrated into their typed
139
+ * errors (e.g. `Errors.KYCShareNeeded`, `Errors.AdditionalKYCNeeded`, `Errors.UserActionNeeded`,
140
+ * `Errors.OperationNotSupported`). Request-level failures (e.g. an invalid signature) still reject.
141
+ */
142
+ getAccountStatus(request: KeetaAssetMovementAnchorGetAccountStatusClientRequest): Promise<KeetaAssetMovementAnchorAccountStatus>;
127
143
  deactivatePersistentForwardingTemplate(request: {
128
144
  id: string;
129
145
  account?: KeetaNetAccount;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/services/asset-movement/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EACX,UAAU,IAAI,kBAAkB,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACX,iDAAiD,EAEjD,0DAA0D,EAC1D,uBAAuB,EACvB,mBAAmB,EAEnB,oEAAoE,EACpE,+DAA+D,EAC/D,qDAAqD,EACrD,eAAe,EACf,gFAAgF,EAEhF,2EAA2E,EAC3E,8EAA8E,EAG9E,qDAAqD,EACrD,kEAAkE,EAClE,6BAA6B,EAC7B,sDAAsD,EACtD,6CAA6C,EAG7C,6DAA6D,EAC7D,uCAAuC,EACvC,gDAAgD,EAChD,oDAAoD,EAEpD,sEAAsE,EAEtE,8DAA8D,EAC9D,2BAA2B,EAC3B,4BAA4B,EAE5B,iBAAiB,EAEjB,gDAAgD,EAChD,qDAAqD,EAGrD,MAAM,aAAa,CAAC;AAqCrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7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AwB,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI;CAQlF;AAED,cAAM,8BAA+B,SAAQ,4BAA4B;;IACxE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;gBAMR,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAE,8BAAmC;IAqC7E,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,gCAAgC,EAAE,GAAG,IAAI,CAAC;IAIxI,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gCAAgC,GAAG,IAAI,CAAC;IAKrF,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;IAchI,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,gCAAgC,GAAG,IAAI,CAAC;CAiB5I;AAED,eAAe,8BAA8B,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
2
2
  import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
3
3
  import { getDefaultResolver } from '../../config.js';
4
- import { assertKeetaSupportedAssetsMetadataItem, convertAssetLocationToString, convertAssetOrPairSearchInputToCanonical, convertAssetSearchInputToCanonical, getKeetaAssetMovementAnchorInitiatePersistentForwardingAddressTemplateRequestSigningData, isKeetaAssetMovementAnchorInitiatePersistentForwardingAddressTemplateResponse, getKeetaAssetMovementAnchorCreatePersistentForwardingAddressTemplateRequestSigningData, getKeetaAssetMovementAnchorCreatePersistentForwardingRequestSigningData, getKeetaAssetMovementAnchorExecuteTransferRequestSigningData, getKeetaAssetMovementAnchorGetTransferStatusRequestSigningData, getKeetaAssetMovementAnchorInitiateTransferRequestSigningData, getKeetaAssetMovementAnchorListForwardingAddressTemplateRequestSigningData, getKeetaAssetMovementAnchorListPersistentForwardingRequestSigningData, getKeetaAssetMovementAnchorlistTransactionsRequestSigningData, getKeetaAssetMovementAnchorShareKYCRequestSigningData, isKeetaAssetMovementAnchorCreatePersistentForwardingAddressTemplateResponse, isKeetaAssetMovementAnchorCreatePersistentForwardingResponse, isKeetaAssetMovementAnchorExecuteTransferResponse, isKeetaAssetMovementAnchorGetExchangeStatusResponse, isKeetaAssetMovementAnchorInitiateTransferResponse, isKeetaAssetMovementAnchorListForwardingAddressTemplateResponse, isKeetaAssetMovementAnchorListPersistentForwardingResponse, isKeetaAssetMovementAnchorlistPersistentForwardingTransactionsResponse, isKeetaAssetMovementAnchorShareKYCResponse, toAssetLocationFromString, isExternalChainAsset, isAnchorTokenLocationMetadata, isKeetaAssetMovementAnchorSimulateTransferResponse, getKeetaAssetMovementAnchorSimulateTransferRequestSigningData, getKeetaAssetMovementAnchorDeactivatePersistentForwardingTemplateRequestSigningData, isKeetaAssetMovementAnchorDeactivatePersistentForwardingTemplateResponse, getKeetaAssetMovementAnchorDeactivatePersistentForwardingRequestSigningData, isKeetaAssetMovementAnchorDeactivatePersistentForwardingResponse, Errors } from './common.js';
4
+ import { assertKeetaSupportedAssetsMetadataItem, convertAssetLocationToString, convertAssetOrPairSearchInputToCanonical, convertAssetSearchInputToCanonical, getKeetaAssetMovementAnchorInitiatePersistentForwardingAddressTemplateRequestSigningData, isKeetaAssetMovementAnchorInitiatePersistentForwardingAddressTemplateResponse, getKeetaAssetMovementAnchorCreatePersistentForwardingAddressTemplateRequestSigningData, getKeetaAssetMovementAnchorCreatePersistentForwardingRequestSigningData, getKeetaAssetMovementAnchorExecuteTransferRequestSigningData, getKeetaAssetMovementAnchorGetTransferStatusRequestSigningData, getKeetaAssetMovementAnchorGetAccountStatusRequestSigningData, isKeetaAssetMovementAnchorGetAccountStatusResponse, isKeetaAssetMovementAnchorError, getKeetaAssetMovementAnchorInitiateTransferRequestSigningData, getKeetaAssetMovementAnchorListForwardingAddressTemplateRequestSigningData, getKeetaAssetMovementAnchorListPersistentForwardingRequestSigningData, getKeetaAssetMovementAnchorlistTransactionsRequestSigningData, getKeetaAssetMovementAnchorShareKYCRequestSigningData, isKeetaAssetMovementAnchorCreatePersistentForwardingAddressTemplateResponse, isKeetaAssetMovementAnchorCreatePersistentForwardingResponse, isKeetaAssetMovementAnchorExecuteTransferResponse, isKeetaAssetMovementAnchorGetExchangeStatusResponse, isKeetaAssetMovementAnchorInitiateTransferResponse, isKeetaAssetMovementAnchorListForwardingAddressTemplateResponse, isKeetaAssetMovementAnchorListPersistentForwardingResponse, isKeetaAssetMovementAnchorlistPersistentForwardingTransactionsResponse, isKeetaAssetMovementAnchorShareKYCResponse, toAssetLocationFromString, isExternalChainAsset, isAnchorTokenLocationMetadata, isKeetaAssetMovementAnchorSimulateTransferResponse, getKeetaAssetMovementAnchorSimulateTransferRequestSigningData, getKeetaAssetMovementAnchorDeactivatePersistentForwardingTemplateRequestSigningData, isKeetaAssetMovementAnchorDeactivatePersistentForwardingTemplateResponse, getKeetaAssetMovementAnchorDeactivatePersistentForwardingRequestSigningData, isKeetaAssetMovementAnchorDeactivatePersistentForwardingResponse, Errors } from './common.js';
5
5
  import Resolver from "../../lib/resolver.js";
6
6
  import crypto from '../../lib/utils/crypto.js';
7
+ import { brandString } from '../../lib/utils/brand.js';
7
8
  import { createAssertEquals } from 'typia';
8
9
  import { addSignatureToURL } from '../../lib/http-server/common.js';
9
10
  import { SignData } from '../../lib/utils/signing.js';
@@ -26,7 +27,7 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
26
27
  if (undefined === value)
27
28
  return true;
28
29
  return false;
29
- })); const _io1 = (input, _exceptionable = true) => (undefined === input.authentication || "object" === typeof input.authentication && null !== input.authentication && _io2(input.authentication, true && _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every(key => {
30
+ })); const _io1 = (input, _exceptionable = true) => (undefined === input.authentication || "object" === typeof input.authentication && null !== input.authentication && _iu0(input.authentication, true && _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every(key => {
30
31
  if (["authentication"].some(prop => key === prop))
31
32
  return true;
32
33
  const value = input[key];
@@ -40,7 +41,19 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
40
41
  if (undefined === value)
41
42
  return true;
42
43
  return false;
43
- })); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.url || __typia_transform__assertGuard._assertGuard(_exceptionable, {
44
+ })); const _io3 = (input, _exceptionable = true) => null !== input.method && undefined === input.method && "none" === input.type && (1 === Object.keys(input).length || Object.keys(input).every(key => {
45
+ if (["method", "type"].some(prop => key === prop))
46
+ return true;
47
+ const value = input[key];
48
+ if (undefined === value)
49
+ return true;
50
+ return false;
51
+ })); const _iu0 = (input, _exceptionable = true) => (() => {
52
+ if ("keeta-account" === input.method)
53
+ return _io2(input, true && _exceptionable);
54
+ else
55
+ return _io3(input, true && _exceptionable);
56
+ })(); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.url || __typia_transform__assertGuard._assertGuard(_exceptionable, {
44
57
  method: "createAssertEquals",
45
58
  path: _path + ".url",
46
59
  expected: "string",
@@ -70,12 +83,12 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
70
83
  }))); const _ao1 = (input, _path, _exceptionable = true) => (undefined === input.authentication || ("object" === typeof input.authentication && null !== input.authentication || __typia_transform__assertGuard._assertGuard(_exceptionable, {
71
84
  method: "createAssertEquals",
72
85
  path: _path + ".authentication",
73
- expected: "(ServiceMetadataAuthenticationType | undefined)",
86
+ expected: "(__type.o2 | __type.o3 | undefined)",
74
87
  value: input.authentication
75
- }, _errorFactory)) && _ao2(input.authentication, _path + ".authentication", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
88
+ }, _errorFactory)) && _au0(input.authentication, _path + ".authentication", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
76
89
  method: "createAssertEquals",
77
90
  path: _path + ".authentication",
78
- expected: "(ServiceMetadataAuthenticationType | undefined)",
91
+ expected: "(__type.o2 | __type.o3 | undefined)",
79
92
  value: input.authentication
80
93
  }, _errorFactory)) && (0 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
81
94
  if (["authentication"].some(prop => key === prop))
@@ -111,7 +124,39 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
111
124
  expected: "undefined",
112
125
  value: value
113
126
  }, _errorFactory);
114
- }))); const __is = (input, _exceptionable = true) => null !== input && undefined !== input && ("string" === typeof input || "object" === typeof input && null !== input && _io0(input, true)); let _errorFactory; return (input, errorFactory) => {
127
+ }))); const _ao3 = (input, _path, _exceptionable = true) => (null !== input.method || __typia_transform__assertGuard._assertGuard(_exceptionable, {
128
+ method: "createAssertEquals",
129
+ path: _path + ".method",
130
+ expected: "undefined",
131
+ value: input.method
132
+ }, _errorFactory)) && (undefined === input.method || __typia_transform__assertGuard._assertGuard(_exceptionable, {
133
+ method: "createAssertEquals",
134
+ path: _path + ".method",
135
+ expected: "undefined",
136
+ value: input.method
137
+ }, _errorFactory)) && ("none" === input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
138
+ method: "createAssertEquals",
139
+ path: _path + ".type",
140
+ expected: "\"none\"",
141
+ value: input.type
142
+ }, _errorFactory)) && (1 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
143
+ if (["method", "type"].some(prop => key === prop))
144
+ return true;
145
+ const value = input[key];
146
+ if (undefined === value)
147
+ return true;
148
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
149
+ method: "createAssertEquals",
150
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
151
+ expected: "undefined",
152
+ value: value
153
+ }, _errorFactory);
154
+ }))); const _au0 = (input, _path, _exceptionable = true) => (() => {
155
+ if ("keeta-account" === input.method)
156
+ return _ao2(input, _path, true && _exceptionable);
157
+ else
158
+ return _ao3(input, _path, true && _exceptionable);
159
+ })(); const __is = (input, _exceptionable = true) => null !== input && undefined !== input && ("string" === typeof input || "object" === typeof input && null !== input && _io0(input, true)); let _errorFactory; return (input, errorFactory) => {
115
160
  if (false === __is(input)) {
116
161
  _errorFactory = errorFactory;
117
162
  ((input, _path, _exceptionable = true) => (null !== input || __typia_transform__assertGuard._assertGuard(true, {
@@ -313,15 +358,25 @@ async function getEndpoints(resolver, request, shared, logger) {
313
358
  configurable: true
314
359
  });
315
360
  }
361
+ let anchorAccount;
362
+ if (serviceInfo.account !== undefined) {
363
+ anchorAccount = await serviceInfo.account('string');
364
+ }
365
+ const legalExtension = await resolveSharedAnchorMetadataLegalExtension(serviceInfo.legal, { logger });
366
+ const resolvedServiceInfo = {
367
+ ...legalExtension,
368
+ operations: operationsFunctions,
369
+ supportedAssets: supportedAssets
370
+ };
371
+ if (locationMetadata) {
372
+ resolvedServiceInfo.locationMetadata = locationMetadata;
373
+ }
374
+ if (anchorAccount !== undefined) {
375
+ resolvedServiceInfo.account = anchorAccount;
376
+ }
316
377
  return ([
317
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
318
- id,
319
- {
320
- ...(await resolveSharedAnchorMetadataLegalExtension(serviceInfo.legal, { logger })),
321
- operations: operationsFunctions,
322
- supportedAssets: supportedAssets,
323
- ...(locationMetadata ? { locationMetadata } : {})
324
- }
378
+ brandString(id),
379
+ resolvedServiceInfo
325
380
  ]);
326
381
  });
327
382
  const retval = Object.fromEntries(await Promise.all(serviceInfoPromises));
@@ -353,7 +408,7 @@ class BaseKeetaAssetMovementTransfer {
353
408
  */
354
409
  class KeetaAssetMovementTransfer extends BaseKeetaAssetMovementTransfer {
355
410
  isSimulation = false;
356
- get transferId() {
411
+ get transferID() {
357
412
  return (this.transfer.id);
358
413
  }
359
414
  async getTransferStatus() {
@@ -445,7 +500,7 @@ export class KeetaAssetMovementAnchorProvider extends KeetaAssetMovementAnchorBa
445
500
  else {
446
501
  errorStr = 'Unknown error';
447
502
  }
448
- return (new Error(`asset movement request failed: ${errorStr}`));
503
+ return (new KeetaAnchorError(`asset movement request failed: ${errorStr}`));
449
504
  }
450
505
  }
451
506
  async #makeRequest(input) {
@@ -603,6 +658,45 @@ export class KeetaAssetMovementAnchorProvider extends KeetaAssetMovementAnchorBa
603
658
  this.logger?.debug(`asset movement request successful, request ID ${request.id}`);
604
659
  return (requestInformationJSON);
605
660
  }
661
+ /**
662
+ * Check whether the (authenticated) account is ready to use this asset movement provider.
663
+ *
664
+ * Resolves with the account status, mirroring the wire `actionRequired` discriminant:
665
+ * `{ actionRequired: false }` means the account is ready, while `{ actionRequired: true, errors }`
666
+ * lists the actions the account must complete before it can proceed, rehydrated into their typed
667
+ * errors (e.g. `Errors.KYCShareNeeded`, `Errors.AdditionalKYCNeeded`, `Errors.UserActionNeeded`,
668
+ * `Errors.OperationNotSupported`). Request-level failures (e.g. an invalid signature) still reject.
669
+ */
670
+ async getAccountStatus(request) {
671
+ this.logger?.debug(`Getting account status for provider ID: ${String(this.providerID)}`);
672
+ const { account } = request;
673
+ let response;
674
+ try {
675
+ response = await this.#makeRequest({
676
+ method: 'POST',
677
+ endpoint: 'getAccountStatus',
678
+ account,
679
+ body: {},
680
+ serializeRequest: () => (account ? { account: account.assertAccount().publicKeyString.get() } : {}),
681
+ getSignedData: () => getKeetaAssetMovementAnchorGetAccountStatusRequestSigningData(),
682
+ isResponse: isKeetaAssetMovementAnchorGetAccountStatusResponse
683
+ });
684
+ }
685
+ catch (error) {
686
+ if (isKeetaAssetMovementAnchorError(error)) {
687
+ this.logger?.debug('get account status successful, 1 required action(s) (thrown)');
688
+ return ({ actionRequired: true, errors: [error] });
689
+ }
690
+ throw (error);
691
+ }
692
+ if (!response.actionRequired) {
693
+ this.logger?.debug('get account status successful, account ready');
694
+ return ({ actionRequired: false });
695
+ }
696
+ const errors = await Promise.all(response.errors.map((entry) => this.#parseResponseError(entry)));
697
+ this.logger?.debug(`get account status successful, ${errors.length} required action(s)`);
698
+ return ({ actionRequired: true, errors });
699
+ }
606
700
  async deactivatePersistentForwardingTemplate(request) {
607
701
  this.logger?.debug(`Deactivating persistent forwarding template ${request.id} for provider ID: ${String(this.providerID)}`);
608
702
  const { id, account } = request;