Skip to content

Commit

Permalink
Fixes for CDSI lookup in node
Browse files Browse the repository at this point in the history
Fix issues that made this harder to use in client libraries:

- mutable arguments made Net.cdsiLookup harder to call
- a missing error code field made discriminating a RateLimitedError un-idiomatic
  • Loading branch information
akonradi-signal authored Nov 3, 2023
1 parent d6afc1b commit 89630ec
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"dependencies": {
"node-gyp-build": "^4.2.3",
"type-fest": "^3.5.0",
"uuid": "^8.3.0"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions node/ts/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export enum ErrorCode {
InputDataTooLong,
InvalidEntropyDataLength,
InvalidUsernameLinkEncryptedData,

RateLimitedError,
}

export class LibSignalErrorBase extends Error {
Expand Down Expand Up @@ -164,6 +166,7 @@ export type UnsupportedMediaInputError = LibSignalErrorCommon & {
};

export type RateLimitedError = LibSignalErrorBase & {
code: ErrorCode.RateLimitedError;
readonly retryAfterSecs: number;
};

Expand Down
5 changes: 3 additions & 2 deletions node/ts/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

import type { ReadonlyDeep } from 'type-fest';
import * as Native from '../Native';
import { Aci } from './Address';

Expand Down Expand Up @@ -44,13 +45,13 @@ export class Net {
}

async cdsiLookup(
{ username, password }: CDSAuthType,
{ username, password }: Readonly<CDSAuthType>,
{
e164s,
acisAndAccessKeys,
timeout,
returnAcisWithoutUaks,
}: CDSRequestOptionsType
}: ReadonlyDeep<CDSRequestOptionsType>
): Promise<CDSResponseType<string, string>> {
const request = { _nativeHandle: Native.LookupRequest_new() };
e164s.forEach((e164) => {
Expand Down
5 changes: 5 additions & 0 deletions node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,11 @@ type-fest@^0.20.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==

type-fest@^3.5.0:
version "3.13.1"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-3.13.1.tgz#bb744c1f0678bea7543a2d1ec24e83e68e8c8706"
integrity sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==

typed-array-buffer@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60"
Expand Down

0 comments on commit 89630ec

Please sign in to comment.