@wnlx/o2-client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/index.cjs +620 -0
- package/dist/index.d.cts +98 -0
- package/dist/index.d.mts +98 -0
- package/dist/index.mjs +595 -0
- package/package.json +32 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ConnectionOptions } from "node:tls";
|
|
2
|
+
//#region src/sdk/client.d.ts
|
|
3
|
+
interface O2TLSOptions extends Omit<ConnectionOptions, "host" | "port"> {
|
|
4
|
+
/**
|
|
5
|
+
* TLS hostname used for certificate verification and SNI.
|
|
6
|
+
*
|
|
7
|
+
* Defaults to `host` when `host` is a hostname.
|
|
8
|
+
* When connecting by IP, set this to the hostname contained
|
|
9
|
+
* in the server certificate if necessary.
|
|
10
|
+
*/
|
|
11
|
+
servername?: string;
|
|
12
|
+
}
|
|
13
|
+
interface O2ClientOptions {
|
|
14
|
+
host?: string;
|
|
15
|
+
port?: number;
|
|
16
|
+
keyId: string;
|
|
17
|
+
secret: string;
|
|
18
|
+
transferBufferBytes?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Enable TLS for O2/TCP.
|
|
21
|
+
*
|
|
22
|
+
* - false / undefined: plain O2/TCP
|
|
23
|
+
* - true: TLS with normal CA/certificate verification
|
|
24
|
+
* - object: TLS with custom Node TLS options
|
|
25
|
+
*/
|
|
26
|
+
tls?: boolean | O2TLSOptions;
|
|
27
|
+
}
|
|
28
|
+
interface O2ObjectInfo {
|
|
29
|
+
key: string;
|
|
30
|
+
size: number;
|
|
31
|
+
}
|
|
32
|
+
interface O2NamespaceInfo {
|
|
33
|
+
name: string;
|
|
34
|
+
length: number;
|
|
35
|
+
}
|
|
36
|
+
interface O2Metadata {
|
|
37
|
+
size: number;
|
|
38
|
+
sha256: string;
|
|
39
|
+
}
|
|
40
|
+
interface O2Retrieval extends AsyncIterable<Uint8Array> {
|
|
41
|
+
readonly streamId: number;
|
|
42
|
+
readonly namespace: string;
|
|
43
|
+
readonly key: string;
|
|
44
|
+
readonly size: number;
|
|
45
|
+
readonly sha256?: string;
|
|
46
|
+
cancel(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export declare class O2Error extends Error {
|
|
49
|
+
readonly streamId?: number | undefined;
|
|
50
|
+
constructor(message: string, streamId?: number | undefined);
|
|
51
|
+
}
|
|
52
|
+
export declare class O2Client {
|
|
53
|
+
private readonly options;
|
|
54
|
+
private socket;
|
|
55
|
+
private writer;
|
|
56
|
+
private reader;
|
|
57
|
+
private incomingWork;
|
|
58
|
+
private pendingBytes;
|
|
59
|
+
private writeBlocked;
|
|
60
|
+
private nextStreamId;
|
|
61
|
+
private connected;
|
|
62
|
+
private closing;
|
|
63
|
+
private challengeWaiter;
|
|
64
|
+
private controlWaiter;
|
|
65
|
+
private requests;
|
|
66
|
+
private transfers;
|
|
67
|
+
private readonly host;
|
|
68
|
+
private readonly port;
|
|
69
|
+
private readonly transferBufferBytes;
|
|
70
|
+
constructor(options: O2ClientOptions);
|
|
71
|
+
connect(): Promise<void>;
|
|
72
|
+
close(): Promise<void>;
|
|
73
|
+
listNamespaces(): Promise<O2NamespaceInfo[]>;
|
|
74
|
+
listObjects(namespace: string): Promise<O2ObjectInfo[]>;
|
|
75
|
+
createNamespace(namespace: string): Promise<void>;
|
|
76
|
+
deleteNamespace(namespace: string): Promise<void>;
|
|
77
|
+
metadata(namespace: string, key: string): Promise<O2Metadata>;
|
|
78
|
+
deleteObject(namespace: string, key: string): Promise<string>;
|
|
79
|
+
putObject(namespace: string, key: string, data: Uint8Array, options?: {
|
|
80
|
+
chunkSize?: number;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
putObjectStream(namespace: string, key: string, source: AsyncIterable<Uint8Array> | Iterable<Uint8Array>): Promise<void>;
|
|
83
|
+
signObject(namespace: string, key: string, expirySeconds: number): Promise<string>;
|
|
84
|
+
retrieve(namespace: string, key: string, options?: {
|
|
85
|
+
chunkSize?: number;
|
|
86
|
+
offset?: number;
|
|
87
|
+
length?: number;
|
|
88
|
+
}): Promise<O2Retrieval>;
|
|
89
|
+
private request;
|
|
90
|
+
private handleFrame;
|
|
91
|
+
private requestOnStream;
|
|
92
|
+
private cancelTransfer;
|
|
93
|
+
private allocateStreamId;
|
|
94
|
+
private ensureConnected;
|
|
95
|
+
private failAll;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export type { O2ClientOptions, O2Metadata, O2NamespaceInfo, O2ObjectInfo, O2Retrieval, O2TLSOptions };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ConnectionOptions } from "node:tls";
|
|
2
|
+
//#region src/sdk/client.d.ts
|
|
3
|
+
interface O2TLSOptions extends Omit<ConnectionOptions, "host" | "port"> {
|
|
4
|
+
/**
|
|
5
|
+
* TLS hostname used for certificate verification and SNI.
|
|
6
|
+
*
|
|
7
|
+
* Defaults to `host` when `host` is a hostname.
|
|
8
|
+
* When connecting by IP, set this to the hostname contained
|
|
9
|
+
* in the server certificate if necessary.
|
|
10
|
+
*/
|
|
11
|
+
servername?: string;
|
|
12
|
+
}
|
|
13
|
+
interface O2ClientOptions {
|
|
14
|
+
host?: string;
|
|
15
|
+
port?: number;
|
|
16
|
+
keyId: string;
|
|
17
|
+
secret: string;
|
|
18
|
+
transferBufferBytes?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Enable TLS for O2/TCP.
|
|
21
|
+
*
|
|
22
|
+
* - false / undefined: plain O2/TCP
|
|
23
|
+
* - true: TLS with normal CA/certificate verification
|
|
24
|
+
* - object: TLS with custom Node TLS options
|
|
25
|
+
*/
|
|
26
|
+
tls?: boolean | O2TLSOptions;
|
|
27
|
+
}
|
|
28
|
+
interface O2ObjectInfo {
|
|
29
|
+
key: string;
|
|
30
|
+
size: number;
|
|
31
|
+
}
|
|
32
|
+
interface O2NamespaceInfo {
|
|
33
|
+
name: string;
|
|
34
|
+
length: number;
|
|
35
|
+
}
|
|
36
|
+
interface O2Metadata {
|
|
37
|
+
size: number;
|
|
38
|
+
sha256: string;
|
|
39
|
+
}
|
|
40
|
+
interface O2Retrieval extends AsyncIterable<Uint8Array> {
|
|
41
|
+
readonly streamId: number;
|
|
42
|
+
readonly namespace: string;
|
|
43
|
+
readonly key: string;
|
|
44
|
+
readonly size: number;
|
|
45
|
+
readonly sha256?: string;
|
|
46
|
+
cancel(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export declare class O2Error extends Error {
|
|
49
|
+
readonly streamId?: number | undefined;
|
|
50
|
+
constructor(message: string, streamId?: number | undefined);
|
|
51
|
+
}
|
|
52
|
+
export declare class O2Client {
|
|
53
|
+
private readonly options;
|
|
54
|
+
private socket;
|
|
55
|
+
private writer;
|
|
56
|
+
private reader;
|
|
57
|
+
private incomingWork;
|
|
58
|
+
private pendingBytes;
|
|
59
|
+
private writeBlocked;
|
|
60
|
+
private nextStreamId;
|
|
61
|
+
private connected;
|
|
62
|
+
private closing;
|
|
63
|
+
private challengeWaiter;
|
|
64
|
+
private controlWaiter;
|
|
65
|
+
private requests;
|
|
66
|
+
private transfers;
|
|
67
|
+
private readonly host;
|
|
68
|
+
private readonly port;
|
|
69
|
+
private readonly transferBufferBytes;
|
|
70
|
+
constructor(options: O2ClientOptions);
|
|
71
|
+
connect(): Promise<void>;
|
|
72
|
+
close(): Promise<void>;
|
|
73
|
+
listNamespaces(): Promise<O2NamespaceInfo[]>;
|
|
74
|
+
listObjects(namespace: string): Promise<O2ObjectInfo[]>;
|
|
75
|
+
createNamespace(namespace: string): Promise<void>;
|
|
76
|
+
deleteNamespace(namespace: string): Promise<void>;
|
|
77
|
+
metadata(namespace: string, key: string): Promise<O2Metadata>;
|
|
78
|
+
deleteObject(namespace: string, key: string): Promise<string>;
|
|
79
|
+
putObject(namespace: string, key: string, data: Uint8Array, options?: {
|
|
80
|
+
chunkSize?: number;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
putObjectStream(namespace: string, key: string, source: AsyncIterable<Uint8Array> | Iterable<Uint8Array>): Promise<void>;
|
|
83
|
+
signObject(namespace: string, key: string, expirySeconds: number): Promise<string>;
|
|
84
|
+
retrieve(namespace: string, key: string, options?: {
|
|
85
|
+
chunkSize?: number;
|
|
86
|
+
offset?: number;
|
|
87
|
+
length?: number;
|
|
88
|
+
}): Promise<O2Retrieval>;
|
|
89
|
+
private request;
|
|
90
|
+
private handleFrame;
|
|
91
|
+
private requestOnStream;
|
|
92
|
+
private cancelTransfer;
|
|
93
|
+
private allocateStreamId;
|
|
94
|
+
private ensureConnected;
|
|
95
|
+
private failAll;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export type { O2ClientOptions, O2Metadata, O2NamespaceInfo, O2ObjectInfo, O2Retrieval, O2TLSOptions };
|