@pacspace-io/sdk 0.9.0 → 0.15.2

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 (152) hide show
  1. package/README.md +53 -132
  2. package/dist/blinding-file.d.ts +13 -0
  3. package/dist/blinding-file.d.ts.map +1 -0
  4. package/dist/blinding-guard.d.ts +7 -0
  5. package/dist/blinding-guard.d.ts.map +1 -0
  6. package/dist/blinding.d.ts +32 -0
  7. package/dist/blinding.d.ts.map +1 -0
  8. package/dist/client.d.ts +28 -4
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/fingerprint.d.ts +26 -5
  11. package/dist/fingerprint.d.ts.map +1 -1
  12. package/dist/index.d.ts +35 -35
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +7366 -186
  15. package/dist/index.js.map +7 -1
  16. package/dist/inputs.txt +132 -0
  17. package/dist/records-crypto-libraries.json +42 -0
  18. package/dist/records-crypto-types/proof/hiding-commitment-v1.d.ts +19 -0
  19. package/dist/records-crypto-types/proof/jcs.d.ts +4 -0
  20. package/dist/records-crypto-types/proof/layout-document-v1.d.ts +72 -0
  21. package/dist/records-crypto-types/proof/ledger-head-v1.d.ts +22 -0
  22. package/dist/records-crypto-types/proof/merkle-v2.d.ts +5 -0
  23. package/dist/records-crypto-types/proof/payload-ref-v1.d.ts +17 -0
  24. package/dist/records-crypto-types/proof/seal-input.d.ts +2 -0
  25. package/dist/records-crypto-types/proof/semantic-receipt-v2.d.ts +89 -0
  26. package/dist/records-crypto-types/proof/semantic-receipt-v3.d.ts +20 -0
  27. package/dist/records-crypto-types/proof/slot-encoding-v1.d.ts +169 -0
  28. package/dist/records-crypto-types/records/flag-threads-v1.d.ts +53 -0
  29. package/dist/records-crypto-types/records/labels.d.ts +37 -0
  30. package/dist/records-crypto-types/records/reader-crypto-v1.d.ts +198 -0
  31. package/dist/records-crypto-types/records/reader-link-v1.d.ts +164 -0
  32. package/dist/records-crypto-types/records/shared-record-ack-v2.d.ts +72 -0
  33. package/dist/records-crypto-types/records/signed-acknowledgment-v1.d.ts +38 -0
  34. package/dist/records-crypto-types/records/signed-acknowledgment-v2.d.ts +12 -0
  35. package/dist/records-crypto-types/records/trail-index-v1.d.ts +89 -0
  36. package/dist/records-crypto-types/records/trail-rule.d.ts +54 -0
  37. package/dist/records-crypto-types/records-crypto/asymmetric/ack-flag-notes-v1.d.ts +57 -0
  38. package/dist/records-crypto-types/records-crypto/asymmetric/flag-notes-v1.d.ts +55 -0
  39. package/dist/records-crypto-types/records-crypto/asymmetric/index.d.ts +4 -0
  40. package/dist/records-crypto-types/records-crypto/asymmetric/reader-wraps-v1.d.ts +83 -0
  41. package/dist/records-crypto-types/records-crypto/asymmetric/records-asymmetric-v1.d.ts +201 -0
  42. package/dist/records-crypto-types/records-crypto/base64url.d.ts +3 -0
  43. package/dist/records-crypto-types/records-crypto/blinding-file.d.ts +16 -0
  44. package/dist/records-crypto-types/records-crypto/blinding-value.d.ts +10 -0
  45. package/dist/records-crypto-types/records-crypto/bundle-entry.d.ts +2 -0
  46. package/dist/records-crypto-types/records-crypto/disclosure-envelope-v1.d.ts +42 -0
  47. package/dist/records-crypto-types/records-crypto/held-file.d.ts +17 -0
  48. package/dist/records-crypto-types/records-crypto/hmac-node.d.ts +8 -0
  49. package/dist/records-crypto-types/records-crypto/hmac-web.d.ts +8 -0
  50. package/dist/records-crypto-types/records-crypto/index.d.ts +13 -0
  51. package/dist/records-crypto-types/records-crypto/platform-crypto.d.ts +9 -0
  52. package/dist/records-crypto-types/records-crypto/record-disclosure-v1.d.ts +171 -0
  53. package/dist/records-crypto-types/records-crypto/record-hash-v2.d.ts +49 -0
  54. package/dist/records-crypto-types/records-crypto/record-hash-v3.d.ts +36 -0
  55. package/dist/records-crypto-types/records-crypto/records-encryption-v1.d.ts +185 -0
  56. package/dist/records-crypto-types/records-crypto/wrap-shapes-v1.d.ts +23 -0
  57. package/dist/records-crypto.d.ts +1 -0
  58. package/dist/records-crypto.js +16105 -0
  59. package/dist/records-crypto.js.map +7 -0
  60. package/dist/records-encryption/base64url.d.ts +5 -0
  61. package/dist/records-encryption/base64url.d.ts.map +1 -0
  62. package/dist/records-encryption/encrypted-records.d.ts +338 -0
  63. package/dist/records-encryption/encrypted-records.d.ts.map +1 -0
  64. package/dist/records-encryption/index.d.ts +14 -0
  65. package/dist/records-encryption/index.d.ts.map +1 -0
  66. package/dist/records-encryption/keys.d.ts +40 -0
  67. package/dist/records-encryption/keys.d.ts.map +1 -0
  68. package/dist/records-encryption/loader.d.ts +15 -0
  69. package/dist/records-encryption/loader.d.ts.map +1 -0
  70. package/dist/records-encryption/pin-store-file.d.ts +8 -0
  71. package/dist/records-encryption/pin-store-file.d.ts.map +1 -0
  72. package/dist/records-encryption/pin-store.d.ts +17 -0
  73. package/dist/records-encryption/pin-store.d.ts.map +1 -0
  74. package/dist/records-encryption/transport.d.ts +23 -0
  75. package/dist/records-encryption/transport.d.ts.map +1 -0
  76. package/dist/records-encryption/words.d.ts +40 -0
  77. package/dist/records-encryption/words.d.ts.map +1 -0
  78. package/dist/records-encryption/workspace-secret.d.ts +9 -0
  79. package/dist/records-encryption/workspace-secret.d.ts.map +1 -0
  80. package/dist/resources/records.d.ts +112 -2
  81. package/dist/resources/records.d.ts.map +1 -1
  82. package/dist/types/common.d.ts +0 -8
  83. package/dist/types/common.d.ts.map +1 -1
  84. package/dist/types/config.d.ts +7 -5
  85. package/dist/types/config.d.ts.map +1 -1
  86. package/dist/types/records-encryption.d.ts +136 -0
  87. package/dist/types/records-encryption.d.ts.map +1 -0
  88. package/dist/types/records.d.ts +171 -20
  89. package/dist/types/records.d.ts.map +1 -1
  90. package/dist/types/verify.d.ts +84 -0
  91. package/dist/types/verify.d.ts.map +1 -0
  92. package/dist/webhooks/index.d.ts +1 -1
  93. package/dist/webhooks/index.d.ts.map +1 -1
  94. package/dist/webhooks/index.js +229 -5
  95. package/dist/webhooks/index.js.map +7 -1
  96. package/dist/webhooks/types.d.ts +15 -7
  97. package/dist/webhooks/types.d.ts.map +1 -1
  98. package/dist/workspace-secret-file.d.ts +18 -0
  99. package/dist/workspace-secret-file.d.ts.map +1 -0
  100. package/package.json +16 -13
  101. package/dist/client.js +0 -553
  102. package/dist/client.js.map +0 -1
  103. package/dist/errors/index.js +0 -223
  104. package/dist/errors/index.js.map +0 -1
  105. package/dist/fingerprint.js +0 -132
  106. package/dist/fingerprint.js.map +0 -1
  107. package/dist/resources/balance.d.ts +0 -384
  108. package/dist/resources/balance.d.ts.map +0 -1
  109. package/dist/resources/balance.js +0 -1120
  110. package/dist/resources/balance.js.map +0 -1
  111. package/dist/resources/customers.d.ts +0 -33
  112. package/dist/resources/customers.d.ts.map +0 -1
  113. package/dist/resources/customers.js +0 -26
  114. package/dist/resources/customers.js.map +0 -1
  115. package/dist/resources/internal/batch-transport.d.ts +0 -65
  116. package/dist/resources/internal/batch-transport.d.ts.map +0 -1
  117. package/dist/resources/internal/batch-transport.js +0 -42
  118. package/dist/resources/internal/batch-transport.js.map +0 -1
  119. package/dist/resources/receipts.d.ts +0 -46
  120. package/dist/resources/receipts.d.ts.map +0 -1
  121. package/dist/resources/receipts.js +0 -133
  122. package/dist/resources/receipts.js.map +0 -1
  123. package/dist/resources/records.js +0 -232
  124. package/dist/resources/records.js.map +0 -1
  125. package/dist/resources/submission.d.ts +0 -79
  126. package/dist/resources/submission.d.ts.map +0 -1
  127. package/dist/resources/submission.js +0 -398
  128. package/dist/resources/submission.js.map +0 -1
  129. package/dist/types/balance.d.ts +0 -966
  130. package/dist/types/balance.d.ts.map +0 -1
  131. package/dist/types/balance.js +0 -3
  132. package/dist/types/balance.js.map +0 -1
  133. package/dist/types/common.js +0 -3
  134. package/dist/types/common.js.map +0 -1
  135. package/dist/types/config.js +0 -3
  136. package/dist/types/config.js.map +0 -1
  137. package/dist/types/records.js +0 -5
  138. package/dist/types/records.js.map +0 -1
  139. package/dist/types/submission.d.ts +0 -125
  140. package/dist/types/submission.d.ts.map +0 -1
  141. package/dist/types/submission.js +0 -3
  142. package/dist/types/submission.js.map +0 -1
  143. package/dist/utils/polling.d.ts +0 -32
  144. package/dist/utils/polling.d.ts.map +0 -1
  145. package/dist/utils/polling.js +0 -52
  146. package/dist/utils/polling.js.map +0 -1
  147. package/dist/utils/retry.js +0 -21
  148. package/dist/utils/retry.js.map +0 -1
  149. package/dist/webhooks/types.js +0 -3
  150. package/dist/webhooks/types.js.map +0 -1
  151. package/dist/webhooks/verify.js +0 -191
  152. package/dist/webhooks/verify.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ /** Unpadded base64url from the platform's own btoa and atob, so encrypted records run in a browser as in Node. */
2
+ export declare function toBase64Url(bytes: Uint8Array): string;
3
+ /** Lenient as Node's base64url decoding is: what isn't base64url decodes to fewer bytes, never throws. */
4
+ export declare function fromBase64Url(text: string): Uint8Array;
5
+ //# sourceMappingURL=base64url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../src/records-encryption/base64url.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIrD;AAED,0GAA0G;AAC1G,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAQtD"}
@@ -0,0 +1,338 @@
1
+ import { verifyRecordHistoryBundleV3, type EncryptedReadRefusalV1, type RecordHistoryBundleV3 } from '@pacspace/shared';
2
+ import { type ClientRequestOptions } from '../client';
3
+ import { PacSpaceError } from '../errors';
4
+ import type { RequestOptions } from '../types/config';
5
+ import type { OpenedRecordEntry, RecordReadOptions } from '../types/records';
6
+ import { type RecordsCrypto } from './loader';
7
+ import { type Keyring, type RecordsKeys, type RecordsSecretSource } from './keys';
8
+ import type { RecordsPinStore } from './pin-store';
9
+ import type { RecordsTransport } from './transport';
10
+ export declare const RECORDS_SUPPORT_HEADER = "X-PacSpace-Records-Encryption";
11
+ export declare const RECORDS_GRANT_HEADER = "X-PacSpace-Grant";
12
+ export declare const RECORDS_HOLDER_HEADER = "X-PacSpace-Holder-For";
13
+ /** The door's step-up proof (card 10, F4): replacing or setting up a key at the key pages only. */
14
+ export declare const RECORDS_STEP_UP_HEADER = "X-PacSpace-Step-Up";
15
+ type RecordKey = Awaited<ReturnType<RecordsCrypto['recordKeyOfV1']>>;
16
+ type Seed = Awaited<ReturnType<RecordsCrypto['workspaceSeedFromBytesV1']>>;
17
+ type SeedWrapView = {
18
+ version: number;
19
+ wrap: unknown;
20
+ };
21
+ /** GET identity: the current key (null after PacSpace retires it) and every retired one (card 10, F4). */
22
+ type OwnIdentity = {
23
+ workspaceId?: string;
24
+ xwingPublic: string | null;
25
+ xwingPublicId: string | null;
26
+ seedWraps: SeedWrapView[];
27
+ retiredIdentities?: Array<{
28
+ xwingPublic: string;
29
+ xwingPublicId: string;
30
+ retiredAt: string;
31
+ seedWraps: SeedWrapView[];
32
+ }>;
33
+ };
34
+ /** What a key change returns: the new key, its code to read out, and the new version. */
35
+ export interface KeyChange {
36
+ xwingPublicId: string;
37
+ code: string;
38
+ version: number;
39
+ kid: string;
40
+ holders: Array<{
41
+ holderId: string;
42
+ workspaceId: string;
43
+ wrapped: boolean;
44
+ code?: string;
45
+ }>;
46
+ holdersNeedingConfirmation: string[];
47
+ }
48
+ type Envelope = {
49
+ kid?: unknown;
50
+ };
51
+ type Receipt = Record<string, unknown> & {
52
+ schema?: string;
53
+ seq?: number;
54
+ envelopes?: Envelope[];
55
+ };
56
+ export declare function recordPathOf(recordType: string, entityId: string, suffix: string): string;
57
+ /** A refusal of the shared opener, as the SDK's sentence; entries count from 1. */
58
+ export declare function readRefusal(refusal: EncryptedReadRefusalV1): PacSpaceError;
59
+ /** The shared verifier's sentence for an entry whose seal does not reproduce, word for word. */
60
+ export declare const RECORD_HISTORY_SEAL_SENTENCE = "The sealed record does not recompute to the seal tag carried by the word.";
61
+ export interface Pinned {
62
+ workspaceId: string;
63
+ publicKey: Uint8Array;
64
+ publicKeyId: string;
65
+ }
66
+ /**
67
+ * The encrypted paths of `pac.records`. Keys stay in this process: requests
68
+ * carry wire ids, record hashes, content tags, envelopes and wraps only.
69
+ */
70
+ export declare class EncryptedRecords {
71
+ private readonly client;
72
+ readonly keys: RecordsKeys;
73
+ readonly pins: RecordsPinStore;
74
+ /** A record's version, once known: `recordType \0 wireRecordId` to version. */
75
+ private readonly versionOf;
76
+ /**
77
+ * The record hash version intake took last (card 10, F1): 3 until intake
78
+ * says 3 is not turned on. A refusal on one names the other, once.
79
+ */
80
+ private hashVersion;
81
+ private workspaceId;
82
+ constructor(client: RecordsTransport, keys: RecordsKeys, pins: RecordsPinStore);
83
+ wireId(recordType: string, record: string): Promise<string>;
84
+ wireReferenceId(referenceId: string): Promise<string>;
85
+ /** The id a read or a write puts in the path, and whether the record is read as encrypted. */
86
+ target(recordType: string, record: string | undefined, read?: RecordReadOptions): Promise<{
87
+ entityId: string;
88
+ encrypted: boolean;
89
+ }>;
90
+ /** Intake's admission, run here because intake cannot read encrypted content. */
91
+ private admit;
92
+ emit(input: {
93
+ recordType: string;
94
+ record: string;
95
+ lifecycle: string;
96
+ content: Record<string, unknown>;
97
+ idempotencyKey?: string;
98
+ labels?: Array<[string, string]>;
99
+ }, options?: RequestOptions): Promise<{
100
+ response: Record<string, unknown>;
101
+ wireRecordId: string;
102
+ wireReferenceId: string;
103
+ }>;
104
+ /** A kid's version, from this workspace's own registry; '?' when it isn't there. */
105
+ private versionNumberOf;
106
+ /** Headers for a read: the support header always, and the grant or holder the caller named. */
107
+ readHeaders(read: RecordReadOptions): Record<string, string>;
108
+ /** The record's key for these receipts: the caller's, a grant's wrap, a holder's wrap, or the keyring. */
109
+ recordKeyFor(record: {
110
+ recordType: string;
111
+ wireRecordId: string;
112
+ }, receipts: Receipt[], read: RecordReadOptions, options?: RequestOptions): Promise<{
113
+ rc: RecordsCrypto;
114
+ recordKey: RecordKey;
115
+ others?: RecordKey[];
116
+ }>;
117
+ /** The record key in the bundled verifier's own form, with the version it came from; the bytes cross in memory only. */
118
+ private forVerifier;
119
+ /**
120
+ * Verifies a v3 history with its record's key: every envelope opened and
121
+ * checked against its record hash, then every seal, the chain between
122
+ * entries and the file's own digest, and the current word when `chainWord`
123
+ * is given. The verifier's refusal is returned, not thrown; finding the
124
+ * key can throw (no workspace secret, or a version it doesn't hold).
125
+ */
126
+ verifyHistory(body: RecordHistoryBundleV3, read: RecordReadOptions, verify?: {
127
+ expect?: {
128
+ recordType: string;
129
+ wireRecordId: string;
130
+ };
131
+ chainWord?: string;
132
+ }, options?: RequestOptions): Promise<{
133
+ result: Awaited<ReturnType<typeof verifyRecordHistoryBundleV3>>;
134
+ recordKey: RecordKey;
135
+ rc: RecordsCrypto;
136
+ }>;
137
+ /** Opens a v3 history: every v4 receipt and refused envelope, each checked against its record hash. */
138
+ openHistory(body: RecordHistoryBundleV3, record: {
139
+ recordType: string;
140
+ wireRecordId: string;
141
+ }, read: RecordReadOptions, options?: RequestOptions): Promise<{
142
+ opened: Array<OpenedRecordEntry & {
143
+ saltKey: string;
144
+ seq: number;
145
+ }>;
146
+ recordKey: RecordKey;
147
+ rc: RecordsCrypto;
148
+ sealsVerified: boolean;
149
+ /** Why this history is not one to hand back, copy or re-key; null when it is, a page and a record with nothing committed included. */
150
+ notChecked: PacSpaceError | null;
151
+ }>;
152
+ /**
153
+ * Opens a history to hand it back, copy it or re-key it: refused when an
154
+ * entry presented in it does not check (RECORD_HISTORY_SEAL), or when the
155
+ * history holds entries and its own form stopped the verifier before it
156
+ * checked any (see `notCheckedOf`). A page of a record, and a record with
157
+ * nothing committed yet, are still read: the verifier calls neither one
158
+ * verified, and neither holds an entry that fails or went unchecked.
159
+ * `openHistory` itself reports and does not refuse, for a caller that
160
+ * shows the result.
161
+ */
162
+ openCheckedHistory(body: RecordHistoryBundleV3, record: {
163
+ recordType: string;
164
+ wireRecordId: string;
165
+ }, read: RecordReadOptions, options?: RequestOptions): Promise<Awaited<ReturnType<EncryptedRecords['openHistory']>>>;
166
+ /** Opens one v4 receipt, or a v3 record's v5 (card 10). */
167
+ openReceipt(receipt: Receipt, record: {
168
+ recordType: string;
169
+ wireRecordId: string;
170
+ }, read: RecordReadOptions, options?: RequestOptions): Promise<OpenedRecordEntry>;
171
+ /** N8's copy file: the history with its record key, for a reader with no workspace. */
172
+ copyOf(body: RecordHistoryBundleV3, recordKey: RecordKey, rc: RecordsCrypto): Promise<Uint8Array>;
173
+ /** The record's own history, as the owner reads it; null when it has no entries yet. */
174
+ ownHistory(recordType: string, wireRecordId: string, options?: RequestOptions): Promise<RecordHistoryBundleV3 | null>;
175
+ /** The owner's key for one record: the version its entries carry, or the current one before its first entry. */
176
+ ownRecordKey(recordType: string, wireRecordId: string, options?: RequestOptions): Promise<{
177
+ rc: RecordsCrypto;
178
+ recordKey: RecordKey;
179
+ history: RecordHistoryBundleV3 | null;
180
+ }>;
181
+ ownIdentity(): Promise<OwnIdentity>;
182
+ /** This workspace's own id, as the API names it: the owner every wrap it makes is bound to. */
183
+ ownWorkspaceId(): Promise<string>;
184
+ /**
185
+ * One identity's seed, opened with `keyring`: null when no wrap opens,
186
+ * 'outdated' when every wrap is under a version the keyring doesn't hold.
187
+ * A seed that opens to another public key is `mismatch`'s refusal.
188
+ */
189
+ private openSeedOf;
190
+ /** This workspace's seed, opened with its own secret; null when it has no current identity. */
191
+ ownSeed(ring?: Keyring): Promise<Seed | null>;
192
+ /**
193
+ * Every seed this workspace's secret opens, current first, then each
194
+ * retired one (card 10, F4): a wrap made to a key before it was replaced
195
+ * still opens. A server still on the file before a replacement opens the
196
+ * retired seeds only; with none, W-C10-B-18.
197
+ */
198
+ ownSeeds(): Promise<Seed[]>;
199
+ /**
200
+ * The seed of each identity this workspace has had, sealed under
201
+ * `version` of `ring`: the current one must open; a retired one that
202
+ * doesn't is left out (a key PacSpace retired that this workspace never
203
+ * held). Undefined before the first identity.
204
+ */
205
+ private seedWrapsFor;
206
+ /** Registers each version of the secret the API doesn't list yet. */
207
+ registerVersions(): Promise<void>;
208
+ /**
209
+ * PUT versions in format 2 (card 10, F3): the version's records key
210
+ * wrapped to each workspace holder whose pin is held, with the holder set
211
+ * those wraps were made for; read again once if that set changed.
212
+ */
213
+ private putVersion;
214
+ /** The version's records key wrapped to each workspace holder whose pin is held, with the holder set those wraps were made for. */
215
+ private holderWrapsFor;
216
+ /** Registers this workspace's identity and every version of its secret. Idempotent. */
217
+ registerIdentity(): Promise<{
218
+ xwingPublicId: string;
219
+ code: string;
220
+ created: boolean;
221
+ }>;
222
+ /**
223
+ * Another workspace's public key, pinned: the code is computed here from
224
+ * the bytes fetched, never read from an API field. With `confirmedCode`
225
+ * it must equal that code and is then pinned; without, the pin must exist
226
+ * and still name the key served. Refuses before any wrap.
227
+ */
228
+ pinned(workspaceId: string, confirmedCode?: string): Promise<Pinned>;
229
+ addHolder(input: {
230
+ workspaceId: string;
231
+ scope: 'workspace' | 'record';
232
+ required: boolean;
233
+ record?: {
234
+ recordType: string;
235
+ wireRecordId: string;
236
+ };
237
+ confirmedCode?: string;
238
+ }): Promise<{
239
+ holderId: string;
240
+ created: boolean;
241
+ wraps: Array<{
242
+ version: number | null;
243
+ state: string;
244
+ }>;
245
+ }>;
246
+ /**
247
+ * Opens each stored wrap with this workspace's seed and confirms it, or
248
+ * refuses it so the writer is told. A workspace wrap's key id is
249
+ * recomputed from the opened bytes; a record wrap is confirmed by opening
250
+ * one of the record's entries, and waits while the record has none.
251
+ */
252
+ confirmHoldings(): Promise<Array<{
253
+ holderId: string;
254
+ version: number | null;
255
+ state: string;
256
+ reason?: string;
257
+ }>>;
258
+ /** The kid of the first envelope this record key opens, read as a holder; 'none-yet' before any entry. */
259
+ private kidOpenedBy;
260
+ grantReaderWrap(record: {
261
+ recordType: string;
262
+ wireRecordId: string;
263
+ }, workspaceId: string, confirmedCode: string | undefined): Promise<{
264
+ pinnedId: string;
265
+ rkid: string;
266
+ wrap: unknown;
267
+ } | null>;
268
+ disclosureWrap(handle: string, disclosureKey: Uint8Array, workspaceId: string, confirmedCode: string | undefined): Promise<{
269
+ workspaceId: string;
270
+ pinnedId: string;
271
+ wrap: import("@pacspace/shared/dist/records-crypto/asymmetric").KeyWrapV2;
272
+ }>;
273
+ /** A disclosure link's key from this workspace's wrap, or null when the sharer stored none for it. */
274
+ disclosureKeyFromWrap(handle: string): Promise<Uint8Array | null>;
275
+ rotate(nextSource: RecordsSecretSource): Promise<{
276
+ version: number;
277
+ kid: string;
278
+ holders: Array<{
279
+ holderId: string;
280
+ workspaceId: string;
281
+ wrapped: boolean;
282
+ code?: string;
283
+ }>;
284
+ holdersNeedingConfirmation: string[];
285
+ }>;
286
+ /** `nextSource` read and checked to add exactly the next version and keep every earlier one. */
287
+ private nextOf;
288
+ /**
289
+ * Replaces this workspace's key, at the key pages' door only (card 10,
290
+ * F4; design v5, D3 a): `stepUp` is the door's step-up proof. The API
291
+ * challenges the current key, this seed answers, and the new key and
292
+ * `nextSource`'s new version are written together. Save `nextSource`'s
293
+ * file before calling: it is the only secret that opens the new key.
294
+ */
295
+ replaceKey(nextSource: RecordsSecretSource, stepUp: string): Promise<KeyChange>;
296
+ /**
297
+ * Sets up a new key after PacSpace retired this workspace's key at its
298
+ * request (card 10, F4; D4 a), at the door only, with `nextSource`'s new
299
+ * version. The new key's seed is sealed under that version only.
300
+ */
301
+ setUpKey(nextSource: RecordsSecretSource, stepUp: string): Promise<KeyChange>;
302
+ /**
303
+ * Re-seals each stored entry's same plaintext under the version's record
304
+ * key, latest entry first (same salt key, so each record hash is
305
+ * unchanged), then wraps the new record key to the record's grants and
306
+ * record holders whose pins are held. Stops at the first refusal.
307
+ */
308
+ rekey(input: {
309
+ recordType: string;
310
+ wireRecordId: string;
311
+ toVersion: number;
312
+ /** Called after each entry, done or already under the version. */
313
+ onEntry?: (progress: {
314
+ done: number;
315
+ total: number;
316
+ }) => void;
317
+ }): Promise<{
318
+ entries: Array<{
319
+ entry: number;
320
+ state: 'swapped' | 'already';
321
+ }>;
322
+ grants: Array<{
323
+ grantId: string;
324
+ wrapped: boolean;
325
+ code?: string;
326
+ }>;
327
+ holders: Array<{
328
+ holderId: string;
329
+ wrapped: boolean;
330
+ code?: string;
331
+ }>;
332
+ }>;
333
+ /** For `records.recordKey()`: `RK` as base64url. */
334
+ exportRecordKey(rc: RecordsCrypto, recordKey: RecordKey): string;
335
+ requestOptions(read: RecordReadOptions, options?: RequestOptions): ClientRequestOptions;
336
+ }
337
+ export {};
338
+ //# sourceMappingURL=encrypted-records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypted-records.d.ts","sourceRoot":"","sources":["../../src/records-encryption/encrypted-records.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAgB,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAa,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AACtE,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAC7D,mGAAmG;AACnG,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAS3D,KAAK,SAAS,GAAG,OAAO,CAAC,U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vE,CAAC;IAoEF,oDAAoD;IACpD,eAAe,CAAC,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM;IAIhE,cAAc,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,oBAAoB;CAGxF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Encrypted records for a browser (L2e design v2, D5): the same client the
3
+ * SDK uses, with no Node module on its path. A key page passes its own
4
+ * transport, keys and pin store; nothing here is a second client.
5
+ */
6
+ export { EncryptedRecords, RECORDS_GRANT_HEADER, RECORDS_HOLDER_HEADER, RECORDS_STEP_UP_HEADER, RECORDS_SUPPORT_HEADER, recordPathOf, type KeyChange, } from './encrypted-records';
7
+ export { RecordsKeys, keyringOf, type Keyring } from './keys';
8
+ export { loadRecordsCrypto, type RecordsCrypto } from './loader';
9
+ export { memoryPinStore, type RecordsPin, type RecordsPinStore } from './pin-store';
10
+ export { transportError, type RecordsTransport } from './transport';
11
+ export { RECORDS_ENCRYPTION_WORDS, RecordsEncryptionError, type RecordsEncryptionCode } from './words';
12
+ export { generateWorkspaceSecret, nextWorkspaceSecret } from './workspace-secret';
13
+ export { PacSpaceError } from '../errors';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/records-encryption/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACvG,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { RecordsEncryptionOptions, RecordsSecretSource } from '../types/records-encryption';
2
+ import { type RecordsCrypto } from './loader';
3
+ export type { RecordsEncryptionOptions, RecordsSecretSource };
4
+ export type Keyring = Awaited<ReturnType<RecordsCrypto['RecordsKeyringV1']['fromProvider']>>;
5
+ /** Parses a workspace secret into a keyring, or refuses with W-L2d-24. */
6
+ export declare function keyringOf(source: RecordsSecretSource): Promise<{
7
+ rc: RecordsCrypto;
8
+ ring: Keyring;
9
+ text: string;
10
+ }>;
11
+ /**
12
+ * The client's workspace secret, loaded on first use. Without `secret` or
13
+ * `secretProvider` nothing is configured and records are written as 0.12.0
14
+ * wrote them.
15
+ */
16
+ export declare class RecordsKeys {
17
+ private readonly options;
18
+ private loading;
19
+ constructor(options: RecordsEncryptionOptions | undefined);
20
+ get configured(): boolean;
21
+ /** The keyring, or W-L2d-23 when no workspace secret is configured. */
22
+ ring(): Promise<{
23
+ rc: RecordsCrypto;
24
+ ring: Keyring;
25
+ }>;
26
+ /** The keyring file's text, for `rotate` to compare versions. */
27
+ text(): Promise<string>;
28
+ /** After a rotation: the next keyring is used from here on. */
29
+ replace(next: {
30
+ rc: RecordsCrypto;
31
+ ring: Keyring;
32
+ text: string;
33
+ }): void;
34
+ /** The keyring without refusing: null when none is configured. */
35
+ maybe(): Promise<{
36
+ rc: RecordsCrypto;
37
+ ring: Keyring;
38
+ } | null>;
39
+ }
40
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 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+1,15 @@
1
+ import type * as Shared from '@pacspace/shared';
2
+ import type * as Asymmetric from '@pacspace/shared/dist/records-crypto/asymmetric';
3
+ /**
4
+ * The key layer of encrypted records: records-crypto and its asymmetric
5
+ * part, loaded once per process. Every key the SDK makes or opens comes from
6
+ * this one module, because a key is only usable by the module that made it;
7
+ * a record key crosses to the bundled verifier as bytes, in memory only.
8
+ *
9
+ * In the published package scripts/build.mjs replaces this file with a
10
+ * require of the bundled `./records-crypto.js` subpath, which carries the
11
+ * pinned libraries; the names below are exactly what that subpath exports.
12
+ */
13
+ export type RecordsCrypto = Pick<typeof Shared, 'RecordsKeyringV1' | 'localRecordsKeyProviderV1' | 'parseRecordsKeyringFileV1' | 'serializeRecordsKeyringFileV1' | 'generateWorkspaceSecretV1' | 'wireRecordIdV1' | 'wireReferenceIdV1' | 'blindedLabelV1' | 'contentTagV1' | 'contentTagV2' | 'recordKeyOfV1' | 'recordKeyFromBytesV1' | 'exportKeyBytesV1' | 'sealRecordEntryV1' | 'openRecordEntryEnvelopeV1' | 'recordEntryPlaintextV1' | 'checkEncryptedWriteSizeV1' | 'newSaltKeyV2' | 'commitRecordContentV2' | 'commitRecordContentV3'> & Pick<typeof Asymmetric, 'workspaceSeedFromBytesV1' | 'sealSeedWrapV1' | 'openSeedWrapV1' | 'publicKeyIdV1' | 'holderKeyCodeV1' | 'KEY_WRAP_OWNER_V2' | 'wrapRecordsKeyV2' | 'wrapRecordKeyV2' | 'wrapDisclosureKeyV2' | 'unwrapRecordsKeyV2' | 'unwrapRecordKeyV2' | 'unwrapDisclosureKeyV2' | 'rotationProofV1'>;
14
+ export declare function loadRecordsCrypto(): Promise<RecordsCrypto>;
15
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/records-encryption/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,KAAK,UAAU,MAAM,iDAAiD,CAAC;AAKnF;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,OAAO,MAAM,EACX,kBAAkB,GAClB,2BAA2B,GAC3B,2BAA2B,GAC3B,+BAA+B,GAC/B,2BAA2B,GAC3B,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,eAAe,GACf,sBAAsB,GACtB,kBAAkB,GAClB,mBAAmB,GACnB,2BAA2B,GAC3B,wBAAwB,GACxB,2BAA2B,GAC3B,cAAc,GACd,uBAAuB,GACvB,uBAAuB,CAC1B,GACC,IAAI,CACF,OAAO,UAAU,EACf,0BAA0B,GAC1B,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,iBAAiB,GACjB,mBAAmB,GACnB,kBAAkB,GAClB,iBAAiB,GACjB,qBAAqB,GACrB,oBAAoB,GACpB,mBAAmB,GACnB,uBAAuB,GACvB,iBAAiB,CACpB,CAAC;AAIJ,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,aAAa,CAAC,CAO1D"}
@@ -0,0 +1,8 @@
1
+ import type { RecordsPinStore } from './pin-store';
2
+ /**
3
+ * Pins kept in a JSON file, readable by its owner only (mode 0600). Each
4
+ * write replaces the file whole, so a crash leaves the previous pins. A file
5
+ * that can't be read as pins holds none: every code is confirmed again.
6
+ */
7
+ export declare function filePinStore(path: string): RecordsPinStore;
8
+ //# sourceMappingURL=pin-store-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pin-store-file.d.ts","sourceRoot":"","sources":["../../src/records-encryption/pin-store-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAc,eAAe,EAAE,MAAM,aAAa,CAAC;AAK/D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAgC1D"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A workspace whose code the person confirmed outside PacSpace: the id of
3
+ * the public key that made the code, and when. Wraps go only to a pinned key;
4
+ * a later wrap that finds another key there is refused before anything is
5
+ * wrapped. A pin holds no secret.
6
+ */
7
+ export interface RecordsPin {
8
+ publicKeyId: string;
9
+ confirmedAt: string;
10
+ }
11
+ export interface RecordsPinStore {
12
+ get(workspaceId: string): Promise<RecordsPin | null>;
13
+ set(workspaceId: string, pin: RecordsPin): Promise<void>;
14
+ }
15
+ /** Pins held for this process only. */
16
+ export declare function memoryPinStore(): RecordsPinStore;
17
+ //# sourceMappingURL=pin-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pin-store.d.ts","sourceRoot":"","sources":["../../src/records-encryption/pin-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACrD,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,uCAAuC;AACvC,wBAAgB,cAAc,IAAI,eAAe,CAWhD"}
@@ -0,0 +1,23 @@
1
+ import { type ClientRequestOptions } from '../client';
2
+ import { PacSpaceError } from '../errors';
3
+ /**
4
+ * What encrypted records need from a transport (L2e design v2, D5).
5
+ * `HttpClient` is one, sending the API key; a key page passes one that sends
6
+ * the dashboard session to the dashboard's encrypted door instead. The paths
7
+ * are always the SDK's own `/api/v1/records/...` paths.
8
+ */
9
+ export interface RecordsTransport {
10
+ get<T>(path: string, options?: ClientRequestOptions): Promise<T>;
11
+ getRaw<T>(path: string, options?: ClientRequestOptions): Promise<{
12
+ body: T;
13
+ headers: Headers;
14
+ status: number;
15
+ }>;
16
+ post<T>(path: string, body?: unknown, options?: ClientRequestOptions): Promise<T>;
17
+ postNow<T>(path: string, body: unknown, options?: ClientRequestOptions): Promise<T>;
18
+ put<T>(path: string, body: unknown, options?: ClientRequestOptions): Promise<T>;
19
+ delete<T>(path: string, options?: ClientRequestOptions): Promise<T>;
20
+ }
21
+ /** A refusal from another transport, carrying its body for the SDK's retry rules (as `recordKid`). */
22
+ export declare function transportError(message: string, statusCode: number, code: string, body?: Record<string, unknown>): PacSpaceError;
23
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/records-encryption/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjE,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChH,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAClF,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACpF,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChF,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACrE;AAED,sGAAsG;AACtG,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAI/H"}
@@ -0,0 +1,40 @@
1
+ import { PacSpaceError } from '../errors';
2
+ /**
3
+ * The SDK's refusals for encrypted records (L2d words list, W-L2d-23 to 37):
4
+ * the same codes and sentences in TypeScript and Python. A sentence never
5
+ * carries key bytes; an entry is named by its number, counting from 1.
6
+ */
7
+ export declare const RECORDS_ENCRYPTION_WORDS: {
8
+ readonly RECORDS_SECRET_REQUIRED: "Encrypted records need the workspace secret. Pass it as records.secret or records.secretProvider.";
9
+ readonly RECORDS_SECRET_INVALID: "The workspace secret isn't a pacspace-workspace-secret/v1 file this version reads.";
10
+ readonly RECORDS_VERSION_NOT_HELD: "This record is under version {v}, which this workspace secret doesn't hold.";
11
+ readonly RECORDS_ENTRY_UNOPENED: "Entry {seq} didn't open. The record or the workspace secret is not the one expected.";
12
+ readonly RECORDS_ENTRY_HASH_MISMATCH: "Entry {seq} opened, but its content doesn't match its sealed record hash.";
13
+ readonly RECORDS_ENTRY_REFS_MISMATCH: "Entry {seq} opened, but the entries it amends or references don't match the ones stored with it.";
14
+ readonly RECORDS_HISTORY_OTHER_RECORD: "The history served is for another record. Nothing was opened.";
15
+ readonly RECORDS_CODE_REQUIRED: "Confirm this workspace's code with them outside PacSpace first, then pass it as confirmedCode.";
16
+ readonly RECORDS_CODE_MISMATCH: "The code computed for this workspace doesn't match the one confirmed. Nothing was wrapped. Confirm the code with them again.";
17
+ readonly RECORDS_PIN_CHANGED: "This workspace's identity changed since its code was confirmed. Nothing was wrapped. Confirm the new code with them.";
18
+ readonly RECORDS_NOT_ENCRYPTED: "This record isn't encrypted. Keep its history file instead.";
19
+ readonly RECORDS_LINK_NO_KEY: "This link has no key after # and no wrap for your workspace.";
20
+ readonly RECORDS_REKEY_STOPPED: "Re-encryption stopped at entry {seq}. Entries after it are done; run it again to finish.";
21
+ readonly RECORDS_ROTATE_NOT_NEXT: "The new workspace secret must add exactly the next version and keep every earlier one.";
22
+ readonly RECORDS_IDENTITY_OTHER: "This workspace already registered another identity, which this workspace secret doesn't open.";
23
+ readonly RECORDS_OWNER_INVALID: "This workspace id isn't in the expected form.";
24
+ readonly RECORDS_DISCLOSURE_LINK_MISMATCH: "This shared record doesn't match the link it came from.";
25
+ readonly RECORDS_SECRET_FILE_OUTDATED: "This workspace replaced its key. Use its new secret file on this server.";
26
+ readonly RECORDS_RETIRED_KEY_MISMATCH: "A retired key for this workspace doesn't match its listed code. Don't use it; contact PacSpace.";
27
+ readonly RECORDS_LAYOUT_NOT_READ: "This file was written under a record layout this version does not read, so it could not be checked.";
28
+ };
29
+ /** RECORDS_VERSION_NOT_HELD's sentence when a write's claim names a version this client doesn't hold (card 10, W-C10-B-2). */
30
+ export declare const RECORDS_WRITE_VERSION_NOT_HELD = "This write was first made under encryption version {v}, which this client doesn't hold. Open that version first, or use a new reference.";
31
+ export type RecordsEncryptionCode = keyof typeof RECORDS_ENCRYPTION_WORDS;
32
+ /** A client-side refusal on an encrypted path: a code and its sentence, never a key. */
33
+ export declare class RecordsEncryptionError extends PacSpaceError {
34
+ constructor(code: RecordsEncryptionCode, values?: {
35
+ v?: number | string;
36
+ seq?: number | string;
37
+ write?: boolean;
38
+ });
39
+ }
40
+ //# sourceMappingURL=words.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words.d.ts","sourceRoot":"","sources":["../../src/records-encryption/words.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;CAqB3B,CAAC;AAEX,8HAA8H;AAC9H,eAAO,MAAM,8BAA8B,6IACiG,CAAC;AAE7I,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAE1E,wFAAwF;AACxF,qBAAa,sBAAuB,SAAQ,aAAa;gBAC3C,IAAI,EAAE,qBAAqB,EAAE,MAAM,GAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAQtH"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A new workspace secret: a pacspace-workspace-secret/v1 file with version
3
+ * 1, drawn in this process. Keep it where the workspace keeps its other
4
+ * secrets; PacSpace never receives it, and a lost secret can't be recovered.
5
+ */
6
+ export declare function generateWorkspaceSecret(): string;
7
+ /** The same file with the next version added, drawn here: the input to `records.rotate()`. */
8
+ export declare function nextWorkspaceSecret(keyring: string): string;
9
+ //# sourceMappingURL=workspace-secret.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-secret.d.ts","sourceRoot":"","sources":["../../src/records-encryption/workspace-secret.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK3D"}