@interncom/diplomatic 0.22.0 → 0.24.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/cli/bun/src/crypto.d.ts +2 -3
- package/dist/cli/index.mjs +4 -5
- package/dist/cli/shared/api/peek.d.ts +9 -1
- package/dist/cli/shared/api/pull.d.ts +9 -1
- package/dist/cli/shared/api/push.d.ts +3 -1
- package/dist/cli/shared/api/user.d.ts +1 -1
- package/dist/cli/shared/auth.d.ts +2 -2
- package/dist/cli/shared/bag.d.ts +11 -6
- package/dist/cli/shared/client.d.ts +18 -9
- package/dist/cli/shared/codec.d.ts +4 -0
- package/dist/cli/shared/codecs/kdm.d.ts +7 -0
- package/dist/cli/shared/codecs/notifItem.d.ts +2 -0
- package/dist/cli/shared/crypto/bagman.d.ts +19 -0
- package/dist/cli/shared/crypto/binary.d.ts +1 -0
- package/dist/cli/shared/crypto/derivation.d.ts +45 -0
- package/dist/cli/shared/crypto/enclave.d.ts +31 -102
- package/dist/cli/shared/crypto/largeBlob.d.ts +8 -0
- package/dist/cli/shared/crypto/noble.d.ts +15 -22
- package/dist/cli/shared/crypto/pairing.d.ts +19 -2
- package/dist/cli/shared/crypto/prf.d.ts +52 -0
- package/dist/cli/shared/crypto/realms.d.ts +7 -0
- package/dist/cli/shared/endpoint.d.ts +4 -5
- package/dist/cli/shared/http.d.ts +12 -12
- package/dist/cli/shared/sync.d.ts +3 -3
- package/dist/cli/shared/types.d.ts +24 -16
- package/dist/cli/shared/webauthn/prf.d.ts +8 -0
- package/dist/cli/src/index.d.ts +6 -5
- package/dist/web/client.d.ts +18 -7
- package/dist/web/crypto.d.ts +2 -3
- package/dist/web/entdb/cached.d.ts +4 -0
- package/dist/web/entdb/entdb.d.ts +3 -0
- package/dist/web/entdb/idb.d.ts +8 -5
- package/dist/web/index.d.ts +11 -5
- package/dist/web/index.mjs +1 -1
- package/dist/web/objEq.d.ts +1 -0
- package/dist/web/passkey/prf-store.d.ts +26 -10
- package/dist/web/passkey/seed.d.ts +12 -6
- package/dist/web/shared/api/peek.d.ts +9 -1
- package/dist/web/shared/api/pull.d.ts +9 -1
- package/dist/web/shared/api/push.d.ts +3 -1
- package/dist/web/shared/api/user.d.ts +1 -1
- package/dist/web/shared/auth.d.ts +2 -2
- package/dist/web/shared/bag.d.ts +11 -6
- package/dist/web/shared/blobs.d.ts +25 -0
- package/dist/web/shared/client.d.ts +18 -9
- package/dist/web/shared/codec.d.ts +4 -0
- package/dist/web/shared/codecs/ent.d.ts +5 -0
- package/dist/web/shared/codecs/kdm.d.ts +7 -0
- package/dist/web/shared/codecs/notifItem.d.ts +2 -0
- package/dist/web/shared/crypto/bagman.d.ts +19 -0
- package/dist/web/shared/crypto/binary.d.ts +1 -0
- package/dist/web/shared/crypto/derivation.d.ts +45 -0
- package/dist/web/shared/crypto/enclave.d.ts +31 -102
- package/dist/web/shared/crypto/largeBlob.d.ts +8 -0
- package/dist/web/shared/crypto/noble.d.ts +15 -22
- package/dist/web/shared/crypto/pairing.d.ts +19 -2
- package/dist/web/shared/crypto/prf.d.ts +52 -0
- package/dist/web/shared/crypto/realms.d.ts +7 -0
- package/dist/web/shared/crypto/tty.d.ts +3 -0
- package/dist/web/shared/endpoint.d.ts +4 -5
- package/dist/web/shared/exim.d.ts +5 -5
- package/dist/web/shared/http.d.ts +12 -12
- package/dist/web/shared/storage/memory.d.ts +2 -2
- package/dist/web/shared/sync.d.ts +3 -3
- package/dist/web/shared/types.d.ts +24 -16
- package/dist/web/shared/webauthn/prf.d.ts +8 -0
- package/dist/web/state.d.ts +1 -2
- package/dist/web/stores/cursor.d.ts +30 -0
- package/dist/web/stores/idb/account.d.ts +58 -0
- package/dist/web/stores/idb/catalog.d.ts +1 -0
- package/dist/web/stores/idb/dnlds.d.ts +3 -2
- package/dist/web/stores/idb/hosts.d.ts +8 -7
- package/dist/web/stores/idb/idbutil.d.ts +2 -0
- package/dist/web/stores/idb/migrate.d.ts +2 -0
- package/dist/web/stores/idb/msgs.d.ts +1 -1
- package/dist/web/stores/idb/names.d.ts +13 -0
- package/dist/web/stores/idb/realms.d.ts +11 -0
- package/dist/web/stores/idb/store.d.ts +26 -19
- package/dist/web/stores/idb/uplds.d.ts +1 -1
- package/dist/web/stores/keyTag.d.ts +14 -0
- package/dist/web/stores/label.d.ts +3 -0
- package/dist/web/stores/memory/account.d.ts +14 -0
- package/dist/web/stores/memory/dnlds.d.ts +4 -2
- package/dist/web/stores/memory/hosts.d.ts +8 -6
- package/dist/web/stores/memory/realms.d.ts +10 -0
- package/dist/web/stores/memory/store.d.ts +6 -2
- package/dist/web/stores/realm.d.ts +35 -0
- package/dist/web/sync.d.ts +18 -16
- package/dist/web/types.d.ts +59 -18
- package/dist/web/worker/client.d.ts +7 -3
- package/dist/web/worker/protocol.d.ts +6 -0
- package/dist/web/worker/runtime.d.ts +4 -2
- package/dist/web/worker.mjs +1 -1
- package/package.json +1 -2
- package/dist/cli/bun/src/codec.d.ts +0 -3
- package/dist/web/stores/idb/seed.d.ts +0 -32
- package/dist/web/stores/identityPin.d.ts +0 -19
- package/dist/web/stores/memory/seed.d.ts +0 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function objEq(a: unknown, b: unknown): boolean;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { Enclave
|
|
1
|
+
import { Enclave } from "../shared/crypto/enclave";
|
|
2
|
+
import { type PDK } from "../shared/crypto/derivation";
|
|
3
|
+
import type { PasskeyPrfOpts } from "../shared/crypto/prf";
|
|
4
|
+
import { Status } from "../shared/consts";
|
|
2
5
|
import { type SealedMasterKey } from "../shared/seed";
|
|
3
6
|
import { type ValStat } from "../shared/valstat";
|
|
4
|
-
import type {
|
|
7
|
+
import type { IAccountStore, SetSeedOpts } from "../types";
|
|
5
8
|
import { type PrfRp } from "../shared/webauthn/prf";
|
|
6
9
|
import { type AuthenticatorAttachmentName, type EnrolledOs } from "../shared/webauthn/common";
|
|
7
10
|
/** Max bindings on one device. Keeps allowCredentials small. */
|
|
@@ -12,8 +15,8 @@ export type KeyringEntry = {
|
|
|
12
15
|
type: "prf";
|
|
13
16
|
sealedMaster: SealedMasterKey;
|
|
14
17
|
credId: Uint8Array;
|
|
15
|
-
/**
|
|
16
|
-
tag:
|
|
18
|
+
/** Bind-tag PDK child keyed by credId; check-only, not a display fingerprint. */
|
|
19
|
+
tag: PDK["BindTag"];
|
|
17
20
|
userId?: Uint8Array;
|
|
18
21
|
nick?: string;
|
|
19
22
|
enrolledAt: number;
|
|
@@ -45,10 +48,18 @@ export type KeyringRow = {
|
|
|
45
48
|
* Persist the keyring for cold start (e.g. protocol IDB).
|
|
46
49
|
* Called with `undefined` when the store is wiped.
|
|
47
50
|
*/
|
|
48
|
-
export type PersistKeyring = (ring: Keyring | undefined) =>
|
|
51
|
+
export type PersistKeyring = (ring: Keyring | undefined) => Status | Promise<Status>;
|
|
49
52
|
export type PrfSeedStoreOpts = PrfRp & {
|
|
50
53
|
persistKeyring: PersistKeyring;
|
|
51
54
|
keyring?: Keyring;
|
|
55
|
+
/**
|
|
56
|
+
* When set, unlock runs this instead of the keyring held here.
|
|
57
|
+
* The account store uses it to pick the row by the asserted credId.
|
|
58
|
+
*/
|
|
59
|
+
unlockAccount?: () => Promise<ValStat<{
|
|
60
|
+
enclave: Enclave;
|
|
61
|
+
keyring?: Keyring;
|
|
62
|
+
}>>;
|
|
52
63
|
};
|
|
53
64
|
/**
|
|
54
65
|
* Session + durable PRF-bound seed. Session secret is always {@link Enclave}.
|
|
@@ -57,13 +68,14 @@ export type PrfSeedStoreOpts = PrfRp & {
|
|
|
57
68
|
* - {@link bindAndSave} creates a binding and appends/upserts a keyring entry.
|
|
58
69
|
* - {@link unlock} runs PRF UV inside Enclave and returns a new enclave.
|
|
59
70
|
*/
|
|
60
|
-
export declare class PrfSeedStore implements
|
|
71
|
+
export declare class PrfSeedStore implements IAccountStore {
|
|
61
72
|
#private;
|
|
62
|
-
constructor(opts: PrfSeedStoreOpts);
|
|
73
|
+
constructor(opts: Omit<PrfSeedStoreOpts, "keyring">);
|
|
74
|
+
static open(opts: PrfSeedStoreOpts): ValStat<PrfSeedStore>;
|
|
63
75
|
get keyring(): Keyring | undefined;
|
|
64
76
|
/** Public rows (no sealed master). */
|
|
65
77
|
list(): KeyringRow[];
|
|
66
|
-
save(enclave: Enclave, opts?: SetSeedOpts): Promise<Enclave
|
|
78
|
+
save(enclave: Enclave, opts?: SetSeedOpts): Promise<ValStat<Enclave>>;
|
|
67
79
|
/**
|
|
68
80
|
* PRF UV inside Enclave.bind, persist the entry.
|
|
69
81
|
* Always creates a new cred unless `credId` is passed (re-bind that cred).
|
|
@@ -73,7 +85,10 @@ export declare class PrfSeedStore implements ISeedStore {
|
|
|
73
85
|
nick?: string;
|
|
74
86
|
}): Promise<ValStat<Enclave>>;
|
|
75
87
|
load(): Promise<Enclave | void>;
|
|
76
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Passkey UV inside Enclave → new session enclave.
|
|
90
|
+
* With `unlockAccount`, the asserted credId selects the account.
|
|
91
|
+
*/
|
|
77
92
|
unlock(): Promise<ValStat<Enclave>>;
|
|
78
93
|
/** Set a display nick (local only; does not update the binding key). */
|
|
79
94
|
rename(credId: Uint8Array, nick: string): Promise<ValStat<void>>;
|
|
@@ -84,11 +99,12 @@ export declare class PrfSeedStore implements ISeedStore {
|
|
|
84
99
|
remove(credId: Uint8Array): Promise<ValStat<void>>;
|
|
85
100
|
wipe(): Promise<void>;
|
|
86
101
|
}
|
|
87
|
-
export declare function cloneKeyring(r: Keyring): Keyring
|
|
102
|
+
export declare function cloneKeyring(r: Keyring): ValStat<Keyring>;
|
|
88
103
|
/** Read a keyring from IDB structured-clone output. */
|
|
89
104
|
export declare function decodeKeyring(raw: unknown): Keyring | undefined;
|
|
90
105
|
/** Cred ids of every keyring entry. */
|
|
91
106
|
export declare function keyringCredIds(ring: Keyring | undefined): Uint8Array[];
|
|
107
|
+
export declare function touchKeyring(ring: Keyring, credId: Uint8Array): ValStat<Keyring | undefined>;
|
|
92
108
|
/** Inferred kind for UI. Not attested. */
|
|
93
109
|
export declare function keyringKind(row: KeyringRow): string;
|
|
94
110
|
/** Display label: nick, else inferred kind + short cred id. */
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { Enclave } from "../shared/crypto/enclave";
|
|
2
2
|
import { type ValStat } from "../shared/valstat";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IAccountStore, SetSeedOpts } from "../types";
|
|
4
4
|
import type { LargeBlobRp } from "../shared/webauthn/largeBlob";
|
|
5
5
|
export type PasskeySeedStoreOpts = LargeBlobRp & {
|
|
6
6
|
credId?: Uint8Array;
|
|
7
|
+
/** Account `credId` belongs to. Omitted is the default account, "". */
|
|
8
|
+
label?: string;
|
|
7
9
|
};
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
11
|
+
* IAccountStore backed by largeBlob. Session secret is always {@link Enclave}.
|
|
12
|
+
* Each account label has its own credential. Omitted label is "".
|
|
10
13
|
* Persist uses {@link Enclave.persistToLargeBlob} / {@link Enclave.fromLargeBlob}.
|
|
11
14
|
*/
|
|
12
|
-
export declare class PasskeySeedStore implements
|
|
15
|
+
export declare class PasskeySeedStore implements IAccountStore {
|
|
13
16
|
#private;
|
|
14
17
|
constructor(opts: PasskeySeedStoreOpts);
|
|
18
|
+
/** Credential id of the selected account. */
|
|
15
19
|
get credId(): Uint8Array | undefined;
|
|
16
|
-
setCredId(credId: Uint8Array | undefined): void;
|
|
17
|
-
save(enclave: Enclave, opts?: SetSeedOpts): Promise<Enclave
|
|
20
|
+
setCredId(credId: Uint8Array | undefined, label?: string): void;
|
|
21
|
+
save(enclave: Enclave, opts?: SetSeedOpts): Promise<ValStat<Enclave>>;
|
|
18
22
|
load(): Promise<Enclave | void>;
|
|
19
|
-
unlock(
|
|
23
|
+
unlock(opts?: {
|
|
24
|
+
label?: string;
|
|
25
|
+
}): Promise<ValStat<Enclave>>;
|
|
20
26
|
wipe(): Promise<void>;
|
|
21
27
|
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { ICodecStruct } from "../codec.ts";
|
|
1
2
|
import { IAuthenticatedEndpoint } from "../endpoint.ts";
|
|
2
3
|
import { IBagPeekItem } from "../codecs/peekItem.ts";
|
|
3
|
-
|
|
4
|
+
import { type HostRlm } from "../crypto/derivation.ts";
|
|
5
|
+
/** One realm cursor: that rlm, and the last seq the client has in it. */
|
|
6
|
+
export interface IPeekCursor {
|
|
7
|
+
rlm: HostRlm;
|
|
8
|
+
seq: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const peekCursorCodec: ICodecStruct<IPeekCursor>;
|
|
11
|
+
export declare const peekEnd: IAuthenticatedEndpoint<IPeekCursor, IBagPeekItem[]>;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { ICodecStruct } from "../codec.ts";
|
|
1
2
|
import { type IBagPullItem } from "../codecs/pullItem.ts";
|
|
3
|
+
import { type HostRlm } from "../crypto/derivation.ts";
|
|
2
4
|
import { IAuthenticatedEndpoint } from "../endpoint.ts";
|
|
3
|
-
|
|
5
|
+
/** One realm, and the seqs to fetch in it. */
|
|
6
|
+
export interface IPullReq {
|
|
7
|
+
rlm: HostRlm;
|
|
8
|
+
seqs: number[];
|
|
9
|
+
}
|
|
10
|
+
export declare const pullReqCodec: ICodecStruct<IPullReq>;
|
|
11
|
+
export declare const pullEnd: IAuthenticatedEndpoint<IPullReq, IBagPullItem[]>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ICodecStruct } from "../codec.ts";
|
|
1
2
|
import { type IBagPushItem } from "../codecs/pushItem.ts";
|
|
2
3
|
import { IAuthenticatedEndpoint } from "../endpoint.ts";
|
|
3
4
|
import { IBag } from "../types.ts";
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const pushReqCodec: ICodecStruct<IBag[]>;
|
|
6
|
+
export declare const pushEnd: IAuthenticatedEndpoint<IBag[], IBagPushItem[]>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IAuthenticatedEndpoint } from "../endpoint.ts";
|
|
2
|
-
export declare const userEnd: IAuthenticatedEndpoint<
|
|
2
|
+
export declare const userEnd: IAuthenticatedEndpoint<void, void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IClock } from "./clock.ts";
|
|
2
2
|
import { type IAuthTimestamp } from "./codecs/authTimestamp.ts";
|
|
3
3
|
import { Status } from "./consts.ts";
|
|
4
|
-
import type {
|
|
4
|
+
import type { BagManager } from "./crypto/bagman.ts";
|
|
5
5
|
import type { IHostCrypto } from "./types.ts";
|
|
6
6
|
import { ValStat } from "./valstat.ts";
|
|
7
7
|
export type EncodedAuthTimestamp = Uint8Array;
|
|
8
|
-
export declare function makeAuthTimestamp(identity:
|
|
8
|
+
export declare function makeAuthTimestamp(identity: BagManager, ts: Date): Promise<ValStat<IAuthTimestamp>>;
|
|
9
9
|
export declare function validateAuthTimestamp(authTS: IAuthTimestamp, crypto: IHostCrypto, clock: IClock): Promise<Status>;
|
package/dist/web/shared/bag.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { IMessageHead } from "./codecs/messageHead.ts";
|
|
2
|
-
import
|
|
2
|
+
import type { HostRlm } from "./crypto/derivation.ts";
|
|
3
|
+
import { BagManager } from "./crypto/bagman.ts";
|
|
3
4
|
import { EncodedMessage } from "./message.ts";
|
|
4
5
|
import { type ValStat } from "./valstat.ts";
|
|
5
|
-
import type { Hash, IBag, ICrypto, IHostCrypto, IMessage, IMessageWithHash
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
6
|
+
import type { Hash, IBag, ICrypto, IHostCrypto, IMessage, IMessageWithHash } from "./types.ts";
|
|
7
|
+
export declare function bagSigMsg(rlm: HostRlm, headCph: Uint8Array): Uint8Array;
|
|
8
|
+
export declare function bagSigValid(bag: IBag, verifyKey: CryptoKey, crypto: IHostCrypto): Promise<boolean>;
|
|
9
|
+
export declare function sealBag(msg: IMessage, bagMgr: BagManager, crypto: ICrypto): Promise<ValStat<IBag>>;
|
|
8
10
|
export interface IOpenBag {
|
|
9
11
|
msgHead: IMessageHead;
|
|
10
12
|
bod?: EncodedMessage;
|
|
11
13
|
headHash: Hash;
|
|
12
14
|
}
|
|
13
|
-
export
|
|
15
|
+
export type BagDecrypt = {
|
|
16
|
+
decrypt: (data: Uint8Array) => Promise<ValStat<Uint8Array>>;
|
|
17
|
+
};
|
|
18
|
+
export declare function openBagBody(headEnc: Uint8Array, bodyCph: Uint8Array | undefined, cipher: BagDecrypt, crypto: ICrypto,
|
|
14
19
|
/** When set (e.g. from peek), skip blake3(headEnc). */
|
|
15
20
|
headHashKnown?: Hash): Promise<ValStat<IOpenBag>>;
|
|
16
|
-
export declare function openBag(bag: IBag,
|
|
21
|
+
export declare function openBag(bag: IBag, verifyKey: CryptoKey, crypto: ICrypto, bagMgr: BagManager): Promise<ValStat<IMessageWithHash>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EntityID, IEntRev, IMessage, IMsgEntBody } from "./types.ts";
|
|
2
|
+
import { ValStat } from "./valstat.ts";
|
|
3
|
+
/** Head typ prefix. The rest is an app mime, such as "image/jpeg". */
|
|
4
|
+
export declare const blobPrefix = "blob:";
|
|
5
|
+
export declare function blobTyp(mime: string): string;
|
|
6
|
+
export declare function isBlobTyp(typ: string | undefined): typ is string;
|
|
7
|
+
export declare function mimeOf(typ: string | undefined): string | undefined;
|
|
8
|
+
export interface IBlobWrite {
|
|
9
|
+
tags?: string[];
|
|
10
|
+
pid?: EntityID;
|
|
11
|
+
}
|
|
12
|
+
export interface IBlobUpdate extends IBlobWrite {
|
|
13
|
+
mime?: string;
|
|
14
|
+
}
|
|
15
|
+
type BlobMsg = {
|
|
16
|
+
typ: string;
|
|
17
|
+
bod: Uint8Array;
|
|
18
|
+
};
|
|
19
|
+
export declare function openBlob(bod: Uint8Array): ValStat<IMsgEntBody<Uint8Array>>;
|
|
20
|
+
export declare function insertBlobMsg(mime: string, bytes: Uint8Array, opts?: IBlobWrite): ValStat<BlobMsg>;
|
|
21
|
+
export declare function updateBlobMsg(prev: IMessage | undefined, bytes: Uint8Array, opts?: IBlobUpdate): ValStat<BlobMsg & {
|
|
22
|
+
prior: IEntRev;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function blobBytes(msg: IMessage | undefined): ValStat<Uint8Array>;
|
|
25
|
+
export {};
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import { IClock } from "./clock.ts";
|
|
2
|
+
import { type IKDM } from "./codecs/kdm.ts";
|
|
3
|
+
import type { IBagPeekItem } from "./codecs/peekItem.ts";
|
|
4
|
+
import type { IBagPullItem } from "./codecs/pullItem.ts";
|
|
2
5
|
import { Status } from "./consts.ts";
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
6
|
+
import type { BagManager } from "./crypto/bagman.ts";
|
|
7
|
+
import type { Enclave } from "./crypto/enclave.ts";
|
|
8
|
+
import { type HostRlm } from "./crypto/derivation.ts";
|
|
9
|
+
import type { HostHandle, IBag, ICrypto, IHostMetadata, IMessage, ITransport, PushReceiver } from "./types.ts";
|
|
5
10
|
import { ValStat } from "./valstat.ts";
|
|
11
|
+
export declare function hostBagMgrs(enclave: Enclave, idKDM: IKDM, realms?: readonly IKDM[]): Promise<ValStat<BagManager[]>>;
|
|
6
12
|
export default class DiplomaticClientAPI<Handle extends HostHandle> {
|
|
7
|
-
|
|
13
|
+
#private;
|
|
8
14
|
crypto: ICrypto;
|
|
9
|
-
private host;
|
|
10
15
|
clock: IClock;
|
|
11
16
|
private transport;
|
|
12
17
|
private updateHostMeta;
|
|
13
|
-
constructor(
|
|
18
|
+
constructor(bagMgrs: BagManager[], crypto: ICrypto, clock: IClock, transport: ITransport, updateHostMeta: (meta: IHostMetadata) => Promise<Status>);
|
|
14
19
|
private call;
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
bagMgrFor(realm?: IKDM): BagManager | undefined;
|
|
21
|
+
bagMgrs(): readonly BagManager[];
|
|
22
|
+
add(bagMgr: BagManager): void;
|
|
23
|
+
identity: () => Promise<ValStat<BagManager>>;
|
|
24
|
+
hostRlm: (realm?: IKDM) => Promise<ValStat<HostRlm>>;
|
|
25
|
+
seal: (msg: IMessage, realm?: IKDM) => Promise<ValStat<IBag>>;
|
|
17
26
|
register: () => Promise<ValStat<void>>;
|
|
18
|
-
peek: (lastSeq: number) => Promise<ValStat<
|
|
27
|
+
peek: (lastSeq: number, realm?: IKDM) => Promise<ValStat<IBagPeekItem[]>>;
|
|
19
28
|
push: (bags: IBag[]) => Promise<ValStat<import("./codecs/pushItem.ts").IBagPushItem[]>>;
|
|
20
|
-
pull: (seqs: number[]) => Promise<ValStat<
|
|
29
|
+
pull: (seqs: number[], realm?: IKDM) => Promise<ValStat<IBagPullItem[]>>;
|
|
21
30
|
listen: (recv: PushReceiver, onDisconnect?: () => void, onConnect?: () => void) => Promise<Status>;
|
|
22
31
|
/** Returns whether this client has an active connection to its host.
|
|
23
32
|
* If a push listener is active, reports the listener's connected state.
|
|
@@ -14,12 +14,15 @@ export declare class Decoder {
|
|
|
14
14
|
readDate(): ValStat<Date>;
|
|
15
15
|
readVarInt(): ValStat<number>;
|
|
16
16
|
readVarString(): ValStat<string>;
|
|
17
|
+
readVarStrings(): ValStat<string[]>;
|
|
17
18
|
readBytes(num: number): ValStat<Uint8Array>;
|
|
18
19
|
readVarBytes(): ValStat<Uint8Array>;
|
|
19
20
|
readStruct<T>(codec: ICodecStruct<T>): ValStat<T>;
|
|
20
21
|
readStructs<T>(codec: ICodecStruct<T>): ValStat<T[]>;
|
|
21
22
|
readBytesSeq(len: number): ValStat<Uint8Array[]>;
|
|
22
23
|
done(): boolean;
|
|
24
|
+
remaining(): number;
|
|
25
|
+
readRest(): Uint8Array;
|
|
23
26
|
consumed(): number;
|
|
24
27
|
}
|
|
25
28
|
export declare class Encoder {
|
|
@@ -28,6 +31,7 @@ export declare class Encoder {
|
|
|
28
31
|
writeDate(ts: Date): Status;
|
|
29
32
|
writeVarInt(n: number): Status;
|
|
30
33
|
writeVarString(s: string): Status;
|
|
34
|
+
writeVarStrings(strs: string[]): Status;
|
|
31
35
|
prependBytes(bytes: Uint8Array): void;
|
|
32
36
|
/**
|
|
33
37
|
* Append a copy of `bytes`. Parts must not alias caller buffers — callers
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ICodecStruct } from "../codec.ts";
|
|
2
|
+
import { IMsgEntBody } from "../types.ts";
|
|
3
|
+
import { ValStat } from "../valstat.ts";
|
|
4
|
+
export declare const entCodec: ICodecStruct<IMsgEntBody<Uint8Array>>;
|
|
5
|
+
export declare function encodeEnt(ent: IMsgEntBody<Uint8Array>): ValStat<Uint8Array>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IKDM } from "../codecs/kdm.ts";
|
|
2
|
+
import type { PublicKey } from "../types.ts";
|
|
3
|
+
import { type ValStat } from "../valstat.ts";
|
|
4
|
+
import type { HostRlm, PDK } from "./derivation.ts";
|
|
5
|
+
export declare class BagManager {
|
|
6
|
+
#private;
|
|
7
|
+
readonly publicKey: PublicKey;
|
|
8
|
+
private idnt;
|
|
9
|
+
private realm;
|
|
10
|
+
readonly rlm: HostRlm;
|
|
11
|
+
readonly idKDM: Readonly<IKDM>;
|
|
12
|
+
readonly realmKDM: Readonly<IKDM>;
|
|
13
|
+
private constructor();
|
|
14
|
+
static init(idnt: PDK["Identity"], realm: PDK["RealmKey"], rlm: HostRlm, idKDM: IKDM, realmKDM: IKDM): Promise<ValStat<BagManager>>;
|
|
15
|
+
sign(message: Uint8Array | string): Promise<ValStat<Uint8Array>>;
|
|
16
|
+
bagKDM(msgHeadEnc: Uint8Array): Promise<ValStat<Uint8Array>>;
|
|
17
|
+
encrypt(kdm: Uint8Array, data: Uint8Array): Promise<ValStat<Uint8Array>>;
|
|
18
|
+
decrypt(kdm: Uint8Array, data: Uint8Array): Promise<ValStat<Uint8Array>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type IKDM } from "../codecs/kdm.ts";
|
|
2
|
+
import { type ValStat } from "../valstat.ts";
|
|
3
|
+
export declare const Purpose: {
|
|
4
|
+
readonly Identity: "diplomatic.identity.v1";
|
|
5
|
+
readonly Cipher: "diplomatic.cipher.v1";
|
|
6
|
+
readonly Bind: "diplomatic.bind.v1";
|
|
7
|
+
readonly BindTag: "diplomatic.bindtag.v1";
|
|
8
|
+
readonly Fingerprint: "diplomatic.fingerprint.v1";
|
|
9
|
+
readonly Pair: "diplomatic.qrpair.v1";
|
|
10
|
+
readonly BagKdm: "diplomatic.bagkdm.v1";
|
|
11
|
+
readonly RealmKey: "diplomatic.realmKey.v1";
|
|
12
|
+
readonly RealmID: "diplomatic.realmID.v1";
|
|
13
|
+
readonly HostRLM: "diplomatic.hostRLM.v1";
|
|
14
|
+
};
|
|
15
|
+
export type Purpose = typeof Purpose[keyof typeof Purpose];
|
|
16
|
+
declare const pdkSymbol: unique symbol;
|
|
17
|
+
export type PurposeDerivedKey<P extends Purpose> = Uint8Array & {
|
|
18
|
+
readonly [pdkSymbol]: P;
|
|
19
|
+
};
|
|
20
|
+
declare const childKeySymbol: unique symbol;
|
|
21
|
+
export type ChildKey<P extends Purpose> = Uint8Array & {
|
|
22
|
+
readonly [childKeySymbol]: P;
|
|
23
|
+
};
|
|
24
|
+
export type PDK = {
|
|
25
|
+
[K in keyof typeof Purpose]: ChildKey<(typeof Purpose)[K]>;
|
|
26
|
+
};
|
|
27
|
+
/** Host-stamped bag rlm. Peek, pull, and bag signatures use this. */
|
|
28
|
+
export type HostRlm = PDK["HostRLM"];
|
|
29
|
+
export declare const nullKDM: IKDM;
|
|
30
|
+
export declare function asChildKey<P extends Purpose>(bytes: Uint8Array, _purpose: P): ValStat<ChildKey<P>>;
|
|
31
|
+
export declare function asHostRlm(bytes: Uint8Array): ValStat<HostRlm>;
|
|
32
|
+
export declare function derivePDK<P extends Purpose>({ parent, purpose, }: {
|
|
33
|
+
parent: Uint8Array;
|
|
34
|
+
purpose: P;
|
|
35
|
+
}): Promise<ValStat<PurposeDerivedKey<P>>>;
|
|
36
|
+
export declare function deriveChild<P extends Purpose>({ pdk, kdm, }: {
|
|
37
|
+
pdk: PurposeDerivedKey<P>;
|
|
38
|
+
kdm: Uint8Array | IKDM;
|
|
39
|
+
}): Promise<ValStat<ChildKey<P>>>;
|
|
40
|
+
export declare function deriveKey<P extends Purpose>({ parent, purpose, kdm, }: {
|
|
41
|
+
parent: Uint8Array;
|
|
42
|
+
purpose: P;
|
|
43
|
+
kdm: Uint8Array | IKDM;
|
|
44
|
+
}): Promise<ValStat<ChildKey<P>>>;
|
|
45
|
+
export {};
|
|
@@ -1,98 +1,38 @@
|
|
|
1
1
|
import type { BundleHost } from "../codecs/bundleHost.ts";
|
|
2
|
+
import type { IKDM } from "../codecs/kdm.ts";
|
|
3
|
+
import type { MasterSeed, SealedMasterKey } from "../seed.ts";
|
|
4
|
+
import type { ValStat } from "../valstat.ts";
|
|
5
|
+
import type { PDK } from "./derivation.ts";
|
|
6
|
+
import type { DHKEReq, DHKEResp } from "./pairing.ts";
|
|
7
|
+
import type { LargeBlobCreateOpts, LargeBlobRp } from "../webauthn/largeBlob.ts";
|
|
8
|
+
import type { BindPrior, PasskeyPrfOpts, PrfBinding, PrfBound, PrfSealedMaster } from "./prf.ts";
|
|
2
9
|
import { Status } from "../consts.ts";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { type ValStat } from "../valstat.ts";
|
|
6
|
-
import { type DHKEReq, type DHKEResp } from "./pairing.ts";
|
|
7
|
-
import { type LargeBlobCreateOpts, type LargeBlobRp } from "../webauthn/largeBlob.ts";
|
|
8
|
-
import { type PrfCeremony, type PrfCreateOpts, type PrfEvalOpts, type PrfRp } from "../webauthn/prf.ts";
|
|
9
|
-
export type { LargeBlobCreateOpts, LargeBlobRp };
|
|
10
|
-
export type { PrfCreateOpts, PrfEvalOpts, PrfRp };
|
|
11
|
-
/** Options for PRF seal/unseal ceremonies (no raw PRF bytes). */
|
|
12
|
-
export type PasskeyPrfOpts = PrfCreateOpts & {
|
|
13
|
-
credId?: Uint8Array | readonly Uint8Array[];
|
|
14
|
-
/** Seal only: create a PRF credential first when no credId is known. */
|
|
15
|
-
createCredIfNeeded?: boolean;
|
|
16
|
-
};
|
|
17
|
-
/** One binding to try on unseal (cred id + sealed master). */
|
|
18
|
-
export type PrfBinding = {
|
|
19
|
-
sealedMaster: SealedMasterKey;
|
|
20
|
-
credId: Uint8Array;
|
|
21
|
-
};
|
|
22
|
-
/** Durable PRF-sealed master + public ceremony facts (never includes PRF output). */
|
|
23
|
-
export type PrfSealedMaster = PrfCeremony & {
|
|
24
|
-
sealedMaster: SealedMasterKey;
|
|
25
|
-
salt: Uint8Array;
|
|
26
|
-
};
|
|
27
|
-
/** One existing keyring member used to prove this enclave matches the list. */
|
|
28
|
-
export type BindPrior = {
|
|
29
|
-
credId: Uint8Array;
|
|
30
|
-
tag: Uint8Array;
|
|
31
|
-
};
|
|
32
|
-
/** Seal + bind-tag from {@link Enclave.bind} (tag is not a global fingerprint). */
|
|
33
|
-
export type PrfBound = PrfSealedMaster & {
|
|
34
|
-
tag: Uint8Array;
|
|
35
|
-
};
|
|
36
|
-
export type EncryptCipher = {
|
|
37
|
-
encrypt: (data: Uint8Array) => Promise<Uint8Array>;
|
|
38
|
-
};
|
|
39
|
-
export type DecryptCipher = {
|
|
40
|
-
decrypt: (data: Uint8Array) => Promise<Uint8Array>;
|
|
41
|
-
};
|
|
42
|
-
/** Encrypt + decrypt capability for one KDM. */
|
|
43
|
-
export type DerivedCipher = EncryptCipher & DecryptCipher;
|
|
44
|
-
/** Which ops the caller needs; only those methods are present on the handle. */
|
|
45
|
-
export type CipherUsage = "encrypt" | "decrypt" | "both";
|
|
46
|
-
/** Return shape of `deriveCipher` for a given usage (type-level enforcement). */
|
|
47
|
-
export type CipherForUsage<U extends CipherUsage> = {
|
|
48
|
-
encrypt: EncryptCipher;
|
|
49
|
-
decrypt: DecryptCipher;
|
|
50
|
-
both: DerivedCipher;
|
|
51
|
-
}[U];
|
|
52
|
-
/**
|
|
53
|
-
* Path-scoped signing identity: public key is public; sign/kdmFor re-enter
|
|
54
|
-
* the enclave so the private key never leaves. Used for hosts, export files, etc.
|
|
55
|
-
*/
|
|
56
|
-
export type Identity = {
|
|
57
|
-
readonly publicKey: PublicKey;
|
|
58
|
-
sign: (message: Uint8Array | string) => Promise<Uint8Array>;
|
|
59
|
-
/** Per-bag KDM mixed with this identity's private key (see bag seal). */
|
|
60
|
-
kdmFor: (msgHeadEnc: Uint8Array) => Promise<Uint8Array>;
|
|
61
|
-
};
|
|
62
|
-
declare const SEAL_BIND_DOMAIN: Uint8Array<ArrayBufferLike>;
|
|
63
|
-
declare const FP_MODE: Uint8Array<ArrayBufferLike>;
|
|
64
|
-
declare const SEAL_KEY_LEN = 32;
|
|
65
|
-
declare const SEAL_PRF_MIN_LEN = 16;
|
|
10
|
+
import { PairRequest } from "./pairing.ts";
|
|
11
|
+
import { BagManager } from "./bagman.ts";
|
|
66
12
|
/** Minimum musec length (Mandatory User-Space Entropy Contribution). */
|
|
67
|
-
declare const MUSEC_MIN_LEN = 32;
|
|
68
|
-
declare
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
wipe(): void;
|
|
73
|
-
get dhkeReq(): DHKEReq;
|
|
74
|
-
finish(dhkeResp: DHKEResp): Promise<ValStat<{
|
|
75
|
-
enclave: Enclave;
|
|
76
|
-
hosts: BundleHost[];
|
|
77
|
-
}>>;
|
|
78
|
-
}
|
|
79
|
-
export type { PairRequest };
|
|
13
|
+
export declare const MUSEC_MIN_LEN = 32;
|
|
14
|
+
export declare function fromSeedHosts(buf: Uint8Array): ValStat<{
|
|
15
|
+
enclave: OuterEnclave;
|
|
16
|
+
hosts: BundleHost[];
|
|
17
|
+
}>;
|
|
80
18
|
/** Brand `bytes` as {@link MasterSeed} only if length is {@link MASTER_SEED_LEN}. */
|
|
81
19
|
export declare function asMasterSeed(bytes: Uint8Array): ValStat<MasterSeed>;
|
|
82
|
-
|
|
20
|
+
declare class OuterEnclave {
|
|
83
21
|
#private;
|
|
84
22
|
private constructor();
|
|
85
23
|
/**
|
|
86
24
|
* New enclave: blake3(OS CSPRNG ‖ musec). musec is required (MUSEC_MIN_LEN).
|
|
87
|
-
*
|
|
25
|
+
* Musec is wiped on every return, including rejection and a throw from the
|
|
26
|
+
* OS generator. A rejected digest is wiped. The stored seed is that digest
|
|
27
|
+
* buffer, so the success path must not wipe it.
|
|
88
28
|
*/
|
|
89
|
-
static fromRandom(musec: Uint8Array): Promise<ValStat<
|
|
29
|
+
static fromRandom(musec: Uint8Array): Promise<ValStat<OuterEnclave>>;
|
|
90
30
|
/**
|
|
91
31
|
* Construct from raw master seed bytes (import / bootstrap only).
|
|
92
32
|
* Copies the seed so callers may zero their buffer after success.
|
|
93
33
|
* Prefer {@link fromRandom} or {@link unsealWithPasskey} for normal flows.
|
|
94
34
|
*/
|
|
95
|
-
static fromBytes(bytes: Uint8Array): ValStat<
|
|
35
|
+
static fromBytes(bytes: Uint8Array): ValStat<OuterEnclave>;
|
|
96
36
|
/**
|
|
97
37
|
* UV + PRF ceremony, then AEAD-seal master. Returns sealed ciphertext + public
|
|
98
38
|
* meta only — never PRF output. Sealed blob on disk is useless without a
|
|
@@ -102,7 +42,7 @@ export declare class Enclave {
|
|
|
102
42
|
*/
|
|
103
43
|
sealWithPasskey(opts?: PasskeyPrfOpts): Promise<ValStat<PrfSealedMaster>>;
|
|
104
44
|
/**
|
|
105
|
-
* UV + PRF seal, plus a per-cred bind tag (
|
|
45
|
+
* UV + PRF seal, plus a per-cred bind tag (bindtag PDK child keyed by credId).
|
|
106
46
|
* Tag compute and compare stay in the enclave. If `prior` is non-empty, every
|
|
107
47
|
* stored tag must match this master or bind fails (one keyring, one master).
|
|
108
48
|
*/
|
|
@@ -114,23 +54,23 @@ export declare class Enclave {
|
|
|
114
54
|
static unsealWithPasskey(bindings: readonly PrfBinding[], opts: PasskeyPrfOpts & {
|
|
115
55
|
salt: Uint8Array;
|
|
116
56
|
}): Promise<ValStat<{
|
|
117
|
-
enclave:
|
|
57
|
+
enclave: OuterEnclave;
|
|
118
58
|
credId: Uint8Array;
|
|
119
59
|
}>>;
|
|
120
60
|
/**
|
|
121
61
|
* AEAD-seal master under caller-supplied PRF IKM (CLI hmac-secret).
|
|
122
62
|
* Wipes `ikm` before return. Ciphertext only — never the seed.
|
|
123
63
|
*/
|
|
124
|
-
|
|
64
|
+
sealWithIKM(ikm: Uint8Array): Promise<ValStat<SealedMasterKey>>;
|
|
125
65
|
/**
|
|
126
66
|
* Unseal a PRF binding given IKM (CLI hmac-secret eval). Returns Enclave.
|
|
127
67
|
* Wipes `ikm` before return.
|
|
128
68
|
*/
|
|
129
|
-
static
|
|
69
|
+
static unsealWithIKM(sealed: SealedMasterKey, ikm: Uint8Array): Promise<ValStat<OuterEnclave>>;
|
|
130
70
|
/**
|
|
131
71
|
* UV + write IdentityBundle (seed + hosts) to largeBlob.
|
|
132
|
-
*
|
|
133
|
-
* is returned. Prefer empty `hosts` for seed-only backup.
|
|
72
|
+
* Inner encodes the wire and {@link writeLargeBlob} does the UV write.
|
|
73
|
+
* Nothing seed-bearing is returned. Prefer empty `hosts` for seed-only backup.
|
|
134
74
|
*
|
|
135
75
|
* Pass `opts.credId` to write an existing credential (one UV). Omit it to
|
|
136
76
|
* create a largeBlob-capable credential then write (two UV). Returns the
|
|
@@ -149,7 +89,7 @@ export declare class Enclave {
|
|
|
149
89
|
static fromLargeBlob(opts?: LargeBlobRp & {
|
|
150
90
|
credId?: Uint8Array;
|
|
151
91
|
}): Promise<ValStat<{
|
|
152
|
-
enclave:
|
|
92
|
+
enclave: OuterEnclave;
|
|
153
93
|
hosts: BundleHost[];
|
|
154
94
|
credId: Uint8Array;
|
|
155
95
|
}>>;
|
|
@@ -160,7 +100,7 @@ export declare class Enclave {
|
|
|
160
100
|
* Paced mode erases the previous line before the next (Enter between).
|
|
161
101
|
* Web bundles set DIP_CLI_DUMP=false; the write is compiled out.
|
|
162
102
|
*/
|
|
163
|
-
|
|
103
|
+
dumpToTTY(): Promise<Status>;
|
|
164
104
|
static pairRequest(): Promise<ValStat<PairRequest>>;
|
|
165
105
|
/**
|
|
166
106
|
* Seals seed+hosts for dhkeReq. Returns dhkeResp to send back.
|
|
@@ -186,18 +126,7 @@ export declare class Enclave {
|
|
|
186
126
|
id: number;
|
|
187
127
|
persist?: boolean;
|
|
188
128
|
}): Worker;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
* enclave (async, hardware-shaped). `usage` selects the return shape:
|
|
192
|
-
* `"encrypt"` → `{ encrypt }`, `"decrypt"` → `{ decrypt }`, `"both"` → both.
|
|
193
|
-
*/
|
|
194
|
-
deriveCipher<U extends CipherUsage>(kdm: Uint8Array, usage: U): CipherForUsage<U>;
|
|
195
|
-
/**
|
|
196
|
-
* Path-scoped identity (label+index). Private key stays in the enclave; only
|
|
197
|
-
* publicKey and capability methods are returned (frozen).
|
|
198
|
-
*/
|
|
199
|
-
deriveIdentity(keyPath: string, idx?: number): Promise<Identity>;
|
|
129
|
+
bagman(idKDM: IKDM, realmKDM: IKDM): Promise<ValStat<BagManager>>;
|
|
130
|
+
fingerprint(kdm?: Uint8Array | IKDM): Promise<ValStat<PDK["Fingerprint"]>>;
|
|
200
131
|
}
|
|
201
|
-
|
|
202
|
-
export declare function sealKeyFromPrf(crypto: ICrypto, prf: Uint8Array, domain?: Uint8Array): Promise<ValStat<Uint8Array>>;
|
|
203
|
-
export { FP_MODE, MASTER_SEED_LEN, MUSEC_MIN_LEN, SEAL_BIND_DOMAIN, SEAL_KEY_LEN, SEAL_PRF_MIN_LEN, };
|
|
132
|
+
export { OuterEnclave as Enclave };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Status } from "../consts.ts";
|
|
2
|
+
import { type ValStat } from "../valstat.ts";
|
|
3
|
+
import { type LargeBlobCreateOpts, type LargeBlobRp } from "../webauthn/largeBlob.ts";
|
|
4
|
+
export declare function largeBlobCredId(opts?: LargeBlobCreateOpts & {
|
|
5
|
+
credId?: Uint8Array;
|
|
6
|
+
}): Promise<ValStat<Uint8Array>>;
|
|
7
|
+
export declare function writeLargeBlob(credId: Uint8Array, data: Uint8Array, opts?: LargeBlobRp): Promise<Status>;
|
|
8
|
+
export declare function wipeLargeBlob(credId: Uint8Array, opts?: LargeBlobRp): Promise<Status>;
|