@pacspace-io/check 0.5.6 → 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.
Files changed (27) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +34 -0
  3. package/dist/cli.d.ts +5 -1
  4. package/dist/cli.js +1993 -121
  5. package/dist/index.js +196 -19
  6. package/dist/inputs.txt +11 -0
  7. package/dist/open-io.d.ts +38 -0
  8. package/dist/open.d.ts +16 -15
  9. package/dist/records-crypto-types/records/flag-threads-v1.d.ts +53 -0
  10. package/dist/records-crypto-types/records/labels.d.ts +37 -0
  11. package/dist/records-crypto-types/records/link-handle-v1.d.ts +16 -0
  12. package/dist/records-crypto-types/records/reader-crypto-v1.d.ts +198 -0
  13. package/dist/records-crypto-types/records/reader-link-v1.d.ts +164 -0
  14. package/dist/records-crypto-types/records/shared-record-ack-v2.d.ts +72 -0
  15. package/dist/records-crypto-types/records/trail-index-v1.d.ts +89 -0
  16. package/dist/records-crypto-types/records/trail-rule.d.ts +54 -0
  17. package/dist/records-crypto-types/records-crypto/asymmetric/ack-flag-notes-v1.d.ts +57 -0
  18. package/dist/records-crypto-types/records-crypto/asymmetric/flag-notes-v1.d.ts +55 -0
  19. package/dist/records-crypto-types/records-crypto/asymmetric/index.d.ts +3 -0
  20. package/dist/records-crypto-types/records-crypto/asymmetric/reader-wraps-v1.d.ts +83 -0
  21. package/dist/records-crypto-types/records-crypto/disclosure-envelope-v1.d.ts +1 -1
  22. package/dist/records-crypto-types/records-crypto/index.d.ts +1 -1
  23. package/dist/records-crypto-types/records-crypto/records-encryption-v1.d.ts +1 -0
  24. package/dist/records-crypto.js +547 -66
  25. package/dist/shared-record-link.d.ts +121 -0
  26. package/dist/shared-record-words.d.ts +97 -0
  27. package/package.json +1 -1
@@ -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;
@@ -0,0 +1,89 @@
1
+ import type { TrailRuleV1 } from './trail-rule';
2
+ export declare const TRAIL_INDEX_RECORD_TYPE = "machine-action-record";
3
+ export declare const TRAIL_INDEX_ACTOR = "pacspace";
4
+ export declare const TRAIL_RULE_SALT_BYTES = 32;
5
+ export type TrailIndexKind = 'rule-committed' | 'rule-changed' | 'scope-reworded' | 'record-joined' | 'record-removed' | 'entry-erased' | 'legal-hold-placed' | 'legal-hold-released';
6
+ export interface PayloadDigestV1 {
7
+ alg: 'sha-256';
8
+ digest: string;
9
+ byteLength: string;
10
+ }
11
+ export interface TrailIndexContentV1 {
12
+ title: string;
13
+ kind: TrailIndexKind;
14
+ occurredAt: string;
15
+ actorId: string;
16
+ payloads: PayloadDigestV1[];
17
+ description?: string;
18
+ note?: string;
19
+ references?: Array<{
20
+ recordKey: string;
21
+ seq: number;
22
+ }>;
23
+ }
24
+ export declare function trailIndexEntityId(trailId: string): string;
25
+ export declare function trailEventIdempotencyKey(trailId: string, seq: number): string;
26
+ export declare function payloadDigestV1(value: unknown): PayloadDigestV1;
27
+ export declare function trailRuleDigestInput(rule: TrailRuleV1, salt: Uint8Array): {
28
+ v: 1;
29
+ rule: TrailRuleV1;
30
+ salt: string;
31
+ };
32
+ export interface TrailJoinFactsV1 {
33
+ recordKey: string;
34
+ lastSeq: number;
35
+ lastSeal: string;
36
+ closedBy: 'code' | 'timeout';
37
+ number: number;
38
+ ruleVersion: number;
39
+ }
40
+ export declare function trailIndexTime(at: Date): string;
41
+ export declare function ruleCommittedContentV1(input: {
42
+ scope: string;
43
+ rule: TrailRuleV1;
44
+ salt: Uint8Array;
45
+ at: Date;
46
+ }): TrailIndexContentV1;
47
+ export declare function ruleChangedContentV1(input: {
48
+ rule: TrailRuleV1;
49
+ salt: Uint8Array;
50
+ reason: string;
51
+ at: Date;
52
+ }): TrailIndexContentV1;
53
+ export declare function scopeRewordedContentV1(input: {
54
+ scope: string;
55
+ reason: string;
56
+ at: Date;
57
+ }): TrailIndexContentV1;
58
+ export declare function recordJoinedContentV1(input: TrailJoinFactsV1 & {
59
+ at: Date;
60
+ }): TrailIndexContentV1;
61
+ export declare function recordRemovedContentV1(input: {
62
+ number: number;
63
+ joinedEvent: number;
64
+ recordKey: string;
65
+ lastSeq: number;
66
+ reason: string;
67
+ at: Date;
68
+ }): TrailIndexContentV1;
69
+ export declare function entryErasedContentV1(input: {
70
+ number: number;
71
+ recordKey: string;
72
+ seq: number;
73
+ reason: string;
74
+ at: Date;
75
+ }): TrailIndexContentV1;
76
+ export declare function legalHoldPlacedContentV1(input: {
77
+ holdId: string;
78
+ on: 'whole' | {
79
+ number: number;
80
+ recordKey: string;
81
+ };
82
+ reason: string;
83
+ at: Date;
84
+ }): TrailIndexContentV1;
85
+ export declare function legalHoldReleasedContentV1(input: {
86
+ holdId: string;
87
+ reason: string;
88
+ at: Date;
89
+ }): TrailIndexContentV1;
@@ -0,0 +1,54 @@
1
+ import { type BlindedLabels, type PlainLabels } from './labels';
2
+ export interface TrailRuleV1 {
3
+ v: 1;
4
+ sources: string[];
5
+ labels: PlainLabels | BlindedLabels;
6
+ from: string;
7
+ earlier: boolean;
8
+ }
9
+ export interface TrailRuleRecord {
10
+ sourceId: string | null;
11
+ openedOn: string;
12
+ labels: unknown;
13
+ }
14
+ export declare const TRAIL_RULE_WORDS: {
15
+ readonly sourcesInvalid: "Choose at least one source in this environment. Nothing was committed.";
16
+ readonly labelsUnreadable: "Write each label as a name and a value. Nothing was committed.";
17
+ readonly dayUnreadable: "Write the date as a day, a month and a year, for example 1 September 2026.";
18
+ readonly labelsOverLimit: "Labels are up to 10 key=value pairs. Keys are lowercase.";
19
+ readonly labelsBlindedHere: "This workspace encrypts its records, so a rule names labels blinded in the browser. Nothing was committed.";
20
+ readonly labelsPlainHere: "This workspace keeps its records in plain form, so a rule names labels as a name and a value. Nothing was committed.";
21
+ };
22
+ export declare function parseRuleDay(input: unknown): string | null;
23
+ export declare function formatRuleDay(iso: string): string;
24
+ export declare function ruleMatches(rule: TrailRuleV1, record: TrailRuleRecord): boolean;
25
+ export declare function ruleSame(a: TrailRuleV1, b: TrailRuleV1): boolean;
26
+ export interface RuleSaySource {
27
+ id: string;
28
+ name: string;
29
+ environment: string;
30
+ }
31
+ export declare function ruleSay(rule: TrailRuleV1, sources: readonly RuleSaySource[], labelsText?: string): string;
32
+ export type TrailRuleCheck = {
33
+ ok: true;
34
+ rule: TrailRuleV1;
35
+ } | {
36
+ ok: false;
37
+ code: 'TRAIL_RULE_INVALID';
38
+ message: string;
39
+ };
40
+ export interface TrailRuleInput {
41
+ sources?: unknown;
42
+ labels?: unknown;
43
+ from?: unknown;
44
+ earlier?: unknown;
45
+ }
46
+ export declare function checkTrailRule(input: TrailRuleInput, options: {
47
+ encrypted: boolean;
48
+ }): TrailRuleCheck;
49
+ export interface SqlFragment {
50
+ strings: string[];
51
+ values: unknown[];
52
+ }
53
+ export declare function ruleToSql(rule: TrailRuleV1, alias?: string): SqlFragment;
54
+ export declare function sqlFragmentText(fragment: SqlFragment, offset?: number): string;
@@ -0,0 +1,57 @@
1
+ import { type SealedNoteV1 } from '../../records/reader-crypto-v1';
2
+ import type { KeyWrapV1, WorkspaceSeedV1 } from './records-asymmetric-v1';
3
+ export interface AckFlagNoteDeviceV1 {
4
+ deviceId: string;
5
+ xwingPublicKey: Uint8Array;
6
+ }
7
+ export interface AckFlagNoteKeysV1 {
8
+ devices: Array<{
9
+ deviceId: string;
10
+ wrap: KeyWrapV1;
11
+ }>;
12
+ workspace: KeyWrapV1;
13
+ }
14
+ export declare function sealAckFlagNotesV1(input: {
15
+ handle: string;
16
+ checkRef: string;
17
+ flags: ReadonlyArray<{
18
+ record: number;
19
+ entry: number;
20
+ text: string;
21
+ }>;
22
+ note?: string | null;
23
+ devices: readonly AckFlagNoteDeviceV1[];
24
+ workspace: Uint8Array;
25
+ }): Promise<{
26
+ notes: SealedNoteV1[];
27
+ note: SealedNoteV1 | null;
28
+ keys: AckFlagNoteKeysV1;
29
+ }>;
30
+ export declare function openAckNoteV1(input: {
31
+ note: unknown;
32
+ wrap: unknown;
33
+ seed: WorkspaceSeedV1;
34
+ handle: string;
35
+ checkRef: string;
36
+ }): Promise<{
37
+ ok: true;
38
+ text: string;
39
+ } | {
40
+ ok: false;
41
+ code: string;
42
+ }>;
43
+ export declare function openAckFlagNoteV1(input: {
44
+ note: unknown;
45
+ wrap: unknown;
46
+ seed: WorkspaceSeedV1;
47
+ handle: string;
48
+ checkRef: string;
49
+ record: number;
50
+ entry: number;
51
+ }): Promise<{
52
+ ok: true;
53
+ text: string;
54
+ } | {
55
+ ok: false;
56
+ code: string;
57
+ }>;
@@ -0,0 +1,55 @@
1
+ import { type FlagDraftsV1 } from '../../records/flag-threads-v1';
2
+ import { type NoteNameV1, type SealedNoteV1 } from '../../records/reader-crypto-v1';
3
+ import type { KeyWrapV1, WorkspaceSeedV1 } from './records-asymmetric-v1';
4
+ export interface FlagNoteDeviceV1 {
5
+ deviceId: string;
6
+ xwingPublicKey: Uint8Array;
7
+ }
8
+ export interface SealedFlagNoteV1 {
9
+ note: SealedNoteV1;
10
+ wraps: Array<{
11
+ deviceId: string;
12
+ wrap: KeyWrapV1;
13
+ }>;
14
+ }
15
+ export declare function sealFlagNoteV1(input: {
16
+ text: string;
17
+ name: NoteNameV1;
18
+ devices: readonly FlagNoteDeviceV1[];
19
+ workspace: Uint8Array | null;
20
+ }): Promise<SealedFlagNoteV1 & {
21
+ workspace: KeyWrapV1 | null;
22
+ }>;
23
+ export declare function openFlagNoteV1(input: {
24
+ note: unknown;
25
+ wrap: unknown;
26
+ seed: WorkspaceSeedV1;
27
+ name: NoteNameV1;
28
+ }): Promise<{
29
+ ok: true;
30
+ text: string;
31
+ } | {
32
+ ok: false;
33
+ code: string;
34
+ }>;
35
+ export declare function sealFlagDraftsV1(input: {
36
+ drafts: FlagDraftsV1;
37
+ handle: string;
38
+ reference: string;
39
+ version: number;
40
+ devices: readonly FlagNoteDeviceV1[];
41
+ }): Promise<SealedFlagNoteV1>;
42
+ export declare function openFlagDraftsV1(input: {
43
+ note: unknown;
44
+ wrap: unknown;
45
+ seed: WorkspaceSeedV1;
46
+ handle: string;
47
+ reference: string;
48
+ version: number;
49
+ }): Promise<{
50
+ ok: true;
51
+ drafts: FlagDraftsV1;
52
+ } | {
53
+ ok: false;
54
+ code: string;
55
+ }>;