import type { JWK } from 'jose'; import type { MdocContext } from '../../c-mdoc.js'; import type { DeviceRequest } from './device-request.js'; import { MDoc } from './mdoc.js'; import type { PresentationDefinition } from './presentation-definition.js'; import type { MacSupportedAlgs, SupportedAlgs } from './types.js'; /** * A builder class for creating a device response. */ export declare class DeviceResponse { private mdoc; private pd?; private deviceRequest?; private sessionTranscriptBytes?; private useMac; private devicePrivateKey?; nameSpaces: Record>; private alg?; private macAlg?; private ephemeralPublicKey?; /** * Create a DeviceResponse builder. * * @param {MDoc | Uint8Array} mdoc - The mdoc to use as a base for the device response. * It can be either a parsed MDoc or a CBOR encoded MDoc. * @returns {DeviceResponse} - A DeviceResponse builder. */ static from(mdoc: MDoc | Uint8Array): DeviceResponse; constructor(mdoc: MDoc); /** * * @param pd - The presentation definition to use for the device response. * @returns {DeviceResponse} */ usingPresentationDefinition(pd: PresentationDefinition): DeviceResponse; /** * * @param deviceRequest - The device request * @returns {DeviceResponse} */ usingDeviceRequest(deviceRequest: DeviceRequest): DeviceResponse; /** * Set the session transcript data to use for the device response. * * This is arbitrary and should match the session transcript as it will be calculated by the verifier. * The transcript must be a CBOR encoded DataItem of an array, there is no further requirement. * * Example: `usingSessionTranscriptBytes(cborEncode(DataItem.fromData([a,b,c])))` where `a`, `b` and `c` can be anything including `null`. * * It is preferable to use {@link usingSessionTranscriptForOID4VP} or {@link usingSessionTranscriptForWebAPI} when possible. * * @param {Uint8Array} sessionTranscriptBytes - The sessionTranscriptBytes data to use in the session transcript. * @returns {DeviceResponse} */ usingSessionTranscriptBytes(sessionTranscriptBytes: Uint8Array): DeviceResponse; /** * Set the session transcript data to use for the device response as defined in ISO/IEC 18013-7 in Annex B (OID4VP), 2023 draft. * * This should match the session transcript as it will be calculated by the verifier. * * @param {string} mdocGeneratedNonce - A cryptographically random number with sufficient entropy. * @param {string} clientId - The client_id Authorization Request parameter from the Authorization Request Object. * @param {string} responseUri - The response_uri Authorization Request parameter from the Authorization Request Object. * @param {string} verifierGeneratedNonce - The nonce Authorization Request parameter from the Authorization Request Object. * @returns {DeviceResponse} */ usingSessionTranscriptForOID4VP(input: { mdocGeneratedNonce: string; clientId: string; responseUri: string; verifierGeneratedNonce: string; }): DeviceResponse; static calculateSessionTranscriptForOID4VP(input: { mdocGeneratedNonce: string; clientId: string; responseUri: string; verifierGeneratedNonce: string; }): Uint8Array; /** * Set the session transcript data to use for the device response as defined in ISO/IEC 18013-7 in Annex A (Web API), 2023 draft. * * This should match the session transcript as it will be calculated by the verifier. * * @param {Uint8Array} deviceEngagementBytes - The device engagement, encoded as a Tagged 24 cbor * @param {Uint8Array} readerEngagementBytes - The reader engagement, encoded as a Tagged 24 cbor * @param {Uint8Array} eReaderKeyBytes - The reader ephemeral public key as a COSE Key, encoded as a Tagged 24 cbor * @returns {DeviceResponse} */ usingSessionTranscriptForWebAPI(input: { deviceEngagementBytes: Uint8Array; readerEngagementBytes: Uint8Array; eReaderKeyBytes: Uint8Array; }): DeviceResponse; static calculateSessionTranscriptForWebApi(input: { deviceEngagementBytes: Uint8Array; readerEngagementBytes: Uint8Array; eReaderKeyBytes: Uint8Array; }): Uint8Array; /** * Add a namespace to the device response. * * @param {string} nameSpace - The name space to add to the device response. * @param {Record} data - The data to add to the name space. * @returns {DeviceResponse} */ addDeviceNameSpace(nameSpace: string, data: Record): DeviceResponse; /** * Set the device's private key to be used for signing the device response. * * @param {JWK} devicePrivateKey - The device's private key either as a JWK or a COSEKey. * @param {SupportedAlgs} alg - The algorithm to use for signing the device response. * @returns {DeviceResponse} */ authenticateWithSignature(devicePrivateKey: JWK, alg: SupportedAlgs): DeviceResponse; /** * Set the reader shared key to be used for signing the device response with MAC. * * @param {JWK} devicePrivateKey - The device's private key either as a JWK or a COSEKey. * @param {JWK} ephemeralPublicKey - The public part of the ephemeral key generated by the MDOC. * @param {SupportedAlgs} alg - The algorithm to use for signing the device response. * @returns {DeviceResponse} */ authenticateWithMAC(devicePrivateKey: JWK, ephemeralPublicKey: JWK, alg: MacSupportedAlgs): DeviceResponse; /** * Sign the device response and return the MDoc. * * @returns {Promise} - The device response as an MDoc. */ sign(ctx: { crypto: MdocContext['crypto']; cose: MdocContext['cose']; }): Promise; private getDeviceSigned; private getDeviceAuthMac; private getDeviceAuthSign; } //# sourceMappingURL=device-response.d.ts.map