Commit 39091ff
committed
feat(auth): --profile flag +
User reported `x auth import` auto-detect picked Chrome `Profile 8`
which had stale cookies → 403 from UserByRestId. Their actual logged-in
session was on `Profile 6`. Need a way to (a) see which profiles are
available and (b) pin a specific one.
internal/browsercookies:
Load(ctx, browser, profile, domain) — new `profile` parameter,
case-insensitive substring match against the browser profile
name. Returns the FIRST matching store plus a list of
Alternatives (other browser/profile pairs that also have cookies
for the same domain). The chosen Result now carries Profile and
Alternatives fields.
List(ctx, domain) — new helper that enumerates every (browser,
profile) pair with at least one cookie for the domain, sorted in
kooky's traversal order. Used by the new `x auth browsers`
subcommand.
Match struct gained a Count field so the diagnostic listing can
show "12 cookies" per row.
cmd/auth.go:
--profile <name> pin a browser profile (substring match)
x auth browsers list every browser/profile with x.com
cookies, marked with `*` for the one
auto-detect would pick
acquireCookieString reorganised. The browser-cookie path now runs
whenever --from-browser OR --profile is set (not just both).
After a successful browser read, x-cli prints the chosen
browser/profile and a list of alternatives so the user immediately
sees "you picked Profile 8 but Profile 6 also has cookies — re-run
with --profile 'Profile 6' if you want that one". No more silent
wrong-profile selection.
internal/browsercookies/browsercookies_test.go:
Updated Load callsites for the new signature, added
TestListEmptyDomain.
Verified locally:
./bin/x auth browsers # lists profiles
./bin/x auth import --profile "Profile 6"
./bin/x auth import --from-browser chrome --profile workx auth browsers for multi-profile users1 parent b25c239 commit 39091ff
3 files changed
Lines changed: 210 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| 77 | + | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| 87 | + | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
87 | 128 | | |
88 | 129 | | |
89 | 130 | | |
| |||
152 | 193 | | |
153 | 194 | | |
154 | 195 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
159 | 200 | | |
160 | 201 | | |
161 | 202 | | |
162 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
163 | 208 | | |
164 | 209 | | |
165 | 210 | | |
| |||
168 | 213 | | |
169 | 214 | | |
170 | 215 | | |
171 | | - | |
172 | | - | |
| 216 | + | |
| 217 | + | |
173 | 218 | | |
174 | 219 | | |
175 | 220 | | |
176 | | - | |
177 | | - | |
| 221 | + | |
178 | 222 | | |
179 | | - | |
180 | 223 | | |
181 | 224 | | |
182 | 225 | | |
183 | 226 | | |
184 | 227 | | |
185 | | - | |
| 228 | + | |
186 | 229 | | |
187 | 230 | | |
188 | 231 | | |
189 | 232 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
197 | 242 | | |
198 | 243 | | |
199 | 244 | | |
200 | | - | |
| 245 | + | |
201 | 246 | | |
202 | 247 | | |
203 | | - | |
| 248 | + | |
204 | 249 | | |
205 | | - | |
206 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
207 | 257 | | |
208 | | - | |
| 258 | + | |
209 | 259 | | |
210 | 260 | | |
211 | 261 | | |
212 | 262 | | |
213 | | - | |
214 | | - | |
215 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
216 | 271 | | |
217 | | - | |
| 272 | + | |
218 | 273 | | |
219 | | - | |
| 274 | + | |
220 | 275 | | |
221 | 276 | | |
222 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
52 | 64 | | |
53 | 65 | | |
54 | 66 | | |
55 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
56 | 70 | | |
57 | 71 | | |
58 | | - | |
59 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
60 | 77 | | |
61 | 78 | | |
62 | 79 | | |
63 | | - | |
| 80 | + | |
64 | 81 | | |
65 | 82 | | |
66 | 83 | | |
67 | 84 | | |
68 | | - | |
69 | | - | |
70 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
71 | 98 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 99 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 100 | + | |
81 | 101 | | |
82 | 102 | | |
83 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
84 | 106 | | |
85 | 107 | | |
86 | | - | |
87 | | - | |
| 108 | + | |
88 | 109 | | |
89 | 110 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
94 | 117 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
98 | 122 | | |
99 | 123 | | |
100 | 124 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
104 | 135 | | |
105 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
106 | 150 | | |
107 | 151 | | |
108 | 152 | | |
109 | | - | |
110 | | - | |
111 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
112 | 158 | | |
113 | 159 | | |
114 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
115 | 199 | | |
116 | 200 | | |
117 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
0 commit comments