private async decodeRequest()

in runtimes/runtimes/chat/encryptedChat.ts [134:152]


    private async decodeRequest<T>(request: EncryptedRequestParams): Promise<T> {
        if (!this.key) {
            throw new Error('No encryption key')
        }

        if (this.encoding === 'JWT') {
            const result = await jwtDecrypt(request.message, this.keyBuffer, {
                clockTolerance: 60,
                contentEncryptionAlgorithms: [CONTENT_ENCRYPTION_ALGORITHM],
                keyManagementAlgorithms: [KEY_MANAGEMENT_ALGORITHM],
            })

            if (!result.payload) {
                throw new Error('JWT payload not found')
            }
            return result.payload as T
        }
        throw new Error('Encoding mode not implemented')
    }