@book.dev/sdk 1.76.2 → 2.1.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/dist/ai.d.ts +108 -4
- package/dist/authorize.js +18 -7
- package/dist/authorize.js.map +1 -1
- package/dist/backup.d.ts +1 -1
- package/dist/bookFolder.d.ts +38 -21
- package/dist/bookFolder.js +42 -18
- package/dist/bookFolder.js.map +1 -1
- package/dist/bookfile.d.ts +1 -1
- package/dist/client.d.ts +53 -5
- package/dist/client.js +35 -5
- package/dist/client.js.map +1 -1
- package/dist/database.d.ts +9 -3
- package/dist/database.js +23 -7
- package/dist/database.js.map +1 -1
- package/dist/forwarding/forwardingClient.d.ts +38 -0
- package/dist/forwarding/forwardingClient.js +57 -4
- package/dist/forwarding/forwardingClient.js.map +1 -1
- package/dist/forwarding/index.d.ts +2 -2
- package/dist/forwarding/index.js +2 -2
- package/dist/forwarding/index.js.map +1 -1
- package/dist/forwarding/rosterAssertion.d.ts +61 -12
- package/dist/forwarding/rosterAssertion.js +77 -26
- package/dist/forwarding/rosterAssertion.js.map +1 -1
- package/dist/identity.d.ts +44 -1
- package/dist/identity.js.map +1 -1
- package/dist/import.d.ts +3 -3
- package/dist/import.js +3 -3
- package/dist/import.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/provenance.d.ts +38 -27
- package/dist/provenance.js.map +1 -1
- package/dist/routes.d.ts +34 -3
- package/dist/routes.js +36 -4
- package/dist/routes.js.map +1 -1
- package/dist/templates.d.ts +22 -6
- package/dist/templates.js +461 -14
- package/dist/templates.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,13 @@ import { globalFetch } from '../client';
|
|
|
13
13
|
import { buildAttachMessage, buildReattachMessage } from './challenge';
|
|
14
14
|
import { signWithSiteKey } from './siteKey';
|
|
15
15
|
import { TunnelClient } from './tunnelClient';
|
|
16
|
+
/** Every {@link SiteVisibility}, matching the account's `SITE_VISIBILITIES`. */
|
|
17
|
+
export const SITE_VISIBILITIES = [
|
|
18
|
+
'public',
|
|
19
|
+
'authenticated',
|
|
20
|
+
'members',
|
|
21
|
+
'restricted',
|
|
22
|
+
];
|
|
16
23
|
export class MemoryKeyStore {
|
|
17
24
|
constructor() {
|
|
18
25
|
this.identity = null;
|
|
@@ -53,11 +60,16 @@ export class ForwardingClient {
|
|
|
53
60
|
get region() {
|
|
54
61
|
return this.opts.region ?? 'sin1';
|
|
55
62
|
}
|
|
56
|
-
|
|
63
|
+
/**
|
|
64
|
+
* One authorized account-API round-trip. Threads the device bearer token, folds
|
|
65
|
+
* the server's `{error}` JSON into a {@link ForwardingApiError} on non-OK, and is
|
|
66
|
+
* method-agnostic so the site-visibility GET/PATCH share the same error surface as
|
|
67
|
+
* the POST provisioning flow (the {@link api} shorthand keeps the POST callers terse).
|
|
68
|
+
*/
|
|
69
|
+
async request(path, init) {
|
|
57
70
|
const res = await this.fetchImpl(`${this.opts.accountUrl.replace(/\/$/, '')}${path}`, {
|
|
58
|
-
|
|
59
|
-
headers: { authorization: `Bearer ${this.opts.authToken}`,
|
|
60
|
-
body: JSON.stringify(body),
|
|
71
|
+
...init,
|
|
72
|
+
headers: { authorization: `Bearer ${this.opts.authToken}`, ...init.headers },
|
|
61
73
|
});
|
|
62
74
|
if (!res.ok) {
|
|
63
75
|
let detail;
|
|
@@ -73,6 +85,47 @@ export class ForwardingClient {
|
|
|
73
85
|
}
|
|
74
86
|
return (await res.json());
|
|
75
87
|
}
|
|
88
|
+
api(path, body) {
|
|
89
|
+
return this.request(path, {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
headers: { 'content-type': 'application/json' },
|
|
92
|
+
body: JSON.stringify(body),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** Resolve the registered site id without provisioning: the in-memory identity if
|
|
96
|
+
* the tunnel is up, else the persisted key's — throwing if no site exists yet
|
|
97
|
+
* (visibility is only meaningful for a site that's been registered). */
|
|
98
|
+
async requireSiteId() {
|
|
99
|
+
const id = this.identity ?? (await this.opts.keyStore.load());
|
|
100
|
+
if (!id)
|
|
101
|
+
throw new Error('no site registered — enable publishing first');
|
|
102
|
+
return id.siteId;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Read the published site's current audience scope from the account
|
|
106
|
+
* (`GET /api/sites/:id`). The account is the source of truth — the desktop UI
|
|
107
|
+
* reflects THIS, never a locally-assumed default, so it can honestly tell the
|
|
108
|
+
* owner whether their address is Public or Private.
|
|
109
|
+
*/
|
|
110
|
+
async getSiteVisibility() {
|
|
111
|
+
const siteId = await this.requireSiteId();
|
|
112
|
+
const data = await this.request(`/api/sites/${encodeURIComponent(siteId)}`, { method: 'GET' });
|
|
113
|
+
if (!data.site)
|
|
114
|
+
throw new ForwardingApiError(`/api/sites/${siteId}`, 404, 'site not found');
|
|
115
|
+
return data.site.visibility;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set the published site's audience scope via the EXISTING free-tier route
|
|
119
|
+
* (`PATCH /api/sites/:id`, body `{visibility}`). The account whitelist-validates
|
|
120
|
+
* the value and enforces owner-only server-side (a non-owner 404s); this client
|
|
121
|
+
* only ever runs on the owner's device under their device bearer token. Returns
|
|
122
|
+
* the persisted scope so the caller reflects the server's truth, not the request.
|
|
123
|
+
*/
|
|
124
|
+
async setSiteVisibility(visibility) {
|
|
125
|
+
const siteId = await this.requireSiteId();
|
|
126
|
+
const data = await this.request(`/api/sites/${encodeURIComponent(siteId)}`, { method: 'PATCH', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ visibility }) });
|
|
127
|
+
return data.site.visibility;
|
|
128
|
+
}
|
|
76
129
|
/** Reattach to our existing site (if we hold its key), else provision a new one. */
|
|
77
130
|
async ensureSite() {
|
|
78
131
|
if (this.identity)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forwardingClient.js","sourceRoot":"","sources":["../../src/forwarding/forwardingClient.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mFAAmF;AACnF,+EAA+E;AAC/E,EAAE;AACF,QAAQ;AACR,oFAAoF;AACpF,8EAA8E;AAC9E,2EAA2E;AAC3E,EAAE;AACF,iFAAiF;AACjF,wCAAwC;AAExC,OAAO,EAAC,WAAW,EAAiB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAoB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"forwardingClient.js","sourceRoot":"","sources":["../../src/forwarding/forwardingClient.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mFAAmF;AACnF,+EAA+E;AAC/E,EAAE;AACF,QAAQ;AACR,oFAAoF;AACpF,8EAA8E;AAC9E,2EAA2E;AAC3E,EAAE;AACF,iFAAiF;AACjF,wCAAwC;AAExC,OAAO,EAAC,WAAW,EAAiB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAsB/D,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAA8B;IAC1D,QAAQ;IACR,eAAe;IACf,SAAS;IACT,YAAY;CACb,CAAC;AAUF,MAAM,OAAO,cAAc;IAA3B;QACU,aAAQ,GAAwB,IAAI,CAAC;IAU/C,CAAC;IATC,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,QAAsB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,KAAK;QACT,IAAI,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ForwardingClientOptions } from './forwardingClient';
|
|
1
|
+
export { ForwardingApiError, ForwardingClient, MemoryKeyStore, SITE_VISIBILITIES, type KeyStore, type SiteIdentity, type SiteVisibility, type ForwardingClientOptions, } from './forwardingClient';
|
|
2
2
|
export { TunnelClient, type TunnelStatus, type TunnelClientOptions } from './tunnelClient';
|
|
3
3
|
export { mintSiteKeypair, signWithSiteKey, verifyWithSiteKey, type SiteKeypair } from './siteKey';
|
|
4
|
-
export { signRosterAssertion, verifyRosterAssertion, ROSTER_ASSERTION_VERSION, ROSTER_ASSERTION_SKEW_MS, type RosterAssertionPayload, type SignRosterAssertionInput, type VerifyRosterAssertionInput, } from './rosterAssertion';
|
|
4
|
+
export { signRosterAssertion, verifyRosterAssertion, isAcceptedRosterVersion, ROSTER_ASSERTION_VERSION, ROSTER_ASSERTION_V2, ACCEPTED_ROSTER_VERSIONS, ROSTER_ASSERTION_SKEW_MS, type RosterAssertionVersion, type RosterAssertionPayload, type RosterAssertionV1Payload, type RosterAssertionV2Payload, type SignRosterAssertionInput, type VerifyRosterAssertionInput, type VerifiedRosterAssertion, } from './rosterAssertion';
|
|
5
5
|
export { buildAttachMessage, buildReattachMessage, buildRelayAttachMessage, newNonce, isFreshTimestamp, type AttachClaim, } from './challenge';
|
|
6
6
|
export { encodeControl, decodeControl, encodeBody, decodeBody, FORWARDED_HEADER, type ControlFrame, } from './tunnelProtocol';
|
package/dist/forwarding/index.js
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
// whole surface is runtime-agnostic (Web Crypto + global fetch/WebSocket), so it
|
|
7
7
|
// runs in the Tauri webview; the desktop supplies a keychain-backed KeyStore and
|
|
8
8
|
// the IPC fetch.
|
|
9
|
-
export { ForwardingApiError, ForwardingClient, MemoryKeyStore } from './forwardingClient';
|
|
9
|
+
export { ForwardingApiError, ForwardingClient, MemoryKeyStore, SITE_VISIBILITIES, } from './forwardingClient';
|
|
10
10
|
export { TunnelClient } from './tunnelClient';
|
|
11
11
|
export { mintSiteKeypair, signWithSiteKey, verifyWithSiteKey } from './siteKey';
|
|
12
|
-
export { signRosterAssertion, verifyRosterAssertion, ROSTER_ASSERTION_VERSION, ROSTER_ASSERTION_SKEW_MS, } from './rosterAssertion';
|
|
12
|
+
export { signRosterAssertion, verifyRosterAssertion, isAcceptedRosterVersion, ROSTER_ASSERTION_VERSION, ROSTER_ASSERTION_V2, ACCEPTED_ROSTER_VERSIONS, ROSTER_ASSERTION_SKEW_MS, } from './rosterAssertion';
|
|
13
13
|
export { buildAttachMessage, buildReattachMessage, buildRelayAttachMessage, newNonce, isFreshTimestamp, } from './challenge';
|
|
14
14
|
export { encodeControl, decodeControl, encodeBody, decodeBody, FORWARDED_HEADER, } from './tunnelProtocol';
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/forwarding/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,gFAAgF;AAChF,iFAAiF;AACjF,iFAAiF;AACjF,iBAAiB;AAEjB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/forwarding/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,gFAAgF;AAChF,iFAAiF;AACjF,iFAAiF;AACjF,iBAAiB;AAEjB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,GAKlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,YAAY,EAA8C,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAC,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAmB,MAAM,WAAW,CAAC;AAChG,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,GAQzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACR,gBAAgB,GAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,UAAU,EACV,gBAAgB,GAEjB,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,31 +1,59 @@
|
|
|
1
|
-
/** The assertion
|
|
1
|
+
/** The legacy assertion version tag (v1) — carries `workspaceId`. Still ACCEPTED. */
|
|
2
2
|
export declare const ROSTER_ASSERTION_VERSION = "openbook.roster.v1";
|
|
3
|
+
/** The current assertion version tag (v2, LIB-5) — carries `libraryId`. What the signer emits. */
|
|
4
|
+
export declare const ROSTER_ASSERTION_V2 = "openbook.roster.v2";
|
|
5
|
+
/**
|
|
6
|
+
* Every version tag the verifier accepts (dual-accept v1 + v2). Pinned BEFORE any
|
|
7
|
+
* crypto runs — an unknown / absent `v` is rejected without a signature check, so
|
|
8
|
+
* there is no downgrade oracle. Retiring v1 is a later, reversible step (drop it
|
|
9
|
+
* from this set) — never do it while any un-updatable desktop build still signs v1.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ACCEPTED_ROSTER_VERSIONS: readonly ["openbook.roster.v1", "openbook.roster.v2"];
|
|
12
|
+
/** An accepted roster-assertion version tag. */
|
|
13
|
+
export type RosterAssertionVersion = (typeof ACCEPTED_ROSTER_VERSIONS)[number];
|
|
14
|
+
/** Narrow an arbitrary string to an accepted version tag (pinned before crypto). */
|
|
15
|
+
export declare function isAcceptedRosterVersion(v: unknown): v is RosterAssertionVersion;
|
|
3
16
|
/** Default freshness window for a roster assertion (±5 min — the account's window). */
|
|
4
17
|
export declare const ROSTER_ASSERTION_SKEW_MS: number;
|
|
5
|
-
|
|
18
|
+
/** The legacy (v1) assertion payload — carries `workspaceId`. Still verifiable. */
|
|
19
|
+
export interface RosterAssertionV1Payload {
|
|
6
20
|
/** Fixed protocol tag, {@link ROSTER_ASSERTION_VERSION}. */
|
|
7
21
|
v: typeof ROSTER_ASSERTION_VERSION;
|
|
8
22
|
/** The site's registered public key (raw 32-byte Ed25519, base64url). */
|
|
9
23
|
pub: string;
|
|
10
|
-
/** The
|
|
24
|
+
/** The library the site is asserting it is bound to (legacy key name). */
|
|
11
25
|
workspaceId: string;
|
|
12
26
|
/** Epoch millis the site stamped when signing (freshness). */
|
|
13
27
|
ts: number;
|
|
14
28
|
}
|
|
29
|
+
/** The current (v2, LIB-5) assertion payload — carries `libraryId`. What the signer emits. */
|
|
30
|
+
export interface RosterAssertionV2Payload {
|
|
31
|
+
/** Fixed protocol tag, {@link ROSTER_ASSERTION_V2}. */
|
|
32
|
+
v: typeof ROSTER_ASSERTION_V2;
|
|
33
|
+
/** The site's registered public key (raw 32-byte Ed25519, base64url). */
|
|
34
|
+
pub: string;
|
|
35
|
+
/** The library the site is asserting it is bound to (renamed from `workspaceId`; SAME id value). */
|
|
36
|
+
libraryId: string;
|
|
37
|
+
/** Epoch millis the site stamped when signing (freshness). */
|
|
38
|
+
ts: number;
|
|
39
|
+
}
|
|
40
|
+
/** Any accepted roster-assertion payload (v1 or v2). */
|
|
41
|
+
export type RosterAssertionPayload = RosterAssertionV1Payload | RosterAssertionV2Payload;
|
|
15
42
|
export interface SignRosterAssertionInput {
|
|
16
43
|
/** base64url PKCS#8 site private key — from the OS keychain. NEVER the data-server. */
|
|
17
44
|
privateKey: string;
|
|
18
45
|
/** The site's registered public key (raw base64url) — the verifiable half. */
|
|
19
46
|
publicKey: string;
|
|
20
|
-
/** The bound
|
|
21
|
-
|
|
47
|
+
/** The bound library id (renamed from `workspaceId`; SAME id value). */
|
|
48
|
+
libraryId: string;
|
|
22
49
|
/** Clock injection (tests). Defaults to {@link Date.now}. */
|
|
23
50
|
now?: () => number;
|
|
24
51
|
}
|
|
25
52
|
/**
|
|
26
53
|
* Mint a fresh signed roster assertion bearer for `Authorization: Bearer <…>`.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
54
|
+
* Emits `openbook.roster.v2` (`libraryId`). Returns
|
|
55
|
+
* `base64url(payloadJson) + '.' + base64url(ed25519Sig)`. Stamps `ts` at call time,
|
|
56
|
+
* so mint one PER fetch (the account's freshness window is ±5 min).
|
|
29
57
|
*/
|
|
30
58
|
export declare function signRosterAssertion(input: SignRosterAssertionInput): Promise<string>;
|
|
31
59
|
export interface VerifyRosterAssertionInput {
|
|
@@ -33,17 +61,38 @@ export interface VerifyRosterAssertionInput {
|
|
|
33
61
|
assertion: string;
|
|
34
62
|
/** The site's registered public key (raw base64url) to verify against. */
|
|
35
63
|
publicKey: string;
|
|
36
|
-
/** The
|
|
37
|
-
|
|
64
|
+
/** The library the assertion must claim (renamed from `workspaceId`; SAME id value). */
|
|
65
|
+
libraryId: string;
|
|
38
66
|
/** Clock for the freshness check (ms). Defaults to {@link Date.now}. */
|
|
39
67
|
now?: number;
|
|
40
68
|
/** Freshness window (ms). Defaults to {@link ROSTER_ASSERTION_SKEW_MS}. */
|
|
41
69
|
skewMs?: number;
|
|
42
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A verified roster assertion, version-normalized. `libraryId` is the audience read
|
|
73
|
+
* from whichever key the AUTHENTICATED version carries (v1 `workspaceId`, v2
|
|
74
|
+
* `libraryId`) — callers always read `libraryId` regardless of the on-wire version.
|
|
75
|
+
*/
|
|
76
|
+
export interface VerifiedRosterAssertion {
|
|
77
|
+
/** The authenticated version tag that verified. */
|
|
78
|
+
v: RosterAssertionVersion;
|
|
79
|
+
/** The site's public key the signature verified against. */
|
|
80
|
+
pub: string;
|
|
81
|
+
/** The bound library id (normalized name, whatever the on-wire key). */
|
|
82
|
+
libraryId: string;
|
|
83
|
+
/** The signer's stamped epoch-millis timestamp. */
|
|
84
|
+
ts: number;
|
|
85
|
+
}
|
|
43
86
|
/**
|
|
44
87
|
* Verify a roster assertion (the account side, mirrored here for one canonical
|
|
45
|
-
* impl + end-to-end tests).
|
|
46
|
-
* ANY failure — bad framing,
|
|
88
|
+
* impl + end-to-end tests). DUAL-ACCEPTS v1 + v2. Returns the version-normalized
|
|
89
|
+
* result on success, or `null` on ANY failure — bad framing, unknown/absent
|
|
90
|
+
* version, missing/mistyped field, wrong library/pub, a stale/future `ts`, or a bad
|
|
47
91
|
* signature. Never throws (so it can sit directly in an auth gate).
|
|
92
|
+
*
|
|
93
|
+
* Fail-closed order (all BEFORE trusting anything): frame → decode → pin the
|
|
94
|
+
* version from the authenticated body → select the audience field by the
|
|
95
|
+
* per-version map → require a non-empty audience that matches → freshness →
|
|
96
|
+
* Ed25519 verify over the prefix reconstructed from the authenticated version.
|
|
48
97
|
*/
|
|
49
|
-
export declare function verifyRosterAssertion(input: VerifyRosterAssertionInput): Promise<
|
|
98
|
+
export declare function verifyRosterAssertion(input: VerifyRosterAssertionInput): Promise<VerifiedRosterAssertion | null>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// Per-instance roster assertion (OB-199 — "bind instance ↔
|
|
1
|
+
// Per-instance roster assertion (OB-199 — "bind instance ↔ library").
|
|
2
2
|
//
|
|
3
|
-
// When a managed instance pulls its bound
|
|
4
|
-
// (`GET /api/
|
|
3
|
+
// When a managed instance pulls its bound library's roster from the account
|
|
4
|
+
// (`GET /api/libraries/:id/roster`), it must prove it is the SITE that owns the
|
|
5
5
|
// binding — not an end user. It does so by signing a short-lived assertion with
|
|
6
6
|
// the site's device private key (the same key that double-gates the forwarding
|
|
7
7
|
// tunnel attach). The account verifies the signature against the Site row's
|
|
8
|
-
// registered public key and that the site is bound to the
|
|
8
|
+
// registered public key and that the site is bound to the library.
|
|
9
9
|
//
|
|
10
10
|
// The signing half runs ONLY where the private key lives — the desktop's OS
|
|
11
11
|
// keychain — so the raw key never enters the (separate) data-server process. The
|
|
@@ -13,44 +13,85 @@
|
|
|
13
13
|
// account can adopt one canonical implementation and so the contract is testable
|
|
14
14
|
// end-to-end (sign → verify) without the account repo.
|
|
15
15
|
//
|
|
16
|
+
// LIB-5 — the wire field renamed from `workspaceId` → `libraryId`. Because the
|
|
17
|
+
// field name lives INSIDE the signed bytes, the rename is versioned: the signer
|
|
18
|
+
// emits `openbook.roster.v2` (carrying `libraryId`) while the verifier
|
|
19
|
+
// DUAL-ACCEPTS v1 (`workspaceId`) + v2 (`libraryId`), fail-closed. The version is
|
|
20
|
+
// authenticated (it is part of the signed payload AND the signed-message prefix),
|
|
21
|
+
// so an attacker can never flip v1↔v2 without breaking the signature, and the
|
|
22
|
+
// verifier never trusts an out-of-band version. See the LIB-5 design + runbook.
|
|
23
|
+
//
|
|
16
24
|
// Runtime-agnostic (Web Crypto via {@link signWithSiteKey}/{@link verifyWithSiteKey}).
|
|
17
25
|
import { b64uDecodeString, b64uEncodeString } from './encoding';
|
|
18
26
|
import { signWithSiteKey, verifyWithSiteKey } from './siteKey';
|
|
19
|
-
/** The assertion
|
|
27
|
+
/** The legacy assertion version tag (v1) — carries `workspaceId`. Still ACCEPTED. */
|
|
20
28
|
export const ROSTER_ASSERTION_VERSION = 'openbook.roster.v1';
|
|
29
|
+
/** The current assertion version tag (v2, LIB-5) — carries `libraryId`. What the signer emits. */
|
|
30
|
+
export const ROSTER_ASSERTION_V2 = 'openbook.roster.v2';
|
|
31
|
+
/**
|
|
32
|
+
* Every version tag the verifier accepts (dual-accept v1 + v2). Pinned BEFORE any
|
|
33
|
+
* crypto runs — an unknown / absent `v` is rejected without a signature check, so
|
|
34
|
+
* there is no downgrade oracle. Retiring v1 is a later, reversible step (drop it
|
|
35
|
+
* from this set) — never do it while any un-updatable desktop build still signs v1.
|
|
36
|
+
*/
|
|
37
|
+
export const ACCEPTED_ROSTER_VERSIONS = [ROSTER_ASSERTION_VERSION, ROSTER_ASSERTION_V2];
|
|
38
|
+
/**
|
|
39
|
+
* Which JSON key carries the audience (the bound library id) PER version. v1 signed
|
|
40
|
+
* `workspaceId`; v2 renames the KEY to `libraryId` (the id VALUE — a cuid — is
|
|
41
|
+
* UNCHANGED). The verifier selects this field strictly from the AUTHENTICATED `v`
|
|
42
|
+
* via THIS explicit map — never a binary ternary that defaults to v1 — so a v1 body
|
|
43
|
+
* can't be re-read as v2 (or vice-versa): each version reads only its own key, and
|
|
44
|
+
* a body carrying the wrong key resolves to `undefined` → reject.
|
|
45
|
+
*/
|
|
46
|
+
const AUDIENCE_KEY_BY_VERSION = {
|
|
47
|
+
[ROSTER_ASSERTION_VERSION]: 'workspaceId',
|
|
48
|
+
[ROSTER_ASSERTION_V2]: 'libraryId',
|
|
49
|
+
};
|
|
50
|
+
/** Narrow an arbitrary string to an accepted version tag (pinned before crypto). */
|
|
51
|
+
export function isAcceptedRosterVersion(v) {
|
|
52
|
+
return v === ROSTER_ASSERTION_VERSION || v === ROSTER_ASSERTION_V2;
|
|
53
|
+
}
|
|
21
54
|
/** Default freshness window for a roster assertion (±5 min — the account's window). */
|
|
22
55
|
export const ROSTER_ASSERTION_SKEW_MS = 5 * 60 * 1000;
|
|
23
56
|
/**
|
|
24
|
-
* The exact bytes signed/verified:
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
57
|
+
* The exact bytes signed/verified: `<version>.<base64url(payloadJson)>`. The version
|
|
58
|
+
* prefix is derived from the payload's OWN `v` tag (never hardcoded), so the signed
|
|
59
|
+
* message and the authenticated version can never disagree. The base64url payload
|
|
60
|
+
* carries no `.`, so it never collides with the version prefix's dots when the
|
|
61
|
+
* account reconstructs the message from the assertion's first half.
|
|
28
62
|
*/
|
|
29
|
-
function rosterAssertionMessage(payloadB64) {
|
|
30
|
-
return `${
|
|
63
|
+
function rosterAssertionMessage(version, payloadB64) {
|
|
64
|
+
return `${version}.${payloadB64}`;
|
|
31
65
|
}
|
|
32
66
|
/**
|
|
33
67
|
* Mint a fresh signed roster assertion bearer for `Authorization: Bearer <…>`.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
68
|
+
* Emits `openbook.roster.v2` (`libraryId`). Returns
|
|
69
|
+
* `base64url(payloadJson) + '.' + base64url(ed25519Sig)`. Stamps `ts` at call time,
|
|
70
|
+
* so mint one PER fetch (the account's freshness window is ±5 min).
|
|
36
71
|
*/
|
|
37
72
|
export async function signRosterAssertion(input) {
|
|
38
73
|
const ts = input.now ? input.now() : Date.now();
|
|
39
74
|
const payload = {
|
|
40
|
-
v:
|
|
75
|
+
v: ROSTER_ASSERTION_V2,
|
|
41
76
|
pub: input.publicKey,
|
|
42
|
-
|
|
77
|
+
libraryId: input.libraryId,
|
|
43
78
|
ts,
|
|
44
79
|
};
|
|
45
80
|
const payloadB64 = b64uEncodeString(JSON.stringify(payload));
|
|
46
|
-
const signature = await signWithSiteKey(input.privateKey, rosterAssertionMessage(payloadB64));
|
|
81
|
+
const signature = await signWithSiteKey(input.privateKey, rosterAssertionMessage(ROSTER_ASSERTION_V2, payloadB64));
|
|
47
82
|
return `${payloadB64}.${signature}`;
|
|
48
83
|
}
|
|
49
84
|
/**
|
|
50
85
|
* Verify a roster assertion (the account side, mirrored here for one canonical
|
|
51
|
-
* impl + end-to-end tests).
|
|
52
|
-
* ANY failure — bad framing,
|
|
86
|
+
* impl + end-to-end tests). DUAL-ACCEPTS v1 + v2. Returns the version-normalized
|
|
87
|
+
* result on success, or `null` on ANY failure — bad framing, unknown/absent
|
|
88
|
+
* version, missing/mistyped field, wrong library/pub, a stale/future `ts`, or a bad
|
|
53
89
|
* signature. Never throws (so it can sit directly in an auth gate).
|
|
90
|
+
*
|
|
91
|
+
* Fail-closed order (all BEFORE trusting anything): frame → decode → pin the
|
|
92
|
+
* version from the authenticated body → select the audience field by the
|
|
93
|
+
* per-version map → require a non-empty audience that matches → freshness →
|
|
94
|
+
* Ed25519 verify over the prefix reconstructed from the authenticated version.
|
|
54
95
|
*/
|
|
55
96
|
export async function verifyRosterAssertion(input) {
|
|
56
97
|
try {
|
|
@@ -59,28 +100,38 @@ export async function verifyRosterAssertion(input) {
|
|
|
59
100
|
return null;
|
|
60
101
|
const payloadB64 = input.assertion.slice(0, dot);
|
|
61
102
|
const signature = input.assertion.slice(dot + 1);
|
|
62
|
-
if (signature.includes('.'))
|
|
63
|
-
return null; // exactly two base64url parts
|
|
103
|
+
if (!signature || signature.includes('.'))
|
|
104
|
+
return null; // exactly two non-empty base64url parts
|
|
64
105
|
const parsed = JSON.parse(b64uDecodeString(payloadB64));
|
|
65
106
|
if (typeof parsed !== 'object' || parsed === null)
|
|
66
107
|
return null;
|
|
67
108
|
const payload = parsed;
|
|
68
|
-
|
|
109
|
+
// (1) Pin the version from the AUTHENTICATED, decoded body BEFORE any crypto.
|
|
110
|
+
// Unknown / absent → reject with no signature check (no downgrade oracle).
|
|
111
|
+
const version = payload.v;
|
|
112
|
+
if (!isAcceptedRosterVersion(version))
|
|
69
113
|
return null;
|
|
114
|
+
// (2/3) Select the audience field by an EXPLICIT per-version map — never a
|
|
115
|
+
// binary ternary defaulting to v1. A v1 body carrying `libraryId` reads its
|
|
116
|
+
// (absent) `workspaceId` key → undefined → reject; a v2 body reads `libraryId`.
|
|
117
|
+
const aud = payload[AUDIENCE_KEY_BY_VERSION[version]];
|
|
70
118
|
if (typeof payload.pub !== 'string' || payload.pub !== input.publicKey)
|
|
71
119
|
return null;
|
|
72
|
-
if (typeof
|
|
73
|
-
return null;
|
|
120
|
+
if (typeof aud !== 'string' || !aud)
|
|
121
|
+
return null; // (4) non-empty audience required
|
|
122
|
+
if (aud !== input.libraryId)
|
|
123
|
+
return null; // audience bind — id VALUE unchanged
|
|
74
124
|
if (typeof payload.ts !== 'number' || !Number.isFinite(payload.ts))
|
|
75
125
|
return null;
|
|
76
126
|
const now = input.now ?? Date.now();
|
|
77
127
|
const skewMs = input.skewMs ?? ROSTER_ASSERTION_SKEW_MS;
|
|
78
128
|
if (Math.abs(now - payload.ts) > skewMs)
|
|
79
|
-
return null;
|
|
80
|
-
|
|
129
|
+
return null; // symmetric — rejects stale AND future
|
|
130
|
+
// Reconstruct the signed prefix from the AUTHENTICATED version, never a constant.
|
|
131
|
+
const ok = await verifyWithSiteKey(input.publicKey, rosterAssertionMessage(version, payloadB64), signature);
|
|
81
132
|
if (!ok)
|
|
82
133
|
return null;
|
|
83
|
-
return { v:
|
|
134
|
+
return { v: version, pub: payload.pub, libraryId: aud, ts: payload.ts };
|
|
84
135
|
}
|
|
85
136
|
catch {
|
|
86
137
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rosterAssertion.js","sourceRoot":"","sources":["../../src/forwarding/rosterAssertion.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"rosterAssertion.js","sourceRoot":"","sources":["../../src/forwarding/rosterAssertion.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,mEAAmE;AACnE,EAAE;AACF,4EAA4E;AAC5E,iFAAiF;AACjF,kFAAkF;AAClF,iFAAiF;AACjF,uDAAuD;AACvD,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,uEAAuE;AACvE,kFAAkF;AAClF,kFAAkF;AAClF,8EAA8E;AAC9E,gFAAgF;AAChF,EAAE;AACF,uFAAuF;AAEvF,OAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAE,iBAAiB,EAAC,MAAM,WAAW,CAAC;AAE7D,qFAAqF;AACrF,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAE7D,kGAAkG;AAClG,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,wBAAwB,EAAE,mBAAmB,CAAU,CAAC;AAKjG;;;;;;;GAOG;AACH,MAAM,uBAAuB,GAAgE;IAC3F,CAAC,wBAAwB,CAAC,EAAE,aAAa;IACzC,CAAC,mBAAmB,CAAC,EAAE,WAAW;CACnC,CAAC;AAEF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G,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,wBAAwB,CAAC;QACxD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM;YAAE,OAAO,IAAI,CAAC,CAAC,uCAAuC;QAE7F,kFAAkF;QAClF,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC;QAC5G,IAAI,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QACrB,OAAO,EAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/identity.d.ts
CHANGED
|
@@ -27,8 +27,51 @@ export type VerifiedVia =
|
|
|
27
27
|
| 'synced'
|
|
28
28
|
/** In-process caller (the embedded `LocalDataClient`) — implicitly the local
|
|
29
29
|
* owner; there is no request to carry a credential. */
|
|
30
|
-
| 'local'
|
|
30
|
+
| 'local'
|
|
31
|
+
/**
|
|
32
|
+
* An **agent Personal-Access-Token** (AGENT-6): a `Bearer obat_…` credential an
|
|
33
|
+
* instance admin minted, bound at mint time to the MINTER's own verified subject
|
|
34
|
+
* (never client-chosen). It rides the SUBJECT-keyed authorize rungs its bound user
|
|
35
|
+
* would — owner-content, subject-ACL, authenticated-read — but is deliberately
|
|
36
|
+
* NOT a roster member (no `admin`/`viewer` rung, see `resolveMemberRole`), carries
|
|
37
|
+
* no persona email (never matches an email-ACL), and can never mint verified block
|
|
38
|
+
* authorship (`verifiedSubject` stays jws-only). Its HTTP surface is further
|
|
39
|
+
* confined by a default-deny scope-gate. */
|
|
40
|
+
| 'pat';
|
|
31
41
|
export type PrincipalKind = 'user' | 'guest';
|
|
42
|
+
/** What a minted agent token may do over the API (AGENT-6). `read` is confined to
|
|
43
|
+
* the read scope-gate allowlist; `write` additionally admits the unsafe methods on
|
|
44
|
+
* content routes. Never grants any privileged/admin route (default-deny). */
|
|
45
|
+
export type AgentTokenScope = 'read' | 'write';
|
|
46
|
+
/**
|
|
47
|
+
* The **redacted** view of a minted agent token (AGENT-6), safe to return from the
|
|
48
|
+
* management API and render in settings. NEVER carries the secret itself — only an
|
|
49
|
+
* `obat_…` preview prefix; the plaintext is shown exactly once, in the create
|
|
50
|
+
* response, and only its SHA-256 hash is stored at rest.
|
|
51
|
+
*/
|
|
52
|
+
export interface AgentTokenMeta {
|
|
53
|
+
id: string;
|
|
54
|
+
/** Human label the minter gave the token. */
|
|
55
|
+
name: string;
|
|
56
|
+
scope: AgentTokenScope;
|
|
57
|
+
/** The verified subject the token is bound to (the minter's own subject, or
|
|
58
|
+
* `local:owner` for a hatch/local-owner minter). */
|
|
59
|
+
subject: string;
|
|
60
|
+
/** The issuer that vouched for {@link subject} (empty / `local` for the hatch). */
|
|
61
|
+
issuer: string;
|
|
62
|
+
/** Who minted it (a display label). */
|
|
63
|
+
createdBy: string;
|
|
64
|
+
/** ISO timestamps. */
|
|
65
|
+
createdAt: string;
|
|
66
|
+
/** ISO expiry, or `null` for a no-expiry token. */
|
|
67
|
+
expiresAt: string | null;
|
|
68
|
+
/** ISO last-used, or `null` if never presented. */
|
|
69
|
+
lastUsedAt: string | null;
|
|
70
|
+
/** A short, non-secret prefix of the token (`obat_xxxx…`) for recognition. */
|
|
71
|
+
preview: string;
|
|
72
|
+
/** True once revoked (kept listed briefly for provenance; never resolves). */
|
|
73
|
+
revoked: boolean;
|
|
74
|
+
}
|
|
32
75
|
/** The actor behind a request, resolved by the server and stamped onto changes. */
|
|
33
76
|
export interface Principal {
|
|
34
77
|
kind: PrincipalKind;
|
package/dist/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAEvG,MAAM,OAAO,GAAG,EAAC,IAAI,EAAE,SAAS,EAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAEvG,MAAM,OAAO,GAAG,EAAC,IAAI,EAAE,SAAS,EAAU,CAAC;AAwF3C,uDAAuD;AACvD,MAAM,UAAU,cAAc,CAAC,IAAI,GAAG,EAAE;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1B,OAAO;QACL,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,iBAAiB;QACrD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,OAAO;KACrB,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,cAAc,CAAC,IAAI,GAAG,OAAO;IAC3C,OAAO,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAC,CAAC;AAC7F,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAErD,iFAAiF;AACjF,MAAM,UAAU,WAAW,CA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EAAE,EAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAC;KAC/C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAAC,MAAsB;IAClE,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE;QACtC,MAAM,EAAE,MAAM,CAAC,GAAG;QAClB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;QACvB,4EAA4E;QAC5E,+EAA+E;QAC/E,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzB,WAAW,EAAE,YAAY;QACzB,SAAS,EAAE,EAAC,GAAG,EAAE,MAAM,CAAC,GAAG,EAAC;KAC7B,CAAC;AACJ,CAAC"}
|
package/dist/import.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* - **Strategy B — {@link writeViaBundle}** maps the whole IR into a backup
|
|
16
16
|
* bundle (`{pages, databases}` native records) and hands it to
|
|
17
|
-
* `
|
|
17
|
+
* `importLibrary(…, mode:'copy')`. That inherits — for free — the server's
|
|
18
18
|
* id-remap, `@`-mention link-rewrite, name de-dup, and idempotent-replay
|
|
19
19
|
* machinery (`remapBundle` / `importBundle`), plus the Restore dialog on the
|
|
20
20
|
* UI side. Best for a multi-page / database tree.
|
|
@@ -200,7 +200,7 @@ export type ImportStrategy = 'create' | 'bundle';
|
|
|
200
200
|
*/
|
|
201
201
|
export declare function chooseStrategy(doc: ImportedDoc): ImportStrategy;
|
|
202
202
|
/** The slice of {@link DataClient} the import writers use (a real client satisfies it). */
|
|
203
|
-
export type ImportWriteClient = Pick<DataClient, 'savePage' | 'setPageProperties' | 'createDatabase' | 'createRow' | '
|
|
203
|
+
export type ImportWriteClient = Pick<DataClient, 'savePage' | 'setPageProperties' | 'createDatabase' | 'createRow' | 'importLibrary'>;
|
|
204
204
|
/** Options shared by both writers. */
|
|
205
205
|
export interface ImportOptions {
|
|
206
206
|
/**
|
|
@@ -271,7 +271,7 @@ export declare function buildImportBundle(doc: ImportedDoc, opts?: BundleOptions
|
|
|
271
271
|
};
|
|
272
272
|
/**
|
|
273
273
|
* **Strategy B.** Build the copy-mode bundle ({@link buildImportBundle}) and
|
|
274
|
-
* hand it to `
|
|
274
|
+
* hand it to `importLibrary`, inheriting the server's id-remap, link-rewrite,
|
|
275
275
|
* name-dedup, and idempotent-replay handling. Surfaces the server's
|
|
276
276
|
* {@link ImportResult} (and its `idMap` as the new page ids).
|
|
277
277
|
*/
|
package/dist/import.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* - **Strategy B — {@link writeViaBundle}** maps the whole IR into a backup
|
|
16
16
|
* bundle (`{pages, databases}` native records) and hands it to
|
|
17
|
-
* `
|
|
17
|
+
* `importLibrary(…, mode:'copy')`. That inherits — for free — the server's
|
|
18
18
|
* id-remap, `@`-mention link-rewrite, name de-dup, and idempotent-replay
|
|
19
19
|
* machinery (`remapBundle` / `importBundle`), plus the Restore dialog on the
|
|
20
20
|
* UI side. Best for a multi-page / database tree.
|
|
@@ -300,14 +300,14 @@ export function buildImportBundle(doc, opts = {}) {
|
|
|
300
300
|
}
|
|
301
301
|
/**
|
|
302
302
|
* **Strategy B.** Build the copy-mode bundle ({@link buildImportBundle}) and
|
|
303
|
-
* hand it to `
|
|
303
|
+
* hand it to `importLibrary`, inheriting the server's id-remap, link-rewrite,
|
|
304
304
|
* name-dedup, and idempotent-replay handling. Surfaces the server's
|
|
305
305
|
* {@link ImportResult} (and its `idMap` as the new page ids).
|
|
306
306
|
*/
|
|
307
307
|
export async function writeViaBundle(client, doc, opts = {}) {
|
|
308
308
|
const { pages, databases } = buildImportBundle(doc, opts);
|
|
309
309
|
const req = { pages, databases, mode: 'copy' };
|
|
310
|
-
const importResult = await client.
|
|
310
|
+
const importResult = await client.importLibrary(req);
|
|
311
311
|
// Map the bundle pages that carry an image placeholder to their server-assigned
|
|
312
312
|
// ids (via the id-map) so the post-import rehydration pass revisits only those.
|
|
313
313
|
const placeholderPageIds = [];
|