@keetanetwork/anchor 0.0.79 → 0.0.80

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 (88) hide show
  1. package/lib/anchor-external.d.ts +94 -1
  2. package/lib/anchor-external.d.ts.map +1 -1
  3. package/lib/anchor-external.generated.js +52 -3
  4. package/lib/anchor-external.generated.js.map +1 -1
  5. package/lib/anchor-external.js +126 -3
  6. package/lib/anchor-external.js.map +1 -1
  7. package/lib/anchor-metadata-server.d.ts +15 -2
  8. package/lib/anchor-metadata-server.d.ts.map +1 -1
  9. package/lib/anchor-metadata-server.js +54 -0
  10. package/lib/anchor-metadata-server.js.map +1 -1
  11. package/lib/anchor-status.d.ts +149 -0
  12. package/lib/anchor-status.d.ts.map +1 -0
  13. package/lib/anchor-status.js +93 -0
  14. package/lib/anchor-status.js.map +1 -0
  15. package/lib/chaining.d.ts +2 -1
  16. package/lib/chaining.d.ts.map +1 -1
  17. package/lib/chaining.js +67 -8
  18. package/lib/chaining.js.map +1 -1
  19. package/lib/history.d.ts +405 -0
  20. package/lib/history.d.ts.map +1 -0
  21. package/lib/history.js +723 -0
  22. package/lib/history.js.map +1 -0
  23. package/lib/http-server/index.d.ts +1 -0
  24. package/lib/http-server/index.d.ts.map +1 -1
  25. package/lib/http-server/index.js +1 -0
  26. package/lib/http-server/index.js.map +1 -1
  27. package/lib/index.d.ts +6 -1
  28. package/lib/index.d.ts.map +1 -1
  29. package/lib/index.js +3 -1
  30. package/lib/index.js.map +1 -1
  31. package/lib/metadata.types.d.ts +3 -0
  32. package/lib/metadata.types.d.ts.map +1 -1
  33. package/lib/metadata.types.js.map +1 -1
  34. package/lib/resolver.d.ts +28 -7
  35. package/lib/resolver.d.ts.map +1 -1
  36. package/lib/resolver.generated.js +528 -453
  37. package/lib/resolver.generated.js.map +1 -1
  38. package/lib/resolver.js +67 -8
  39. package/lib/resolver.js.map +1 -1
  40. package/lib/utils/brand.d.ts +5 -0
  41. package/lib/utils/brand.d.ts.map +1 -1
  42. package/lib/utils/brand.js +4 -1
  43. package/lib/utils/brand.js.map +1 -1
  44. package/npm-shrinkwrap.json +10 -17
  45. package/package.json +2 -2
  46. package/services/asset-movement/client.d.ts +7 -1
  47. package/services/asset-movement/client.d.ts.map +1 -1
  48. package/services/asset-movement/client.js +70 -15
  49. package/services/asset-movement/client.js.map +1 -1
  50. package/services/asset-movement/lib/location.d.ts.map +1 -1
  51. package/services/asset-movement/lib/location.js +1 -0
  52. package/services/asset-movement/lib/location.js.map +1 -1
  53. package/services/asset-movement/server.d.ts +1 -1
  54. package/services/asset-movement/server.d.ts.map +1 -1
  55. package/services/asset-movement/server.js +1 -1
  56. package/services/asset-movement/server.js.map +1 -1
  57. package/services/asset-movement/status-source.d.ts +32 -0
  58. package/services/asset-movement/status-source.d.ts.map +1 -0
  59. package/services/asset-movement/status-source.js +77 -0
  60. package/services/asset-movement/status-source.js.map +1 -0
  61. package/services/fx/server.d.ts +2 -2
  62. package/services/fx/server.d.ts.map +1 -1
  63. package/services/fx/server.js +2 -1
  64. package/services/fx/server.js.map +1 -1
  65. package/services/kyc/server.d.ts +1 -1
  66. package/services/kyc/server.d.ts.map +1 -1
  67. package/services/kyc/server.js +1 -1
  68. package/services/kyc/server.js.map +1 -1
  69. package/services/notification/client.js +50 -6
  70. package/services/notification/client.js.map +1 -1
  71. package/services/notification/server.d.ts.map +1 -1
  72. package/services/notification/server.js +4 -1
  73. package/services/notification/server.js.map +1 -1
  74. package/services/storage/client.js +50 -6
  75. package/services/storage/client.js.map +1 -1
  76. package/services/storage/clients/contacts.d.ts +5 -0
  77. package/services/storage/clients/contacts.d.ts.map +1 -1
  78. package/services/storage/clients/contacts.js +20 -9
  79. package/services/storage/clients/contacts.js.map +1 -1
  80. package/services/storage/server.d.ts +1 -1
  81. package/services/storage/server.d.ts.map +1 -1
  82. package/services/storage/server.js +2 -2
  83. package/services/storage/server.js.map +1 -1
  84. package/services/username/client.js +50 -6
  85. package/services/username/client.js.map +1 -1
  86. package/services/username/server.d.ts.map +1 -1
  87. package/services/username/server.js +4 -1
  88. package/services/username/server.js.map +1 -1
@@ -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;AAO5B,OAAO,EACN,+BAA+B,EAC/B,gCAAgC,EAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,gBAAgB,EAChB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,MAAM,uBAAuB,GAAG,0DAA0D,CAAC;AAoI1F,CAAC;AAEF,MAAM,OAAO,2BAA4B,SAAQ,yBAA8G;IACrJ,QAAQ,CAAsD;IAC9D,MAAM,CAAuC;IAC7C,MAAM,CAAoD;IAC1D,EAAE,CAAmC;IACrC,GAAG,CAAoC;IACvC,cAAc,CAA4D;IAC1E,MAAM,CAAoD;IAC1D,aAAa,CAAsC;IAE5D,YAAY,MAAkC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;QAClC,IAAI,CAAC,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gBACrD,OAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC,CAAC,IAAI,EAAE;YACR,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} 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 { ServiceMetadata } from '../../lib/resolver.ts';\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\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 * Country codes that this KYC provider can service (default is all country codes)\n\t\t */\n\t\tcountryCodes?: (CurrencyInfo.Country | CurrencyInfo.ISOCountryCode)[];\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 Required<KeetaAnchorKYCServerConfig> {\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\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\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 = {};\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 parsed = parseSignatureFromURL(requestUrl);\n\t\t\tconst signedField = parsed.signedField;\n\t\t\tconst account = parsed.account;\n\t\t\tif (!signedField || !account) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Missing signature'));\n\t\t\t}\n\n\t\t\tlet valid: boolean;\n\t\t\ttry {\n\t\t\t\tvalid = await verifySignedData({\n\t\t\t\t\taccount: account.publicKeyString.get(),\n\t\t\t\t\tsigned: signedField\n\t\t\t\t});\n\t\t\t} catch {\n\t\t\t\tvalid = false;\n\t\t\t}\n\n\t\t\tif (!valid) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Invalid signature'));\n\t\t\t}\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 * 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\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\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;AAO5B,OAAO,EACN,+BAA+B,EAC/B,gCAAgC,EAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,gBAAgB,EAChB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,MAAM,uBAAuB,GAAG,0DAA0D,CAAC;AAoI1F,CAAC;AAEF,MAAM,OAAO,2BAA4B,SAAQ,yBAA8G;IACrJ,QAAQ,CAAsD;IAC9D,MAAM,CAAuC;IAC7C,MAAM,CAAoD;IAC1D,EAAE,CAAmC;IACrC,GAAG,CAAoC;IACvC,cAAc,CAA4D;IAC1E,MAAM,CAAoD;IAC1D,aAAa,CAAsC;IAE5D,YAAY,MAAkC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,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,qBAAqB,EAAE,CAAC,IAAI,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,OAAO;SAC7F,CAAC;QAEF,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,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} 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 { ServiceMetadata } from '../../lib/resolver.ts';\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\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 * Country codes that this KYC provider can service (default is all country codes)\n\t\t */\n\t\tcountryCodes?: (CurrencyInfo.Country | CurrencyInfo.ISOCountryCode)[];\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\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\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 parsed = parseSignatureFromURL(requestUrl);\n\t\t\tconst signedField = parsed.signedField;\n\t\t\tconst account = parsed.account;\n\t\t\tif (!signedField || !account) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Missing signature'));\n\t\t\t}\n\n\t\t\tlet valid: boolean;\n\t\t\ttry {\n\t\t\t\tvalid = await verifySignedData({\n\t\t\t\t\taccount: account.publicKeyString.get(),\n\t\t\t\t\tsigned: signedField\n\t\t\t\t});\n\t\t\t} catch {\n\t\t\t\tvalid = false;\n\t\t\t}\n\n\t\t\tif (!valid) {\n\t\t\t\tthrow(new KeetaAnchorUserError('Invalid signature'));\n\t\t\t}\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 * 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\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\toperations\n\t\t});\n\t}\n}\n"]}
@@ -15,7 +15,7 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
15
15
  if (undefined === value)
16
16
  return true;
17
17
  return false;
18
- })); const _io1 = (input, _exceptionable = true) => (undefined === input.authentication || "object" === typeof input.authentication && null !== input.authentication && _io2(input.authentication, true && _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every(key => {
18
+ })); const _io1 = (input, _exceptionable = true) => (undefined === input.authentication || "object" === typeof input.authentication && null !== input.authentication && _iu0(input.authentication, true && _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every(key => {
19
19
  if (["authentication"].some(prop => key === prop))
20
20
  return true;
21
21
  const value = input[key];
@@ -29,7 +29,19 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
29
29
  if (undefined === value)
30
30
  return true;
31
31
  return false;
32
- })); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.url || __typia_transform__assertGuard._assertGuard(_exceptionable, {
32
+ })); const _io3 = (input, _exceptionable = true) => null !== input.method && undefined === input.method && "none" === input.type && (1 === Object.keys(input).length || Object.keys(input).every(key => {
33
+ if (["method", "type"].some(prop => key === prop))
34
+ return true;
35
+ const value = input[key];
36
+ if (undefined === value)
37
+ return true;
38
+ return false;
39
+ })); const _iu0 = (input, _exceptionable = true) => (() => {
40
+ if ("keeta-account" === input.method)
41
+ return _io2(input, true && _exceptionable);
42
+ else
43
+ return _io3(input, true && _exceptionable);
44
+ })(); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.url || __typia_transform__assertGuard._assertGuard(_exceptionable, {
33
45
  method: "createAssertEquals",
34
46
  path: _path + ".url",
35
47
  expected: "string",
@@ -59,12 +71,12 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
59
71
  }))); const _ao1 = (input, _path, _exceptionable = true) => (undefined === input.authentication || ("object" === typeof input.authentication && null !== input.authentication || __typia_transform__assertGuard._assertGuard(_exceptionable, {
60
72
  method: "createAssertEquals",
61
73
  path: _path + ".authentication",
62
- expected: "(ServiceMetadataAuthenticationType | undefined)",
74
+ expected: "(__type.o2 | __type.o3 | undefined)",
63
75
  value: input.authentication
64
- }, _errorFactory)) && _ao2(input.authentication, _path + ".authentication", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
76
+ }, _errorFactory)) && _au0(input.authentication, _path + ".authentication", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
65
77
  method: "createAssertEquals",
66
78
  path: _path + ".authentication",
67
- expected: "(ServiceMetadataAuthenticationType | undefined)",
79
+ expected: "(__type.o2 | __type.o3 | undefined)",
68
80
  value: input.authentication
69
81
  }, _errorFactory)) && (0 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
70
82
  if (["authentication"].some(prop => key === prop))
@@ -100,7 +112,39 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
100
112
  expected: "undefined",
101
113
  value: value
102
114
  }, _errorFactory);
103
- }))); const __is = (input, _exceptionable = true) => null !== input && undefined !== input && ("string" === typeof input || "object" === typeof input && null !== input && _io0(input, true)); let _errorFactory; return (input, errorFactory) => {
115
+ }))); const _ao3 = (input, _path, _exceptionable = true) => (null !== input.method || __typia_transform__assertGuard._assertGuard(_exceptionable, {
116
+ method: "createAssertEquals",
117
+ path: _path + ".method",
118
+ expected: "undefined",
119
+ value: input.method
120
+ }, _errorFactory)) && (undefined === input.method || __typia_transform__assertGuard._assertGuard(_exceptionable, {
121
+ method: "createAssertEquals",
122
+ path: _path + ".method",
123
+ expected: "undefined",
124
+ value: input.method
125
+ }, _errorFactory)) && ("none" === input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
126
+ method: "createAssertEquals",
127
+ path: _path + ".type",
128
+ expected: "\"none\"",
129
+ value: input.type
130
+ }, _errorFactory)) && (1 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
131
+ if (["method", "type"].some(prop => key === prop))
132
+ return true;
133
+ const value = input[key];
134
+ if (undefined === value)
135
+ return true;
136
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
137
+ method: "createAssertEquals",
138
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
139
+ expected: "undefined",
140
+ value: value
141
+ }, _errorFactory);
142
+ }))); const _au0 = (input, _path, _exceptionable = true) => (() => {
143
+ if ("keeta-account" === input.method)
144
+ return _ao2(input, _path, true && _exceptionable);
145
+ else
146
+ return _ao3(input, _path, true && _exceptionable);
147
+ })(); const __is = (input, _exceptionable = true) => null !== input && undefined !== input && ("string" === typeof input || "object" === typeof input && null !== input && _io0(input, true)); let _errorFactory; return (input, errorFactory) => {
104
148
  if (false === __is(input)) {
105
149
  _errorFactory = errorFactory;
106
150
  ((input, _path, _exceptionable = true) => (null !== input || __typia_transform__assertGuard._assertGuard(true, {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/services/notification/client.ts"],"names":[],"mappings":";;AACA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CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;SACxH,CAAC;QACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC;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 { 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;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,iDAAiD,EACjD,uDAAuD,EACvD,sDAAsD,EACtD,uDAAuD,EACvD,8BAA8B,EAC9B,kCAAkC,EAClC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAYpE,MAAM,wCAAwC,GAAG,MAAM,CAAC,0CAA0C,CAAC,CAAC;AAEpG,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAgD,CAAC;AAqBpF,SAAS,WAAW,CAAC,GAAuB;IAC3C,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,MAAK,CAAC,IAAI,KAAK,CAAC,0BAA0B,CAA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QAED,OAAM,CAAC,SAAS,CAAC,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAgD,EAAE,MAA6B;QACjG,OAAM,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,UAAkB,EAAE,MAA6B;QAClE,MAAM,oBAAoB,GAAyB;YAClD,GAAG,MAAM;YACT,WAAW,EAAE,MAAM,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;SACxH,CAAC;QACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC;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 { 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 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/services/notification/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,qBAAqB,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AAC3F,OAAO,KAAK,EACX,kDAAkD,EAClD,+CAA+C,EAC/C,gCAAgC,EAChC,gDAAgD,EAGhD,sDAAsD,EACtD,sDAAsD,EAEtD,qDAAqD,EACrD,mBAAmB,EAEnB,4BAA4B,EAC5B,qCAAqC,EAErC,MAAM,aAAa,CAAC;AAerB,OAAO,KAAK,EAAE,eAAe,EAAqC,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAIhF,MAAM,WAAW,mCAAoC,SAAQ,+BAA+B;IAC3F,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IACrD,YAAY,EAAE;QACb,cAAc,CAAC,EAAE,C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AC,qBAAqB,CAAC,MAAM,CAAC;cAkK9F,oBAAoB,IAAI,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CA+CjH"}
@@ -15,7 +15,10 @@ export class KeetaNetNotificationAnchorHTTPServer extends KeetaAnchorMetadataSer
15
15
  this.routes = config.routes ?? {};
16
16
  }
17
17
  async initRoutes(config) {
18
- const routes = { ...this.routes };
18
+ const routes = {
19
+ ...(await super.initRoutes(config)),
20
+ ...this.routes
21
+ };
19
22
  if ('homepage' in config) {
20
23
  routes['GET /'] = async function () {
21
24
  let homepageData;
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/services/notification/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAoB1D,OAAO,EACN,4CAA4C,EAC5C,yCAAyC,EACzC,0CAA0C,EAC1C,gDAAgD,EAChD,gDAAgD,EAChD,+CAA+C,EAC/C,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,sDAAsD,EACtD,oDAAoD,EACpD,0DAA0D,EAC1D,0DAA0D,EAC1D,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAmBhF,MAAM,OAAO,oCAAqC,SAAQ,yBAAgI;IAChL,QAAQ,CAA+D;IACvE,YAAY,CAAsD;IAClE,MAAM,CAA6D;IAE5E,YAAY,MAA2C;QACtD,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,C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AAC,oBAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,EAAC,CAAC;QACjI,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC;YAC1C,MAAM,CAAC,UAAU,CAAC,kBAAkB,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,0BAA0B,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,EAAC,CAAC;QACxI,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC;YACzC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC;QAChE,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,CAAC,sBAAsB,EAAE,CAAC;YAC9C,MAAM,CAAC,sBAAsB,GAAG,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC;QAC1E,CAAC;QAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACnD,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC9C,CAAC;QAED,OAAM,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;CACD","sourcesContent":["import * as KeetaNet from '@keetanetwork/keetanet-client';\nimport type * as KeetaAnchorHTTPServer from '../../lib/http-server/index.js';\nimport type { KeetaAnchorMetadataServerConfig } from '../../lib/anchor-metadata-server.js';\nimport type {\n\tKeetaNotificationAnchorRegisterTargetClientRequest,\n\tKeetaNotificationAnchorListTargetsClientRequest,\n\tNotificationTargetWithIDResponse,\n\tKeetaNotificationAnchorDeleteTargetClientRequest,\n\tKeetaNotificationAnchorRegisterTargetRequest,\n\tKeetaNotificationAnchorDeleteTargetRequest,\n\tKeetaNotificationAnchorCreateSubscriptionClientRequest,\n\tKeetaNotificationAnchorDeleteSubscriptionClientRequest,\n\tKeetaNotificationAnchorDeleteSubscriptionRequest,\n\tKeetaNotificationAnchorListSubscriptionsClientRequest,\n\tSubscriptionDetails,\n\tNotificationSubscriptionArguments,\n\tNotificationSubscriptionType,\n\tSupportedChannelConfigurationMetadata,\n\tSubscriptionDetailsJSON\n} from './common.js';\nimport {\n\tgetNotificationRegisterTargetRequestSignable,\n\tgetNotificationListTargetsRequestSignable,\n\tgetNotificationDeleteTargetRequestSignable,\n\tgetNotificationCreateSubscriptionRequestSignable,\n\tgetNotificationDeleteSubscriptionRequestSignable,\n\tgetNotificationListSubscriptionsRequestSignable\n} from './common.js';\nimport {\n\tassertKeetaNotificationAnchorRegisterTargetRequestJSON,\n\tassertKeetaNotificationAnchorDeleteTargetRequestJSON,\n\tassertKeetaNotificationAnchorCreateSubscriptionRequestJSON,\n\tassertKeetaNotificationAnchorDeleteSubscriptionRequestJSON\n} from './common.server.generated.js';\nimport type { ServiceMetadata, ServiceMetadataAuthenticationType } from '../../lib/resolver.js';\nimport { KeetaAnchorMetadataServer } from '../../lib/anchor-metadata-server.js';\nimport { KeetaAnchorUserError } from '../../lib/error.js';\nimport { verifyBodyAuth, verifyURLAuth } from '../../lib/http-server/common.js';\n\nexport interface KeetaAnchorNotificationServerConfig extends KeetaAnchorMetadataServerConfig {\n\thomepage?: string | (() => Promise<string> | string);\n\tnotification: {\n\t\tregisterTarget?: (args: Required<KeetaNotificationAnchorRegisterTargetClientRequest>) => Promise<{ id: string; }>;\n\t\tlistTargets?: (args: Required<KeetaNotificationAnchorListTargetsClientRequest>) => Promise<{ targets: NotificationTargetWithIDResponse[]; }>;\n\t\tdeleteTarget?: (args: Required<KeetaNotificationAnchorDeleteTargetClientRequest>) => Promise<{ ok: boolean; }>;\n\n\t\tcreateSubscription?: (args: Required<KeetaNotificationAnchorCreateSubscriptionClientRequest>) => Promise<{ id: string; }>;\n\t\tlistSubscriptions?: (args: Required<KeetaNotificationAnchorListSubscriptionsClientRequest>) => Promise<{ subscriptions: SubscriptionDetails[]; }>;\n\t\tdeleteSubscription?: (args: Required<KeetaNotificationAnchorDeleteSubscriptionClientRequest>) => Promise<{ ok: boolean; }>;\n\n\t\tsupportedChannels?: SupportedChannelConfigurationMetadata;\n\t\tsupportedSubscriptions?: NotificationSubscriptionType[];\n\t};\n\troutes?: KeetaAnchorHTTPServer.Routes;\n}\n\nexport class KeetaNetNotificationAnchorHTTPServer extends KeetaAnchorMetadataServer<NonNullable<ServiceMetadata['services']['notification']>[string], KeetaAnchorNotificationServerConfig> {\n\treadonly homepage: NonNullable<KeetaAnchorNotificationServerConfig['homepage']>;\n\treadonly notification: KeetaAnchorNotificationServerConfig['notification'];\n\treadonly routes: NonNullable<KeetaAnchorNotificationServerConfig['routes']>;\n\n\tconstructor(config: KeetaAnchorNotificationServerConfig) {\n\t\tsuper(config);\n\n\t\tthis.homepage = config.homepage ?? '';\n\t\tthis.notification = config.notification;\n\t\tthis.routes = config.routes ?? {};\n\t}\n\n\tprotected async initRoutes(config: KeetaAnchorNotificationServerConfig): Promise<KeetaAnchorHTTPServer.Routes> {\n\t\tconst routes: KeetaAnchorHTTPServer.Routes = { ...this.routes };\n\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; charset=utf-8'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst registerTargetHandler = this.notification.registerTarget;\n\t\tif (registerTargetHandler) {\n\t\t\troutes['POST /api/target'] = async (_params, body) => {\n\t\t\t\tconst raw = assertKeetaNotificationAnchorRegisterTargetRequestJSON(body);\n\t\t\t\tconst account = await verifyBodyAuth(raw, getNotificationRegisterTargetRequestSignable, this.resolvedCertificateChainRequirement);\n\t\t\t\tconst request: Required<KeetaNotificationAnchorRegisterTargetRequest> = { ...raw, account };\n\t\t\t\tconst registerResponse = await registerTargetHandler(request);\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\tid: registerResponse.id\n\t\t\t\t\t}),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst listTargetsHandler = this.notification.listTargets;\n\t\tif (listTargetsHandler) {\n\t\t\troutes['GET /api/targets'] = async (_ignore_params, _ignore_body, _ignore_headers, url) => {\n\t\t\t\tconst account = await verifyURLAuth(\n\t\t\t\t\turl,\n\t\t\t\t\tfunction() { return(getNotificationListTargetsRequestSignable()); },\n\t\t\t\t\tthis.resolvedCertificateChainRequirement\n\t\t\t\t);\n\t\t\t\tconst listResponse = await listTargetsHandler({ account });\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\ttargets: listResponse.targets\n\t\t\t\t\t}),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst deleteTargetHandler = this.notification.deleteTarget;\n\t\tif (deleteTargetHandler) {\n\t\t\t// XXX:TODO should this be post with body or delete with URL param? Delete with URL param is more RESTful but can be more difficult to call from some clients and doesn't allow for a request body (so all data must be in the URL or signature)\n\t\t\troutes['POST /api/delete-target'] = async (_params, body) => {\n\t\t\t\tconst raw = assertKeetaNotificationAnchorDeleteTargetRequestJSON(body);\n\t\t\t\tconst account = await verifyBodyAuth(raw, getNotificationDeleteTargetRequestSignable, this.resolvedCertificateChainRequirement);\n\t\t\t\tconst request: Required<KeetaNotificationAnchorDeleteTargetRequest> = { ...raw, account };\n\t\t\t\tconst deleteResponse = await deleteTargetHandler(request);\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify(deleteResponse),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst createSubscriptionHandler = this.notification.createSubscription;\n\t\tif (createSubscriptionHandler) {\n\t\t\troutes['POST /api/subscription'] = async (_params, body) => {\n\t\t\t\tconst raw = assertKeetaNotificationAnchorCreateSubscriptionRequestJSON(body);\n\n\t\t\t\tlet subscription: NotificationSubscriptionArguments;\n\t\t\t\tif (raw.subscription.type === 'RECEIVE_FUNDS') {\n\t\t\t\t\tsubscription = {\n\t\t\t\t\t\ttype: 'RECEIVE_FUNDS',\n\t\t\t\t\t\ttarget: raw.subscription.target,\n\t\t\t\t\t\t...(raw.subscription.toAddress\n\t\t\t\t\t\t\t? { toAddress: KeetaNet.lib.Account.fromPublicKeyString(raw.subscription.toAddress) }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t...(raw.subscription.locale ? { locale: new Intl.Locale(raw.subscription.locale) } : {})\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tthrow(new KeetaAnchorUserError(`Unsupported subscription type`));\n\t\t\t\t}\n\n\t\t\t\tconst account = await verifyBodyAuth(raw, function() {\n\t\t\t\t\treturn(getNotificationCreateSubscriptionRequestSignable({ subscription }));\n\t\t\t\t}, this.resolvedCertificateChainRequirement);\n\n\t\t\t\tconst request = { account, subscription, signed: raw.signed };\n\t\t\t\tconst createResponse = await createSubscriptionHandler(request);\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify({ ok: true, id: createResponse.id }),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst listSubscriptionsHandler = this.notification.listSubscriptions;\n\t\tif (listSubscriptionsHandler) {\n\t\t\troutes['GET /api/subscriptions'] = async (_ignore_params, _ignore_body, _ignore_headers, url) => {\n\t\t\t\tconst account = await verifyURLAuth(\n\t\t\t\t\turl,\n\t\t\t\t\tfunction() { return(getNotificationListSubscriptionsRequestSignable()); },\n\t\t\t\t\tthis.resolvedCertificateChainRequirement\n\t\t\t\t);\n\n\t\t\t\tconst listResponse = await listSubscriptionsHandler({ account });\n\t\t\t\tconst subscriptionsJSON: SubscriptionDetailsJSON[] = listResponse.subscriptions.map(function(subscription): SubscriptionDetailsJSON {\n\t\t\t\t\tconst { locale, ...restSubscription } = subscription.subscription;\n\t\t\t\t\treturn({\n\t\t\t\t\t\t...subscription,\n\t\t\t\t\t\tsubscription: {\n\t\t\t\t\t\t\t...KeetaNet.lib.Utils.Conversion.toJSONSerializable(restSubscription),\n\t\t\t\t\t\t\t...(locale ? { locale: locale.toString() } : {})\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify(KeetaNet.lib.Utils.Conversion.toJSONSerializable({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\tsubscriptions: subscriptionsJSON\n\t\t\t\t\t})),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst deleteSubscriptionHandler = this.notification.deleteSubscription;\n\t\tif (deleteSubscriptionHandler) {\n\t\t\troutes['POST /api/delete-subscription'] = async (_params, body) => {\n\t\t\t\tconst raw = assertKeetaNotificationAnchorDeleteSubscriptionRequestJSON(body);\n\t\t\t\tconst account = await verifyBodyAuth(raw, getNotificationDeleteSubscriptionRequestSignable, this.resolvedCertificateChainRequirement);\n\t\t\t\tconst request: Required<KeetaNotificationAnchorDeleteSubscriptionRequest> = { ...raw, account };\n\t\t\t\tconst deleteResponse = await deleteSubscriptionHandler(request);\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify(deleteResponse),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\treturn(routes);\n\t}\n\n\tprotected async buildServiceMetadata(): Promise<NonNullable<ServiceMetadata['services']['notification']>[string]> {\n\t\tconst retval: NonNullable<ServiceMetadata['services']['notification']>[string] = { operations: {}};\n\n\t\tconst authentication: ServiceMetadataAuthenticationType = {\n\t\t\tmethod: 'keeta-account',\n\t\t\ttype: 'required'\n\t\t}\n\n\t\tif (this.notification.registerTarget) {\n\t\t\tretval.operations.registerTarget = { url: (new URL('/api/target', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.listTargets) {\n\t\t\tretval.operations.listTargets = { url: (new URL('/api/targets', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.deleteTarget) {\n\t\t\tretval.operations.deleteTarget = { url: (new URL('/api/delete-target', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.createSubscription) {\n\t\t\tretval.operations.createSubscription = { url: (new URL('/api/subscription', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.listSubscriptions) {\n\t\t\tretval.operations.listSubscriptions = { url: (new URL('/api/subscriptions', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.deleteSubscription) {\n\t\t\tretval.operations.deleteSubscription = { url: (new URL('/api/delete-subscription', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.supportedChannels) {\n\t\t\tretval.supportedChannels = this.notification.supportedChannels;\n\t\t}\n\n\t\tif (this.notification.supportedSubscriptions) {\n\t\t\tretval.supportedSubscriptions = this.notification.supportedSubscriptions;\n\t\t}\n\n\t\tconst acceptedIssuerDNs = this.acceptedIssuerDNs();\n\t\tif (acceptedIssuerDNs !== undefined) {\n\t\t\tretval.acceptedIssuerDNs = acceptedIssuerDNs;\n\t\t}\n\n\t\treturn(retval);\n\t}\n}\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/services/notification/server.ts"],"names":[],"mappings":"AAAA,OAAO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AAE,CAAC;YACzC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC;QAChE,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,CAAC,sBAAsB,EAAE,CAAC;YAC9C,MAAM,CAAC,sBAAsB,GAAG,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC;QAC1E,CAAC;QAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACnD,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC9C,CAAC;QAED,OAAM,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;CACD","sourcesContent":["import * as KeetaNet from '@keetanetwork/keetanet-client';\nimport type * as KeetaAnchorHTTPServer from '../../lib/http-server/index.js';\nimport type { KeetaAnchorMetadataServerConfig } from '../../lib/anchor-metadata-server.js';\nimport type {\n\tKeetaNotificationAnchorRegisterTargetClientRequest,\n\tKeetaNotificationAnchorListTargetsClientRequest,\n\tNotificationTargetWithIDResponse,\n\tKeetaNotificationAnchorDeleteTargetClientRequest,\n\tKeetaNotificationAnchorRegisterTargetRequest,\n\tKeetaNotificationAnchorDeleteTargetRequest,\n\tKeetaNotificationAnchorCreateSubscriptionClientRequest,\n\tKeetaNotificationAnchorDeleteSubscriptionClientRequest,\n\tKeetaNotificationAnchorDeleteSubscriptionRequest,\n\tKeetaNotificationAnchorListSubscriptionsClientRequest,\n\tSubscriptionDetails,\n\tNotificationSubscriptionArguments,\n\tNotificationSubscriptionType,\n\tSupportedChannelConfigurationMetadata,\n\tSubscriptionDetailsJSON\n} from './common.js';\nimport {\n\tgetNotificationRegisterTargetRequestSignable,\n\tgetNotificationListTargetsRequestSignable,\n\tgetNotificationDeleteTargetRequestSignable,\n\tgetNotificationCreateSubscriptionRequestSignable,\n\tgetNotificationDeleteSubscriptionRequestSignable,\n\tgetNotificationListSubscriptionsRequestSignable\n} from './common.js';\nimport {\n\tassertKeetaNotificationAnchorRegisterTargetRequestJSON,\n\tassertKeetaNotificationAnchorDeleteTargetRequestJSON,\n\tassertKeetaNotificationAnchorCreateSubscriptionRequestJSON,\n\tassertKeetaNotificationAnchorDeleteSubscriptionRequestJSON\n} from './common.server.generated.js';\nimport type { ServiceMetadata, ServiceMetadataAuthenticationType } from '../../lib/resolver.js';\nimport { KeetaAnchorMetadataServer } from '../../lib/anchor-metadata-server.js';\nimport { KeetaAnchorUserError } from '../../lib/error.js';\nimport { verifyBodyAuth, verifyURLAuth } from '../../lib/http-server/common.js';\n\nexport interface KeetaAnchorNotificationServerConfig extends KeetaAnchorMetadataServerConfig {\n\thomepage?: string | (() => Promise<string> | string);\n\tnotification: {\n\t\tregisterTarget?: (args: Required<KeetaNotificationAnchorRegisterTargetClientRequest>) => Promise<{ id: string; }>;\n\t\tlistTargets?: (args: Required<KeetaNotificationAnchorListTargetsClientRequest>) => Promise<{ targets: NotificationTargetWithIDResponse[]; }>;\n\t\tdeleteTarget?: (args: Required<KeetaNotificationAnchorDeleteTargetClientRequest>) => Promise<{ ok: boolean; }>;\n\n\t\tcreateSubscription?: (args: Required<KeetaNotificationAnchorCreateSubscriptionClientRequest>) => Promise<{ id: string; }>;\n\t\tlistSubscriptions?: (args: Required<KeetaNotificationAnchorListSubscriptionsClientRequest>) => Promise<{ subscriptions: SubscriptionDetails[]; }>;\n\t\tdeleteSubscription?: (args: Required<KeetaNotificationAnchorDeleteSubscriptionClientRequest>) => Promise<{ ok: boolean; }>;\n\n\t\tsupportedChannels?: SupportedChannelConfigurationMetadata;\n\t\tsupportedSubscriptions?: NotificationSubscriptionType[];\n\t};\n\troutes?: KeetaAnchorHTTPServer.Routes;\n}\n\nexport class KeetaNetNotificationAnchorHTTPServer extends KeetaAnchorMetadataServer<NonNullable<ServiceMetadata['services']['notification']>[string], KeetaAnchorNotificationServerConfig> {\n\treadonly homepage: NonNullable<KeetaAnchorNotificationServerConfig['homepage']>;\n\treadonly notification: KeetaAnchorNotificationServerConfig['notification'];\n\treadonly routes: NonNullable<KeetaAnchorNotificationServerConfig['routes']>;\n\n\tconstructor(config: KeetaAnchorNotificationServerConfig) {\n\t\tsuper(config);\n\n\t\tthis.homepage = config.homepage ?? '';\n\t\tthis.notification = config.notification;\n\t\tthis.routes = config.routes ?? {};\n\t}\n\n\tprotected async initRoutes(config: KeetaAnchorNotificationServerConfig): Promise<KeetaAnchorHTTPServer.Routes> {\n\t\tconst routes: KeetaAnchorHTTPServer.Routes = {\n\t\t\t...(await super.initRoutes(config)),\n\t\t\t...this.routes\n\t\t};\n\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; charset=utf-8'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst registerTargetHandler = this.notification.registerTarget;\n\t\tif (registerTargetHandler) {\n\t\t\troutes['POST /api/target'] = async (_params, body) => {\n\t\t\t\tconst raw = assertKeetaNotificationAnchorRegisterTargetRequestJSON(body);\n\t\t\t\tconst account = await verifyBodyAuth(raw, getNotificationRegisterTargetRequestSignable, this.resolvedCertificateChainRequirement);\n\t\t\t\tconst request: Required<KeetaNotificationAnchorRegisterTargetRequest> = { ...raw, account };\n\t\t\t\tconst registerResponse = await registerTargetHandler(request);\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\tid: registerResponse.id\n\t\t\t\t\t}),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst listTargetsHandler = this.notification.listTargets;\n\t\tif (listTargetsHandler) {\n\t\t\troutes['GET /api/targets'] = async (_ignore_params, _ignore_body, _ignore_headers, url) => {\n\t\t\t\tconst account = await verifyURLAuth(\n\t\t\t\t\turl,\n\t\t\t\t\tfunction() { return(getNotificationListTargetsRequestSignable()); },\n\t\t\t\t\tthis.resolvedCertificateChainRequirement\n\t\t\t\t);\n\t\t\t\tconst listResponse = await listTargetsHandler({ account });\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\ttargets: listResponse.targets\n\t\t\t\t\t}),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst deleteTargetHandler = this.notification.deleteTarget;\n\t\tif (deleteTargetHandler) {\n\t\t\t// XXX:TODO should this be post with body or delete with URL param? Delete with URL param is more RESTful but can be more difficult to call from some clients and doesn't allow for a request body (so all data must be in the URL or signature)\n\t\t\troutes['POST /api/delete-target'] = async (_params, body) => {\n\t\t\t\tconst raw = assertKeetaNotificationAnchorDeleteTargetRequestJSON(body);\n\t\t\t\tconst account = await verifyBodyAuth(raw, getNotificationDeleteTargetRequestSignable, this.resolvedCertificateChainRequirement);\n\t\t\t\tconst request: Required<KeetaNotificationAnchorDeleteTargetRequest> = { ...raw, account };\n\t\t\t\tconst deleteResponse = await deleteTargetHandler(request);\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify(deleteResponse),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst createSubscriptionHandler = this.notification.createSubscription;\n\t\tif (createSubscriptionHandler) {\n\t\t\troutes['POST /api/subscription'] = async (_params, body) => {\n\t\t\t\tconst raw = assertKeetaNotificationAnchorCreateSubscriptionRequestJSON(body);\n\n\t\t\t\tlet subscription: NotificationSubscriptionArguments;\n\t\t\t\tif (raw.subscription.type === 'RECEIVE_FUNDS') {\n\t\t\t\t\tsubscription = {\n\t\t\t\t\t\ttype: 'RECEIVE_FUNDS',\n\t\t\t\t\t\ttarget: raw.subscription.target,\n\t\t\t\t\t\t...(raw.subscription.toAddress\n\t\t\t\t\t\t\t? { toAddress: KeetaNet.lib.Account.fromPublicKeyString(raw.subscription.toAddress) }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t...(raw.subscription.locale ? { locale: new Intl.Locale(raw.subscription.locale) } : {})\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tthrow(new KeetaAnchorUserError(`Unsupported subscription type`));\n\t\t\t\t}\n\n\t\t\t\tconst account = await verifyBodyAuth(raw, function() {\n\t\t\t\t\treturn(getNotificationCreateSubscriptionRequestSignable({ subscription }));\n\t\t\t\t}, this.resolvedCertificateChainRequirement);\n\n\t\t\t\tconst request = { account, subscription, signed: raw.signed };\n\t\t\t\tconst createResponse = await createSubscriptionHandler(request);\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify({ ok: true, id: createResponse.id }),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst listSubscriptionsHandler = this.notification.listSubscriptions;\n\t\tif (listSubscriptionsHandler) {\n\t\t\troutes['GET /api/subscriptions'] = async (_ignore_params, _ignore_body, _ignore_headers, url) => {\n\t\t\t\tconst account = await verifyURLAuth(\n\t\t\t\t\turl,\n\t\t\t\t\tfunction() { return(getNotificationListSubscriptionsRequestSignable()); },\n\t\t\t\t\tthis.resolvedCertificateChainRequirement\n\t\t\t\t);\n\n\t\t\t\tconst listResponse = await listSubscriptionsHandler({ account });\n\t\t\t\tconst subscriptionsJSON: SubscriptionDetailsJSON[] = listResponse.subscriptions.map(function(subscription): SubscriptionDetailsJSON {\n\t\t\t\t\tconst { locale, ...restSubscription } = subscription.subscription;\n\t\t\t\t\treturn({\n\t\t\t\t\t\t...subscription,\n\t\t\t\t\t\tsubscription: {\n\t\t\t\t\t\t\t...KeetaNet.lib.Utils.Conversion.toJSONSerializable(restSubscription),\n\t\t\t\t\t\t\t...(locale ? { locale: locale.toString() } : {})\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify(KeetaNet.lib.Utils.Conversion.toJSONSerializable({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\tsubscriptions: subscriptionsJSON\n\t\t\t\t\t})),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\tconst deleteSubscriptionHandler = this.notification.deleteSubscription;\n\t\tif (deleteSubscriptionHandler) {\n\t\t\troutes['POST /api/delete-subscription'] = async (_params, body) => {\n\t\t\t\tconst raw = assertKeetaNotificationAnchorDeleteSubscriptionRequestJSON(body);\n\t\t\t\tconst account = await verifyBodyAuth(raw, getNotificationDeleteSubscriptionRequestSignable, this.resolvedCertificateChainRequirement);\n\t\t\t\tconst request: Required<KeetaNotificationAnchorDeleteSubscriptionRequest> = { ...raw, account };\n\t\t\t\tconst deleteResponse = await deleteSubscriptionHandler(request);\n\n\t\t\t\treturn({\n\t\t\t\t\toutput: JSON.stringify(deleteResponse),\n\t\t\t\t\tcontentType: 'application/json'\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\n\t\treturn(routes);\n\t}\n\n\tprotected async buildServiceMetadata(): Promise<NonNullable<ServiceMetadata['services']['notification']>[string]> {\n\t\tconst retval: NonNullable<ServiceMetadata['services']['notification']>[string] = { operations: {}};\n\n\t\tconst authentication: ServiceMetadataAuthenticationType = {\n\t\t\tmethod: 'keeta-account',\n\t\t\ttype: 'required'\n\t\t}\n\n\t\tif (this.notification.registerTarget) {\n\t\t\tretval.operations.registerTarget = { url: (new URL('/api/target', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.listTargets) {\n\t\t\tretval.operations.listTargets = { url: (new URL('/api/targets', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.deleteTarget) {\n\t\t\tretval.operations.deleteTarget = { url: (new URL('/api/delete-target', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.createSubscription) {\n\t\t\tretval.operations.createSubscription = { url: (new URL('/api/subscription', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.listSubscriptions) {\n\t\t\tretval.operations.listSubscriptions = { url: (new URL('/api/subscriptions', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.deleteSubscription) {\n\t\t\tretval.operations.deleteSubscription = { url: (new URL('/api/delete-subscription', this.url)).toString(), options: { authentication }};\n\t\t}\n\n\t\tif (this.notification.supportedChannels) {\n\t\t\tretval.supportedChannels = this.notification.supportedChannels;\n\t\t}\n\n\t\tif (this.notification.supportedSubscriptions) {\n\t\t\tretval.supportedSubscriptions = this.notification.supportedSubscriptions;\n\t\t}\n\n\t\tconst acceptedIssuerDNs = this.acceptedIssuerDNs();\n\t\tif (acceptedIssuerDNs !== undefined) {\n\t\t\tretval.acceptedIssuerDNs = acceptedIssuerDNs;\n\t\t}\n\n\t\treturn(retval);\n\t}\n}\n"]}
@@ -22,7 +22,7 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
22
22
  if (undefined === value)
23
23
  return true;
24
24
  return false;
25
- })); const _io1 = (input, _exceptionable = true) => (undefined === input.authentication || "object" === typeof input.authentication && null !== input.authentication && _io2(input.authentication, true && _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every(key => {
25
+ })); const _io1 = (input, _exceptionable = true) => (undefined === input.authentication || "object" === typeof input.authentication && null !== input.authentication && _iu0(input.authentication, true && _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every(key => {
26
26
  if (["authentication"].some(prop => key === prop))
27
27
  return true;
28
28
  const value = input[key];
@@ -36,7 +36,19 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
36
36
  if (undefined === value)
37
37
  return true;
38
38
  return false;
39
- })); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.url || __typia_transform__assertGuard._assertGuard(_exceptionable, {
39
+ })); const _io3 = (input, _exceptionable = true) => null !== input.method && undefined === input.method && "none" === input.type && (1 === Object.keys(input).length || Object.keys(input).every(key => {
40
+ if (["method", "type"].some(prop => key === prop))
41
+ return true;
42
+ const value = input[key];
43
+ if (undefined === value)
44
+ return true;
45
+ return false;
46
+ })); const _iu0 = (input, _exceptionable = true) => (() => {
47
+ if ("keeta-account" === input.method)
48
+ return _io2(input, true && _exceptionable);
49
+ else
50
+ return _io3(input, true && _exceptionable);
51
+ })(); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.url || __typia_transform__assertGuard._assertGuard(_exceptionable, {
40
52
  method: "createAssertEquals",
41
53
  path: _path + ".url",
42
54
  expected: "string",
@@ -66,12 +78,12 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
66
78
  }))); const _ao1 = (input, _path, _exceptionable = true) => (undefined === input.authentication || ("object" === typeof input.authentication && null !== input.authentication || __typia_transform__assertGuard._assertGuard(_exceptionable, {
67
79
  method: "createAssertEquals",
68
80
  path: _path + ".authentication",
69
- expected: "(ServiceMetadataAuthenticationType | undefined)",
81
+ expected: "(__type.o2 | __type.o3 | undefined)",
70
82
  value: input.authentication
71
- }, _errorFactory)) && _ao2(input.authentication, _path + ".authentication", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
83
+ }, _errorFactory)) && _au0(input.authentication, _path + ".authentication", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
72
84
  method: "createAssertEquals",
73
85
  path: _path + ".authentication",
74
- expected: "(ServiceMetadataAuthenticationType | undefined)",
86
+ expected: "(__type.o2 | __type.o3 | undefined)",
75
87
  value: input.authentication
76
88
  }, _errorFactory)) && (0 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
77
89
  if (["authentication"].some(prop => key === prop))
@@ -107,7 +119,39 @@ const assertServiceMetadataEndpoint = (() => { const _io0 = (input, _exceptionab
107
119
  expected: "undefined",
108
120
  value: value
109
121
  }, _errorFactory);
110
- }))); const __is = (input, _exceptionable = true) => null !== input && undefined !== input && ("string" === typeof input || "object" === typeof input && null !== input && _io0(input, true)); let _errorFactory; return (input, errorFactory) => {
122
+ }))); const _ao3 = (input, _path, _exceptionable = true) => (null !== input.method || __typia_transform__assertGuard._assertGuard(_exceptionable, {
123
+ method: "createAssertEquals",
124
+ path: _path + ".method",
125
+ expected: "undefined",
126
+ value: input.method
127
+ }, _errorFactory)) && (undefined === input.method || __typia_transform__assertGuard._assertGuard(_exceptionable, {
128
+ method: "createAssertEquals",
129
+ path: _path + ".method",
130
+ expected: "undefined",
131
+ value: input.method
132
+ }, _errorFactory)) && ("none" === input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
133
+ method: "createAssertEquals",
134
+ path: _path + ".type",
135
+ expected: "\"none\"",
136
+ value: input.type
137
+ }, _errorFactory)) && (1 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
138
+ if (["method", "type"].some(prop => key === prop))
139
+ return true;
140
+ const value = input[key];
141
+ if (undefined === value)
142
+ return true;
143
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
144
+ method: "createAssertEquals",
145
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
146
+ expected: "undefined",
147
+ value: value
148
+ }, _errorFactory);
149
+ }))); const _au0 = (input, _path, _exceptionable = true) => (() => {
150
+ if ("keeta-account" === input.method)
151
+ return _ao2(input, _path, true && _exceptionable);
152
+ else
153
+ return _ao3(input, _path, true && _exceptionable);
154
+ })(); const __is = (input, _exceptionable = true) => null !== input && undefined !== input && ("string" === typeof input || "object" === typeof input && null !== input && _io0(input, true)); let _errorFactory; return (input, errorFactory) => {
111
155
  if (false === __is(input)) {
112
156
  _errorFactory = errorFactory;
113
157
  ((input, _path, _exceptionable = true) => (null !== input || __typia_transform__assertGuard._assertGuard(true, {