@pacspace-io/check 0.5.5 → 0.6.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/CHANGELOG.md +27 -1
- package/README.md +36 -2
- package/dist/check.d.ts +6 -1
- package/dist/cli.d.ts +5 -1
- package/dist/cli.js +2496 -380
- package/dist/index.js +518 -91
- package/dist/inputs.txt +12 -0
- package/dist/open-io.d.ts +38 -0
- package/dist/open.d.ts +16 -15
- package/dist/records-crypto-types/records/flag-threads-v1.d.ts +53 -0
- package/dist/records-crypto-types/records/labels.d.ts +37 -0
- package/dist/records-crypto-types/records/link-handle-v1.d.ts +16 -0
- package/dist/records-crypto-types/records/reader-crypto-v1.d.ts +198 -0
- package/dist/records-crypto-types/records/reader-link-v1.d.ts +164 -0
- package/dist/records-crypto-types/records/shared-record-ack-v2.d.ts +72 -0
- package/dist/records-crypto-types/records/trail-index-v1.d.ts +89 -0
- package/dist/records-crypto-types/records/trail-rule.d.ts +54 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/ack-flag-notes-v1.d.ts +57 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/flag-notes-v1.d.ts +55 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/index.d.ts +3 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/reader-wraps-v1.d.ts +83 -0
- package/dist/records-crypto-types/records-crypto/disclosure-envelope-v1.d.ts +1 -1
- package/dist/records-crypto-types/records-crypto/index.d.ts +1 -1
- package/dist/records-crypto-types/records-crypto/records-encryption-v1.d.ts +1 -0
- package/dist/records-crypto.js +547 -66
- package/dist/report.d.ts +20 -1
- package/dist/shared-record-link.d.ts +121 -0
- package/dist/shared-record-words.d.ts +97 -0
- package/package.json +1 -1
package/dist/inputs.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
../shared/src/chain/rpc-guarded-send.ts
|
|
1
2
|
../shared/src/chain/rpc-provider.ts
|
|
2
3
|
../shared/src/demo/independent-verify-records.ts
|
|
3
4
|
../shared/src/demo/mirror-node-record-chain-reader.ts
|
|
@@ -30,7 +31,9 @@
|
|
|
30
31
|
../shared/src/records/layouts.generated.ts
|
|
31
32
|
../shared/src/records/layouts.ts
|
|
32
33
|
../shared/src/records/ledger-write-search-v1.ts
|
|
34
|
+
../shared/src/records/link-handle-v1.ts
|
|
33
35
|
../shared/src/records/model-record-link-v1.ts
|
|
36
|
+
../shared/src/records/reader-crypto-v1.ts
|
|
34
37
|
../shared/src/records/record-content-v1.ts
|
|
35
38
|
../shared/src/records/record-entry-kind-v1.ts
|
|
36
39
|
../shared/src/records/record-history-bundle-v1.ts
|
|
@@ -38,10 +41,19 @@
|
|
|
38
41
|
../shared/src/records/record-history-bundle-v3.ts
|
|
39
42
|
../shared/src/records/record-link-copy-v1.ts
|
|
40
43
|
../shared/src/records/record-seal-history-v1.ts
|
|
44
|
+
../shared/src/records/shared-record-check-v1.ts
|
|
45
|
+
../shared/src/records/shared-record-copy-v1.ts
|
|
46
|
+
../shared/src/records/shared-record-list-v1.ts
|
|
47
|
+
../shared/src/records/shared-record-pace-v1.ts
|
|
48
|
+
../shared/src/records/shared-record-v2.ts
|
|
49
|
+
../shared/src/records/signed-acknowledgment-v2.ts
|
|
41
50
|
scripts/shared-surface.ts
|
|
42
51
|
src/check.ts
|
|
43
52
|
src/cli.ts
|
|
53
|
+
src/open-io.ts
|
|
44
54
|
src/open.ts
|
|
45
55
|
src/release.ts
|
|
46
56
|
src/report.ts
|
|
57
|
+
src/shared-record-link.ts
|
|
58
|
+
src/shared-record-words.ts
|
|
47
59
|
src/writes.ts
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CliIo } from './cli';
|
|
2
|
+
/**
|
|
3
|
+
* What `open` and a kept copy's check share: how a run ends early, small files, new files, and a link host's
|
|
4
|
+
* answers read within a bound. Nothing here prints a handle, a code, a key or a session.
|
|
5
|
+
*/
|
|
6
|
+
/** W-L2g-15 */
|
|
7
|
+
export declare const hostUnreachableSentence: (host: string) => string;
|
|
8
|
+
/** W-L2g-16 */
|
|
9
|
+
export declare const NO_KEY_SENTENCE = "This link reveals fields, but it has no key after #. Ask the sender for the whole link.";
|
|
10
|
+
/** W-L2g-21 */
|
|
11
|
+
export declare const pathExistsSentence: (path: string) => string;
|
|
12
|
+
/** W-L2g-22 */
|
|
13
|
+
export declare const savedReportSentence: (path: string) => string;
|
|
14
|
+
/** Ends the run with this exit code, its sentence on stderr. */
|
|
15
|
+
export declare class OpenStop extends Error {
|
|
16
|
+
readonly exitCode: 1 | 2 | 3;
|
|
17
|
+
constructor(message: string, exitCode: 1 | 2 | 3);
|
|
18
|
+
}
|
|
19
|
+
/** The first line of a small file. */
|
|
20
|
+
export declare function firstLineOf(io: CliIo, path: string): Promise<string>;
|
|
21
|
+
/** A new file only its owner reads; an existing path is refused. */
|
|
22
|
+
export declare function writeNew(io: CliIo, path: string, bytes: Uint8Array): Promise<void>;
|
|
23
|
+
/** Text from a host or a file with no control character, so none reaches the screen. */
|
|
24
|
+
export declare const withoutControls: (text: string) => string;
|
|
25
|
+
export declare const escapeHtml: (text: string) => string;
|
|
26
|
+
/** A refusal as a link host words it: its code, its sentence and the wait it names, from the body alone. */
|
|
27
|
+
export interface Refusal {
|
|
28
|
+
code: string | null;
|
|
29
|
+
message: string | null;
|
|
30
|
+
retryAfterSeconds: number | null;
|
|
31
|
+
}
|
|
32
|
+
export declare function refusalOfBody(body: unknown): Refusal;
|
|
33
|
+
/** A refusal's own sentence and code, as the link host serves it; control characters dropped. */
|
|
34
|
+
export declare function refusalOf(response: Response): Promise<Refusal>;
|
|
35
|
+
/** An answer's body, read no further than `max` bytes. Null when it is longer, or says it is. */
|
|
36
|
+
export declare function bodyWithin(response: Response, max: number): Promise<Uint8Array | null>;
|
|
37
|
+
/** `Retry-After` as seconds, from the header or the body; null when neither names a wait. */
|
|
38
|
+
export declare function retryAfterSecondsOf(response: Response, refusal: Refusal): number | null;
|
package/dist/open.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { type CheckOptions, type RevealedEntry } from './check';
|
|
2
2
|
import type { CliIo } from './cli';
|
|
3
3
|
import { type CheckReport } from './report';
|
|
4
|
+
export { hostUnreachableSentence, NO_KEY_SENTENCE, pathExistsSentence, savedReportSentence } from './open-io';
|
|
4
5
|
/**
|
|
5
|
-
* `pacspace-check open` (ADR 0015 section 8, layer 2; L2g design D2): reads
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* `pacspace-check open` (ADR 0015 section 8, layer 2; L2g design D2; ADR 0021): reads a Shared Record link the
|
|
7
|
+
* way the Shared Record does and checks what it serves.
|
|
8
|
+
*
|
|
9
|
+
* The address is read first, and the handle is the one in it, never one from an answer. Every request goes to one
|
|
10
|
+
* origin: the link's own, or the app host for an address on the key host, which serves files only. That origin is
|
|
11
|
+
* named before anything is asked of it, and named as not PacSpace's, before a code is asked for and again beside
|
|
12
|
+
* the result, when it is not. No redirect is followed, and the part after # never leaves this machine.
|
|
13
|
+
*
|
|
14
|
+
* What the handle answers as decides the rest. A link with a list of records is checked record by record
|
|
15
|
+
* (`shared-record-link.ts`). A link to one record has its revealed fields opened with the key after # and is
|
|
16
|
+
* checked as a kept copy. The access code goes only to the route that takes it; it, the key and the session are
|
|
17
|
+
* never printed or written.
|
|
12
18
|
*/
|
|
13
19
|
/** W-L2g-11 */
|
|
14
20
|
export declare const LINK_PROMPT = "Paste the link, then press Enter:";
|
|
@@ -18,20 +24,12 @@ export declare const LINK_IN_ARGV_SENTENCE = "The link was given on the command
|
|
|
18
24
|
export declare const NOT_A_LINK_SENTENCE = "This is not a PacSpace record link. A record link looks like https://<host>/c/<handle>/.";
|
|
19
25
|
/** W-L2g-14 */
|
|
20
26
|
export declare const ACCESS_CODE_PROMPT = "This link asks for an access code. Type it, then press Enter:";
|
|
21
|
-
/** W-L2g-15 */
|
|
22
|
-
export declare const hostUnreachableSentence: (host: string) => string;
|
|
23
|
-
/** W-L2g-16 */
|
|
24
|
-
export declare const NO_KEY_SENTENCE = "This link reveals fields, but it has no key after #. Ask the sender for the whole link.";
|
|
25
27
|
/** W-L2g-17 */
|
|
26
28
|
export declare const KEY_DOES_NOT_OPEN_SENTENCE = "The revealed fields didn't open with this link's key. Ask the sender for the whole link.";
|
|
27
29
|
/** W-L2g-18 */
|
|
28
30
|
export declare const REVEALED_HEADER = "Revealed fields";
|
|
29
31
|
/** W-L2g-20 */
|
|
30
32
|
export declare const savedCopySentence: (path: string) => string;
|
|
31
|
-
/** W-L2g-21 */
|
|
32
|
-
export declare const pathExistsSentence: (path: string) => string;
|
|
33
|
-
/** W-L2g-22 */
|
|
34
|
-
export declare const savedReportSentence: (path: string) => string;
|
|
35
33
|
export interface OpenArgs {
|
|
36
34
|
link: string | null;
|
|
37
35
|
linkFile: string | null;
|
|
@@ -39,6 +37,8 @@ export interface OpenArgs {
|
|
|
39
37
|
copy: string | null;
|
|
40
38
|
html: string | null;
|
|
41
39
|
source: CheckOptions['source'];
|
|
40
|
+
/** A link with a list of records only: read each contract's whole log. */
|
|
41
|
+
full: boolean;
|
|
42
42
|
timeoutMs: number | undefined;
|
|
43
43
|
json: boolean;
|
|
44
44
|
}
|
|
@@ -51,5 +51,6 @@ export declare function renderOpenHtml(input: {
|
|
|
51
51
|
revealed: RevealedEntry[];
|
|
52
52
|
version: string;
|
|
53
53
|
now: Date;
|
|
54
|
+
notice?: string | null;
|
|
54
55
|
}): string;
|
|
55
56
|
export declare function runOpen(argv: string[], io: CliIo): Promise<number>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type NoteNameV1, type SealedNoteV1 } from './reader-crypto-v1';
|
|
2
|
+
export declare const FLAG_REF_PATTERN_V1: RegExp;
|
|
3
|
+
export declare const FLAG_RESULTS_V1: readonly ["matches", "does-not-match", "copy-differs"];
|
|
4
|
+
export type FlagResultV1 = (typeof FLAG_RESULTS_V1)[number];
|
|
5
|
+
export type FlagStatusV1 = 'open' | 'answered' | 'closed';
|
|
6
|
+
export declare const FLAG_TEXT_MAX_V1 = 2000;
|
|
7
|
+
export declare const FLAG_SEALED_NOTE_MAX_CHARS_V1: number;
|
|
8
|
+
export declare const FLAG_DRAFTS_MAX_V1 = 100;
|
|
9
|
+
export declare const FLAG_DRAFT_NOTE_MAX_V1 = 500;
|
|
10
|
+
export declare const PLAIN_NOTE_SCHEMA_V1: "plain-note/v1";
|
|
11
|
+
export declare const FLAG_DRAFTS_SCHEMA_V1: "flag-drafts/v1";
|
|
12
|
+
export declare function flagRefV1(n: number): string;
|
|
13
|
+
export declare function flagNoteNameV1(input: {
|
|
14
|
+
handle: string;
|
|
15
|
+
kind: 'answer' | 'reply';
|
|
16
|
+
ref: string;
|
|
17
|
+
n: number;
|
|
18
|
+
}): NoteNameV1;
|
|
19
|
+
export declare function flagDraftsNoteNameV1(input: {
|
|
20
|
+
handle: string;
|
|
21
|
+
reference: string;
|
|
22
|
+
version: number;
|
|
23
|
+
}): NoteNameV1;
|
|
24
|
+
export declare function readFlagTextV1(value: unknown): string | null;
|
|
25
|
+
export interface PlainNoteV1 {
|
|
26
|
+
schema: typeof PLAIN_NOTE_SCHEMA_V1;
|
|
27
|
+
text: string;
|
|
28
|
+
salt: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function plainNoteV1(value: string): PlainNoteV1;
|
|
31
|
+
export declare function readPlainNoteV1(value: unknown): {
|
|
32
|
+
ok: true;
|
|
33
|
+
text: string;
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
};
|
|
37
|
+
export declare function readFlagSealedNoteV1(value: unknown): SealedNoteV1 | null;
|
|
38
|
+
export declare function flagNoteDigestV1(note: SealedNoteV1 | PlainNoteV1): Promise<string>;
|
|
39
|
+
export interface FlagDraftV1 {
|
|
40
|
+
record: number;
|
|
41
|
+
entry: number;
|
|
42
|
+
note: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface FlagDraftsV1 {
|
|
45
|
+
schema: typeof FLAG_DRAFTS_SCHEMA_V1;
|
|
46
|
+
flags: FlagDraftV1[];
|
|
47
|
+
}
|
|
48
|
+
export declare function readFlagDraftsV1(value: unknown): {
|
|
49
|
+
ok: true;
|
|
50
|
+
drafts: FlagDraftsV1;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const LABEL_PAIR_RE: RegExp;
|
|
2
|
+
export declare const LABELS_MAX = 10;
|
|
3
|
+
export declare const LABEL_KEY_RE: RegExp;
|
|
4
|
+
export declare const LABEL_VALUE_RE: RegExp;
|
|
5
|
+
export declare const BLINDED_LABEL_RE: RegExp;
|
|
6
|
+
export type PlainLabels = Record<string, string>;
|
|
7
|
+
export type BlindedLabels = {
|
|
8
|
+
b: string[];
|
|
9
|
+
};
|
|
10
|
+
export type StoredLabels = PlainLabels | BlindedLabels;
|
|
11
|
+
export declare function parseLabels(input: unknown): PlainLabels;
|
|
12
|
+
export declare function labelsUnreadable(input: unknown): boolean;
|
|
13
|
+
export type LabelsCheck = {
|
|
14
|
+
ok: true;
|
|
15
|
+
kind: 'plain';
|
|
16
|
+
labels: PlainLabels;
|
|
17
|
+
} | {
|
|
18
|
+
ok: true;
|
|
19
|
+
kind: 'blinded';
|
|
20
|
+
labels: string[];
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
code: 'RECORD_LABELS_INVALID';
|
|
24
|
+
};
|
|
25
|
+
export declare function checkLabels(input: unknown): LabelsCheck;
|
|
26
|
+
export type LabelsMerge = {
|
|
27
|
+
ok: true;
|
|
28
|
+
labels: StoredLabels;
|
|
29
|
+
changed: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
ok: false;
|
|
32
|
+
code: 'RECORD_LABEL_CONFLICT' | 'RECORD_LABELS_INVALID';
|
|
33
|
+
};
|
|
34
|
+
export declare function isBlindedLabels(stored: unknown): stored is BlindedLabels;
|
|
35
|
+
export declare function mergeLabels(stored: unknown, incoming: Exclude<LabelsCheck, {
|
|
36
|
+
ok: false;
|
|
37
|
+
}>): LabelsMerge;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const LINK_HANDLE_PREFIX = "csh1_";
|
|
2
|
+
export declare const LIST_HANDLE_PREFIX = "csl1_";
|
|
3
|
+
export declare const LINK_HANDLE_PREFIXES: readonly ["csh1_", "csl1_"];
|
|
4
|
+
export type LinkHandlePrefix = (typeof LINK_HANDLE_PREFIXES)[number];
|
|
5
|
+
export declare const LINK_HANDLE_PATTERN: RegExp;
|
|
6
|
+
export declare const LINK_HANDLE_PREFIX_SOURCE = "cs[hl]1_";
|
|
7
|
+
export declare const LINK_HANDLE_ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
|
|
8
|
+
export interface LinkHandlePartsV1 {
|
|
9
|
+
handle: string;
|
|
10
|
+
prefix: LinkHandlePrefix;
|
|
11
|
+
body: string;
|
|
12
|
+
checksum: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function normalizeLinkHandleV1(text: unknown): string | null;
|
|
15
|
+
export declare function linkHandlePartsV1(handle: string): LinkHandlePartsV1 | null;
|
|
16
|
+
export declare function hasListHandlePrefixV1(handle: unknown): boolean;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { type RecordDisclosure } from '../records-crypto/record-disclosure-v1';
|
|
2
|
+
import type { SigningPublicKeyJwkV1 } from './signed-acknowledgment-v1';
|
|
3
|
+
export declare const READER_CRYPTO_LABELS_V1: {
|
|
4
|
+
readonly deviceId: "pacspace:reader-device:v1";
|
|
5
|
+
readonly proofKey: "pacspace:device-proof-key:v1";
|
|
6
|
+
readonly deviceProof: "pacspace:device-proof:v1";
|
|
7
|
+
readonly deviceConfirmed: "pacspace:device-confirmed:v1";
|
|
8
|
+
readonly deviceApproval: "pacspace:device-approval:v1";
|
|
9
|
+
readonly signedRequest: "pacspace:signed-request:v1";
|
|
10
|
+
readonly deviceDisconnect: "pacspace:device-disconnect:v1";
|
|
11
|
+
readonly sealedNote: "pacspace:sealed-note:v1";
|
|
12
|
+
readonly workspaceKey: "pacspace:workspace-key:v1";
|
|
13
|
+
};
|
|
14
|
+
export declare const SEALED_NOTE_SCHEMA_V1: "sealed-note/v1";
|
|
15
|
+
export declare const SAMPLE_METHOD_V1: "pacspace-sample/v1";
|
|
16
|
+
export declare const DEVICE_XWING_PUBLIC_KEY_BYTES_V1 = 1216;
|
|
17
|
+
export declare const DEVICE_P256_SPKI_BYTES_V1 = 91;
|
|
18
|
+
export declare const DEVICE_CODE_DIGITS_V1 = 40;
|
|
19
|
+
export declare const LINK_KEY_BYTES_V1 = 32;
|
|
20
|
+
export declare const SAMPLE_SEED_HEX_V1: RegExp;
|
|
21
|
+
export declare const SEALED_NOTE_MAX_CHARS_V1 = 65536;
|
|
22
|
+
export type ReaderCryptoCodeV1 = 'READER_BINDING_INVALID' | 'READER_DEVICE_KEYS_INVALID' | 'READER_KEY_INVALID' | 'SEALED_NOTE_MALFORMED';
|
|
23
|
+
export declare class ReaderCryptoError extends Error {
|
|
24
|
+
readonly code: ReaderCryptoCodeV1;
|
|
25
|
+
constructor(code: ReaderCryptoCodeV1);
|
|
26
|
+
}
|
|
27
|
+
export declare function linkKeyBindingV1(handle: string, epoch: number): string;
|
|
28
|
+
export declare function revealBindingV1(handle: string, epoch: number, recordKey: string): string;
|
|
29
|
+
export declare function answerKeyBindingV1(handle: string, requestRef: string): string;
|
|
30
|
+
export declare function answerEntryBindingV1(handle: string, requestRef: string, number: number, seq: number): string;
|
|
31
|
+
export type NoteScopeV1 = {
|
|
32
|
+
handle: string;
|
|
33
|
+
} | {
|
|
34
|
+
trailRuleOf: string;
|
|
35
|
+
};
|
|
36
|
+
export interface NoteNameV1 {
|
|
37
|
+
scope: NoteScopeV1;
|
|
38
|
+
kind: string;
|
|
39
|
+
ref: string;
|
|
40
|
+
n: number;
|
|
41
|
+
}
|
|
42
|
+
export declare function noteKeyBindingV1(name: NoteNameV1): string;
|
|
43
|
+
export declare function noteAdditionalDataV1(name: NoteNameV1): string;
|
|
44
|
+
export declare function ackFlagNotesKeyNameV1(handle: string, checkRef: string): NoteNameV1;
|
|
45
|
+
export declare function ackFlagNoteNameV1(handle: string, checkRef: string, record: number, entry: number): NoteNameV1;
|
|
46
|
+
export declare function ackNoteNameV1(handle: string, checkRef: string): NoteNameV1;
|
|
47
|
+
export interface DevicePublicKeysV1 {
|
|
48
|
+
xwingPublicKey: Uint8Array;
|
|
49
|
+
p256Jwk: SigningPublicKeyJwkV1;
|
|
50
|
+
mldsaPublicKey: Uint8Array;
|
|
51
|
+
}
|
|
52
|
+
export declare function p256SpkiOfJwkV1(jwk: SigningPublicKeyJwkV1): Promise<Uint8Array>;
|
|
53
|
+
export declare function deviceIdV1(keys: DevicePublicKeysV1): Promise<string>;
|
|
54
|
+
export declare function deviceCodeV1(deviceId: string): string;
|
|
55
|
+
export declare function proofKeyV1(linkKey: Uint8Array): Promise<Uint8Array>;
|
|
56
|
+
export declare function deviceProofV1(proofKey: Uint8Array | CryptoKey, handle: string, epoch: number, deviceId: string): Promise<string>;
|
|
57
|
+
export declare function confirmationTagV1(proofKey: Uint8Array | CryptoKey, handle: string, epoch: number, deviceId: string): Promise<string>;
|
|
58
|
+
export interface ReaderLinkKeysV1 {
|
|
59
|
+
revealKey: CryptoKey;
|
|
60
|
+
proofKey: CryptoKey;
|
|
61
|
+
}
|
|
62
|
+
export declare function readerLinkKeysV1(linkKey: Uint8Array): Promise<ReaderLinkKeysV1>;
|
|
63
|
+
export declare function workspaceKeyTagV1(proofKey: Uint8Array | CryptoKey, handle: string, epoch: number, keyId: string): Promise<string>;
|
|
64
|
+
export declare function servedWorkspaceKeyV1(input: {
|
|
65
|
+
proofKey: Uint8Array | CryptoKey;
|
|
66
|
+
handle: string;
|
|
67
|
+
epoch: number;
|
|
68
|
+
publicKey: Uint8Array;
|
|
69
|
+
tag: unknown;
|
|
70
|
+
}): Promise<{
|
|
71
|
+
ok: true;
|
|
72
|
+
keyId: string;
|
|
73
|
+
} | {
|
|
74
|
+
ok: false;
|
|
75
|
+
code: 'WORKSPACE_KEY_NOT_TAGGED';
|
|
76
|
+
}>;
|
|
77
|
+
export declare function servedDevicesV1(input: {
|
|
78
|
+
proofKey: Uint8Array | CryptoKey;
|
|
79
|
+
handle: string;
|
|
80
|
+
epoch: number;
|
|
81
|
+
devices: unknown;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
ok: true;
|
|
84
|
+
devices: Array<{
|
|
85
|
+
deviceId: string;
|
|
86
|
+
xwingPublicKey: Uint8Array;
|
|
87
|
+
}>;
|
|
88
|
+
} | {
|
|
89
|
+
ok: false;
|
|
90
|
+
code: 'DEVICE_NOT_TAGGED';
|
|
91
|
+
}>;
|
|
92
|
+
export declare function approvalMessageV1(handle: string, epoch: number, newDeviceId: string): string;
|
|
93
|
+
export declare function signedRequestDigestV1(body: Readonly<Record<string, unknown>>): Promise<string>;
|
|
94
|
+
export declare function signedRequestMessageV1(handle: string, epoch: number, deviceId: string, requestDigest: string): string;
|
|
95
|
+
export declare function disconnectMessageV1(handle: string, epoch: number, deviceId: string): string;
|
|
96
|
+
export declare function sameHex64V1(a: unknown, b: unknown): boolean;
|
|
97
|
+
export declare function revealRecordV1(input: {
|
|
98
|
+
disclosure: RecordDisclosure;
|
|
99
|
+
linkKey: Uint8Array;
|
|
100
|
+
handle: string;
|
|
101
|
+
epoch: number;
|
|
102
|
+
recordKey: string;
|
|
103
|
+
}): Promise<string>;
|
|
104
|
+
export declare function openRevealV1(input: {
|
|
105
|
+
envelope: string;
|
|
106
|
+
linkKey: Uint8Array | CryptoKey;
|
|
107
|
+
handle: string;
|
|
108
|
+
epoch: number;
|
|
109
|
+
recordKey: string;
|
|
110
|
+
}): Promise<{
|
|
111
|
+
ok: true;
|
|
112
|
+
disclosure: unknown;
|
|
113
|
+
} | {
|
|
114
|
+
ok: false;
|
|
115
|
+
code: import("../records-crypto/disclosure-envelope-v1").DisclosureEnvelopeRefusalV1;
|
|
116
|
+
reason: string;
|
|
117
|
+
}>;
|
|
118
|
+
export declare function sealAnswerEntryV1(input: {
|
|
119
|
+
disclosure: RecordDisclosure;
|
|
120
|
+
answerKey: Uint8Array;
|
|
121
|
+
handle: string;
|
|
122
|
+
requestRef: string;
|
|
123
|
+
number: number;
|
|
124
|
+
seq: number;
|
|
125
|
+
}): Promise<string>;
|
|
126
|
+
export declare function openAnswerEntryV1(input: {
|
|
127
|
+
envelope: string;
|
|
128
|
+
answerKey: Uint8Array;
|
|
129
|
+
handle: string;
|
|
130
|
+
requestRef: string;
|
|
131
|
+
number: number;
|
|
132
|
+
seq: number;
|
|
133
|
+
recordHashVersion: 1 | 2 | 3;
|
|
134
|
+
}): Promise<{
|
|
135
|
+
ok: true;
|
|
136
|
+
disclosure: RecordDisclosure;
|
|
137
|
+
} | {
|
|
138
|
+
ok: false;
|
|
139
|
+
code: string;
|
|
140
|
+
}>;
|
|
141
|
+
export declare function shownFieldsV1(disclosure: RecordDisclosure): Map<number, string[]>;
|
|
142
|
+
export declare function shownFieldsMatchV1(disclosure: RecordDisclosure, seq: number, declared: readonly string[]): boolean;
|
|
143
|
+
export declare function disclosureDigestV1(envelope: string): Promise<string>;
|
|
144
|
+
export interface SealedNoteV1 {
|
|
145
|
+
schema: typeof SEALED_NOTE_SCHEMA_V1;
|
|
146
|
+
iv: string;
|
|
147
|
+
ct: string;
|
|
148
|
+
}
|
|
149
|
+
export declare function readSealedNoteShapeV1(value: unknown): {
|
|
150
|
+
ok: true;
|
|
151
|
+
iv: Uint8Array;
|
|
152
|
+
ct: Uint8Array;
|
|
153
|
+
} | {
|
|
154
|
+
ok: false;
|
|
155
|
+
code: 'SEALED_NOTE_MALFORMED';
|
|
156
|
+
};
|
|
157
|
+
export declare function sealNoteV1(text: string, name: NoteNameV1): Promise<{
|
|
158
|
+
note: SealedNoteV1;
|
|
159
|
+
key: Uint8Array;
|
|
160
|
+
}>;
|
|
161
|
+
export declare function openNoteV1(input: {
|
|
162
|
+
note: unknown;
|
|
163
|
+
key: Uint8Array;
|
|
164
|
+
name: NoteNameV1;
|
|
165
|
+
}): Promise<{
|
|
166
|
+
ok: true;
|
|
167
|
+
text: string;
|
|
168
|
+
} | {
|
|
169
|
+
ok: false;
|
|
170
|
+
code: 'SEALED_NOTE_MALFORMED' | 'SEALED_NOTE_AUTH_FAILED';
|
|
171
|
+
}>;
|
|
172
|
+
export declare function sealedNoteDigestV1(note: SealedNoteV1): Promise<string>;
|
|
173
|
+
export declare function newSampleSeedV1(): string;
|
|
174
|
+
export declare function sampleDrawerV1(seed: string): {
|
|
175
|
+
next(size: number): Promise<number>;
|
|
176
|
+
rejected: number[];
|
|
177
|
+
};
|
|
178
|
+
export type SampleSpreadV1 = 'any' | 'records' | 'days';
|
|
179
|
+
export interface SamplePoolRecordV1 {
|
|
180
|
+
number: number;
|
|
181
|
+
entries: number;
|
|
182
|
+
openedOn: string;
|
|
183
|
+
}
|
|
184
|
+
export interface SamplePickV1 {
|
|
185
|
+
number: number;
|
|
186
|
+
seq: number;
|
|
187
|
+
}
|
|
188
|
+
export declare function samplePoolV1(records: readonly SamplePoolRecordV1[], leftOut: readonly SamplePickV1[]): Array<SamplePickV1 & {
|
|
189
|
+
openedOn: string;
|
|
190
|
+
}>;
|
|
191
|
+
export declare function samplePoolDigestV1(records: readonly SamplePoolRecordV1[]): Promise<string>;
|
|
192
|
+
export declare function drawSampleV1(input: {
|
|
193
|
+
seed: string;
|
|
194
|
+
records: readonly SamplePoolRecordV1[];
|
|
195
|
+
leftOut: readonly SamplePickV1[];
|
|
196
|
+
n: number;
|
|
197
|
+
spread: SampleSpreadV1;
|
|
198
|
+
}): Promise<SamplePickV1[]>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { type PayloadDigestV1 } from './trail-index-v1';
|
|
2
|
+
import type { SharedRecordAckBodyV2 } from './shared-record-ack-v2';
|
|
3
|
+
export declare const READER_LINK_RECORD_TYPE = "machine-action-record";
|
|
4
|
+
export declare const SHARE_REFERENCE_PATTERN: RegExp;
|
|
5
|
+
export declare const SHARE_REFERENCE_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
6
|
+
export declare const SHARE_CODE_PATTERN: RegExp;
|
|
7
|
+
export declare const SHARE_CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
8
|
+
export declare const SHARE_CODE_TRIES = 5;
|
|
9
|
+
export type ReaderLinkKind = 'link-made' | 'allowance-changed' | 'link-extended' | 'person-added' | 'person-removed' | 'link-key-changed' | 'workspace-key-changed' | 'record-revealed' | 'link-turned-off' | 'device-added' | 'device-confirmed' | 'device-removed' | 'request' | 'answer' | 'acknowledgment' | 'flag' | 'flag-message';
|
|
10
|
+
export interface ReaderLinkContentV1 {
|
|
11
|
+
title: string;
|
|
12
|
+
kind: ReaderLinkKind;
|
|
13
|
+
occurredAt: string;
|
|
14
|
+
actorId: string;
|
|
15
|
+
payloads: PayloadDigestV1[];
|
|
16
|
+
references?: Array<{
|
|
17
|
+
recordKey: string;
|
|
18
|
+
seq: number;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export type RevealModeV1 = 'seals' | 'fields' | 'all';
|
|
22
|
+
export type AnswersByV1 = 'people' | 'agent';
|
|
23
|
+
export interface ReaderLinkTermsV1 {
|
|
24
|
+
reference: string;
|
|
25
|
+
allowance: number | null;
|
|
26
|
+
endsOn: string;
|
|
27
|
+
reveal: {
|
|
28
|
+
mode: RevealModeV1;
|
|
29
|
+
fields: string[];
|
|
30
|
+
time: boolean;
|
|
31
|
+
};
|
|
32
|
+
answers: {
|
|
33
|
+
by: AnswersByV1;
|
|
34
|
+
fields: string[];
|
|
35
|
+
};
|
|
36
|
+
responseDays: number | null;
|
|
37
|
+
}
|
|
38
|
+
export declare function readerLinkEntityId(shareId: string): string;
|
|
39
|
+
export declare function shareEventIdempotencyKey(shareId: string, seq: number): string;
|
|
40
|
+
export declare function linkMadeContentV1(input: ReaderLinkTermsV1 & {
|
|
41
|
+
workspaceKeyTag?: string | null;
|
|
42
|
+
at: Date;
|
|
43
|
+
}): ReaderLinkContentV1;
|
|
44
|
+
export declare function workspaceKeyTagPayloadV1(epoch: number, workspaceKeyTag: string): PayloadDigestV1;
|
|
45
|
+
export declare function allowanceChangedContentV1(input: {
|
|
46
|
+
allowance: number | null;
|
|
47
|
+
from: number | null;
|
|
48
|
+
at: Date;
|
|
49
|
+
}): ReaderLinkContentV1;
|
|
50
|
+
export declare function linkExtendedContentV1(input: {
|
|
51
|
+
endsOn: string;
|
|
52
|
+
at: Date;
|
|
53
|
+
}): ReaderLinkContentV1;
|
|
54
|
+
export declare function personChangedContentV1(input: {
|
|
55
|
+
change: 'added' | 'removed';
|
|
56
|
+
count: number;
|
|
57
|
+
epoch: number;
|
|
58
|
+
at: Date;
|
|
59
|
+
}): ReaderLinkContentV1;
|
|
60
|
+
export declare function linkKeyChangedContentV1(input: {
|
|
61
|
+
epoch: number;
|
|
62
|
+
workspaceKeyTag?: string | null;
|
|
63
|
+
at: Date;
|
|
64
|
+
}): ReaderLinkContentV1;
|
|
65
|
+
export declare function workspaceKeyChangedContentV1(input: {
|
|
66
|
+
epoch: number;
|
|
67
|
+
workspaceKeyTag: string;
|
|
68
|
+
at: Date;
|
|
69
|
+
}): ReaderLinkContentV1;
|
|
70
|
+
export declare function workspaceKeyTagCommittedV1(entries: ReadonlyArray<{
|
|
71
|
+
seq: number;
|
|
72
|
+
content: unknown;
|
|
73
|
+
}>, committedEntries: number, epoch: number, tag: string): boolean;
|
|
74
|
+
export declare function lastWorkspaceKeyTagDigestV1(entries: ReadonlyArray<{
|
|
75
|
+
seq: number;
|
|
76
|
+
content: unknown;
|
|
77
|
+
}>, committedEntries: number, epoch: number): string | null;
|
|
78
|
+
export declare function recordRevealedContentV1(input: {
|
|
79
|
+
number: number;
|
|
80
|
+
recordKey: string;
|
|
81
|
+
lastSeq: number;
|
|
82
|
+
envelope: string;
|
|
83
|
+
at: Date;
|
|
84
|
+
}): ReaderLinkContentV1;
|
|
85
|
+
export declare function linkTurnedOffContentV1(input: {
|
|
86
|
+
at: Date;
|
|
87
|
+
}): ReaderLinkContentV1;
|
|
88
|
+
export type DeviceConfirmedByV1 = 'code' | 'proof' | 'device';
|
|
89
|
+
export type DeviceKindV1 = 'browser' | 'agent';
|
|
90
|
+
export declare function deviceChangedContentV1(input: {
|
|
91
|
+
change: 'added' | 'confirmed' | 'removed';
|
|
92
|
+
code: string;
|
|
93
|
+
kind: DeviceKindV1;
|
|
94
|
+
confirmedBy: DeviceConfirmedByV1 | null;
|
|
95
|
+
at: Date;
|
|
96
|
+
}): ReaderLinkContentV1;
|
|
97
|
+
export interface RequestItemV1 {
|
|
98
|
+
number: number;
|
|
99
|
+
seq: number;
|
|
100
|
+
seal: string;
|
|
101
|
+
picked: 'random' | 'chosen' | 'mismatch';
|
|
102
|
+
}
|
|
103
|
+
export interface RequestSampleV1 {
|
|
104
|
+
method: 'pacspace-sample/v1';
|
|
105
|
+
seed: string;
|
|
106
|
+
poolDigest: string;
|
|
107
|
+
poolSize: number;
|
|
108
|
+
leftOut: Array<{
|
|
109
|
+
number: number;
|
|
110
|
+
seq: number;
|
|
111
|
+
}>;
|
|
112
|
+
spread: 'any' | 'records' | 'days';
|
|
113
|
+
removed: Array<{
|
|
114
|
+
number: number;
|
|
115
|
+
seq: number;
|
|
116
|
+
}>;
|
|
117
|
+
}
|
|
118
|
+
export interface RequestManifestV1 {
|
|
119
|
+
ref: string;
|
|
120
|
+
items: RequestItemV1[];
|
|
121
|
+
sample: RequestSampleV1 | null;
|
|
122
|
+
question: string | null;
|
|
123
|
+
beyond: number;
|
|
124
|
+
dueOn: string | null;
|
|
125
|
+
}
|
|
126
|
+
export declare function requestContentV1(input: {
|
|
127
|
+
manifest: RequestManifestV1;
|
|
128
|
+
recordKeys: ReadonlyMap<number, string>;
|
|
129
|
+
at: Date;
|
|
130
|
+
}): ReaderLinkContentV1;
|
|
131
|
+
export type AnswerDeclineV1 = {
|
|
132
|
+
kind: 'legal_hold' | 'personal_data' | 'beyond_sample' | 'past_retention';
|
|
133
|
+
} | {
|
|
134
|
+
kind: 'other';
|
|
135
|
+
note: string;
|
|
136
|
+
};
|
|
137
|
+
export type AnswerItemV1 = {
|
|
138
|
+
number: number;
|
|
139
|
+
seq: number;
|
|
140
|
+
outcome: 'shown';
|
|
141
|
+
declaredFields: string[];
|
|
142
|
+
disclosureDigest: string;
|
|
143
|
+
} | {
|
|
144
|
+
number: number;
|
|
145
|
+
seq: number;
|
|
146
|
+
outcome: 'declined';
|
|
147
|
+
reason: AnswerDeclineV1;
|
|
148
|
+
};
|
|
149
|
+
export interface AnswerManifestV1 {
|
|
150
|
+
ref: string;
|
|
151
|
+
items: AnswerItemV1[];
|
|
152
|
+
replyDigest: string | null;
|
|
153
|
+
sentBy: 'person' | 'agent';
|
|
154
|
+
}
|
|
155
|
+
export declare function answerContentV1(input: {
|
|
156
|
+
manifest: AnswerManifestV1;
|
|
157
|
+
at: Date;
|
|
158
|
+
}): ReaderLinkContentV1;
|
|
159
|
+
export declare const ACKNOWLEDGMENT_REF_PATTERN: RegExp;
|
|
160
|
+
export declare function acknowledgmentContentV1(input: {
|
|
161
|
+
ref: string;
|
|
162
|
+
body: SharedRecordAckBodyV2;
|
|
163
|
+
at: Date;
|
|
164
|
+
}): ReaderLinkContentV1;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type SealedNoteV1 } from './reader-crypto-v1';
|
|
2
|
+
export declare const SHARED_RECORD_ACK_SCHEMA_V2: "shared-record-ack/v2";
|
|
3
|
+
export declare const SHARED_RECORD_ACK_SIGNING_LABEL_V2 = "pacspace:shared-record-ack:v2";
|
|
4
|
+
export declare const SHARED_RECORD_ACK_MAX_CHARS_V2: number;
|
|
5
|
+
export declare const SHARED_RECORD_ACK_NOTE_MAX_V2 = 2000;
|
|
6
|
+
export declare const SHARED_RECORD_ACK_FLAG_NOTE_MAX_V2 = 500;
|
|
7
|
+
export declare const SHARED_RECORD_ACK_SEALED_FLAG_NOTE_MAX_CHARS_V2: number;
|
|
8
|
+
export declare const SHARED_RECORD_ACK_SEALED_NOTE_MAX_CHARS_V2: number;
|
|
9
|
+
export declare const SHARED_RECORD_ACK_LIST_MAX_V2 = 100;
|
|
10
|
+
export declare const SHARED_RECORD_ACK_SAMPLES_MAX_V2 = 20;
|
|
11
|
+
export declare const SHARED_RECORD_ACK_FLAG_RESULTS_V2: readonly ["matches", "does-not-match", "copy-differs"];
|
|
12
|
+
export type SharedRecordAckFlagResultV2 = (typeof SHARED_RECORD_ACK_FLAG_RESULTS_V2)[number];
|
|
13
|
+
export interface SharedRecordAckEntryV2 {
|
|
14
|
+
record: number;
|
|
15
|
+
entry: number;
|
|
16
|
+
}
|
|
17
|
+
export interface SharedRecordAckBodyV2 {
|
|
18
|
+
schema: typeof SHARED_RECORD_ACK_SCHEMA_V2;
|
|
19
|
+
reference: string;
|
|
20
|
+
deviceId: string;
|
|
21
|
+
keyId: string;
|
|
22
|
+
check: {
|
|
23
|
+
ref: string;
|
|
24
|
+
on: string;
|
|
25
|
+
};
|
|
26
|
+
sealHistoryDigest: string;
|
|
27
|
+
disclosureDigest: string | null;
|
|
28
|
+
counts: {
|
|
29
|
+
records: number;
|
|
30
|
+
entries: number;
|
|
31
|
+
matched: number;
|
|
32
|
+
notMatched: number;
|
|
33
|
+
};
|
|
34
|
+
sample: Array<{
|
|
35
|
+
request: string;
|
|
36
|
+
method: 'pacspace-sample/v1';
|
|
37
|
+
seed: string;
|
|
38
|
+
picks: SharedRecordAckEntryV2[];
|
|
39
|
+
}>;
|
|
40
|
+
answers: {
|
|
41
|
+
shown: number;
|
|
42
|
+
declined: number;
|
|
43
|
+
};
|
|
44
|
+
mismatches: SharedRecordAckEntryV2[];
|
|
45
|
+
flags: Array<SharedRecordAckEntryV2 & {
|
|
46
|
+
result: SharedRecordAckFlagResultV2;
|
|
47
|
+
note: string | SealedNoteV1 | null;
|
|
48
|
+
}>;
|
|
49
|
+
declaredFields: Array<{
|
|
50
|
+
request: string;
|
|
51
|
+
asDeclared: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
note: string | SealedNoteV1 | null;
|
|
54
|
+
signedAt: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SharedRecordAckEnvelopeV2 {
|
|
57
|
+
body: SharedRecordAckBodyV2;
|
|
58
|
+
signature: string;
|
|
59
|
+
mldsaSignature: string;
|
|
60
|
+
}
|
|
61
|
+
export declare function readSharedRecordAckFlagTextV2(value: unknown): string | null;
|
|
62
|
+
export declare function readSharedRecordAckNoteTextV2(value: unknown): string | null;
|
|
63
|
+
export declare const isSealedFlagNoteV2: (n: string | SealedNoteV1 | null) => n is SealedNoteV1;
|
|
64
|
+
export declare const ackNotesV2: (body: Pick<SharedRecordAckBodyV2, "note" | "flags">) => Array<string | SealedNoteV1 | null>;
|
|
65
|
+
export declare function readSharedRecordAckV2(value: unknown): {
|
|
66
|
+
ok: true;
|
|
67
|
+
body: SharedRecordAckBodyV2;
|
|
68
|
+
} | {
|
|
69
|
+
ok: false;
|
|
70
|
+
problem: string;
|
|
71
|
+
};
|
|
72
|
+
export declare function sharedRecordAckMessageV2(body: SharedRecordAckBodyV2): string;
|