(feat): add descriptor to wasm & ts-sdk
All checks were successful
CI / checks (push) Successful in 7m16s
All checks were successful
CI / checks (push) Successful in 7m16s
This commit is contained in:
parent
8ae8377662
commit
c3fbeb2e78
2 changed files with 8 additions and 0 deletions
|
|
@ -93,6 +93,7 @@ export interface MTPClientCredentials {
|
||||||
|
|
||||||
export interface MTPClientOptions {
|
export interface MTPClientOptions {
|
||||||
url: string;
|
url: string;
|
||||||
|
descriptor?: string;
|
||||||
hostPublicKey?: MTPBytesInput | string;
|
hostPublicKey?: MTPBytesInput | string;
|
||||||
credentials?: MTPCredentials | string | null;
|
credentials?: MTPCredentials | string | null;
|
||||||
credentialsStorageKey?: string;
|
credentialsStorageKey?: string;
|
||||||
|
|
@ -296,6 +297,9 @@ function validateOptions(options) {
|
||||||
if (typeof options.url !== "string" || !options.url.trim()) {
|
if (typeof options.url !== "string" || !options.url.trim()) {
|
||||||
throw new TypeError("MTPClient.create requires a non-empty url");
|
throw new TypeError("MTPClient.create requires a non-empty url");
|
||||||
}
|
}
|
||||||
|
if (options.descriptor != null && typeof options.descriptor !== "string") {
|
||||||
|
throw new TypeError("descriptor must be a string");
|
||||||
|
}
|
||||||
if (options.storage) {
|
if (options.storage) {
|
||||||
for (const method of ["getItem", "setItem", "removeItem"]) {
|
for (const method of ["getItem", "setItem", "removeItem"]) {
|
||||||
if (typeof options.storage[method] !== "function") {
|
if (typeof options.storage[method] !== "function") {
|
||||||
|
|
@ -427,6 +431,9 @@ export class MTPClient {
|
||||||
if (this.#options.maxMessageSize != null) {
|
if (this.#options.maxMessageSize != null) {
|
||||||
config.max_message_size = this.#options.maxMessageSize;
|
config.max_message_size = this.#options.maxMessageSize;
|
||||||
}
|
}
|
||||||
|
if (this.#options.descriptor != null) {
|
||||||
|
config.description = this.#options.descriptor;
|
||||||
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
1
wasm/types/mtp_wasm.d.ts
vendored
1
wasm/types/mtp_wasm.d.ts
vendored
|
|
@ -48,6 +48,7 @@ export class ConnectionConfig implements DisposableWasmObject {
|
||||||
free(): void;
|
free(): void;
|
||||||
[Symbol.dispose](): void;
|
[Symbol.dispose](): void;
|
||||||
client_id: bigint;
|
client_id: bigint;
|
||||||
|
description: string | undefined;
|
||||||
max_message_size: number;
|
max_message_size: number;
|
||||||
server_certificate_hashes: string[];
|
server_certificate_hashes: string[];
|
||||||
readonly url: string;
|
readonly url: string;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue