@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,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
+ }>;
@@ -0,0 +1,4 @@
1
+ export { RECORDS_ASYMMETRIC_LABELS_V1, KEY_WRAP_SUITE_V1, KEY_WRAP_SUITES_V1, WORKSPACE_SEED_BYTES_V1, WORKSPACE_PUBLIC_KEY_BYTES_V1, KEY_WRAP_ENC_BYTES_V1, KEY_WRAP_CT_BYTES_V1, SEED_WRAP_CT_BYTES_V1, MLDSA65_SEED_BYTES_V1, HOLDER_KEY_CODE_DIGITS_V1, RecordsAsymmetricError, WorkspaceSeedV1, MldsaSigningKeyV1, exportWorkspaceSeedBytesV1, publicKeyIdV1, holderKeyCodeV1, workspaceSeedFromBytesV1, generateWorkspaceSeedV1, sealSeedWrapV1, readSeedWrapShapeV1, openSeedWrapV1, keyWrapInfoV1, wrapRecordsKeyV1, wrapRecordKeyV1, wrapDisclosureKeyV1, readKeyWrapShapeV1, unwrapRecordsKeyV1, unwrapRecordKeyV1, unwrapDisclosureKeyV1, KEY_WRAP_OWNER_V2, keyWrapInfoV2, wrapRecordsKeyV2, wrapRecordKeyV2, wrapDisclosureKeyV2, readKeyWrapShapeV2, unwrapRecordsKeyV2, unwrapRecordKeyV2, unwrapDisclosureKeyV2, ROTATION_CHALLENGE_ID_V1, ROTATION_CHALLENGE_ENC_BYTES_V1, rotationChallengeV1, rotationProofV1, rotationProofHashV1, mldsaSigningKeyFromSeedV1, generateMldsaSigningKeyV1, exportMldsaSeedBytesV1, signMldsa65V1, verifyMldsa65V1, type KeyWrapPurposeV1, type KeyWrapBindingV1, type KeyWrapV1, type KeyWrapBindingV2, type KeyWrapV2, type RotationBindingV1, type SeedWrapV1, type RecordsAsymmetricCodeV1, } from './records-asymmetric-v1';
2
+ export { makeDeviceKeysV1, devicePublicV1, wrapLinkKeyV1, unwrapLinkKeyV1, wrapAnswerKeyV1, unwrapAnswerKeyV1, wrapNoteKeyV1, unwrapNoteKeyV1, signApprovalV1, signDeviceMessageV1, verifyDeviceMessageV1, type DeviceKeysV1, } from './reader-wraps-v1';
3
+ export { sealAckFlagNotesV1, openAckFlagNoteV1, openAckNoteV1, type AckFlagNoteDeviceV1, type AckFlagNoteKeysV1 } from './ack-flag-notes-v1';
4
+ export { sealFlagNoteV1, openFlagNoteV1, sealFlagDraftsV1, openFlagDraftsV1, type FlagNoteDeviceV1, type SealedFlagNoteV1, } from './flag-notes-v1';
@@ -0,0 +1,83 @@
1
+ import { type NoteNameV1 } from '../../records/reader-crypto-v1';
2
+ import type { SigningPublicKeyJwkV1 } from '../../records/signed-acknowledgment-v1';
3
+ import { MldsaSigningKeyV1, WorkspaceSeedV1, type KeyWrapV1 } from './records-asymmetric-v1';
4
+ export interface DeviceKeysV1 {
5
+ xwing: WorkspaceSeedV1;
6
+ mldsa: MldsaSigningKeyV1;
7
+ p256Jwk: SigningPublicKeyJwkV1;
8
+ deviceId: string;
9
+ code: string;
10
+ }
11
+ export declare function makeDeviceKeysV1(input: {
12
+ xwingSeed: Uint8Array;
13
+ mldsaSeed: Uint8Array;
14
+ p256Jwk: SigningPublicKeyJwkV1;
15
+ }): Promise<DeviceKeysV1>;
16
+ export declare function devicePublicV1(keys: DeviceKeysV1): {
17
+ xwingPublicKey: string;
18
+ p256Jwk: SigningPublicKeyJwkV1;
19
+ mldsaPublicKey: string;
20
+ };
21
+ export declare function wrapLinkKeyV1(publicKey: Uint8Array, linkKey: Uint8Array, handle: string, epoch: number): Promise<KeyWrapV1>;
22
+ export declare function unwrapLinkKeyV1(input: {
23
+ seed: WorkspaceSeedV1;
24
+ wrap: unknown;
25
+ handle: string;
26
+ epoch: number;
27
+ }): Promise<{
28
+ ok: false;
29
+ code: "KEY_WRAP_MALFORMED" | "KEY_WRAP_SUITE" | "KEY_WRAP_WRONG_HOLDER" | "KEY_WRAP_AUTH_FAILED" | "KEY_WRAP_BINDING_INVALID";
30
+ } | {
31
+ ok: true;
32
+ disclosureKey: Uint8Array;
33
+ }>;
34
+ export declare function wrapAnswerKeyV1(publicKey: Uint8Array, answerKey: Uint8Array, handle: string, requestRef: string): Promise<KeyWrapV1>;
35
+ export declare function unwrapAnswerKeyV1(input: {
36
+ seed: WorkspaceSeedV1;
37
+ wrap: unknown;
38
+ handle: string;
39
+ requestRef: string;
40
+ }): Promise<{
41
+ ok: false;
42
+ code: "KEY_WRAP_MALFORMED" | "KEY_WRAP_SUITE" | "KEY_WRAP_WRONG_HOLDER" | "KEY_WRAP_AUTH_FAILED" | "KEY_WRAP_BINDING_INVALID";
43
+ } | {
44
+ ok: true;
45
+ disclosureKey: Uint8Array;
46
+ }>;
47
+ export declare function wrapNoteKeyV1(publicKey: Uint8Array, noteKey: Uint8Array, name: NoteNameV1): Promise<KeyWrapV1>;
48
+ export declare function unwrapNoteKeyV1(input: {
49
+ seed: WorkspaceSeedV1;
50
+ wrap: unknown;
51
+ name: NoteNameV1;
52
+ }): Promise<{
53
+ ok: false;
54
+ code: "KEY_WRAP_MALFORMED" | "KEY_WRAP_SUITE" | "KEY_WRAP_WRONG_HOLDER" | "KEY_WRAP_AUTH_FAILED" | "KEY_WRAP_BINDING_INVALID";
55
+ } | {
56
+ ok: true;
57
+ disclosureKey: Uint8Array;
58
+ }>;
59
+ export declare function signApprovalV1(input: {
60
+ p256PrivateKey: CryptoKey;
61
+ mldsa: MldsaSigningKeyV1;
62
+ handle: string;
63
+ epoch: number;
64
+ newDeviceId: string;
65
+ }): Promise<{
66
+ signature: string;
67
+ mldsaSignature: string;
68
+ }>;
69
+ export declare function signDeviceMessageV1(input: {
70
+ p256PrivateKey: CryptoKey;
71
+ mldsa: MldsaSigningKeyV1;
72
+ message: string;
73
+ }): Promise<{
74
+ signature: string;
75
+ mldsaSignature: string;
76
+ }>;
77
+ export declare function verifyDeviceMessageV1(input: {
78
+ p256Jwk: SigningPublicKeyJwkV1;
79
+ mldsaPublicKey: Uint8Array;
80
+ message: string;
81
+ signature: unknown;
82
+ mldsaSignature: unknown;
83
+ }): Promise<boolean>;
@@ -0,0 +1,201 @@
1
+ import { RecordKeyV1, RecordsKeyV1, RecordsKeyringV1, RecordsWrapKeyV1, type RecordsRefusalV1 } from '../records-encryption-v1';
2
+ import { KEY_WRAP_CT_BYTES_V1, KEY_WRAP_ENC_BYTES_V1, KEY_WRAP_SUITE_V1, SEED_WRAP_CT_BYTES_V1, WORKSPACE_PUBLIC_KEY_BYTES_V1, readKeyWrapShapeV1, readKeyWrapShapeV2, readSeedWrapShapeV1 } from '../wrap-shapes-v1';
3
+ export { KEY_WRAP_CT_BYTES_V1, KEY_WRAP_ENC_BYTES_V1, KEY_WRAP_SUITE_V1, SEED_WRAP_CT_BYTES_V1, WORKSPACE_PUBLIC_KEY_BYTES_V1, readKeyWrapShapeV1, readKeyWrapShapeV2, readSeedWrapShapeV1, };
4
+ export declare const RECORDS_ASYMMETRIC_LABELS_V1: {
5
+ readonly publicKeyId: "pacspace:public-key-id:v1";
6
+ readonly holderKeyCode: "pacspace:holder-key-code:v1";
7
+ readonly seedWrap: "pacspace:seed-wrap:v1";
8
+ readonly wrap: "pacspace:wrap:v1";
9
+ readonly wrapV2: "pacspace:wrap:v2";
10
+ readonly identityRotation: "pacspace:identity-rotation:v1";
11
+ };
12
+ export declare const KEY_WRAP_SUITES_V1: {
13
+ readonly 'hpke-1': {
14
+ readonly kem: 25722;
15
+ readonly kdf: 1;
16
+ readonly aead: 2;
17
+ readonly draft: "draft-ietf-hpke-pq-05";
18
+ };
19
+ };
20
+ export declare const WORKSPACE_SEED_BYTES_V1 = 32;
21
+ export declare const MLDSA65_SEED_BYTES_V1 = 32;
22
+ export declare const HOLDER_KEY_CODE_DIGITS_V1 = 40;
23
+ export type KeyWrapPurposeV1 = 'records-key' | 'record-key' | 'disclosure-key';
24
+ export type RecordsAsymmetricCodeV1 = 'WORKSPACE_SEED_INVALID' | 'WORKSPACE_PUBLIC_KEY_INVALID' | 'SEED_WRAP_MALFORMED' | 'SEED_WRAP_WRONG_KEY' | 'SEED_WRAP_AUTH_FAILED' | 'KEY_WRAP_MALFORMED' | 'KEY_WRAP_SUITE' | 'KEY_WRAP_WRONG_HOLDER' | 'KEY_WRAP_AUTH_FAILED' | 'KEY_WRAP_KEY_MISMATCH' | 'KEY_WRAP_BINDING_INVALID' | 'MLDSA_KEY_INVALID' | 'ROTATION_BINDING_INVALID' | 'ROTATION_CHALLENGE_MALFORMED';
25
+ export declare class RecordsAsymmetricError extends Error {
26
+ readonly code: RecordsAsymmetricCodeV1;
27
+ constructor(code: RecordsAsymmetricCodeV1);
28
+ }
29
+ declare const INSPECT: unique symbol;
30
+ declare abstract class HiddenKey {
31
+ protected constructor(bytes: Uint8Array);
32
+ protected abstract describe(): string;
33
+ toString(): string;
34
+ toJSON(): string;
35
+ [INSPECT](): string;
36
+ }
37
+ export declare class WorkspaceSeedV1 extends HiddenKey {
38
+ #private;
39
+ readonly publicKeyId: string;
40
+ get publicKey(): Uint8Array;
41
+ protected describe(): string;
42
+ }
43
+ export declare class MldsaSigningKeyV1 extends HiddenKey {
44
+ #private;
45
+ get publicKey(): Uint8Array;
46
+ protected describe(): string;
47
+ }
48
+ export declare function exportWorkspaceSeedBytesV1(seed: WorkspaceSeedV1): Uint8Array;
49
+ export declare function publicKeyIdV1(publicKey: Uint8Array): Promise<string>;
50
+ export declare function holderKeyCodeV1(publicKey: Uint8Array): Promise<string>;
51
+ export declare function workspaceSeedFromBytesV1(seed: Uint8Array): Promise<WorkspaceSeedV1>;
52
+ export declare function generateWorkspaceSeedV1(): Promise<WorkspaceSeedV1>;
53
+ export interface SeedWrapV1 {
54
+ v: 1;
55
+ alg: 'A256GCM';
56
+ kid: string;
57
+ iv: string;
58
+ ct: string;
59
+ }
60
+ export declare function sealSeedWrapV1(wrapKey: RecordsWrapKeyV1, seed: WorkspaceSeedV1): Promise<SeedWrapV1>;
61
+ export declare function openSeedWrapV1(input: {
62
+ wrap: unknown;
63
+ publicKeyId: string;
64
+ wrapKey?: RecordsWrapKeyV1;
65
+ keyring?: RecordsKeyringV1;
66
+ }): Promise<{
67
+ ok: true;
68
+ seed: WorkspaceSeedV1;
69
+ } | RecordsRefusalV1<'SEED_WRAP_MALFORMED' | 'SEED_WRAP_WRONG_KEY' | 'SEED_WRAP_AUTH_FAILED'>>;
70
+ export interface KeyWrapV1 {
71
+ v: 1;
72
+ suite: typeof KEY_WRAP_SUITE_V1;
73
+ to: string;
74
+ enc: string;
75
+ ct: string;
76
+ }
77
+ export type KeyWrapBindingV1 = {
78
+ purpose: 'records-key';
79
+ recordsKeyId: string;
80
+ } | {
81
+ purpose: 'record-key';
82
+ recordType: string;
83
+ wireRecordId: string;
84
+ } | {
85
+ purpose: 'disclosure-key';
86
+ handle: string;
87
+ };
88
+ export declare function keyWrapInfoV1(binding: KeyWrapBindingV1): Promise<Uint8Array>;
89
+ export declare function wrapRecordsKeyV1(publicKey: Uint8Array, recordsKey: RecordsKeyV1): Promise<KeyWrapV1>;
90
+ export declare function wrapRecordKeyV1(publicKey: Uint8Array, recordKey: RecordKeyV1, record: {
91
+ recordType: string;
92
+ wireRecordId: string;
93
+ }): Promise<KeyWrapV1>;
94
+ export declare function wrapDisclosureKeyV1(publicKey: Uint8Array, disclosureKey: Uint8Array, handle: string): Promise<KeyWrapV1>;
95
+ type UnwrapRefusal = RecordsRefusalV1<'KEY_WRAP_MALFORMED' | 'KEY_WRAP_SUITE' | 'KEY_WRAP_WRONG_HOLDER' | 'KEY_WRAP_AUTH_FAILED' | 'KEY_WRAP_BINDING_INVALID'>;
96
+ export declare function unwrapRecordsKeyV1(input: {
97
+ seed: WorkspaceSeedV1;
98
+ wrap: unknown;
99
+ version: number;
100
+ recordsKeyId: string;
101
+ }): Promise<{
102
+ ok: true;
103
+ recordsKey: RecordsKeyV1;
104
+ } | UnwrapRefusal | RecordsRefusalV1<'KEY_WRAP_KEY_MISMATCH'>>;
105
+ export declare function unwrapRecordKeyV1(input: {
106
+ seed: WorkspaceSeedV1;
107
+ wrap: unknown;
108
+ recordType: string;
109
+ wireRecordId: string;
110
+ }): Promise<{
111
+ ok: true;
112
+ recordKey: RecordKeyV1;
113
+ } | UnwrapRefusal>;
114
+ export declare function unwrapDisclosureKeyV1(input: {
115
+ seed: WorkspaceSeedV1;
116
+ wrap: unknown;
117
+ handle: string;
118
+ }): Promise<{
119
+ ok: true;
120
+ disclosureKey: Uint8Array;
121
+ } | UnwrapRefusal>;
122
+ export interface KeyWrapV2 {
123
+ v: 2;
124
+ suite: typeof KEY_WRAP_SUITE_V1;
125
+ to: string;
126
+ enc: string;
127
+ ct: string;
128
+ }
129
+ export type KeyWrapBindingV2 = {
130
+ purpose: 'records-key';
131
+ owner: string;
132
+ version: number;
133
+ recordsKeyId: string;
134
+ } | {
135
+ purpose: 'record-key';
136
+ owner: string;
137
+ recordType: string;
138
+ wireRecordId: string;
139
+ recordKeyId: string;
140
+ } | {
141
+ purpose: 'disclosure-key';
142
+ owner: string;
143
+ handle: string;
144
+ };
145
+ export declare const KEY_WRAP_OWNER_V2: RegExp;
146
+ export declare function keyWrapInfoV2(binding: KeyWrapBindingV2): Promise<Uint8Array>;
147
+ export declare function wrapRecordsKeyV2(publicKey: Uint8Array, recordsKey: RecordsKeyV1, owner: string): Promise<KeyWrapV2>;
148
+ export declare function wrapRecordKeyV2(publicKey: Uint8Array, recordKey: RecordKeyV1, record: {
149
+ recordType: string;
150
+ wireRecordId: string;
151
+ }, owner: string): Promise<KeyWrapV2>;
152
+ export declare function wrapDisclosureKeyV2(publicKey: Uint8Array, disclosureKey: Uint8Array, handle: string, owner: string): Promise<KeyWrapV2>;
153
+ export declare function unwrapRecordsKeyV2(input: {
154
+ seed: WorkspaceSeedV1;
155
+ wrap: unknown;
156
+ owner: string;
157
+ version: number;
158
+ recordsKeyId: string;
159
+ }): Promise<{
160
+ ok: true;
161
+ recordsKey: RecordsKeyV1;
162
+ } | UnwrapRefusal | RecordsRefusalV1<'KEY_WRAP_KEY_MISMATCH'>>;
163
+ export declare function unwrapRecordKeyV2(input: {
164
+ seed: WorkspaceSeedV1;
165
+ wrap: unknown;
166
+ owner: string;
167
+ recordType: string;
168
+ wireRecordId: string;
169
+ recordKeyId: string;
170
+ }): Promise<{
171
+ ok: true;
172
+ recordKey: RecordKeyV1;
173
+ } | UnwrapRefusal | RecordsRefusalV1<'KEY_WRAP_KEY_MISMATCH'>>;
174
+ export declare function unwrapDisclosureKeyV2(input: {
175
+ seed: WorkspaceSeedV1;
176
+ wrap: unknown;
177
+ owner: string;
178
+ handle: string;
179
+ }): Promise<{
180
+ ok: true;
181
+ disclosureKey: Uint8Array;
182
+ } | UnwrapRefusal>;
183
+ export interface RotationBindingV1 {
184
+ workspaceId: string;
185
+ fromId: string;
186
+ newId: string;
187
+ challengeId: string;
188
+ }
189
+ export declare const ROTATION_CHALLENGE_ID_V1: RegExp;
190
+ export declare const ROTATION_CHALLENGE_ENC_BYTES_V1 = 1120;
191
+ export declare function rotationProofHashV1(proof: unknown): Promise<string | null>;
192
+ export declare function rotationChallengeV1(currentPublicKey: Uint8Array, binding: RotationBindingV1, ikmE?: Uint8Array): Promise<{
193
+ enc: string;
194
+ proofHash: string;
195
+ }>;
196
+ export declare function rotationProofV1(seed: WorkspaceSeedV1, enc: string, binding: RotationBindingV1): Promise<string>;
197
+ export declare function mldsaSigningKeyFromSeedV1(seed: Uint8Array): Promise<MldsaSigningKeyV1>;
198
+ export declare function generateMldsaSigningKeyV1(): Promise<MldsaSigningKeyV1>;
199
+ export declare function exportMldsaSeedBytesV1(key: MldsaSigningKeyV1): Uint8Array;
200
+ export declare function signMldsa65V1(key: MldsaSigningKeyV1, message: Uint8Array): Promise<Uint8Array>;
201
+ export declare function verifyMldsa65V1(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): Promise<boolean>;
@@ -0,0 +1,3 @@
1
+ export declare function toBase64Url(bytes: Uint8Array): string;
2
+ export declare function fromBase64Url(text: string): Uint8Array | null;
3
+ export declare function base64UrlLength(byteLength: number): number;
@@ -0,0 +1,16 @@
1
+ export declare const BLINDING_FILE_MAX_BYTES = 1024;
2
+ export interface BlindingFileV1 {
3
+ value: Uint8Array;
4
+ digest: string;
5
+ byteLength: string;
6
+ }
7
+ export type BlindingFileRefusal = 'over-cap' | 'not-utf8' | 'not-json' | 'not-object' | 'fields' | 'schema' | 'alg' | 'value' | 'digest' | 'byteLength' | 'not-canonical';
8
+ export type ParsedBlindingFile = {
9
+ ok: true;
10
+ blinding: BlindingFileV1;
11
+ } | {
12
+ ok: false;
13
+ reason: BlindingFileRefusal;
14
+ };
15
+ export declare function serializeBlindingFile(blinding: BlindingFileV1): string;
16
+ export declare function parseBlindingFile(bytes: Uint8Array): ParsedBlindingFile;
@@ -0,0 +1,10 @@
1
+ import type { PayloadByteSource } from '../proof/payload-ref-v1';
2
+ export declare const BLINDING_VALUE_BYTES = 32;
3
+ export declare class BlindingError extends Error {
4
+ constructor(message?: string);
5
+ }
6
+ export declare function assertBlindingValue(value: unknown): asserts value is Uint8Array;
7
+ export declare function chunksOf(source: PayloadByteSource): AsyncGenerator<Uint8Array>;
8
+ export declare function isNodeRuntime(): boolean;
9
+ export declare function loadNodeCrypto(): Promise<typeof import('node:crypto')>;
10
+ export declare const toHex: (bytes: Uint8Array) => string;
@@ -0,0 +1,2 @@
1
+ export * from './index';
2
+ export * from './asymmetric';
@@ -0,0 +1,42 @@
1
+ import { type RecordDisclosure } from './record-disclosure-v1';
2
+ export declare const RECORD_DISCLOSURE_ENVELOPE_VERSION_V1 = 1;
3
+ export declare const RECORD_DISCLOSURE_PAD_BLOCK_V1 = 4096;
4
+ export declare const RECORD_DISCLOSURE_ENVELOPE_MAX_BYTES_V1: number;
5
+ export declare const RECORD_DISCLOSURE_ENVELOPE_MAX_CHARS_V1: number;
6
+ export type DisclosureEnvelopeRefusalV1 = 'DISCLOSURE_ENVELOPE_MALFORMED' | 'DISCLOSURE_ENVELOPE_TOO_LARGE' | 'DISCLOSURE_ENVELOPE_AUTH_FAILED';
7
+ export declare function newDisclosureKeyV1(): Uint8Array;
8
+ export declare function disclosureFragmentV1(key: Uint8Array): string;
9
+ export declare function readDisclosureFragmentV1(hash: string): Uint8Array | null;
10
+ export type DisclosureLinkFragmentV2 = {
11
+ kind: 'key';
12
+ key: Uint8Array;
13
+ } | {
14
+ kind: 'digest';
15
+ digest: string;
16
+ };
17
+ export declare function readDisclosureLinkFragmentV2(hash: string): DisclosureLinkFragmentV2 | null;
18
+ export declare function disclosureDigestFragmentV2(digest: string): string;
19
+ export declare function readDisclosureEnvelopeShapeV1(text: string): {
20
+ ok: true;
21
+ byteLength: number;
22
+ } | {
23
+ ok: false;
24
+ code: 'DISCLOSURE_ENVELOPE_MALFORMED' | 'DISCLOSURE_ENVELOPE_TOO_LARGE';
25
+ };
26
+ export declare function encryptDisclosureV1(input: {
27
+ disclosure: RecordDisclosure;
28
+ key: Uint8Array;
29
+ handle: string;
30
+ }): Promise<string>;
31
+ export declare function decryptDisclosureV1(input: {
32
+ envelope: string;
33
+ key: Uint8Array | CryptoKey;
34
+ handle: string;
35
+ }): Promise<{
36
+ ok: true;
37
+ disclosure: unknown;
38
+ } | {
39
+ ok: false;
40
+ code: DisclosureEnvelopeRefusalV1;
41
+ reason: string;
42
+ }>;
@@ -0,0 +1,17 @@
1
+ export interface HeldFile {
2
+ sha256: string;
3
+ byteLength: string;
4
+ hmac?: {
5
+ digest: string;
6
+ blindingDigest: string;
7
+ blindingByteLength: string;
8
+ };
9
+ }
10
+ export interface HeldFileMatch {
11
+ matched: boolean;
12
+ matchedIndex: number | null;
13
+ blinded: boolean;
14
+ blindingNeeded: boolean;
15
+ refused: null | 'blinding-length' | 'blinding-digest';
16
+ }
17
+ export declare function matchHeldFile(items: unknown, held: HeldFile): HeldFileMatch;
@@ -0,0 +1,8 @@
1
+ import type { PayloadByteSource, PayloadRefV1 } from '../proof/payload-ref-v1';
2
+ export declare const hmacNode: {
3
+ hmacSha256(key: Uint8Array, source: PayloadByteSource): Promise<{
4
+ digest: string;
5
+ byteLength: string;
6
+ }>;
7
+ blindedDigest(source: PayloadByteSource, value: Uint8Array): Promise<PayloadRefV1>;
8
+ };
@@ -0,0 +1,8 @@
1
+ import type { PayloadByteSource, PayloadRefV1 } from '../proof/payload-ref-v1';
2
+ export declare const hmacWeb: {
3
+ hmacSha256(key: Uint8Array, source: PayloadByteSource): Promise<{
4
+ digest: string;
5
+ byteLength: string;
6
+ }>;
7
+ blindedDigest(source: PayloadByteSource, value: Uint8Array): Promise<PayloadRefV1>;
8
+ };
@@ -0,0 +1,13 @@
1
+ import type { PayloadByteSource, PayloadRefV1 } from '../proof/payload-ref-v1';
2
+ export { BLINDING_FILE_SCHEMA_V1 } from '../proof/payload-ref-v1';
3
+ export { BLINDING_VALUE_BYTES, BlindingError, assertBlindingValue } from './blinding-value';
4
+ export { BLINDING_FILE_MAX_BYTES, parseBlindingFile, serializeBlindingFile, type BlindingFileRefusal, type BlindingFileV1, type ParsedBlindingFile, } from './blinding-file';
5
+ export { matchHeldFile, type HeldFile, type HeldFileMatch } from './held-file';
6
+ export * from './record-hash-v2';
7
+ export * from './record-hash-v3';
8
+ export * from './record-disclosure-v1';
9
+ export * from './disclosure-envelope-v1';
10
+ export * from './wrap-shapes-v1';
11
+ export { RECORDS_ENCRYPTION_LABELS_V1, RECORDS_ENCRYPTION_PAD_BLOCK_V1, RECORD_ENTRY_PLAINTEXT_MAX_BYTES_V1, RECORD_ENTRY_CIPHERTEXT_MAX_BYTES_V1, RECORD_ENTRY_CIPHERTEXT_MAX_CHARS_V1, RECORD_ENTRY_BODY_MAX_BYTES_V1, RECORDS_KEYRING_MAX_BYTES_V1, RECORDS_KEYRING_SCHEMA_V1, WORKSPACE_SECRET_BYTES_V1, RecordsEncryptionError, RecordsIdKeyV1, RecordsKeyV1, RecordsWrapKeyV1, RecordKeyV1, RecordsContentTagKeyV2, RECORDS_CONTENT_TAG_LABELS_V2, RecordsKeyringV1, exportKeyBytesV1, generateWorkspaceSecretV1, deriveRecordsIdKeyV1, deriveRecordsKeysV1, importWorkspaceSecretKeyV1, deriveRecordsIdKeyFromBaseV1, deriveRecordsKeysFromBaseV1, recordKeyOfV1, recordKeyFromBytesV1, recordsKeyFromBytesV1, wireRecordIdV1, wireReferenceIdV1, blindedLabelV1, contentTagV1, contentTagV2, recordEntryPlaintextV1, padRecordEntryV1, sealRecordEntryV1, readRecordEnvelopeShapeV1, openRecordEntryEnvelopeV1, encryptedWriteBodyBytesV1, checkEncryptedWriteSizeV1, entryRefsMatchV1, localRecordsKeyProviderV1, serializeRecordsKeyringFileV1, parseRecordsKeyringFileV1, type RecordsEncryptionCodeV1, type RecordsRefusalV1, type RecordEntryEnvelopeV1, type OpenRecordEntryResultV1, type RecordsKeyProviderV1, type RecordsBaseKeyProviderV1, } from './records-encryption-v1';
12
+ export declare function blindedDigest(source: PayloadByteSource, value: Uint8Array): Promise<PayloadRefV1>;
13
+ export declare function newBlindingValue(): Promise<Uint8Array>;
@@ -0,0 +1,9 @@
1
+ export declare function platformCrypto(): Promise<Crypto>;
2
+ export declare function randomBytes(length: number): Uint8Array;
3
+ export declare function sha256(bytes: Uint8Array): Promise<Uint8Array>;
4
+ export declare function hmacSha256(key: Uint8Array, bytes: Uint8Array): Promise<Uint8Array>;
5
+ export declare function concatBytes(...parts: Uint8Array[]): Uint8Array;
6
+ export declare const utf8: (s: string) => Uint8Array;
7
+ export declare const toHex0x: (bytes: Uint8Array) => string;
8
+ export declare const isHex32: (value: unknown) => value is string;
9
+ export declare function fromHex32(value: string): Uint8Array;