@synonymdev/pubky 0.17.1 → 0.18.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 +35 -3
- package/index.cjs +170 -57
- package/index.js +171 -58
- package/package.json +4 -3
- package/pubky.d.ts +97 -8
- package/pubky_bg.wasm +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@synonymdev/pubky",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Decentralized identity, auth flows, and user-owned storage",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.18.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/tape": "^5.6.4",
|
|
42
42
|
"browser-resolve": "^2.0.0",
|
|
43
43
|
"browserify": "^17.0.1",
|
|
44
|
-
"electron": "
|
|
44
|
+
"electron": "45.1.0",
|
|
45
45
|
"esmify": "^2.1.1",
|
|
46
46
|
"tape": "^5.8.1",
|
|
47
47
|
"tape-run": "^11.0.0",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"fetch-cookie": "^3.0.1"
|
|
53
53
|
},
|
|
54
54
|
"overrides": {
|
|
55
|
-
"electron": "
|
|
55
|
+
"electron": "45.1.0",
|
|
56
|
+
"minimist": "^1.2.8"
|
|
56
57
|
}
|
|
57
58
|
}
|
package/pubky.d.ts
CHANGED
|
@@ -25,6 +25,33 @@ export interface RecoveredEncryptionKeys {
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
/** The individual limits of a quota. A limit is a number, a rate string such as
|
|
29
|
+
* `"100mb/m"`, or `"unlimited"`. Absent in `overrides` means the system default. */
|
|
30
|
+
export interface AccountQuotaLimits {
|
|
31
|
+
/** Storage quota in megabytes, or "unlimited". */
|
|
32
|
+
storageQuotaMb?: number | "unlimited";
|
|
33
|
+
/** Read bandwidth limit, e.g. "100mb/m", or "unlimited". */
|
|
34
|
+
rateRead?: string;
|
|
35
|
+
/** Write bandwidth limit, e.g. "50mb/s", or "unlimited". */
|
|
36
|
+
rateWrite?: string;
|
|
37
|
+
/** Burst allowance for reads, in the rate's unit. Absent means burst equals rate. */
|
|
38
|
+
rateReadBurst?: number;
|
|
39
|
+
/** Burst allowance for writes, in the rate's unit. Absent means burst equals rate. */
|
|
40
|
+
rateWriteBurst?: number;
|
|
41
|
+
/** Path prefixes the user may write to. Absent means unrestricted; empty means read-only. */
|
|
42
|
+
allowedWritePaths?: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A user's quota, both as it applies and as it was customised. */
|
|
46
|
+
export interface AccountQuota {
|
|
47
|
+
/** Overrides merged with the homeserver's defaults. */
|
|
48
|
+
effective: AccountQuotaLimits;
|
|
49
|
+
/** Only the per-user overrides. */
|
|
50
|
+
overrides: AccountQuotaLimits;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
28
55
|
export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
|
|
29
56
|
/** Root-signed grant claims. Public keys are z-base-32; times are Unix seconds. */
|
|
30
57
|
export interface VerifiedGrantClaims {
|
|
@@ -96,6 +123,15 @@ export interface GrantAuthFlowOptions {
|
|
|
96
123
|
* `signedApprovalV1` sets `af=v1` in the authorization link.
|
|
97
124
|
*/
|
|
98
125
|
approvalFormat?: GrantApprovalFormat;
|
|
126
|
+
/**
|
|
127
|
+
* Optional expected identity: public key of the signed-in user that must
|
|
128
|
+
* approve, as raw z32 or `pubky<z32>`. Set it only when the app already
|
|
129
|
+
* knows the user, e.g. to re-authorize or request more capabilities. It
|
|
130
|
+
* adds `spk` to the link; signers approve with that key or refuse, and the
|
|
131
|
+
* flow rejects approvals from any other key. Switching accounts takes a
|
|
132
|
+
* flow without it. Sign-up flows reject it.
|
|
133
|
+
*/
|
|
134
|
+
expectedSigner?: string | null;
|
|
99
135
|
}
|
|
100
136
|
|
|
101
137
|
/**
|
|
@@ -180,6 +216,7 @@ export type RequestErrorReason =
|
|
|
180
216
|
| "Http"
|
|
181
217
|
| "Timeout"
|
|
182
218
|
| "Connection"
|
|
219
|
+
| "TlsVerification"
|
|
183
220
|
| "Body"
|
|
184
221
|
| "Decode"
|
|
185
222
|
| "InvalidRequest"
|
|
@@ -319,6 +356,39 @@ export type Capabilities = "" | CapabilityEntry | `${CapabilityEntry}${Capabilit
|
|
|
319
356
|
export type Path = `/pub/${string}` | `/priv/${string}`;
|
|
320
357
|
|
|
321
358
|
|
|
359
|
+
/**
|
|
360
|
+
* A user's account as returned by `session.grant.account()`.
|
|
361
|
+
*/
|
|
362
|
+
export class AccountInfo {
|
|
363
|
+
private constructor();
|
|
364
|
+
free(): void;
|
|
365
|
+
[Symbol.dispose](): void;
|
|
366
|
+
/**
|
|
367
|
+
* When the user signed up, as an ISO 8601 date and time without a UTC
|
|
368
|
+
* offset (e.g. `2026-10-22T10:11:12.123456`).
|
|
369
|
+
*/
|
|
370
|
+
readonly createdAt: string;
|
|
371
|
+
/**
|
|
372
|
+
* Whether the account is disabled. Disabled accounts can read and delete
|
|
373
|
+
* but not write.
|
|
374
|
+
*/
|
|
375
|
+
readonly disabled: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* The user this account belongs to.
|
|
378
|
+
*/
|
|
379
|
+
readonly pubky: PublicKey;
|
|
380
|
+
/**
|
|
381
|
+
* The quota that applies and the per-user overrides behind it.
|
|
382
|
+
*
|
|
383
|
+
* @returns {AccountQuota}
|
|
384
|
+
*/
|
|
385
|
+
readonly quota: AccountQuota;
|
|
386
|
+
/**
|
|
387
|
+
* Bytes of storage currently used.
|
|
388
|
+
*/
|
|
389
|
+
readonly usedBytes: number;
|
|
390
|
+
}
|
|
391
|
+
|
|
322
392
|
/**
|
|
323
393
|
* Start and control a pubkyauth authorization flow.
|
|
324
394
|
*
|
|
@@ -1069,7 +1139,7 @@ export class GrantAuthFlow {
|
|
|
1069
1139
|
* The kind of authentication flow to perform.
|
|
1070
1140
|
*
|
|
1071
1141
|
* @param {GrantAuthFlowOptions} options
|
|
1072
|
-
* Options for the grant flow: `{ clientId, relay?, xCallback? }`.
|
|
1142
|
+
* Options for the grant flow: `{ clientId, relay?, xCallback?, approvalFormat?, expectedSigner? }`.
|
|
1073
1143
|
*
|
|
1074
1144
|
* @returns {GrantAuthFlow}
|
|
1075
1145
|
* A running grant auth flow. Call `authorizationUrl()` to show the deep link,
|
|
@@ -1169,6 +1239,17 @@ export class GrantSession {
|
|
|
1169
1239
|
private constructor();
|
|
1170
1240
|
free(): void;
|
|
1171
1241
|
[Symbol.dispose](): void;
|
|
1242
|
+
/**
|
|
1243
|
+
* Fetch this user's account: storage used, whether it is disabled, and
|
|
1244
|
+
* the quota that applies.
|
|
1245
|
+
*
|
|
1246
|
+
* Requires read permission on the root scope (`/:r`, `/:rw`, ...).
|
|
1247
|
+
* Path-scoped sessions surface the homeserver `403` as the standard
|
|
1248
|
+
* request error.
|
|
1249
|
+
*
|
|
1250
|
+
* @returns {Promise<AccountInfo>}
|
|
1251
|
+
*/
|
|
1252
|
+
account(): Promise<AccountInfo>;
|
|
1172
1253
|
/**
|
|
1173
1254
|
* Sign JSON data and return both the custom proof and its root-signed grant.
|
|
1174
1255
|
* Data follows `JSON.stringify` semantics, e.g. `undefined` properties are omitted.
|
|
@@ -1611,7 +1692,7 @@ export class Pubky {
|
|
|
1611
1692
|
* @param {string} capabilities Comma-separated caps, e.g. `"/pub/app/:rw,/pub/foo/file:r"`.
|
|
1612
1693
|
* @param {AuthFlowKind} kind The kind of authentication flow to perform.
|
|
1613
1694
|
* @param {GrantAuthFlowOptions} options Options for the grant flow:
|
|
1614
|
-
* `{ clientId, relay?, xCallback?, approvalFormat? }`.
|
|
1695
|
+
* `{ clientId, relay?, xCallback?, approvalFormat?, expectedSigner? }`.
|
|
1615
1696
|
* @returns {Promise<GrantAuthFlow>}
|
|
1616
1697
|
* A running grant auth flow. Show `authorizationUrl` as QR/deeplink,
|
|
1617
1698
|
* then `awaitApproval()` to obtain a grant-backed `Session`.
|
|
@@ -1712,7 +1793,8 @@ export class PubkyResource {
|
|
|
1712
1793
|
*/
|
|
1713
1794
|
static parse(value: string): PubkyResource;
|
|
1714
1795
|
/**
|
|
1715
|
-
* Render as `pubky://<owner
|
|
1796
|
+
* Render as `pubky://<owner><path>` (deep-link form), the form listings
|
|
1797
|
+
* and events use.
|
|
1716
1798
|
*/
|
|
1717
1799
|
toPubkyUrl(): string;
|
|
1718
1800
|
/**
|
|
@@ -1724,7 +1806,7 @@ export class PubkyResource {
|
|
|
1724
1806
|
*/
|
|
1725
1807
|
readonly owner: PublicKey;
|
|
1726
1808
|
/**
|
|
1727
|
-
* Get the absolute path (e.g., "/pub/
|
|
1809
|
+
* Get the absolute path (e.g., "/pub/My File.txt").
|
|
1728
1810
|
*/
|
|
1729
1811
|
readonly path: string;
|
|
1730
1812
|
}
|
|
@@ -1794,10 +1876,10 @@ export class PublicStorage {
|
|
|
1794
1876
|
*/
|
|
1795
1877
|
get(address: Address): Promise<Response>;
|
|
1796
1878
|
/**
|
|
1797
|
-
* List a directory. Results are `pubky
|
|
1879
|
+
* List a directory. Results are `pubky://<pk><path>` entries.
|
|
1798
1880
|
*
|
|
1799
1881
|
* @param {Address} address Addressed directory (must end with `/`).
|
|
1800
|
-
* @param {string|null=} cursor Optional suffix or
|
|
1882
|
+
* @param {string|null=} cursor Optional suffix or entry (as returned) to start **after**.
|
|
1801
1883
|
* @param {boolean=} reverse Default `false`. When `true`, newest/lexicographically-last first.
|
|
1802
1884
|
* @param {number=} limit Optional result limit.
|
|
1803
1885
|
* @param {boolean=} shallow Default `false`. When `true`, lists only first-level entries.
|
|
@@ -2034,11 +2116,11 @@ export class SessionStorage {
|
|
|
2034
2116
|
* List a directory (absolute session path).
|
|
2035
2117
|
*
|
|
2036
2118
|
* @param {Path} path Must end with `/`.
|
|
2037
|
-
* @param {string|null=} cursor Optional last entry
|
|
2119
|
+
* @param {string|null=} cursor Optional last entry (as returned) to start **after**.
|
|
2038
2120
|
* @param {boolean=} reverse Default `false`.
|
|
2039
2121
|
* @param {number=} limit Optional result limit.
|
|
2040
2122
|
* @param {boolean=} shallow Default `false`.
|
|
2041
|
-
* @returns {Promise<string[]>} `pubky
|
|
2123
|
+
* @returns {Promise<string[]>} `pubky://<pk><path>` entries, or an empty array for an empty page.
|
|
2042
2124
|
* @throws {PubkyError} Missing directory (404), invalid cursor (400), invalid response
|
|
2043
2125
|
* entries, or shared errors (see {@link SessionStorage}).
|
|
2044
2126
|
*/
|
|
@@ -2374,6 +2456,13 @@ export class SigninGrantDeepLink {
|
|
|
2374
2456
|
* @returns {Uint8Array|undefined}
|
|
2375
2457
|
*/
|
|
2376
2458
|
readonly ephemeralPublicKey: Uint8Array | undefined;
|
|
2459
|
+
/**
|
|
2460
|
+
* Expected identity (`spk`): the public key that must approve this
|
|
2461
|
+
* request, or `undefined`. Signers approve with this key or refuse.
|
|
2462
|
+
*
|
|
2463
|
+
* @returns {PublicKey|undefined}
|
|
2464
|
+
*/
|
|
2465
|
+
readonly expectedSigner: PublicKey | undefined;
|
|
2377
2466
|
/**
|
|
2378
2467
|
* Shared relay secret, or `undefined` for an HPKE link.
|
|
2379
2468
|
* Keep this secret confidential until the flow completes or is abandoned.
|
package/pubky_bg.wasm
CHANGED
|
Binary file
|