@@ -19,15 +19,25 @@ export interface UseKeyRotationOptions extends SensitiveInfoOptions {
1919 readonly reEncryptEagerly ?: boolean
2020}
2121
22+ /** Per-call overrides accepted by {@link UseKeyRotationResult.rotate}. */
23+ export interface RotateCallOptions {
24+ readonly reEncryptEagerly ?: boolean
25+ }
26+
2227export interface UseKeyRotationResult {
2328 /** Most recent rotation result, if any. */
2429 readonly lastResult : RotationResult | null
2530 /** Current error bag for rotation operations. */
2631 readonly error : HookError | null
2732 /** True while a rotation call is in flight. */
2833 readonly isRotating : boolean
29- /** Trigger a master-key rotation for the configured service. */
30- readonly rotate : ( ) => Promise < HookMutationResult >
34+ /**
35+ * Trigger a master-key rotation for the configured service. Pass
36+ * `{ reEncryptEagerly: true }` to override the hook-level default for this call only.
37+ */
38+ readonly rotate : (
39+ overrides ?: RotateCallOptions
40+ ) => Promise < HookMutationResult >
3141 /** Imperatively read the active key version from the native module. */
3242 readonly readVersion : ( ) => Promise < number | null >
3343}
@@ -51,18 +61,22 @@ export function useKeyRotation(
5161 'Check that the service exists and that no auth-gated entries are blocking eager rotation.'
5262 )
5363
54- const rotate = useCallback ( async ( ) : Promise < HookMutationResult > => {
55- const request : RotateKeysRequest = {
56- ...options ,
57- reEncryptEagerly : options ?. reEncryptEagerly ?? false ,
58- }
59- const outcome = await mutate ( ( ) => rotateKeys ( request ) )
60- if ( outcome . success ) {
61- setLastResult ( outcome . data )
62- return createHookSuccessResult ( )
63- }
64- return createHookFailureResult ( outcome . error )
65- } , [ mutate , options ] )
64+ const rotate = useCallback (
65+ async ( overrides ?: RotateCallOptions ) : Promise < HookMutationResult > => {
66+ const request : RotateKeysRequest = {
67+ ...options ,
68+ reEncryptEagerly :
69+ overrides ?. reEncryptEagerly ?? options ?. reEncryptEagerly ?? false ,
70+ }
71+ const outcome = await mutate ( ( ) => rotateKeys ( request ) )
72+ if ( outcome . success ) {
73+ setLastResult ( outcome . data )
74+ return createHookSuccessResult ( )
75+ }
76+ return createHookFailureResult ( outcome . error )
77+ } ,
78+ [ mutate , options ]
79+ )
6680
6781 const readVersion = useCallback ( async ( ) => {
6882 try {
0 commit comments