Files
libsignal/node/ts/zkgroup/backups/BackupAuthCredentialRequestContext.ts
Jordan Rose 85686caa01 node: Combine Native.js and .d.ts into Native.ts
This allows the file to be checked by tsc, which would have caught
some of the missing type aliases sooner (now added to Native.ts.in).
Strictly speaking the behavior is slightly different: we have returned
to exporting many items individually instead of collecting them on a
single object.

Co-authored-by: Alex Bakon <akonradi@signal.org>
2025-10-15 17:50:37 -07:00

57 lines
1.6 KiB
TypeScript

//
// Copyright 2023 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
import * as uuid from 'uuid';
import ByteArray from '../internal/ByteArray.js';
import * as Native from '../../Native.js';
import BackupAuthCredentialRequest from './BackupAuthCredentialRequest.js';
import BackupAuthCredentialResponse from './BackupAuthCredentialResponse.js';
import BackupAuthCredential from './BackupAuthCredential.js';
import GenericServerPublicParams from '../GenericServerPublicParams.js';
import type { Uuid } from '../../index.js';
export default class BackupAuthCredentialRequestContext extends ByteArray {
private readonly __type?: never;
constructor(contents: Uint8Array) {
super(
contents,
Native.BackupAuthCredentialRequestContext_CheckValidContents
);
}
static create(
backupKey: Uint8Array,
aci: Uuid
): BackupAuthCredentialRequestContext {
return new BackupAuthCredentialRequestContext(
Native.BackupAuthCredentialRequestContext_New(backupKey, uuid.parse(aci))
);
}
getRequest(): BackupAuthCredentialRequest {
return new BackupAuthCredentialRequest(
Native.BackupAuthCredentialRequestContext_GetRequest(this.contents)
);
}
receive(
response: BackupAuthCredentialResponse,
redemptionTime: number,
params: GenericServerPublicParams
): BackupAuthCredential {
return new BackupAuthCredential(
Native.BackupAuthCredentialRequestContext_ReceiveResponse(
this.contents,
response.contents,
redemptionTime,
params.contents
)
);
}
}