@buoy-gg/impersonate 7.0.41 → 7.0.43

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 (78) hide show
  1. package/README.md +12 -80
  2. package/lib/commonjs/impersonate/components/DataNukeSettings.js +8 -675
  3. package/lib/commonjs/impersonate/components/ImpersonateBanner.js +1 -221
  4. package/lib/commonjs/impersonate/components/ImpersonateHistoryList.js +1 -181
  5. package/lib/commonjs/impersonate/components/ImpersonateModal.js +1 -319
  6. package/lib/commonjs/impersonate/components/ImpersonateOverlay.js +1 -26
  7. package/lib/commonjs/impersonate/components/ImpersonateStatusBar.js +1 -130
  8. package/lib/commonjs/impersonate/components/UserAvatar.js +1 -146
  9. package/lib/commonjs/impersonate/components/UserCard.js +1 -201
  10. package/lib/commonjs/impersonate/components/UserSearchView.js +1 -227
  11. package/lib/commonjs/impersonate/hooks/asyncStoragePeer.js +1 -17
  12. package/lib/commonjs/impersonate/hooks/asyncStoragePeer.web.js +1 -11
  13. package/lib/commonjs/impersonate/hooks/useAutoClearAsyncStorage.js +1 -134
  14. package/lib/commonjs/impersonate/hooks/useAutoClearReactQuery.js +1 -155
  15. package/lib/commonjs/impersonate/hooks/useAutoClearReactQuery.web.js +1 -20
  16. package/lib/commonjs/impersonate/hooks/useAutoClearRedux.js +1 -188
  17. package/lib/commonjs/impersonate/hooks/useAutoClearRedux.web.js +1 -27
  18. package/lib/commonjs/impersonate/hooks/useImpersonate.js +1 -215
  19. package/lib/commonjs/impersonate/hooks/useImpersonateHistory.js +1 -56
  20. package/lib/commonjs/impersonate/types/index.js +1 -16
  21. package/lib/commonjs/impersonate/types/types.js +1 -1
  22. package/lib/commonjs/impersonate/utils/impersonateListener.js +1 -350
  23. package/lib/commonjs/impersonate/utils/impersonateStore.js +1 -689
  24. package/lib/commonjs/index.js +1 -150
  25. package/lib/commonjs/preset.js +1 -232
  26. package/lib/commonjs/sync/impersonateSyncAdapter.js +1 -170
  27. package/lib/module/impersonate/components/DataNukeSettings.js +8 -670
  28. package/lib/module/impersonate/components/ImpersonateBanner.js +1 -215
  29. package/lib/module/impersonate/components/ImpersonateHistoryList.js +1 -176
  30. package/lib/module/impersonate/components/ImpersonateModal.js +1 -314
  31. package/lib/module/impersonate/components/ImpersonateOverlay.js +1 -21
  32. package/lib/module/impersonate/components/ImpersonateStatusBar.js +1 -125
  33. package/lib/module/impersonate/components/UserAvatar.js +1 -140
  34. package/lib/module/impersonate/components/UserCard.js +1 -196
  35. package/lib/module/impersonate/components/UserSearchView.js +1 -222
  36. package/lib/module/impersonate/hooks/asyncStoragePeer.js +1 -13
  37. package/lib/module/impersonate/hooks/asyncStoragePeer.web.js +1 -6
  38. package/lib/module/impersonate/hooks/useAutoClearAsyncStorage.js +1 -130
  39. package/lib/module/impersonate/hooks/useAutoClearReactQuery.js +1 -151
  40. package/lib/module/impersonate/hooks/useAutoClearReactQuery.web.js +1 -16
  41. package/lib/module/impersonate/hooks/useAutoClearRedux.js +1 -183
  42. package/lib/module/impersonate/hooks/useAutoClearRedux.web.js +1 -22
  43. package/lib/module/impersonate/hooks/useImpersonate.js +1 -212
  44. package/lib/module/impersonate/hooks/useImpersonateHistory.js +1 -52
  45. package/lib/module/impersonate/types/index.js +1 -3
  46. package/lib/module/impersonate/types/types.js +1 -1
  47. package/lib/module/impersonate/utils/impersonateListener.js +1 -341
  48. package/lib/module/impersonate/utils/impersonateStore.js +1 -686
  49. package/lib/module/index.js +1 -117
  50. package/lib/module/preset.js +1 -216
  51. package/lib/module/sync/impersonateSyncAdapter.js +1 -162
  52. package/lib/web/index.mjs +7 -8
  53. package/package.json +3 -6
  54. package/lib/typescript/impersonate/components/DataNukeSettings.d.ts.map +0 -1
  55. package/lib/typescript/impersonate/components/ImpersonateBanner.d.ts.map +0 -1
  56. package/lib/typescript/impersonate/components/ImpersonateHistoryList.d.ts.map +0 -1
  57. package/lib/typescript/impersonate/components/ImpersonateModal.d.ts.map +0 -1
  58. package/lib/typescript/impersonate/components/ImpersonateOverlay.d.ts.map +0 -1
  59. package/lib/typescript/impersonate/components/ImpersonateStatusBar.d.ts.map +0 -1
  60. package/lib/typescript/impersonate/components/UserAvatar.d.ts.map +0 -1
  61. package/lib/typescript/impersonate/components/UserCard.d.ts.map +0 -1
  62. package/lib/typescript/impersonate/components/UserSearchView.d.ts.map +0 -1
  63. package/lib/typescript/impersonate/hooks/asyncStoragePeer.d.ts.map +0 -1
  64. package/lib/typescript/impersonate/hooks/asyncStoragePeer.web.d.ts.map +0 -1
  65. package/lib/typescript/impersonate/hooks/useAutoClearAsyncStorage.d.ts.map +0 -1
  66. package/lib/typescript/impersonate/hooks/useAutoClearReactQuery.d.ts.map +0 -1
  67. package/lib/typescript/impersonate/hooks/useAutoClearReactQuery.web.d.ts.map +0 -1
  68. package/lib/typescript/impersonate/hooks/useAutoClearRedux.d.ts.map +0 -1
  69. package/lib/typescript/impersonate/hooks/useAutoClearRedux.web.d.ts.map +0 -1
  70. package/lib/typescript/impersonate/hooks/useImpersonate.d.ts.map +0 -1
  71. package/lib/typescript/impersonate/hooks/useImpersonateHistory.d.ts.map +0 -1
  72. package/lib/typescript/impersonate/types/index.d.ts.map +0 -1
  73. package/lib/typescript/impersonate/types/types.d.ts.map +0 -1
  74. package/lib/typescript/impersonate/utils/impersonateListener.d.ts.map +0 -1
  75. package/lib/typescript/impersonate/utils/impersonateStore.d.ts.map +0 -1
  76. package/lib/typescript/index.d.ts.map +0 -1
  77. package/lib/typescript/preset.d.ts.map +0 -1
  78. package/lib/typescript/sync/impersonateSyncAdapter.d.ts.map +0 -1
@@ -1,672 +1,10 @@
1
- "use strict";
2
-
3
- /**
4
- * DataNukeSettings Component
5
- *
6
- * Settings panel for configuring what data to clear on impersonation change.
7
- * Features Save/Discard/Restore pattern for reliable persistence.
8
- */
9
-
10
- import React, { useState, useEffect, useMemo } from "react";
11
- import { View, Text, TextInput, StyleSheet, ScrollView, TouchableOpacity } from "react-native";
12
- import { CollapsibleSection, buoyColors, night, Settings, AlertTriangle, Info, Zap, RefreshCw, Check, X, Copy, Eye, copyToClipboard, ToggleRow as SharedToggleRow, monoFont } from "@buoy-gg/shared-ui";
13
- import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
14
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
- const DEFAULT_HEADER_KEY = "x-impersonate-user-id";
16
- const DEFAULT_SHOW_BANNER = true;
17
- const DEFAULT_DATA_NUKE_SETTINGS = {
18
- reactQuery: true,
19
- redux: true,
20
- asyncStorage: false,
21
- mmkv: false
22
- };
23
-
24
- /**
25
- * Detection status for auto-clear integrations
26
- */
27
-
28
- function ToggleRow({
29
- label,
30
- description,
31
- value,
32
- onChange,
33
- recommended,
34
- dangerous,
35
- detected
36
- }) {
37
- const accessory = /*#__PURE__*/_jsxs(_Fragment, {
38
- children: [detected !== undefined && /*#__PURE__*/_jsxs(View, {
39
- style: [styles.detectedBadge, detected ? styles.detectedBadgeActive : styles.detectedBadgeInactive],
40
- children: [detected ? /*#__PURE__*/_jsx(Check, {
41
- size: 10,
42
- color: buoyColors.success
43
- }) : /*#__PURE__*/_jsx(X, {
44
- size: 10,
45
- color: night.color.textTertiary
46
- }), /*#__PURE__*/_jsx(Text, {
47
- style: [styles.detectedText, detected ? styles.detectedTextActive : styles.detectedTextInactive],
48
- children: detected ? "Detected" : "Not Detected"
49
- })]
50
- }), recommended && detected !== false && /*#__PURE__*/_jsxs(View, {
51
- style: styles.recommendedBadge,
52
- children: [/*#__PURE__*/_jsx(Zap, {
53
- size: 10,
54
- color: night.color.accent
55
- }), /*#__PURE__*/_jsx(Text, {
56
- style: styles.recommendedText,
57
- children: "Recommended"
58
- })]
59
- })]
60
- });
61
- return /*#__PURE__*/_jsx(SharedToggleRow, {
62
- variant: "plain",
63
- label: label,
64
- description: description,
65
- value: value,
66
- onValueChange: onChange,
67
- tone: dangerous ? "warning" : "accent",
68
- emphasizeLabel: dangerous,
69
- accessory: accessory
70
- });
71
- }
72
- export function DataNukeSettings({
73
- headerKey,
74
- settings,
75
- showBanner,
76
- onSave,
77
- onShowBannerChange,
78
- detectionStatus
79
- }) {
80
- // Local state for editing
81
- const [localHeaderKey, setLocalHeaderKey] = useState(headerKey);
82
- const [localSettings, setLocalSettings] = useState(settings);
83
- const [localShowBanner, setLocalShowBanner] = useState(showBanner);
84
- const [copySuccess, setCopySuccess] = useState(false);
85
-
86
- // Sync local state when props change (e.g., after async load from storage)
87
- useEffect(() => {
88
- setLocalHeaderKey(headerKey);
89
- }, [headerKey]);
90
- useEffect(() => {
91
- setLocalSettings(settings);
92
- }, [settings]);
93
- useEffect(() => {
94
- setLocalShowBanner(showBanner);
95
- }, [showBanner]);
96
-
97
- // Check if there are unsaved changes
98
- // Note: showBanner is not included here because it applies immediately
99
- const hasChanges = useMemo(() => {
100
- return localHeaderKey !== headerKey || localSettings.reactQuery !== settings.reactQuery || localSettings.redux !== settings.redux || localSettings.asyncStorage !== settings.asyncStorage || localSettings.mmkv !== settings.mmkv;
101
- }, [localHeaderKey, localSettings, headerKey, settings]);
102
-
103
- // Check if current values differ from defaults
104
- const isDefault = useMemo(() => {
105
- return localHeaderKey === DEFAULT_HEADER_KEY && localShowBanner === DEFAULT_SHOW_BANNER && localSettings.reactQuery === DEFAULT_DATA_NUKE_SETTINGS.reactQuery && localSettings.redux === DEFAULT_DATA_NUKE_SETTINGS.redux && localSettings.asyncStorage === DEFAULT_DATA_NUKE_SETTINGS.asyncStorage && localSettings.mmkv === DEFAULT_DATA_NUKE_SETTINGS.mmkv;
106
- }, [localHeaderKey, localShowBanner, localSettings]);
107
- const handleSave = () => {
108
- onSave(localHeaderKey.trim() || DEFAULT_HEADER_KEY, localSettings, localShowBanner);
109
- };
110
- const handleDiscard = () => {
111
- setLocalHeaderKey(headerKey);
112
- setLocalSettings(settings);
113
- setLocalShowBanner(showBanner);
114
- };
115
- const handleRestoreDefaults = () => {
116
- setLocalHeaderKey(DEFAULT_HEADER_KEY);
117
- setLocalSettings(DEFAULT_DATA_NUKE_SETTINGS);
118
- setLocalShowBanner(DEFAULT_SHOW_BANNER);
119
- onShowBannerChange(DEFAULT_SHOW_BANNER); // Apply banner change immediately
120
- };
121
- const updateLocalSetting = (key, value) => {
122
- setLocalSettings(prev => ({
123
- ...prev,
124
- [key]: value
125
- }));
126
- };
127
-
128
- // Config object for DataViewer and copying
129
- const configData = useMemo(() => ({
130
- defaults: {
131
- headerKey: localHeaderKey,
132
- showBanner: localShowBanner,
133
- dataNukeSettings: {
134
- reactQuery: localSettings.reactQuery,
135
- redux: localSettings.redux,
136
- asyncStorage: localSettings.asyncStorage,
137
- mmkv: localSettings.mmkv
138
- }
139
- }
140
- }), [localHeaderKey, localShowBanner, localSettings]);
141
- const handleCopyConfig = async () => {
142
- // Format as JS object literal (not JSON) for direct paste into createImpersonateTool()
143
- const configString = `defaults: {
144
- headerKey: '${localHeaderKey}',
145
- showBanner: ${localShowBanner},
1
+ "use strict";import ae,{useState as k,useEffect as z,useMemo as D}from"react";import{View as a,Text as c,TextInput as q,StyleSheet as K,ScrollView as X,TouchableOpacity as p}from"react-native";import{CollapsibleSection as f,buoyColors as m,night as o,Settings as Y,AlertTriangle as V,Info as G,Zap as Z,RefreshCw as J,Check as R,X as E,Copy as A,Eye as ee,copyToClipboard as te,ToggleRow as oe,monoFont as W}from"@buoy-gg/shared-ui";import{DataViewer as re}from"@buoy-gg/shared-ui/dataViewer";import{jsx as t,jsxs as n,Fragment as H}from"react/jsx-runtime";const x="x-impersonate-user-id";const I=true;const C={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function b({label:s,description:d,value:h,onChange:B,recommended:T,dangerous:u,detected:i}){const g=n(H,{children:[i!==void 0&&n(a,{style:[e.detectedBadge,i?e.detectedBadgeActive:e.detectedBadgeInactive],children:[i?t(R,{size:10,color:m.success}):t(E,{size:10,color:o.color.textTertiary}),t(c,{style:[e.detectedText,i?e.detectedTextActive:e.detectedTextInactive],children:i?"Detected":"Not Detected"})]}),T&&i!==false&&n(a,{style:e.recommendedBadge,children:[t(Z,{size:10,color:o.color.accent}),t(c,{style:e.recommendedText,children:"Recommended"})]})]});return t(oe,{variant:"plain",label:s,description:d,value:h,onValueChange:B,tone:u?"warning":"accent",emphasizeLabel:u,accessory:g})}export function DataNukeSettings({headerKey:s,settings:d,showBanner:h,onSave:B,onShowBannerChange:T,detectionStatus:u}){const[i,g]=k(s);const[r,S]=k(d);const[y,v]=k(h);const[F,L]=k(false);z(()=>{g(s)},[s]);z(()=>{S(d)},[d]);z(()=>{v(h)},[h]);const Q=D(()=>{return i!==s||r.reactQuery!==d.reactQuery||r.redux!==d.redux||r.asyncStorage!==d.asyncStorage||r.mmkv!==d.mmkv},[i,r,s,d]);const _=D(()=>{return i===x&&y===I&&r.reactQuery===C.reactQuery&&r.redux===C.redux&&r.asyncStorage===C.asyncStorage&&r.mmkv===C.mmkv},[i,y,r]);const j=()=>{B(i.trim()||x,r,y)};const N=()=>{g(s);S(d);v(h)};const O=()=>{g(x);S(C);v(I);T(I)};const w=(l,$)=>{S(U=>({...U,[l]:$}))};const M=D(()=>({defaults:{headerKey:i,showBanner:y,dataNukeSettings:{reactQuery:r.reactQuery,redux:r.redux,asyncStorage:r.asyncStorage,mmkv:r.mmkv}}}),[i,y,r]);const P=async()=>{const l=`defaults: {
2
+ headerKey: '${i}',
3
+ showBanner: ${y},
146
4
  dataNukeSettings: {
147
- reactQuery: ${localSettings.reactQuery},
148
- redux: ${localSettings.redux},
149
- asyncStorage: ${localSettings.asyncStorage},
150
- mmkv: ${localSettings.mmkv},
5
+ reactQuery: ${r.reactQuery},
6
+ redux: ${r.redux},
7
+ asyncStorage: ${r.asyncStorage},
8
+ mmkv: ${r.mmkv},
151
9
  },
152
- },`;
153
- try {
154
- await copyToClipboard(configString);
155
- setCopySuccess(true);
156
- setTimeout(() => setCopySuccess(false), 2000);
157
- } catch {
158
- // Silently fail - user will notice copy didn't work
159
- }
160
- };
161
- return /*#__PURE__*/_jsxs(ScrollView, {
162
- style: styles.container,
163
- contentContainerStyle: styles.contentContainer,
164
- children: [hasChanges && /*#__PURE__*/_jsx(View, {
165
- style: styles.actionBar,
166
- children: /*#__PURE__*/_jsxs(View, {
167
- style: styles.actionBarContent,
168
- children: [/*#__PURE__*/_jsx(Text, {
169
- style: styles.unsavedText,
170
- children: "Unsaved changes"
171
- }), /*#__PURE__*/_jsxs(View, {
172
- style: styles.actionButtons,
173
- children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
174
- style: styles.discardButton,
175
- onPress: handleDiscard,
176
- children: [/*#__PURE__*/_jsx(X, {
177
- size: 14,
178
- color: night.color.textSecondary
179
- }), /*#__PURE__*/_jsx(Text, {
180
- style: styles.discardButtonText,
181
- children: "Discard"
182
- })]
183
- }), /*#__PURE__*/_jsxs(TouchableOpacity, {
184
- style: styles.saveButton,
185
- onPress: handleSave,
186
- children: [/*#__PURE__*/_jsx(Check, {
187
- size: 14,
188
- color: night.color.onAccent
189
- }), /*#__PURE__*/_jsx(Text, {
190
- style: styles.saveButtonText,
191
- children: "Save"
192
- })]
193
- })]
194
- })]
195
- })
196
- }), /*#__PURE__*/_jsx(CollapsibleSection, {
197
- title: "Header Configuration",
198
- icon: Settings,
199
- defaultOpen: true,
200
- variant: "bordered",
201
- children: /*#__PURE__*/_jsxs(View, {
202
- style: styles.sectionContent,
203
- children: [/*#__PURE__*/_jsx(Text, {
204
- style: styles.inputLabel,
205
- children: "Header Key"
206
- }), /*#__PURE__*/_jsx(TextInput, {
207
- style: styles.input,
208
- value: localHeaderKey,
209
- onChangeText: setLocalHeaderKey,
210
- placeholder: "x-impersonate-user-id",
211
- placeholderTextColor: night.color.placeholder,
212
- autoCapitalize: "none",
213
- autoCorrect: false
214
- }), /*#__PURE__*/_jsxs(View, {
215
- style: styles.inputFooter,
216
- children: [/*#__PURE__*/_jsx(Text, {
217
- style: styles.helperText,
218
- children: "The HTTP header key used for impersonation. Value will be the user ID."
219
- }), localHeaderKey !== DEFAULT_HEADER_KEY && /*#__PURE__*/_jsx(TouchableOpacity, {
220
- onPress: () => setLocalHeaderKey(DEFAULT_HEADER_KEY),
221
- style: styles.resetLink,
222
- children: /*#__PURE__*/_jsx(Text, {
223
- style: styles.resetLinkText,
224
- children: "Reset to default"
225
- })
226
- })]
227
- })]
228
- })
229
- }), /*#__PURE__*/_jsx(CollapsibleSection, {
230
- title: "Display",
231
- icon: Eye,
232
- defaultOpen: true,
233
- variant: "bordered",
234
- children: /*#__PURE__*/_jsx(View, {
235
- style: styles.sectionContent,
236
- children: /*#__PURE__*/_jsx(View, {
237
- style: styles.togglesCard,
238
- children: /*#__PURE__*/_jsx(ToggleRow, {
239
- label: "Floating Banner",
240
- description: "Show a floating banner when impersonation is active",
241
- value: localShowBanner,
242
- onChange: value => {
243
- setLocalShowBanner(value);
244
- onShowBannerChange(value); // Apply immediately
245
- },
246
- recommended: true
247
- })
248
- })
249
- })
250
- }), /*#__PURE__*/_jsx(CollapsibleSection, {
251
- title: "Data Clearing",
252
- icon: AlertTriangle,
253
- defaultOpen: true,
254
- variant: "bordered",
255
- children: /*#__PURE__*/_jsxs(View, {
256
- style: styles.sectionContent,
257
- children: [/*#__PURE__*/_jsx(Text, {
258
- style: styles.sectionDescription,
259
- children: "Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."
260
- }), /*#__PURE__*/_jsxs(View, {
261
- style: styles.togglesCard,
262
- children: [/*#__PURE__*/_jsx(ToggleRow, {
263
- label: "React Query",
264
- description: "Clear query cache and cancel pending queries",
265
- value: localSettings.reactQuery,
266
- onChange: v => updateLocalSetting("reactQuery", v),
267
- recommended: true,
268
- detected: detectionStatus?.reactQuery
269
- }), /*#__PURE__*/_jsx(View, {
270
- style: styles.divider
271
- }), /*#__PURE__*/_jsx(ToggleRow, {
272
- label: "Redux",
273
- description: "Reset Redux store to initial state",
274
- value: localSettings.redux,
275
- onChange: v => updateLocalSetting("redux", v),
276
- recommended: true,
277
- detected: detectionStatus?.redux
278
- })]
279
- }), /*#__PURE__*/_jsxs(View, {
280
- style: styles.advancedSection,
281
- children: [/*#__PURE__*/_jsx(Text, {
282
- style: styles.advancedLabel,
283
- children: "Storage Options"
284
- }), /*#__PURE__*/_jsxs(View, {
285
- style: [styles.togglesCard, styles.dangerousCard],
286
- children: [/*#__PURE__*/_jsx(ToggleRow, {
287
- label: "AsyncStorage",
288
- description: "Clear app data (preserves @buoy/* keys)",
289
- value: localSettings.asyncStorage,
290
- onChange: v => updateLocalSetting("asyncStorage", v),
291
- dangerous: true,
292
- detected: detectionStatus?.asyncStorage
293
- }), /*#__PURE__*/_jsx(View, {
294
- style: styles.divider
295
- }), /*#__PURE__*/_jsx(ToggleRow, {
296
- label: "MMKV",
297
- description: "Clear MMKV storage (preserves @buoy/* keys)",
298
- value: localSettings.mmkv,
299
- onChange: v => updateLocalSetting("mmkv", v),
300
- dangerous: true,
301
- detected: detectionStatus?.mmkv
302
- })]
303
- })]
304
- }), (localSettings.asyncStorage || localSettings.mmkv) && /*#__PURE__*/_jsxs(View, {
305
- style: styles.warningCard,
306
- children: [/*#__PURE__*/_jsx(AlertTriangle, {
307
- size: 16,
308
- color: night.color.warning
309
- }), /*#__PURE__*/_jsxs(View, {
310
- style: styles.warningContent,
311
- children: [/*#__PURE__*/_jsx(Text, {
312
- style: styles.warningTitle,
313
- children: "Storage Clearing Enabled"
314
- }), /*#__PURE__*/_jsx(Text, {
315
- style: styles.warningText,
316
- children: "This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."
317
- })]
318
- })]
319
- })]
320
- })
321
- }), !isDefault && /*#__PURE__*/_jsxs(TouchableOpacity, {
322
- style: styles.restoreButton,
323
- onPress: handleRestoreDefaults,
324
- children: [/*#__PURE__*/_jsx(RefreshCw, {
325
- size: 14,
326
- color: night.color.textSecondary
327
- }), /*#__PURE__*/_jsx(Text, {
328
- style: styles.restoreButtonText,
329
- children: "Restore Defaults"
330
- })]
331
- }), /*#__PURE__*/_jsx(CollapsibleSection, {
332
- title: "How It Works",
333
- icon: Info,
334
- defaultOpen: false,
335
- variant: "bordered",
336
- children: /*#__PURE__*/_jsxs(View, {
337
- style: styles.sectionContent,
338
- children: [/*#__PURE__*/_jsx(Text, {
339
- style: styles.infoText,
340
- children: "When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."
341
- }), /*#__PURE__*/_jsx(Text, {
342
- style: [styles.infoText, styles.infoTextSpaced],
343
- children: "Your backend should check for this header and return data for the specified user ID instead of the authenticated user."
344
- }), /*#__PURE__*/_jsxs(View, {
345
- style: styles.codeBlock,
346
- children: [/*#__PURE__*/_jsx(Text, {
347
- style: styles.codeComment,
348
- children: "// Example request header"
349
- }), /*#__PURE__*/_jsxs(Text, {
350
- style: styles.codeText,
351
- children: [localHeaderKey || "x-impersonate-user-id", ": ", /*#__PURE__*/_jsx(Text, {
352
- style: styles.codeValue,
353
- children: "user_123"
354
- })]
355
- })]
356
- })]
357
- })
358
- }), /*#__PURE__*/_jsx(CollapsibleSection, {
359
- title: "Export Configuration",
360
- icon: Copy,
361
- defaultOpen: false,
362
- variant: "bordered",
363
- children: /*#__PURE__*/_jsxs(View, {
364
- style: styles.sectionContent,
365
- children: [/*#__PURE__*/_jsx(Text, {
366
- style: styles.infoText,
367
- children: "Copy current settings to use in createImpersonateTool()."
368
- }), /*#__PURE__*/_jsx(View, {
369
- style: styles.dataViewerContainer,
370
- children: /*#__PURE__*/_jsx(DataViewer, {
371
- title: "",
372
- data: configData,
373
- showTypeFilter: true,
374
- rawMode: true,
375
- initialExpanded: true
376
- })
377
- }), /*#__PURE__*/_jsx(TouchableOpacity, {
378
- style: styles.copyButton,
379
- onPress: handleCopyConfig,
380
- children: copySuccess ? /*#__PURE__*/_jsxs(_Fragment, {
381
- children: [/*#__PURE__*/_jsx(Check, {
382
- size: 14,
383
- color: buoyColors.success
384
- }), /*#__PURE__*/_jsx(Text, {
385
- style: [styles.copyButtonText, styles.copySuccessText],
386
- children: "Copied!"
387
- })]
388
- }) : /*#__PURE__*/_jsxs(_Fragment, {
389
- children: [/*#__PURE__*/_jsx(Copy, {
390
- size: 14,
391
- color: night.color.accent
392
- }), /*#__PURE__*/_jsx(Text, {
393
- style: styles.copyButtonText,
394
- children: "Copy Config"
395
- })]
396
- })
397
- })]
398
- })
399
- })]
400
- });
401
- }
402
- const styles = StyleSheet.create({
403
- container: {
404
- flex: 1
405
- },
406
- contentContainer: {
407
- padding: 16,
408
- gap: 12,
409
- paddingBottom: 32
410
- },
411
- actionBar: {
412
- backgroundColor: night.color.accentSoft,
413
- borderRadius: 10,
414
- borderWidth: 1,
415
- borderColor: night.color.accentBorder,
416
- padding: 12
417
- },
418
- actionBarContent: {
419
- flexDirection: "row",
420
- alignItems: "center",
421
- justifyContent: "space-between"
422
- },
423
- unsavedText: {
424
- fontSize: 13,
425
- fontWeight: "500",
426
- color: night.color.accent
427
- },
428
- actionButtons: {
429
- flexDirection: "row",
430
- gap: 8
431
- },
432
- saveButton: {
433
- flexDirection: "row",
434
- alignItems: "center",
435
- gap: 6,
436
- backgroundColor: night.color.accent,
437
- paddingHorizontal: 14,
438
- paddingVertical: 8,
439
- borderRadius: 6
440
- },
441
- saveButtonText: {
442
- fontSize: 13,
443
- fontWeight: "600",
444
- // Ink on a filled accent surface — the night accent takes dark ink.
445
- color: night.color.onAccent
446
- },
447
- discardButton: {
448
- flexDirection: "row",
449
- alignItems: "center",
450
- gap: 6,
451
- backgroundColor: night.color.surfaceElevated,
452
- paddingHorizontal: 14,
453
- paddingVertical: 8,
454
- borderRadius: 6,
455
- borderWidth: 1,
456
- borderColor: night.color.border
457
- },
458
- discardButtonText: {
459
- fontSize: 13,
460
- fontWeight: "500",
461
- color: night.color.textSecondary
462
- },
463
- restoreButton: {
464
- flexDirection: "row",
465
- alignItems: "center",
466
- justifyContent: "center",
467
- gap: 8,
468
- paddingVertical: 12,
469
- borderRadius: 8,
470
- borderWidth: 1,
471
- borderColor: night.color.border,
472
- borderStyle: "dashed"
473
- },
474
- restoreButtonText: {
475
- fontSize: 13,
476
- color: night.color.textSecondary
477
- },
478
- sectionContent: {
479
- paddingTop: 8
480
- },
481
- sectionDescription: {
482
- fontSize: 13,
483
- color: night.color.textSecondary,
484
- lineHeight: 18,
485
- marginBottom: 14
486
- },
487
- togglesCard: {
488
- backgroundColor: night.color.surface,
489
- borderRadius: 10,
490
- borderWidth: 1,
491
- borderColor: night.color.border,
492
- padding: 4
493
- },
494
- dangerousCard: {
495
- borderColor: night.color.warning + "30"
496
- },
497
- advancedSection: {
498
- marginTop: 16
499
- },
500
- advancedLabel: {
501
- fontSize: 11,
502
- fontWeight: "600",
503
- color: night.color.textTertiary,
504
- textTransform: "uppercase",
505
- letterSpacing: 0.5,
506
- marginBottom: 8,
507
- marginLeft: 2
508
- },
509
- inputLabel: {
510
- fontSize: 12,
511
- fontWeight: "600",
512
- color: night.color.textSecondary,
513
- marginBottom: 8
514
- },
515
- input: {
516
- height: 42,
517
- backgroundColor: night.color.surfaceElevated,
518
- borderRadius: 8,
519
- borderWidth: 1,
520
- borderColor: night.color.border,
521
- paddingHorizontal: 14,
522
- fontSize: 14,
523
- color: night.color.text,
524
- fontFamily: monoFont
525
- },
526
- inputFooter: {
527
- flexDirection: "row",
528
- justifyContent: "space-between",
529
- alignItems: "flex-start",
530
- marginTop: 8,
531
- gap: 12
532
- },
533
- helperText: {
534
- flex: 1,
535
- fontSize: 12,
536
- color: night.color.textTertiary,
537
- lineHeight: 16
538
- },
539
- resetLink: {
540
- paddingVertical: 2
541
- },
542
- resetLinkText: {
543
- fontSize: 12,
544
- color: night.color.accent,
545
- fontWeight: "500"
546
- },
547
- recommendedBadge: {
548
- flexDirection: "row",
549
- alignItems: "center",
550
- gap: 4,
551
- backgroundColor: night.color.accentSoft,
552
- paddingHorizontal: 8,
553
- paddingVertical: 3,
554
- borderRadius: 4
555
- },
556
- recommendedText: {
557
- fontSize: 10,
558
- fontWeight: "600",
559
- color: night.color.accent
560
- },
561
- detectedBadge: {
562
- flexDirection: "row",
563
- alignItems: "center",
564
- gap: 4,
565
- paddingHorizontal: 8,
566
- paddingVertical: 3,
567
- borderRadius: 4
568
- },
569
- detectedBadgeActive: {
570
- backgroundColor: buoyColors.success + "15"
571
- },
572
- detectedBadgeInactive: {
573
- backgroundColor: night.color.textTertiary + "15"
574
- },
575
- detectedText: {
576
- fontSize: 10,
577
- fontWeight: "600"
578
- },
579
- detectedTextActive: {
580
- color: buoyColors.success
581
- },
582
- detectedTextInactive: {
583
- color: night.color.textTertiary
584
- },
585
- divider: {
586
- height: 1,
587
- backgroundColor: night.color.separator,
588
- marginHorizontal: 12
589
- },
590
- warningCard: {
591
- marginTop: 14,
592
- flexDirection: "row",
593
- alignItems: "flex-start",
594
- gap: 12,
595
- backgroundColor: night.color.warningSoft,
596
- borderRadius: 10,
597
- borderWidth: 1,
598
- borderColor: night.color.warning + "25",
599
- padding: 14
600
- },
601
- warningContent: {
602
- flex: 1
603
- },
604
- warningTitle: {
605
- fontSize: 13,
606
- fontWeight: "600",
607
- color: night.color.warning,
608
- marginBottom: 4
609
- },
610
- warningText: {
611
- fontSize: 12,
612
- color: night.color.textSecondary,
613
- lineHeight: 17
614
- },
615
- infoText: {
616
- fontSize: 13,
617
- color: night.color.textSecondary,
618
- lineHeight: 19
619
- },
620
- infoTextSpaced: {
621
- marginTop: 10
622
- },
623
- codeBlock: {
624
- marginTop: 14,
625
- // Inset code box — darker than the card, the night track color.
626
- backgroundColor: night.color.bg,
627
- borderRadius: 8,
628
- padding: 14
629
- },
630
- codeComment: {
631
- fontSize: 12,
632
- color: night.color.textTertiary,
633
- fontFamily: monoFont,
634
- marginBottom: 6
635
- },
636
- codeText: {
637
- fontSize: 13,
638
- color: night.color.text,
639
- fontFamily: monoFont
640
- },
641
- codeValue: {
642
- color: night.color.accent
643
- },
644
- dataViewerContainer: {
645
- marginTop: 12,
646
- borderRadius: 8,
647
- overflow: "hidden",
648
- borderWidth: 1,
649
- borderColor: night.color.border
650
- },
651
- copyButton: {
652
- flexDirection: "row",
653
- alignItems: "center",
654
- justifyContent: "center",
655
- gap: 8,
656
- marginTop: 14,
657
- backgroundColor: night.color.accentSoft,
658
- paddingVertical: 10,
659
- paddingHorizontal: 16,
660
- borderRadius: 8,
661
- borderWidth: 1,
662
- borderColor: night.color.accentBorder
663
- },
664
- copyButtonText: {
665
- fontSize: 13,
666
- fontWeight: "600",
667
- color: night.color.accent
668
- },
669
- copySuccessText: {
670
- color: buoyColors.success
671
- }
672
- });
10
+ },`;try{await te(l);L(true);setTimeout(()=>L(false),2e3)}catch{}};return n(X,{style:e.container,contentContainerStyle:e.contentContainer,children:[Q&&t(a,{style:e.actionBar,children:n(a,{style:e.actionBarContent,children:[t(c,{style:e.unsavedText,children:"Unsaved changes"}),n(a,{style:e.actionButtons,children:[n(p,{style:e.discardButton,onPress:N,children:[t(E,{size:14,color:o.color.textSecondary}),t(c,{style:e.discardButtonText,children:"Discard"})]}),n(p,{style:e.saveButton,onPress:j,children:[t(R,{size:14,color:o.color.onAccent}),t(c,{style:e.saveButtonText,children:"Save"})]})]})]})}),t(f,{title:"Header Configuration",icon:Y,defaultOpen:true,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.inputLabel,children:"Header Key"}),t(q,{style:e.input,value:i,onChangeText:g,placeholder:"x-impersonate-user-id",placeholderTextColor:o.color.placeholder,autoCapitalize:"none",autoCorrect:false}),n(a,{style:e.inputFooter,children:[t(c,{style:e.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),i!==x&&t(p,{onPress:()=>g(x),style:e.resetLink,children:t(c,{style:e.resetLinkText,children:"Reset to default"})})]})]})}),t(f,{title:"Display",icon:ee,defaultOpen:true,variant:"bordered",children:t(a,{style:e.sectionContent,children:t(a,{style:e.togglesCard,children:t(b,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:y,onChange:l=>{v(l);T(l)},recommended:true})})})}),t(f,{title:"Data Clearing",icon:V,defaultOpen:true,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),n(a,{style:e.togglesCard,children:[t(b,{label:"React Query",description:"Clear query cache and cancel pending queries",value:r.reactQuery,onChange:l=>w("reactQuery",l),recommended:true,detected:u?.reactQuery}),t(a,{style:e.divider}),t(b,{label:"Redux",description:"Reset Redux store to initial state",value:r.redux,onChange:l=>w("redux",l),recommended:true,detected:u?.redux})]}),n(a,{style:e.advancedSection,children:[t(c,{style:e.advancedLabel,children:"Storage Options"}),n(a,{style:[e.togglesCard,e.dangerousCard],children:[t(b,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:r.asyncStorage,onChange:l=>w("asyncStorage",l),dangerous:true,detected:u?.asyncStorage}),t(a,{style:e.divider}),t(b,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:r.mmkv,onChange:l=>w("mmkv",l),dangerous:true,detected:u?.mmkv})]})]}),(r.asyncStorage||r.mmkv)&&n(a,{style:e.warningCard,children:[t(V,{size:16,color:o.color.warning}),n(a,{style:e.warningContent,children:[t(c,{style:e.warningTitle,children:"Storage Clearing Enabled"}),t(c,{style:e.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!_&&n(p,{style:e.restoreButton,onPress:O,children:[t(J,{size:14,color:o.color.textSecondary}),t(c,{style:e.restoreButtonText,children:"Restore Defaults"})]}),t(f,{title:"How It Works",icon:G,defaultOpen:false,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),t(c,{style:[e.infoText,e.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),n(a,{style:e.codeBlock,children:[t(c,{style:e.codeComment,children:"// Example request header"}),n(c,{style:e.codeText,children:[i||"x-impersonate-user-id",": ",t(c,{style:e.codeValue,children:"user_123"})]})]})]})}),t(f,{title:"Export Configuration",icon:A,defaultOpen:false,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.infoText,children:"Copy current settings to use in createImpersonateTool()."}),t(a,{style:e.dataViewerContainer,children:t(re,{title:"",data:M,showTypeFilter:true,rawMode:true,initialExpanded:true})}),t(p,{style:e.copyButton,onPress:P,children:F?n(H,{children:[t(R,{size:14,color:m.success}),t(c,{style:[e.copyButtonText,e.copySuccessText],children:"Copied!"})]}):n(H,{children:[t(A,{size:14,color:o.color.accent}),t(c,{style:e.copyButtonText,children:"Copy Config"})]})})]})})]})}const e=K.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:o.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:o.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:o.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:o.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:o.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:o.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:o.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:o.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:o.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:o.color.surface,borderRadius:10,borderWidth:1,borderColor:o.color.border,padding:4},dangerousCard:{borderColor:o.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:o.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:o.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:o.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:o.color.border,paddingHorizontal:14,fontSize:14,color:o.color.text,fontFamily:W},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:o.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:o.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:o.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:o.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:m.success+"15"},detectedBadgeInactive:{backgroundColor:o.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:m.success},detectedTextInactive:{color:o.color.textTertiary},divider:{height:1,backgroundColor:o.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:o.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:o.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:o.color.warning,marginBottom:4},warningText:{fontSize:12,color:o.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:o.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:o.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:o.color.textTertiary,fontFamily:W,marginBottom:6},codeText:{fontSize:13,color:o.color.text,fontFamily:W},codeValue:{color:o.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:o.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:o.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:o.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:o.color.accent},copySuccessText:{color:m.success}});