import { Get, Injectable } from '@nestjs/common'; import { Indexes } from '../indexes.js'; import { Address4, Address6 } from 'ip-address'; export type AdditionalData = { ip: Address4 | Address6 }; export type HKPOperation = keyof AbstractKeysProvider; export type GetOperationReturn = string | 404; export const VALID_OPS: readonly HKPOperation[] = Object.freeze([ 'get', 'index' ]) /** https://www.ietf.org/archive/id/draft-gallagher-openpgp-hkp-05.html#name-the-op-operation-field */ @Injectable() export abstract class AbstractKeysProvider { readonly url = Object.freeze('http://none'); /** The "get" operation requests keys from the keyserver by textual search. A string that specifies which key(s) to return is provided in the "search" field. The response to a successful "get" request is a HTTP document containing an ASCII-armored keyring as specified in [Section 8](https://www.ietf.org/archive/id/draft-gallagher-openpgp-hkp-05.html#keyring-format). The response MAY be wrapped in any HTML or other text desired, except that the actual key data consisting of an initial line break, the "-----BEGIN PGP PUBLIC KEY BLOCK-----" header, the armored key data itself, the "-----END PGP PUBLIC KEY BLOCK-----" header, and a final line break MUST NOT be modified from the form specified in [[I-D.ietf-openpgp-crypto-refresh](https://www.ietf.org/archive/id/draft-gallagher-openpgp-hkp-05.html#I-D.ietf-openpgp-crypto-refresh)]. If no keys match the request, the keyserver SHOULD return an appropriate HTTP error code such as 404 ("Not Found"). */ @Get() async get(search: string, data: AdditionalData): Promise { return 404 } @Get() async index(search: string, data: AdditionalData): Promise { return [] } }