@synonymdev/locks-sdk 0.1.0-rc5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Synonym
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @synonymdev/locks-sdk
2
+
3
+ Browser JS/WASM SDK for Pubky Locks.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @synonymdev/locks-sdk@rc
9
+ ```
10
+
11
+ ## Initialize
12
+
13
+ ```js
14
+ import init, { Locks } from '@synonymdev/locks-sdk';
15
+
16
+ await init();
17
+ const locks = Locks.forServer(lockServerPubky);
18
+ ```
19
+
20
+ The package targets browsers and loads its bundled WebAssembly module through the generated ES module initializer.
21
+
22
+ API and integration documentation: <https://github.com/pubky/locks/blob/master/docs/SDK.md>
23
+
24
+ ## License
25
+
26
+ MIT
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@synonymdev/locks-sdk",
3
+ "version": "0.1.0-rc5",
4
+ "description": "Browser JS/WASM bindings for the Pubky Locks Creator SDK",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/pubky/locks.git",
10
+ "directory": "locks-sdk/bindings/js"
11
+ },
12
+ "homepage": "https://github.com/pubky/locks#readme",
13
+ "bugs": "https://github.com/pubky/locks/issues",
14
+ "main": "./pkg/locks_sdk_wasm.js",
15
+ "types": "./pkg/locks_sdk_wasm.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./pkg/locks_sdk_wasm.d.ts",
19
+ "import": "./pkg/locks_sdk_wasm.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "pkg/locks_sdk_wasm.js",
24
+ "pkg/locks_sdk_wasm_bg.wasm",
25
+ "pkg/locks_sdk_wasm.d.ts",
26
+ "pkg/locks_sdk_wasm_bg.wasm.d.ts"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "tag": "rc"
31
+ },
32
+ "scripts": {
33
+ "build": "wasm-pack build --target web --out-dir pkg",
34
+ "check:wasm": "cargo check -p locks-sdk-wasm --target wasm32-unknown-unknown",
35
+ "smoke:pkg": "npm run build && node scripts/smoke-generated-api.mjs",
36
+ "smoke:demo": "node scripts/smoke-demo.mjs",
37
+ "smoke:examples": "node scripts/smoke-examples.mjs",
38
+ "release:audit": "node scripts/release-readiness.mjs",
39
+ "live:smoke:check": "node scripts/live-smoke-check.mjs",
40
+ "prepack": "npm run smoke:pkg",
41
+ "test:native": "cargo test -p locks-sdk-wasm",
42
+ "test": "npm run test:native && npm run check:wasm && npm run smoke:pkg && npm run smoke:demo && npm run smoke:examples"
43
+ },
44
+ "devDependencies": {}
45
+ }
@@ -0,0 +1,318 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * The `ReadableStreamType` enum.
5
+ *
6
+ * *This API requires the following crate features to be activated: `ReadableStreamType`*
7
+ */
8
+
9
+ export type ReadableStreamType = "bytes";
10
+
11
+ export class BundleId {
12
+ free(): void;
13
+ [Symbol.dispose](): void;
14
+ static generate(): BundleId;
15
+ constructor(value: string);
16
+ toString(): string;
17
+ }
18
+
19
+ export class ConnectCallback {
20
+ private constructor();
21
+ free(): void;
22
+ [Symbol.dispose](): void;
23
+ readonly code: string;
24
+ readonly state: string;
25
+ }
26
+
27
+ export class ConnectUrlOptions {
28
+ free(): void;
29
+ [Symbol.dispose](): void;
30
+ constructor(return_to: string, state: string);
31
+ readonly returnTo: string;
32
+ readonly state: string;
33
+ }
34
+
35
+ export class CreateContentLockRequestBuilder {
36
+ free(): void;
37
+ [Symbol.dispose](): void;
38
+ accessPolicy(access_policy: any): CreateContentLockRequestBuilder;
39
+ build(): any;
40
+ criteria(criteria: any): CreateContentLockRequestBuilder;
41
+ lockLogic(lock_logic: any): CreateContentLockRequestBuilder;
42
+ lockServer(lock_server: any): CreateContentLockRequestBuilder;
43
+ constructor();
44
+ primaryResource(resource: any): CreateContentLockRequestBuilder;
45
+ secondaryResource(resource: any): CreateContentLockRequestBuilder;
46
+ secondaryResources(resources: any): CreateContentLockRequestBuilder;
47
+ }
48
+
49
+ export class Creator {
50
+ private constructor();
51
+ free(): void;
52
+ [Symbol.dispose](): void;
53
+ createContentLock(body: any): Promise<any>;
54
+ deleteGuardedResource(options: DeleteGuardedResourceOptions): Promise<void>;
55
+ exportSessionSecretForTests(): string;
56
+ paykitSetupStatus(): Promise<any>;
57
+ registerGuardedResource(options: RegisterGuardedResourceOptions): Promise<any>;
58
+ setLockServicePointer(options: SetLockServicePointerOptions): Promise<void>;
59
+ }
60
+
61
+ export class DeleteGuardedResourceOptions {
62
+ free(): void;
63
+ [Symbol.dispose](): void;
64
+ constructor(path: string);
65
+ readonly path: string;
66
+ }
67
+
68
+ export class ExchangeFrontendSessionCodeOptions {
69
+ free(): void;
70
+ [Symbol.dispose](): void;
71
+ constructor(code: string, state: string);
72
+ readonly code: string;
73
+ readonly state: string;
74
+ }
75
+
76
+ export class IntoUnderlyingByteSource {
77
+ private constructor();
78
+ free(): void;
79
+ [Symbol.dispose](): void;
80
+ cancel(): void;
81
+ pull(controller: ReadableByteStreamController): Promise<any>;
82
+ start(controller: ReadableByteStreamController): void;
83
+ readonly autoAllocateChunkSize: number;
84
+ readonly type: ReadableStreamType;
85
+ }
86
+
87
+ export class IntoUnderlyingSink {
88
+ private constructor();
89
+ free(): void;
90
+ [Symbol.dispose](): void;
91
+ abort(reason: any): Promise<any>;
92
+ close(): Promise<any>;
93
+ write(chunk: any): Promise<any>;
94
+ }
95
+
96
+ export class IntoUnderlyingSource {
97
+ private constructor();
98
+ free(): void;
99
+ [Symbol.dispose](): void;
100
+ cancel(): void;
101
+ pull(controller: ReadableStreamDefaultController): Promise<any>;
102
+ }
103
+
104
+ export class Locks {
105
+ private constructor();
106
+ free(): void;
107
+ [Symbol.dispose](): void;
108
+ createConnectUrl(options: ConnectUrlOptions): Promise<string>;
109
+ exchangeFrontendSessionCode(options: ExchangeFrontendSessionCodeOptions): Promise<Session>;
110
+ static forContentLock(resource: string): Promise<Locks>;
111
+ static forContentLockWithOptions(resource: string, options: LocksOptions): Promise<Locks>;
112
+ static forCreator(creator: string): Promise<Locks>;
113
+ static forCreatorWithOptions(creator: string, options: LocksOptions): Promise<Locks>;
114
+ static forServer(lock_server: string): Locks;
115
+ static forServerWithOptions(lock_server: string, options: LocksOptions): Locks;
116
+ static fromCreatorLockServicePointer(pointer: any): Locks;
117
+ static hasPaykitData(user: string): Promise<boolean>;
118
+ static hasPaykitDataWithOptions(user: string, options: LocksOptions): Promise<boolean>;
119
+ lockServer(): string;
120
+ static parseConnectCallback(callback_url: string): ConnectCallback;
121
+ static readContentLock(resource: string): Promise<any>;
122
+ static readContentLockWithOptions(resource: string, options: LocksOptions): Promise<any>;
123
+ restoreSession(secret: string): Session;
124
+ readonly viewer: Viewer;
125
+ }
126
+
127
+ export class LocksOptions {
128
+ free(): void;
129
+ [Symbol.dispose](): void;
130
+ addPkarrRelay(relay_url: string): LocksOptions;
131
+ constructor();
132
+ readonly pkarrRelays: string[];
133
+ }
134
+
135
+ export class RegisterGuardedResourceOptions {
136
+ free(): void;
137
+ [Symbol.dispose](): void;
138
+ constructor(path: string, content_type: string, bytes: Uint8Array);
139
+ readonly bytes: Uint8Array;
140
+ readonly contentType: string;
141
+ readonly path: string;
142
+ }
143
+
144
+ export class Session {
145
+ private constructor();
146
+ free(): void;
147
+ [Symbol.dispose](): void;
148
+ creatorPubky(): string | undefined;
149
+ exportSecret(): string;
150
+ lockServer(): string;
151
+ signout(): Promise<void>;
152
+ readonly creator: Creator;
153
+ }
154
+
155
+ export class SetLockServicePointerOptions {
156
+ free(): void;
157
+ [Symbol.dispose](): void;
158
+ constructor(default_lock_server: string);
159
+ readonly defaultLockServer: string;
160
+ }
161
+
162
+ export class VerificationTaskHandleOptions {
163
+ free(): void;
164
+ [Symbol.dispose](): void;
165
+ constructor(creator: string, bundle_id: string);
166
+ readonly bundleId: string;
167
+ readonly creator: string;
168
+ }
169
+
170
+ export class Viewer {
171
+ private constructor();
172
+ free(): void;
173
+ [Symbol.dispose](): void;
174
+ completeVerificationTask(options: VerificationTaskHandleOptions): Promise<any>;
175
+ issueAccessCredential(options: VerificationTaskHandleOptions): Promise<any>;
176
+ lookupPaykitConnectionState(options: VerificationTaskHandleOptions): Promise<any>;
177
+ lookupVerificationTask(options: VerificationTaskHandleOptions): Promise<any>;
178
+ proxyReadGuardedResource(access_credential: string, path: string): Promise<Uint8Array>;
179
+ proxyReadGuardedResourceResponse(access_credential: string, path: string): Promise<Response>;
180
+ submitProofBundle(submitted_proof_bundle: any): Promise<any>;
181
+ }
182
+
183
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
184
+
185
+ export interface InitOutput {
186
+ readonly memory: WebAssembly.Memory;
187
+ readonly __wbg_createcontentlockrequestbuilder_free: (a: number, b: number) => void;
188
+ readonly __wbg_creator_free: (a: number, b: number) => void;
189
+ readonly __wbg_deleteguardedresourceoptions_free: (a: number, b: number) => void;
190
+ readonly __wbg_registerguardedresourceoptions_free: (a: number, b: number) => void;
191
+ readonly __wbg_setlockservicepointeroptions_free: (a: number, b: number) => void;
192
+ readonly createcontentlockrequestbuilder_accessPolicy: (a: number, b: any) => [number, number, number];
193
+ readonly createcontentlockrequestbuilder_build: (a: number) => [number, number, number];
194
+ readonly createcontentlockrequestbuilder_criteria: (a: number, b: any) => [number, number, number];
195
+ readonly createcontentlockrequestbuilder_lockLogic: (a: number, b: any) => [number, number, number];
196
+ readonly createcontentlockrequestbuilder_lockServer: (a: number, b: any) => [number, number, number];
197
+ readonly createcontentlockrequestbuilder_new: () => number;
198
+ readonly createcontentlockrequestbuilder_primaryResource: (a: number, b: any) => [number, number, number];
199
+ readonly createcontentlockrequestbuilder_secondaryResource: (a: number, b: any) => [number, number, number];
200
+ readonly createcontentlockrequestbuilder_secondaryResources: (a: number, b: any) => [number, number, number];
201
+ readonly creator_createContentLock: (a: number, b: any) => any;
202
+ readonly creator_deleteGuardedResource: (a: number, b: number) => any;
203
+ readonly creator_exportSessionSecretForTests: (a: number) => [number, number];
204
+ readonly creator_paykitSetupStatus: (a: number) => any;
205
+ readonly creator_registerGuardedResource: (a: number, b: number) => any;
206
+ readonly creator_setLockServicePointer: (a: number, b: number) => any;
207
+ readonly deleteguardedresourceoptions_new: (a: number, b: number) => number;
208
+ readonly deleteguardedresourceoptions_path: (a: number) => [number, number];
209
+ readonly registerguardedresourceoptions_bytes: (a: number) => [number, number];
210
+ readonly registerguardedresourceoptions_contentType: (a: number) => [number, number];
211
+ readonly registerguardedresourceoptions_new: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
212
+ readonly registerguardedresourceoptions_path: (a: number) => [number, number];
213
+ readonly setlockservicepointeroptions_defaultLockServer: (a: number) => [number, number];
214
+ readonly setlockservicepointeroptions_new: (a: number, b: number) => number;
215
+ readonly __wbg_session_free: (a: number, b: number) => void;
216
+ readonly session_creator: (a: number) => number;
217
+ readonly session_creatorPubky: (a: number) => [number, number];
218
+ readonly session_exportSecret: (a: number) => [number, number];
219
+ readonly session_lockServer: (a: number) => [number, number];
220
+ readonly session_signout: (a: number) => any;
221
+ readonly __wbg_connectcallback_free: (a: number, b: number) => void;
222
+ readonly __wbg_connecturloptions_free: (a: number, b: number) => void;
223
+ readonly __wbg_exchangefrontendsessioncodeoptions_free: (a: number, b: number) => void;
224
+ readonly __wbg_locks_free: (a: number, b: number) => void;
225
+ readonly __wbg_locksoptions_free: (a: number, b: number) => void;
226
+ readonly connectcallback_code: (a: number) => [number, number];
227
+ readonly connectcallback_state: (a: number) => [number, number];
228
+ readonly connecturloptions_new: (a: number, b: number, c: number, d: number) => number;
229
+ readonly connecturloptions_returnTo: (a: number) => [number, number];
230
+ readonly connecturloptions_state: (a: number) => [number, number];
231
+ readonly exchangefrontendsessioncodeoptions_code: (a: number) => [number, number];
232
+ readonly exchangefrontendsessioncodeoptions_state: (a: number) => [number, number];
233
+ readonly locks_createConnectUrl: (a: number, b: number) => any;
234
+ readonly locks_exchangeFrontendSessionCode: (a: number, b: number) => any;
235
+ readonly locks_forContentLock: (a: number, b: number) => any;
236
+ readonly locks_forContentLockWithOptions: (a: number, b: number, c: number) => any;
237
+ readonly locks_forCreator: (a: number, b: number) => any;
238
+ readonly locks_forCreatorWithOptions: (a: number, b: number, c: number) => any;
239
+ readonly locks_forServer: (a: number, b: number) => [number, number, number];
240
+ readonly locks_forServerWithOptions: (a: number, b: number, c: number) => [number, number, number];
241
+ readonly locks_fromCreatorLockServicePointer: (a: any) => [number, number, number];
242
+ readonly locks_hasPaykitData: (a: number, b: number) => any;
243
+ readonly locks_hasPaykitDataWithOptions: (a: number, b: number, c: number) => any;
244
+ readonly locks_lockServer: (a: number) => [number, number];
245
+ readonly locks_parseConnectCallback: (a: number, b: number) => [number, number, number];
246
+ readonly locks_readContentLock: (a: number, b: number) => any;
247
+ readonly locks_readContentLockWithOptions: (a: number, b: number, c: number) => any;
248
+ readonly locks_restoreSession: (a: number, b: number, c: number) => number;
249
+ readonly locks_viewer: (a: number) => number;
250
+ readonly locksoptions_addPkarrRelay: (a: number, b: number, c: number) => [number, number, number];
251
+ readonly locksoptions_new: () => number;
252
+ readonly locksoptions_pkarrRelays: (a: number) => [number, number];
253
+ readonly exchangefrontendsessioncodeoptions_new: (a: number, b: number, c: number, d: number) => number;
254
+ readonly __wbg_bundleid_free: (a: number, b: number) => void;
255
+ readonly __wbg_verificationtaskhandleoptions_free: (a: number, b: number) => void;
256
+ readonly __wbg_viewer_free: (a: number, b: number) => void;
257
+ readonly bundleid_generate: () => number;
258
+ readonly bundleid_new: (a: number, b: number) => [number, number, number];
259
+ readonly bundleid_toString: (a: number) => [number, number];
260
+ readonly verificationtaskhandleoptions_bundleId: (a: number) => [number, number];
261
+ readonly verificationtaskhandleoptions_creator: (a: number) => [number, number];
262
+ readonly verificationtaskhandleoptions_new: (a: number, b: number, c: number, d: number) => [number, number, number];
263
+ readonly viewer_completeVerificationTask: (a: number, b: number) => any;
264
+ readonly viewer_issueAccessCredential: (a: number, b: number) => any;
265
+ readonly viewer_lookupPaykitConnectionState: (a: number, b: number) => any;
266
+ readonly viewer_lookupVerificationTask: (a: number, b: number) => any;
267
+ readonly viewer_proxyReadGuardedResource: (a: number, b: number, c: number, d: number, e: number) => any;
268
+ readonly viewer_proxyReadGuardedResourceResponse: (a: number, b: number, c: number, d: number, e: number) => any;
269
+ readonly viewer_submitProofBundle: (a: number, b: any) => any;
270
+ readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
271
+ readonly intounderlyingsource_cancel: (a: number) => void;
272
+ readonly intounderlyingsource_pull: (a: number, b: any) => any;
273
+ readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
274
+ readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
275
+ readonly intounderlyingbytesource_cancel: (a: number) => void;
276
+ readonly intounderlyingbytesource_pull: (a: number, b: any) => any;
277
+ readonly intounderlyingbytesource_start: (a: number, b: any) => void;
278
+ readonly intounderlyingbytesource_type: (a: number) => number;
279
+ readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
280
+ readonly intounderlyingsink_abort: (a: number, b: any) => any;
281
+ readonly intounderlyingsink_close: (a: number) => any;
282
+ readonly intounderlyingsink_write: (a: number, b: any) => any;
283
+ readonly wasm_bindgen__convert__closures_____invoke__h91c6e0a7524f6a5b: (a: number, b: number, c: any) => [number, number];
284
+ readonly wasm_bindgen__convert__closures_____invoke__h0bbd1023632d6b79: (a: number, b: number, c: any, d: any) => void;
285
+ readonly wasm_bindgen__convert__closures_____invoke__h67168fce963d1069: (a: number, b: number) => void;
286
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
287
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
288
+ readonly __wbindgen_exn_store: (a: number) => void;
289
+ readonly __externref_table_alloc: () => number;
290
+ readonly __wbindgen_externrefs: WebAssembly.Table;
291
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
292
+ readonly __externref_table_dealloc: (a: number) => void;
293
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
294
+ readonly __externref_drop_slice: (a: number, b: number) => void;
295
+ readonly __wbindgen_start: () => void;
296
+ }
297
+
298
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
299
+
300
+ /**
301
+ * Instantiates the given `module`, which can either be bytes or
302
+ * a precompiled `WebAssembly.Module`.
303
+ *
304
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
305
+ *
306
+ * @returns {InitOutput}
307
+ */
308
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
309
+
310
+ /**
311
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
312
+ * for everything else, calls `WebAssembly.instantiate` directly.
313
+ *
314
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
315
+ *
316
+ * @returns {Promise<InitOutput>}
317
+ */
318
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;