@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
@@ -2,32 +2,16 @@ import * as KeetaNet from '@keetanetwork/keetanet-client';
2
2
  import * as CurrencyInfo from '@keetanetwork/currency-info';
3
3
  import { KeetaAnchorUserError } from '../../lib/error.js';
4
4
  import { assertCreateVerificationRequest, assertCreateVerificationResponse } from './common.server.generated.js';
5
- import { verifySignedData } from './common.js';
6
5
  import { kycEntityTypes } from '../../lib/resolver.js';
7
- import { parseSignatureFromURL } from '../../lib/http-server/common.js';
6
+ import { verifyBodyAuth, verifyURLAuth } from '../../lib/http-server/common.js';
8
7
  import { KeetaAnchorMetadataServer } from '../../lib/anchor-metadata-server.js';
9
8
  const kycProviderURLUndefined = 'NO_KYC_PROVIDER_URL:87f0175c-4d0a-4029-a4f3-ba93ef725654';
10
- async function assertSignedRequester(requestUrl) {
11
- const parsed = parseSignatureFromURL(requestUrl);
12
- const signedField = parsed.signedField;
13
- const account = parsed.account;
14
- if (!signedField || !account) {
15
- throw (new KeetaAnchorUserError('Missing signature'));
16
- }
17
- let valid;
18
- try {
19
- valid = await verifySignedData({
20
- account: account.publicKeyString.get(),
21
- signed: signedField
22
- });
23
- }
24
- catch {
25
- valid = false;
26
- }
27
- if (!valid) {
28
- throw (new KeetaAnchorUserError('Invalid signature'));
29
- }
30
- return (account);
9
+ /**
10
+ * Every signed KYC request carries an empty signable: the request
11
+ * binding covers the operation, the verification ID and the body.
12
+ */
13
+ function noSigningData() {
14
+ return ([]);
31
15
  }
32
16
  ;
33
17
  export class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer {
@@ -64,6 +48,7 @@ export class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer {
64
48
  }
65
49
  async initRoutes(config) {
66
50
  const routes = await super.initRoutes(config);
51
+ const requestAuthContext = this.requestAuthContext.bind(this);
67
52
  /**
68
53
  * If a homepage is provided, setup the route for it
69
54
  */
@@ -89,16 +74,12 @@ export class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer {
89
74
  * Begin the KYC verification process
90
75
  * with this KYC provider
91
76
  */
92
- routes['POST /api/createVerification'] = async function (_ignore_params, bodyInput) {
77
+ routes['POST /api/createVerification'] = async function (_ignore_params, bodyInput, _ignore_headers, requestUrl) {
93
78
  if (bodyInput === null || typeof bodyInput !== 'object' || !('request' in bodyInput)) {
94
79
  throw (new KeetaAnchorUserError('Invalid request'));
95
80
  }
96
81
  const body = assertCreateVerificationRequest(bodyInput.request);
97
- const valid = await verifySignedData(body);
98
- if (!valid) {
99
- throw (new KeetaAnchorUserError('Invalid signature'));
100
- }
101
- /* XXX:TODO: Validate that the nonce is unique (within a reasonable time frame) */
82
+ await verifyBodyAuth(requestAuthContext('POST', requestUrl, bodyInput.request), body, noSigningData);
102
83
  let response = {};
103
84
  if (config.kyc.verificationStarted) {
104
85
  response = await config.kyc.verificationStarted(body);
@@ -152,12 +133,13 @@ export class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer {
152
133
  * Get the certificate for the
153
134
  * KYC verification
154
135
  */
155
- routes['GET /api/getCertificates/:verificationID'] = async function (params) {
136
+ routes['GET /api/getCertificates/:verificationID'] = async function (params, _ignore_body, _ignore_headers, requestUrl) {
156
137
  const verificationID = params.get('verificationID');
157
138
  if (verificationID === undefined) {
158
139
  throw (new KeetaAnchorUserError('No verification ID provided'));
159
140
  }
160
- const certificates = await config.kyc.getCertificates(verificationID);
141
+ const account = await verifyURLAuth(requestAuthContext('GET', requestUrl), noSigningData);
142
+ const certificates = await config.kyc.getCertificates(verificationID, { account });
161
143
  const response = {
162
144
  ok: true,
163
145
  results: certificates
@@ -174,7 +156,7 @@ export class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer {
174
156
  if (verificationID === undefined) {
175
157
  throw (new KeetaAnchorUserError('No verification ID provided'));
176
158
  }
177
- const account = await assertSignedRequester(requestUrl);
159
+ const account = await verifyURLAuth(requestAuthContext('GET', requestUrl), noSigningData);
178
160
  const result = await config.kyc.getVerificationStatus(verificationID, { account });
179
161
  const response = {
180
162
  ok: true,
@@ -197,7 +179,7 @@ export class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer {
197
179
  if (verificationID === undefined) {
198
180
  throw (new KeetaAnchorUserError('No verification ID provided'));
199
181
  }
200
- const account = await assertSignedRequester(requestUrl);
182
+ const account = await verifyURLAuth(requestAuthContext('GET', requestUrl), noSigningData);
201
183
  const result = await getVerificationURL(verificationID, { account });
202
184
  const response = {
203
185
  ok: true,
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/services/kyc/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAI5D,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EACN,+BAA+B,EAC/B,g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,IAAI,CAAC,CAAC;YACtB,CAAC,CAAC,IAAI,EAAE;YACR,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;gBACjE,OAAM,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;YACH,UAAU;SACV,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import * as KeetaNet from '@keetanetwork/keetanet-client';\nimport * as CurrencyInfo from '@keetanetwork/currency-info';\n\nimport type * as KeetaAnchorHTTPServer from '../../lib/http-server/index.js';\nimport type { KeetaAnchorMetadataServerConfig } from '../../lib/anchor-metadata-server.js';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type {\n\tKeetaKYCAnchorCreateVerificationRequest,\n\tKeetaKYCAnchorCreateVerificationResponse,\n\tKeetaKYCAnchorGetCertificateResponse,\n\tKeetaKYCAnchorGetVerificationStatusResponse,\n\tKeetaKYCAnchorGetVerificationURLResponse\n} from './common.ts';\nimport {\n\tassertCreateVerificationRequest,\n\tassertCreateVerificationResponse\n} from './common.server.generated.js';\nimport {\n\tverifySignedData\n} from './common.js';\nimport type { Account } from '@keetanetwork/keetanet-client/lib/account.js';\nimport type * as Signing from '../../lib/utils/signing.js';\nimport type { KYCEntityType, ServiceMetadata } from '../../lib/resolver.ts';\nimport { kycEntityTypes } from '../../lib/resolver.js';\nimport { parseSignatureFromURL } from '../../lib/http-server/common.js';\nimport { KeetaAnchorMetadataServer } from '../../lib/anchor-metadata-server.js';\n\nconst kycProviderURLUndefined = 'NO_KYC_PROVIDER_URL:87f0175c-4d0a-4029-a4f3-ba93ef725654';\n\nasync function assertSignedRequester(requestUrl: URL): Promise<Account> {\n\tconst parsed = parseSignatureFromURL(requestUrl);\n\tconst signedField = parsed.signedField;\n\tconst account = parsed.account;\n\tif (!signedField || !account) {\n\t\tthrow(new KeetaAnchorUserError('Missing signature'));\n\t}\n\n\tlet valid: boolean;\n\ttry {\n\t\tvalid = await verifySignedData({\n\t\t\taccount: account.publicKeyString.get(),\n\t\t\tsigned: signedField\n\t\t});\n\t} catch {\n\t\tvalid = false;\n\t}\n\n\tif (!valid) {\n\t\tthrow(new KeetaAnchorUserError('Invalid signature'));\n\t}\n\n\treturn(account);\n}\n\n/**\n * The Base certificate type, from the KeetaNet Client\n *\n * The KYC Certificate type is a subclass of this, so it will also work\n */\ntype BaseCertificate = InstanceType<typeof KeetaNet.lib.Utils.Certificate.Certificate>;\n\nexport interface KeetaAnchorKYCServerConfig extends KeetaAnchorMetadataServerConfig {\n\t/**\n\t * The data to use for the index page (optional)\n\t */\n\thomepage?: string | (() => Promise<string> | string);\n\n\t/**\n\t * The network client to use for submitting blocks\n\t */\n\tclient: { client: KeetaNet.Client; network: bigint; networkAlias: typeof KeetaNet.Client.Config.networksArray[number] } | KeetaNet.UserClient;\n\n\t/**\n\t * Configuration for the KYC Anchor\n\t *\n\t * The flow for a KYC Anchor is as follows:\n\t * 1. Client requests a new verification with a country code and\n\t * account from the KYC Anchor Server\n\t * 2. KYC Anchor Server responds with a verification ID and a URL\n\t * to the KYC provider's web URL, including the verification ID\n\t * 3. Client visits the KYC provider's web URL to complete the\n\t * verification\n\t * 4. KYC provider notifies the Anchor server that the\n\t * verification is complete\n\t * 5. Client requests the certificate for the verification ID\n\t * (polling) from the KYC Anchor Server\n\t * 6. KYC Anchor Server responds with the certificate(s) for the\n\t * verification ID (if complete, pending if still in progress,\n\t * an error if failed)\n\t * 7. Client installs the certificate(s) in their wallet using\n\t * the KeetaNet Client library\n\t *\n\t *\n\t * +-------------------+ +---------------------+ +------------------+\n\t * | Client | | KYC Anchor Server | | KYC Provider |\n\t * +-------------------+ +---------------------+ +------------------+\n\t * | | |\n\t * (1) Create Verification | |\n\t * countryCode, account ---------------------->| |\n\t * | | |\n\t * | (2) Create verification |\n\t * |----------------------------------- verificationID, providerURL |\n\t * | | |\n\t * (3) Open providerURL (with verificationID)------------------------------------>|\n\t * | | |\n\t * | | (4) Notify\n\t * | |<-------- verificationID, verificationStatus, certificates?\n\t * | |\n\t * (5) Poll certificate for verificationID --->|\n\t * | |\n\t * |<-------------------------- (6) Pending / Certificate(s) / Error\n\t * | (repeat #5 until complete)\n\t * |\n\t * (7) Install certificate(s) in wallet using KeetaNet Client library\n\t */\n\tkyc: {\n\t\t/**\n\t\t * Notification that a verification has been started (optional)\n\t\t *\n\t\t * This method can be used to notify the KYC provider that\n\t\t * a verification has been started. It can return additional\n\t\t * information about the verification, such as the web URL\n\t\t * where the user can complete the verification.\n\t\t *\n\t\t * If this method is not provided, the server will generate\n\t\t * a random verification ID and use the `kycProviderURL` from\n\t\t * the server configuration, replacing `{id}` with the\n\t\t * verification ID.\n\t\t */\n\t\tverificationStarted?: (request: KeetaKYCAnchorCreateVerificationRequest) => Promise<Partial<KeetaKYCAnchorCreateVerificationResponse> | undefined>;\n\n\t\t/**\n\t\t * Retrieve the certificate for a verification\n\t\t *\n\t\t * This should return the certificate(s) for the\n\t\t * verification ID. If the verification is still\n\t\t * in progress, it should throw an `CertificateNotFound`\n\t\t * error.\n\t\t * If the verification has failed permanently, it should\n\t\t * throw a `KeetaAnchorUserError` with an appropriate\n\t\t * error message or `VerificationNotFound` if the\n\t\t * verification ID is not found.\n\t\t */\n\t\tgetCertificates: (verificationID: string) => Promise<Extract<KeetaKYCAnchorGetCertificateResponse, { ok: true; }>['results']>;\n\n\t\t/**\n\t\t * Retrieve the verification status for a verification.\n\t\t *\n\t\t * If the verification ID is unknown, the implementation should\n\t\t * throw a `VerificationNotFound` error.\n\t\t */\n\t\tgetVerificationStatus: (verificationID: string, requester: { account: Account }) => Promise<Pick<Extract<KeetaKYCAnchorGetVerificationStatusResponse, { ok: true; }>, 'status' | 'requiresManualVerification'>>;\n\n\t\t/**\n\t\t * Issue a new link to continue an existing verification (optional)\n\t\t *\n\t\t * Links handed out earlier should keep working. If the\n\t\t * verification ID is unknown or belongs to another account,\n\t\t * the implementation should throw a `VerificationNotFound` error.\n\t\t */\n\t\tgetVerificationURL?: (verificationID: string, requester: { account: Account }) => Promise<Pick<Extract<KeetaKYCAnchorGetVerificationURLResponse, { ok: true; }>, 'webURL'>>;\n\n\t\t/**\n\t\t * Country codes that this KYC provider can service (default is all country codes)\n\t\t */\n\t\tcountryCodes?: (CurrencyInfo.Country | CurrencyInfo.ISOCountryCode)[];\n\n\t\t/**\n\t\t * Entity types that this KYC provider can verify.\n\t\t *\n\t\t * Defaults to `['individual']` (the classic KYC flow).\n\t\t * Add `'business'` to advertise Know Your Business (KYB)\n\t\t * support. Both are hosted redirect flows: the provider\n\t\t * returns a `webURL` to the hosted collection experience it\n\t\t * owns (individual KYC or KYB), and the client polls for the\n\t\t * certificate. A provider that does both lists both:\n\t\t * `['individual', 'business']`.\n\t\t */\n\t\tentityTypes?: KYCEntityType[];\n\t}\n\n\t/**\n\t * The certificate to use for signing certificates\n\t */\n\tca: BaseCertificate;\n\n\t/**\n\t * The account to use for signing certificates\n\t */\n\tsigner: Signing.SignableAccount;\n\n\t/**\n\t * URL for the KYC Provider (optional)\n\t *\n\t * This is the URL that clients will be directed to in order to\n\t * complete the KYC verification process. It is optional because\n\t * the `kyc.verificationStarted` method can also return a `webURL`.\n\t * If both are provided, the URL from `kyc.verificationStarted` takes\n\t * precedence.\n\t */\n\tkycProviderURL?: string | ((verificationID: string) => string);\n\n\t/**\n\t * Additional routes to add to the server (optional)\n\t */\n\troutes?: KeetaAnchorHTTPServer.Routes;\n};\n\nexport class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer<NonNullable<ServiceMetadata['services']['kyc']>[string], KeetaAnchorKYCServerConfig> implements Omit<Required<KeetaAnchorKYCServerConfig>, 'serviceMetadataEndpoint'> {\n\treadonly homepage: NonNullable<KeetaAnchorKYCServerConfig['homepage']>;\n\treadonly client: KeetaAnchorKYCServerConfig['client'];\n\treadonly signer: NonNullable<KeetaAnchorKYCServerConfig['signer']>;\n\treadonly ca: KeetaAnchorKYCServerConfig['ca'];\n\treadonly kyc: KeetaAnchorKYCServerConfig['kyc'];\n\treadonly kycProviderURL: NonNullable<KeetaAnchorKYCServerConfig['kycProviderURL']>;\n\treadonly routes: NonNullable<KeetaAnchorKYCServerConfig['routes']>;\n\treadonly #countryCodes?: CurrencyInfo.Country[] | undefined;\n\treadonly #entityTypes: KYCEntityType[];\n\n\tconstructor(config: KeetaAnchorKYCServerConfig) {\n\t\tsuper(config);\n\n\t\tthis.homepage = config.homepage ?? '';\n\t\tthis.client = config.client;\n\t\tthis.signer = config.signer;\n\t\tthis.ca = config.ca;\n\t\tthis.kyc = config.kyc;\n\t\tthis.routes = config.routes ?? {};\n\t\tthis.kycProviderURL = config.kycProviderURL ?? kycProviderURLUndefined;\n\t\tif (config.kyc.entityTypes !== undefined && config.kyc.entityTypes.length === 0) {\n\t\t\tthrow(new Error('Expected \"kyc.entityTypes\" to declare at least one entity type'));\n\t\t}\n\n\t\tthis.#entityTypes = [...config.kyc.entityTypes ?? ['individual']];\n\n\t\tif (config.kyc.countryCodes) {\n\t\t\tthis.#countryCodes = config.kyc.countryCodes.map(function(inputCode) {\n\t\t\t\tif (CurrencyInfo.Country.isCountryCode(inputCode)) {\n\t\t\t\t\treturn(new CurrencyInfo.Country(inputCode));\n\t\t\t\t}\n\n\t\t\t\treturn(inputCode);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected async initRoutes(config: KeetaAnchorKYCServerConfig): Promise<KeetaAnchorHTTPServer.Routes> {\n\t\tconst routes: KeetaAnchorHTTPServer.Routes = await super.initRoutes(config);\n\n\t\t/**\n\t\t * If a homepage is provided, setup the route for it\n\t\t */\n\t\tif ('homepage' in config) {\n\t\t\troutes['GET /'] = async function() {\n\t\t\t\tlet homepageData: string;\n\t\t\t\tif (typeof config.homepage === 'string') {\n\t\t\t\t\thomepageData = config.homepage;\n\t\t\t\t} else {\n\t\t\t\t\tif (!config.homepage) {\n\t\t\t\t\t\tthrow(new Error('internal error: No homepage function provided'));\n\t\t\t\t\t}\n\n\t\t\t\t\thomepageData = await config.homepage();\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: homepageData,\n\t\t\t\t\tcontentType: 'text/html'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Begin the KYC verification process\n\t\t * with this KYC provider\n\t\t */\n\t\troutes['POST /api/createVerification'] = async function(_ignore_params, bodyInput) {\n\t\t\tif (bodyInput === null || typeof bodyInput !== 'object' || !('request' in bodyInput)) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Invalid request'));\n\t\t\t}\n\n\t\t\tconst body = assertCreateVerificationRequest(bodyInput.request);\n\t\t\tconst valid = await verifySignedData(body);\n\t\t\tif (!valid) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Invalid signature'));\n\t\t\t}\n\n\t\t\t/* XXX:TODO: Validate that the nonce is unique (within a reasonable time frame) */\n\n\t\t\tlet response: Partial<KeetaKYCAnchorCreateVerificationResponse> | undefined = {};\n\t\t\tif (config.kyc.verificationStarted) {\n\t\t\t\tresponse = await config.kyc.verificationStarted(body);\n\t\t\t}\n\n\t\t\tresponse ??= {};\n\n\t\t\tif (response?.ok === false) {\n\t\t\t\tthrow(new KeetaAnchorUserError(response.error ?? 'Unknown error'));\n\t\t\t}\n\n\t\t\tresponse.ok = true;\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow(new Error('internal error: invalid response'));\n\t\t\t}\n\t\t\tresponse.id ??= crypto.randomUUID();\n\n\t\t\tlet defaultWebURL: string;\n\t\t\tif (typeof config.kycProviderURL === 'string') {\n\t\t\t\tdefaultWebURL = config.kycProviderURL.replace('{id}', encodeURIComponent(response.id));\n\t\t\t} else if (config.kycProviderURL !== undefined) {\n\t\t\t\tdefaultWebURL = config.kycProviderURL(response.id);\n\t\t\t} else {\n\t\t\t\tdefaultWebURL = kycProviderURLUndefined;\n\t\t\t}\n\t\t\tresponse.webURL ??= defaultWebURL;\n\n\t\t\tif (!response.webURL || response.webURL === kycProviderURLUndefined) {\n\t\t\t\tthrow(new KeetaAnchorUserError('No webURL provided -- cannot proceed with verification'));\n\t\t\t}\n\n\t\t\tresponse.expectedCost = {\n\t\t\t\tmin: '0',\n\t\t\t\tmax: '0',\n\t\t\t\ttoken: KeetaNet.lib.Account.generateBaseAddresses(config.client.network).baseToken.publicKeyString.get(),\n\t\t\t\t...response.expectedCost\n\t\t\t};\n\n\t\t\tconst responseValidated = assertCreateVerificationResponse(response);\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(responseValidated)\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Request an estimate for a KYC\n\t\t * verification (optional)\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['POST /api/createEstimate'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\t/**\n\t\t * Get the certificate for the\n\t\t * KYC verification\n\t\t */\n\t\troutes['GET /api/getCertificates/:verificationID'] = async function(params) {\n\t\t\tconst verificationID = params.get('verificationID');\n\t\t\tif (verificationID === undefined) {\n\t\t\t\tthrow(new KeetaAnchorUserError('No verification ID provided'));\n\t\t\t}\n\n\t\t\tconst certificates = await config.kyc.getCertificates(verificationID);\n\n\t\t\tconst response: KeetaKYCAnchorGetCertificateResponse = {\n\t\t\t\tok: true,\n\t\t\t\tresults: certificates\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(response)\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Get the verification status.\n\t\t */\n\t\troutes['GET /api/getVerificationStatus/:verificationID'] = async function(params, _ignore_body, _ignore_headers, requestUrl) {\n\t\t\tconst verificationID = params.get('verificationID');\n\t\t\tif (verificationID === undefined) {\n\t\t\t\tthrow(new KeetaAnchorUserError('No verification ID provided'));\n\t\t\t}\n\n\t\t\tconst account = await assertSignedRequester(requestUrl);\n\n\t\t\tconst result = await config.kyc.getVerificationStatus(verificationID, { account });\n\t\t\tconst response: KeetaKYCAnchorGetVerificationStatusResponse = {\n\t\t\t\tok: true,\n\t\t\t\tstatus: result.status\n\t\t\t};\n\t\t\tif (result.requiresManualVerification !== undefined) {\n\t\t\t\tresponse.requiresManualVerification = result.requiresManualVerification;\n\t\t\t}\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(response)\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Get a new link to continue an existing verification (optional)\n\t\t */\n\t\tconst getVerificationURL = config.kyc.getVerificationURL;\n\t\tif (getVerificationURL !== undefined) {\n\t\t\troutes['GET /api/getVerificationURL/:verificationID'] = async function(params, _ignore_body, _ignore_headers, requestUrl) {\n\t\t\t\tconst verificationID = params.get('verificationID');\n\t\t\t\tif (verificationID === undefined) {\n\t\t\t\t\tthrow(new KeetaAnchorUserError('No verification ID provided'));\n\t\t\t\t}\n\n\t\t\t\tconst account = await assertSignedRequester(requestUrl);\n\n\t\t\t\tconst result = await getVerificationURL(verificationID, { account });\n\t\t\t\tconst response: KeetaKYCAnchorGetVerificationURLResponse = {\n\t\t\t\t\tok: true,\n\t\t\t\t\twebURL: result.webURL\n\t\t\t\t};\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify(response)\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Check if the KYC provider can\n\t\t * service a more specific locality\n\t\t * (optional)\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['GET /api/checkLocality'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\t/**\n\t\t * Notification that payment has been received for the KYC verification\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['POST /api/notifyPayment/:verificationID'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\treturn({\n\t\t\t...config.routes,\n\t\t\t...routes\n\t\t});\n\t}\n\n\tprotected async buildServiceMetadata(): Promise<NonNullable<ServiceMetadata['services']['kyc']>[string]> {\n\t\tconst operations: NonNullable<ServiceMetadata['services']['kyc']>[string]['operations'] = {\n\t\t\t// checkLocality: (new URL('/api/checkLocality', this.url)).toString(),\n\t\t\t// getEstimate: (new URL('/api/createEstimate', this.url)).toString(),\n\t\t\t// notifyPayment: (new URL('/api/notifyPayment/{id}', this.url)).toString(),\n\t\t\tcreateVerification: (new URL('/api/createVerification', this.url)).toString(),\n\t\t\tgetCertificates: (new URL('/api/getCertificates', this.url)).toString() + '/{id}',\n\t\t\tgetVerificationStatus: (new URL('/api/getVerificationStatus', this.url)).toString() + '/{id}'\n\t\t};\n\t\tif (this.kyc.getVerificationURL !== undefined) {\n\t\t\toperations.getVerificationURL = (new URL('/api/getVerificationURL', this.url)).toString() + '/{id}';\n\t\t}\n\n\t\treturn({\n\t\t\tca: this.ca.toPEM(),\n\t\t\tcountryCodes: this.#countryCodes?.map(function(country) {\n\t\t\t\treturn(country.code);\n\t\t\t}) ?? [],\n\t\t\tentityTypes: Object.fromEntries(kycEntityTypes.map((entityType) => {\n\t\t\t\treturn([entityType, this.#entityTypes.includes(entityType)]);\n\t\t\t})),\n\t\t\toperations\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/services/kyc/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAI5D,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EACN,+BAA+B,EAC/B,gCAAgC,EAChC,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;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E;YAC5E,kBAAkB,EAAE,CAAC,IAAI,GAAG,CAAC,yBAAyB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;YAC7E,eAAe,EAAE,CAAC,IAAI,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,OAAO;YACjF,qBAAqB,EAAE,CAAC,IAAI,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,OAAO;SAC7F,CAAC;QACF,IAAI,IAAI,CAAC,GAAG,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAC/C,UAAU,CAAC,kBAAkB,GAAG,CAAC,IAAI,GAAG,CAAC,yBAAyB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC;QACrG,CAAC;QAED,OAAM,CAAC;YACN,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE;YACnB,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,UAAS,OAAO;gBACrD,OAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC,CAAC,IAAI,EAAE;YACR,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;gBACjE,OAAM,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;YACH,UAAU;SACV,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import * as KeetaNet from '@keetanetwork/keetanet-client';\nimport * as CurrencyInfo from '@keetanetwork/currency-info';\n\nimport type * as KeetaAnchorHTTPServer from '../../lib/http-server/index.js';\nimport type { KeetaAnchorMetadataServerConfig } from '../../lib/anchor-metadata-server.js';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type {\n\tKeetaKYCAnchorCreateVerificationRequest,\n\tKeetaKYCAnchorCreateVerificationResponse,\n\tKeetaKYCAnchorGetCertificateResponse,\n\tKeetaKYCAnchorGetVerificationStatusResponse,\n\tKeetaKYCAnchorGetVerificationURLResponse\n} from './common.ts';\nimport {\n\tassertCreateVerificationRequest,\n\tassertCreateVerificationResponse\n} from './common.server.generated.js';\nimport type { Account } from '@keetanetwork/keetanet-client/lib/account.js';\nimport type * as Signing from '../../lib/utils/signing.js';\nimport type { KYCEntityType, ServiceMetadata } from '../../lib/resolver.ts';\nimport { kycEntityTypes } from '../../lib/resolver.js';\nimport { verifyBodyAuth, verifyURLAuth } from '../../lib/http-server/common.js';\nimport { KeetaAnchorMetadataServer } from '../../lib/anchor-metadata-server.js';\n\nconst kycProviderURLUndefined = 'NO_KYC_PROVIDER_URL:87f0175c-4d0a-4029-a4f3-ba93ef725654';\n\n/**\n * Every signed KYC request carries an empty signable: the request\n * binding covers the operation, the verification ID and the body.\n */\nfunction noSigningData(): [] {\n\treturn([]);\n}\n\n/**\n * The Base certificate type, from the KeetaNet Client\n *\n * The KYC Certificate type is a subclass of this, so it will also work\n */\ntype BaseCertificate = InstanceType<typeof KeetaNet.lib.Utils.Certificate.Certificate>;\n\nexport interface KeetaAnchorKYCServerConfig extends KeetaAnchorMetadataServerConfig {\n\t/**\n\t * The data to use for the index page (optional)\n\t */\n\thomepage?: string | (() => Promise<string> | string);\n\n\t/**\n\t * The network client to use for submitting blocks\n\t */\n\tclient: { client: KeetaNet.Client; network: bigint; networkAlias: typeof KeetaNet.Client.Config.networksArray[number] } | KeetaNet.UserClient;\n\n\t/**\n\t * Configuration for the KYC Anchor\n\t *\n\t * The flow for a KYC Anchor is as follows:\n\t * 1. Client requests a new verification with a country code and\n\t * account from the KYC Anchor Server\n\t * 2. KYC Anchor Server responds with a verification ID and a URL\n\t * to the KYC provider's web URL, including the verification ID\n\t * 3. Client visits the KYC provider's web URL to complete the\n\t * verification\n\t * 4. KYC provider notifies the Anchor server that the\n\t * verification is complete\n\t * 5. Client requests the certificate for the verification ID\n\t * (polling) from the KYC Anchor Server\n\t * 6. KYC Anchor Server responds with the certificate(s) for the\n\t * verification ID (if complete, pending if still in progress,\n\t * an error if failed)\n\t * 7. Client installs the certificate(s) in their wallet using\n\t * the KeetaNet Client library\n\t *\n\t *\n\t * +-------------------+ +---------------------+ +------------------+\n\t * | Client | | KYC Anchor Server | | KYC Provider |\n\t * +-------------------+ +---------------------+ +------------------+\n\t * | | |\n\t * (1) Create Verification | |\n\t * countryCode, account ---------------------->| |\n\t * | | |\n\t * | (2) Create verification |\n\t * |----------------------------------- verificationID, providerURL |\n\t * | | |\n\t * (3) Open providerURL (with verificationID)------------------------------------>|\n\t * | | |\n\t * | | (4) Notify\n\t * | |<-------- verificationID, verificationStatus, certificates?\n\t * | |\n\t * (5) Poll certificate for verificationID --->|\n\t * | |\n\t * |<-------------------------- (6) Pending / Certificate(s) / Error\n\t * | (repeat #5 until complete)\n\t * |\n\t * (7) Install certificate(s) in wallet using KeetaNet Client library\n\t */\n\tkyc: {\n\t\t/**\n\t\t * Notification that a verification has been started (optional)\n\t\t *\n\t\t * This method can be used to notify the KYC provider that\n\t\t * a verification has been started. It can return additional\n\t\t * information about the verification, such as the web URL\n\t\t * where the user can complete the verification.\n\t\t *\n\t\t * If this method is not provided, the server will generate\n\t\t * a random verification ID and use the `kycProviderURL` from\n\t\t * the server configuration, replacing `{id}` with the\n\t\t * verification ID.\n\t\t */\n\t\tverificationStarted?: (request: KeetaKYCAnchorCreateVerificationRequest) => Promise<Partial<KeetaKYCAnchorCreateVerificationResponse> | undefined>;\n\n\t\t/**\n\t\t * Retrieve the certificate for a verification\n\t\t *\n\t\t * This should return the certificate(s) for the\n\t\t * verification ID. If the verification is still\n\t\t * in progress, it should throw an `CertificateNotFound`\n\t\t * error.\n\t\t * If the verification has failed permanently, it should\n\t\t * throw a `KeetaAnchorUserError` with an appropriate\n\t\t * error message or `VerificationNotFound` if the\n\t\t * verification ID is not found.\n\t\t */\n\t\tgetCertificates: (verificationID: string, requester: { account: Account }) => Promise<Extract<KeetaKYCAnchorGetCertificateResponse, { ok: true; }>['results']>;\n\n\t\t/**\n\t\t * Retrieve the verification status for a verification.\n\t\t *\n\t\t * If the verification ID is unknown, the implementation should\n\t\t * throw a `VerificationNotFound` error.\n\t\t */\n\t\tgetVerificationStatus: (verificationID: string, requester: { account: Account }) => Promise<Pick<Extract<KeetaKYCAnchorGetVerificationStatusResponse, { ok: true; }>, 'status' | 'requiresManualVerification'>>;\n\n\t\t/**\n\t\t * Issue a new link to continue an existing verification (optional)\n\t\t *\n\t\t * Links handed out earlier should keep working. If the\n\t\t * verification ID is unknown or belongs to another account,\n\t\t * the implementation should throw a `VerificationNotFound` error.\n\t\t */\n\t\tgetVerificationURL?: (verificationID: string, requester: { account: Account }) => Promise<Pick<Extract<KeetaKYCAnchorGetVerificationURLResponse, { ok: true; }>, 'webURL'>>;\n\n\t\t/**\n\t\t * Country codes that this KYC provider can service (default is all country codes)\n\t\t */\n\t\tcountryCodes?: (CurrencyInfo.Country | CurrencyInfo.ISOCountryCode)[];\n\n\t\t/**\n\t\t * Entity types that this KYC provider can verify.\n\t\t *\n\t\t * Defaults to `['individual']` (the classic KYC flow).\n\t\t * Add `'business'` to advertise Know Your Business (KYB)\n\t\t * support. Both are hosted redirect flows: the provider\n\t\t * returns a `webURL` to the hosted collection experience it\n\t\t * owns (individual KYC or KYB), and the client polls for the\n\t\t * certificate. A provider that does both lists both:\n\t\t * `['individual', 'business']`.\n\t\t */\n\t\tentityTypes?: KYCEntityType[];\n\t}\n\n\t/**\n\t * The certificate to use for signing certificates\n\t */\n\tca: BaseCertificate;\n\n\t/**\n\t * The account to use for signing certificates\n\t */\n\tsigner: Signing.SignableAccount;\n\n\t/**\n\t * URL for the KYC Provider (optional)\n\t *\n\t * This is the URL that clients will be directed to in order to\n\t * complete the KYC verification process. It is optional because\n\t * the `kyc.verificationStarted` method can also return a `webURL`.\n\t * If both are provided, the URL from `kyc.verificationStarted` takes\n\t * precedence.\n\t */\n\tkycProviderURL?: string | ((verificationID: string) => string);\n\n\t/**\n\t * Additional routes to add to the server (optional)\n\t */\n\troutes?: KeetaAnchorHTTPServer.Routes;\n};\n\nexport class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer<NonNullable<ServiceMetadata['services']['kyc']>[string], KeetaAnchorKYCServerConfig> implements Omit<Required<KeetaAnchorKYCServerConfig>, 'serviceMetadataEndpoint'> {\n\treadonly homepage: NonNullable<KeetaAnchorKYCServerConfig['homepage']>;\n\treadonly client: KeetaAnchorKYCServerConfig['client'];\n\treadonly signer: NonNullable<KeetaAnchorKYCServerConfig['signer']>;\n\treadonly ca: KeetaAnchorKYCServerConfig['ca'];\n\treadonly kyc: KeetaAnchorKYCServerConfig['kyc'];\n\treadonly kycProviderURL: NonNullable<KeetaAnchorKYCServerConfig['kycProviderURL']>;\n\treadonly routes: NonNullable<KeetaAnchorKYCServerConfig['routes']>;\n\treadonly #countryCodes?: CurrencyInfo.Country[] | undefined;\n\treadonly #entityTypes: KYCEntityType[];\n\n\tconstructor(config: KeetaAnchorKYCServerConfig) {\n\t\tsuper(config);\n\n\t\tthis.homepage = config.homepage ?? '';\n\t\tthis.client = config.client;\n\t\tthis.signer = config.signer;\n\t\tthis.ca = config.ca;\n\t\tthis.kyc = config.kyc;\n\t\tthis.routes = config.routes ?? {};\n\t\tthis.kycProviderURL = config.kycProviderURL ?? kycProviderURLUndefined;\n\t\tif (config.kyc.entityTypes !== undefined && config.kyc.entityTypes.length === 0) {\n\t\t\tthrow(new Error('Expected \"kyc.entityTypes\" to declare at least one entity type'));\n\t\t}\n\n\t\tthis.#entityTypes = [...config.kyc.entityTypes ?? ['individual']];\n\n\t\tif (config.kyc.countryCodes) {\n\t\t\tthis.#countryCodes = config.kyc.countryCodes.map(function(inputCode) {\n\t\t\t\tif (CurrencyInfo.Country.isCountryCode(inputCode)) {\n\t\t\t\t\treturn(new CurrencyInfo.Country(inputCode));\n\t\t\t\t}\n\n\t\t\t\treturn(inputCode);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected async initRoutes(config: KeetaAnchorKYCServerConfig): Promise<KeetaAnchorHTTPServer.Routes> {\n\t\tconst routes: KeetaAnchorHTTPServer.Routes = await super.initRoutes(config);\n\t\tconst requestAuthContext = this.requestAuthContext.bind(this);\n\n\n\t\t/**\n\t\t * If a homepage is provided, setup the route for it\n\t\t */\n\t\tif ('homepage' in config) {\n\t\t\troutes['GET /'] = async function() {\n\t\t\t\tlet homepageData: string;\n\t\t\t\tif (typeof config.homepage === 'string') {\n\t\t\t\t\thomepageData = config.homepage;\n\t\t\t\t} else {\n\t\t\t\t\tif (!config.homepage) {\n\t\t\t\t\t\tthrow(new Error('internal error: No homepage function provided'));\n\t\t\t\t\t}\n\n\t\t\t\t\thomepageData = await config.homepage();\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: homepageData,\n\t\t\t\t\tcontentType: 'text/html'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Begin the KYC verification process\n\t\t * with this KYC provider\n\t\t */\n\t\troutes['POST /api/createVerification'] = async function(_ignore_params, bodyInput, _ignore_headers, requestUrl) {\n\t\t\tif (bodyInput === null || typeof bodyInput !== 'object' || !('request' in bodyInput)) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Invalid request'));\n\t\t\t}\n\n\t\t\tconst body = assertCreateVerificationRequest(bodyInput.request);\n\t\t\tawait verifyBodyAuth(requestAuthContext('POST', requestUrl, bodyInput.request), body, noSigningData);\n\n\t\t\tlet response: Partial<KeetaKYCAnchorCreateVerificationResponse> | undefined = {};\n\t\t\tif (config.kyc.verificationStarted) {\n\t\t\t\tresponse = await config.kyc.verificationStarted(body);\n\t\t\t}\n\n\t\t\tresponse ??= {};\n\n\t\t\tif (response?.ok === false) {\n\t\t\t\tthrow(new KeetaAnchorUserError(response.error ?? 'Unknown error'));\n\t\t\t}\n\n\t\t\tresponse.ok = true;\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow(new Error('internal error: invalid response'));\n\t\t\t}\n\t\t\tresponse.id ??= crypto.randomUUID();\n\n\t\t\tlet defaultWebURL: string;\n\t\t\tif (typeof config.kycProviderURL === 'string') {\n\t\t\t\tdefaultWebURL = config.kycProviderURL.replace('{id}', encodeURIComponent(response.id));\n\t\t\t} else if (config.kycProviderURL !== undefined) {\n\t\t\t\tdefaultWebURL = config.kycProviderURL(response.id);\n\t\t\t} else {\n\t\t\t\tdefaultWebURL = kycProviderURLUndefined;\n\t\t\t}\n\t\t\tresponse.webURL ??= defaultWebURL;\n\n\t\t\tif (!response.webURL || response.webURL === kycProviderURLUndefined) {\n\t\t\t\tthrow(new KeetaAnchorUserError('No webURL provided -- cannot proceed with verification'));\n\t\t\t}\n\n\t\t\tresponse.expectedCost = {\n\t\t\t\tmin: '0',\n\t\t\t\tmax: '0',\n\t\t\t\ttoken: KeetaNet.lib.Account.generateBaseAddresses(config.client.network).baseToken.publicKeyString.get(),\n\t\t\t\t...response.expectedCost\n\t\t\t};\n\n\t\t\tconst responseValidated = assertCreateVerificationResponse(response);\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(responseValidated)\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Request an estimate for a KYC\n\t\t * verification (optional)\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['POST /api/createEstimate'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\t/**\n\t\t * Get the certificate for the\n\t\t * KYC verification\n\t\t */\n\t\troutes['GET /api/getCertificates/:verificationID'] = async function(params, _ignore_body, _ignore_headers, requestUrl) {\n\t\t\tconst verificationID = params.get('verificationID');\n\t\t\tif (verificationID === undefined) {\n\t\t\t\tthrow(new KeetaAnchorUserError('No verification ID provided'));\n\t\t\t}\n\n\t\t\tconst account = await verifyURLAuth(requestAuthContext('GET', requestUrl), noSigningData);\n\t\t\tconst certificates = await config.kyc.getCertificates(verificationID, { account });\n\n\t\t\tconst response: KeetaKYCAnchorGetCertificateResponse = {\n\t\t\t\tok: true,\n\t\t\t\tresults: certificates\n\t\t\t};\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(response)\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Get the verification status.\n\t\t */\n\t\troutes['GET /api/getVerificationStatus/:verificationID'] = async function(params, _ignore_body, _ignore_headers, requestUrl) {\n\t\t\tconst verificationID = params.get('verificationID');\n\t\t\tif (verificationID === undefined) {\n\t\t\t\tthrow(new KeetaAnchorUserError('No verification ID provided'));\n\t\t\t}\n\n\t\t\tconst account = await verifyURLAuth(requestAuthContext('GET', requestUrl), noSigningData);\n\n\t\t\tconst result = await config.kyc.getVerificationStatus(verificationID, { account });\n\t\t\tconst response: KeetaKYCAnchorGetVerificationStatusResponse = {\n\t\t\t\tok: true,\n\t\t\t\tstatus: result.status\n\t\t\t};\n\t\t\tif (result.requiresManualVerification !== undefined) {\n\t\t\t\tresponse.requiresManualVerification = result.requiresManualVerification;\n\t\t\t}\n\n\t\t\treturn({\n\t\t\t\toutput: JSON.stringify(response)\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Get a new link to continue an existing verification (optional)\n\t\t */\n\t\tconst getVerificationURL = config.kyc.getVerificationURL;\n\t\tif (getVerificationURL !== undefined) {\n\t\t\troutes['GET /api/getVerificationURL/:verificationID'] = async function(params, _ignore_body, _ignore_headers, requestUrl) {\n\t\t\t\tconst verificationID = params.get('verificationID');\n\t\t\t\tif (verificationID === undefined) {\n\t\t\t\t\tthrow(new KeetaAnchorUserError('No verification ID provided'));\n\t\t\t\t}\n\n\t\t\t\tconst account = await verifyURLAuth(requestAuthContext('GET', requestUrl), noSigningData);\n\n\t\t\t\tconst result = await getVerificationURL(verificationID, { account });\n\t\t\t\tconst response: KeetaKYCAnchorGetVerificationURLResponse = {\n\t\t\t\t\tok: true,\n\t\t\t\t\twebURL: result.webURL\n\t\t\t\t};\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify(response)\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Check if the KYC provider can\n\t\t * service a more specific locality\n\t\t * (optional)\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['GET /api/checkLocality'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\t/**\n\t\t * Notification that payment has been received for the KYC verification\n\t\t *\n\t\t * XXX:TODO\n\t\t */\n\t\t// if (false) {\n\t\t// \troutes['POST /api/notifyPayment/:verificationID'] = async function(_ignore_params, _ignore_body) {\n\t\t// \t\tthrow(new Error('not implemented'));\n\t\t// \t};\n\t\t// }\n\n\t\treturn({\n\t\t\t...config.routes,\n\t\t\t...routes\n\t\t});\n\t}\n\n\tprotected async buildServiceMetadata(): Promise<NonNullable<ServiceMetadata['services']['kyc']>[string]> {\n\t\tconst operations: NonNullable<ServiceMetadata['services']['kyc']>[string]['operations'] = {\n\t\t\t// checkLocality: (new URL('/api/checkLocality', this.url)).toString(),\n\t\t\t// getEstimate: (new URL('/api/createEstimate', this.url)).toString(),\n\t\t\t// notifyPayment: (new URL('/api/notifyPayment/{id}', this.url)).toString(),\n\t\t\tcreateVerification: (new URL('/api/createVerification', this.url)).toString(),\n\t\t\tgetCertificates: (new URL('/api/getCertificates', this.url)).toString() + '/{id}',\n\t\t\tgetVerificationStatus: (new URL('/api/getVerificationStatus', this.url)).toString() + '/{id}'\n\t\t};\n\t\tif (this.kyc.getVerificationURL !== undefined) {\n\t\t\toperations.getVerificationURL = (new URL('/api/getVerificationURL', this.url)).toString() + '/{id}';\n\t\t}\n\n\t\treturn({\n\t\t\tca: this.ca.toPEM(),\n\t\t\tcountryCodes: this.#countryCodes?.map(function(country) {\n\t\t\t\treturn(country.code);\n\t\t\t}) ?? [],\n\t\t\tentityTypes: Object.fromEntries(kycEntityTypes.map((entityType) => {\n\t\t\t\treturn([entityType, this.#entityTypes.includes(entityType)]);\n\t\t\t})),\n\t\t\toperations\n\t\t});\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/services/notification/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EACX,UAAU,IAAI,kBAAkB,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,iCAAiC,EAA2B,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEtK,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,KAAK,EACX,kDAAkD,EAClD,+CAA+C,EAC/C,gDAAgD,EAChD,sDAAsD,EACtD,qDAAqD,EACrD,sDAAsD,EACtD,gCAAgC,EAChC,mBAAmB,EACnB,4BAA4B,EAI5B,MAAM,aAAa,CAAC;AAqBrB,MAAM,MAAM,mCAAmC,GAAG;IACjD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;CACnD,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAA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G,OAAO,CAAC,+BAA+B,GAAG,IAAI,CAAC;CAqBrH;AAED,eAAe,6BAA6B,CAAC;AAC7C,OAAO,EAAE,+BAA+B,EAAE,CAAC"}
@@ -4,7 +4,7 @@ import { getDefaultResolver } from '../../config.js';
4
4
  import Resolver from '../../lib/resolver.js';
5
5
  import { createAssertEquals } from 'typia';
6
6
  import { KeetaAnchorError } from '../../lib/error.js';
7
- import { SignData } from '../../lib/utils/signing.js';
7
+ import { signRequest } from '../../lib/http-server/request-signing.js';
8
8
  import { getNotificationRegisterTargetRequestSignable, getNotificationListTargetsRequestSignable, getNotificationDeleteTargetRequestSignable, getNotificationCreateSubscriptionRequestSignable, getNotificationListSubscriptionsRequestSignable, getNotificationDeleteSubscriptionRequestSignable, isKeetaNotificationAnchorRegisterTargetResponseJSON, isKeetaNotificationAnchorListTargetsResponseJSON, isKeetaNotificationAnchorDeleteTargetResponseJSON, isKeetaNotificationAnchorCreateSubscriptionResponseJSON, isKeetaNotificationAnchorListSubscriptionsResponseJSON, isKeetaNotificationAnchorDeleteSubscriptionResponseJSON, parseSubscriptionDetailsWithID, assertNotificationSubscriptionType } from './common.js';
9
9
  import { addSignatureToURL } from '../../lib/http-server/common.js';
10
10
  const KeetaNotificationAnchorClientAccessToken = Symbol('KeetaNotificationAnchorClientAccessToken');
@@ -362,18 +362,19 @@ class KeetaNotificationAnchorProvider extends KeetaNotificationAnchorBase {
362
362
  throw (new Error('Notification registerTarget operation must require account authentication'));
363
363
  }
364
364
  const accountToUse = this.#resolveAccount(input.account);
365
- const signed = await SignData(accountToUse.assertAccount(), getNotificationRegisterTargetRequestSignable(input));
366
- const response = await fetch(endpoint.url(), {
365
+ const body = {
366
+ account: accountToUse.publicKeyString.get(),
367
+ channel: input.channel
368
+ };
369
+ const serviceURL = new URL(endpoint.url());
370
+ const signed = await signRequest(accountToUse.assertAccount(), { method: 'POST', url: serviceURL, body }, getNotificationRegisterTargetRequestSignable(input));
371
+ const response = await fetch(serviceURL, {
367
372
  method: 'POST',
368
373
  headers: {
369
374
  'Content-Type': 'application/json',
370
375
  'Accept': 'application/json'
371
376
  },
372
- body: JSON.stringify({
373
- account: accountToUse.publicKeyString.get(),
374
- channel: input.channel,
375
- signed
376
- })
377
+ body: JSON.stringify({ ...body, signed })
377
378
  });
378
379
  let responseJSON;
379
380
  try {
@@ -396,8 +397,9 @@ class KeetaNotificationAnchorProvider extends KeetaNotificationAnchorBase {
396
397
  throw (new Error('Notification listTargets operation must require account authentication'));
397
398
  }
398
399
  const accountToUse = this.#resolveAccount(input?.account);
399
- const signed = await SignData(accountToUse.assertAccount(), getNotificationListTargetsRequestSignable());
400
- const serviceURL = addSignatureToURL(endpoint.url(), { signedField: signed, account: accountToUse.assertAccount() });
400
+ const operationURL = new URL(endpoint.url());
401
+ const signed = await signRequest(accountToUse.assertAccount(), { method: 'GET', url: operationURL }, getNotificationListTargetsRequestSignable());
402
+ const serviceURL = addSignatureToURL(operationURL, { signedField: signed, account: accountToUse.assertAccount() });
401
403
  const response = await fetch(serviceURL, {
402
404
  method: 'GET',
403
405
  headers: { 'Accept': 'application/json' }
@@ -423,18 +425,19 @@ class KeetaNotificationAnchorProvider extends KeetaNotificationAnchorBase {
423
425
  throw (new Error('Notification deleteTarget operation must require account authentication'));
424
426
  }
425
427
  const accountToUse = this.#resolveAccount(input.account);
426
- const signed = await SignData(accountToUse.assertAccount(), getNotificationDeleteTargetRequestSignable(input));
427
- const response = await fetch(endpoint.url(), {
428
+ const body = {
429
+ account: accountToUse.publicKeyString.get(),
430
+ id: input.id
431
+ };
432
+ const serviceURL = new URL(endpoint.url());
433
+ const signed = await signRequest(accountToUse.assertAccount(), { method: 'POST', url: serviceURL, body }, getNotificationDeleteTargetRequestSignable(input));
434
+ const response = await fetch(serviceURL, {
428
435
  method: 'POST',
429
436
  headers: {
430
437
  'Content-Type': 'application/json',
431
438
  'Accept': 'application/json'
432
439
  },
433
- body: JSON.stringify({
434
- account: accountToUse.publicKeyString.get(),
435
- id: input.id,
436
- signed
437
- })
440
+ body: JSON.stringify({ ...body, signed })
438
441
  });
439
442
  let responseJSON;
440
443
  try {
@@ -457,23 +460,24 @@ class KeetaNotificationAnchorProvider extends KeetaNotificationAnchorBase {
457
460
  throw (new Error('Notification createSubscription operation must require account authentication'));
458
461
  }
459
462
  const accountToUse = this.#resolveAccount(input.account);
460
- const signed = await SignData(accountToUse.assertAccount(), getNotificationCreateSubscriptionRequestSignable(input));
461
463
  const serializedSubscription = {
462
464
  ...input.subscription,
463
465
  ...(input.subscription.locale ? { locale: input.subscription.locale.toString() } : {}),
464
466
  ...(input.subscription.toAddress ? { toAddress: input.subscription.toAddress.publicKeyString.get() } : {})
465
467
  };
466
- const response = await fetch(endpoint.url(), {
468
+ const body = {
469
+ account: accountToUse.publicKeyString.get(),
470
+ subscription: serializedSubscription
471
+ };
472
+ const serviceURL = new URL(endpoint.url());
473
+ const signed = await signRequest(accountToUse.assertAccount(), { method: 'POST', url: serviceURL, body }, getNotificationCreateSubscriptionRequestSignable(input));
474
+ const response = await fetch(serviceURL, {
467
475
  method: 'POST',
468
476
  headers: {
469
477
  'Content-Type': 'application/json',
470
478
  'Accept': 'application/json'
471
479
  },
472
- body: JSON.stringify({
473
- account: accountToUse.publicKeyString.get(),
474
- subscription: serializedSubscription,
475
- signed
476
- })
480
+ body: JSON.stringify({ ...body, signed })
477
481
  });
478
482
  let responseJSON;
479
483
  try {
@@ -496,8 +500,9 @@ class KeetaNotificationAnchorProvider extends KeetaNotificationAnchorBase {
496
500
  throw (new Error('Notification listSubscriptions operation must require account authentication'));
497
501
  }
498
502
  const accountToUse = this.#resolveAccount(input?.account);
499
- const signed = await SignData(accountToUse.assertAccount(), getNotificationListSubscriptionsRequestSignable());
500
- const serviceURL = addSignatureToURL(endpoint.url(), { signedField: signed, account: accountToUse.assertAccount() });
503
+ const operationURL = new URL(endpoint.url());
504
+ const signed = await signRequest(accountToUse.assertAccount(), { method: 'GET', url: operationURL }, getNotificationListSubscriptionsRequestSignable());
505
+ const serviceURL = addSignatureToURL(operationURL, { signedField: signed, account: accountToUse.assertAccount() });
501
506
  const response = await fetch(serviceURL, {
502
507
  method: 'GET',
503
508
  headers: { 'Accept': 'application/json' }
@@ -527,18 +532,19 @@ class KeetaNotificationAnchorProvider extends KeetaNotificationAnchorBase {
527
532
  throw (new Error('Notification deleteSubscription operation must require account authentication'));
528
533
  }
529
534
  const accountToUse = this.#resolveAccount(input.account);
530
- const signed = await SignData(accountToUse.assertAccount(), getNotificationDeleteSubscriptionRequestSignable(input));
531
- const response = await fetch(endpoint.url(), {
535
+ const body = {
536
+ account: accountToUse.publicKeyString.get(),
537
+ id: input.id
538
+ };
539
+ const serviceURL = new URL(endpoint.url());
540
+ const signed = await signRequest(accountToUse.assertAccount(), { method: 'POST', url: serviceURL, body }, getNotificationDeleteSubscriptionRequestSignable(input));
541
+ const response = await fetch(serviceURL, {
532
542
  method: 'POST',
533
543
  headers: {
534
544
  'Content-Type': 'application/json',
535
545
  'Accept': 'application/json'
536
546
  },
537
- body: JSON.stringify({
538
- account: accountToUse.publicKeyString.get(),
539
- id: input.id,
540
- signed
541
- })
547
+ body: JSON.stringify({ ...body, signed })
542
548
  });
543
549
  let responseJSON;
544
550
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/services/notification/client.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAKrD,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAetD,OAAO,EACN,4CAA4C,EAC5C,yCAAyC,EACzC,0CAA0C,EAC1C,gDAAgD,EAChD,+CAA+C,EAC/C,gDAAgD,EAChD,mDAAmD,EACnD,gDAAgD,EAChD,iDAA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AAC;IAED,gBAAgB;IAChB,UAAU,CAAC,WAAmB;QAC7B,IAAI,WAAW,KAAK,wCAAwC,EAAE,CAAC;YAC9D,MAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,OAAM,CAAC;YACN,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC;IACJ,CAAC;CACD;AAED,eAAe,6BAA6B,CAAC;AAC7C,OAAO,EAAE,+BAA+B,EAAE,CAAC","sourcesContent":["import type { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\nimport { getDefaultResolver } from '../../config.js';\nimport type {\n\tUserClient as KeetaNetUserClient\n} from '@keetanetwork/keetanet-client';\nimport type { Logger } from '../../lib/log/index.js';\nimport Resolver from '../../lib/resolver.js';\nimport type { ServiceMetadata, ServiceMetadataAuthenticationType, ServiceMetadataEndpoint, ServiceSearchCriteria, SharedLookupCriteria } from '../../lib/resolver.js';\nimport { createAssertEquals } from 'typia';\nimport type { BrandedString } from '../../lib/utils/brand.js';\nimport { KeetaAnchorError } from '../../lib/error.js';\nimport { SignData } from '../../lib/utils/signing.js';\nimport type {\n\tKeetaNotificationAnchorRegisterTargetClientRequest,\n\tKeetaNotificationAnchorListTargetsClientRequest,\n\tKeetaNotificationAnchorDeleteTargetClientRequest,\n\tKeetaNotificationAnchorCreateSubscriptionClientRequest,\n\tKeetaNotificationAnchorListSubscriptionsClientRequest,\n\tKeetaNotificationAnchorDeleteSubscriptionClientRequest,\n\tNotificationTargetWithIDResponse,\n\tSubscriptionDetails,\n\tNotificationChannelArguments,\n\tNotificationChannelType,\n\tSupportedChannelConfigurationMetadata,\n\tNotificationSubscriptionType\n} from './common.js';\nimport {\n\tgetNotificationRegisterTargetRequestSignable,\n\tgetNotificationListTargetsRequestSignable,\n\tgetNotificationDeleteTargetRequestSignable,\n\tgetNotificationCreateSubscriptionRequestSignable,\n\tgetNotificationListSubscriptionsRequestSignable,\n\tgetNotificationDeleteSubscriptionRequestSignable,\n\tisKeetaNotificationAnchorRegisterTargetResponseJSON,\n\tisKeetaNotificationAnchorListTargetsResponseJSON,\n\tisKeetaNotificationAnchorDeleteTargetResponseJSON,\n\tisKeetaNotificationAnchorCreateSubscriptionResponseJSON,\n\tisKeetaNotificationAnchorListSubscriptionsResponseJSON,\n\tisKeetaNotificationAnchorDeleteSubscriptionResponseJSON,\n\tparseSubscriptionDetailsWithID,\n\tassertNotificationSubscriptionType\n} from './common.js';\nimport type { HTTPSignedField } from '../../lib/http-server/common.js';\nimport { addSignatureToURL } from '../../lib/http-server/common.js';\nimport type { AssertNever } from '../../lib/utils/never.js';\n\nexport type KeetaNotificationAnchorClientConfig = {\n\tid?: string;\n\tlogger?: Logger | undefined;\n\tresolver?: Resolver;\n\taccount?: InstanceType<typeof KeetaNetLib.Account>;\n} & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'>;\n\ntype ProviderID = BrandedString<'NotificationProviderID'>;\n\nconst KeetaNotificationAnchorClientAccessToken = Symbol('KeetaNotificationAnchorClientAccessToken');\n\nconst assertServiceMetadataEndpoint = createAssertEquals<ServiceMetadataEndpoint>();\n\ntype KeetaNotificationAnchorOperations = {\n\t[operation in keyof NonNullable<ServiceMetadata['services']['notification']>[string]['operations']]?: {\n\t\turl: (params?: { [key: string]: string; }) => URL;\n\t\toptions: {\n\t\t\tauthentication: ServiceMetadataAuthenticationType;\n\t\t};\n\t};\n};\n\ntype KeetaNotificationServiceInfo = Omit<NonNullable<ServiceMetadata['services']['notification']>[string], 'operations'> & {\n\toperations: {\n\t\t[operation in keyof KeetaNotificationAnchorOperations]: Promise<KeetaNotificationAnchorOperations[operation]>;\n\t};\n};\n\ntype GetEndpointsResult = {\n\t[id in ProviderID]: KeetaNotificationServiceInfo;\n};\n\nfunction validateURL(url: string | undefined): URL {\n\tif (!url) {\n\t\tthrow(new Error('Invalid URL: empty value'));\n\t}\n\n\treturn(new URL(url));\n}\n\nasync function getEndpoints(resolver: Resolver, criteria: ServiceSearchCriteria<'notification'>, shared?: SharedLookupCriteria, logger?: Logger): Promise<GetEndpointsResult | null> {\n\tconst response = await resolver.lookup('notification', criteria, shared);\n\tif (response === undefined) {\n\t\treturn(null);\n\t}\n\n\tconst serviceInfoPromises = Object.entries(response).map(async function([id, serviceInfo]): Promise<[ProviderID, KeetaNotificationServiceInfo]> {\n\t\tconst operations = await serviceInfo.operations('object');\n\t\tconst operationsFunctions: Partial<KeetaNotificationServiceInfo['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 endpoint = assertServiceMetadataEndpoint(await Resolver.Metadata.fullyResolveValuizable(operation));\n\n\t\t\t\t\tlet url: string;\n\t\t\t\t\tlet authentication: ServiceMetadataAuthenticationType = {\n\t\t\t\t\t\tmethod: 'keeta-account',\n\t\t\t\t\t\ttype: 'none'\n\t\t\t\t\t};\n\n\t\t\t\t\tif (typeof endpoint === 'string') {\n\t\t\t\t\t\turl = endpoint;\n\t\t\t\t\t} else {\n\t\t\t\t\t\turl = endpoint.url;\n\t\t\t\t\t\tif (endpoint.options?.authentication) {\n\t\t\t\t\t\t\tauthentication = endpoint.options.authentication;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn({\n\t\t\t\t\t\turl: function(params?: { [key: string]: string; }): URL {\n\t\t\t\t\t\t\tlet substitutedURL: string;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tsubstitutedURL = decodeURI(url);\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tlogger?.debug('NotificationAnchor:getEndpoints', 'Failed to decode URI, using original URL for substitution', error, url);\n\t\t\t\t\t\t\t\tsubstitutedURL = url;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (const [paramKey, paramValue] of Object.entries(params ?? {})) {\n\t\t\t\t\t\t\t\tsubstitutedURL = substitutedURL.replace(`{${paramKey}}`, encodeURIComponent(paramValue));\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn(validateURL(substitutedURL));\n\t\t\t\t\t\t},\n\t\t\t\t\t\toptions: { authentication }\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\n\t\tconst supportedChannels = await (async () => {\n\t\t\tif (!serviceInfo.supportedChannels) {\n\t\t\t\treturn(undefined);\n\t\t\t}\n\n\t\t\tconst resolvedValue = await serviceInfo.supportedChannels('object');\n\n\t\t\tconst allChannelTypes = ['FCM'] as const;\n\t\t\t// Check that NotificationChannelType is fully covered by allChannelTypes\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\ttype __checkAllChannelTypes = AssertNever<NotificationChannelType extends typeof allChannelTypes[number] ? never : true>;\n\n\t\t\tconst retval: Partial<SupportedChannelConfigurationMetadata> = {};\n\n\t\t\tfor (const type of allChannelTypes) {\n\t\t\t\tconst typeCheck = await resolvedValue[type]?.('array');\n\n\t\t\t\tif (!typeCheck) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!retval[type]) {\n\t\t\t\t\tretval[type] = [];\n\t\t\t\t}\n\n\t\t\t\tfor (const item of typeCheck) {\n\t\t\t\t\tconst resolvedItem = await item('object');\n\t\t\t\t\tif (type === 'FCM') {\n\t\t\t\t\t\tconst [ projectId, messagingSenderId, appId, apiKey, vapidKey, bundleId ] = await Promise.all([\n\t\t\t\t\t\t\tresolvedItem.projectId('string'),\n\t\t\t\t\t\t\tresolvedItem.messagingSenderId('string'),\n\t\t\t\t\t\t\tresolvedItem.appId('string'),\n\t\t\t\t\t\t\tresolvedItem.apiKey('string'),\n\t\t\t\t\t\t\tresolvedItem.vapidKey?.('string'),\n\t\t\t\t\t\t\tresolvedItem.bundleId?.('string')\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tif (!projectId || !messagingSenderId || !appId || !apiKey) {\n\t\t\t\t\t\t\tlogger?.debug('NotificationAnchor:getEndpoints', 'Invalid supported channel configuration, missing required fields', { type, item: resolvedItem });\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tretval[type].push({\n\t\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\t\tmessagingSenderId,\n\t\t\t\t\t\t\tappId,\n\t\t\t\t\t\t\tapiKey,\n\t\t\t\t\t\t\t...(vapidKey ? { vapidKey } : {}),\n\t\t\t\t\t\t\t...(bundleId ? { bundleId } : {})\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn(retval);\n\t\t})();\n\n\t\tconst supportedSubscriptions = await (async (): Promise<NotificationSubscriptionType[] | undefined> => {\n\t\t\tif (!serviceInfo.supportedSubscriptions) {\n\t\t\t\treturn(undefined);\n\t\t\t}\n\n\t\t\tconst resolvedValue = await serviceInfo.supportedSubscriptions('array');\n\n\t\t\tconst allValues = await Promise.allSettled(resolvedValue.map(async function(item) {\n\t\t\t\treturn(assertNotificationSubscriptionType(await item('string')))\n\t\t\t}));\n\n\t\t\tconst retval: NotificationSubscriptionType[] = [];\n\n\t\t\tfor (const result of allValues) {\n\t\t\t\tif (result.status === 'fulfilled') {\n\t\t\t\t\tretval.push(result.value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn(retval);\n\t\t})();\n\n\t\treturn([\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tid as unknown as ProviderID,\n\t\t\t{\n\t\t\t\toperations: operationsFunctions,\n\t\t\t\t...(supportedChannels ? { supportedChannels } : {}),\n\t\t\t\t...(supportedSubscriptions ? { supportedSubscriptions } : {})\n\t\t\t}\n\t\t]);\n\t});\n\n\tif (serviceInfoPromises.length === 0) {\n\t\treturn(null);\n\t}\n\n\tconst entries = await Promise.all(serviceInfoPromises);\n\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\treturn(Object.fromEntries(entries) as GetEndpointsResult);\n}\n\ninterface KeetaNotificationAnchorBaseConfig {\n\tclient: KeetaNetUserClient;\n\tlogger?: Logger | undefined;\n\taccount?: InstanceType<typeof KeetaNetLib.Account> | undefined;\n}\n\nclass KeetaNotificationAnchorBase {\n\tprotected readonly client: KeetaNetUserClient;\n\tprotected readonly logger?: Logger | undefined;\n\tprotected readonly account?: InstanceType<typeof KeetaNetLib.Account> | undefined;\n\n\tconstructor(config: KeetaNotificationAnchorBaseConfig) {\n\t\tthis.client = config.client;\n\t\tthis.logger = config.logger;\n\t\tthis.account = config.account;\n\t}\n}\n\nclass KeetaNotificationAnchorProvider extends KeetaNotificationAnchorBase {\n\treadonly serviceInfo: KeetaNotificationServiceInfo;\n\treadonly providerID: ProviderID;\n\n\tconstructor(serviceInfo: KeetaNotificationServiceInfo, providerID: ProviderID, parent: KeetaNotificationAnchorClient) {\n\t\tconst parentInternals = parent._internals(KeetaNotificationAnchorClientAccessToken);\n\t\tsuper(parentInternals);\n\n\t\tthis.serviceInfo = serviceInfo;\n\t\tthis.providerID = providerID;\n\t}\n\n\tasync #getOperation<Name extends keyof KeetaNotificationAnchorOperations>(operationName: Name): Promise<NonNullable<KeetaNotificationAnchorOperations[Name]>> {\n\t\tconst operationGetter = this.serviceInfo.operations[operationName];\n\t\tif (operationGetter === undefined) {\n\t\t\tthrow(new Error(`Notification provider does not support ${operationName} operation`));\n\t\t}\n\n\t\tconst endpoint = await operationGetter;\n\t\tif (endpoint === undefined) {\n\t\t\tthrow(new Error(`Notification provider does not support ${operationName} operation`));\n\t\t}\n\n\t\tif (endpoint.options.authentication.method !== 'keeta-account') {\n\t\t\tthrow(new Error(`Unsupported authentication method: ${endpoint.options.authentication.method}`));\n\t\t}\n\n\t\treturn(endpoint);\n\t}\n\n\tasync #parseResponseError(data: unknown): Promise<Error> {\n\t\ttry {\n\t\t\treturn(await KeetaAnchorError.fromJSON(data));\n\t\t} catch (error) {\n\t\t\tthis.logger?.debug('NotificationAnchor', 'Failed to parse error response', error, data);\n\n\t\t\tif (typeof data === 'object' && data !== null && 'error' in data && typeof data.error === 'string') {\n\t\t\t\treturn(new Error(data.error));\n\t\t\t}\n\n\t\t\treturn(new Error('Notification provider request failed'));\n\t\t}\n\t}\n\n\t#resolveAccount(account?: InstanceType<typeof KeetaNetLib.Account>): InstanceType<typeof KeetaNetLib.Account> {\n\t\tconst accountToUse = account ?? this.account;\n\t\tif (!accountToUse) {\n\t\t\tthrow(new Error('Account is required for this operation'));\n\t\t}\n\n\t\treturn(accountToUse);\n\t}\n\n\tasync registerTarget(input: KeetaNotificationAnchorRegisterTargetClientRequest & { channel: NotificationChannelArguments }): Promise<{ id: string }> {\n\t\tconst endpoint = await this.#getOperation('registerTarget');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification registerTarget operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input.account);\n\t\tconst signed: HTTPSignedField = await SignData(accountToUse.assertAccount(), getNotificationRegisterTargetRequestSignable(input));\n\n\t\tconst response = await fetch(endpoint.url(), {\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\taccount: accountToUse.publicKeyString.get(),\n\t\t\t\tchannel: input.channel,\n\t\t\t\tsigned\n\t\t\t})\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification registerTarget response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorRegisterTargetResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider registerTarget endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ id: responseJSON.id });\n\t}\n\n\tasync listTargets(input?: KeetaNotificationAnchorListTargetsClientRequest): Promise<{ targets: NotificationTargetWithIDResponse[] }> {\n\t\tconst endpoint = await this.#getOperation('listTargets');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification listTargets operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input?.account);\n\t\tconst signed: HTTPSignedField = await SignData(accountToUse.assertAccount(), getNotificationListTargetsRequestSignable());\n\n\t\tconst serviceURL = addSignatureToURL(endpoint.url(), { signedField: signed, account: accountToUse.assertAccount() });\n\n\t\tconst response = await fetch(serviceURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: { 'Accept': 'application/json' }\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification listTargets response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorListTargetsResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider listTargets endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ targets: responseJSON.targets });\n\t}\n\n\tasync deleteTarget(input: KeetaNotificationAnchorDeleteTargetClientRequest): Promise<{ ok: boolean }> {\n\t\tconst endpoint = await this.#getOperation('deleteTarget');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification deleteTarget operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input.account);\n\t\tconst signed: HTTPSignedField = await SignData(accountToUse.assertAccount(), getNotificationDeleteTargetRequestSignable(input));\n\n\t\tconst response = await fetch(endpoint.url(), {\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\taccount: accountToUse.publicKeyString.get(),\n\t\t\t\tid: input.id,\n\t\t\t\tsigned\n\t\t\t})\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification deleteTarget response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorDeleteTargetResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider deleteTarget endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ ok: responseJSON.ok });\n\t}\n\n\tasync createSubscription(input: KeetaNotificationAnchorCreateSubscriptionClientRequest): Promise<{ id: string }> {\n\t\tconst endpoint = await this.#getOperation('createSubscription');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification createSubscription operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input.account);\n\t\tconst signed: HTTPSignedField = await SignData(accountToUse.assertAccount(), getNotificationCreateSubscriptionRequestSignable(input));\n\n\t\tconst serializedSubscription = {\n\t\t\t...input.subscription,\n\t\t\t...(input.subscription.locale ? { locale: input.subscription.locale.toString() } : {}),\n\t\t\t...(input.subscription.toAddress ? { toAddress: input.subscription.toAddress.publicKeyString.get() } : {})\n\t\t};\n\n\t\tconst response = await fetch(endpoint.url(), {\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\taccount: accountToUse.publicKeyString.get(),\n\t\t\t\tsubscription: serializedSubscription,\n\t\t\t\tsigned\n\t\t\t})\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification createSubscription response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorCreateSubscriptionResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider createSubscription endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ id: responseJSON.id });\n\t}\n\n\tasync listSubscriptions(input?: KeetaNotificationAnchorListSubscriptionsClientRequest): Promise<{ subscriptions: SubscriptionDetails[] }> {\n\t\tconst endpoint = await this.#getOperation('listSubscriptions');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification listSubscriptions operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input?.account);\n\t\tconst signed: HTTPSignedField = await SignData(accountToUse.assertAccount(), getNotificationListSubscriptionsRequestSignable());\n\n\t\tconst serviceURL = addSignatureToURL(endpoint.url(), { signedField: signed, account: accountToUse.assertAccount() });\n\n\t\tconst response = await fetch(serviceURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: { 'Accept': 'application/json' }\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification listSubscriptions response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorListSubscriptionsResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider listSubscriptions endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({\n\t\t\tsubscriptions: responseJSON.subscriptions.map(function(row) {\n\t\t\t\treturn(parseSubscriptionDetailsWithID(row));\n\t\t\t})\n\t\t});\n\t}\n\n\tasync deleteSubscription(input: KeetaNotificationAnchorDeleteSubscriptionClientRequest): Promise<{ ok: boolean }> {\n\t\tconst endpoint = await this.#getOperation('deleteSubscription');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification deleteSubscription operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input.account);\n\t\tconst signed: HTTPSignedField = await SignData(accountToUse.assertAccount(), getNotificationDeleteSubscriptionRequestSignable(input));\n\n\t\tconst response = await fetch(endpoint.url(), {\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\taccount: accountToUse.publicKeyString.get(),\n\t\t\t\tid: input.id,\n\t\t\t\tsigned\n\t\t\t})\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification deleteSubscription response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorDeleteSubscriptionResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider deleteSubscription endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ ok: responseJSON.ok });\n\t}\n}\n\nclass KeetaNotificationAnchorClient extends KeetaNotificationAnchorBase {\n\treadonly resolver: Resolver;\n\treadonly id: string;\n\n\tconstructor(client: KeetaNetUserClient, config: KeetaNotificationAnchorClientConfig = {}) {\n\t\tsuper({ client, logger: config.logger, account: config.account });\n\t\tthis.resolver = config.resolver ?? getDefaultResolver(client, config);\n\t\tthis.id = config.id ?? crypto.randomUUID();\n\t}\n\n\tasync #lookup(criteria: ServiceSearchCriteria<'notification'> = {}, shared?: SharedLookupCriteria): Promise<KeetaNotificationAnchorProvider[] | null> {\n\t\tconst endpoints = await getEndpoints(this.resolver, criteria, shared, this.logger);\n\t\tif (endpoints === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst providers = Object.entries(endpoints).map(([providerID, serviceInfo]) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\treturn(new KeetaNotificationAnchorProvider(serviceInfo as KeetaNotificationServiceInfo, providerID as unknown as ProviderID, this));\n\t\t});\n\n\t\tif (providers.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\treturn(providers);\n\t}\n\n\tasync getProviders(criteria?: ServiceSearchCriteria<'notification'>, shared?: SharedLookupCriteria): Promise<KeetaNotificationAnchorProvider[] | null> {\n\t\treturn(await this.#lookup(criteria, shared));\n\t}\n\n\tasync getProvider(providerID: string, shared?: SharedLookupCriteria): Promise<KeetaNotificationAnchorProvider | null> {\n\t\tconst mergedSharedCriteria: SharedLookupCriteria = {\n\t\t\t...shared,\n\t\t\tproviderIDs: shared?.providerIDs !== undefined ? Array.from(new Set([...shared.providerIDs, providerID])) : [providerID]\n\t\t};\n\t\tconst providers = await this.#lookup({}, mergedSharedCriteria);\n\t\treturn(providers?.[0] ?? null);\n\t}\n\n\t/** @internal */\n\t_internals(accessToken: symbol) {\n\t\tif (accessToken !== KeetaNotificationAnchorClientAccessToken) {\n\t\t\tthrow(new Error('invalid access token'));\n\t\t}\n\n\t\treturn({\n\t\t\tclient: this.client,\n\t\t\tlogger: this.logger,\n\t\t\taccount: this.account\n\t\t});\n\t}\n}\n\nexport default KeetaNotificationAnchorClient;\nexport { KeetaNotificationAnchorProvider };\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/services/notification/client.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AA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AC;QAC/D,OAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,gBAAgB;IAChB,UAAU,CAAC,WAAmB;QAC7B,IAAI,WAAW,KAAK,wCAAwC,EAAE,CAAC;YAC9D,MAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,OAAM,CAAC;YACN,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC;IACJ,CAAC;CACD;AAED,eAAe,6BAA6B,CAAC;AAC7C,OAAO,EAAE,+BAA+B,EAAE,CAAC","sourcesContent":["import type { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\nimport { getDefaultResolver } from '../../config.js';\nimport type {\n\tUserClient as KeetaNetUserClient\n} from '@keetanetwork/keetanet-client';\nimport type { Logger } from '../../lib/log/index.js';\nimport Resolver from '../../lib/resolver.js';\nimport type { ServiceMetadata, ServiceMetadataAuthenticationType, ServiceMetadataEndpoint, ServiceSearchCriteria, SharedLookupCriteria } from '../../lib/resolver.js';\nimport { createAssertEquals } from 'typia';\nimport type { BrandedString } from '../../lib/utils/brand.js';\nimport { KeetaAnchorError } from '../../lib/error.js';\nimport { signRequest } from '../../lib/http-server/request-signing.js';\nimport type {\n\tKeetaNotificationAnchorRegisterTargetClientRequest,\n\tKeetaNotificationAnchorListTargetsClientRequest,\n\tKeetaNotificationAnchorDeleteTargetClientRequest,\n\tKeetaNotificationAnchorCreateSubscriptionClientRequest,\n\tKeetaNotificationAnchorListSubscriptionsClientRequest,\n\tKeetaNotificationAnchorDeleteSubscriptionClientRequest,\n\tNotificationTargetWithIDResponse,\n\tSubscriptionDetails,\n\tNotificationChannelArguments,\n\tNotificationChannelType,\n\tSupportedChannelConfigurationMetadata,\n\tNotificationSubscriptionType\n} from './common.js';\nimport {\n\tgetNotificationRegisterTargetRequestSignable,\n\tgetNotificationListTargetsRequestSignable,\n\tgetNotificationDeleteTargetRequestSignable,\n\tgetNotificationCreateSubscriptionRequestSignable,\n\tgetNotificationListSubscriptionsRequestSignable,\n\tgetNotificationDeleteSubscriptionRequestSignable,\n\tisKeetaNotificationAnchorRegisterTargetResponseJSON,\n\tisKeetaNotificationAnchorListTargetsResponseJSON,\n\tisKeetaNotificationAnchorDeleteTargetResponseJSON,\n\tisKeetaNotificationAnchorCreateSubscriptionResponseJSON,\n\tisKeetaNotificationAnchorListSubscriptionsResponseJSON,\n\tisKeetaNotificationAnchorDeleteSubscriptionResponseJSON,\n\tparseSubscriptionDetailsWithID,\n\tassertNotificationSubscriptionType\n} from './common.js';\nimport type { HTTPSignedField } from '../../lib/http-server/common.js';\nimport { addSignatureToURL } from '../../lib/http-server/common.js';\nimport type { AssertNever } from '../../lib/utils/never.js';\n\nexport type KeetaNotificationAnchorClientConfig = {\n\tid?: string;\n\tlogger?: Logger | undefined;\n\tresolver?: Resolver;\n\taccount?: InstanceType<typeof KeetaNetLib.Account>;\n} & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'>;\n\ntype ProviderID = BrandedString<'NotificationProviderID'>;\n\nconst KeetaNotificationAnchorClientAccessToken = Symbol('KeetaNotificationAnchorClientAccessToken');\n\nconst assertServiceMetadataEndpoint = createAssertEquals<ServiceMetadataEndpoint>();\n\ntype KeetaNotificationAnchorOperations = {\n\t[operation in keyof NonNullable<ServiceMetadata['services']['notification']>[string]['operations']]?: {\n\t\turl: (params?: { [key: string]: string; }) => URL;\n\t\toptions: {\n\t\t\tauthentication: ServiceMetadataAuthenticationType;\n\t\t};\n\t};\n};\n\ntype KeetaNotificationServiceInfo = Omit<NonNullable<ServiceMetadata['services']['notification']>[string], 'operations'> & {\n\toperations: {\n\t\t[operation in keyof KeetaNotificationAnchorOperations]: Promise<KeetaNotificationAnchorOperations[operation]>;\n\t};\n};\n\ntype GetEndpointsResult = {\n\t[id in ProviderID]: KeetaNotificationServiceInfo;\n};\n\nfunction validateURL(url: string | undefined): URL {\n\tif (!url) {\n\t\tthrow(new Error('Invalid URL: empty value'));\n\t}\n\n\treturn(new URL(url));\n}\n\nasync function getEndpoints(resolver: Resolver, criteria: ServiceSearchCriteria<'notification'>, shared?: SharedLookupCriteria, logger?: Logger): Promise<GetEndpointsResult | null> {\n\tconst response = await resolver.lookup('notification', criteria, shared);\n\tif (response === undefined) {\n\t\treturn(null);\n\t}\n\n\tconst serviceInfoPromises = Object.entries(response).map(async function([id, serviceInfo]): Promise<[ProviderID, KeetaNotificationServiceInfo]> {\n\t\tconst operations = await serviceInfo.operations('object');\n\t\tconst operationsFunctions: Partial<KeetaNotificationServiceInfo['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 endpoint = assertServiceMetadataEndpoint(await Resolver.Metadata.fullyResolveValuizable(operation));\n\n\t\t\t\t\tlet url: string;\n\t\t\t\t\tlet authentication: ServiceMetadataAuthenticationType = {\n\t\t\t\t\t\tmethod: 'keeta-account',\n\t\t\t\t\t\ttype: 'none'\n\t\t\t\t\t};\n\n\t\t\t\t\tif (typeof endpoint === 'string') {\n\t\t\t\t\t\turl = endpoint;\n\t\t\t\t\t} else {\n\t\t\t\t\t\turl = endpoint.url;\n\t\t\t\t\t\tif (endpoint.options?.authentication) {\n\t\t\t\t\t\t\tauthentication = endpoint.options.authentication;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn({\n\t\t\t\t\t\turl: function(params?: { [key: string]: string; }): URL {\n\t\t\t\t\t\t\tlet substitutedURL: string;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tsubstitutedURL = decodeURI(url);\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tlogger?.debug('NotificationAnchor:getEndpoints', 'Failed to decode URI, using original URL for substitution', error, url);\n\t\t\t\t\t\t\t\tsubstitutedURL = url;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (const [paramKey, paramValue] of Object.entries(params ?? {})) {\n\t\t\t\t\t\t\t\tsubstitutedURL = substitutedURL.replace(`{${paramKey}}`, encodeURIComponent(paramValue));\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn(validateURL(substitutedURL));\n\t\t\t\t\t\t},\n\t\t\t\t\t\toptions: { authentication }\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\n\t\tconst supportedChannels = await (async () => {\n\t\t\tif (!serviceInfo.supportedChannels) {\n\t\t\t\treturn(undefined);\n\t\t\t}\n\n\t\t\tconst resolvedValue = await serviceInfo.supportedChannels('object');\n\n\t\t\tconst allChannelTypes = ['FCM'] as const;\n\t\t\t// Check that NotificationChannelType is fully covered by allChannelTypes\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\ttype __checkAllChannelTypes = AssertNever<NotificationChannelType extends typeof allChannelTypes[number] ? never : true>;\n\n\t\t\tconst retval: Partial<SupportedChannelConfigurationMetadata> = {};\n\n\t\t\tfor (const type of allChannelTypes) {\n\t\t\t\tconst typeCheck = await resolvedValue[type]?.('array');\n\n\t\t\t\tif (!typeCheck) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!retval[type]) {\n\t\t\t\t\tretval[type] = [];\n\t\t\t\t}\n\n\t\t\t\tfor (const item of typeCheck) {\n\t\t\t\t\tconst resolvedItem = await item('object');\n\t\t\t\t\tif (type === 'FCM') {\n\t\t\t\t\t\tconst [ projectId, messagingSenderId, appId, apiKey, vapidKey, bundleId ] = await Promise.all([\n\t\t\t\t\t\t\tresolvedItem.projectId('string'),\n\t\t\t\t\t\t\tresolvedItem.messagingSenderId('string'),\n\t\t\t\t\t\t\tresolvedItem.appId('string'),\n\t\t\t\t\t\t\tresolvedItem.apiKey('string'),\n\t\t\t\t\t\t\tresolvedItem.vapidKey?.('string'),\n\t\t\t\t\t\t\tresolvedItem.bundleId?.('string')\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tif (!projectId || !messagingSenderId || !appId || !apiKey) {\n\t\t\t\t\t\t\tlogger?.debug('NotificationAnchor:getEndpoints', 'Invalid supported channel configuration, missing required fields', { type, item: resolvedItem });\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tretval[type].push({\n\t\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\t\tmessagingSenderId,\n\t\t\t\t\t\t\tappId,\n\t\t\t\t\t\t\tapiKey,\n\t\t\t\t\t\t\t...(vapidKey ? { vapidKey } : {}),\n\t\t\t\t\t\t\t...(bundleId ? { bundleId } : {})\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn(retval);\n\t\t})();\n\n\t\tconst supportedSubscriptions = await (async (): Promise<NotificationSubscriptionType[] | undefined> => {\n\t\t\tif (!serviceInfo.supportedSubscriptions) {\n\t\t\t\treturn(undefined);\n\t\t\t}\n\n\t\t\tconst resolvedValue = await serviceInfo.supportedSubscriptions('array');\n\n\t\t\tconst allValues = await Promise.allSettled(resolvedValue.map(async function(item) {\n\t\t\t\treturn(assertNotificationSubscriptionType(await item('string')))\n\t\t\t}));\n\n\t\t\tconst retval: NotificationSubscriptionType[] = [];\n\n\t\t\tfor (const result of allValues) {\n\t\t\t\tif (result.status === 'fulfilled') {\n\t\t\t\t\tretval.push(result.value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn(retval);\n\t\t})();\n\n\t\treturn([\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tid as unknown as ProviderID,\n\t\t\t{\n\t\t\t\toperations: operationsFunctions,\n\t\t\t\t...(supportedChannels ? { supportedChannels } : {}),\n\t\t\t\t...(supportedSubscriptions ? { supportedSubscriptions } : {})\n\t\t\t}\n\t\t]);\n\t});\n\n\tif (serviceInfoPromises.length === 0) {\n\t\treturn(null);\n\t}\n\n\tconst entries = await Promise.all(serviceInfoPromises);\n\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\treturn(Object.fromEntries(entries) as GetEndpointsResult);\n}\n\ninterface KeetaNotificationAnchorBaseConfig {\n\tclient: KeetaNetUserClient;\n\tlogger?: Logger | undefined;\n\taccount?: InstanceType<typeof KeetaNetLib.Account> | undefined;\n}\n\nclass KeetaNotificationAnchorBase {\n\tprotected readonly client: KeetaNetUserClient;\n\tprotected readonly logger?: Logger | undefined;\n\tprotected readonly account?: InstanceType<typeof KeetaNetLib.Account> | undefined;\n\n\tconstructor(config: KeetaNotificationAnchorBaseConfig) {\n\t\tthis.client = config.client;\n\t\tthis.logger = config.logger;\n\t\tthis.account = config.account;\n\t}\n}\n\nclass KeetaNotificationAnchorProvider extends KeetaNotificationAnchorBase {\n\treadonly serviceInfo: KeetaNotificationServiceInfo;\n\treadonly providerID: ProviderID;\n\n\tconstructor(serviceInfo: KeetaNotificationServiceInfo, providerID: ProviderID, parent: KeetaNotificationAnchorClient) {\n\t\tconst parentInternals = parent._internals(KeetaNotificationAnchorClientAccessToken);\n\t\tsuper(parentInternals);\n\n\t\tthis.serviceInfo = serviceInfo;\n\t\tthis.providerID = providerID;\n\t}\n\n\tasync #getOperation<Name extends keyof KeetaNotificationAnchorOperations>(operationName: Name): Promise<NonNullable<KeetaNotificationAnchorOperations[Name]>> {\n\t\tconst operationGetter = this.serviceInfo.operations[operationName];\n\t\tif (operationGetter === undefined) {\n\t\t\tthrow(new Error(`Notification provider does not support ${operationName} operation`));\n\t\t}\n\n\t\tconst endpoint = await operationGetter;\n\t\tif (endpoint === undefined) {\n\t\t\tthrow(new Error(`Notification provider does not support ${operationName} operation`));\n\t\t}\n\n\t\tif (endpoint.options.authentication.method !== 'keeta-account') {\n\t\t\tthrow(new Error(`Unsupported authentication method: ${endpoint.options.authentication.method}`));\n\t\t}\n\n\t\treturn(endpoint);\n\t}\n\n\tasync #parseResponseError(data: unknown): Promise<Error> {\n\t\ttry {\n\t\t\treturn(await KeetaAnchorError.fromJSON(data));\n\t\t} catch (error) {\n\t\t\tthis.logger?.debug('NotificationAnchor', 'Failed to parse error response', error, data);\n\n\t\t\tif (typeof data === 'object' && data !== null && 'error' in data && typeof data.error === 'string') {\n\t\t\t\treturn(new Error(data.error));\n\t\t\t}\n\n\t\t\treturn(new Error('Notification provider request failed'));\n\t\t}\n\t}\n\n\t#resolveAccount(account?: InstanceType<typeof KeetaNetLib.Account>): InstanceType<typeof KeetaNetLib.Account> {\n\t\tconst accountToUse = account ?? this.account;\n\t\tif (!accountToUse) {\n\t\t\tthrow(new Error('Account is required for this operation'));\n\t\t}\n\n\t\treturn(accountToUse);\n\t}\n\n\tasync registerTarget(input: KeetaNotificationAnchorRegisterTargetClientRequest & { channel: NotificationChannelArguments }): Promise<{ id: string }> {\n\t\tconst endpoint = await this.#getOperation('registerTarget');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification registerTarget operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input.account);\n\n\t\tconst body = {\n\t\t\taccount: accountToUse.publicKeyString.get(),\n\t\t\tchannel: input.channel\n\t\t};\n\t\tconst serviceURL = new URL(endpoint.url());\n\t\tconst signed: HTTPSignedField = await signRequest(accountToUse.assertAccount(), { method: 'POST', url: serviceURL, body }, getNotificationRegisterTargetRequestSignable(input));\n\n\t\tconst response = await fetch(serviceURL, {\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({ ...body, signed })\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification registerTarget response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorRegisterTargetResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider registerTarget endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ id: responseJSON.id });\n\t}\n\n\tasync listTargets(input?: KeetaNotificationAnchorListTargetsClientRequest): Promise<{ targets: NotificationTargetWithIDResponse[] }> {\n\t\tconst endpoint = await this.#getOperation('listTargets');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification listTargets operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input?.account);\n\t\tconst operationURL = new URL(endpoint.url());\n\t\tconst signed: HTTPSignedField = await signRequest(accountToUse.assertAccount(), { method: 'GET', url: operationURL }, getNotificationListTargetsRequestSignable());\n\n\t\tconst serviceURL = addSignatureToURL(operationURL, { signedField: signed, account: accountToUse.assertAccount() });\n\n\t\tconst response = await fetch(serviceURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: { 'Accept': 'application/json' }\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification listTargets response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorListTargetsResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider listTargets endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ targets: responseJSON.targets });\n\t}\n\n\tasync deleteTarget(input: KeetaNotificationAnchorDeleteTargetClientRequest): Promise<{ ok: boolean }> {\n\t\tconst endpoint = await this.#getOperation('deleteTarget');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification deleteTarget operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input.account);\n\n\t\tconst body = {\n\t\t\taccount: accountToUse.publicKeyString.get(),\n\t\t\tid: input.id\n\t\t};\n\t\tconst serviceURL = new URL(endpoint.url());\n\t\tconst signed: HTTPSignedField = await signRequest(accountToUse.assertAccount(), { method: 'POST', url: serviceURL, body }, getNotificationDeleteTargetRequestSignable(input));\n\n\t\tconst response = await fetch(serviceURL, {\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({ ...body, signed })\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification deleteTarget response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorDeleteTargetResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider deleteTarget endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ ok: responseJSON.ok });\n\t}\n\n\tasync createSubscription(input: KeetaNotificationAnchorCreateSubscriptionClientRequest): Promise<{ id: string }> {\n\t\tconst endpoint = await this.#getOperation('createSubscription');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification createSubscription operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input.account);\n\n\t\tconst serializedSubscription = {\n\t\t\t...input.subscription,\n\t\t\t...(input.subscription.locale ? { locale: input.subscription.locale.toString() } : {}),\n\t\t\t...(input.subscription.toAddress ? { toAddress: input.subscription.toAddress.publicKeyString.get() } : {})\n\t\t};\n\n\t\tconst body = {\n\t\t\taccount: accountToUse.publicKeyString.get(),\n\t\t\tsubscription: serializedSubscription\n\t\t};\n\t\tconst serviceURL = new URL(endpoint.url());\n\t\tconst signed: HTTPSignedField = await signRequest(accountToUse.assertAccount(), { method: 'POST', url: serviceURL, body }, getNotificationCreateSubscriptionRequestSignable(input));\n\n\t\tconst response = await fetch(serviceURL, {\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({ ...body, signed })\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification createSubscription response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorCreateSubscriptionResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider createSubscription endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ id: responseJSON.id });\n\t}\n\n\tasync listSubscriptions(input?: KeetaNotificationAnchorListSubscriptionsClientRequest): Promise<{ subscriptions: SubscriptionDetails[] }> {\n\t\tconst endpoint = await this.#getOperation('listSubscriptions');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification listSubscriptions operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input?.account);\n\t\tconst operationURL = new URL(endpoint.url());\n\t\tconst signed: HTTPSignedField = await signRequest(accountToUse.assertAccount(), { method: 'GET', url: operationURL }, getNotificationListSubscriptionsRequestSignable());\n\n\t\tconst serviceURL = addSignatureToURL(operationURL, { signedField: signed, account: accountToUse.assertAccount() });\n\n\t\tconst response = await fetch(serviceURL, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: { 'Accept': 'application/json' }\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification listSubscriptions response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorListSubscriptionsResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider listSubscriptions endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({\n\t\t\tsubscriptions: responseJSON.subscriptions.map(function(row) {\n\t\t\t\treturn(parseSubscriptionDetailsWithID(row));\n\t\t\t})\n\t\t});\n\t}\n\n\tasync deleteSubscription(input: KeetaNotificationAnchorDeleteSubscriptionClientRequest): Promise<{ ok: boolean }> {\n\t\tconst endpoint = await this.#getOperation('deleteSubscription');\n\n\t\tif (endpoint.options.authentication.type === 'none') {\n\t\t\tthrow(new Error('Notification deleteSubscription operation must require account authentication'));\n\t\t}\n\n\t\tconst accountToUse = this.#resolveAccount(input.account);\n\n\t\tconst body = {\n\t\t\taccount: accountToUse.publicKeyString.get(),\n\t\t\tid: input.id\n\t\t};\n\t\tconst serviceURL = new URL(endpoint.url());\n\t\tconst signed: HTTPSignedField = await signRequest(accountToUse.assertAccount(), { method: 'POST', url: serviceURL, body }, getNotificationDeleteSubscriptionRequestSignable(input));\n\n\t\tconst response = await fetch(serviceURL, {\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({ ...body, signed })\n\t\t});\n\n\t\tlet responseJSON: unknown;\n\t\ttry {\n\t\t\tresponseJSON = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow(new Error(`Failed to parse notification deleteSubscription response as JSON: ${error}`));\n\t\t}\n\n\t\tif (!isKeetaNotificationAnchorDeleteSubscriptionResponseJSON(responseJSON)) {\n\t\t\tthrow(new Error('Invalid response from notification provider deleteSubscription endpoint'));\n\t\t}\n\n\t\tif (!responseJSON.ok) {\n\t\t\tthrow(await this.#parseResponseError(responseJSON));\n\t\t}\n\n\t\treturn({ ok: responseJSON.ok });\n\t}\n}\n\nclass KeetaNotificationAnchorClient extends KeetaNotificationAnchorBase {\n\treadonly resolver: Resolver;\n\treadonly id: string;\n\n\tconstructor(client: KeetaNetUserClient, config: KeetaNotificationAnchorClientConfig = {}) {\n\t\tsuper({ client, logger: config.logger, account: config.account });\n\t\tthis.resolver = config.resolver ?? getDefaultResolver(client, config);\n\t\tthis.id = config.id ?? crypto.randomUUID();\n\t}\n\n\tasync #lookup(criteria: ServiceSearchCriteria<'notification'> = {}, shared?: SharedLookupCriteria): Promise<KeetaNotificationAnchorProvider[] | null> {\n\t\tconst endpoints = await getEndpoints(this.resolver, criteria, shared, this.logger);\n\t\tif (endpoints === null) {\n\t\t\treturn(null);\n\t\t}\n\n\t\tconst providers = Object.entries(endpoints).map(([providerID, serviceInfo]) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\treturn(new KeetaNotificationAnchorProvider(serviceInfo as KeetaNotificationServiceInfo, providerID as unknown as ProviderID, this));\n\t\t});\n\n\t\tif (providers.length === 0) {\n\t\t\treturn(null);\n\t\t}\n\n\t\treturn(providers);\n\t}\n\n\tasync getProviders(criteria?: ServiceSearchCriteria<'notification'>, shared?: SharedLookupCriteria): Promise<KeetaNotificationAnchorProvider[] | null> {\n\t\treturn(await this.#lookup(criteria, shared));\n\t}\n\n\tasync getProvider(providerID: string, shared?: SharedLookupCriteria): Promise<KeetaNotificationAnchorProvider | null> {\n\t\tconst mergedSharedCriteria: SharedLookupCriteria = {\n\t\t\t...shared,\n\t\t\tproviderIDs: shared?.providerIDs !== undefined ? Array.from(new Set([...shared.providerIDs, providerID])) : [providerID]\n\t\t};\n\t\tconst providers = await this.#lookup({}, mergedSharedCriteria);\n\t\treturn(providers?.[0] ?? null);\n\t}\n\n\t/** @internal */\n\t_internals(accessToken: symbol) {\n\t\tif (accessToken !== KeetaNotificationAnchorClientAccessToken) {\n\t\t\tthrow(new Error('invalid access token'));\n\t\t}\n\n\t\treturn({\n\t\t\tclient: this.client,\n\t\t\tlogger: this.logger,\n\t\t\taccount: this.account\n\t\t});\n\t}\n}\n\nexport default KeetaNotificationAnchorClient;\nexport { KeetaNotificationAnchorProvider };\n"]}