@keyhive/keyhive 0.0.0-alpha.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 +34 -0
- package/package.json +46 -0
- package/pkg/.gitignore +1 -0
- package/pkg/README.md +34 -0
- package/pkg/keyhive_wasm.d.ts +349 -0
- package/pkg/keyhive_wasm.js +5 -0
- package/pkg/keyhive_wasm_bg.js +3444 -0
- package/pkg/keyhive_wasm_bg.wasm +0 -0
- package/pkg/keyhive_wasm_bg.wasm.d.ts +208 -0
- package/pkg/package.json +28 -0
- package/pkg-node/.gitignore +1 -0
- package/pkg-node/README.md +34 -0
- package/pkg-node/keyhive_wasm.d.ts +349 -0
- package/pkg-node/keyhive_wasm.js +3493 -0
- package/pkg-node/keyhive_wasm_bg.wasm +0 -0
- package/pkg-node/keyhive_wasm_bg.wasm.d.ts +208 -0
- package/pkg-node/package.json +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Keyhive WASM bindings
|
|
2
|
+
|
|
3
|
+
## Build package
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
wasm-pack build --target web --out-dir pkg -- --features web-sys
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
To build with the `ingest_static` feature:
|
|
10
|
+
```
|
|
11
|
+
wasm-pack build --target web --out-dir pkg -- --features web-sys,ingest_static
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Run tests
|
|
15
|
+
|
|
16
|
+
Install dependencies:
|
|
17
|
+
```
|
|
18
|
+
pnpm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Install Playwright's browser binaries:
|
|
22
|
+
```
|
|
23
|
+
npx playwright install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run tests:
|
|
27
|
+
```
|
|
28
|
+
npx playwright test
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
View Playwright report:
|
|
32
|
+
```
|
|
33
|
+
npx playwright show-report
|
|
34
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@keyhive/keyhive",
|
|
3
|
+
"version": "0.0.0-alpha.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "pkg/keyhive_wasm.js",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"module": "pkg/keyhive_wasm.js",
|
|
11
|
+
"types": "pkg/keyhive_wasm.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"pkg/*",
|
|
14
|
+
"pkg-node/*"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"node": {
|
|
19
|
+
"import": "./pkg-node/keyhive_wasm.js",
|
|
20
|
+
"require": "./pkg-node/keyhive_wasm.js",
|
|
21
|
+
"types": "./pkg-node/keyhive_wasm.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"import": "./pkg/keyhive_wasm.js",
|
|
24
|
+
"require": "./pkg/keyhive_wasm.js",
|
|
25
|
+
"types": "./pkg/keyhive_wasm.d.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@playwright/test": "^1.55.0",
|
|
30
|
+
"@types/node": "^22.17.2",
|
|
31
|
+
"html-webpack-plugin": "^5.6.4",
|
|
32
|
+
"ts-loader": "^9.5.2",
|
|
33
|
+
"typescript": "^5.9.2",
|
|
34
|
+
"vite": "^5.4.19",
|
|
35
|
+
"vite-plugin-top-level-await": "^1.6.0",
|
|
36
|
+
"vite-plugin-wasm": "^3.5.0",
|
|
37
|
+
"webpack": "^5.101.3",
|
|
38
|
+
"webpack-cli": "^5.1.4",
|
|
39
|
+
"webpack-dev-server": "^5.2.2"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "npm run build-node && npm run build-bundler",
|
|
43
|
+
"build-node": "wasm-pack build --out-dir pkg-node --target nodejs --release",
|
|
44
|
+
"build-bundler": "wasm-pack build --out-dir pkg --target bundler --release"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/pkg/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
package/pkg/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Keyhive WASM bindings
|
|
2
|
+
|
|
3
|
+
## Build package
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
wasm-pack build --target web --out-dir pkg -- --features web-sys
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
To build with the `ingest_static` feature:
|
|
10
|
+
```
|
|
11
|
+
wasm-pack build --target web --out-dir pkg -- --features web-sys,ingest_static
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Run tests
|
|
15
|
+
|
|
16
|
+
Install dependencies:
|
|
17
|
+
```
|
|
18
|
+
pnpm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Install Playwright's browser binaries:
|
|
22
|
+
```
|
|
23
|
+
npx playwright install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run tests:
|
|
27
|
+
```
|
|
28
|
+
npx playwright test
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
View Playwright report:
|
|
32
|
+
```
|
|
33
|
+
npx playwright show-report
|
|
34
|
+
```
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Panic hook lets us get better error messages if our Rust code ever panics.
|
|
5
|
+
*
|
|
6
|
+
* This function needs to be called at least once during initialisation.
|
|
7
|
+
* https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/template-deep-dive/src-utils-rs.html#2-what-is-console_error_panic_hook
|
|
8
|
+
*/
|
|
9
|
+
export function setPanicHook(): void;
|
|
10
|
+
export class Access {
|
|
11
|
+
private constructor();
|
|
12
|
+
free(): void;
|
|
13
|
+
static tryFromString(s: string): Access | undefined;
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
16
|
+
export class AddMemberError {
|
|
17
|
+
private constructor();
|
|
18
|
+
free(): void;
|
|
19
|
+
message(): string;
|
|
20
|
+
}
|
|
21
|
+
export class Agent {
|
|
22
|
+
private constructor();
|
|
23
|
+
free(): void;
|
|
24
|
+
toString(): string;
|
|
25
|
+
isIndividual(): boolean;
|
|
26
|
+
isGroup(): boolean;
|
|
27
|
+
isDocument(): boolean;
|
|
28
|
+
readonly id: Identifier;
|
|
29
|
+
}
|
|
30
|
+
export class Archive {
|
|
31
|
+
free(): void;
|
|
32
|
+
constructor(bytes: Uint8Array);
|
|
33
|
+
toBytes(): Uint8Array;
|
|
34
|
+
tryToKeyhive(ciphertext_store: CiphertextStore, signer: Signer, event_handler: Function): Keyhive;
|
|
35
|
+
}
|
|
36
|
+
export class CannotParseEd25519SigningKey {
|
|
37
|
+
private constructor();
|
|
38
|
+
free(): void;
|
|
39
|
+
}
|
|
40
|
+
export class CannotParseIdentifier {
|
|
41
|
+
private constructor();
|
|
42
|
+
free(): void;
|
|
43
|
+
}
|
|
44
|
+
export class Capability {
|
|
45
|
+
private constructor();
|
|
46
|
+
free(): void;
|
|
47
|
+
readonly who: Agent;
|
|
48
|
+
readonly can: Access;
|
|
49
|
+
readonly proof: SignedDelegation;
|
|
50
|
+
}
|
|
51
|
+
export class CgkaOperation {
|
|
52
|
+
private constructor();
|
|
53
|
+
free(): void;
|
|
54
|
+
readonly variant: string;
|
|
55
|
+
}
|
|
56
|
+
export class ChangeRef {
|
|
57
|
+
free(): void;
|
|
58
|
+
constructor(bytes: Uint8Array);
|
|
59
|
+
readonly bytes: Uint8Array;
|
|
60
|
+
}
|
|
61
|
+
export class CiphertextStore {
|
|
62
|
+
private constructor();
|
|
63
|
+
free(): void;
|
|
64
|
+
static newInMemory(): CiphertextStore;
|
|
65
|
+
static newFromWebStorage(storage: Storage): CiphertextStore;
|
|
66
|
+
}
|
|
67
|
+
export class ContactCard {
|
|
68
|
+
private constructor();
|
|
69
|
+
free(): void;
|
|
70
|
+
signature(): Uint8Array;
|
|
71
|
+
static fromJson(json: string): ContactCard;
|
|
72
|
+
toJson(): string;
|
|
73
|
+
readonly id: IndividualId;
|
|
74
|
+
readonly shareKey: ShareKey;
|
|
75
|
+
}
|
|
76
|
+
export class Delegation {
|
|
77
|
+
private constructor();
|
|
78
|
+
free(): void;
|
|
79
|
+
readonly delegate: Agent;
|
|
80
|
+
readonly can: Access;
|
|
81
|
+
readonly proof: SignedDelegation | undefined;
|
|
82
|
+
readonly after: History;
|
|
83
|
+
}
|
|
84
|
+
export class DelegationError {
|
|
85
|
+
private constructor();
|
|
86
|
+
free(): void;
|
|
87
|
+
}
|
|
88
|
+
export class DocContentRefs {
|
|
89
|
+
free(): void;
|
|
90
|
+
constructor(doc_id: DocumentId, change_hashes: ChangeRef[]);
|
|
91
|
+
addChangeRef(hash: ChangeRef): void;
|
|
92
|
+
readonly docId: DocumentId;
|
|
93
|
+
readonly change_hashes: ChangeRef[];
|
|
94
|
+
}
|
|
95
|
+
export class Document {
|
|
96
|
+
private constructor();
|
|
97
|
+
free(): void;
|
|
98
|
+
toPeer(): Peer;
|
|
99
|
+
toAgent(): Agent;
|
|
100
|
+
readonly id: Identifier;
|
|
101
|
+
readonly doc_id: DocumentId;
|
|
102
|
+
}
|
|
103
|
+
export class DocumentId {
|
|
104
|
+
free(): void;
|
|
105
|
+
constructor(bytes: Uint8Array);
|
|
106
|
+
fromString(): string;
|
|
107
|
+
toJsValue(): any;
|
|
108
|
+
toBytes(): Uint8Array;
|
|
109
|
+
}
|
|
110
|
+
export class Encrypted {
|
|
111
|
+
private constructor();
|
|
112
|
+
free(): void;
|
|
113
|
+
toBytes(): Uint8Array;
|
|
114
|
+
readonly ciphertext: Uint8Array;
|
|
115
|
+
readonly nonce: Uint8Array;
|
|
116
|
+
readonly pcs_key_hash: Uint8Array;
|
|
117
|
+
readonly content_ref: Uint8Array;
|
|
118
|
+
readonly pred_refs: Uint8Array;
|
|
119
|
+
}
|
|
120
|
+
export class EncryptedContentWithUpdate {
|
|
121
|
+
private constructor();
|
|
122
|
+
free(): void;
|
|
123
|
+
encrypted_content(): Encrypted;
|
|
124
|
+
update_op(): SignedCgkaOperation | undefined;
|
|
125
|
+
}
|
|
126
|
+
export class Event {
|
|
127
|
+
private constructor();
|
|
128
|
+
free(): void;
|
|
129
|
+
tryIntoSignedDelegation(): SignedDelegation | undefined;
|
|
130
|
+
tryIntoSignedRevocation(): SignedRevocation | undefined;
|
|
131
|
+
readonly variant: string;
|
|
132
|
+
readonly isDelegated: boolean;
|
|
133
|
+
readonly isRevoked: boolean;
|
|
134
|
+
}
|
|
135
|
+
export class GenerateDocError {
|
|
136
|
+
private constructor();
|
|
137
|
+
free(): void;
|
|
138
|
+
message(): string;
|
|
139
|
+
}
|
|
140
|
+
export class GenerateWebCryptoError {
|
|
141
|
+
private constructor();
|
|
142
|
+
free(): void;
|
|
143
|
+
message(): string;
|
|
144
|
+
}
|
|
145
|
+
export class GetCiphertextError {
|
|
146
|
+
private constructor();
|
|
147
|
+
free(): void;
|
|
148
|
+
readonly message: string;
|
|
149
|
+
}
|
|
150
|
+
export class Group {
|
|
151
|
+
private constructor();
|
|
152
|
+
free(): void;
|
|
153
|
+
toPeer(): Peer;
|
|
154
|
+
toAgent(): Agent;
|
|
155
|
+
toMembered(): Membered;
|
|
156
|
+
readonly id: Identifier;
|
|
157
|
+
readonly groupId: GroupId;
|
|
158
|
+
readonly members: Capability[];
|
|
159
|
+
}
|
|
160
|
+
export class GroupId {
|
|
161
|
+
private constructor();
|
|
162
|
+
free(): void;
|
|
163
|
+
toString(): string;
|
|
164
|
+
}
|
|
165
|
+
export class History {
|
|
166
|
+
private constructor();
|
|
167
|
+
free(): void;
|
|
168
|
+
delegations(): SignedDelegation[];
|
|
169
|
+
revocations(): SignedRevocation[];
|
|
170
|
+
contentRefs(): DocContentRefs[];
|
|
171
|
+
}
|
|
172
|
+
export class Identifier {
|
|
173
|
+
free(): void;
|
|
174
|
+
constructor(bytes: Uint8Array);
|
|
175
|
+
toBytes(): Uint8Array;
|
|
176
|
+
}
|
|
177
|
+
export class Individual {
|
|
178
|
+
private constructor();
|
|
179
|
+
free(): void;
|
|
180
|
+
toPeer(): Peer;
|
|
181
|
+
toAgent(): Agent;
|
|
182
|
+
pickPrekey(doc_id: DocumentId): ShareKey;
|
|
183
|
+
readonly id: Identifier;
|
|
184
|
+
readonly individualId: IndividualId;
|
|
185
|
+
}
|
|
186
|
+
export class IndividualId {
|
|
187
|
+
private constructor();
|
|
188
|
+
free(): void;
|
|
189
|
+
readonly bytes: Uint8Array;
|
|
190
|
+
}
|
|
191
|
+
export class Invocation {
|
|
192
|
+
private constructor();
|
|
193
|
+
free(): void;
|
|
194
|
+
}
|
|
195
|
+
export class JsDecryptError {
|
|
196
|
+
private constructor();
|
|
197
|
+
free(): void;
|
|
198
|
+
}
|
|
199
|
+
export class JsEncryptError {
|
|
200
|
+
private constructor();
|
|
201
|
+
free(): void;
|
|
202
|
+
}
|
|
203
|
+
export class JsReceivePreKeyOpError {
|
|
204
|
+
private constructor();
|
|
205
|
+
free(): void;
|
|
206
|
+
}
|
|
207
|
+
export class JsReceiveStaticEventError {
|
|
208
|
+
private constructor();
|
|
209
|
+
free(): void;
|
|
210
|
+
}
|
|
211
|
+
export class Keyhive {
|
|
212
|
+
private constructor();
|
|
213
|
+
free(): void;
|
|
214
|
+
static init(signer: Signer, ciphertext_store: CiphertextStore, event_handler: Function): Promise<Keyhive>;
|
|
215
|
+
generateGroup(coparents: Peer[]): Promise<Group>;
|
|
216
|
+
generateDocument(coparents: Peer[], initial_content_ref_head: ChangeRef, more_initial_content_refs: ChangeRef[]): Promise<Document>;
|
|
217
|
+
trySign(data: Uint8Array): Promise<Signed>;
|
|
218
|
+
tryEncrypt(doc: Document, content_ref: ChangeRef, pred_refs: ChangeRef[], content: Uint8Array): Promise<EncryptedContentWithUpdate>;
|
|
219
|
+
tryEncryptArchive(doc: Document, content_ref: ChangeRef, pred_refs: ChangeRef[], content: Uint8Array): Promise<EncryptedContentWithUpdate>;
|
|
220
|
+
tryDecrypt(doc: Document, encrypted: Encrypted): Uint8Array;
|
|
221
|
+
addMember(to_add: Agent, membered: Membered, access: Access, other_relevant_docs: Document[]): Promise<SignedDelegation>;
|
|
222
|
+
revokeMember(to_revoke: Agent, retain_all_other_members: boolean, membered: Membered): Promise<SignedRevocation[]>;
|
|
223
|
+
reachableDocs(): Summary[];
|
|
224
|
+
forcePcsUpdate(doc: Document): Promise<void>;
|
|
225
|
+
rotatePrekey(prekey: ShareKey): Promise<ShareKey>;
|
|
226
|
+
expandPrekeys(): Promise<ShareKey>;
|
|
227
|
+
contactCard(): Promise<ContactCard>;
|
|
228
|
+
receiveContactCard(contact_card: ContactCard): Individual;
|
|
229
|
+
getAgent(id: Identifier): Agent | undefined;
|
|
230
|
+
getGroup(id: Identifier): Group | undefined;
|
|
231
|
+
docMemberCapabilities(doc_id: DocumentId): SimpleCapability[];
|
|
232
|
+
accessForDoc(id: Identifier, doc_id: DocumentId): Access | undefined;
|
|
233
|
+
intoArchive(): Archive;
|
|
234
|
+
toArchive(): Archive;
|
|
235
|
+
readonly id: IndividualId;
|
|
236
|
+
readonly whoami: IndividualId;
|
|
237
|
+
readonly idString: string;
|
|
238
|
+
}
|
|
239
|
+
export class Membered {
|
|
240
|
+
private constructor();
|
|
241
|
+
free(): void;
|
|
242
|
+
}
|
|
243
|
+
export class Peer {
|
|
244
|
+
private constructor();
|
|
245
|
+
free(): void;
|
|
246
|
+
toString(): string;
|
|
247
|
+
isIndividual(): boolean;
|
|
248
|
+
isGroup(): boolean;
|
|
249
|
+
isDocument(): boolean;
|
|
250
|
+
}
|
|
251
|
+
export class RemoveCiphertextError {
|
|
252
|
+
private constructor();
|
|
253
|
+
free(): void;
|
|
254
|
+
}
|
|
255
|
+
export class Revocation {
|
|
256
|
+
private constructor();
|
|
257
|
+
free(): void;
|
|
258
|
+
readonly subject_id: Identifier;
|
|
259
|
+
readonly revoked: SignedDelegation;
|
|
260
|
+
readonly proof: SignedDelegation | undefined;
|
|
261
|
+
readonly after: History;
|
|
262
|
+
}
|
|
263
|
+
export class RevokeMemberError {
|
|
264
|
+
private constructor();
|
|
265
|
+
free(): void;
|
|
266
|
+
readonly message: string;
|
|
267
|
+
}
|
|
268
|
+
export class SerializationError {
|
|
269
|
+
private constructor();
|
|
270
|
+
free(): void;
|
|
271
|
+
toError(): any;
|
|
272
|
+
}
|
|
273
|
+
export class ShareKey {
|
|
274
|
+
private constructor();
|
|
275
|
+
free(): void;
|
|
276
|
+
}
|
|
277
|
+
export class Signed {
|
|
278
|
+
private constructor();
|
|
279
|
+
free(): void;
|
|
280
|
+
static fromBytes(bytes: Uint8Array): Signed;
|
|
281
|
+
toBytes(): Uint8Array;
|
|
282
|
+
verify(): boolean;
|
|
283
|
+
readonly payload: Uint8Array;
|
|
284
|
+
readonly verifyingKey: Uint8Array;
|
|
285
|
+
readonly signature: Uint8Array;
|
|
286
|
+
}
|
|
287
|
+
export class SignedCgkaOperation {
|
|
288
|
+
private constructor();
|
|
289
|
+
free(): void;
|
|
290
|
+
verify(): boolean;
|
|
291
|
+
readonly delegation: CgkaOperation;
|
|
292
|
+
readonly verifyingKey: Uint8Array;
|
|
293
|
+
readonly signature: Uint8Array;
|
|
294
|
+
}
|
|
295
|
+
export class SignedDelegation {
|
|
296
|
+
private constructor();
|
|
297
|
+
free(): void;
|
|
298
|
+
verify(): boolean;
|
|
299
|
+
readonly delegation: Delegation;
|
|
300
|
+
readonly verifyingKey: Uint8Array;
|
|
301
|
+
readonly signature: Uint8Array;
|
|
302
|
+
}
|
|
303
|
+
export class SignedInvocation {
|
|
304
|
+
private constructor();
|
|
305
|
+
free(): void;
|
|
306
|
+
}
|
|
307
|
+
export class SignedRevocation {
|
|
308
|
+
private constructor();
|
|
309
|
+
free(): void;
|
|
310
|
+
verify(): boolean;
|
|
311
|
+
readonly delegation: Revocation;
|
|
312
|
+
readonly verifyingKey: Uint8Array;
|
|
313
|
+
readonly signature: Uint8Array;
|
|
314
|
+
}
|
|
315
|
+
export class Signer {
|
|
316
|
+
private constructor();
|
|
317
|
+
free(): void;
|
|
318
|
+
static generate(): Promise<Signer>;
|
|
319
|
+
static generateMemory(): Signer;
|
|
320
|
+
static generateWebCrypto(): Promise<Signer>;
|
|
321
|
+
static memorySignerFromBytes(bytes: Uint8Array): Signer;
|
|
322
|
+
static webCryptoSigner(keypair: any): Promise<Signer>;
|
|
323
|
+
trySign(bytes: Uint8Array): Promise<Signed>;
|
|
324
|
+
clone(): Signer;
|
|
325
|
+
readonly variant: string;
|
|
326
|
+
readonly verifyingKey: Uint8Array;
|
|
327
|
+
}
|
|
328
|
+
export class SigningError {
|
|
329
|
+
private constructor();
|
|
330
|
+
free(): void;
|
|
331
|
+
message(): string;
|
|
332
|
+
}
|
|
333
|
+
export class SimpleCapability {
|
|
334
|
+
private constructor();
|
|
335
|
+
free(): void;
|
|
336
|
+
readonly who: Agent;
|
|
337
|
+
readonly can: Access;
|
|
338
|
+
}
|
|
339
|
+
export class Summary {
|
|
340
|
+
private constructor();
|
|
341
|
+
free(): void;
|
|
342
|
+
readonly doc: Document;
|
|
343
|
+
readonly access: Access;
|
|
344
|
+
}
|
|
345
|
+
export class TryFromArchiveError {
|
|
346
|
+
private constructor();
|
|
347
|
+
free(): void;
|
|
348
|
+
toError(): any;
|
|
349
|
+
}
|