mindoodb 0.0.97 → 0.0.99
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-server.md +15 -0
- package/README.md +1 -0
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts +7 -0
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js +17 -9
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js.map +1 -1
- package/dist/appendonlystores/network/HttpTransport.d.ts.map +1 -1
- package/dist/appendonlystores/network/HttpTransport.js +1 -0
- package/dist/appendonlystores/network/HttpTransport.js.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +18 -0
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +41 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
- package/dist/browser/index.mjs +76 -0
- package/dist/core/BaseMindooDB.d.ts +2 -0
- package/dist/core/BaseMindooDB.d.ts.map +1 -1
- package/dist/core/BaseMindooDB.js +73 -53
- package/dist/core/BaseMindooDB.js.map +1 -1
- package/dist/core/BaseMindooTenant.d.ts +44 -1
- package/dist/core/BaseMindooTenant.d.ts.map +1 -1
- package/dist/core/BaseMindooTenant.js +176 -42
- package/dist/core/BaseMindooTenant.js.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.d.ts +11 -0
- package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.js +137 -92
- package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
- package/dist/core/MindooDBServerAdmin.d.ts +1 -1
- package/dist/core/MindooDBServerAdmin.d.ts.map +1 -1
- package/dist/core/appendonlystores/migration/StoreMigration.d.ts +41 -1
- package/dist/core/appendonlystores/migration/StoreMigration.d.ts.map +1 -1
- package/dist/core/appendonlystores/migration/StoreMigration.js +126 -0
- package/dist/core/appendonlystores/migration/StoreMigration.js.map +1 -1
- package/dist/core/appendonlystores/sqlite/SqliteContentAddressedStore.d.ts.map +1 -1
- package/dist/core/appendonlystores/sqlite/SqliteContentAddressedStore.js +29 -0
- package/dist/core/appendonlystores/sqlite/SqliteContentAddressedStore.js.map +1 -1
- package/dist/core/appendonlystores/syncStores.d.ts +6 -0
- package/dist/core/appendonlystores/syncStores.d.ts.map +1 -1
- package/dist/core/appendonlystores/syncStores.js +21 -0
- package/dist/core/appendonlystores/syncStores.js.map +1 -1
- package/dist/core/appendonlystores/types.d.ts +8 -0
- package/dist/core/appendonlystores/types.d.ts.map +1 -1
- package/dist/core/appendonlystores/types.js.map +1 -1
- package/dist/core/builtinDbInvariants.d.ts +26 -1
- package/dist/core/builtinDbInvariants.d.ts.map +1 -1
- package/dist/core/builtinDbInvariants.js +52 -2
- package/dist/core/builtinDbInvariants.js.map +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/joinrequests/crypto.d.ts +110 -0
- package/dist/core/joinrequests/crypto.d.ts.map +1 -0
- package/dist/core/joinrequests/crypto.js +340 -0
- package/dist/core/joinrequests/crypto.js.map +1 -0
- package/dist/core/joinrequests/index.d.ts +4 -0
- package/dist/core/joinrequests/index.d.ts.map +1 -0
- package/dist/core/joinrequests/index.js +29 -0
- package/dist/core/joinrequests/index.js.map +1 -0
- package/dist/core/joinrequests/invitations.d.ts +257 -0
- package/dist/core/joinrequests/invitations.d.ts.map +1 -0
- package/dist/core/joinrequests/invitations.js +703 -0
- package/dist/core/joinrequests/invitations.js.map +1 -0
- package/dist/core/joinrequests/types.d.ts +208 -0
- package/dist/core/joinrequests/types.d.ts.map +1 -0
- package/dist/core/joinrequests/types.js +43 -0
- package/dist/core/joinrequests/types.js.map +1 -0
- package/dist/core/recovery/PaperRescueDevice.d.ts +101 -0
- package/dist/core/recovery/PaperRescueDevice.d.ts.map +1 -0
- package/dist/core/recovery/PaperRescueDevice.js +205 -0
- package/dist/core/recovery/PaperRescueDevice.js.map +1 -0
- package/dist/core/recovery/RecoveryContactsDocument.d.ts +86 -0
- package/dist/core/recovery/RecoveryContactsDocument.d.ts.map +1 -0
- package/dist/core/recovery/RecoveryContactsDocument.js +91 -0
- package/dist/core/recovery/RecoveryContactsDocument.js.map +1 -0
- package/dist/core/recovery/RecoveryContactsManager.d.ts +176 -0
- package/dist/core/recovery/RecoveryContactsManager.d.ts.map +1 -0
- package/dist/core/recovery/RecoveryContactsManager.js +455 -0
- package/dist/core/recovery/RecoveryContactsManager.js.map +1 -0
- package/dist/core/recovery/index.d.ts +9 -0
- package/dist/core/recovery/index.d.ts.map +1 -0
- package/dist/core/recovery/index.js +48 -0
- package/dist/core/recovery/index.js.map +1 -0
- package/dist/core/recovery/recoverWithContacts.d.ts +56 -0
- package/dist/core/recovery/recoverWithContacts.d.ts.map +1 -0
- package/dist/core/recovery/recoverWithContacts.js +142 -0
- package/dist/core/recovery/recoverWithContacts.js.map +1 -0
- package/dist/core/recovery/recoveryPackage.d.ts +80 -0
- package/dist/core/recovery/recoveryPackage.d.ts.map +1 -0
- package/dist/core/recovery/recoveryPackage.js +182 -0
- package/dist/core/recovery/recoveryPackage.js.map +1 -0
- package/dist/core/recovery/rescueApproval.d.ts +39 -0
- package/dist/core/recovery/rescueApproval.d.ts.map +1 -0
- package/dist/core/recovery/rescueApproval.js +52 -0
- package/dist/core/recovery/rescueApproval.js.map +1 -0
- package/dist/core/recovery/rescueDevice.d.ts +51 -0
- package/dist/core/recovery/rescueDevice.d.ts.map +1 -0
- package/dist/core/recovery/rescueDevice.js +201 -0
- package/dist/core/recovery/rescueDevice.js.map +1 -0
- package/dist/core/recovery/shamir.d.ts +30 -0
- package/dist/core/recovery/shamir.d.ts.map +1 -0
- package/dist/core/recovery/shamir.js +133 -0
- package/dist/core/recovery/shamir.js.map +1 -0
- package/dist/core/types.d.ts +73 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/userkeys/UserKeyManager.d.ts +45 -0
- package/dist/core/userkeys/UserKeyManager.d.ts.map +1 -1
- package/dist/core/userkeys/UserKeyManager.js +121 -8
- package/dist/core/userkeys/UserKeyManager.js.map +1 -1
- package/dist/core/userkeys/generationSignature.d.ts +6 -0
- package/dist/core/userkeys/generationSignature.d.ts.map +1 -1
- package/dist/core/userkeys/generationSignature.js +1 -0
- package/dist/core/userkeys/generationSignature.js.map +1 -1
- package/dist/core/userkeys/resolveUserKeyDocument.d.ts.map +1 -1
- package/dist/core/userkeys/resolveUserKeyDocument.js +6 -6
- package/dist/core/userkeys/resolveUserKeyDocument.js.map +1 -1
- package/dist/core/userkeys/validateUserKeyDocument.d.ts +11 -1
- package/dist/core/userkeys/validateUserKeyDocument.d.ts.map +1 -1
- package/dist/core/userkeys/validateUserKeyDocument.js +18 -5
- package/dist/core/userkeys/validateUserKeyDocument.js.map +1 -1
- package/dist/node/appendonlystores/sqlite/FsBlobContentStore.d.ts +23 -0
- package/dist/node/appendonlystores/sqlite/FsBlobContentStore.d.ts.map +1 -0
- package/dist/node/appendonlystores/sqlite/FsBlobContentStore.js +119 -0
- package/dist/node/appendonlystores/sqlite/FsBlobContentStore.js.map +1 -0
- package/dist/node/appendonlystores/sqlite/NodeSqliteStore.d.ts +43 -0
- package/dist/node/appendonlystores/sqlite/NodeSqliteStore.d.ts.map +1 -0
- package/dist/node/appendonlystores/sqlite/NodeSqliteStore.js +121 -0
- package/dist/node/appendonlystores/sqlite/NodeSqliteStore.js.map +1 -0
- package/dist/node/appendonlystores/sqlite/ServerSqliteStore.d.ts +43 -0
- package/dist/node/appendonlystores/sqlite/ServerSqliteStore.d.ts.map +1 -0
- package/dist/node/appendonlystores/sqlite/ServerSqliteStore.js +279 -0
- package/dist/node/appendonlystores/sqlite/ServerSqliteStore.js.map +1 -0
- package/dist/node/server/MindooDBServer.d.ts +2 -0
- package/dist/node/server/MindooDBServer.d.ts.map +1 -1
- package/dist/node/server/MindooDBServer.js +46 -0
- package/dist/node/server/MindooDBServer.js.map +1 -1
- package/dist/node/server/StoreFactory.d.ts +5 -2
- package/dist/node/server/StoreFactory.d.ts.map +1 -1
- package/dist/node/server/StoreFactory.js +21 -4
- package/dist/node/server/StoreFactory.js.map +1 -1
- package/dist/node/server/TenantManager.d.ts +6 -0
- package/dist/node/server/TenantManager.d.ts.map +1 -1
- package/dist/node/server/TenantManager.js +17 -0
- package/dist/node/server/TenantManager.js.map +1 -1
- package/dist/node/server/server.js +2 -0
- package/dist/node/server/server.js.map +1 -1
- package/dist/server/JoinRequestService.d.ts +108 -0
- package/dist/server/JoinRequestService.d.ts.map +1 -0
- package/dist/server/JoinRequestService.js +454 -0
- package/dist/server/JoinRequestService.js.map +1 -0
- package/dist/server/TenantManager.d.ts +57 -1
- package/dist/server/TenantManager.d.ts.map +1 -1
- package/dist/server/TenantManager.js +273 -34
- package/dist/server/TenantManager.js.map +1 -1
- package/dist/server/http/MindooDBServerCore.d.ts +18 -0
- package/dist/server/http/MindooDBServerCore.d.ts.map +1 -1
- package/dist/server/http/MindooDBServerCore.js +230 -137
- package/dist/server/http/MindooDBServerCore.js.map +1 -1
- package/dist/server/serverConfig.d.ts.map +1 -1
- package/dist/server/serverConfig.js +17 -0
- package/dist/server/serverConfig.js.map +1 -1
- package/dist/server/types.d.ts +16 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js +6 -0
- package/dist/server/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaperRescueDevice.js","sourceRoot":"","sources":["../../../src/core/recovery/PaperRescueDevice.ts"],"names":[],"mappings":";;;AA6FA,oDAiBC;AAOD,sDAkBC;AAlHD,oCAAsG;AAEtG,yDAAuE;AACvE,6CAAiD;AACjD,qDAA2E;AAC3E,yEAAkE;AACl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,MAAM,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;IACH,CAAC;IAED,kFAAkF;IAClF,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC,CAAC,CAAC,IAAA,4CAAkB,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrG,CAAC;IAED,2FAA2F;IAC3F,KAAK,CAAC,MAAM;QACV,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClC,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC5D,OAAO,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC;CACF;AAvID,gDAuIC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovery contacts document `rcv_` (docs/userkeys.md §12).
|
|
3
|
+
*
|
|
4
|
+
* One personal document per setup in `userdirectory`, written by the person
|
|
5
|
+
* whose devices it can replace. It holds the encrypted rescue device and one
|
|
6
|
+
* secret share per contact, each sealed to that contact's User-Key.
|
|
7
|
+
*
|
|
8
|
+
* **It uses the tenant `default` key.** Contacts must be able to read it to
|
|
9
|
+
* find their share, and the recovering device never needs to: everything it
|
|
10
|
+
* needs travels in the helper packages. `$publicinfos` would hand the hoster
|
|
11
|
+
* the list of who would vouch for whom, which is none of its business — the
|
|
12
|
+
* same reasoning as `dev_` and `qtn_` (§7.6).
|
|
13
|
+
*
|
|
14
|
+
* **Ids are generated** (`rcv_` plus an object id). A new contact list is a
|
|
15
|
+
* new setup with a new rescue device; the old document is deleted.
|
|
16
|
+
*
|
|
17
|
+
* **A document is a claim until it is verified.** Anyone may create an `rcv_`
|
|
18
|
+
* document naming anyone. {@link verifyRecoveryContactsDoc} accepts one only
|
|
19
|
+
* when its `doc_create` was signed by a device that resolves to the grant of
|
|
20
|
+
* the person the payload names (grant device or certified device), and the
|
|
21
|
+
* named username hashes to the same `username_hash`. The personal-document
|
|
22
|
+
* write rule then keeps everybody else from changing it.
|
|
23
|
+
*/
|
|
24
|
+
import type { BaseMindooTenantDirectory } from "../BaseMindooTenantDirectory";
|
|
25
|
+
import type { MindooDB, MindooDoc } from "../types";
|
|
26
|
+
import { USERKEY_FORM } from "../userkeys/types";
|
|
27
|
+
import { type RescueDeviceRef } from "./rescueApproval";
|
|
28
|
+
export declare const RECOVERY_CONTACTS_DOC_ID_PREFIX = "rcv_";
|
|
29
|
+
export declare const RECOVERY_CONTACTS_TYPE = "recoverycontacts";
|
|
30
|
+
export declare const RECOVERY_CONTACTS_SCHEMA_VERSION = 1;
|
|
31
|
+
/** Any two contacts together can recover; one alone cannot. */
|
|
32
|
+
export declare const RECOVERY_CONTACTS_THRESHOLD = 2;
|
|
33
|
+
/** At least two contacts, so that one contact alone never suffices. */
|
|
34
|
+
export declare const RECOVERY_CONTACTS_MIN = 2;
|
|
35
|
+
export interface RecoveryContactEntry {
|
|
36
|
+
/** The contact's username, as the person picked it. Display and lookup. */
|
|
37
|
+
username: string;
|
|
38
|
+
/** Fingerprint of the contact's User-Key generation the share is sealed to. */
|
|
39
|
+
userKeyFingerprint: string;
|
|
40
|
+
/** Base64 RSA-OAEP ciphertext of the contact's share. */
|
|
41
|
+
sealedShare: string;
|
|
42
|
+
}
|
|
43
|
+
export interface RecoveryContactsPayload {
|
|
44
|
+
form: typeof USERKEY_FORM;
|
|
45
|
+
type: typeof RECOVERY_CONTACTS_TYPE;
|
|
46
|
+
schemaVersion: number;
|
|
47
|
+
/** The person, as on their grant. */
|
|
48
|
+
username: string;
|
|
49
|
+
username_hash: string;
|
|
50
|
+
threshold: number;
|
|
51
|
+
createdAt: number;
|
|
52
|
+
rescueDevice: RescueDeviceRef;
|
|
53
|
+
/** The rescue device's private keys, AES-256-GCM under the recovery secret. */
|
|
54
|
+
rescueBlob: string;
|
|
55
|
+
contacts: RecoveryContactEntry[];
|
|
56
|
+
}
|
|
57
|
+
/** A setup that passed {@link verifyRecoveryContactsDoc}. */
|
|
58
|
+
export interface RecoveryContactsSetup {
|
|
59
|
+
docId: string;
|
|
60
|
+
payload: RecoveryContactsPayload;
|
|
61
|
+
}
|
|
62
|
+
export declare function isRecoveryContactsDocId(docId: string | null | undefined): boolean;
|
|
63
|
+
export declare function asRecoveryContactsPayload(data: unknown): RecoveryContactsPayload | null;
|
|
64
|
+
/**
|
|
65
|
+
* Verify an `rcv_` document: payload shape, creator bound to the person the
|
|
66
|
+
* payload names, username bound to that person's hash. Returns `null` for
|
|
67
|
+
* anything that fails — an unverifiable setup is litter, not an error.
|
|
68
|
+
*/
|
|
69
|
+
export declare function verifyRecoveryContactsDoc(input: {
|
|
70
|
+
db: MindooDB;
|
|
71
|
+
doc: MindooDoc;
|
|
72
|
+
directory: BaseMindooTenantDirectory;
|
|
73
|
+
}): Promise<RecoveryContactsSetup | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a personal document was created by the person it names: its
|
|
76
|
+
* `doc_create` signer resolves (grant device or certified device) to the grant
|
|
77
|
+
* with `usernameHash`, and `username` hashes to that same value.
|
|
78
|
+
*/
|
|
79
|
+
export declare function personalDocBelongsTo(input: {
|
|
80
|
+
db: MindooDB;
|
|
81
|
+
docId: string;
|
|
82
|
+
directory: BaseMindooTenantDirectory;
|
|
83
|
+
username: string;
|
|
84
|
+
usernameHash: string;
|
|
85
|
+
}): Promise<boolean>;
|
|
86
|
+
//# sourceMappingURL=RecoveryContactsDocument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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E,uBAAuB,CAAC;CAClC;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEjF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI,CAmBvF;AAaD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,KAAK,EAAE;IACrD,EAAE,EAAE,QAAQ,CAAC;IACb,GAAG,EAAE,SAAS,CAAC;IACf,SAAS,EAAE,yBAAyB,CAAC;CACtC,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAUxC;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,yBAAyB,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RECOVERY_CONTACTS_MIN = exports.RECOVERY_CONTACTS_THRESHOLD = exports.RECOVERY_CONTACTS_SCHEMA_VERSION = exports.RECOVERY_CONTACTS_TYPE = exports.RECOVERY_CONTACTS_DOC_ID_PREFIX = void 0;
|
|
4
|
+
exports.isRecoveryContactsDocId = isRecoveryContactsDocId;
|
|
5
|
+
exports.asRecoveryContactsPayload = asRecoveryContactsPayload;
|
|
6
|
+
exports.verifyRecoveryContactsDoc = verifyRecoveryContactsDoc;
|
|
7
|
+
exports.personalDocBelongsTo = personalDocBelongsTo;
|
|
8
|
+
const types_1 = require("../userkeys/types");
|
|
9
|
+
const rescueApproval_1 = require("./rescueApproval");
|
|
10
|
+
exports.RECOVERY_CONTACTS_DOC_ID_PREFIX = "rcv_";
|
|
11
|
+
exports.RECOVERY_CONTACTS_TYPE = "recoverycontacts";
|
|
12
|
+
exports.RECOVERY_CONTACTS_SCHEMA_VERSION = 1;
|
|
13
|
+
/** Any two contacts together can recover; one alone cannot. */
|
|
14
|
+
exports.RECOVERY_CONTACTS_THRESHOLD = 2;
|
|
15
|
+
/** At least two contacts, so that one contact alone never suffices. */
|
|
16
|
+
exports.RECOVERY_CONTACTS_MIN = 2;
|
|
17
|
+
function isRecoveryContactsDocId(docId) {
|
|
18
|
+
return typeof docId === "string" && docId.startsWith(exports.RECOVERY_CONTACTS_DOC_ID_PREFIX);
|
|
19
|
+
}
|
|
20
|
+
function asRecoveryContactsPayload(data) {
|
|
21
|
+
if (!data || typeof data !== "object")
|
|
22
|
+
return null;
|
|
23
|
+
const d = data;
|
|
24
|
+
if (d.form !== types_1.USERKEY_FORM || d.type !== exports.RECOVERY_CONTACTS_TYPE)
|
|
25
|
+
return null;
|
|
26
|
+
for (const key of ["username", "username_hash", "rescueBlob"]) {
|
|
27
|
+
if (typeof d[key] !== "string" || !d[key])
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (typeof d.threshold !== "number" || typeof d.createdAt !== "number")
|
|
31
|
+
return null;
|
|
32
|
+
const rescue = d.rescueDevice;
|
|
33
|
+
if (!rescue || typeof rescue !== "object")
|
|
34
|
+
return null;
|
|
35
|
+
if (!(0, rescueApproval_1.isRescueDeviceRef)(rescue))
|
|
36
|
+
return null;
|
|
37
|
+
if (!Array.isArray(d.contacts))
|
|
38
|
+
return null;
|
|
39
|
+
for (const entry of d.contacts) {
|
|
40
|
+
const c = entry;
|
|
41
|
+
if (!c || typeof c.username !== "string" || typeof c.userKeyFingerprint !== "string" || typeof c.sealedShare !== "string") {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return d;
|
|
46
|
+
}
|
|
47
|
+
async function resolveCreateSigner(db, docId) {
|
|
48
|
+
try {
|
|
49
|
+
// History is ordered causally, so `doc_create` is on the first page.
|
|
50
|
+
const page = await db.getDocumentHistoryPage(docId, { limit: 10 });
|
|
51
|
+
const create = page.entries.find((entry) => entry.entryType === "doc_create");
|
|
52
|
+
return create?.changeCreatedByPublicKey ?? null;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Verify an `rcv_` document: payload shape, creator bound to the person the
|
|
60
|
+
* payload names, username bound to that person's hash. Returns `null` for
|
|
61
|
+
* anything that fails — an unverifiable setup is litter, not an error.
|
|
62
|
+
*/
|
|
63
|
+
async function verifyRecoveryContactsDoc(input) {
|
|
64
|
+
const { db, doc, directory } = input;
|
|
65
|
+
const docId = doc.getId();
|
|
66
|
+
if (!isRecoveryContactsDocId(docId) || doc.isDeleted())
|
|
67
|
+
return null;
|
|
68
|
+
const payload = asRecoveryContactsPayload(doc.getData());
|
|
69
|
+
if (!payload)
|
|
70
|
+
return null;
|
|
71
|
+
if (!(await personalDocBelongsTo({ db, docId, directory, username: payload.username, usernameHash: payload.username_hash }))) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return { docId, payload: JSON.parse(JSON.stringify(payload)) };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Whether a personal document was created by the person it names: its
|
|
78
|
+
* `doc_create` signer resolves (grant device or certified device) to the grant
|
|
79
|
+
* with `usernameHash`, and `username` hashes to that same value.
|
|
80
|
+
*/
|
|
81
|
+
async function personalDocBelongsTo(input) {
|
|
82
|
+
const creator = await resolveCreateSigner(input.db, input.docId);
|
|
83
|
+
if (!creator)
|
|
84
|
+
return false;
|
|
85
|
+
const resolved = await input.directory.resolveSignerToGrant(creator, Number.MAX_SAFE_INTEGER);
|
|
86
|
+
if (!resolved || resolved.grant.usernameHash !== input.usernameHash)
|
|
87
|
+
return false;
|
|
88
|
+
const candidates = await input.directory.getUsernameHashCandidates(input.username);
|
|
89
|
+
return candidates.includes(input.usernameHash);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=RecoveryContactsDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecoveryContactsDocument.js","sourceRoot":"","sources":["../../../src/core/recovery/RecoveryContactsDocument.ts"],"names":[],"mappings":";;;AAkEA,0DAEC;AAED,8DAmBC;AAkBD,8DAcC;AAOD,oDAaC;AApHD,6CAAiD;AACjD,qDAA2E;AAE9D,QAAA,+BAA+B,GAAG,MAAM,CAAC;AACzC,QAAA,sBAAsB,GAAG,kBAAkB,CAAC;AAC5C,QAAA,gCAAgC,GAAG,CAAC,CAAC;AAClD,+DAA+D;AAClD,QAAA,2BAA2B,GAAG,CAAC,CAAC;AAC7C,uEAAuE;AAC1D,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAgCvC,SAAgB,uBAAuB,CAAC,KAAgC;IACtE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,uCAA+B,CAAC,CAAC;AACxF,CAAC;AAED,SAAgB,yBAAyB,CAAC,IAAa;IACrD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnD,MAAM,CAAC,GAAG,IAA+B,CAAC;IAC1C,IAAI,CAAC,CAAC,IAAI,KAAK,oBAAY,IAAI,CAAC,CAAC,IAAI,KAAK,8BAAsB;QAAE,OAAO,IAAI,CAAC;IAC9E,KAAK,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,eAAe,EAAE,YAAY,CAAC,EAAE,CAAC;QAC9D,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAE,CAAC,CAAC,GAAG,CAAY;YAAE,OAAO,IAAI,CAAC;IACrE,CAAC;IACD,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ;QAAE,OAAO,IAAI,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CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovery contacts on the person's and on the contacts' devices
|
|
3
|
+
* (docs/userkeys.md §12). Reached through the tenant:
|
|
4
|
+
* `tenant.setupRecoveryContacts`, `getRecoveryContactsSetup`,
|
|
5
|
+
* `removeRecoveryContacts`, `listRecoveryContactRequests`,
|
|
6
|
+
* `createRecoveryHelperPackage`.
|
|
7
|
+
*/
|
|
8
|
+
import type { BaseMindooTenant } from "../BaseMindooTenant";
|
|
9
|
+
import type { UserKeyManager } from "../userkeys/UserKeyManager";
|
|
10
|
+
import { type RecoveryContactsSetup } from "./RecoveryContactsDocument";
|
|
11
|
+
import type { RecoveryHelperPackage } from "./recoveryPackage";
|
|
12
|
+
import { type RescueDeviceRef } from "./rescueApproval";
|
|
13
|
+
export type RecoveryContactsErrorCode = "self-grant-required" | "too-few-contacts" | "contact-is-self" | "contact-without-key" | "no-user-key" | "no-default-key" | "not-a-contact" | "no-setup";
|
|
14
|
+
export declare class RecoveryContactsError extends Error {
|
|
15
|
+
readonly code: RecoveryContactsErrorCode;
|
|
16
|
+
/** Usernames the error is about (`contact-without-key`, `contact-is-self`). */
|
|
17
|
+
readonly usernames: string[];
|
|
18
|
+
constructor(code: RecoveryContactsErrorCode, message: string,
|
|
19
|
+
/** Usernames the error is about (`contact-without-key`, `contact-is-self`). */
|
|
20
|
+
usernames?: string[]);
|
|
21
|
+
}
|
|
22
|
+
/** A person who named this device's person as a recovery contact. */
|
|
23
|
+
export interface RecoveryContactRequest {
|
|
24
|
+
docId: string;
|
|
25
|
+
username: string;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
threshold: number;
|
|
28
|
+
/** All contacts of that setup, this person included. */
|
|
29
|
+
contacts: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface SetupRecoveryContactsOptions {
|
|
32
|
+
/** Label of the rescue device certificate. Default "Rescue device". */
|
|
33
|
+
rescueDeviceLabel?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Signing-key fingerprints of further rescue devices to withdraw, such as
|
|
36
|
+
* the one a recovery just used, in case its setup is not in this replica.
|
|
37
|
+
*/
|
|
38
|
+
withdrawRescueDevices?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Without device self-grant, let the administrator admit the rescue device
|
|
41
|
+
* (docs/userkeys.md §12.9). Default true; false fails with
|
|
42
|
+
* `self-grant-required` instead.
|
|
43
|
+
*/
|
|
44
|
+
allowAdminApproval?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** What {@link RecoveryContactsManager.setup} returns. */
|
|
47
|
+
export interface SetupRecoveryContactsResult extends RecoveryContactsSetup {
|
|
48
|
+
/**
|
|
49
|
+
* Set when the rescue device waits for the administrator: hand this join
|
|
50
|
+
* request to the admin, who grants it under this person's name.
|
|
51
|
+
*/
|
|
52
|
+
joinRequestUri?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Signing-key fingerprints of earlier rescue devices on the grant that only
|
|
55
|
+
* the administrator can remove (they were admitted by the admin).
|
|
56
|
+
*/
|
|
57
|
+
rescueDevicesToRemove: string[];
|
|
58
|
+
}
|
|
59
|
+
/** Where a rescue device stands (see {@link rescueDeviceStatus}). */
|
|
60
|
+
export type RescueDeviceStatus =
|
|
61
|
+
/** Certified with the self-grant key, or on the grant and holding the User-Key. */
|
|
62
|
+
"active"
|
|
63
|
+
/** Waiting for the administrator to put it on the grant. */
|
|
64
|
+
| "waiting-for-admin"
|
|
65
|
+
/** On the grant; this person's device has not wrapped the User-Key yet. */
|
|
66
|
+
| "waiting-for-key"
|
|
67
|
+
/** Neither certified nor on the grant any more. */
|
|
68
|
+
| "withdrawn";
|
|
69
|
+
/**
|
|
70
|
+
* Admit a rescue device: certify it with the self-grant key, or — without
|
|
71
|
+
* self-grant — attest it with the User-Key for the administrator to grant
|
|
72
|
+
* (docs/userkeys.md §12.9).
|
|
73
|
+
*/
|
|
74
|
+
export declare function admitRescueDevice(input: {
|
|
75
|
+
userKeys: UserKeyManager;
|
|
76
|
+
rescue: {
|
|
77
|
+
signingPublicKey: string;
|
|
78
|
+
encryptionPublicKey: string;
|
|
79
|
+
signingKeyFingerprint: string;
|
|
80
|
+
};
|
|
81
|
+
label: string;
|
|
82
|
+
usernameHash: string;
|
|
83
|
+
allowAdminApproval?: boolean;
|
|
84
|
+
}): Promise<{
|
|
85
|
+
ref: RescueDeviceRef;
|
|
86
|
+
joinRequestUri?: string;
|
|
87
|
+
}>;
|
|
88
|
+
/** Whether an admin-approved rescue device was set up by a holder of the person's User-Key. */
|
|
89
|
+
export declare function rescueAttestationHolds(userKeys: UserKeyManager, usernameHash: string, ref: RescueDeviceRef): Promise<boolean>;
|
|
90
|
+
/**
|
|
91
|
+
* Whether the rescue device a `rcv_`/`rpp_` document names is genuine: an
|
|
92
|
+
* admin-approved one must carry an attestation by the person's User-Key, a
|
|
93
|
+
* certified one must be certified now. A device on the person's grant can
|
|
94
|
+
* write documents under their name, so the document alone proves nothing.
|
|
95
|
+
*/
|
|
96
|
+
export declare function rescueRefIsGenuine(input: {
|
|
97
|
+
tenant: BaseMindooTenant;
|
|
98
|
+
userKeys: UserKeyManager;
|
|
99
|
+
username: string;
|
|
100
|
+
usernameHash: string;
|
|
101
|
+
ref: RescueDeviceRef;
|
|
102
|
+
}): Promise<boolean>;
|
|
103
|
+
/** Where a rescue device of this person stands. */
|
|
104
|
+
export declare function rescueDeviceStatus(tenant: BaseMindooTenant, userKeys: UserKeyManager, ref: RescueDeviceRef): Promise<RescueDeviceStatus>;
|
|
105
|
+
/**
|
|
106
|
+
* Wrap the User-Key to this person's own admin-approved rescue devices that
|
|
107
|
+
* reached the grant (no dialog: their attestation proves this person set them
|
|
108
|
+
* up). Returns how many were approved.
|
|
109
|
+
*/
|
|
110
|
+
export declare function approveOwnRescueDevices(userKeys: UserKeyManager, usernameHash: string, refs: RescueDeviceRef[]): Promise<number>;
|
|
111
|
+
export declare class RecoveryContactsManager {
|
|
112
|
+
private readonly tenant;
|
|
113
|
+
private readonly userKeys;
|
|
114
|
+
constructor(tenant: BaseMindooTenant, userKeys: UserKeyManager);
|
|
115
|
+
private userDirectory;
|
|
116
|
+
private directory;
|
|
117
|
+
/** Every `rcv_` document that verifies, newest first. */
|
|
118
|
+
private verifiedSetups;
|
|
119
|
+
private ownUsernameHash;
|
|
120
|
+
/** This person's current setups, newest first (normally one). */
|
|
121
|
+
private ownSetups;
|
|
122
|
+
/** This person's current recovery contacts, or `null` when none are set up. */
|
|
123
|
+
getSetup(): Promise<RecoveryContactsSetup | null>;
|
|
124
|
+
/**
|
|
125
|
+
* Name recovery contacts: make a new rescue device, certify it, split its
|
|
126
|
+
* secret among the contacts (any two recover) and publish the `rcv_`
|
|
127
|
+
* document. Replaces an earlier setup and withdraws its rescue device.
|
|
128
|
+
* Needs the person's device self-grant (the rescue device is certified with
|
|
129
|
+
* it) and a published User-Key for every contact.
|
|
130
|
+
*/
|
|
131
|
+
setup(contactUsernames: string[], options?: SetupRecoveryContactsOptions): Promise<SetupRecoveryContactsResult>;
|
|
132
|
+
/** Fingerprints of admin-approved rescue devices among `refs` that are still on the grant. */
|
|
133
|
+
private adminRescueDevicesOnGrant;
|
|
134
|
+
/** Where this person's current rescue device stands (`null` without a setup). */
|
|
135
|
+
status(): Promise<RescueDeviceStatus | null>;
|
|
136
|
+
/** The rescue devices of all own setups (for {@link approveOwnRescueDevices}). */
|
|
137
|
+
ownRescueDevices(): Promise<{
|
|
138
|
+
usernameHash: string | null;
|
|
139
|
+
refs: RescueDeviceRef[];
|
|
140
|
+
}>;
|
|
141
|
+
/** Delete a setup and withdraw its rescue device. */
|
|
142
|
+
private retire;
|
|
143
|
+
/** Withdraw rescue devices by fingerprint that no retired setup covered. */
|
|
144
|
+
private withdrawExtra;
|
|
145
|
+
/**
|
|
146
|
+
* Remove recovery contacts: delete every own setup and withdraw its rescue
|
|
147
|
+
* device (and `withdrawRescueDevices`). Returns how many setups were removed.
|
|
148
|
+
*/
|
|
149
|
+
remove(options?: {
|
|
150
|
+
withdrawRescueDevices?: string[];
|
|
151
|
+
}): Promise<number>;
|
|
152
|
+
/**
|
|
153
|
+
* People who named this person as a recovery contact, one entry per person
|
|
154
|
+
* (their newest setup), newest first.
|
|
155
|
+
*/
|
|
156
|
+
listRequests(): Promise<RecoveryContactRequest[]>;
|
|
157
|
+
/**
|
|
158
|
+
* Help a person recover: open this contact's share of their newest setup
|
|
159
|
+
* and build the package (plaintext — encrypt it with
|
|
160
|
+
* {@link encryptRecoveryHelperPackage} before handing it over).
|
|
161
|
+
* `person` is the person's username or the setup document id.
|
|
162
|
+
*/
|
|
163
|
+
createHelperPackage(person: string, options?: {
|
|
164
|
+
serverUrl?: string;
|
|
165
|
+
}): Promise<RecoveryHelperPackage>;
|
|
166
|
+
/**
|
|
167
|
+
* Signing keys of the rescue devices of every verified setup in the local
|
|
168
|
+
* replica (deleted setups are not included). A certificate issued by one of
|
|
169
|
+
* them means a recovery took place (docs/userkeys.md §12.5).
|
|
170
|
+
*/
|
|
171
|
+
rescueDeviceSigningKeys(): Promise<Array<{
|
|
172
|
+
username: string;
|
|
173
|
+
signingPublicKey: string;
|
|
174
|
+
}>>;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=RecoveryContactsManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecoveryContactsManager.d.ts","sourceRoot":"","sources":["../../../src/core/recovery/RecoveryContactsManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,EAQL,KAAK,qBAAqB,EAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,MAAM,yBAAy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