@keetanetwork/anchor 0.0.112 → 0.0.113

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 (65) hide show
  1. package/lib/http-server/common.d.ts +3 -2
  2. package/lib/http-server/common.d.ts.map +1 -1
  3. package/lib/http-server/common.js +9 -13
  4. package/lib/http-server/common.js.map +1 -1
  5. package/lib/http-server/index.d.ts +21 -1
  6. package/lib/http-server/index.d.ts.map +1 -1
  7. package/lib/http-server/index.js +84 -36
  8. package/lib/http-server/index.js.map +1 -1
  9. package/lib/http-server/replay-guard.d.ts +29 -0
  10. package/lib/http-server/replay-guard.d.ts.map +1 -0
  11. package/lib/http-server/replay-guard.js +58 -0
  12. package/lib/http-server/replay-guard.js.map +1 -0
  13. package/lib/http-server/request-signing.d.ts +53 -0
  14. package/lib/http-server/request-signing.d.ts.map +1 -0
  15. package/lib/http-server/request-signing.js +130 -0
  16. package/lib/http-server/request-signing.js.map +1 -0
  17. package/lib/utils/signing.d.ts +5 -0
  18. package/lib/utils/signing.d.ts.map +1 -1
  19. package/lib/utils/signing.js +6 -1
  20. package/lib/utils/signing.js.map +1 -1
  21. package/npm-shrinkwrap.json +2 -2
  22. package/package.json +1 -1
  23. package/services/asset-movement/client.d.ts +5 -4
  24. package/services/asset-movement/client.d.ts.map +1 -1
  25. package/services/asset-movement/client.js +27 -13
  26. package/services/asset-movement/client.js.map +1 -1
  27. package/services/asset-movement/common.generated.js +1 -1
  28. package/services/asset-movement/common.server.generated.js +50 -50
  29. package/services/asset-movement/server.d.ts.map +1 -1
  30. package/services/asset-movement/server.js +22 -4
  31. package/services/asset-movement/server.js.map +1 -1
  32. package/services/fx/server.d.ts.map +1 -1
  33. package/services/fx/server.js +45 -38
  34. package/services/fx/server.js.map +1 -1
  35. package/services/kyc/client.d.ts +8 -3
  36. package/services/kyc/client.d.ts.map +1 -1
  37. package/services/kyc/client.js +24 -23
  38. package/services/kyc/client.js.map +1 -1
  39. package/services/kyc/common.d.ts +0 -7
  40. package/services/kyc/common.d.ts.map +1 -1
  41. package/services/kyc/common.js +0 -8
  42. package/services/kyc/common.js.map +1 -1
  43. package/services/kyc/server.d.ts +3 -1
  44. package/services/kyc/server.d.ts.map +1 -1
  45. package/services/kyc/server.js +15 -33
  46. package/services/kyc/server.js.map +1 -1
  47. package/services/notification/client.d.ts.map +1 -1
  48. package/services/notification/client.js +39 -33
  49. package/services/notification/client.js.map +1 -1
  50. package/services/notification/server.js +10 -10
  51. package/services/notification/server.js.map +1 -1
  52. package/services/storage/client.d.ts +3 -0
  53. package/services/storage/client.d.ts.map +1 -1
  54. package/services/storage/client.js +41 -11
  55. package/services/storage/client.js.map +1 -1
  56. package/services/storage/server.d.ts.map +1 -1
  57. package/services/storage/server.js +12 -11
  58. package/services/storage/server.js.map +1 -1
  59. package/services/username/client.d.ts +12 -1
  60. package/services/username/client.d.ts.map +1 -1
  61. package/services/username/client.js +36 -30
  62. package/services/username/client.js.map +1 -1
  63. package/services/username/server.d.ts.map +1 -1
  64. package/services/username/server.js +7 -6
  65. package/services/username/server.js.map +1 -1
@@ -5,7 +5,7 @@ import { Certificate as KYCCertificate } from '../../lib/certificates.js';
5
5
  import type { Client as KeetaNetClient, UserClient as KeetaNetUserClient } from '@keetanetwork/keetanet-client';
6
6
  import type { KeetaKYCAnchorCreateVerificationRequest } from './common.ts';
7
7
  import type { KYCVerificationStatus } from './status.js';
8
- import { type SignableAccount } from '../../lib/utils/signing.js';
8
+ import type { SignableAccount } from '../../lib/utils/signing.js';
9
9
  import type { Logger } from '../../lib/log/index.ts';
10
10
  import type Resolver from '../../lib/resolver.ts';
11
11
  import type { KYCEntityType, ServiceMetadata } from '../../lib/resolver.ts';
@@ -90,10 +90,14 @@ type KeetaKYCVerificationServiceInfo = {
90
90
  countryCodes?: CurrencyInfo.Country[] | undefined;
91
91
  ca: () => Promise<KYCCertificate>;
92
92
  };
93
+ /**
94
+ * A verification request before it is signed for one provider.
95
+ */
96
+ type KeetaKYCAnchorUnsignedVerificationRequest = Omit<KeetaKYCAnchorCreateVerificationRequest, 'signed'>;
93
97
  type KeetaKYCAnchorCommonConfig = {
94
98
  id: ProviderID;
95
99
  serviceInfo: KeetaKYCVerificationServiceInfo;
96
- request: KeetaKYCAnchorCreateVerificationRequest;
100
+ request: KeetaKYCAnchorUnsignedVerificationRequest;
97
101
  account: SignableAccount;
98
102
  client: KeetaKYCAnchorClient;
99
103
  operations: NonNullable<Pick<KeetaKYCAnchorOperations, 'createVerification' | 'getCertificates' | 'getVerificationStatus'>>;
@@ -143,8 +147,9 @@ declare class KeetaKYCAnchorClient {
143
147
  private readonly logger?;
144
148
  constructor(client: KeetaNetClient | KeetaNetUserClient, config?: KeetaKYCAnchorClientConfig);
145
149
  createVerification(request: KeetaKYCAnchorClientCreateVerificationRequest): Promise<KeetaKYCProvider[]>;
146
- getCertificates(providerID: ProviderID, request: KeetaKYCAnchorCreateVerificationRequest & {
150
+ getCertificates(providerID: ProviderID, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'> & {
147
151
  id: RequestID;
152
+ account: SignableAccount;
148
153
  }): Promise<KeetaKYCAnchorClientGetCertificateResponse>;
149
154
  getSupportedCountries(entityType?: KYCEntityType): Promise<CurrencyInfo.Country[]>;
150
155
  getVerificationStatus(providerID: ProviderID, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'> & {
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/services/kyc/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAG5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,KAAK,EACX,MAAM,IAA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C,gBAAgB,EAAE,CAAC;IA0EvG,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,uCAAuC,EAAE,cAAc,GAAG,YAAY,CAAC,GAAG;QAAE,EAAE,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,eAAe,CAAC;KAAE,GAAG,OAAO,CAAC,0CAA0C,CAAC;IA8ElO,qBAAqB,CAAC,UAAU,GAAE,aAA4B,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IAIhG,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,uCAAuC,EAAE,cAAc,GAAG,YAAY,CAAC,GAAG;QAAE,EAAE,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,eAAe,CAAC;KAAE,GAAG,OAAO,CAAC,iDAAiD,CAAC;IAmDrP;;OAEG;IACG,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,uCAAuC,EAAE,cAAc,GAAG,YAAY,CAAC,GAAG;QAAE,EAAE,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,eAAe,CAAC;KAAE,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IA2CrM,WAAW,CAAC,GAAG,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IAIvD,aAAa,CAAC,GAAG,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;CAG/D;AAED,eAAe,oBAAoB,CAAC"}
@@ -3,12 +3,10 @@ import * as CurrencyInfo from '@keetanetwork/currency-info';
3
3
  import { createIs } from 'typia';
4
4
  import { getDefaultResolver } from '../../config.js';
5
5
  import { Certificate as KYCCertificate } from '../../lib/certificates.js';
6
- import { verifySignedData, generateSignedData } from './common.js';
7
6
  import { addSignatureToURL } from '../../lib/http-server/common.js';
8
- import { SignData } from '../../lib/utils/signing.js';
7
+ import { signRequest } from '../../lib/http-server/request-signing.js';
9
8
  import crypto from '../../lib/utils/crypto.js';
10
9
  import { validateURL } from '../../lib/utils/url.js';
11
- const PARANOID = true;
12
10
  const isKeetaKYCAnchorCreateVerificationResponse = (() => { const _io0 = input => true === input.ok && "string" === typeof input.id && ("object" === typeof input.expectedCost && null !== input.expectedCost && _io1(input.expectedCost)) && "string" === typeof input.webURL; const _io1 = input => "string" === typeof input.min && "string" === typeof input.max && ("string" === typeof input.token && (RegExp(/^keeta_am(.*)/).test(input.token) || RegExp(/^keeta_an(.*)/).test(input.token) || RegExp(/^keeta_ao(.*)/).test(input.token) || RegExp(/^keeta_ap(.*)/).test(input.token) || RegExp(/^tyblocks_am(.*)/).test(input.token) || RegExp(/^tyblocks_an(.*)/).test(input.token) || RegExp(/^tyblocks_ao(.*)/).test(input.token) || RegExp(/^tyblocks_ap(.*)/).test(input.token))); const _io2 = input => false === input.ok && "string" === typeof input.error; const _iu0 = input => (() => {
13
11
  if (true === input.ok)
14
12
  return _io0(input);
@@ -132,6 +130,7 @@ class KeetaKYCVerification {
132
130
  if (createVerification === undefined) {
133
131
  throw (new Error('KYC verification service does not support createVerification operation'));
134
132
  }
133
+ const signed = await signRequest(args.account, { method: 'POST', url: createVerification, body: args.request }, []);
135
134
  const requestInformation = await fetch(createVerification, {
136
135
  method: 'POST',
137
136
  headers: {
@@ -139,7 +138,7 @@ class KeetaKYCVerification {
139
138
  'Accept': 'application/json'
140
139
  },
141
140
  body: JSON.stringify({
142
- request: args.request
141
+ request: { ...args.request, signed }
143
142
  })
144
143
  });
145
144
  const requestInformationJSON = await requestInformation.json();
@@ -162,10 +161,15 @@ class KeetaKYCVerification {
162
161
  return (await this.serviceInfo.ca());
163
162
  }
164
163
  getCertificates() {
165
- return (this.client.getCertificates(this.providerID, {
164
+ const request = {
166
165
  id: this.id,
167
- ...this.request
168
- }));
166
+ account: this.account,
167
+ countryCodes: this.request.countryCodes
168
+ };
169
+ if (this.request.entityType !== undefined) {
170
+ request.entityType = this.request.entityType;
171
+ }
172
+ return (this.client.getCertificates(this.providerID, request));
169
173
  }
170
174
  getVerificationStatus() {
171
175
  return (this.client.getVerificationStatus(this.providerID, {
@@ -238,22 +242,14 @@ class KeetaKYCAnchorClient {
238
242
  this.logger = config.logger;
239
243
  }
240
244
  async createVerification(request) {
241
- const signedData = await generateSignedData(request.account.assertAccount());
242
- if (PARANOID) {
243
- const check = await verifySignedData({ account: request.account.publicKeyString.get(), signed: signedData });
244
- if (!check) {
245
- throw (new Error('Failed to verify signed data'));
246
- }
247
- }
248
- const signedRequest = {
245
+ const unsignedRequest = {
249
246
  ...request,
250
- account: request.account.publicKeyString.get(),
251
- signed: signedData
247
+ account: request.account.publicKeyString.get()
252
248
  };
253
249
  /* Only provider selection defaults to individual; the by-ID lookups below must not filter. */
254
250
  const endpoints = await getEndpoints(this.resolver, {
255
- countryCodes: signedRequest.countryCodes,
256
- entityType: signedRequest.entityType ?? 'individual'
251
+ countryCodes: unsignedRequest.countryCodes,
252
+ entityType: unsignedRequest.entityType ?? 'individual'
257
253
  });
258
254
  if (endpoints === null) {
259
255
  throw (new Error('No KYC endpoints found for the given criteria'));
@@ -280,7 +276,7 @@ class KeetaKYCAnchorClient {
280
276
  return (new KeetaKYCProvider({
281
277
  id: providerID,
282
278
  serviceInfo: serviceInfo,
283
- request: signedRequest,
279
+ request: unsignedRequest,
284
280
  account: request.account.assertAccount(),
285
281
  client: this,
286
282
  logger: this.logger,
@@ -326,7 +322,12 @@ class KeetaKYCAnchorClient {
326
322
  if (getCertificate === undefined) {
327
323
  throw (new Error('internal error: KYC verification service does not support getCertificate operation'));
328
324
  }
329
- const response = await fetch(getCertificate, {
325
+ const signed = await signRequest(request.account, { method: 'GET', url: getCertificate }, []);
326
+ const signedURL = addSignatureToURL(getCertificate, {
327
+ signedField: signed,
328
+ account: request.account
329
+ });
330
+ const response = await fetch(signedURL, {
330
331
  method: 'GET',
331
332
  headers: {
332
333
  'Accept': 'application/json'
@@ -390,7 +391,7 @@ class KeetaKYCAnchorClient {
390
391
  if (getVerificationStatus === undefined) {
391
392
  throw (new Error('internal error: KYC verification service does not support getVerificationStatus operation'));
392
393
  }
393
- const signed = await SignData(request.account, []);
394
+ const signed = await signRequest(request.account, { method: 'GET', url: getVerificationStatus }, []);
394
395
  const signedURL = addSignatureToURL(getVerificationStatus, {
395
396
  signedField: signed,
396
397
  account: request.account
@@ -435,7 +436,7 @@ class KeetaKYCAnchorClient {
435
436
  if (getVerificationURL === undefined) {
436
437
  return (null);
437
438
  }
438
- const signed = await SignData(request.account, []);
439
+ const signed = await signRequest(request.account, { method: 'GET', url: getVerificationURL }, []);
439
440
  const signedURL = addSignatureToURL(getVerificationURL, {
440
441
  signedField: signed,
441
442
  account: request.account
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/services/kyc/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAgB1E,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAwB,MAAM,4BAA4B,CAAC;AAI5E,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,QAAQ,GAAG,IAAI,CAAC;AAkGtB,MAAM,0CAA0C;;;;;;;sFAAuD,CAAC;AACxG,MAAM,sCAAsC;;;;;;;sFAAmD,CAAC;AAChG,MAAM,6CAA6C;;;;;;;s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AClB,MAAK,CAAC,IAAI,KAAK,CAAC,mCAAmC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,YAAY,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpD,IAAI,CAAC,0CAA0C,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/D,MAAK,CAAC,IAAI,KAAK,CAAC,uDAAuD,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;QACzG,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;YACtB,MAAK,CAAC,IAAI,KAAK,CAAC,wCAAwC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAChF,CAAC;QAED,OAAM,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,GAAG,YAAuB;QAC3C,MAAK,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,GAAG,YAAuB;QAC7C,MAAK,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACrC,CAAC;CACD;AAED,eAAe,oBAAoB,CAAC","sourcesContent":["import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\nimport * as CurrencyInfo from '@keetanetwork/currency-info';\nimport { createIs } from 'typia';\n\nimport { getDefaultResolver } from '../../config.js';\nimport { Certificate as KYCCertificate } from '../../lib/certificates.js';\n\nimport type {\n\tClient as KeetaNetClient,\n\tUserClient as KeetaNetUserClient\n} from '@keetanetwork/keetanet-client';\nimport type {\n\tKeetaKYCAnchorCreateVerificationRequest,\n\tKeetaKYCAnchorCreateVerificationResponse,\n\tKeetaKYCAnchorGetCertificateResponse,\n\tKeetaKYCAnchorGetVerificationStatusResponse,\n\tKeetaKYCAnchorGetVerificationURLResponse\n} from './common.ts';\nimport type {\n\tKYCVerificationStatus\n} from './status.js';\nimport {\n\tverifySignedData,\n\tgenerateSignedData\n} from './common.js';\nimport { addSignatureToURL } from '../../lib/http-server/common.js';\nimport { SignData, type SignableAccount } from '../../lib/utils/signing.js';\nimport type { Logger } from '../../lib/log/index.ts';\nimport type Resolver from '../../lib/resolver.ts';\nimport type { KYCEntityType, ServiceMetadata } from '../../lib/resolver.ts';\nimport crypto from '../../lib/utils/crypto.js';\nimport { validateURL } from '../../lib/utils/url.js';\n\nconst PARANOID = true;\n\n/**\n * The configuration options for the KYC Anchor client.\n */\nexport type KeetaKYCAnchorClientConfig = {\n\t/**\n\t * The ID of the client. This is used to identify the client in logs.\n\t * If not provided, a random ID will be generated.\n\t */\n\tid?: string;\n\t/**\n\t * The logger to use for logging messages. If not provided, no logging\n\t * will be done.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * The resolver to use for resolving KYC Anchor services. If not\n\t * provided, a default resolver will be created using the provided\n\t * client and network (if the network is also not provided and the\n\t * client is not a UserClient, an error occurs).\n\t */\n\tresolver?: Resolver;\n} & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'>;\n\n/**\n * Any kind of X.509v3 Certificate. This may or may not be a KYC certificate.\n */\ntype BaseCertificate = InstanceType<typeof KeetaNetLib.Utils.Certificate.Certificate>;\n\n/**\n * The response type for the {@link KeetaKYCAnchorClient['getCertificates']()} method of the KYC Anchor client.\n * It contains the certificate and optionally a set of intermediate certificates.\n */\ntype KeetaKYCAnchorClientGetCertificateResponse = ({\n\tok: true;\n\tresults: {\n\t\tcertificate: KYCCertificate;\n\t\tintermediates?: Set<BaseCertificate> | undefined;\n\t}[]\n} | {\n\tok: false;\n\tretryAfter: number;\n\treason: string;\n});\n\n/**\n * The response type for {@link KeetaKYCAnchorClient['getVerificationStatus']()}.\n */\ntype KeetaKYCAnchorClientGetVerificationStatusResponse = {\n\tstatus: KYCVerificationStatus;\n\trequiresManualVerification?: boolean;\n};\n\ntype KeetaKYCAnchorClientCreateVerificationRequest = Omit<KeetaKYCAnchorCreateVerificationRequest, 'signed' | 'account'> & {\n\taccount: InstanceType<typeof KeetaNetLib.Account>;\n};\n\n/**\n * An opaque type that represents a provider ID.\n */\ntype ProviderID = string & {\n\treadonly __providerID: unique symbol;\n};\n\n/**\n * An opaque type that represents a KYC Anchor request ID\n */\ntype RequestID = string & {\n\treadonly __requestID: unique symbol;\n};\n\n/**\n * A list of operations that can be performed by the KYC Anchor service.\n */\ntype KeetaKYCAnchorOperations = {\n\t[operation in keyof NonNullable<ServiceMetadata['services']['kyc']>[string]['operations']]?: (params?: { [key: string]: string; }) => URL;\n};\n\n/**\n * The service information for a KYC Anchor service.\n */\ntype KeetaKYCVerificationServiceInfo = {\n\toperations: {\n\t\t[operation in keyof KeetaKYCAnchorOperations]: Promise<KeetaKYCAnchorOperations[operation]>;\n\t};\n\tcountryCodes?: CurrencyInfo.Country[] | undefined;\n\tca: () => Promise<KYCCertificate>;\n};\n\n/**\n * For each matching KYC Anchor service, this type describes the\n * operations available and the country codes that the service supports.\n */\ntype GetEndpointsResult = {\n\t[id: ProviderID]: KeetaKYCVerificationServiceInfo;\n};\n\nconst isKeetaKYCAnchorCreateVerificationResponse = createIs<KeetaKYCAnchorCreateVerificationResponse>();\nconst isKeetaKYCAnchorGetCertificateResponse = createIs<KeetaKYCAnchorGetCertificateResponse>();\nconst isKeetaKYCAnchorGetVerificationStatusResponse = createIs<KeetaKYCAnchorGetVerificationStatusResponse>();\nconst isKeetaKYCAnchorGetVerificationURLResponse = createIs<KeetaKYCAnchorGetVerificationURLResponse>();\n\nasync function getEndpoints(resolver: Resolver, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'>): Promise<GetEndpointsResult | null> {\n\tconst response = await resolver.lookup('kyc', {\n\t\tcountryCodes: request.countryCodes,\n\t\t...(request.entityType !== undefined ? { entityType: request.entityType } : {})\n\t});\n\n\tif (response === undefined) {\n\t\treturn(null);\n\t}\n\n\tconst serviceInfoPromises = Object.entries(response).map(async function([id, serviceInfo]): Promise<[ProviderID, KeetaKYCVerificationServiceInfo]> {\n\t\tconst countryCodesPromises = (await serviceInfo.countryCodes?.('array'))?.map(async function(countryCode) {\n\t\t\treturn(new CurrencyInfo.Country(CurrencyInfo.Country.assertCountryCode(await countryCode('string'))));\n\t\t});\n\n\t\tlet countryCodes: CurrencyInfo.Country[] | undefined;\n\t\tif (countryCodesPromises !== undefined) {\n\t\t\tconst countryCodesResults = await Promise.allSettled(countryCodesPromises);\n\t\t\tcountryCodes = countryCodesResults.map(function(result) {\n\t\t\t\tif (result.status === 'fulfilled') {\n\t\t\t\t\treturn(result.value);\n\t\t\t\t}\n\t\t\t\tthrow(result.reason);\n\t\t\t});\n\t\t}\n\n\t\tconst operations = await serviceInfo.operations('object');\n\t\tconst operationsFunctions: KeetaKYCVerificationServiceInfo['operations'] = {};\n\t\tfor (const [key, operation] of Object.entries(operations)) {\n\t\t\tif (operation === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tObject.defineProperty(operationsFunctions, key, {\n\t\t\t\tget: async function() {\n\t\t\t\t\tconst url = await operation('string');\n\t\t\t\t\treturn(function(params?: { [key: string]: string; }): URL {\n\t\t\t\t\t\tlet substitutedURL = url;\n\t\t\t\t\t\tfor (const [paramKey, paramValue] of Object.entries(params ?? {})) {\n\t\t\t\t\t\t\tsubstitutedURL = substitutedURL.replace(`{${paramKey}}`, encodeURIComponent(paramValue));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn(validateURL(substitutedURL));\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true\n\t\t\t});\n\t\t}\n\t\treturn([\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tid as ProviderID,\n\t\t\t{\n\t\t\t\tcountryCodes: countryCodes,\n\t\t\t\toperations: operationsFunctions,\n\t\t\t\tca: async function() {\n\t\t\t\t\tconst certificatePEM = await serviceInfo.ca?.('string');\n\t\t\t\t\tconst certificate = new KYCCertificate(certificatePEM);\n\n\t\t\t\t\treturn(certificate);\n\t\t\t\t}\n\t\t\t}\n\t\t]);\n\t});\n\n\tconst retval = Object.fromEntries(await Promise.all(serviceInfoPromises));\n\n\treturn(retval);\n}\n\ntype KeetaKYCAnchorCommonConfig = {\n\tid: ProviderID;\n\tserviceInfo: KeetaKYCVerificationServiceInfo;\n\trequest: KeetaKYCAnchorCreateVerificationRequest;\n\taccount: SignableAccount;\n\tclient: KeetaKYCAnchorClient;\n\toperations: NonNullable<Pick<KeetaKYCAnchorOperations, 'createVerification' | 'getCertificates' | 'getVerificationStatus'>>;\n\tlogger?: Logger | undefined;\n};\n\n/**\n * Represents an in-progress KYC verification request.\n */\nclass KeetaKYCVerification {\n\treadonly providerID: KeetaKYCAnchorCommonConfig['id'];\n\treadonly id: RequestID;\n\tprivate readonly serviceInfo: KeetaKYCAnchorCommonConfig['serviceInfo'];\n\tprivate readonly request: KeetaKYCAnchorCommonConfig['request'];\n\tprivate readonly account: KeetaKYCAnchorCommonConfig['account'];\n\tprivate readonly logger?: KeetaKYCAnchorCommonConfig['logger'] | undefined;\n\tprivate readonly client: KeetaKYCAnchorCommonConfig['client'];\n\tprivate readonly response: Extract<KeetaKYCAnchorCreateVerificationResponse, { ok: true }>;\n\n\tprivate constructor(args: KeetaKYCAnchorCommonConfig, response: Extract<KeetaKYCAnchorCreateVerificationResponse, { ok: true }>) {\n\t\tthis.providerID = args.id;\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tthis.id = response.id as RequestID;\n\t\tthis.serviceInfo = args.serviceInfo;\n\t\tthis.request = args.request;\n\t\tthis.account = args.account;\n\t\tthis.client = args.client;\n\t\tthis.logger = args.logger;\n\t\tthis.response = response;\n\n\t\tthis.logger?.debug(`Created KYC verification for provider ID: ${this.providerID}, request: ${JSON.stringify(args.request)}, response: ${JSON.stringify(response)}`);\n\t}\n\n\tstatic async start(args: KeetaKYCAnchorCommonConfig): Promise<KeetaKYCVerification> {\n\t\targs.logger?.debug(`Starting KYC verification for provider ID: ${args.id}, request: ${JSON.stringify(args.request)}`);\n\n\t\tconst endpoints = args.operations;\n\t\tconst createVerification = endpoints.createVerification?.();\n\t\tif (createVerification === undefined) {\n\t\t\tthrow(new Error('KYC verification service does not support createVerification operation'));\n\t\t}\n\n\t\tconst requestInformation = await fetch(createVerification, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Accept': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\trequest: args.request\n\t\t\t})\n\t\t});\n\n\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\tif (!isKeetaKYCAnchorCreateVerificationResponse(requestInformationJSON)) {\n\t\t\tthrow(new Error(`Invalid response from KYC verification service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t}\n\n\t\tif (!requestInformationJSON.ok) {\n\t\t\tthrow(new Error(`KYC verification request failed: ${requestInformationJSON.error}`));\n\t\t}\n\n\t\targs.logger?.debug(`KYC verification request successful, request ID ${requestInformationJSON.id}`);\n\n\t\treturn(new KeetaKYCVerification(args, requestInformationJSON));\n\n\t}\n\n\tget expectedCost(): typeof this.response.expectedCost {\n\t\treturn(this.response.expectedCost);\n\t}\n\n\tget webURL(): URL {\n\t\treturn(validateURL(this.response.webURL));\n\t}\n\n\tasync getProviderIssuerCertificate(): Promise<KYCCertificate> {\n\t\treturn(await this.serviceInfo.ca());\n\t}\n\n\tgetCertificates(): Promise<KeetaKYCAnchorClientGetCertificateResponse> {\n\t\treturn(this.client.getCertificates(this.providerID, {\n\t\t\tid: this.id,\n\t\t\t...this.request\n\t\t}));\n\t}\n\n\tgetVerificationStatus(): Promise<KeetaKYCAnchorClientGetVerificationStatusResponse> {\n\t\treturn(this.client.getVerificationStatus(this.providerID, {\n\t\t\tid: this.id,\n\t\t\taccount: this.account,\n\t\t\tcountryCodes: this.request.countryCodes,\n\t\t\t...(this.request.entityType !== undefined ? { entityType: this.request.entityType } : {})\n\t\t}));\n\t}\n\n\tgetVerificationURL(): Promise<URL | null> {\n\t\treturn(this.client.getVerificationURL(this.providerID, {\n\t\t\tid: this.id,\n\t\t\taccount: this.account,\n\t\t\tcountryCodes: this.request.countryCodes,\n\t\t\t...(this.request.entityType !== undefined ? { entityType: this.request.entityType } : {})\n\t\t}));\n\t}\n}\n\n/**\n * Represents the KYC operations for a specific provider\n */\nclass KeetaKYCProvider {\n\treadonly id: ProviderID;\n\tprivate readonly serviceInfo: KeetaKYCVerificationServiceInfo;\n\tprivate readonly request: KeetaKYCAnchorCreateVerificationRequest;\n\tprivate readonly account: SignableAccount;\n\tprivate readonly logger?: Logger | undefined;\n\tprivate readonly client: KeetaKYCAnchorClient;\n\tprivate readonly operations: NonNullable<Pick<KeetaKYCAnchorOperations, 'createVerification' | 'getCertificates' | 'getVerificationStatus'>>;\n\n\tprivate cachedCA?: KYCCertificate;\n\n\tconstructor(args: KeetaKYCAnchorCommonConfig) {\n\t\tthis.id = args.id;\n\t\tthis.serviceInfo = args.serviceInfo;\n\t\tthis.request = args.request;\n\t\tthis.account = args.account;\n\t\tthis.client = args.client;\n\t\tthis.operations = args.operations;\n\t\tthis.logger = args.logger;\n\n\t\tthis.logger?.debug(`Created KYC verification for provider ID: ${args.id}, request: ${JSON.stringify(args.request)}`);\n\t}\n\n\tasync countryCodes(): Promise<CurrencyInfo.Country[] | undefined> {\n\t\treturn(this.serviceInfo.countryCodes);\n\t}\n\n\tasync ca(): Promise<KYCCertificate> {\n\t\tif (this.cachedCA !== undefined) {\n\t\t\treturn(this.cachedCA);\n\t\t}\n\n\t\tthis.cachedCA = await this.serviceInfo.ca();\n\n\t\treturn(this.cachedCA);\n\t}\n\n\tasync startVerification(): Promise<KeetaKYCVerification> {\n\t\treturn(await KeetaKYCVerification.start({\n\t\t\tid: this.id,\n\t\t\tserviceInfo: this.serviceInfo,\n\t\t\trequest: this.request,\n\t\t\taccount: this.account,\n\t\t\tclient: this.client,\n\t\t\toperations: this.operations,\n\t\t\tlogger: this.logger\n\t\t}));\n\t}\n}\n\n\nclass KeetaKYCAnchorClient {\n\treadonly resolver: Resolver;\n\treadonly id: string;\n\tprivate readonly logger?: Logger | undefined;\n\n\tconstructor(client: KeetaNetClient | KeetaNetUserClient, config: KeetaKYCAnchorClientConfig = {}) {\n\t\tthis.resolver = config.resolver ?? getDefaultResolver(client, config);\n\t\tthis.id = config.id ?? crypto.randomUUID();\n\t\tthis.logger = config.logger;\n\t}\n\n\tasync createVerification(request: KeetaKYCAnchorClientCreateVerificationRequest): Promise<KeetaKYCProvider[]> {\n\t\tconst signedData = await generateSignedData(request.account.assertAccount());\n\n\t\tif (PARANOID) {\n\t\t\tconst check = await verifySignedData({ account: request.account.publicKeyString.get(), signed: signedData });\n\t\t\tif (!check) {\n\t\t\t\tthrow(new Error('Failed to verify signed data'));\n\t\t\t}\n\t\t}\n\n\t\tconst signedRequest: KeetaKYCAnchorCreateVerificationRequest = {\n\t\t\t...request,\n\t\t\taccount: request.account.publicKeyString.get(),\n\t\t\tsigned: signedData\n\t\t};\n\n\t\t/* Only provider selection defaults to individual; the by-ID lookups below must not filter. */\n\t\tconst endpoints = await getEndpoints(this.resolver, {\n\t\t\tcountryCodes: signedRequest.countryCodes,\n\t\t\tentityType: signedRequest.entityType ?? 'individual'\n\t\t});\n\t\tif (endpoints === null) {\n\t\t\tthrow(new Error('No KYC endpoints found for the given criteria'));\n\t\t}\n\n\t\tconst validEndpoints = await Promise.allSettled(Object.entries(endpoints).map(async ([id, serviceInfo]) => {\n\t\t\tconst endpoints = serviceInfo.operations;\n\t\t\t/*\n\t\t\t * Verify that we have the required operations\n\t\t\t * available to perform a KYC verification.\n\t\t\t */\n\t\t\tconst createVerification = await endpoints.createVerification;\n\t\t\tconst getCertificates = await endpoints.getCertificates;\n\t\t\tconst getVerificationStatus = await endpoints.getVerificationStatus;\n\t\t\tif (createVerification === undefined || getCertificates === undefined || getVerificationStatus === undefined) {\n\t\t\t\tthis.logger?.warn(`KYC verification provider ${id} does not support required operations (createVerification, getCertificates, getVerificationStatus)`);\n\n\t\t\t\treturn(null);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * We can safely cast the ID to a ProviderID because it's a branded type\n\t\t\t * for this specific type\n\t\t\t */\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tconst providerID = id as ProviderID;\n\t\t\treturn(new KeetaKYCProvider({\n\t\t\t\tid: providerID,\n\t\t\t\tserviceInfo: serviceInfo,\n\t\t\t\trequest: signedRequest,\n\t\t\t\taccount: request.account.assertAccount(),\n\t\t\t\tclient: this,\n\t\t\t\tlogger: this.logger,\n\t\t\t\toperations: {\n\t\t\t\t\tcreateVerification,\n\t\t\t\t\tgetCertificates,\n\t\t\t\t\tgetVerificationStatus\n\t\t\t\t}\n\t\t\t}));\n\t\t}));\n\n\t\t/*\n\t\t * Filter out any endpoints that were not able to be resolved\n\t\t * or that did not have the required operations.\n\t\t */\n\t\tconst retval = validEndpoints.map(function(result) {\n\t\t\tif (result.status !== 'fulfilled') {\n\t\t\t\treturn(null);\n\t\t\t}\n\t\t\tif (result.value === null) {\n\t\t\t\treturn(null);\n\t\t\t}\n\t\t\treturn(result.value);\n\t\t}).filter(function(result) {\n\t\t\treturn(result !== null);\n\t\t});\n\n\t\tif (retval.length === 0) {\n\t\t\tthrow(new Error('No valid KYC verification endpoints found'));\n\t\t}\n\n\t\treturn(retval);\n\t}\n\n\tasync getCertificates(providerID: ProviderID, request: KeetaKYCAnchorCreateVerificationRequest & { id: RequestID; }): Promise<KeetaKYCAnchorClientGetCertificateResponse> {\n\t\tconst endpoints = await getEndpoints(this.resolver, request);\n\t\tif (endpoints === null) {\n\t\t\tthrow(new Error('No KYC endpoints found for the given criteria'));\n\t\t}\n\t\tconst providerEndpoints = endpoints[providerID];\n\t\tif (providerEndpoints === undefined) {\n\t\t\tthrow(new Error(`No KYC endpoints found for provider ID: ${providerID}`));\n\t\t}\n\n\t\tconst requestID = request.id;\n\t\tconst operations = providerEndpoints.operations;\n\t\tconst getCertificate = (await operations.getCertificates)?.({ id: requestID });\n\t\tif (getCertificate === undefined) {\n\t\t\tthrow(new Error('internal error: KYC verification service does not support getCertificate operation'));\n\t\t}\n\n\t\tconst response = await fetch(getCertificate, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Accept': 'application/json'\n\t\t\t}\n\t\t});\n\n\t\t/*\n\t\t * Handle retryable errors by passing them up to the caller to\n\t\t * retry.\n\t\t */\n\t\tif (response.status === 404) {\n\t\t\treturn({\n\t\t\t\tok: false,\n\t\t\t\tretryAfter: 500,\n\t\t\t\treason: 'Certificate not found'\n\t\t\t});\n\t\t}\n\n\t\t/*\n\t\t * Handle other errors as fatal errors that should not be retried.\n\t\t */\n\t\tif (!response.ok) {\n\t\t\tthrow(new Error(`Failed to get certificate: ${response.statusText}`));\n\t\t}\n\n\t\tconst responseJSON: unknown = await response.json();\n\t\tif (!isKeetaKYCAnchorGetCertificateResponse(responseJSON)) {\n\t\t\tthrow(new Error(`Invalid response from KYC certificate service: ${JSON.stringify(responseJSON)}`));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(new Error(`KYC certificate request failed: ${responseJSON.error}`));\n\t\t}\n\n\t\treturn({\n\t\t\tok: true,\n\t\t\tresults: responseJSON.results.map(function(result) {\n\t\t\t\tconst intermediates = result.intermediates?.map(function(intermediate) {\n\t\t\t\t\treturn(new KeetaNetLib.Utils.Certificate.Certificate(intermediate));\n\t\t\t\t});\n\n\t\t\t\tlet intermediatesSet;\n\t\t\t\tif (intermediates !== undefined && intermediates.length > 0) {\n\t\t\t\t\tintermediatesSet = new Set(intermediates);\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\tcertificate: new KYCCertificate(result.certificate),\n\t\t\t\t\tintermediates: intermediatesSet\n\t\t\t\t});\n\t\t\t})\n\t\t});\n\t}\n\n\tasync getSupportedCountries(entityType: KYCEntityType = 'individual'): Promise<CurrencyInfo.Country[]> {\n\t\treturn(await this.resolver.listSupportedKYCCountries(entityType));\n\t}\n\n\tasync getVerificationStatus(providerID: ProviderID, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'> & { id: RequestID; account: SignableAccount; }): Promise<KeetaKYCAnchorClientGetVerificationStatusResponse> {\n\t\tconst endpoints = await getEndpoints(this.resolver, request);\n\t\tif (endpoints === null) {\n\t\t\tthrow(new Error('No KYC endpoints found for the given criteria'));\n\t\t}\n\n\t\tconst providerEndpoints = endpoints[providerID];\n\t\tif (providerEndpoints === undefined) {\n\t\t\tthrow(new Error(`No KYC endpoints found for provider ID: ${providerID}`));\n\t\t}\n\n\t\tconst operations = providerEndpoints.operations;\n\t\tconst getVerificationStatus = (await operations.getVerificationStatus)?.({ id: request.id });\n\t\tif (getVerificationStatus === undefined) {\n\t\t\tthrow(new Error('internal error: KYC verification service does not support getVerificationStatus operation'));\n\t\t}\n\n\t\tconst signed = await SignData(request.account, []);\n\t\tconst signedURL = addSignatureToURL(getVerificationStatus, {\n\t\t\tsignedField: signed,\n\t\t\taccount: request.account\n\t\t});\n\n\t\tconst response = await fetch(signedURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Accept': 'application/json'\n\t\t\t}\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow(new Error(`Failed to get verification status: ${response.statusText}`));\n\t\t}\n\n\t\tconst responseJSON: unknown = await response.json();\n\t\tif (!isKeetaKYCAnchorGetVerificationStatusResponse(responseJSON)) {\n\t\t\tthrow(new Error(`Invalid response from KYC status service: ${JSON.stringify(responseJSON)}`));\n\t\t}\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(new Error(`KYC status request failed: ${responseJSON.error}`));\n\t\t}\n\n\t\tconst result: KeetaKYCAnchorClientGetVerificationStatusResponse = {\n\t\t\tstatus: responseJSON.status\n\t\t};\n\t\tif (responseJSON.requiresManualVerification !== undefined) {\n\t\t\tresult.requiresManualVerification = responseJSON.requiresManualVerification;\n\t\t}\n\n\t\treturn(result);\n\t}\n\n\t/**\n\t * Get a new link to continue an existing verification, or null if the provider does not offer one\n\t */\n\tasync getVerificationURL(providerID: ProviderID, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'> & { id: RequestID; account: SignableAccount; }): Promise<URL | null> {\n\t\tconst endpoints = await getEndpoints(this.resolver, request);\n\t\tif (endpoints === null) {\n\t\t\tthrow(new Error('No KYC endpoints found for the given criteria'));\n\t\t}\n\n\t\tconst providerEndpoints = endpoints[providerID];\n\t\tif (providerEndpoints === undefined) {\n\t\t\tthrow(new Error(`No KYC endpoints found for provider ID: ${providerID}`));\n\t\t}\n\n\t\tconst getVerificationURL = (await providerEndpoints.operations.getVerificationURL)?.({ id: request.id });\n\t\tif (getVerificationURL === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst signed = await SignData(request.account, []);\n\t\tconst signedURL = addSignatureToURL(getVerificationURL, {\n\t\t\tsignedField: signed,\n\t\t\taccount: request.account\n\t\t});\n\n\t\tconst response = await fetch(signedURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Accept': 'application/json'\n\t\t\t}\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow(new Error(`Failed to get verification URL: ${response.statusText}`));\n\t\t}\n\n\t\tconst responseJSON: unknown = await response.json();\n\t\tif (!isKeetaKYCAnchorGetVerificationURLResponse(responseJSON)) {\n\t\t\tthrow(new Error(`Invalid response from KYC verification URL service: ${JSON.stringify(responseJSON)}`));\n\t\t}\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(new Error(`KYC verification URL request failed: ${responseJSON.error}`));\n\t\t}\n\n\t\treturn(validateURL(responseJSON.webURL));\n\t}\n\n\tasync getEstimate(..._ignore_args: unknown[]): Promise<never> {\n\t\tthrow(new Error('not implemented'));\n\t}\n\n\tasync checkLocality(..._ignore_args: unknown[]): Promise<never> {\n\t\tthrow(new Error('not implemented'));\n\t}\n}\n\nexport default KeetaKYCAnchorClient;\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/services/kyc/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAgB1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAKvE,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAkGrD,MAAM,0CAA0C;;;;;;;sFAAuD,CAAC;AACxG,MAAM,sCAAsC;;;;;;;sFAAmD,CAAC;AAChG,MAAM,6CAA6C;;;;;;;sFAA0D,CAAC;AAC9G,MAAM,0CAA0C;;;;;;;sFAAuD,CAAC;AAExG,KAAK,UAAU,YAAY,CAAC,QAAkB,EAAE,OAAqF;IACpI,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE;QAC7C,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/E,CAAC,CAAC;IAEH,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAM,CAAC,IAAI,CAAC,CAAC;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AK,CAAC,mCAAmC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,YAAY,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpD,IAAI,CAAC,0CAA0C,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/D,MAAK,CAAC,IAAI,KAAK,CAAC,uDAAuD,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;QACzG,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;YACtB,MAAK,CAAC,IAAI,KAAK,CAAC,wCAAwC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAChF,CAAC;QAED,OAAM,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,GAAG,YAAuB;QAC3C,MAAK,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,GAAG,YAAuB;QAC7C,MAAK,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACrC,CAAC;CACD;AAED,eAAe,oBAAoB,CAAC","sourcesContent":["import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\nimport * as CurrencyInfo from '@keetanetwork/currency-info';\nimport { createIs } from 'typia';\n\nimport { getDefaultResolver } from '../../config.js';\nimport { Certificate as KYCCertificate } from '../../lib/certificates.js';\n\nimport type {\n\tClient as KeetaNetClient,\n\tUserClient as KeetaNetUserClient\n} from '@keetanetwork/keetanet-client';\nimport type {\n\tKeetaKYCAnchorCreateVerificationRequest,\n\tKeetaKYCAnchorCreateVerificationResponse,\n\tKeetaKYCAnchorGetCertificateResponse,\n\tKeetaKYCAnchorGetVerificationStatusResponse,\n\tKeetaKYCAnchorGetVerificationURLResponse\n} from './common.ts';\nimport type {\n\tKYCVerificationStatus\n} from './status.js';\nimport { addSignatureToURL } from '../../lib/http-server/common.js';\nimport { signRequest } from '../../lib/http-server/request-signing.js';\nimport type { SignableAccount } from '../../lib/utils/signing.js';\nimport type { Logger } from '../../lib/log/index.ts';\nimport type Resolver from '../../lib/resolver.ts';\nimport type { KYCEntityType, ServiceMetadata } from '../../lib/resolver.ts';\nimport crypto from '../../lib/utils/crypto.js';\nimport { validateURL } from '../../lib/utils/url.js';\n\n/**\n * The configuration options for the KYC Anchor client.\n */\nexport type KeetaKYCAnchorClientConfig = {\n\t/**\n\t * The ID of the client. This is used to identify the client in logs.\n\t * If not provided, a random ID will be generated.\n\t */\n\tid?: string;\n\t/**\n\t * The logger to use for logging messages. If not provided, no logging\n\t * will be done.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * The resolver to use for resolving KYC Anchor services. If not\n\t * provided, a default resolver will be created using the provided\n\t * client and network (if the network is also not provided and the\n\t * client is not a UserClient, an error occurs).\n\t */\n\tresolver?: Resolver;\n} & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'>;\n\n/**\n * Any kind of X.509v3 Certificate. This may or may not be a KYC certificate.\n */\ntype BaseCertificate = InstanceType<typeof KeetaNetLib.Utils.Certificate.Certificate>;\n\n/**\n * The response type for the {@link KeetaKYCAnchorClient['getCertificates']()} method of the KYC Anchor client.\n * It contains the certificate and optionally a set of intermediate certificates.\n */\ntype KeetaKYCAnchorClientGetCertificateResponse = ({\n\tok: true;\n\tresults: {\n\t\tcertificate: KYCCertificate;\n\t\tintermediates?: Set<BaseCertificate> | undefined;\n\t}[]\n} | {\n\tok: false;\n\tretryAfter: number;\n\treason: string;\n});\n\n/**\n * The response type for {@link KeetaKYCAnchorClient['getVerificationStatus']()}.\n */\ntype KeetaKYCAnchorClientGetVerificationStatusResponse = {\n\tstatus: KYCVerificationStatus;\n\trequiresManualVerification?: boolean;\n};\n\ntype KeetaKYCAnchorClientCreateVerificationRequest = Omit<KeetaKYCAnchorCreateVerificationRequest, 'signed' | 'account'> & {\n\taccount: InstanceType<typeof KeetaNetLib.Account>;\n};\n\n/**\n * An opaque type that represents a provider ID.\n */\ntype ProviderID = string & {\n\treadonly __providerID: unique symbol;\n};\n\n/**\n * An opaque type that represents a KYC Anchor request ID\n */\ntype RequestID = string & {\n\treadonly __requestID: unique symbol;\n};\n\n/**\n * A list of operations that can be performed by the KYC Anchor service.\n */\ntype KeetaKYCAnchorOperations = {\n\t[operation in keyof NonNullable<ServiceMetadata['services']['kyc']>[string]['operations']]?: (params?: { [key: string]: string; }) => URL;\n};\n\n/**\n * The service information for a KYC Anchor service.\n */\ntype KeetaKYCVerificationServiceInfo = {\n\toperations: {\n\t\t[operation in keyof KeetaKYCAnchorOperations]: Promise<KeetaKYCAnchorOperations[operation]>;\n\t};\n\tcountryCodes?: CurrencyInfo.Country[] | undefined;\n\tca: () => Promise<KYCCertificate>;\n};\n\n/**\n * For each matching KYC Anchor service, this type describes the\n * operations available and the country codes that the service supports.\n */\ntype GetEndpointsResult = {\n\t[id: ProviderID]: KeetaKYCVerificationServiceInfo;\n};\n\nconst isKeetaKYCAnchorCreateVerificationResponse = createIs<KeetaKYCAnchorCreateVerificationResponse>();\nconst isKeetaKYCAnchorGetCertificateResponse = createIs<KeetaKYCAnchorGetCertificateResponse>();\nconst isKeetaKYCAnchorGetVerificationStatusResponse = createIs<KeetaKYCAnchorGetVerificationStatusResponse>();\nconst isKeetaKYCAnchorGetVerificationURLResponse = createIs<KeetaKYCAnchorGetVerificationURLResponse>();\n\nasync function getEndpoints(resolver: Resolver, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'>): Promise<GetEndpointsResult | null> {\n\tconst response = await resolver.lookup('kyc', {\n\t\tcountryCodes: request.countryCodes,\n\t\t...(request.entityType !== undefined ? { entityType: request.entityType } : {})\n\t});\n\n\tif (response === undefined) {\n\t\treturn(null);\n\t}\n\n\tconst serviceInfoPromises = Object.entries(response).map(async function([id, serviceInfo]): Promise<[ProviderID, KeetaKYCVerificationServiceInfo]> {\n\t\tconst countryCodesPromises = (await serviceInfo.countryCodes?.('array'))?.map(async function(countryCode) {\n\t\t\treturn(new CurrencyInfo.Country(CurrencyInfo.Country.assertCountryCode(await countryCode('string'))));\n\t\t});\n\n\t\tlet countryCodes: CurrencyInfo.Country[] | undefined;\n\t\tif (countryCodesPromises !== undefined) {\n\t\t\tconst countryCodesResults = await Promise.allSettled(countryCodesPromises);\n\t\t\tcountryCodes = countryCodesResults.map(function(result) {\n\t\t\t\tif (result.status === 'fulfilled') {\n\t\t\t\t\treturn(result.value);\n\t\t\t\t}\n\t\t\t\tthrow(result.reason);\n\t\t\t});\n\t\t}\n\n\t\tconst operations = await serviceInfo.operations('object');\n\t\tconst operationsFunctions: KeetaKYCVerificationServiceInfo['operations'] = {};\n\t\tfor (const [key, operation] of Object.entries(operations)) {\n\t\t\tif (operation === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tObject.defineProperty(operationsFunctions, key, {\n\t\t\t\tget: async function() {\n\t\t\t\t\tconst url = await operation('string');\n\t\t\t\t\treturn(function(params?: { [key: string]: string; }): URL {\n\t\t\t\t\t\tlet substitutedURL = url;\n\t\t\t\t\t\tfor (const [paramKey, paramValue] of Object.entries(params ?? {})) {\n\t\t\t\t\t\t\tsubstitutedURL = substitutedURL.replace(`{${paramKey}}`, encodeURIComponent(paramValue));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn(validateURL(substitutedURL));\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true\n\t\t\t});\n\t\t}\n\t\treturn([\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tid as ProviderID,\n\t\t\t{\n\t\t\t\tcountryCodes: countryCodes,\n\t\t\t\toperations: operationsFunctions,\n\t\t\t\tca: async function() {\n\t\t\t\t\tconst certificatePEM = await serviceInfo.ca?.('string');\n\t\t\t\t\tconst certificate = new KYCCertificate(certificatePEM);\n\n\t\t\t\t\treturn(certificate);\n\t\t\t\t}\n\t\t\t}\n\t\t]);\n\t});\n\n\tconst retval = Object.fromEntries(await Promise.all(serviceInfoPromises));\n\n\treturn(retval);\n}\n\n/**\n * A verification request before it is signed for one provider.\n */\ntype KeetaKYCAnchorUnsignedVerificationRequest = Omit<KeetaKYCAnchorCreateVerificationRequest, 'signed'>;\n\ntype KeetaKYCAnchorCommonConfig = {\n\tid: ProviderID;\n\tserviceInfo: KeetaKYCVerificationServiceInfo;\n\trequest: KeetaKYCAnchorUnsignedVerificationRequest;\n\taccount: SignableAccount;\n\tclient: KeetaKYCAnchorClient;\n\toperations: NonNullable<Pick<KeetaKYCAnchorOperations, 'createVerification' | 'getCertificates' | 'getVerificationStatus'>>;\n\tlogger?: Logger | undefined;\n};\n\n/**\n * Represents an in-progress KYC verification request.\n */\nclass KeetaKYCVerification {\n\treadonly providerID: KeetaKYCAnchorCommonConfig['id'];\n\treadonly id: RequestID;\n\tprivate readonly serviceInfo: KeetaKYCAnchorCommonConfig['serviceInfo'];\n\tprivate readonly request: KeetaKYCAnchorCommonConfig['request'];\n\tprivate readonly account: KeetaKYCAnchorCommonConfig['account'];\n\tprivate readonly logger?: KeetaKYCAnchorCommonConfig['logger'] | undefined;\n\tprivate readonly client: KeetaKYCAnchorCommonConfig['client'];\n\tprivate readonly response: Extract<KeetaKYCAnchorCreateVerificationResponse, { ok: true }>;\n\n\tprivate constructor(args: KeetaKYCAnchorCommonConfig, response: Extract<KeetaKYCAnchorCreateVerificationResponse, { ok: true }>) {\n\t\tthis.providerID = args.id;\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tthis.id = response.id as RequestID;\n\t\tthis.serviceInfo = args.serviceInfo;\n\t\tthis.request = args.request;\n\t\tthis.account = args.account;\n\t\tthis.client = args.client;\n\t\tthis.logger = args.logger;\n\t\tthis.response = response;\n\n\t\tthis.logger?.debug(`Created KYC verification for provider ID: ${this.providerID}, request: ${JSON.stringify(args.request)}, response: ${JSON.stringify(response)}`);\n\t}\n\n\tstatic async start(args: KeetaKYCAnchorCommonConfig): Promise<KeetaKYCVerification> {\n\t\targs.logger?.debug(`Starting KYC verification for provider ID: ${args.id}, request: ${JSON.stringify(args.request)}`);\n\n\t\tconst endpoints = args.operations;\n\t\tconst createVerification = endpoints.createVerification?.();\n\t\tif (createVerification === undefined) {\n\t\t\tthrow(new Error('KYC verification service does not support createVerification operation'));\n\t\t}\n\n\t\tconst signed = await signRequest(args.account, { method: 'POST', url: createVerification, body: args.request }, []);\n\t\tconst requestInformation = await fetch(createVerification, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Accept': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\trequest: { ...args.request, signed }\n\t\t\t})\n\t\t});\n\n\t\tconst requestInformationJSON: unknown = await requestInformation.json();\n\t\tif (!isKeetaKYCAnchorCreateVerificationResponse(requestInformationJSON)) {\n\t\t\tthrow(new Error(`Invalid response from KYC verification service: ${JSON.stringify(requestInformationJSON)}`));\n\t\t}\n\n\t\tif (!requestInformationJSON.ok) {\n\t\t\tthrow(new Error(`KYC verification request failed: ${requestInformationJSON.error}`));\n\t\t}\n\n\t\targs.logger?.debug(`KYC verification request successful, request ID ${requestInformationJSON.id}`);\n\n\t\treturn(new KeetaKYCVerification(args, requestInformationJSON));\n\n\t}\n\n\tget expectedCost(): typeof this.response.expectedCost {\n\t\treturn(this.response.expectedCost);\n\t}\n\n\tget webURL(): URL {\n\t\treturn(validateURL(this.response.webURL));\n\t}\n\n\tasync getProviderIssuerCertificate(): Promise<KYCCertificate> {\n\t\treturn(await this.serviceInfo.ca());\n\t}\n\n\tgetCertificates(): Promise<KeetaKYCAnchorClientGetCertificateResponse> {\n\t\tconst request: Parameters<KeetaKYCAnchorClient['getCertificates']>[1] = {\n\t\t\tid: this.id,\n\t\t\taccount: this.account,\n\t\t\tcountryCodes: this.request.countryCodes\n\t\t};\n\t\tif (this.request.entityType !== undefined) {\n\t\t\trequest.entityType = this.request.entityType;\n\t\t}\n\n\t\treturn(this.client.getCertificates(this.providerID, request));\n\t}\n\n\tgetVerificationStatus(): Promise<KeetaKYCAnchorClientGetVerificationStatusResponse> {\n\t\treturn(this.client.getVerificationStatus(this.providerID, {\n\t\t\tid: this.id,\n\t\t\taccount: this.account,\n\t\t\tcountryCodes: this.request.countryCodes,\n\t\t\t...(this.request.entityType !== undefined ? { entityType: this.request.entityType } : {})\n\t\t}));\n\t}\n\n\tgetVerificationURL(): Promise<URL | null> {\n\t\treturn(this.client.getVerificationURL(this.providerID, {\n\t\t\tid: this.id,\n\t\t\taccount: this.account,\n\t\t\tcountryCodes: this.request.countryCodes,\n\t\t\t...(this.request.entityType !== undefined ? { entityType: this.request.entityType } : {})\n\t\t}));\n\t}\n}\n\n/**\n * Represents the KYC operations for a specific provider\n */\nclass KeetaKYCProvider {\n\treadonly id: ProviderID;\n\tprivate readonly serviceInfo: KeetaKYCVerificationServiceInfo;\n\tprivate readonly request: KeetaKYCAnchorUnsignedVerificationRequest;\n\tprivate readonly account: SignableAccount;\n\tprivate readonly logger?: Logger | undefined;\n\tprivate readonly client: KeetaKYCAnchorClient;\n\tprivate readonly operations: NonNullable<Pick<KeetaKYCAnchorOperations, 'createVerification' | 'getCertificates' | 'getVerificationStatus'>>;\n\n\tprivate cachedCA?: KYCCertificate;\n\n\tconstructor(args: KeetaKYCAnchorCommonConfig) {\n\t\tthis.id = args.id;\n\t\tthis.serviceInfo = args.serviceInfo;\n\t\tthis.request = args.request;\n\t\tthis.account = args.account;\n\t\tthis.client = args.client;\n\t\tthis.operations = args.operations;\n\t\tthis.logger = args.logger;\n\n\t\tthis.logger?.debug(`Created KYC verification for provider ID: ${args.id}, request: ${JSON.stringify(args.request)}`);\n\t}\n\n\tasync countryCodes(): Promise<CurrencyInfo.Country[] | undefined> {\n\t\treturn(this.serviceInfo.countryCodes);\n\t}\n\n\tasync ca(): Promise<KYCCertificate> {\n\t\tif (this.cachedCA !== undefined) {\n\t\t\treturn(this.cachedCA);\n\t\t}\n\n\t\tthis.cachedCA = await this.serviceInfo.ca();\n\n\t\treturn(this.cachedCA);\n\t}\n\n\tasync startVerification(): Promise<KeetaKYCVerification> {\n\t\treturn(await KeetaKYCVerification.start({\n\t\t\tid: this.id,\n\t\t\tserviceInfo: this.serviceInfo,\n\t\t\trequest: this.request,\n\t\t\taccount: this.account,\n\t\t\tclient: this.client,\n\t\t\toperations: this.operations,\n\t\t\tlogger: this.logger\n\t\t}));\n\t}\n}\n\n\nclass KeetaKYCAnchorClient {\n\treadonly resolver: Resolver;\n\treadonly id: string;\n\tprivate readonly logger?: Logger | undefined;\n\n\tconstructor(client: KeetaNetClient | KeetaNetUserClient, config: KeetaKYCAnchorClientConfig = {}) {\n\t\tthis.resolver = config.resolver ?? getDefaultResolver(client, config);\n\t\tthis.id = config.id ?? crypto.randomUUID();\n\t\tthis.logger = config.logger;\n\t}\n\n\tasync createVerification(request: KeetaKYCAnchorClientCreateVerificationRequest): Promise<KeetaKYCProvider[]> {\n\t\tconst unsignedRequest: KeetaKYCAnchorUnsignedVerificationRequest = {\n\t\t\t...request,\n\t\t\taccount: request.account.publicKeyString.get()\n\t\t};\n\n\t\t/* Only provider selection defaults to individual; the by-ID lookups below must not filter. */\n\t\tconst endpoints = await getEndpoints(this.resolver, {\n\t\t\tcountryCodes: unsignedRequest.countryCodes,\n\t\t\tentityType: unsignedRequest.entityType ?? 'individual'\n\t\t});\n\t\tif (endpoints === null) {\n\t\t\tthrow(new Error('No KYC endpoints found for the given criteria'));\n\t\t}\n\n\t\tconst validEndpoints = await Promise.allSettled(Object.entries(endpoints).map(async ([id, serviceInfo]) => {\n\t\t\tconst endpoints = serviceInfo.operations;\n\t\t\t/*\n\t\t\t * Verify that we have the required operations\n\t\t\t * available to perform a KYC verification.\n\t\t\t */\n\t\t\tconst createVerification = await endpoints.createVerification;\n\t\t\tconst getCertificates = await endpoints.getCertificates;\n\t\t\tconst getVerificationStatus = await endpoints.getVerificationStatus;\n\t\t\tif (createVerification === undefined || getCertificates === undefined || getVerificationStatus === undefined) {\n\t\t\t\tthis.logger?.warn(`KYC verification provider ${id} does not support required operations (createVerification, getCertificates, getVerificationStatus)`);\n\n\t\t\t\treturn(null);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * We can safely cast the ID to a ProviderID because it's a branded type\n\t\t\t * for this specific type\n\t\t\t */\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tconst providerID = id as ProviderID;\n\t\t\treturn(new KeetaKYCProvider({\n\t\t\t\tid: providerID,\n\t\t\t\tserviceInfo: serviceInfo,\n\t\t\t\trequest: unsignedRequest,\n\t\t\t\taccount: request.account.assertAccount(),\n\t\t\t\tclient: this,\n\t\t\t\tlogger: this.logger,\n\t\t\t\toperations: {\n\t\t\t\t\tcreateVerification,\n\t\t\t\t\tgetCertificates,\n\t\t\t\t\tgetVerificationStatus\n\t\t\t\t}\n\t\t\t}));\n\t\t}));\n\n\t\t/*\n\t\t * Filter out any endpoints that were not able to be resolved\n\t\t * or that did not have the required operations.\n\t\t */\n\t\tconst retval = validEndpoints.map(function(result) {\n\t\t\tif (result.status !== 'fulfilled') {\n\t\t\t\treturn(null);\n\t\t\t}\n\t\t\tif (result.value === null) {\n\t\t\t\treturn(null);\n\t\t\t}\n\t\t\treturn(result.value);\n\t\t}).filter(function(result) {\n\t\t\treturn(result !== null);\n\t\t});\n\n\t\tif (retval.length === 0) {\n\t\t\tthrow(new Error('No valid KYC verification endpoints found'));\n\t\t}\n\n\t\treturn(retval);\n\t}\n\n\tasync getCertificates(providerID: ProviderID, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'> & { id: RequestID; account: SignableAccount; }): Promise<KeetaKYCAnchorClientGetCertificateResponse> {\n\t\tconst endpoints = await getEndpoints(this.resolver, request);\n\t\tif (endpoints === null) {\n\t\t\tthrow(new Error('No KYC endpoints found for the given criteria'));\n\t\t}\n\t\tconst providerEndpoints = endpoints[providerID];\n\t\tif (providerEndpoints === undefined) {\n\t\t\tthrow(new Error(`No KYC endpoints found for provider ID: ${providerID}`));\n\t\t}\n\n\t\tconst requestID = request.id;\n\t\tconst operations = providerEndpoints.operations;\n\t\tconst getCertificate = (await operations.getCertificates)?.({ id: requestID });\n\t\tif (getCertificate === undefined) {\n\t\t\tthrow(new Error('internal error: KYC verification service does not support getCertificate operation'));\n\t\t}\n\n\t\tconst signed = await signRequest(request.account, { method: 'GET', url: getCertificate }, []);\n\t\tconst signedURL = addSignatureToURL(getCertificate, {\n\t\t\tsignedField: signed,\n\t\t\taccount: request.account\n\t\t});\n\n\t\tconst response = await fetch(signedURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Accept': 'application/json'\n\t\t\t}\n\t\t});\n\n\t\t/*\n\t\t * Handle retryable errors by passing them up to the caller to\n\t\t * retry.\n\t\t */\n\t\tif (response.status === 404) {\n\t\t\treturn({\n\t\t\t\tok: false,\n\t\t\t\tretryAfter: 500,\n\t\t\t\treason: 'Certificate not found'\n\t\t\t});\n\t\t}\n\n\t\t/*\n\t\t * Handle other errors as fatal errors that should not be retried.\n\t\t */\n\t\tif (!response.ok) {\n\t\t\tthrow(new Error(`Failed to get certificate: ${response.statusText}`));\n\t\t}\n\n\t\tconst responseJSON: unknown = await response.json();\n\t\tif (!isKeetaKYCAnchorGetCertificateResponse(responseJSON)) {\n\t\t\tthrow(new Error(`Invalid response from KYC certificate service: ${JSON.stringify(responseJSON)}`));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(new Error(`KYC certificate request failed: ${responseJSON.error}`));\n\t\t}\n\n\t\treturn({\n\t\t\tok: true,\n\t\t\tresults: responseJSON.results.map(function(result) {\n\t\t\t\tconst intermediates = result.intermediates?.map(function(intermediate) {\n\t\t\t\t\treturn(new KeetaNetLib.Utils.Certificate.Certificate(intermediate));\n\t\t\t\t});\n\n\t\t\t\tlet intermediatesSet;\n\t\t\t\tif (intermediates !== undefined && intermediates.length > 0) {\n\t\t\t\t\tintermediatesSet = new Set(intermediates);\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\tcertificate: new KYCCertificate(result.certificate),\n\t\t\t\t\tintermediates: intermediatesSet\n\t\t\t\t});\n\t\t\t})\n\t\t});\n\t}\n\n\tasync getSupportedCountries(entityType: KYCEntityType = 'individual'): Promise<CurrencyInfo.Country[]> {\n\t\treturn(await this.resolver.listSupportedKYCCountries(entityType));\n\t}\n\n\tasync getVerificationStatus(providerID: ProviderID, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'> & { id: RequestID; account: SignableAccount; }): Promise<KeetaKYCAnchorClientGetVerificationStatusResponse> {\n\t\tconst endpoints = await getEndpoints(this.resolver, request);\n\t\tif (endpoints === null) {\n\t\t\tthrow(new Error('No KYC endpoints found for the given criteria'));\n\t\t}\n\n\t\tconst providerEndpoints = endpoints[providerID];\n\t\tif (providerEndpoints === undefined) {\n\t\t\tthrow(new Error(`No KYC endpoints found for provider ID: ${providerID}`));\n\t\t}\n\n\t\tconst operations = providerEndpoints.operations;\n\t\tconst getVerificationStatus = (await operations.getVerificationStatus)?.({ id: request.id });\n\t\tif (getVerificationStatus === undefined) {\n\t\t\tthrow(new Error('internal error: KYC verification service does not support getVerificationStatus operation'));\n\t\t}\n\n\t\tconst signed = await signRequest(request.account, { method: 'GET', url: getVerificationStatus }, []);\n\t\tconst signedURL = addSignatureToURL(getVerificationStatus, {\n\t\t\tsignedField: signed,\n\t\t\taccount: request.account\n\t\t});\n\n\t\tconst response = await fetch(signedURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Accept': 'application/json'\n\t\t\t}\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow(new Error(`Failed to get verification status: ${response.statusText}`));\n\t\t}\n\n\t\tconst responseJSON: unknown = await response.json();\n\t\tif (!isKeetaKYCAnchorGetVerificationStatusResponse(responseJSON)) {\n\t\t\tthrow(new Error(`Invalid response from KYC status service: ${JSON.stringify(responseJSON)}`));\n\t\t}\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(new Error(`KYC status request failed: ${responseJSON.error}`));\n\t\t}\n\n\t\tconst result: KeetaKYCAnchorClientGetVerificationStatusResponse = {\n\t\t\tstatus: responseJSON.status\n\t\t};\n\t\tif (responseJSON.requiresManualVerification !== undefined) {\n\t\t\tresult.requiresManualVerification = responseJSON.requiresManualVerification;\n\t\t}\n\n\t\treturn(result);\n\t}\n\n\t/**\n\t * Get a new link to continue an existing verification, or null if the provider does not offer one\n\t */\n\tasync getVerificationURL(providerID: ProviderID, request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'countryCodes' | 'entityType'> & { id: RequestID; account: SignableAccount; }): Promise<URL | null> {\n\t\tconst endpoints = await getEndpoints(this.resolver, request);\n\t\tif (endpoints === null) {\n\t\t\tthrow(new Error('No KYC endpoints found for the given criteria'));\n\t\t}\n\n\t\tconst providerEndpoints = endpoints[providerID];\n\t\tif (providerEndpoints === undefined) {\n\t\t\tthrow(new Error(`No KYC endpoints found for provider ID: ${providerID}`));\n\t\t}\n\n\t\tconst getVerificationURL = (await providerEndpoints.operations.getVerificationURL)?.({ id: request.id });\n\t\tif (getVerificationURL === undefined) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst signed = await signRequest(request.account, { method: 'GET', url: getVerificationURL }, []);\n\t\tconst signedURL = addSignatureToURL(getVerificationURL, {\n\t\t\tsignedField: signed,\n\t\t\taccount: request.account\n\t\t});\n\n\t\tconst response = await fetch(signedURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Accept': 'application/json'\n\t\t\t}\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow(new Error(`Failed to get verification URL: ${response.statusText}`));\n\t\t}\n\n\t\tconst responseJSON: unknown = await response.json();\n\t\tif (!isKeetaKYCAnchorGetVerificationURLResponse(responseJSON)) {\n\t\t\tthrow(new Error(`Invalid response from KYC verification URL service: ${JSON.stringify(responseJSON)}`));\n\t\t}\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(new Error(`KYC verification URL request failed: ${responseJSON.error}`));\n\t\t}\n\n\t\treturn(validateURL(responseJSON.webURL));\n\t}\n\n\tasync getEstimate(..._ignore_args: unknown[]): Promise<never> {\n\t\tthrow(new Error('not implemented'));\n\t}\n\n\tasync checkLocality(..._ignore_args: unknown[]): Promise<never> {\n\t\tthrow(new Error('not implemented'));\n\t}\n}\n\nexport default KeetaKYCAnchorClient;\n"]}
@@ -1,6 +1,5 @@
1
1
  import type { KYCEntityType, ServiceMetadata, ServiceSearchCriteria } from '../../lib/resolver.ts';
2
2
  import * as KeetaNet from '@keetanetwork/keetanet-client';
3
- import * as Signing from '../../lib/utils/signing.js';
4
3
  import { KeetaAnchorUserError } from '../../lib/error.js';
5
4
  import type { HTTPSignedField } from '../../lib/http-server/common.js';
6
5
  import type { KYCVerificationStatus } from './status.js';
@@ -148,11 +147,5 @@ export declare const Errors: {
148
147
  CertificateNotFound: typeof KeetaKYCAnchorCertificateNotFoundError;
149
148
  PaymentRequired: typeof KeetaKYCAnchorCertificatePaymentRequired;
150
149
  };
151
- export declare function generateSignedData(account: Signing.SignableAccount): Promise<{
152
- nonce: string;
153
- timestamp: string;
154
- signature: string;
155
- }>;
156
- export declare function verifySignedData(request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'account' | 'signed'>): Promise<boolean>;
157
150
  export {};
158
151
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/services/kyc/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,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AAO,sCAAsC,CAAC;IACnE,eAAe,EAAE,OAAO,wCAAwC,CAAC;CAiBjE,CAAA"}
@@ -1,5 +1,4 @@
1
1
  import * as KeetaNet from '@keetanetwork/keetanet-client';
2
- import * as Signing from '../../lib/utils/signing.js';
3
2
  import { KeetaAnchorUserError } from '../../lib/error.js';
4
3
  class KeetaKYCAnchorVerificationNotFoundError extends KeetaAnchorUserError {
5
4
  static name = 'KeetaKYCAnchorVerificationNotFoundError';
@@ -117,11 +116,4 @@ export const Errors = {
117
116
  */
118
117
  PaymentRequired: KeetaKYCAnchorCertificatePaymentRequired
119
118
  };
120
- export async function generateSignedData(account) {
121
- return (await Signing.SignData(account, []));
122
- }
123
- export async function verifySignedData(request) {
124
- const account = KeetaNet.lib.Account.fromPublicKeyString(request.account);
125
- return (await Signing.VerifySignedData(account, [], request.signed));
126
- }
127
119
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/services/kyc/common.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AA+G5B,MAAM,uCAAwC,SAAQ,oBAAoB;IACzE,MAAM,CAAmB,IAAI,GAAW,yCAAyC,CAAC;IACjE,mDAAmD,CAAU;IACtE,MAAM,CAAU,mDAAmD,GAAG,sCAAsC,CAAC;IACnG,QAAQ,GAAG,OAAO,CAAC;IAErC,YAAY,OAAgB;QAC3B,KAAK,CAAC,OAAO,IAAI,2BAA2B,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QAEtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qDAAqD,EAAE;YAClF,KAAK,EAAE,uCAAuC,CAAC,mDAAmD;YAClG,UAAU,EAAE,KAAK;SACjB,CAAC,CAAC;IACJ,CAAC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Q,CAAC,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1E,OAAM,CAAC,MAAM,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import type {\n\tKYCEntityType,\n\tServiceMetadata,\n\tServiceSearchCriteria\n} from '../../lib/resolver.ts';\nimport * as KeetaNet from '@keetanetwork/keetanet-client';\nimport * as Signing from '../../lib/utils/signing.js';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type { HTTPSignedField } from '../../lib/http-server/common.js';\nimport type { KYCVerificationStatus } from './status.js';\n\ntype KeetaNetToken = InstanceType<typeof KeetaNet.lib.Account<typeof KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN>>;\n\nexport type CountryCodesSearchCriteria = ServiceSearchCriteria<'kyc'>['countryCodes'];\n\nexport type Operations = NonNullable<ServiceMetadata['services']['kyc']>[string]['operations'];\nexport type OperationNames = keyof Operations;\n\nexport type KYCRedirectStatus = 'completed' | 'cancelled' | 'failed';\n\nexport interface KeetaKYCAnchorCreateVerificationRequest {\n\tcountryCodes: CountryCodesSearchCriteria;\n\taccount: ReturnType<InstanceType<typeof KeetaNet.lib.Account>['publicKeyString']['get']>;\n\tsigned: HTTPSignedField;\n\t/**\n\t * An optional URL that the KYC provider will redirect the user to\n\t * after the verification flow ends. The provider appends a\n\t * {@link KYCRedirectStatus} query parameter indicating the outcome.\n\t */\n\tredirectURL?: string;\n\t/**\n\t * The type of entity being verified. Defaults to `individual` when\n\t * omitted, preserving the classic KYC behavior. The provider uses\n\t * this to choose which hosted collection experience to present.\n\t */\n\tentityType?: KYCEntityType;\n}\n\ntype KeetaNetTokenPublicKeyString = ReturnType<InstanceType<typeof KeetaNet.lib.Account<typeof KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN>>['publicKeyString']['get']>;\nexport type KeetaKYCAnchorCreateVerificationResponse = ({\n\tok: true;\n\n\t/**\n\t * The ID of the verification request -- this is a unique identifier\n\t * for the verification request that can be used to fetch the\n\t * certificate later\n\t */\n\tid: string;\n\t/**\n\t * The expected cost of the verification request, in the form of a\n\t * token and a range of minimum and maximum expected costs\n\t */\n\texpectedCost: {\n\t\tmin: string;\n\t\tmax: string;\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t};\n\t/**\n\t * The URL to the verification service where the user can complete the\n\t * verification process. This URL is expected to be a web URL that the\n\t * user can visit to complete the verification. The provider hosts the\n\t * collection experience for both individual and business entity types.\n\t */\n\twebURL: string;\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaKYCAnchorGetCertificateResponse = ({\n\tok: true;\n\t/**\n\t * The certificates that were issued by the KYC Anchor service.\n\t * Typically this will just be a single certificate, but\n\t * it could also be multiple certificates if the service\n\t * issues multiple certificates for a single verification.\n\t *\n\t * Each certificate is represented as a PEM-encoded string.\n\t * The `intermediates` field is optional and may contain\n\t * additional intermediate certificates that are required to\n\t * validate the certificate chain.\n\t */\n\tresults: ({\n\t\tcertificate: string;\n\t\tintermediates?: string[];\n\t})[];\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaKYCAnchorGetVerificationStatusResponse = ({\n\tok: true;\n\t/**\n\t * The verification status reported by the KYC provider.\n\t */\n\tstatus: KYCVerificationStatus;\n\t/**\n\t * Whether the verification requires manual review by the\n\t * KYC provider before a final determination can be made.\n\t */\n\trequiresManualVerification?: boolean;\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaKYCAnchorGetVerificationURLResponse = ({\n\tok: true;\n\t/**\n\t * A web URL where the user can continue the verification\n\t */\n\twebURL: string;\n} | {\n\tok: false;\n\terror: string;\n});\n\nclass KeetaKYCAnchorVerificationNotFoundError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaKYCAnchorVerificationNotFoundError';\n\tprivate readonly KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID!: string;\n\tprivate static readonly KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID = '79d7036f-58ad-4eec-b64c-26bdf98cd3c1';\n\toverride readonly logLevel = 'DEBUG';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Verification ID not found');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID', {\n\t\t\tvalue: KeetaKYCAnchorVerificationNotFoundError.KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaKYCAnchorVerificationNotFoundError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID', KeetaKYCAnchorVerificationNotFoundError.KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID));\n\t}\n}\n\nclass KeetaKYCAnchorCertificateNotFoundError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaKYCAnchorCertificateNotFoundError';\n\tprivate readonly KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID!: string;\n\tprivate static readonly KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID = '6f4d9620-df33-468e-ae03-898d4fa67aeb';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Certificate not found (pending)');\n\t\tthis.statusCode = 404;\n\n\t\tObject.defineProperty(this, 'KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID', {\n\t\t\tvalue: KeetaKYCAnchorCertificateNotFoundError.KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaKYCAnchorCertificateNotFoundError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID', KeetaKYCAnchorCertificateNotFoundError.KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID));\n\t}\n}\n\nclass KeetaKYCAnchorCertificatePaymentRequired extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaKYCAnchorCertificatePaymentRequired';\n\tprivate readonly KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID!: string;\n\tprivate static readonly KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID = '92b2481d-b29b-4fa2-a295-3a47d99c0869';\n\treadonly amount: bigint;\n\treadonly token: KeetaNetToken;\n\n\tconstructor(cost: { amount: bigint | string; token: KeetaNetToken | string; }, message?: string) {\n\t\tsuper(message ?? 'Payment required for certificate');\n\t\tthis.statusCode = 402;\n\n\t\tthis.amount = BigInt(cost.amount);\n\t\tthis.token = KeetaNet.lib.Account.toAccount<typeof KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN>(cost.token);\n\n\t\tObject.defineProperty(this, 'KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID', {\n\t\t\tvalue: KeetaKYCAnchorCertificatePaymentRequired.KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaKYCAnchorCertificatePaymentRequired {\n\t\treturn(this.hasPropWithValue(input, 'KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID', KeetaKYCAnchorCertificatePaymentRequired.KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID));\n\t}\n\n\tasErrorResponse(contentType: 'text/plain' | 'application/json'): { error: string; statusCode: number; contentType: string } {\n\t\tlet message = this.message;\n\t\tif (contentType === 'application/json') {\n\t\t\tmessage = JSON.stringify({\n\t\t\t\tok: false,\n\t\t\t\tcode: 'KEETA_ANCHOR_KYC_PAYMENT_REQUIRED',\n\t\t\t\tdata: {\n\t\t\t\t\tcost: {\n\t\t\t\t\t\tamount: `0x${this.amount.toString(16)}`,\n\t\t\t\t\t\ttoken: this.token.publicKeyString.get()\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: this.message\n\t\t\t});\n\t\t}\n\n\t\treturn({\n\t\t\terror: message,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tcontentType: contentType\n\t\t});\n\t}\n\n\ttoJSON(): { ok: false; retryable: boolean; error: string; name: string; statusCode: number; amount: string; token: string } {\n\t\treturn({\n\t\t\tok: false,\n\t\t\tretryable: this.retryable,\n\t\t\terror: this.message,\n\t\t\tname: this.name,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tamount: `0x${this.amount.toString(16)}`,\n\t\t\ttoken: this.token.publicKeyString.get()\n\t\t});\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<KeetaKYCAnchorCertificatePaymentRequired> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\n\t\t// Extract required properties specific to PaymentRequired\n\t\tif (!('amount' in other) || typeof other.amount !== 'string') {\n\t\t\tthrow(new Error('Invalid KeetaKYCAnchorCertificatePaymentRequired JSON object: missing or invalid amount'));\n\t\t}\n\n\t\tif (!('token' in other) || typeof other.token !== 'string') {\n\t\t\tthrow(new Error('Invalid KeetaKYCAnchorCertificatePaymentRequired JSON object: missing or invalid token'));\n\t\t}\n\n\t\tconst error = new this(\n\t\t\t{\n\t\t\t\tamount: other.amount,\n\t\t\t\ttoken: other.token\n\t\t\t},\n\t\t\tmessage\n\t\t);\n\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nexport const Errors: {\n\tVerificationNotFound: typeof KeetaKYCAnchorVerificationNotFoundError;\n\tCertificateNotFound: typeof KeetaKYCAnchorCertificateNotFoundError;\n\tPaymentRequired: typeof KeetaKYCAnchorCertificatePaymentRequired;\n} = {\n\t/**\n\t * The verification ID was not found\n\t */\n\tVerificationNotFound: KeetaKYCAnchorVerificationNotFoundError,\n\n\t/**\n\t * The certificate for the verification ID was not found\n\t * (typically this means the verification is still pending)\n\t */\n\tCertificateNotFound: KeetaKYCAnchorCertificateNotFoundError,\n\n\t/**\n\t * Payment is required for the certificate\n\t */\n\tPaymentRequired: KeetaKYCAnchorCertificatePaymentRequired\n}\n\nexport async function generateSignedData(account: Signing.SignableAccount): Promise<{ nonce: string; timestamp: string; signature: string; }> {\n\treturn(await Signing.SignData(account, []));\n}\n\nexport async function verifySignedData(request: Pick<KeetaKYCAnchorCreateVerificationRequest, 'account' | 'signed'>): Promise<boolean> {\n\tconst account = KeetaNet.lib.Account.fromPublicKeyString(request.account);\n\treturn(await Signing.VerifySignedData(account, [], request.signed));\n}\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/services/kyc/common.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AA+G5B,MAAM,uCAAwC,SAAQ,oBAAoB;IACzE,MAAM,CAAmB,IAAI,GAAW,yCAAyC,CAAC;IACjE,mDAAmD,CAAU;IACtE,MAAM,CAAU,mDAAmD,GAAG,sCAAsC,CAAC;IACnG,QAAQ,GAAG,OAAO,CAAC;IAErC,YAAY,OAAgB;QAC3B,KAAK,CAAC,OAAO,IAAI,2BAA2B,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QAEtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qDAAqD,EAAE;YAClF,KAAK,EAAE,uCAAuC,CAAC,mDAAmD;YAClG,UAAU,EAAE,KAAK;SACjB,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,KAAc;QAC/B,OAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,qDAAqD,EAAE,uCAAuC,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAC1L,CAAC;;AAGF,MAAM,sCAAuC,SAAQ,oBAAoB;IACxE,MAAM,CAAmB,IAAI,GAAW,wCAAwC,CAAC;IAChE,kDAAkD,CAAU;IACrE,MAAM,CAAU,kDAAkD,GAAG,sCAAsC,CAAC;IAEpH,YAAY,OAAgB;QAC3B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;YAC9D,MAAK,CAAC,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAC,CAAC;QAC7G,CAAC;QAED,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5D,MAAK,CAAC,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC,CAAC;QAC5G,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,IAAI,CACrB;YACC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;SAClB,EACD,OAAO,CACP,CAAC;QAEF,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;;AAGF,MAAM,CAAC,MAAM,MAAM,GAIf;IACH;;OAEG;IACH,oBAAoB,EAAE,uCAAuC;IAE7D;;;OAGG;IACH,mBAAmB,EAAE,sCAAsC;IAE3D;;OAEG;IACH,eAAe,EAAE,wCAAwC;CACzD,CAAA","sourcesContent":["import type {\n\tKYCEntityType,\n\tServiceMetadata,\n\tServiceSearchCriteria\n} from '../../lib/resolver.ts';\nimport * as KeetaNet from '@keetanetwork/keetanet-client';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type { HTTPSignedField } from '../../lib/http-server/common.js';\nimport type { KYCVerificationStatus } from './status.js';\n\ntype KeetaNetToken = InstanceType<typeof KeetaNet.lib.Account<typeof KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN>>;\n\nexport type CountryCodesSearchCriteria = ServiceSearchCriteria<'kyc'>['countryCodes'];\n\nexport type Operations = NonNullable<ServiceMetadata['services']['kyc']>[string]['operations'];\nexport type OperationNames = keyof Operations;\n\nexport type KYCRedirectStatus = 'completed' | 'cancelled' | 'failed';\n\nexport interface KeetaKYCAnchorCreateVerificationRequest {\n\tcountryCodes: CountryCodesSearchCriteria;\n\taccount: ReturnType<InstanceType<typeof KeetaNet.lib.Account>['publicKeyString']['get']>;\n\tsigned: HTTPSignedField;\n\t/**\n\t * An optional URL that the KYC provider will redirect the user to\n\t * after the verification flow ends. The provider appends a\n\t * {@link KYCRedirectStatus} query parameter indicating the outcome.\n\t */\n\tredirectURL?: string;\n\t/**\n\t * The type of entity being verified. Defaults to `individual` when\n\t * omitted, preserving the classic KYC behavior. The provider uses\n\t * this to choose which hosted collection experience to present.\n\t */\n\tentityType?: KYCEntityType;\n}\n\ntype KeetaNetTokenPublicKeyString = ReturnType<InstanceType<typeof KeetaNet.lib.Account<typeof KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN>>['publicKeyString']['get']>;\nexport type KeetaKYCAnchorCreateVerificationResponse = ({\n\tok: true;\n\n\t/**\n\t * The ID of the verification request -- this is a unique identifier\n\t * for the verification request that can be used to fetch the\n\t * certificate later\n\t */\n\tid: string;\n\t/**\n\t * The expected cost of the verification request, in the form of a\n\t * token and a range of minimum and maximum expected costs\n\t */\n\texpectedCost: {\n\t\tmin: string;\n\t\tmax: string;\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t};\n\t/**\n\t * The URL to the verification service where the user can complete the\n\t * verification process. This URL is expected to be a web URL that the\n\t * user can visit to complete the verification. The provider hosts the\n\t * collection experience for both individual and business entity types.\n\t */\n\twebURL: string;\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaKYCAnchorGetCertificateResponse = ({\n\tok: true;\n\t/**\n\t * The certificates that were issued by the KYC Anchor service.\n\t * Typically this will just be a single certificate, but\n\t * it could also be multiple certificates if the service\n\t * issues multiple certificates for a single verification.\n\t *\n\t * Each certificate is represented as a PEM-encoded string.\n\t * The `intermediates` field is optional and may contain\n\t * additional intermediate certificates that are required to\n\t * validate the certificate chain.\n\t */\n\tresults: ({\n\t\tcertificate: string;\n\t\tintermediates?: string[];\n\t})[];\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaKYCAnchorGetVerificationStatusResponse = ({\n\tok: true;\n\t/**\n\t * The verification status reported by the KYC provider.\n\t */\n\tstatus: KYCVerificationStatus;\n\t/**\n\t * Whether the verification requires manual review by the\n\t * KYC provider before a final determination can be made.\n\t */\n\trequiresManualVerification?: boolean;\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaKYCAnchorGetVerificationURLResponse = ({\n\tok: true;\n\t/**\n\t * A web URL where the user can continue the verification\n\t */\n\twebURL: string;\n} | {\n\tok: false;\n\terror: string;\n});\n\nclass KeetaKYCAnchorVerificationNotFoundError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaKYCAnchorVerificationNotFoundError';\n\tprivate readonly KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID!: string;\n\tprivate static readonly KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID = '79d7036f-58ad-4eec-b64c-26bdf98cd3c1';\n\toverride readonly logLevel = 'DEBUG';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Verification ID not found');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID', {\n\t\t\tvalue: KeetaKYCAnchorVerificationNotFoundError.KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaKYCAnchorVerificationNotFoundError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID', KeetaKYCAnchorVerificationNotFoundError.KeetaKYCAnchorVerificationNotFoundErrorObjectTypeID));\n\t}\n}\n\nclass KeetaKYCAnchorCertificateNotFoundError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaKYCAnchorCertificateNotFoundError';\n\tprivate readonly KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID!: string;\n\tprivate static readonly KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID = '6f4d9620-df33-468e-ae03-898d4fa67aeb';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Certificate not found (pending)');\n\t\tthis.statusCode = 404;\n\n\t\tObject.defineProperty(this, 'KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID', {\n\t\t\tvalue: KeetaKYCAnchorCertificateNotFoundError.KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaKYCAnchorCertificateNotFoundError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID', KeetaKYCAnchorCertificateNotFoundError.KeetaKYCAnchorCertificateNotFoundErrorObjectTypeID));\n\t}\n}\n\nclass KeetaKYCAnchorCertificatePaymentRequired extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaKYCAnchorCertificatePaymentRequired';\n\tprivate readonly KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID!: string;\n\tprivate static readonly KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID = '92b2481d-b29b-4fa2-a295-3a47d99c0869';\n\treadonly amount: bigint;\n\treadonly token: KeetaNetToken;\n\n\tconstructor(cost: { amount: bigint | string; token: KeetaNetToken | string; }, message?: string) {\n\t\tsuper(message ?? 'Payment required for certificate');\n\t\tthis.statusCode = 402;\n\n\t\tthis.amount = BigInt(cost.amount);\n\t\tthis.token = KeetaNet.lib.Account.toAccount<typeof KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN>(cost.token);\n\n\t\tObject.defineProperty(this, 'KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID', {\n\t\t\tvalue: KeetaKYCAnchorCertificatePaymentRequired.KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaKYCAnchorCertificatePaymentRequired {\n\t\treturn(this.hasPropWithValue(input, 'KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID', KeetaKYCAnchorCertificatePaymentRequired.KeetaKYCAnchorCertificatePaymentRequiredObjectTypeID));\n\t}\n\n\tasErrorResponse(contentType: 'text/plain' | 'application/json'): { error: string; statusCode: number; contentType: string } {\n\t\tlet message = this.message;\n\t\tif (contentType === 'application/json') {\n\t\t\tmessage = JSON.stringify({\n\t\t\t\tok: false,\n\t\t\t\tcode: 'KEETA_ANCHOR_KYC_PAYMENT_REQUIRED',\n\t\t\t\tdata: {\n\t\t\t\t\tcost: {\n\t\t\t\t\t\tamount: `0x${this.amount.toString(16)}`,\n\t\t\t\t\t\ttoken: this.token.publicKeyString.get()\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: this.message\n\t\t\t});\n\t\t}\n\n\t\treturn({\n\t\t\terror: message,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tcontentType: contentType\n\t\t});\n\t}\n\n\ttoJSON(): { ok: false; retryable: boolean; error: string; name: string; statusCode: number; amount: string; token: string } {\n\t\treturn({\n\t\t\tok: false,\n\t\t\tretryable: this.retryable,\n\t\t\terror: this.message,\n\t\t\tname: this.name,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tamount: `0x${this.amount.toString(16)}`,\n\t\t\ttoken: this.token.publicKeyString.get()\n\t\t});\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<KeetaKYCAnchorCertificatePaymentRequired> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\n\t\t// Extract required properties specific to PaymentRequired\n\t\tif (!('amount' in other) || typeof other.amount !== 'string') {\n\t\t\tthrow(new Error('Invalid KeetaKYCAnchorCertificatePaymentRequired JSON object: missing or invalid amount'));\n\t\t}\n\n\t\tif (!('token' in other) || typeof other.token !== 'string') {\n\t\t\tthrow(new Error('Invalid KeetaKYCAnchorCertificatePaymentRequired JSON object: missing or invalid token'));\n\t\t}\n\n\t\tconst error = new this(\n\t\t\t{\n\t\t\t\tamount: other.amount,\n\t\t\t\ttoken: other.token\n\t\t\t},\n\t\t\tmessage\n\t\t);\n\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nexport const Errors: {\n\tVerificationNotFound: typeof KeetaKYCAnchorVerificationNotFoundError;\n\tCertificateNotFound: typeof KeetaKYCAnchorCertificateNotFoundError;\n\tPaymentRequired: typeof KeetaKYCAnchorCertificatePaymentRequired;\n} = {\n\t/**\n\t * The verification ID was not found\n\t */\n\tVerificationNotFound: KeetaKYCAnchorVerificationNotFoundError,\n\n\t/**\n\t * The certificate for the verification ID was not found\n\t * (typically this means the verification is still pending)\n\t */\n\tCertificateNotFound: KeetaKYCAnchorCertificateNotFoundError,\n\n\t/**\n\t * Payment is required for the certificate\n\t */\n\tPaymentRequired: KeetaKYCAnchorCertificatePaymentRequired\n}\n"]}
@@ -96,7 +96,9 @@ export interface KeetaAnchorKYCServerConfig extends KeetaAnchorMetadataServerCon
96
96
  * error message or `VerificationNotFound` if the
97
97
  * verification ID is not found.
98
98
  */
99
- getCertificates: (verificationID: string) => Promise<Extract<KeetaKYCAnchorGetCertificateResponse, {
99
+ getCertificates: (verificationID: string, requester: {
100
+ account: Account;
101
+ }) => Promise<Extract<KeetaKYCAnchorGetCertificateResponse, {
100
102
  ok: true;
101
103
  }>['results']>;
102
104
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/services/kyc/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAE5D,OAAO,KAAK,KAAK,qBAAqB,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AAI3F,OAAO,KAAK,EACX,uCAAuC,EACvC,wCAAwC,EACxC,oCAAoC,EACpC,2CAA2C,EAC3C,wCAAwC,EACxC,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAC5E,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