@opendatalabs/personal-server-ts-lite 0.0.1-canary.9ce2194
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/dist/bridge.d.ts +23 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +53 -0
- package/dist/bridge.js.map +1 -0
- package/dist/browser-runtime.d.ts +29 -0
- package/dist/browser-runtime.d.ts.map +1 -0
- package/dist/browser-runtime.js +81 -0
- package/dist/browser-runtime.js.map +1 -0
- package/dist/browser-tls-rustls/browser_tls_rustls.d.ts +49 -0
- package/dist/browser-tls-rustls/browser_tls_rustls.js +401 -0
- package/dist/browser-tls-rustls/browser_tls_rustls_bg.wasm +0 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/relay-tls.d.ts +19 -0
- package/dist/relay-tls.d.ts.map +1 -0
- package/dist/relay-tls.js +226 -0
- package/dist/relay-tls.js.map +1 -0
- package/dist/relay.d.ts +68 -0
- package/dist/relay.d.ts.map +1 -0
- package/dist/relay.js +361 -0
- package/dist/relay.js.map +1 -0
- package/dist/runtime.d.ts +76 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +543 -0
- package/dist/runtime.js.map +1 -0
- package/dist/state.d.ts +58 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +281 -0
- package/dist/state.js.map +1 -0
- package/dist/storage-utils.d.ts +7 -0
- package/dist/storage-utils.d.ts.map +1 -0
- package/dist/storage-utils.js +66 -0
- package/dist/storage-utils.js.map +1 -0
- package/dist/storage.d.ts +37 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +282 -0
- package/dist/storage.js.map +1 -0
- package/dist/sync.d.ts +25 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +62 -0
- package/dist/sync.js.map +1 -0
- package/package.json +40 -0
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PsLiteRuntime } from "./runtime.js";
|
|
2
|
+
export interface PsLiteBridgeRequest {
|
|
3
|
+
requestId: string;
|
|
4
|
+
method: string;
|
|
5
|
+
path: string;
|
|
6
|
+
query: string;
|
|
7
|
+
headers: Record<string, string>;
|
|
8
|
+
/** Base64-encoded request body, matching the browser-local relay PoC. */
|
|
9
|
+
body: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PsLiteBridgeResponse {
|
|
12
|
+
requestId: string;
|
|
13
|
+
status: number;
|
|
14
|
+
headers: Record<string, string>;
|
|
15
|
+
/** Base64-encoded response body for relay transport. */
|
|
16
|
+
body: string;
|
|
17
|
+
/** Decoded response body for same-context consumers and tests. */
|
|
18
|
+
textBody: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function handlePsLiteBridgeRequest(runtime: PsLiteRuntime, bridgeRequest: PsLiteBridgeRequest, options?: {
|
|
21
|
+
origin?: string;
|
|
22
|
+
}): Promise<PsLiteBridgeResponse>;
|
|
23
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkDD,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,aAAa,EACtB,aAAa,EAAE,mBAAmB,EAClC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAe/B"}
|
package/dist/bridge.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function decodeBase64(input) {
|
|
2
|
+
if (!input)
|
|
3
|
+
return new Uint8Array();
|
|
4
|
+
const binary = typeof globalThis.atob === "function"
|
|
5
|
+
? globalThis.atob(input)
|
|
6
|
+
: Buffer.from(input, "base64").toString("binary");
|
|
7
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
8
|
+
}
|
|
9
|
+
function encodeBase64(bytes) {
|
|
10
|
+
let binary = "";
|
|
11
|
+
for (const byte of bytes) {
|
|
12
|
+
binary += String.fromCharCode(byte);
|
|
13
|
+
}
|
|
14
|
+
return typeof globalThis.btoa === "function"
|
|
15
|
+
? globalThis.btoa(binary)
|
|
16
|
+
: Buffer.from(binary, "binary").toString("base64");
|
|
17
|
+
}
|
|
18
|
+
function headersToRecord(headers) {
|
|
19
|
+
const result = {};
|
|
20
|
+
headers.forEach((value, key) => {
|
|
21
|
+
result[key] = value;
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function buildRequest(origin, bridgeRequest) {
|
|
26
|
+
const query = bridgeRequest.query
|
|
27
|
+
? `?${bridgeRequest.query.replace(/^\?/, "")}`
|
|
28
|
+
: "";
|
|
29
|
+
const url = `${origin.replace(/\/+$/, "")}${bridgeRequest.path}${query}`;
|
|
30
|
+
const method = bridgeRequest.method.toUpperCase();
|
|
31
|
+
const hasBody = method !== "GET" && method !== "HEAD";
|
|
32
|
+
const body = hasBody
|
|
33
|
+
? decodeBase64(bridgeRequest.body).slice().buffer
|
|
34
|
+
: undefined;
|
|
35
|
+
return new Request(url, {
|
|
36
|
+
method,
|
|
37
|
+
headers: bridgeRequest.headers,
|
|
38
|
+
body,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export async function handlePsLiteBridgeRequest(runtime, bridgeRequest, options = {}) {
|
|
42
|
+
const request = buildRequest(options.origin ?? "https://ps-lite.local", bridgeRequest);
|
|
43
|
+
const response = await runtime.fetch(request);
|
|
44
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
45
|
+
return {
|
|
46
|
+
requestId: bridgeRequest.requestId,
|
|
47
|
+
status: response.status,
|
|
48
|
+
headers: headersToRecord(response.headers),
|
|
49
|
+
body: encodeBase64(bytes),
|
|
50
|
+
textBody: new TextDecoder().decode(bytes),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAsBA,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,UAAU,EAAE,CAAC;IACpC,MAAM,MAAM,GACV,OAAO,UAAU,CAAC,IAAI,KAAK,UAAU;QACnC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;QACxB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACtD,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,YAAY,CAAC,KAAiB;IACrC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM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B,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAAsB,EACtB,aAAkC,EAClC,UAA+B,EAAE;IAEjC,MAAM,OAAO,GAAG,YAAY,CAC1B,OAAO,CAAC,MAAM,IAAI,uBAAuB,EACzC,aAAa,CACd,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAE3D,OAAO;QACL,SAAS,EAAE,aAAa,CAAC,SAAS;QAClC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC1C,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC;QACzB,QAAQ,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ServerConfig } from "@opendatalabs/personal-server-ts-core/schemas";
|
|
2
|
+
import type { AccessLogReader } from "@opendatalabs/personal-server-ts-core/logging/access-reader";
|
|
3
|
+
import type { AccessLogWriter } from "@opendatalabs/personal-server-ts-core/logging/access-log";
|
|
4
|
+
import type { DataStoragePort } from "@opendatalabs/personal-server-ts-core/ports";
|
|
5
|
+
import { type PsLiteDataFileStore } from "./storage.js";
|
|
6
|
+
import { type PsLiteStateStore, type PsLiteUnlockedServerIdentity } from "./state.js";
|
|
7
|
+
import { type PsLiteRuntime, type PsLiteRuntimeOptions } from "./runtime.js";
|
|
8
|
+
export interface IndexedDbPsLiteRuntimeOptions extends Omit<PsLiteRuntimeOptions, "accessLogReader" | "accessLogWriter" | "config" | "identity" | "saveConfig" | "stateCapabilities" | "storage" | "tokenStore"> {
|
|
9
|
+
ownerSignature: `0x${string}`;
|
|
10
|
+
dbName?: string;
|
|
11
|
+
stateStoreName?: string;
|
|
12
|
+
storageDbName?: string;
|
|
13
|
+
storageStoreName?: string;
|
|
14
|
+
storageKey?: string;
|
|
15
|
+
configDefaults?: Partial<ServerConfig>;
|
|
16
|
+
dataFileStore?: PsLiteDataFileStore;
|
|
17
|
+
}
|
|
18
|
+
export interface IndexedDbPsLiteRuntime {
|
|
19
|
+
runtime: PsLiteRuntime;
|
|
20
|
+
config: ServerConfig;
|
|
21
|
+
identity: PsLiteUnlockedServerIdentity;
|
|
22
|
+
stateStore: PsLiteStateStore;
|
|
23
|
+
storage: DataStoragePort;
|
|
24
|
+
tokenStore: PsLiteRuntimeOptions["tokenStore"];
|
|
25
|
+
accessLogStore: AccessLogReader & AccessLogWriter;
|
|
26
|
+
syncManager: PsLiteRuntimeOptions["syncManager"];
|
|
27
|
+
}
|
|
28
|
+
export declare function createIndexedDbPsLiteRuntime(options: IndexedDbPsLiteRuntimeOptions): Promise<IndexedDbPsLiteRuntime>;
|
|
29
|
+
//# sourceMappingURL=browser-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-runtime.d.ts","sourceRoot":"","sources":["../src/browser-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6DAA6D,CAAC;AACnG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAKnF,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAOL,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EAClC,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,6BAA8B,SAAQ,IAAI,CACzD,oBAAoB,EAClB,iBAAiB,GACjB,iBAAiB,GACjB,QAAQ,GACR,UAAU,GACV,YAAY,GACZ,mBAAmB,GACnB,SAAS,GACT,YAAY,CACf;IACC,cAAc,EAAE,KAAK,MAAM,EAAE,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,4BAA4B,CAAC;IACvC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAC/C,cAAc,EAAE,eAAe,GAAG,eAAe,CAAC;IAClD,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;CAClD;AAED,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,sBAAsB,CAAC,CAoFjC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createServerSigner } from "@opendatalabs/personal-server-ts-core/signing";
|
|
2
|
+
import { createGatewayClient, recoverServerOwner, } from "@opendatalabs/vana-sdk/browser";
|
|
3
|
+
import { createIndexedDbPsLitePersistence, createPersistentPsLiteStorage, } from "./storage.js";
|
|
4
|
+
import { createIndexedDbPsLiteAccessLogStore, createIndexedDbPsLiteStateStore, createIndexedDbPsLiteTokenStore, loadOrCreatePsLiteConfig, loadOrCreatePsLiteServerIdentity, savePsLiteConfig, } from "./state.js";
|
|
5
|
+
import { createPsLiteRuntime, } from "./runtime.js";
|
|
6
|
+
import { createPsLiteSyncManager } from "./sync.js";
|
|
7
|
+
export async function createIndexedDbPsLiteRuntime(options) {
|
|
8
|
+
const dbName = options.dbName ?? "personal-server-lite";
|
|
9
|
+
const stateStore = createIndexedDbPsLiteStateStore({
|
|
10
|
+
dbName,
|
|
11
|
+
storeName: options.stateStoreName ?? "state",
|
|
12
|
+
});
|
|
13
|
+
const config = await loadOrCreatePsLiteConfig(stateStore, options.configDefaults);
|
|
14
|
+
const identity = await loadOrCreatePsLiteServerIdentity({
|
|
15
|
+
store: stateStore,
|
|
16
|
+
ownerSignature: options.ownerSignature,
|
|
17
|
+
});
|
|
18
|
+
const tokenStore = createIndexedDbPsLiteTokenStore({
|
|
19
|
+
dbName,
|
|
20
|
+
storeName: "tokens",
|
|
21
|
+
});
|
|
22
|
+
const accessLogStore = createIndexedDbPsLiteAccessLogStore({
|
|
23
|
+
dbName,
|
|
24
|
+
storeName: "accessLogs",
|
|
25
|
+
});
|
|
26
|
+
const storage = await createPersistentPsLiteStorage({ kind: "indexeddb" }, createIndexedDbPsLitePersistence({
|
|
27
|
+
dbName: options.storageDbName ?? `${dbName}-storage`,
|
|
28
|
+
storeName: options.storageStoreName ?? "state",
|
|
29
|
+
key: options.storageKey ?? "data-storage-v1",
|
|
30
|
+
}), options.dataFileStore);
|
|
31
|
+
const gateway = options.gateway ?? createGatewayClient(config.gateway.url);
|
|
32
|
+
const serverOwner = await recoverServerOwner(options.ownerSignature);
|
|
33
|
+
const serverSigner = options.serverSigner ??
|
|
34
|
+
createServerSigner(identity.account, {
|
|
35
|
+
chainId: config.gateway.chainId,
|
|
36
|
+
contracts: config.gateway.contracts,
|
|
37
|
+
});
|
|
38
|
+
let syncManager = options.syncManager ?? null;
|
|
39
|
+
if (!syncManager && config.sync.enabled) {
|
|
40
|
+
syncManager = (await createPsLiteSyncManager({
|
|
41
|
+
config,
|
|
42
|
+
stateStore,
|
|
43
|
+
storage,
|
|
44
|
+
ownerSignature: options.ownerSignature,
|
|
45
|
+
serverAccount: identity.account,
|
|
46
|
+
gateway,
|
|
47
|
+
})).syncManager;
|
|
48
|
+
}
|
|
49
|
+
const runtime = createPsLiteRuntime({
|
|
50
|
+
...options,
|
|
51
|
+
storage,
|
|
52
|
+
config,
|
|
53
|
+
identity: {
|
|
54
|
+
address: identity.account.address,
|
|
55
|
+
publicKey: identity.account.publicKey,
|
|
56
|
+
},
|
|
57
|
+
gateway,
|
|
58
|
+
serverOwner,
|
|
59
|
+
serverSigner,
|
|
60
|
+
syncManager,
|
|
61
|
+
saveConfig: async (nextConfig) => {
|
|
62
|
+
const saved = await savePsLiteConfig(stateStore, nextConfig);
|
|
63
|
+
Object.assign(config, saved);
|
|
64
|
+
},
|
|
65
|
+
stateCapabilities: { config: "indexeddb" },
|
|
66
|
+
tokenStore,
|
|
67
|
+
accessLogReader: accessLogStore,
|
|
68
|
+
accessLogWriter: accessLogStore,
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
runtime,
|
|
72
|
+
config,
|
|
73
|
+
identity,
|
|
74
|
+
stateStore,
|
|
75
|
+
storage,
|
|
76
|
+
tokenStore,
|
|
77
|
+
accessLogStore,
|
|
78
|
+
syncManager,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=browser-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-runtime.js","sourceRoot":"","sources":["../src/browser-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAInF,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gCAAgC,EAChC,6BAA6B,GAE9B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mCAAmC,EACnC,+BAA+B,EAC/B,+BAA+B,EAC/B,wBAAwB,EACxB,gCAAgC,EA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ACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class TlsServer {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
constructor(cert_pem: string, key_pem: string);
|
|
8
|
+
process_tls(input: Uint8Array): any;
|
|
9
|
+
write_plaintext(plaintext: Uint8Array, close: boolean): any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
13
|
+
|
|
14
|
+
export interface InitOutput {
|
|
15
|
+
readonly memory: WebAssembly.Memory;
|
|
16
|
+
readonly __wbg_tlsserver_free: (a: number, b: number) => void;
|
|
17
|
+
readonly tlsserver_new: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
18
|
+
readonly tlsserver_process_tls: (a: number, b: number, c: number) => [number, number, number];
|
|
19
|
+
readonly tlsserver_write_plaintext: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
20
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
21
|
+
readonly __externref_table_alloc: () => number;
|
|
22
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
23
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
24
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
25
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
26
|
+
readonly __wbindgen_start: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
33
|
+
* a precompiled `WebAssembly.Module`.
|
|
34
|
+
*
|
|
35
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
36
|
+
*
|
|
37
|
+
* @returns {InitOutput}
|
|
38
|
+
*/
|
|
39
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
43
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
44
|
+
*
|
|
45
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
46
|
+
*
|
|
47
|
+
* @returns {Promise<InitOutput>}
|
|
48
|
+
*/
|
|
49
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* @ts-self-types="./browser_tls_rustls.d.ts" */
|
|
3
|
+
|
|
4
|
+
export class TlsServer {
|
|
5
|
+
__destroy_into_raw() {
|
|
6
|
+
const ptr = this.__wbg_ptr;
|
|
7
|
+
this.__wbg_ptr = 0;
|
|
8
|
+
TlsServerFinalization.unregister(this);
|
|
9
|
+
return ptr;
|
|
10
|
+
}
|
|
11
|
+
free() {
|
|
12
|
+
const ptr = this.__destroy_into_raw();
|
|
13
|
+
wasm.__wbg_tlsserver_free(ptr, 0);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} cert_pem
|
|
17
|
+
* @param {string} key_pem
|
|
18
|
+
*/
|
|
19
|
+
constructor(cert_pem, key_pem) {
|
|
20
|
+
const ptr0 = passStringToWasm0(cert_pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
21
|
+
const len0 = WASM_VECTOR_LEN;
|
|
22
|
+
const ptr1 = passStringToWasm0(key_pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
23
|
+
const len1 = WASM_VECTOR_LEN;
|
|
24
|
+
const ret = wasm.tlsserver_new(ptr0, len0, ptr1, len1);
|
|
25
|
+
if (ret[2]) {
|
|
26
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
27
|
+
}
|
|
28
|
+
this.__wbg_ptr = ret[0];
|
|
29
|
+
TlsServerFinalization.register(this, this.__wbg_ptr, this);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @param {Uint8Array} input
|
|
34
|
+
* @returns {any}
|
|
35
|
+
*/
|
|
36
|
+
process_tls(input) {
|
|
37
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ret = wasm.tlsserver_process_tls(this.__wbg_ptr, ptr0, len0);
|
|
40
|
+
if (ret[2]) {
|
|
41
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
42
|
+
}
|
|
43
|
+
return takeFromExternrefTable0(ret[0]);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @param {Uint8Array} plaintext
|
|
47
|
+
* @param {boolean} close
|
|
48
|
+
* @returns {any}
|
|
49
|
+
*/
|
|
50
|
+
write_plaintext(plaintext, close) {
|
|
51
|
+
const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
52
|
+
const len0 = WASM_VECTOR_LEN;
|
|
53
|
+
const ret = wasm.tlsserver_write_plaintext(this.__wbg_ptr, ptr0, len0, close);
|
|
54
|
+
if (ret[2]) {
|
|
55
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
56
|
+
}
|
|
57
|
+
return takeFromExternrefTable0(ret[0]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (Symbol.dispose) TlsServer.prototype[Symbol.dispose] = TlsServer.prototype.free;
|
|
61
|
+
function __wbg_get_imports() {
|
|
62
|
+
const import0 = {
|
|
63
|
+
__proto__: null,
|
|
64
|
+
__wbg___wbindgen_is_function_2f0fd7ceb86e64c5: function(arg0) {
|
|
65
|
+
const ret = typeof(arg0) === 'function';
|
|
66
|
+
return ret;
|
|
67
|
+
},
|
|
68
|
+
__wbg___wbindgen_is_object_5b22ff2418063a9c: function(arg0) {
|
|
69
|
+
const val = arg0;
|
|
70
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
71
|
+
return ret;
|
|
72
|
+
},
|
|
73
|
+
__wbg___wbindgen_is_string_eddc07a3efad52e6: function(arg0) {
|
|
74
|
+
const ret = typeof(arg0) === 'string';
|
|
75
|
+
return ret;
|
|
76
|
+
},
|
|
77
|
+
__wbg___wbindgen_is_undefined_244a92c34d3b6ec0: function(arg0) {
|
|
78
|
+
const ret = arg0 === undefined;
|
|
79
|
+
return ret;
|
|
80
|
+
},
|
|
81
|
+
__wbg___wbindgen_throw_9c75d47bf9e7731e: function(arg0, arg1) {
|
|
82
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
83
|
+
},
|
|
84
|
+
__wbg_call_a41d6421b30a32c5: function() { return handleError(function (arg0, arg1, arg2) {
|
|
85
|
+
const ret = arg0.call(arg1, arg2);
|
|
86
|
+
return ret;
|
|
87
|
+
}, arguments); },
|
|
88
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
89
|
+
const ret = arg0.crypto;
|
|
90
|
+
return ret;
|
|
91
|
+
},
|
|
92
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
93
|
+
arg0.getRandomValues(arg1);
|
|
94
|
+
}, arguments); },
|
|
95
|
+
__wbg_length_ba3c032602efe310: function(arg0) {
|
|
96
|
+
const ret = arg0.length;
|
|
97
|
+
return ret;
|
|
98
|
+
},
|
|
99
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
100
|
+
const ret = arg0.msCrypto;
|
|
101
|
+
return ret;
|
|
102
|
+
},
|
|
103
|
+
__wbg_new_2fad8ca02fd00684: function() {
|
|
104
|
+
const ret = new Object();
|
|
105
|
+
return ret;
|
|
106
|
+
},
|
|
107
|
+
__wbg_new_from_slice_5a173c243af2e823: function(arg0, arg1) {
|
|
108
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
109
|
+
return ret;
|
|
110
|
+
},
|
|
111
|
+
__wbg_new_with_length_9011f5da794bf5d9: function(arg0) {
|
|
112
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
113
|
+
return ret;
|
|
114
|
+
},
|
|
115
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
116
|
+
const ret = arg0.node;
|
|
117
|
+
return ret;
|
|
118
|
+
},
|
|
119
|
+
__wbg_now_4f457f10f864aec5: function() {
|
|
120
|
+
const ret = Date.now();
|
|
121
|
+
return ret;
|
|
122
|
+
},
|
|
123
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
124
|
+
const ret = arg0.process;
|
|
125
|
+
return ret;
|
|
126
|
+
},
|
|
127
|
+
__wbg_prototypesetcall_fd4050e806e1d519: function(arg0, arg1, arg2) {
|
|
128
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
129
|
+
},
|
|
130
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
131
|
+
arg0.randomFillSync(arg1);
|
|
132
|
+
}, arguments); },
|
|
133
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
134
|
+
const ret = module.require;
|
|
135
|
+
return ret;
|
|
136
|
+
}, arguments); },
|
|
137
|
+
__wbg_set_5337f8ac82364a3f: function() { return handleError(function (arg0, arg1, arg2) {
|
|
138
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
139
|
+
return ret;
|
|
140
|
+
}, arguments); },
|
|
141
|
+
__wbg_static_accessor_GLOBAL_THIS_1c7f1bd6c6941fdb: function() {
|
|
142
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
143
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
144
|
+
},
|
|
145
|
+
__wbg_static_accessor_GLOBAL_e039bc914f83e74e: function() {
|
|
146
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
147
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
148
|
+
},
|
|
149
|
+
__wbg_static_accessor_SELF_8bf8c48c28420ad5: function() {
|
|
150
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
151
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
152
|
+
},
|
|
153
|
+
__wbg_static_accessor_WINDOW_6aeee9b51652ee0f: function() {
|
|
154
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
155
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
156
|
+
},
|
|
157
|
+
__wbg_subarray_fbe3cef290e1fa43: function(arg0, arg1, arg2) {
|
|
158
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
159
|
+
return ret;
|
|
160
|
+
},
|
|
161
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
162
|
+
const ret = arg0.versions;
|
|
163
|
+
return ret;
|
|
164
|
+
},
|
|
165
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
166
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
167
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
168
|
+
return ret;
|
|
169
|
+
},
|
|
170
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
171
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
172
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
173
|
+
return ret;
|
|
174
|
+
},
|
|
175
|
+
__wbindgen_init_externref_table: function() {
|
|
176
|
+
const table = wasm.__wbindgen_externrefs;
|
|
177
|
+
const offset = table.grow(4);
|
|
178
|
+
table.set(0, undefined);
|
|
179
|
+
table.set(offset + 0, undefined);
|
|
180
|
+
table.set(offset + 1, null);
|
|
181
|
+
table.set(offset + 2, true);
|
|
182
|
+
table.set(offset + 3, false);
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
return {
|
|
186
|
+
__proto__: null,
|
|
187
|
+
"./browser_tls_rustls_bg.js": import0,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const TlsServerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
192
|
+
? { register: () => {}, unregister: () => {} }
|
|
193
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_tlsserver_free(ptr, 1));
|
|
194
|
+
|
|
195
|
+
function addToExternrefTable0(obj) {
|
|
196
|
+
const idx = wasm.__externref_table_alloc();
|
|
197
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
198
|
+
return idx;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
202
|
+
ptr = ptr >>> 0;
|
|
203
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function getStringFromWasm0(ptr, len) {
|
|
207
|
+
return decodeText(ptr >>> 0, len);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
let cachedUint8ArrayMemory0 = null;
|
|
211
|
+
function getUint8ArrayMemory0() {
|
|
212
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
213
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
214
|
+
}
|
|
215
|
+
return cachedUint8ArrayMemory0;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function handleError(f, args) {
|
|
219
|
+
try {
|
|
220
|
+
return f.apply(this, args);
|
|
221
|
+
} catch (e) {
|
|
222
|
+
const idx = addToExternrefTable0(e);
|
|
223
|
+
wasm.__wbindgen_exn_store(idx);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function isLikeNone(x) {
|
|
228
|
+
return x === undefined || x === null;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
232
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
233
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
234
|
+
WASM_VECTOR_LEN = arg.length;
|
|
235
|
+
return ptr;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
239
|
+
if (realloc === undefined) {
|
|
240
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
241
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
242
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
243
|
+
WASM_VECTOR_LEN = buf.length;
|
|
244
|
+
return ptr;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
let len = arg.length;
|
|
248
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
249
|
+
|
|
250
|
+
const mem = getUint8ArrayMemory0();
|
|
251
|
+
|
|
252
|
+
let offset = 0;
|
|
253
|
+
|
|
254
|
+
for (; offset < len; offset++) {
|
|
255
|
+
const code = arg.charCodeAt(offset);
|
|
256
|
+
if (code > 0x7F) break;
|
|
257
|
+
mem[ptr + offset] = code;
|
|
258
|
+
}
|
|
259
|
+
if (offset !== len) {
|
|
260
|
+
if (offset !== 0) {
|
|
261
|
+
arg = arg.slice(offset);
|
|
262
|
+
}
|
|
263
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
264
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
265
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
266
|
+
|
|
267
|
+
offset += ret.written;
|
|
268
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
WASM_VECTOR_LEN = offset;
|
|
272
|
+
return ptr;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function takeFromExternrefTable0(idx) {
|
|
276
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
277
|
+
wasm.__externref_table_dealloc(idx);
|
|
278
|
+
return value;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
282
|
+
cachedTextDecoder.decode();
|
|
283
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
284
|
+
let numBytesDecoded = 0;
|
|
285
|
+
function decodeText(ptr, len) {
|
|
286
|
+
numBytesDecoded += len;
|
|
287
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
288
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
289
|
+
cachedTextDecoder.decode();
|
|
290
|
+
numBytesDecoded = len;
|
|
291
|
+
}
|
|
292
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const cachedTextEncoder = new TextEncoder();
|
|
296
|
+
|
|
297
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
298
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
299
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
300
|
+
view.set(buf);
|
|
301
|
+
return {
|
|
302
|
+
read: arg.length,
|
|
303
|
+
written: buf.length
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
let WASM_VECTOR_LEN = 0;
|
|
309
|
+
|
|
310
|
+
let wasmModule, wasmInstance, wasm;
|
|
311
|
+
function __wbg_finalize_init(instance, module) {
|
|
312
|
+
wasmInstance = instance;
|
|
313
|
+
wasm = instance.exports;
|
|
314
|
+
wasmModule = module;
|
|
315
|
+
cachedUint8ArrayMemory0 = null;
|
|
316
|
+
wasm.__wbindgen_start();
|
|
317
|
+
return wasm;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async function __wbg_load(module, imports) {
|
|
321
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
322
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
323
|
+
try {
|
|
324
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
325
|
+
} catch (e) {
|
|
326
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
327
|
+
|
|
328
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
329
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
330
|
+
|
|
331
|
+
} else { throw e; }
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const bytes = await module.arrayBuffer();
|
|
336
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
337
|
+
} else {
|
|
338
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
339
|
+
|
|
340
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
341
|
+
return { instance, module };
|
|
342
|
+
} else {
|
|
343
|
+
return instance;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function expectedResponseType(type) {
|
|
348
|
+
switch (type) {
|
|
349
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
350
|
+
}
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function initSync(module) {
|
|
356
|
+
if (wasm !== undefined) return wasm;
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
if (module !== undefined) {
|
|
360
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
361
|
+
({module} = module)
|
|
362
|
+
} else {
|
|
363
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const imports = __wbg_get_imports();
|
|
368
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
369
|
+
module = new WebAssembly.Module(module);
|
|
370
|
+
}
|
|
371
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
372
|
+
return __wbg_finalize_init(instance, module);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async function __wbg_init(module_or_path) {
|
|
376
|
+
if (wasm !== undefined) return wasm;
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
if (module_or_path !== undefined) {
|
|
380
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
381
|
+
({module_or_path} = module_or_path)
|
|
382
|
+
} else {
|
|
383
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (module_or_path === undefined) {
|
|
388
|
+
module_or_path = new URL('browser_tls_rustls_bg.wasm', import.meta.url);
|
|
389
|
+
}
|
|
390
|
+
const imports = __wbg_get_imports();
|
|
391
|
+
|
|
392
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
393
|
+
module_or_path = fetch(module_or_path);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
397
|
+
|
|
398
|
+
return __wbg_finalize_init(instance, module);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createIndexedDbPsLiteRuntime, type IndexedDbPsLiteRuntime, type IndexedDbPsLiteRuntimeOptions, } from "./browser-runtime.js";
|
|
2
|
+
export { handlePsLiteBridgeRequest, type PsLiteBridgeRequest, type PsLiteBridgeResponse, } from "./bridge.js";
|
|
3
|
+
export { createIndexedDbPsLitePersistence, createOpfsPsLiteDataFileStore, createPersistentPsLiteStorage, isOpfsAvailable, type IndexedDbPsLitePersistenceOptions, type PsLiteDataFileStore, type PsLiteFileStorageKind, type PsLitePersistedStorageState, type PsLitePersistenceAdapter, } from "./storage.js";
|
|
4
|
+
export { createIndexedDbPsLiteAccessLogStore, createIndexedDbPsLiteStateStore, createIndexedDbPsLiteTokenStore, loadOrCreatePsLiteConfig, loadOrCreatePsLiteServerIdentity, savePsLiteConfig, type IndexedDbPsLiteAccessLogStoreOptions, type IndexedDbPsLiteStateStoreOptions, type IndexedDbPsLiteTokenStoreOptions, type PsLiteEncryptedPrivateKey, type PsLiteEncryptedServerIdentity, type PsLiteRelayState, type PsLiteStateKey, type PsLiteStateStore, type PsLiteUnlockedServerIdentity, } from "./state.js";
|
|
5
|
+
export { createPsLiteSyncCursor, createPsLiteSyncManager, type PsLiteSyncOptions, } from "./sync.js";
|
|
6
|
+
export { createBearerTokenPsLiteAuth, createPsLiteRuntime, createWeb3SignedPsLiteAuth, type BearerTokenPsLiteAuthOptions, type PsLiteAuthAdapter, type PsLiteReadAuthInput, type PsLiteRuntime, type PsLiteRuntimeOptions, type PsLiteStorageAdapter, type PsLiteTokenStore, type Web3SignedPsLiteAuthOptions, } from "./runtime.js";
|
|
7
|
+
export { decodeDataFrame, encodeDataFrame, psLiteRelayControlUrl, psLiteRelayPublicUrl, startPsLiteRelayClient, type PsLiteRelayClient, type PsLiteRelayClientOptions, type PsLiteRelayStatus, type PsLiteRelayTlsFactory, type PsLiteRelayTlsPrepareInput, type PsLiteRelayTlsStep, type PsLiteRelayTlsStream, type PsLiteRelayTlsStreamInput, type PsLiteRelayWebSocket, type PsLiteRelayWebSocketFactory, } from "./relay.js";
|
|
8
|
+
export { createRustlsPsLiteRelayTlsFactory, psLiteRelayPublicHost, psLiteRelayPublicUrl as psLiteRelayTlsPublicUrl, type PsLiteRelayTlsIdentity, type RustlsPsLiteRelayTlsOptions, } from "./relay-tls.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|