@cortexkit/antigravity-auth-core 2.2.1 → 3.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 (230) hide show
  1. package/README.md +24 -2
  2. package/dist/abort-forwarding.d.ts +3 -0
  3. package/dist/abort-forwarding.d.ts.map +1 -0
  4. package/dist/abort-forwarding.js +19 -0
  5. package/dist/abort-forwarding.js.map +1 -0
  6. package/dist/account-identity.d.ts +52 -0
  7. package/dist/account-identity.d.ts.map +1 -0
  8. package/dist/account-identity.js +66 -0
  9. package/dist/account-identity.js.map +1 -0
  10. package/dist/account-manager.d.ts +228 -43
  11. package/dist/account-manager.d.ts.map +1 -1
  12. package/dist/account-manager.js +942 -903
  13. package/dist/account-manager.js.map +1 -1
  14. package/dist/account-migration.d.ts +309 -0
  15. package/dist/account-migration.d.ts.map +1 -0
  16. package/dist/account-migration.js +2282 -0
  17. package/dist/account-migration.js.map +1 -0
  18. package/dist/account-repository-codecs.d.ts +82 -0
  19. package/dist/account-repository-codecs.d.ts.map +1 -0
  20. package/dist/account-repository-codecs.js +609 -0
  21. package/dist/account-repository-codecs.js.map +1 -0
  22. package/dist/account-repository-types.d.ts +831 -0
  23. package/dist/account-repository-types.d.ts.map +1 -0
  24. package/dist/account-repository-types.js +137 -0
  25. package/dist/account-repository-types.js.map +1 -0
  26. package/dist/account-repository.d.ts +442 -0
  27. package/dist/account-repository.d.ts.map +1 -0
  28. package/dist/account-repository.js +2253 -0
  29. package/dist/account-repository.js.map +1 -0
  30. package/dist/account-selector.d.ts +470 -0
  31. package/dist/account-selector.d.ts.map +1 -0
  32. package/dist/account-selector.js +1383 -0
  33. package/dist/account-selector.js.map +1 -0
  34. package/dist/account-storage.d.ts.map +1 -1
  35. package/dist/account-storage.js +5 -0
  36. package/dist/account-storage.js.map +1 -1
  37. package/dist/agy-transport.d.ts.map +1 -1
  38. package/dist/agy-transport.js +21 -35
  39. package/dist/agy-transport.js.map +1 -1
  40. package/dist/antigravity-command-menu.d.ts +171 -0
  41. package/dist/antigravity-command-menu.d.ts.map +1 -0
  42. package/dist/antigravity-command-menu.js +523 -0
  43. package/dist/antigravity-command-menu.js.map +1 -0
  44. package/dist/atomic-write.d.ts +18 -1
  45. package/dist/atomic-write.d.ts.map +1 -1
  46. package/dist/atomic-write.js +15 -3
  47. package/dist/atomic-write.js.map +1 -1
  48. package/dist/common-auth-embedded/NOTICE.txt +21 -0
  49. package/dist/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
  50. package/dist/common-auth-embedded/auth-menu/accounts.js +387 -0
  51. package/dist/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
  52. package/dist/common-auth-embedded/auth-menu/ansi.js +98 -0
  53. package/dist/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
  54. package/dist/common-auth-embedded/auth-menu/confirm.js +21 -0
  55. package/dist/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
  56. package/dist/common-auth-embedded/auth-menu/doctor.js +81 -0
  57. package/dist/common-auth-embedded/auth-menu/index.d.ts +17 -0
  58. package/dist/common-auth-embedded/auth-menu/index.js +12 -0
  59. package/dist/common-auth-embedded/auth-menu/login.d.ts +55 -0
  60. package/dist/common-auth-embedded/auth-menu/login.js +83 -0
  61. package/dist/common-auth-embedded/auth-menu/menu.d.ts +59 -0
  62. package/dist/common-auth-embedded/auth-menu/menu.js +73 -0
  63. package/dist/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
  64. package/dist/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
  65. package/dist/common-auth-embedded/auth-menu/select.d.ts +21 -0
  66. package/dist/common-auth-embedded/auth-menu/select.js +159 -0
  67. package/dist/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
  68. package/dist/common-auth-embedded/auth-menu/terminal.js +19 -0
  69. package/dist/common-auth-embedded/claustrum/consumer.d.ts +102 -0
  70. package/dist/common-auth-embedded/claustrum/consumer.js +298 -0
  71. package/dist/common-auth-embedded/claustrum/custody.d.ts +175 -0
  72. package/dist/common-auth-embedded/claustrum/custody.js +354 -0
  73. package/dist/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
  74. package/dist/common-auth-embedded/claustrum/enrollment.js +759 -0
  75. package/dist/common-auth-embedded/claustrum/errors.d.ts +16 -0
  76. package/dist/common-auth-embedded/claustrum/errors.js +8 -0
  77. package/dist/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
  78. package/dist/common-auth-embedded/claustrum/host-slot.js +72 -0
  79. package/dist/common-auth-embedded/claustrum/index.d.ts +18 -0
  80. package/dist/common-auth-embedded/claustrum/index.js +22 -0
  81. package/dist/common-auth-embedded/claustrum/interlock.d.ts +27 -0
  82. package/dist/common-auth-embedded/claustrum/interlock.js +29 -0
  83. package/dist/common-auth-embedded/claustrum/roster.d.ts +208 -0
  84. package/dist/common-auth-embedded/claustrum/roster.js +536 -0
  85. package/dist/common-auth-embedded/commands/builtins.d.ts +71 -0
  86. package/dist/common-auth-embedded/commands/builtins.js +534 -0
  87. package/dist/common-auth-embedded/commands/index.d.ts +10 -0
  88. package/dist/common-auth-embedded/commands/index.js +5 -0
  89. package/dist/common-auth-embedded/commands/menu.d.ts +61 -0
  90. package/dist/common-auth-embedded/commands/menu.js +300 -0
  91. package/dist/common-auth-embedded/commands/model.d.ts +238 -0
  92. package/dist/common-auth-embedded/commands/model.js +16 -0
  93. package/dist/common-auth-embedded/commands/pi.d.ts +23 -0
  94. package/dist/common-auth-embedded/commands/pi.js +206 -0
  95. package/dist/common-auth-embedded/commands/seam.d.ts +72 -0
  96. package/dist/common-auth-embedded/commands/seam.js +301 -0
  97. package/dist/common-auth-embedded/fs/atomic-write.d.ts +20 -0
  98. package/dist/common-auth-embedded/fs/atomic-write.js +80 -0
  99. package/dist/common-auth-embedded/fs/index.d.ts +7 -0
  100. package/dist/common-auth-embedded/fs/index.js +6 -0
  101. package/dist/common-auth-embedded/fs/lock-constants.d.ts +14 -0
  102. package/dist/common-auth-embedded/fs/lock-constants.js +14 -0
  103. package/dist/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
  104. package/dist/common-auth-embedded/fs/refresh-file-lock.js +501 -0
  105. package/dist/common-auth-embedded/fs/with-lock.d.ts +33 -0
  106. package/dist/common-auth-embedded/fs/with-lock.js +48 -0
  107. package/dist/common-auth-embedded/logger/capture-sink.d.ts +14 -0
  108. package/dist/common-auth-embedded/logger/capture-sink.js +13 -0
  109. package/dist/common-auth-embedded/logger/engine.d.ts +100 -0
  110. package/dist/common-auth-embedded/logger/engine.js +246 -0
  111. package/dist/common-auth-embedded/logger/index.d.ts +6 -0
  112. package/dist/common-auth-embedded/logger/index.js +3 -0
  113. package/dist/common-auth-embedded/logger/redact.d.ts +11 -0
  114. package/dist/common-auth-embedded/logger/redact.js +83 -0
  115. package/dist/common-auth-embedded/pi-slot/index.d.ts +3 -0
  116. package/dist/common-auth-embedded/pi-slot/index.js +2 -0
  117. package/dist/common-auth-embedded/pi-slot/lock.js +212 -0
  118. package/dist/common-auth-embedded/pi-slot/slot.d.ts +49 -0
  119. package/dist/common-auth-embedded/pi-slot/slot.js +383 -0
  120. package/dist/common-auth-embedded/quota/codec.d.ts +11 -0
  121. package/dist/common-auth-embedded/quota/codec.js +12 -0
  122. package/dist/common-auth-embedded/quota/format.d.ts +46 -0
  123. package/dist/common-auth-embedded/quota/format.js +138 -0
  124. package/dist/common-auth-embedded/quota/index.d.ts +10 -0
  125. package/dist/common-auth-embedded/quota/index.js +5 -0
  126. package/dist/common-auth-embedded/quota/map.d.ts +63 -0
  127. package/dist/common-auth-embedded/quota/map.js +105 -0
  128. package/dist/common-auth-embedded/quota/merge.d.ts +48 -0
  129. package/dist/common-auth-embedded/quota/merge.js +162 -0
  130. package/dist/common-auth-embedded/quota/projection.d.ts +64 -0
  131. package/dist/common-auth-embedded/quota/projection.js +134 -0
  132. package/dist/common-auth-embedded/routing/admission.d.ts +93 -0
  133. package/dist/common-auth-embedded/routing/admission.js +142 -0
  134. package/dist/common-auth-embedded/routing/index.d.ts +8 -0
  135. package/dist/common-auth-embedded/routing/index.js +4 -0
  136. package/dist/common-auth-embedded/routing/ordered.d.ts +47 -0
  137. package/dist/common-auth-embedded/routing/ordered.js +58 -0
  138. package/dist/common-auth-embedded/routing/pins.d.ts +22 -0
  139. package/dist/common-auth-embedded/routing/pins.js +34 -0
  140. package/dist/common-auth-embedded/routing/sticky.d.ts +158 -0
  141. package/dist/common-auth-embedded/routing/sticky.js +339 -0
  142. package/dist/common-auth-embedded/source-output.json +1090 -0
  143. package/dist/common-auth-embedded/store/attribution.d.ts +28 -0
  144. package/dist/common-auth-embedded/store/attribution.js +60 -0
  145. package/dist/common-auth-embedded/store/errors.d.ts +55 -0
  146. package/dist/common-auth-embedded/store/errors.js +38 -0
  147. package/dist/common-auth-embedded/store/hooks.d.ts +12 -0
  148. package/dist/common-auth-embedded/store/hooks.js +34 -0
  149. package/dist/common-auth-embedded/store/identity.d.ts +39 -0
  150. package/dist/common-auth-embedded/store/identity.js +79 -0
  151. package/dist/common-auth-embedded/store/index.d.ts +21 -0
  152. package/dist/common-auth-embedded/store/index.js +7 -0
  153. package/dist/common-auth-embedded/store/mutate.d.ts +189 -0
  154. package/dist/common-auth-embedded/store/mutate.js +500 -0
  155. package/dist/common-auth-embedded/store/pool.d.ts +196 -0
  156. package/dist/common-auth-embedded/store/pool.js +120 -0
  157. package/dist/common-auth-embedded/store/provider-state.d.ts +131 -0
  158. package/dist/common-auth-embedded/store/provider-state.js +226 -0
  159. package/dist/common-auth-embedded/store/publication.d.ts +47 -0
  160. package/dist/common-auth-embedded/store/publication.js +304 -0
  161. package/dist/common-auth-embedded/store/pull.d.ts +36 -0
  162. package/dist/common-auth-embedded/store/pull.js +143 -0
  163. package/dist/common-auth-embedded/store/refresh-lock.d.ts +63 -0
  164. package/dist/common-auth-embedded/store/refresh-lock.js +136 -0
  165. package/dist/common-auth-embedded/store/refresh.d.ts +72 -0
  166. package/dist/common-auth-embedded/store/refresh.js +225 -0
  167. package/dist/common-auth-embedded/store/reserved.js +13 -0
  168. package/dist/common-auth-embedded/store/rows.d.ts +313 -0
  169. package/dist/common-auth-embedded/store/rows.js +1258 -0
  170. package/dist/common-auth-embedded/store/runtime.d.ts +36 -0
  171. package/dist/common-auth-embedded/store/runtime.js +68 -0
  172. package/dist/common-auth-embedded/store/schema.d.ts +443 -0
  173. package/dist/common-auth-embedded/store/schema.js +754 -0
  174. package/dist/common-auth-embedded/store/settings.d.ts +63 -0
  175. package/dist/common-auth-embedded/store/settings.js +120 -0
  176. package/dist/common-auth-embedded/store/torn.d.ts +78 -0
  177. package/dist/common-auth-embedded/store/torn.js +294 -0
  178. package/dist/common-auth-embedded/util/any-signal.js +42 -0
  179. package/dist/common-auth-runtime.d.ts +73 -0
  180. package/dist/common-auth-runtime.d.ts.map +1 -0
  181. package/dist/common-auth-runtime.js +65 -0
  182. package/dist/common-auth-runtime.js.map +1 -0
  183. package/dist/credential-redaction.d.ts +13 -0
  184. package/dist/credential-redaction.d.ts.map +1 -0
  185. package/dist/credential-redaction.js +230 -0
  186. package/dist/credential-redaction.js.map +1 -0
  187. package/dist/fetch-timeout.d.ts +4 -2
  188. package/dist/fetch-timeout.d.ts.map +1 -1
  189. package/dist/fetch-timeout.js +121 -14
  190. package/dist/fetch-timeout.js.map +1 -1
  191. package/dist/index.d.ts +16 -1
  192. package/dist/index.d.ts.map +1 -1
  193. package/dist/index.js +15 -0
  194. package/dist/index.js.map +1 -1
  195. package/dist/quota-manager.d.ts.map +1 -1
  196. package/dist/quota-manager.js +35 -10
  197. package/dist/quota-manager.js.map +1 -1
  198. package/dist/quota-presentation.d.ts +10 -0
  199. package/dist/quota-presentation.d.ts.map +1 -0
  200. package/dist/quota-presentation.js +60 -0
  201. package/dist/quota-presentation.js.map +1 -0
  202. package/dist/quota-types.d.ts +2 -0
  203. package/dist/quota-types.d.ts.map +1 -1
  204. package/dist/rotation.d.ts +8 -0
  205. package/dist/rotation.d.ts.map +1 -1
  206. package/dist/rotation.js +24 -0
  207. package/dist/rotation.js.map +1 -1
  208. package/dist/transform/claude.d.ts +7 -3
  209. package/dist/transform/claude.d.ts.map +1 -1
  210. package/dist/transform/claude.js +6 -2
  211. package/dist/transform/claude.js.map +1 -1
  212. package/dist/transform/types.d.ts +1 -1
  213. package/dist/transform/types.d.ts.map +1 -1
  214. package/dist/vault-account-source.d.ts +183 -0
  215. package/dist/vault-account-source.d.ts.map +1 -0
  216. package/dist/vault-account-source.js +296 -0
  217. package/dist/vault-account-source.js.map +1 -0
  218. package/dist/vault-enrollment-authority.d.ts +16 -0
  219. package/dist/vault-enrollment-authority.d.ts.map +1 -0
  220. package/dist/vault-enrollment-authority.js +19 -0
  221. package/dist/vault-enrollment-authority.js.map +1 -0
  222. package/dist/vault-family.d.ts +11 -0
  223. package/dist/vault-family.d.ts.map +1 -0
  224. package/dist/vault-family.js +24 -0
  225. package/dist/vault-family.js.map +1 -0
  226. package/dist/vault-provider-state.d.ts +162 -0
  227. package/dist/vault-provider-state.d.ts.map +1 -0
  228. package/dist/vault-provider-state.js +422 -0
  229. package/dist/vault-provider-state.js.map +1 -0
  230. package/package.json +39 -2
@@ -0,0 +1,313 @@
1
+ import type { Attribution } from './attribution.js';
2
+ import { PoolOperationError } from './errors.js';
3
+ import { type Transaction } from './mutate.js';
4
+ import { type ProviderStateWrite, type RowTransitionMutator, type UpdateProviderStateResult } from './provider-state.js';
5
+ import type { PoolLockSpec } from './refresh-lock.js';
6
+ import { type StoreRuntime } from './runtime.js';
7
+ import { type CredentialBinding, type PoolCredential, type PoolRow, type RotateCredential, type StagedStamp, type StoredCredential } from './schema.js';
8
+ import { type StampedTransition } from './torn.js';
9
+ export type FailureHook = (rowId: string, error: PoolOperationError) => void | Promise<void>;
10
+ export interface RowOperationOptions {
11
+ /** Called once, awaited, on every non-success path, before locks release. */
12
+ onFailure?: FailureHook;
13
+ /** The provider-wide lock, when an operation may change identity keying. */
14
+ providerLock?: PoolLockSpec;
15
+ /**
16
+ * Further locks taken after the row lock and the provider-wide lock, in
17
+ * this order, before the store locks: the same place `refresh` takes its
18
+ * extra locks, so a caller holding legacy locks around a row write and a
19
+ * refresh of that row acquire them in one order and cannot deadlock.
20
+ */
21
+ extraLocks?: readonly PoolLockSpec[];
22
+ }
23
+ export interface RowProjection {
24
+ id: string;
25
+ type: 'oauth' | 'api';
26
+ label?: string;
27
+ enabled: boolean;
28
+ disabledReason?: string;
29
+ identity?: string;
30
+ credentialEpoch?: number;
31
+ stamp?: PoolRow['stamp'];
32
+ staged?: {
33
+ reservation: string;
34
+ };
35
+ torn?: true;
36
+ invalid?: 'roster' | 'entry';
37
+ }
38
+ export interface ProtectView {
39
+ id: string;
40
+ row?: RowProjection;
41
+ rows: RowProjection[];
42
+ config: Readonly<Record<string, unknown>>;
43
+ }
44
+ export type ProtectFn = (view: ProtectView) => string | undefined | Promise<string | undefined>;
45
+ export interface AddOptions extends RowOperationOptions {
46
+ onExisting?: 'rotate' | 'refuse' | 'stage-duplicate';
47
+ protect?: ProtectFn;
48
+ }
49
+ export declare function protectIn(tx: Transaction, id: string, protect?: ProtectFn): Promise<void>;
50
+ /** Options of `replace` and `rotate`. Without `attribution` a call behaves as before. */
51
+ export interface RowWriteOptions extends RowOperationOptions {
52
+ /**
53
+ * The credential epoch and recorded identity the caller read the row at
54
+ * when it decided on this write; an identity left out means the row had
55
+ * none. Compared exactly, under the row and store locks, before any write
56
+ * or replacement hook, including the completion of an interrupted replace.
57
+ * The call is refused (`attribution`, retryable, nothing written) once the
58
+ * row holds another epoch or identity, so a write decided on an older
59
+ * credential never overwrites the one that replaced it. `disable`, `enable`,
60
+ * `recordQuota` and `updateProviderState` take the same fence.
61
+ */
62
+ attribution?: Attribution;
63
+ }
64
+ /**
65
+ * Options of `disable`, `enable` and `remove`. The provider-wide lock guards
66
+ * changes to the recorded identity a row lock is named by; none of these
67
+ * three records an identity, so none takes it. The extra locks are taken
68
+ * where every other row write takes them, after the row lock and before the
69
+ * store locks.
70
+ */
71
+ export type RowToggleOptions = Pick<RowOperationOptions, 'onFailure' | 'extraLocks'>;
72
+ /** What a `remove` protect predicate is shown, read under every lock. */
73
+ export interface RemoveView {
74
+ /**
75
+ * The row as loaded; undefined when the roster no longer holds the id and
76
+ * only its state-file entry is left (an add or removal interrupted between writes).
77
+ */
78
+ row: PoolRow | undefined;
79
+ /** The config file as read under the store locks. */
80
+ config: Readonly<Record<string, unknown>>;
81
+ /** The state file as read under the store locks. */
82
+ state: Readonly<Record<string, unknown>>;
83
+ }
84
+ export interface RemoveOptions extends RowToggleOptions {
85
+ /** Exact reservation required to remove a row that is still staged. */
86
+ staged?: {
87
+ reservation: string;
88
+ };
89
+ /**
90
+ * The credential the removal was decided for (since 0.11.7). Checked under
91
+ * every lock, before `protect` and before anything is written or repaired:
92
+ * - a roster row must be bound to its credential stamp, not torn, and hold
93
+ * exactly this epoch and recorded identity (absence included);
94
+ * - an orphan (only a state-file entry left, by a removal or add
95
+ * interrupted between its writes) must carry a stamp this store can bind
96
+ * to the credential beside it, and that stamp must name exactly this
97
+ * epoch and identity.
98
+ * Epochs only grow per id (a removal records the dropped epoch, and a later
99
+ * add of the id starts past it), so an orphan an interrupted later add
100
+ * left under the same id never matches the epoch of the row the caller
101
+ * meant to remove. A mismatch refuses with kind `attribution`, an orphan
102
+ * or row with no bindable stamp with kind `unbound-credential`; both leave
103
+ * the files byte for byte unchanged. Without it, `remove` drops whatever
104
+ * the id holds, as before.
105
+ *
106
+ * The epoch survives a refresh or `rotate`, so it names a credential
107
+ * lineage, not one token: a caller that must remove only an exact token
108
+ * still checks the loaded credential in `protect`.
109
+ */
110
+ attribution?: Attribution;
111
+ /**
112
+ * Awaited under every lock before anything is written; a reason refuses
113
+ * the removal (kind `row-protected`) with both files unchanged. The store
114
+ * keeps no record of a plugin's in-flight work, so this is where a plugin
115
+ * refuses an id it reserves or one its own pending-operation record (kept
116
+ * in the config or state file) still names: reading that record from the
117
+ * locked files here cannot race a writer that holds the store locks.
118
+ */
119
+ protect?: (id: string, view: RemoveView) => string | undefined | Promise<string | undefined>;
120
+ }
121
+ export type RemoveResult = {
122
+ id: string;
123
+ /**
124
+ * `removed`: the roster row was dropped (and its state entry, if any).
125
+ * `completed`: only a state-file entry was left, by a removal interrupted
126
+ * between its config and state writes or an add interrupted before its
127
+ * config write, and it is now dropped.
128
+ */
129
+ outcome: 'removed' | 'completed';
130
+ };
131
+ /**
132
+ * Options of `reorder`. It names no row, so its failure hook is handed only
133
+ * the failure; it takes no row lock and no provider-wide lock, so the extra
134
+ * locks are taken first, then the store locks.
135
+ */
136
+ export interface ReorderOptions {
137
+ /** Called once, awaited, on every non-success path, before the extra locks release. */
138
+ onFailure?: (error: PoolOperationError) => void | Promise<void>;
139
+ /** Locks taken, in this order, before the store locks. */
140
+ extraLocks?: readonly PoolLockSpec[];
141
+ }
142
+ export type ReorderResult = {
143
+ /** The roster order now on disk. */
144
+ ids: string[];
145
+ /** `unchanged` when the roster was already in this order; nothing was written. */
146
+ outcome: 'reordered' | 'unchanged';
147
+ };
148
+ export interface AddInput {
149
+ id: string;
150
+ credential: PoolCredential;
151
+ identity?: string;
152
+ label?: string;
153
+ disabled?: {
154
+ reason: string;
155
+ };
156
+ stage?: {
157
+ reservation: string;
158
+ };
159
+ /**
160
+ * Provider state for the credential, written in the same state write as
161
+ * the credential (needs the store's provider-state codec). On an `add`
162
+ * that rotates a row already holding this secret it is merged with the
163
+ * row's value (`ProviderStateCodec.merge`); left out, that row keeps its
164
+ * value.
165
+ */
166
+ providerState?: unknown;
167
+ }
168
+ /** What `replace` and `rotate` take beside the credential. */
169
+ export interface CredentialWriteInput {
170
+ identity?: string;
171
+ /**
172
+ * Provider state written in the same state write as the credential. For
173
+ * `rotate` it is merged with the row's value; left out, the row keeps its
174
+ * value. For `replace` see `ProviderStateCodec.onReplace`.
175
+ */
176
+ providerState?: unknown;
177
+ }
178
+ export type AddResult = {
179
+ /** The row holding the credential; an existing row's id on a re-add. */
180
+ id: string;
181
+ outcome: 'added' | 'added-disabled' | 'completed' | 'rotated' | 'exists';
182
+ credential: StoredCredential;
183
+ credentialEpoch: number;
184
+ };
185
+ /**
186
+ * Build the credential and its state entry without writing. The stamp records
187
+ * the credential's epoch, identity and API endpoint so readers can verify that
188
+ * they belong together. A replacement records the new epoch and account; a
189
+ * rotation keeps the current epoch, account and quota. Pending writes are read
190
+ * as completed when choosing those fields, even while disk config is behind.
191
+ * Endpoint checks and provider-state encoding finish here, before any repair.
192
+ */
193
+ declare function planRotationIn(rt: StoreRuntime, tx: Transaction, id: string, given: RotateCredential, extra?: {
194
+ stamp?: number;
195
+ clearErrors?: boolean;
196
+ binding?: CredentialBinding;
197
+ identity?: string;
198
+ providerState?: ProviderStateWrite;
199
+ /** Config transition persisted with the successor credential for crash recovery. */
200
+ transition?: StampedTransition;
201
+ staged?: StagedStamp;
202
+ }): {
203
+ stored: StoredCredential;
204
+ account: Record<string, unknown>;
205
+ };
206
+ /** Validate the endpoint and encode provider state and its stamp before committing state. */
207
+ export declare function rotateIn(rt: StoreRuntime, tx: Transaction, id: string, given: RotateCredential, extra?: Parameters<typeof planRotationIn>[4]): Promise<StoredCredential>;
208
+ export declare function validateAttribution(operation: PoolOperationError['operation'], id: string, fence: Attribution | undefined): void;
209
+ /** Exact recorded identity, including absence, is part of a credential fence. */
210
+ export declare function assertRowAttribution(operation: PoolOperationError['operation'], id: string, row: PoolRow | undefined, fence: Attribution): void;
211
+ export declare function addRow(rt: StoreRuntime, input: AddInput, options?: AddOptions): Promise<AddResult>;
212
+ export declare function replaceRow(rt: StoreRuntime, id: string, credential: PoolCredential, input?: CredentialWriteInput, options?: RowWriteOptions): Promise<{
213
+ id: string;
214
+ credential: StoredCredential;
215
+ credentialEpoch: number;
216
+ }>;
217
+ export declare function rotateRow(rt: StoreRuntime, id: string, credential: RotateCredential, input?: CredentialWriteInput, options?: RowWriteOptions): Promise<{
218
+ id: string;
219
+ credential: StoredCredential;
220
+ }>;
221
+ /**
222
+ * Options of `disable` and `enable`. A call that passes neither
223
+ * `attribution` nor `providerState` behaves exactly as it did before 0.7.0.
224
+ */
225
+ export interface RowTransitionOptions extends RowToggleOptions {
226
+ protect?: ProtectFn;
227
+ /**
228
+ * The credential epoch and recorded identity the caller's evidence for the
229
+ * transition was obtained under (as `recordQuota`'s attribution: an
230
+ * identity left out means the row had none). The call is refused
231
+ * (`attribution`, retryable, nothing written) once the row holds another
232
+ * epoch or identity, so a provider's late answer about a replaced
233
+ * credential never disables, or switches back on, the row now holding its
234
+ * successor.
235
+ */
236
+ attribution?: Attribution;
237
+ /**
238
+ * A provider-state change made in the same transaction as the transition,
239
+ * under the rules of `updateProviderState` (codec validation, the stamp
240
+ * rebound to the value, `unbound-credential` for a row no stamp of this
241
+ * store can bind it to); it requires `attribution`. The value and the
242
+ * enabled flag land together: no reader, and no crash at any write point,
243
+ * shows one without the other. Returning `DECLINE_TRANSITION` declines the
244
+ * whole call and writes nothing.
245
+ */
246
+ providerState?: RowTransitionMutator;
247
+ }
248
+ export interface RowTransitionResult {
249
+ id: string;
250
+ /** The provider-state mutator declined: nothing was written. */
251
+ declined?: true;
252
+ /**
253
+ * Set when a provider-state mutator ran and did not decline: what it did
254
+ * to the value, as `updateProviderState` reports it.
255
+ */
256
+ providerStateOutcome?: UpdateProviderStateResult['outcome'];
257
+ /** The provider state the row now holds, when a mutator ran and left one. */
258
+ providerState?: unknown;
259
+ }
260
+ /**
261
+ * Marks a row disabled with a reason. See `RowTransitionOptions` for the
262
+ * attributed form, which may change the provider state with it.
263
+ */
264
+ export declare function disableRow(rt: StoreRuntime, id: string, reason: string, options?: RowTransitionOptions): Promise<RowTransitionResult>;
265
+ /**
266
+ * Clears a row's `enabled: false` and its `disabledReason` in one config
267
+ * write. An identity-contradicted row refuses with `identity-contradicted`
268
+ * until the caller validates a replacement's identity and supplies it to replace.
269
+ * An OAuth row whose recorded identity another enabled OAuth row holds
270
+ * stays disabled and the call refuses (`duplicate-identity`): the same rule
271
+ * that makes `add` store such a row disabled. Enabling a row that is already
272
+ * enabled writes nothing. See `RowTransitionOptions` for the attributed
273
+ * form, which may change the provider state with it.
274
+ */
275
+ export declare function enableRow(rt: StoreRuntime, id: string, options?: RowTransitionOptions): Promise<RowTransitionResult>;
276
+ /**
277
+ * Deletes a row: its roster row and per-row entry (quota, epoch; the identity
278
+ * lives in the roster row) in one config write, then its credential and
279
+ * runtime fields in one state write. The config goes first, so a crash
280
+ * between the two leaves a row every reader already sees as removed, with
281
+ * only an orphaned state entry that no reader loads; calling `remove` again
282
+ * drops that entry (`completed`). As with every id the store drops, the id is
283
+ * not reused by `add` in this process, and the config write records the
284
+ * row's credential epoch, so an `add` of the id in any other process starts
285
+ * past it (see `nextAddEpochIn`).
286
+ */
287
+ export declare function removeRow(rt: StoreRuntime, id: string, options?: RemoveOptions): Promise<RemoveResult>;
288
+ /** An attributed removal of a roster row: bound, not torn, same epoch and identity. */
289
+ export declare function assertBoundRowAttribution(id: string, row: PoolRow, fence: Attribution, operation?: PoolOperationError['operation']): void;
290
+ /**
291
+ * Sets the roster order in one config write. `ids` must name every roster id
292
+ * exactly once; anything else refuses (`invalid-order`) before writing. The
293
+ * roster rows, the per-row entries and the state file are left as they are:
294
+ * only the order of the legacy `accounts` array changes, which older readers
295
+ * load as is. It takes the extra locks, then the store locks, and no row or
296
+ * provider-wide lock, since no row's credential, identity or quota changes.
297
+ * An order equal to the current one writes nothing.
298
+ */
299
+ export declare function reorderRows(rt: StoreRuntime, ids: readonly string[], options?: ReorderOptions): Promise<ReorderResult>;
300
+ /**
301
+ * Records the wire identity an identity lookup found for a row's credential.
302
+ * `attribution` is the credential epoch the lookup was issued for (a row
303
+ * without an entry is at epoch 1): a lookup that completes after the row was
304
+ * replaced is refused (`attribution`), as a quota reading would be, so the
305
+ * first credential's account is never recorded on the second credential. A
306
+ * row already recorded for another account refuses (`identity-mismatch`):
307
+ * that is a replacement, not something learnt about the same credential.
308
+ */
309
+ export declare function recordRowIdentity(rt: StoreRuntime, id: string, identity: string, attribution: Pick<Attribution, 'credentialEpoch'>, options?: RowOperationOptions): Promise<{
310
+ id: string;
311
+ disabled: string[];
312
+ }>;
313
+ export {};