@umbra-privacy/sdk 1.0.0 → 2.0.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 (181) hide show
  1. package/README.md +104 -25
  2. package/dist/{addresses-Brzgurv_.d.ts → addresses-B7HybtbJ.d.ts} +2 -1
  3. package/dist/{addresses-D_0YAS6B.d.cts → addresses-CTVY1oi7.d.cts} +2 -1
  4. package/dist/arcium-BXXlryfe.d.cts +20 -0
  5. package/dist/arcium-BXXlryfe.d.ts +20 -0
  6. package/dist/chunk-4RHXVBNI.js +203 -0
  7. package/dist/chunk-4RHXVBNI.js.map +1 -0
  8. package/dist/chunk-4TZVXB5G.js +324 -0
  9. package/dist/chunk-4TZVXB5G.js.map +1 -0
  10. package/dist/chunk-5GUSMQ74.cjs +549 -0
  11. package/dist/chunk-5GUSMQ74.cjs.map +1 -0
  12. package/dist/chunk-5KPQXPQM.js +36 -0
  13. package/dist/chunk-5KPQXPQM.js.map +1 -0
  14. package/dist/chunk-AXD7LXYY.cjs +405 -0
  15. package/dist/chunk-AXD7LXYY.cjs.map +1 -0
  16. package/dist/{chunk-HOEXDXRC.cjs → chunk-BL6WXLPV.cjs} +32 -360
  17. package/dist/chunk-BL6WXLPV.cjs.map +1 -0
  18. package/dist/chunk-CFFLOE7D.cjs +598 -0
  19. package/dist/chunk-CFFLOE7D.cjs.map +1 -0
  20. package/dist/{chunk-BM7N6N7E.js → chunk-CFTW5WNG.js} +3 -325
  21. package/dist/chunk-CFTW5WNG.js.map +1 -0
  22. package/dist/chunk-DD2WCK4C.js +327 -0
  23. package/dist/chunk-DD2WCK4C.js.map +1 -0
  24. package/dist/chunk-DMPMQ74B.cjs +246 -0
  25. package/dist/chunk-DMPMQ74B.cjs.map +1 -0
  26. package/dist/{chunk-2Q75CQQJ.js → chunk-EEKF4553.js} +2 -2
  27. package/dist/chunk-EEKF4553.js.map +1 -0
  28. package/dist/chunk-ENVYYEM4.cjs +113 -0
  29. package/dist/chunk-ENVYYEM4.cjs.map +1 -0
  30. package/dist/chunk-FQX6ZYGJ.js +500 -0
  31. package/dist/chunk-FQX6ZYGJ.js.map +1 -0
  32. package/dist/chunk-FSK2ICMB.cjs +39 -0
  33. package/dist/chunk-FSK2ICMB.cjs.map +1 -0
  34. package/dist/chunk-FZYWLQAF.cjs +355 -0
  35. package/dist/chunk-FZYWLQAF.cjs.map +1 -0
  36. package/dist/chunk-GP26R377.js +436 -0
  37. package/dist/chunk-GP26R377.js.map +1 -0
  38. package/dist/chunk-HA5FLM63.js +393 -0
  39. package/dist/chunk-HA5FLM63.js.map +1 -0
  40. package/dist/chunk-INJ73LXQ.js +1107 -0
  41. package/dist/chunk-INJ73LXQ.js.map +1 -0
  42. package/dist/chunk-JPDF7BIT.cjs +10892 -0
  43. package/dist/chunk-JPDF7BIT.cjs.map +1 -0
  44. package/dist/{chunk-MDFSBU5W.cjs → chunk-LTCKPTZC.cjs} +2 -351
  45. package/dist/chunk-LTCKPTZC.cjs.map +1 -0
  46. package/dist/chunk-MKNCBUFA.js +564 -0
  47. package/dist/chunk-MKNCBUFA.js.map +1 -0
  48. package/dist/chunk-NKVMSABR.cjs +207 -0
  49. package/dist/chunk-NKVMSABR.cjs.map +1 -0
  50. package/dist/chunk-OFDWNWCL.js +70 -0
  51. package/dist/chunk-OFDWNWCL.js.map +1 -0
  52. package/dist/chunk-QJAUUYZU.cjs +331 -0
  53. package/dist/chunk-QJAUUYZU.cjs.map +1 -0
  54. package/dist/chunk-RVUYPKKD.js +10750 -0
  55. package/dist/chunk-RVUYPKKD.js.map +1 -0
  56. package/dist/chunk-TLR7A64G.js +103 -0
  57. package/dist/chunk-TLR7A64G.js.map +1 -0
  58. package/dist/{chunk-MVKTV3FT.cjs → chunk-TQQZGNOI.cjs} +2 -2
  59. package/dist/chunk-TQQZGNOI.cjs.map +1 -0
  60. package/dist/chunk-UOFYS6M3.js +219 -0
  61. package/dist/chunk-UOFYS6M3.js.map +1 -0
  62. package/dist/chunk-UXMQI6B7.js +2406 -0
  63. package/dist/chunk-UXMQI6B7.js.map +1 -0
  64. package/dist/chunk-WN75ORDT.js +571 -0
  65. package/dist/chunk-WN75ORDT.js.map +1 -0
  66. package/dist/chunk-Y55PYKXH.cjs +595 -0
  67. package/dist/chunk-Y55PYKXH.cjs.map +1 -0
  68. package/dist/chunk-YEZBTYCP.cjs +77 -0
  69. package/dist/chunk-YEZBTYCP.cjs.map +1 -0
  70. package/dist/chunk-ZQOIYCGA.cjs +1126 -0
  71. package/dist/chunk-ZQOIYCGA.cjs.map +1 -0
  72. package/dist/chunk-ZY3TSHMJ.cjs +2665 -0
  73. package/dist/chunk-ZY3TSHMJ.cjs.map +1 -0
  74. package/dist/client-DkVBHMWb.d.cts +2613 -0
  75. package/dist/client-V4AF6Bz9.d.ts +2613 -0
  76. package/dist/common/pda/index.cjs +145 -0
  77. package/dist/common/pda/index.cjs.map +1 -0
  78. package/dist/common/pda/index.d.cts +1250 -0
  79. package/dist/common/pda/index.d.ts +1250 -0
  80. package/dist/common/pda/index.js +8 -0
  81. package/dist/common/pda/index.js.map +1 -0
  82. package/dist/constants/index.cjs +38 -164
  83. package/dist/constants/index.cjs.map +1 -1
  84. package/dist/constants/index.d.cts +8 -425
  85. package/dist/constants/index.d.ts +8 -425
  86. package/dist/constants/index.js +15 -124
  87. package/dist/constants/index.js.map +1 -1
  88. package/dist/crypto/index.cjs +583 -0
  89. package/dist/crypto/index.cjs.map +1 -0
  90. package/dist/crypto/index.d.cts +6731 -0
  91. package/dist/crypto/index.d.ts +6731 -0
  92. package/dist/crypto/index.js +14 -0
  93. package/dist/crypto/index.js.map +1 -0
  94. package/dist/{cryptography-BTGC72u-.d.ts → cryptography-BFSJcvi6.d.ts} +3 -2465
  95. package/dist/{cryptography-BTGC72u-.d.cts → cryptography-D6tPDh-Y.d.cts} +3 -2465
  96. package/dist/errors/index.cjs +64 -54
  97. package/dist/errors/index.d.cts +7 -797
  98. package/dist/errors/index.d.ts +7 -797
  99. package/dist/errors/index.js +3 -1
  100. package/dist/errors-B9EoPeWV.d.cts +593 -0
  101. package/dist/errors-B9EoPeWV.d.ts +593 -0
  102. package/dist/errors-DAIrstEL.d.cts +300 -0
  103. package/dist/errors-DPNMfyh0.d.ts +300 -0
  104. package/dist/index-BG0yjL7C.d.cts +6006 -0
  105. package/dist/index-ByynoyBO.d.ts +6006 -0
  106. package/dist/index.cjs +5126 -16118
  107. package/dist/index.cjs.map +1 -1
  108. package/dist/index.d.cts +1031 -7685
  109. package/dist/index.d.ts +1031 -7685
  110. package/dist/index.js +3219 -14905
  111. package/dist/index.js.map +1 -1
  112. package/dist/interfaces/index.d.cts +14 -6
  113. package/dist/interfaces/index.d.ts +14 -6
  114. package/dist/interfaces-43cReBcS.d.cts +3346 -0
  115. package/dist/interfaces-B8xKNl_6.d.ts +997 -0
  116. package/dist/interfaces-D2NO6kDD.d.cts +997 -0
  117. package/dist/interfaces-z_xYJlgV.d.ts +3346 -0
  118. package/dist/math/index.cjs +115 -0
  119. package/dist/math/index.cjs.map +1 -0
  120. package/dist/math/index.d.cts +1327 -0
  121. package/dist/math/index.d.ts +1327 -0
  122. package/dist/math/index.js +10 -0
  123. package/dist/math/index.js.map +1 -0
  124. package/dist/networks-RMd3abPE.d.ts +44 -0
  125. package/dist/networks-yAoO8peQ.d.cts +44 -0
  126. package/dist/relayer-NRRMSMNB.js +4 -0
  127. package/dist/relayer-NRRMSMNB.js.map +1 -0
  128. package/dist/relayer-RJHEIXJG.cjs +21 -0
  129. package/dist/relayer-RJHEIXJG.cjs.map +1 -0
  130. package/dist/solana/index.cjs +56 -0
  131. package/dist/solana/index.cjs.map +1 -0
  132. package/dist/solana/index.d.cts +105 -0
  133. package/dist/solana/index.d.ts +105 -0
  134. package/dist/solana/index.js +7 -0
  135. package/dist/solana/index.js.map +1 -0
  136. package/dist/{index-CLj_zWSD.d.ts → temporal-BbRaEPoO.d.ts} +1 -1
  137. package/dist/{index-CX6_pIRS.d.cts → temporal-oUj7iCaq.d.cts} +1 -1
  138. package/dist/transaction-forwarder-5mAMTjw6.d.ts +1155 -0
  139. package/dist/transaction-forwarder-C6gMUG7a.d.cts +1155 -0
  140. package/dist/types/index.cjs +232 -231
  141. package/dist/types/index.d.cts +15 -1485
  142. package/dist/types/index.d.ts +15 -1485
  143. package/dist/types/index.js +2 -1
  144. package/dist/types-BohhvPth.d.cts +87 -0
  145. package/dist/types-CW0oTT0j.d.ts +87 -0
  146. package/dist/types-C_V_CaKK.d.cts +2468 -0
  147. package/dist/types-C_V_CaKK.d.ts +2468 -0
  148. package/dist/types-Ca7frykr.d.ts +793 -0
  149. package/dist/types-CuKeoI19.d.cts +1296 -0
  150. package/dist/types-CxfTIpN9.d.ts +1052 -0
  151. package/dist/{types-n-sHFcgr.d.ts → types-D1jDUjfN.d.ts} +2 -2
  152. package/dist/types-DKEDUlH9.d.ts +1296 -0
  153. package/dist/types-EKuIfxTz.d.cts +1052 -0
  154. package/dist/{types-BBuELtY8.d.cts → types-IMGYmlv-.d.cts} +2 -2
  155. package/dist/types-PwNLi_2k.d.cts +793 -0
  156. package/dist/utils/index.cjs +823 -525
  157. package/dist/utils/index.d.cts +1711 -4021
  158. package/dist/utils/index.d.ts +1711 -4021
  159. package/dist/utils/index.js +9 -3
  160. package/dist/{versions-D9PqsEvj.d.cts → versions-BRlR36EA.d.cts} +1 -0
  161. package/dist/{versions-D9PqsEvj.d.ts → versions-BRlR36EA.d.ts} +1 -0
  162. package/package.json +79 -18
  163. package/dist/chunk-2Q75CQQJ.js.map +0 -1
  164. package/dist/chunk-BM7N6N7E.js.map +0 -1
  165. package/dist/chunk-GXKSUB2U.cjs +0 -4416
  166. package/dist/chunk-GXKSUB2U.cjs.map +0 -1
  167. package/dist/chunk-HOEXDXRC.cjs.map +0 -1
  168. package/dist/chunk-MDFSBU5W.cjs.map +0 -1
  169. package/dist/chunk-MQY7HDIA.js +0 -600
  170. package/dist/chunk-MQY7HDIA.js.map +0 -1
  171. package/dist/chunk-MVKTV3FT.cjs.map +0 -1
  172. package/dist/chunk-PG2J6V6Y.js +0 -4094
  173. package/dist/chunk-PG2J6V6Y.js.map +0 -1
  174. package/dist/chunk-VEGLTTYQ.cjs +0 -621
  175. package/dist/chunk-VEGLTTYQ.cjs.map +0 -1
  176. package/dist/chunk-WVHQ46DD.js +0 -758
  177. package/dist/chunk-WVHQ46DD.js.map +0 -1
  178. package/dist/index-B9pDY73x.d.ts +0 -12933
  179. package/dist/index-D33yo0qB.d.cts +0 -12933
  180. package/dist/networks-C-orpSFW.d.ts +0 -65
  181. package/dist/networks-FxYERGD1.d.cts +0 -65
@@ -0,0 +1,1052 @@
1
+ import { N as Network } from './versions-BRlR36EA.js';
2
+ import { h as U512, b as SubBrandedType, g as BrandedType, S as SubSubBrandedType, B as Bytes } from './types-C_V_CaKK.js';
3
+ import { M as MasterSeed } from './cryptography-BFSJcvi6.js';
4
+ import { Transaction, TransactionWithBlockhashLifetime } from '@solana/kit';
5
+
6
+ /**
7
+ * Storage Types for Key Management
8
+ *
9
+ * This module defines types and interfaces for loading, storing, and generating
10
+ * cryptographic keys and derived values. The storage system supports both persistent
11
+ * storage (e.g., IndexedDB, local storage) and ephemeral storage (in-memory only).
12
+ *
13
+ * @remarks
14
+ * The storage abstraction allows callers to supply custom persistence backends for
15
+ * the SDK's cryptographic keys without coupling the SDK to any particular storage
16
+ * technology. The most security-sensitive type here is `MasterSeed`, whose loader,
17
+ * storer, and generator functions control the full lifecycle of the root key.
18
+ *
19
+ * All load/store operations are asynchronous to support remote key management services
20
+ * (e.g., cloud HSMs, encrypted databases) without blocking the main thread.
21
+ *
22
+ * @packageDocumentation
23
+ * @since 2.0.0
24
+ * @module types/storage
25
+ */
26
+
27
+ /**
28
+ * Result of a load operation.
29
+ *
30
+ * @remarks
31
+ * A discriminated union that signals whether a stored value was found. When `exists` is
32
+ * `true`, the `seed` field contains the loaded value. When `exists` is `false`, the caller
33
+ * should generate a new value and store it.
34
+ *
35
+ * @typeParam T - The type of value being loaded
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const result = await loadMasterSeed();
40
+ * if (result.exists) {
41
+ * // Use result.seed
42
+ * } else {
43
+ * // Generate and store a new seed
44
+ * }
45
+ * ```
46
+ *
47
+ * @public
48
+ */
49
+ type LoadResult<T> = {
50
+ readonly exists: true;
51
+ readonly seed: T;
52
+ } | {
53
+ readonly exists: false;
54
+ };
55
+ /**
56
+ * Result of a store operation.
57
+ *
58
+ * @remarks
59
+ * A discriminated union that signals whether the store succeeded. When `success` is `false`,
60
+ * the `error` field contains a human-readable description of what went wrong (e.g., quota
61
+ * exceeded, permission denied, serialization failure).
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const result = await storeMasterSeed(seed);
66
+ * if (!result.success) {
67
+ * console.error("Failed to persist seed:", result.error);
68
+ * // Optionally continue with in-memory seed only
69
+ * }
70
+ * ```
71
+ *
72
+ * @public
73
+ */
74
+ type StoreResult = {
75
+ readonly success: true;
76
+ } | {
77
+ readonly success: false;
78
+ readonly error: string;
79
+ };
80
+ /**
81
+ * Context information for key storage operations.
82
+ *
83
+ * This context is passed to load and store functions to provide all the necessary
84
+ * information about the key being stored or loaded, including versioning information,
85
+ * network, and derivation parameters.
86
+ *
87
+ * @remarks
88
+ * The context ensures that keys are stored and retrieved with the correct version and
89
+ * parameter information, preventing version mismatches across SDK upgrades. The combination
90
+ * of `signerAddress`, `network`, `domainSeparator`, and all three version strings forms a
91
+ * unique storage key that can be used as a lookup identifier in any key-value store.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const context: KeyStorageContext = {
96
+ * signerAddress: "7xKXt...",
97
+ * domainSeparator: "MasterViewingKey/0",
98
+ * network: "mainnet-beta",
99
+ * protocolVersion: "1.0.0",
100
+ * algorithmVersion: "1.0.0",
101
+ * schemeVersion: "1.0.0",
102
+ * };
103
+ * const result = await loaderFn(context);
104
+ * ```
105
+ *
106
+ * @public
107
+ */
108
+ interface KeyStorageContext {
109
+ /**
110
+ * The signer's public key / wallet address (user identifier).
111
+ *
112
+ * @remarks
113
+ * Used to namespace stored keys per user so that multiple wallets can use the same
114
+ * storage backend without interference.
115
+ * @readonly
116
+ */
117
+ readonly signerAddress: string;
118
+ /**
119
+ * Domain separator for key derivation (e.g., `"MasterViewingKey/0"`).
120
+ *
121
+ * @remarks
122
+ * The domain separator ensures that keys derived for different purposes are
123
+ * cryptographically independent even when derived from the same root material.
124
+ * @readonly
125
+ */
126
+ readonly domainSeparator: string;
127
+ /**
128
+ * Network environment (e.g., `"mainnet-beta"`, `"devnet"`).
129
+ *
130
+ * @remarks
131
+ * Prevents keys generated on devnet from being mistakenly used on mainnet.
132
+ * @readonly
133
+ */
134
+ readonly network: Network;
135
+ /**
136
+ * Protocol version string (e.g., `"1.0.0"`).
137
+ *
138
+ * @remarks
139
+ * Bumped when the on-chain protocol changes in a way that requires fresh keys.
140
+ * @readonly
141
+ */
142
+ readonly protocolVersion: string;
143
+ /**
144
+ * Algorithm version string (e.g., `"1.0.0"`).
145
+ *
146
+ * @remarks
147
+ * Bumped when the cryptographic algorithm (hash function, cipher) changes.
148
+ * @readonly
149
+ */
150
+ readonly algorithmVersion: string;
151
+ /**
152
+ * Scheme version string (e.g., `"1.0.0"`).
153
+ *
154
+ * @remarks
155
+ * Bumped when the key derivation scheme (domain separators, input ordering) changes.
156
+ * @readonly
157
+ */
158
+ readonly schemeVersion: string;
159
+ /**
160
+ * Optional derivation parameters (e.g., `{ year: "2024", mint: "7xKXt..." }`).
161
+ *
162
+ * @remarks
163
+ * Supplied for parameterized keys (yearly viewing keys, mint-specific keys) to distinguish
164
+ * storage entries for different time periods or token mints.
165
+ * @readonly
166
+ */
167
+ readonly derivationParams?: Record<string, string>;
168
+ /**
169
+ * Optional offset used in key derivation.
170
+ *
171
+ * @remarks
172
+ * Used when a key is derived with an explicit 512-bit offset (e.g., for generation-indexed
173
+ * AES keys). Most keys do not use this field.
174
+ * @readonly
175
+ */
176
+ readonly offset?: U512;
177
+ }
178
+ /**
179
+ * Loads a value from storage.
180
+ *
181
+ * @remarks
182
+ * Implementations should be idempotent: calling load multiple times with the same context
183
+ * must return the same result (assuming no concurrent stores).
184
+ *
185
+ * @typeParam T - The type of value being loaded
186
+ * @param context - Storage context with version and parameter information
187
+ * @returns A promise that resolves to a `LoadResult` indicating whether the value exists
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const loader: LoaderFunction<MasterViewingKey> = async (context) => {
192
+ * const raw = await db.get(buildKey(context));
193
+ * if (!raw) return { exists: false };
194
+ * return { exists: true, seed: parseMvk(raw) };
195
+ * };
196
+ * ```
197
+ *
198
+ * @public
199
+ */
200
+ type LoaderFunction<T> = (context: KeyStorageContext) => Promise<LoadResult<T>>;
201
+ /**
202
+ * Stores a value to storage.
203
+ *
204
+ * @remarks
205
+ * Implementations should overwrite any previously stored value for the same context.
206
+ * Failures must be reported via a `StoreResult` with `success: false` rather than throwing,
207
+ * unless the failure is catastrophic.
208
+ *
209
+ * @typeParam T - The type of value being stored
210
+ * @param value - The value to store
211
+ * @param context - Storage context with version and parameter information
212
+ * @returns A promise that resolves to a `StoreResult` indicating success or describing the failure
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const storer: StorerFunction<MasterViewingKey> = async (value, context) => {
217
+ * try {
218
+ * await db.put(buildKey(context), serializeMvk(value));
219
+ * return { success: true };
220
+ * } catch (error) {
221
+ * return { success: false, error: String(error) };
222
+ * }
223
+ * };
224
+ * ```
225
+ *
226
+ * @public
227
+ */
228
+ type StorerFunction<T> = (value: T, context: KeyStorageContext) => Promise<StoreResult>;
229
+ /**
230
+ * Generates a new value.
231
+ *
232
+ * @remarks
233
+ * Called when no stored value is found. The implementation should use the context to
234
+ * deterministically or randomly generate a fresh value. For security-critical keys, the
235
+ * generator should use a cryptographically secure random source.
236
+ *
237
+ * @typeParam T - The type of value being generated
238
+ * @param context - Storage context with version and parameter information
239
+ * @returns A promise that resolves to the freshly generated value
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * const generator: GeneratorFunction<MasterViewingKey> = async (context) => {
244
+ * const entropy = crypto.getRandomValues(new Uint8Array(32));
245
+ * return deriveMasterViewingKey(entropy, context.domainSeparator);
246
+ * };
247
+ * ```
248
+ *
249
+ * @public
250
+ */
251
+ type GeneratorFunction<T> = (context: KeyStorageContext) => Promise<T>;
252
+ /**
253
+ * Loads a value that requires additional parameters (e.g., year, mint address).
254
+ *
255
+ * @remarks
256
+ * Similar to `LoaderFunction`, but accepts an extra `params` argument to disambiguate
257
+ * storage entries when the same key type can exist for multiple parameter values (e.g.,
258
+ * a yearly viewing key for 2023 vs. 2024).
259
+ *
260
+ * @typeParam T - The type of value being loaded
261
+ * @typeParam TParams - The type of extra parameters required for lookup
262
+ * @param params - Parameters for key derivation and lookup (e.g., `{ year: 2024n }`)
263
+ * @param context - Storage context with version and base parameter information
264
+ * @returns A promise that resolves to a `LoadResult` indicating whether the value exists
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * const loader: ParameterizedLoaderFunction<YearlyViewingKey, { year: bigint }> =
269
+ * async (params, context) => {
270
+ * const key = buildYearKey(context, params.year);
271
+ * const raw = await db.get(key);
272
+ * if (!raw) return { exists: false };
273
+ * return { exists: true, seed: parseYvk(raw) };
274
+ * };
275
+ * ```
276
+ *
277
+ * @see {@link LoaderFunction}
278
+ * @public
279
+ */
280
+ type ParameterizedLoaderFunction<T, TParams> = (params: TParams, context: KeyStorageContext) => Promise<LoadResult<T>>;
281
+ /**
282
+ * Stores a value that requires additional parameters.
283
+ *
284
+ * @remarks
285
+ * Similar to `StorerFunction`, but accepts an extra `params` argument so the implementation
286
+ * can construct a unique storage key for each parameter combination.
287
+ *
288
+ * @typeParam T - The type of value being stored
289
+ * @typeParam TParams - The type of extra parameters required for storage
290
+ * @param value - The value to store
291
+ * @param params - Parameters for key derivation and storage (e.g., `{ year: 2024n }`)
292
+ * @param context - Storage context with version and base parameter information
293
+ * @returns A promise that resolves to a `StoreResult` indicating success or describing the failure
294
+ *
295
+ * @see {@link StorerFunction}
296
+ * @public
297
+ */
298
+ type ParameterizedStorerFunction<T, TParams> = (value: T, params: TParams, context: KeyStorageContext) => Promise<StoreResult>;
299
+ /**
300
+ * Generates a value that requires additional parameters.
301
+ *
302
+ * @remarks
303
+ * Similar to `GeneratorFunction`, but accepts `params` to derive a key that is specific to
304
+ * a given parameter set (e.g., deriving a yearly viewing key scoped to a particular year and mint).
305
+ *
306
+ * @typeParam T - The type of value being generated
307
+ * @typeParam TParams - The type of extra parameters required for derivation
308
+ * @param params - Parameters for key derivation (e.g., `{ year: 2024n, mint: "7xKXt..." }`)
309
+ * @param context - Storage context with version and base parameter information
310
+ * @returns A promise that resolves to the freshly generated value
311
+ *
312
+ * @see {@link GeneratorFunction}
313
+ * @public
314
+ */
315
+ type ParameterizedGeneratorFunction<T, TParams> = (params: TParams, context: KeyStorageContext) => Promise<T>;
316
+ /**
317
+ * Loads the master seed from storage.
318
+ *
319
+ * @remarks
320
+ * The master seed is the root of all key derivation. This function should:
321
+ * - Check if a master seed exists in storage
322
+ * - Return the seed if it exists
323
+ * - Return `{ exists: false }` if no seed is stored (caller will then generate one)
324
+ *
325
+ * This function takes no context argument because the master seed is not scoped to any
326
+ * particular set of derivation parameters — it is the single universal root.
327
+ *
328
+ * @returns A promise that resolves to a `LoadResult` containing the master seed if found
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * const loader: MasterSeedLoaderFunction = async () => {
333
+ * const encrypted = localStorage.getItem("umbraMasterSeed");
334
+ * if (!encrypted) return { exists: false };
335
+ * const seed = await decrypt(encrypted);
336
+ * return { exists: true, seed };
337
+ * };
338
+ * ```
339
+ *
340
+ * @see {@link MasterSeed}
341
+ * @see {@link MasterSeedStorerFunction}
342
+ * @see {@link MasterSeedGeneratorFunction}
343
+ * @public
344
+ */
345
+ type MasterSeedLoaderFunction = () => Promise<LoadResult<MasterSeed>>;
346
+ /**
347
+ * Stores the master seed to storage.
348
+ *
349
+ * @remarks
350
+ * This function should securely persist the master seed. The default SDK implementation
351
+ * uses an in-memory closure-based store, but production applications should provide a
352
+ * custom implementation that encrypts the seed before persisting it (e.g., AES-GCM
353
+ * with a password-derived key, or storing in a platform secure enclave).
354
+ *
355
+ * Security guidance:
356
+ * - Never store the raw seed in plaintext on disk or in localStorage
357
+ * - Use authenticated encryption (e.g., AES-256-GCM) to protect the seed at rest
358
+ * - Consider using the platform keychain (Keychain on iOS/macOS, Keystore on Android)
359
+ *
360
+ * @param seed - The master seed to store (64 bytes)
361
+ * @returns A promise that resolves to a `StoreResult` indicating success or describing the failure
362
+ *
363
+ * @example
364
+ * ```typescript
365
+ * const storer: MasterSeedStorerFunction = async (seed) => {
366
+ * try {
367
+ * const encrypted = await encryptWithUserPassword(seed);
368
+ * localStorage.setItem("umbraMasterSeed", encrypted);
369
+ * return { success: true };
370
+ * } catch (error) {
371
+ * return { success: false, error: String(error) };
372
+ * }
373
+ * };
374
+ * ```
375
+ *
376
+ * @see {@link MasterSeed}
377
+ * @see {@link MasterSeedLoaderFunction}
378
+ * @public
379
+ */
380
+ type MasterSeedStorerFunction = (seed: MasterSeed) => Promise<StoreResult>;
381
+ /**
382
+ * Generates a new master seed.
383
+ *
384
+ * @remarks
385
+ * The default SDK implementation follows these steps:
386
+ * 1. Constructs the message: `"Umbra Privacy - Master Seed Generation - {signerAddress}"`
387
+ * 2. Signs the message with the user's wallet signer (producing a deterministic Ed25519 signature)
388
+ * 3. Hashes the signature with KMAC256 (key derivation length = 64) to produce the 512-bit seed
389
+ *
390
+ * This approach makes seed generation deterministic and tied to the user's wallet keypair,
391
+ * so the same wallet always regenerates the same master seed. Applications that prefer
392
+ * non-deterministic seeds can supply a custom generator that uses `crypto.getRandomValues`.
393
+ *
394
+ * @returns A promise that resolves to the freshly generated `MasterSeed` (64 bytes)
395
+ *
396
+ * @example
397
+ * ```typescript
398
+ * // Deterministic (default): derived from wallet signature
399
+ * const generator: MasterSeedGeneratorFunction = async () => {
400
+ * const msg = `Umbra Privacy - Master Seed Generation - ${signerAddress}`;
401
+ * const sig = await signer.signMessage(msg);
402
+ * return kmac256(sig, { dkLen: 64 }) as MasterSeed;
403
+ * };
404
+ * ```
405
+ *
406
+ * @see {@link MasterSeed}
407
+ * @see {@link MasterSeedLoaderFunction}
408
+ * @see {@link MasterSeedStorerFunction}
409
+ * @public
410
+ */
411
+ type MasterSeedGeneratorFunction = () => Promise<MasterSeed>;
412
+
413
+ /**
414
+ * Solana Types Module.
415
+ *
416
+ * This module provides branded types and runtime assertion functions for
417
+ * Solana-specific data structures. By attaching nominal brands to primitive
418
+ * `string` and `Uint8Array` values, and to `@solana/kit` transaction objects,
419
+ * the SDK achieves compile-time safety that prevents common mistakes such as:
420
+ * - Passing a raw string where a `TransactionSignature` is expected.
421
+ * - Submitting an unsigned transaction to a `TransactionForwarder`.
422
+ * - Mixing up different byte-array representations.
423
+ *
424
+ * @remarks
425
+ * **Type hierarchy overview:**
426
+ *
427
+ * String types:
428
+ * - {@link String} — root branded string (base type for all string sub-brands)
429
+ * - {@link TransactionSignature} — base58-encoded Ed25519 signature string
430
+ *
431
+ * Byte array types:
432
+ * - {@link SolanaBytes} — root branded `Uint8Array` for Solana binary data
433
+ * - {@link SignatureBytes} — exactly 64-byte raw Ed25519 signature
434
+ *
435
+ * Transaction types (wrapping `@solana/kit`'s `Transaction`):
436
+ * - {@link UnsignedTransaction} — no signatures present
437
+ * - {@link SignedTransaction} — at least one signature; includes blockhash lifetime
438
+ * - {@link PartiallySignedTransaction} — some but not all required signatures
439
+ * - {@link FullySignedTransaction} — all required signatures present; ready for submission
440
+ *
441
+ * **Runtime assertions:**
442
+ * - {@link assertString} — narrows `string` to `String`
443
+ * - {@link assertTransactionSignature} — narrows `string` to `TransactionSignature` (base58 validated)
444
+ * - {@link assertSolanaBytes} — narrows `Uint8Array` to `SolanaBytes`
445
+ * - {@link assertSignatureBytes} — narrows `Uint8Array` to `SignatureBytes` (64-byte validated)
446
+ *
447
+ * **Error class:**
448
+ * - {@link SolanaAssertionError} — thrown by all assertion functions with structured context
449
+ *
450
+ * @example
451
+ * ```typescript
452
+ * import {
453
+ * assertTransactionSignature,
454
+ * assertSignatureBytes,
455
+ * TransactionSignature,
456
+ * SignatureBytes,
457
+ * } from "./types";
458
+ *
459
+ * const sigString = "5wHu1qwD7q5menT3ydT9VdFPQfkLaWvqPgVbqsM1qwD7";
460
+ * assertTransactionSignature(sigString);
461
+ * // sigString is now typed as TransactionSignature
462
+ *
463
+ * const sigBytes = new Uint8Array(64);
464
+ * assertSignatureBytes(sigBytes);
465
+ * // sigBytes is now typed as SignatureBytes
466
+ * ```
467
+ *
468
+ * @see {@link BrandedType} for the underlying branding utility
469
+ * @see {@link Bytes} for the generic byte array base type
470
+ *
471
+ * @packageDocumentation
472
+ * @since 2.0.0
473
+ * @module types/solana
474
+ */
475
+
476
+ /**
477
+ * Length of an Ed25519 signature in bytes.
478
+ *
479
+ * The Ed25519 signature scheme, used by Solana for all transaction signing,
480
+ * always produces exactly 64-byte signatures:
481
+ * - Bytes 0–31: the R component (a compressed point on the Ed25519 curve)
482
+ * - Bytes 32–63: the S component (a scalar value)
483
+ *
484
+ * @remarks
485
+ * This constant is used by {@link assertSignatureBytes} to validate the length
486
+ * of raw signature byte arrays before branding them as {@link SignatureBytes}.
487
+ *
488
+ * @example
489
+ * ```typescript
490
+ * const raw = new Uint8Array(SIGNATURE_BYTE_LENGTH); // 64-byte zeroed buffer
491
+ * assertSignatureBytes(raw);
492
+ * ```
493
+ *
494
+ * @public
495
+ */
496
+ declare const SIGNATURE_BYTE_LENGTH = 64;
497
+ /**
498
+ * Error thrown when a Solana type assertion function fails.
499
+ *
500
+ * All assertion functions in this module (`assertString`,
501
+ * `assertTransactionSignature`, `assertSolanaBytes`, `assertSignatureBytes`)
502
+ * throw `SolanaAssertionError` when the supplied value does not satisfy the
503
+ * type constraint. The error carries structured fields that make it easy to
504
+ * log diagnostics or write type-specific error handlers.
505
+ *
506
+ * @remarks
507
+ * `SolanaAssertionError` sets `Error.captureStackTrace` (available in V8
508
+ * environments) to exclude the assertion function's own frame from the stack,
509
+ * making the stack trace point to the caller rather than the assertion body.
510
+ *
511
+ * The prototype is explicitly reset via `Object.setPrototypeOf` to ensure
512
+ * `instanceof` works correctly across CommonJS module boundary re-exports.
513
+ *
514
+ * @example
515
+ * Catching and inspecting a failed assertion:
516
+ * ```typescript
517
+ * import { assertTransactionSignature, SolanaAssertionError } from "./types";
518
+ *
519
+ * try {
520
+ * assertTransactionSignature("invalid!sig");
521
+ * } catch (error) {
522
+ * if (error instanceof SolanaAssertionError) {
523
+ * console.error(`Expected: ${error.expectedType}`);
524
+ * console.error(`Constraint: ${error.constraint}`);
525
+ * console.error(`Got: ${String(error.value)}`);
526
+ * }
527
+ * }
528
+ * ```
529
+ *
530
+ * @public
531
+ */
532
+ declare class SolanaAssertionError extends Error {
533
+ /**
534
+ * The actual value that was passed to the assertion function and failed
535
+ * the type check.
536
+ *
537
+ * @remarks
538
+ * Typed as `unknown` because assertion functions accept values of unknown
539
+ * type before narrowing. Inspect carefully — the value may be `undefined`,
540
+ * `null`, or any primitive or object.
541
+ */
542
+ readonly value: unknown;
543
+ /**
544
+ * The name of the expected type (e.g., `"TransactionSignature"`,
545
+ * `"SignatureBytes"`).
546
+ *
547
+ * @remarks
548
+ * Matches the TypeScript type name for the intended branded type, not a
549
+ * JavaScript `typeof` string.
550
+ */
551
+ readonly expectedType: string;
552
+ /**
553
+ * A human-readable description of the specific constraint that was violated,
554
+ * if applicable.
555
+ *
556
+ * @remarks
557
+ * Examples:
558
+ * - `"length > 0"` — empty string passed to `assertTransactionSignature`
559
+ * - `"length === 64"` — wrong byte count passed to `assertSignatureBytes`
560
+ * - `"characters must be in base58 alphabet: 123...xyz"` — invalid character
561
+ *
562
+ * `undefined` when the only constraint is the TypeScript type itself
563
+ * (e.g., `assertString` only checks `typeof value === "string"`).
564
+ */
565
+ readonly constraint: string | undefined;
566
+ /**
567
+ * Creates a new `SolanaAssertionError`.
568
+ *
569
+ * @param message - Human-readable description of the assertion failure.
570
+ * @param options - Structured context for the failed assertion.
571
+ * @param options.value - The value that failed the assertion.
572
+ * @param options.expectedType - The name of the expected branded type.
573
+ * @param options.constraint - The specific constraint that was violated, if any.
574
+ */
575
+ constructor(message: string, options: {
576
+ value: unknown;
577
+ expectedType: string;
578
+ constraint?: string;
579
+ });
580
+ }
581
+ /**
582
+ * Root branded string type for the Solana types module.
583
+ *
584
+ * This is the base type from which all specialized Solana string types derive.
585
+ * Branding it prevents raw `string` literals from being used where a validated
586
+ * Solana string is required, while still allowing structural compatibility with
587
+ * `string` via the underlying primitive.
588
+ *
589
+ * @remarks
590
+ * Prefer the more specific sub-types (e.g., {@link TransactionSignature}) over
591
+ * `String` when the string has additional semantic meaning. Use `String` only
592
+ * when building generic utilities that operate on any validated Solana string
593
+ * and need to accept multiple sub-brands.
594
+ *
595
+ * @example
596
+ * ```typescript
597
+ * function logSolanaString(s: String): void {
598
+ * console.log("Solana string:", s);
599
+ * }
600
+ *
601
+ * const raw = "hello";
602
+ * assertString(raw);
603
+ * logSolanaString(raw); // OK — raw is now branded as String
604
+ * ```
605
+ *
606
+ * @see {@link assertString} for the corresponding runtime assertion
607
+ * @public
608
+ */
609
+ type String = BrandedType<string, "String">;
610
+ /**
611
+ * Base58-encoded Solana transaction signature.
612
+ *
613
+ * A transaction signature is the result of an Ed25519 sign operation on the
614
+ * serialized transaction message. Solana encodes it as a base58 string
615
+ * (approximately 87–88 characters) for human-readable display and API usage.
616
+ *
617
+ * @remarks
618
+ * **Encoding details:**
619
+ * - Underlying binary: 64 bytes (see {@link SignatureBytes})
620
+ * - Base58 alphabet: 58 characters (`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)
621
+ * - Excluded characters: `0`, `O`, `I`, `l` (visually ambiguous)
622
+ * - Typical string length: 87–88 characters
623
+ *
624
+ * **Type safety:** The {@link assertTransactionSignature} function validates
625
+ * that a `string` value is non-empty and contains only Base58 characters before
626
+ * branding it as `TransactionSignature`. This catches obvious data errors at
627
+ * the ingestion boundary.
628
+ *
629
+ * **Note:** Validation is character-level only. The assertion does NOT verify
630
+ * cryptographic correctness (i.e., it does not verify that the signature was
631
+ * produced by a specific keypair).
632
+ *
633
+ * @example
634
+ * Narrowing a raw string to `TransactionSignature`:
635
+ * ```typescript
636
+ * const raw = "5wHu1qwD7q5menT3ydT9VdFPQfkLaWvqPgVbqsM1qwD7";
637
+ * assertTransactionSignature(raw);
638
+ * // raw is now typed as TransactionSignature
639
+ * ```
640
+ *
641
+ * @example
642
+ * Using in a function signature:
643
+ * ```typescript
644
+ * async function getTransactionDetails(sig: TransactionSignature) {
645
+ * return await rpc.getTransaction(sig).send();
646
+ * }
647
+ * ```
648
+ *
649
+ * @see {@link assertTransactionSignature} for the runtime assertion
650
+ * @see {@link SignatureBytes} for the raw binary equivalent
651
+ * @public
652
+ */
653
+ type TransactionSignature = SubBrandedType<String, "TransactionSignature">;
654
+ /**
655
+ * Root branded `Uint8Array` type for Solana binary data.
656
+ *
657
+ * This is the base type for all Solana-specific byte array types. It derives
658
+ * from the generic `Bytes` type and adds the `"SolanaBytes"` nominal brand,
659
+ * distinguishing Solana binary data from other `Uint8Array` values in the SDK.
660
+ *
661
+ * @remarks
662
+ * No specific length constraint — the length depends on the particular data
663
+ * being represented. Sub-types like {@link SignatureBytes} impose their own
664
+ * length requirements.
665
+ *
666
+ * Use `SolanaBytes` when the binary data is Solana-specific but does not fall
667
+ * into a more precise category (e.g., serialized account data, raw message
668
+ * bytes).
669
+ *
670
+ * @example
671
+ * ```typescript
672
+ * const accountData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
673
+ * assertSolanaBytes(accountData);
674
+ * // accountData is now typed as SolanaBytes
675
+ * ```
676
+ *
677
+ * @see {@link assertSolanaBytes} for the runtime assertion
678
+ * @see {@link SignatureBytes} for the 64-byte Ed25519 signature sub-type
679
+ * @public
680
+ */
681
+ type SolanaBytes = SubBrandedType<Bytes, "SolanaBytes">;
682
+ /**
683
+ * 64-byte raw Ed25519 signature in binary form.
684
+ *
685
+ * This type represents the binary encoding of an Ed25519 signature as used
686
+ * internally by the Solana runtime and the `@solana/kit` library. It is the
687
+ * binary equivalent of a {@link TransactionSignature} string — the same 64
688
+ * bytes, without the Base58 encoding.
689
+ *
690
+ * @remarks
691
+ * **Structure:**
692
+ * - Bytes 0–31: R component — a compressed Ed25519 curve point
693
+ * - Bytes 32–63: S component — a scalar in the range `[0, l)` where `l` is
694
+ * the order of the Ed25519 base point
695
+ *
696
+ * **Conversion:**
697
+ * - `SignatureBytes` → `TransactionSignature`: Base58-encode the bytes
698
+ * - `TransactionSignature` → `SignatureBytes`: Base58-decode the string
699
+ *
700
+ * The {@link assertSignatureBytes} function validates both that the value is a
701
+ * `Uint8Array` and that it is exactly {@link SIGNATURE_BYTE_LENGTH} (64) bytes.
702
+ *
703
+ * @example
704
+ * Creating and validating a signature byte array:
705
+ * ```typescript
706
+ * const sigBytes = new Uint8Array(64);
707
+ * // ... fill sigBytes with actual Ed25519 signature material ...
708
+ * assertSignatureBytes(sigBytes);
709
+ * // sigBytes is now typed as SignatureBytes
710
+ * ```
711
+ *
712
+ * @example
713
+ * Using with a Solana transaction builder:
714
+ * ```typescript
715
+ * declare function attachSignature(
716
+ * tx: UnsignedTransaction,
717
+ * publicKey: Address,
718
+ * signature: SignatureBytes,
719
+ * ): PartiallySignedTransaction;
720
+ * ```
721
+ *
722
+ * @see {@link assertSignatureBytes} for the runtime assertion
723
+ * @see {@link TransactionSignature} for the base58-encoded equivalent
724
+ * @see {@link SIGNATURE_BYTE_LENGTH} for the required byte length constant
725
+ * @public
726
+ */
727
+ type SignatureBytes = SubSubBrandedType<SolanaBytes, "SignatureBytes">;
728
+ /**
729
+ * An unsigned Solana transaction — a transaction that has been constructed
730
+ * but has not yet received any signatures.
731
+ *
732
+ * @remarks
733
+ * This type wraps `Transaction` from `@solana/kit` with the `"UnsignedTransaction"`
734
+ * brand. The brand prevents an unsigned transaction from being passed to a
735
+ * `TransactionForwarder` or any function that requires a {@link SignedTransaction},
736
+ * catching the mistake at compile time.
737
+ *
738
+ * **Lifecycle:** Build the transaction message → compile to `Transaction` →
739
+ * brand as `UnsignedTransaction` → sign to produce {@link SignedTransaction}.
740
+ *
741
+ * @example
742
+ * Type-safe transaction building:
743
+ * ```typescript
744
+ * import { UnsignedTransaction } from "./types";
745
+ *
746
+ * function buildTransfer(from: Address, to: Address, amount: bigint): UnsignedTransaction {
747
+ * // ... build and compile message ...
748
+ * return compiledTx as UnsignedTransaction;
749
+ * }
750
+ *
751
+ * const tx = buildTransfer(sender, recipient, 1_000_000n);
752
+ * // tx cannot be passed to forwarder.forwardSequentially — compile error
753
+ * ```
754
+ *
755
+ * @see {@link SignedTransaction} for the signed counterpart
756
+ * @public
757
+ */
758
+ type UnsignedTransaction = BrandedType<Transaction, "UnsignedTransaction">;
759
+ /**
760
+ * A Solana transaction that has at least one signature and a blockhash
761
+ * lifetime constraint.
762
+ *
763
+ * This is the base type for all signed transaction variants. It intersects
764
+ * `Transaction` with `TransactionWithBlockhashLifetime` from `@solana/kit`,
765
+ * ensuring the blockhash expiry window (`blockhash` + `lastValidBlockHeight`)
766
+ * is present alongside the signature data.
767
+ *
768
+ * @remarks
769
+ * **Blockhash lifetime** — The `TransactionWithBlockhashLifetime` intersection
770
+ * ensures that every `SignedTransaction` carries `lifetimeConstraint.blockhash`
771
+ * and `lifetimeConstraint.lastValidBlockHeight`. The forwarder uses these to
772
+ * detect expiry before submission.
773
+ *
774
+ * **Sub-types** — `SignedTransaction` is the common type used in forwarder
775
+ * method signatures because it accepts both {@link PartiallySignedTransaction}
776
+ * and {@link FullySignedTransaction}. Use the more specific sub-types when the
777
+ * exact signing completeness matters to the API contract.
778
+ *
779
+ * @example
780
+ * Accepting any signed transaction (partial or full):
781
+ * ```typescript
782
+ * function logSignedTx(tx: SignedTransaction): void {
783
+ * console.log(`Valid until block: ${tx.lifetimeConstraint.lastValidBlockHeight}`);
784
+ * }
785
+ * ```
786
+ *
787
+ * @see {@link PartiallySignedTransaction} for partial signing state
788
+ * @see {@link FullySignedTransaction} for full signing state
789
+ * @see {@link UnsignedTransaction} for the unsigned state
790
+ * @public
791
+ */
792
+ type SignedTransaction = BrandedType<Transaction & TransactionWithBlockhashLifetime, "SignedTransaction">;
793
+ /**
794
+ * A Solana transaction with some but potentially not all required signatures.
795
+ *
796
+ * A sub-brand of {@link SignedTransaction}. The transaction has been signed by
797
+ * at least one party but may still be missing signatures from other required
798
+ * signers. This state is common in multi-signature workflows where different
799
+ * parties sign at different times or different locations.
800
+ *
801
+ * @remarks
802
+ * In the Umbra SDK, partial signing arises when:
803
+ * - The user's wallet signs the transaction locally.
804
+ * - The relayer counter-signs before submission.
805
+ * - A hardware wallet adds its signature after an initial software signature.
806
+ *
807
+ * A `PartiallySignedTransaction` cannot be submitted to the network until all
808
+ * required signatures are collected, at which point it can be cast (or built
809
+ * up) to {@link FullySignedTransaction}.
810
+ *
811
+ * @example
812
+ * Multi-sig workflow:
813
+ * ```typescript
814
+ * const partial: PartiallySignedTransaction = await userWallet.sign(unsigned);
815
+ * const full: FullySignedTransaction = await relayer.countersign(partial);
816
+ * await forwarder.forwardSequentially([full]);
817
+ * ```
818
+ *
819
+ * @see {@link FullySignedTransaction} for the fully-signed state
820
+ * @see {@link SignedTransaction} for the base signed state
821
+ * @public
822
+ */
823
+ type PartiallySignedTransaction = SubBrandedType<SignedTransaction, "PartiallySignedTransaction">;
824
+ /**
825
+ * A Solana transaction with all required signatures present and ready for
826
+ * network submission.
827
+ *
828
+ * This is the terminal transaction state in the signing lifecycle. A
829
+ * `FullySignedTransaction` has been signed by every required signer and can be
830
+ * submitted to the Solana network via a {@link TransactionForwarder}.
831
+ *
832
+ * @remarks
833
+ * **Compile-time guarantee** — The {@link TransactionForwarder} interface's
834
+ * `forwardSequentially` and `forwardInParallel` methods accept
835
+ * `readonly SignedTransaction[]` (the common base type). Callers that track
836
+ * signing state explicitly can use `FullySignedTransaction` in their own
837
+ * function signatures to signal that all signatures are present.
838
+ *
839
+ * **Branding vs. validation** — The brand is a compile-time assertion — the
840
+ * runtime does NOT verify that all required pubkeys have corresponding
841
+ * signatures. It is the responsibility of the signing workflow to ensure
842
+ * completeness before casting to `FullySignedTransaction`.
843
+ *
844
+ * @example
845
+ * Enforcing full signing at a function boundary:
846
+ * ```typescript
847
+ * import { FullySignedTransaction } from "./types";
848
+ * import type { TransactionForwarder } from "./interfaces";
849
+ *
850
+ * async function submitAll(
851
+ * forwarder: TransactionForwarder,
852
+ * txs: readonly FullySignedTransaction[],
853
+ * ) {
854
+ * return forwarder.forwardSequentially(txs);
855
+ * }
856
+ * ```
857
+ *
858
+ * @see {@link PartiallySignedTransaction} for partial signing state
859
+ * @see {@link SignedTransaction} for the base signed state
860
+ * @see {@link TransactionForwarder} for the submission interface
861
+ * @public
862
+ */
863
+ type FullySignedTransaction = SubSubBrandedType<PartiallySignedTransaction, "FullySignedTransaction">;
864
+ /**
865
+ * Asserts that a value is a primitive `string` and narrows it to {@link String}.
866
+ *
867
+ * This is the base assertion for all Solana branded string types. It only
868
+ * checks that the input is a primitive `string` — no format or content
869
+ * validation is performed.
870
+ *
871
+ * @param value - The value to assert. Must be a primitive string.
872
+ * @throws {SolanaAssertionError} If `typeof value !== "string"`.
873
+ *
874
+ * @remarks
875
+ * For more specific string types, use the dedicated assertion functions:
876
+ * - {@link assertTransactionSignature} — for base58-encoded signatures
877
+ *
878
+ * @example
879
+ * ```typescript
880
+ * const raw: unknown = "hello world";
881
+ * assertString(raw as string);
882
+ * // raw is now typed as String
883
+ *
884
+ * assertString(123 as unknown as string); // Throws: not a string
885
+ * assertString(null as unknown as string); // Throws: not a string
886
+ * ```
887
+ *
888
+ * @see {@link String} for the branded type
889
+ * @see {@link assertTransactionSignature} for the signature-specific assertion
890
+ * @public
891
+ */
892
+ declare function assertString(value: string): asserts value is String;
893
+ /**
894
+ * Asserts that a value is a valid base58-encoded Solana transaction signature
895
+ * and narrows it to {@link TransactionSignature}.
896
+ *
897
+ * Validation rules:
898
+ * 1. `typeof value === "string"`
899
+ * 2. `value.length > 0` (non-empty)
900
+ * 3. Every character is in the Base58 alphabet (`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)
901
+ *
902
+ * @param value - The string to assert as a base58 transaction signature.
903
+ * @throws {SolanaAssertionError} If the value is not a string, is empty, or
904
+ * contains characters outside the Base58 alphabet. The error's `constraint`
905
+ * field identifies which rule was violated, and for alphabet violations,
906
+ * includes the position and character that failed.
907
+ *
908
+ * @remarks
909
+ * **Validation scope** — This function performs character-level validation only.
910
+ * It does NOT verify cryptographic correctness (i.e., it does not check that
911
+ * the 64 decoded bytes constitute a valid Ed25519 signature, nor that the
912
+ * signature was produced by any particular keypair).
913
+ *
914
+ * **Excluded characters** — The Base58 alphabet deliberately omits `0` (zero),
915
+ * `O` (capital O), `I` (capital I), and `l` (lowercase L) to avoid
916
+ * transcription errors. Any of these characters in `value` will cause a throw.
917
+ *
918
+ * **Typical usage** — Call this function at SDK ingestion boundaries (e.g.,
919
+ * when accepting a signature string from user input or an external API) to
920
+ * ensure downstream code only ever sees branded, validated values.
921
+ *
922
+ * @example
923
+ * Validating a signature from an external source:
924
+ * ```typescript
925
+ * const rawSig: string = apiResponse.signature;
926
+ * assertTransactionSignature(rawSig);
927
+ * // rawSig is now typed as TransactionSignature
928
+ * ```
929
+ *
930
+ * @example
931
+ * Invalid inputs:
932
+ * ```typescript
933
+ * assertTransactionSignature(""); // Throws: empty string
934
+ * assertTransactionSignature("hello!world"); // Throws: invalid char '!'
935
+ * assertTransactionSignature("0abc"); // Throws: '0' not in Base58
936
+ * assertTransactionSignature("IIII"); // Throws: 'I' not in Base58
937
+ * ```
938
+ *
939
+ * @see {@link TransactionSignature} for the branded type
940
+ * @see {@link SignatureBytes} for the binary equivalent
941
+ * @public
942
+ */
943
+ declare function assertTransactionSignature(value: string): asserts value is TransactionSignature;
944
+ /**
945
+ * Asserts that a value is a `Uint8Array` and narrows it to {@link SolanaBytes}.
946
+ *
947
+ * This is the base assertion for all Solana byte array types. It only checks
948
+ * that the input is a `Uint8Array` instance — no length validation is performed.
949
+ *
950
+ * @param value - The `Uint8Array` to assert. Must be an instance of `Uint8Array`.
951
+ * @throws {SolanaAssertionError} If `!(value instanceof Uint8Array)`.
952
+ *
953
+ * @remarks
954
+ * For byte arrays with specific length requirements, use the more specific
955
+ * assertion function:
956
+ * - {@link assertSignatureBytes} — for 64-byte Ed25519 signature arrays
957
+ *
958
+ * @example
959
+ * ```typescript
960
+ * const data = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
961
+ * assertSolanaBytes(data);
962
+ * // data is now typed as SolanaBytes
963
+ *
964
+ * assertSolanaBytes([] as unknown as Uint8Array); // Throws: not a Uint8Array
965
+ * assertSolanaBytes("bytes" as unknown as Uint8Array); // Throws: not a Uint8Array
966
+ * ```
967
+ *
968
+ * @see {@link SolanaBytes} for the branded type
969
+ * @see {@link assertSignatureBytes} for the length-constrained variant
970
+ * @public
971
+ */
972
+ declare function assertSolanaBytes(value: Uint8Array): asserts value is SolanaBytes;
973
+ /**
974
+ * Asserts that a value is a `Uint8Array` of exactly {@link SIGNATURE_BYTE_LENGTH}
975
+ * (64) bytes and narrows it to {@link SignatureBytes}.
976
+ *
977
+ * Validation rules:
978
+ * 1. `value instanceof Uint8Array`
979
+ * 2. `value.length === 64`
980
+ *
981
+ * @param value - The `Uint8Array` to assert as a 64-byte Ed25519 signature.
982
+ * @throws {SolanaAssertionError} If the value is not a `Uint8Array` or is not
983
+ * exactly 64 bytes. The error's `constraint` field specifies
984
+ * `"length === 64"` for length violations.
985
+ *
986
+ * @remarks
987
+ * The 64-byte requirement is defined by the Ed25519 specification and is
988
+ * invariant across all Solana Ed25519 signatures. Passing a 63- or 65-byte
989
+ * array will always throw, regardless of the content.
990
+ *
991
+ * **Structure:**
992
+ * - Bytes 0–31: R component (compressed curve point)
993
+ * - Bytes 32–63: S component (scalar)
994
+ *
995
+ * @example
996
+ * Validating a signature byte array:
997
+ * ```typescript
998
+ * const sigBytes = new Uint8Array(64);
999
+ * // ... populate with actual Ed25519 signature bytes ...
1000
+ * assertSignatureBytes(sigBytes);
1001
+ * // sigBytes is now typed as SignatureBytes
1002
+ * ```
1003
+ *
1004
+ * @example
1005
+ * Invalid inputs:
1006
+ * ```typescript
1007
+ * assertSignatureBytes(new Uint8Array(63)); // Throws: expected 64 bytes, got 63
1008
+ * assertSignatureBytes(new Uint8Array(65)); // Throws: expected 64 bytes, got 65
1009
+ * assertSignatureBytes([] as unknown as Uint8Array); // Throws: not a Uint8Array
1010
+ * ```
1011
+ *
1012
+ * @see {@link SignatureBytes} for the branded type
1013
+ * @see {@link SIGNATURE_BYTE_LENGTH} for the required length constant
1014
+ * @see {@link TransactionSignature} for the base58-encoded equivalent
1015
+ * @public
1016
+ */
1017
+ declare function assertSignatureBytes(value: Uint8Array): asserts value is SignatureBytes;
1018
+ /**
1019
+ * Brands a compiled `Transaction` as a {@link SignedTransaction} for relay
1020
+ * submission.
1021
+ *
1022
+ * @remarks
1023
+ * This function is used for transactions that will be signed by the **relayer**,
1024
+ * not by the client. In the Umbra relay flow, the client builds and serializes
1025
+ * a transaction message, which is then passed to the relayer service. The
1026
+ * relayer signs and submits the transaction. Because the blockhash lifetime is
1027
+ * already embedded in the compiled message bytes (`messageBytes`), the
1028
+ * transaction is treated as carrying a blockhash constraint even though
1029
+ * `lifetimeConstraint` is not set as a TypeScript property.
1030
+ *
1031
+ * **This is an escape hatch** — it performs an unchecked cast. Use only when
1032
+ * you are certain the compiled message bytes include a valid blockhash and the
1033
+ * relayer will supply the required signature before submission.
1034
+ *
1035
+ * @param tx - A `Transaction` object whose compiled message bytes already
1036
+ * embed the blockhash lifetime constraint.
1037
+ * @returns The same `Transaction` value cast to {@link SignedTransaction}.
1038
+ *
1039
+ * @example
1040
+ * ```typescript
1041
+ * import { asRelayableSignedTransaction } from "./types";
1042
+ *
1043
+ * const compiledTx: Transaction = compileTransactionMessage(txMessage);
1044
+ * const relayable = asRelayableSignedTransaction(compiledTx);
1045
+ * // relayable can now be passed to relayer submission APIs
1046
+ * ```
1047
+ *
1048
+ * @public
1049
+ */
1050
+ declare function asRelayableSignedTransaction(tx: Transaction): SignedTransaction;
1051
+
1052
+ export { type FullySignedTransaction as F, type GeneratorFunction as G, type KeyStorageContext as K, type LoaderFunction as L, type MasterSeedLoaderFunction as M, type ParameterizedLoaderFunction as P, type SignedTransaction as S, type TransactionSignature as T, type UnsignedTransaction as U, type MasterSeedStorerFunction as a, type MasterSeedGeneratorFunction as b, type StorerFunction as c, type ParameterizedStorerFunction as d, type ParameterizedGeneratorFunction as e, type LoadResult as f, type StoreResult as g, type PartiallySignedTransaction as h, SIGNATURE_BYTE_LENGTH as i, type SignatureBytes as j, SolanaAssertionError as k, type SolanaBytes as l, type String as m, asRelayableSignedTransaction as n, assertSignatureBytes as o, assertSolanaBytes as p, assertString as q, assertTransactionSignature as r };