@lks347/dsh-oauth 0.0.0-stage → 1.0.1
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.
- package/README.en.md +155 -0
- package/README.md +100 -2
- package/app.js +1005 -0
- package/auth.html +80 -0
- package/client.js +31 -0
- package/cordis.patch.yml +4 -0
- package/docs/CONNECTIONS.md +77 -0
- package/docs/LIVE-VALIDATION-1.0.1.md +100 -0
- package/docs/RELEASE-1.0.1.md +38 -0
- package/docs/VALIDATION.md +59 -0
- package/docs/evidence/live-1.0.1.json +135 -0
- package/index.html +43 -0
- package/package.json +64 -4
- package/providers.js +73 -0
- package/scripts/check-upstreams.mjs +27 -0
- package/scripts/link-peers.js +38 -0
- package/scripts/verify-browser.mjs +297 -0
- package/scripts/verify-host.mjs +484 -0
- package/scripts/verify-live.mjs +268 -0
- package/scripts/verify-package.mjs +168 -0
- package/scripts/verify-persistence.mjs +307 -0
- package/scripts/verify-subscriptions-ui.mjs +304 -0
- package/src/account.js +85 -0
- package/src/account.test.js +52 -0
- package/src/authorization.js +199 -0
- package/src/authorization.test.js +332 -0
- package/src/catalog.js +177 -0
- package/src/catalog.test.js +146 -0
- package/src/chat-recovery.js +110 -0
- package/src/chat-recovery.test.js +261 -0
- package/src/connection-runtime.js +126 -0
- package/src/connection-runtime.test.js +244 -0
- package/src/connections.js +70 -0
- package/src/grants.js +103 -0
- package/src/grants.test.js +327 -0
- package/src/index.js +704 -0
- package/src/local-imports.js +145 -0
- package/src/local-imports.test.js +168 -0
- package/src/media.js +149 -0
- package/src/models.js +546 -0
- package/src/models.test.js +415 -0
- package/src/profile-store.js +51 -0
- package/src/pulls.js +100 -0
- package/src/pulls.test.js +156 -0
- package/src/qwen.js +141 -0
- package/src/qwen.test.js +35 -0
- package/src/request-errors.js +50 -0
- package/src/request-errors.test.js +131 -0
- package/src/routes.js +47 -0
- package/src/routes.test.js +136 -0
- package/src/subscription-models.test.js +139 -0
- package/src/usage/aggregators.js +292 -0
- package/src/usage/aggregators.test.js +316 -0
- package/src/usage/core.js +68 -0
- package/src/usage/index.js +93 -0
- package/src/usage/official.js +339 -0
- package/src/usage/official.test.js +273 -0
- package/src/usage/service.test.js +89 -0
- package/src/xai-browser.js +272 -0
- package/src/xai-browser.test.js +256 -0
- package/src/xai-login.js +121 -0
- package/src/xai-login.test.js +259 -0
- package/styles.css +364 -0
- package/theme.js +118 -0
- package/upstreams.json +10 -0
package/styles.css
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
color-scheme: dark;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
* { box-sizing: border-box; }
|
|
6
|
+
|
|
7
|
+
html, body {
|
|
8
|
+
margin: 0;
|
|
9
|
+
height: 100%;
|
|
10
|
+
background: var(--dsh-oauth-bg);
|
|
11
|
+
color: var(--dsh-oauth-text);
|
|
12
|
+
font-family: var(--dsh-oauth-font);
|
|
13
|
+
font-size: 14px;
|
|
14
|
+
line-height: 1.5;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
button, input, select { font: inherit; color: inherit; }
|
|
18
|
+
|
|
19
|
+
.app {
|
|
20
|
+
min-height: 100%;
|
|
21
|
+
display: grid;
|
|
22
|
+
grid-template-columns: 240px minmax(0, 1fr);
|
|
23
|
+
background: var(--dsh-oauth-bg);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.nav {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: 2px;
|
|
30
|
+
padding: 16px 12px;
|
|
31
|
+
border-right: 0.5px solid var(--dsh-oauth-border-subtle);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.brand {
|
|
35
|
+
margin: 4px 8px 16px;
|
|
36
|
+
font-size: 13px;
|
|
37
|
+
font-weight: 600;
|
|
38
|
+
letter-spacing: 0.04em;
|
|
39
|
+
color: var(--dsh-oauth-text);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.nav button {
|
|
43
|
+
display: block;
|
|
44
|
+
width: 100%;
|
|
45
|
+
text-align: left;
|
|
46
|
+
background: transparent;
|
|
47
|
+
border: 0;
|
|
48
|
+
border-radius: var(--dsh-oauth-radius-control);
|
|
49
|
+
color: var(--dsh-oauth-text-secondary);
|
|
50
|
+
padding: 8px 10px;
|
|
51
|
+
cursor: default;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.nav button[aria-current="page"] {
|
|
55
|
+
color: var(--dsh-oauth-text);
|
|
56
|
+
background: var(--dsh-oauth-layer2);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.main {
|
|
60
|
+
min-width: 0;
|
|
61
|
+
padding: 28px 32px 64px;
|
|
62
|
+
max-width: 920px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.kicker {
|
|
66
|
+
margin: 0 0 6px;
|
|
67
|
+
color: var(--dsh-oauth-caption);
|
|
68
|
+
font-size: 12px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
h1 {
|
|
72
|
+
margin: 0 0 8px;
|
|
73
|
+
font-size: 20px;
|
|
74
|
+
line-height: 28px;
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.lead {
|
|
79
|
+
margin: 0 0 20px;
|
|
80
|
+
max-width: 68ch;
|
|
81
|
+
color: var(--dsh-oauth-text-tertiary);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.card {
|
|
85
|
+
background: var(--dsh-oauth-layer1);
|
|
86
|
+
border-radius: var(--dsh-oauth-radius);
|
|
87
|
+
box-shadow: var(--dsh-oauth-shadow);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.card-head, .card-body { padding: 16px 18px; }
|
|
91
|
+
|
|
92
|
+
.card-head {
|
|
93
|
+
display: flex;
|
|
94
|
+
justify-content: space-between;
|
|
95
|
+
gap: 16px;
|
|
96
|
+
align-items: flex-start;
|
|
97
|
+
border-bottom: 0.5px solid var(--dsh-oauth-border-subtle);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.head-title {
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
gap: 8px;
|
|
104
|
+
margin: 0;
|
|
105
|
+
font-size: 16px;
|
|
106
|
+
font-weight: 600;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.head-desc {
|
|
110
|
+
margin: 6px 0 0;
|
|
111
|
+
color: var(--dsh-oauth-text-tertiary);
|
|
112
|
+
font-size: 13px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.icon-btn, .btn {
|
|
116
|
+
border: 0;
|
|
117
|
+
background: transparent;
|
|
118
|
+
color: var(--dsh-oauth-text);
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
border-radius: var(--dsh-oauth-radius-control);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.icon-btn {
|
|
124
|
+
width: 32px;
|
|
125
|
+
height: 32px;
|
|
126
|
+
display: grid;
|
|
127
|
+
place-items: center;
|
|
128
|
+
color: var(--dsh-oauth-text-secondary);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.icon-btn:hover, .btn:hover { background: var(--dsh-oauth-hover); }
|
|
132
|
+
|
|
133
|
+
.btn {
|
|
134
|
+
min-height: 32px;
|
|
135
|
+
padding: 0 12px;
|
|
136
|
+
font-size: 13px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.btn.solid {
|
|
140
|
+
background: var(--dsh-oauth-primary-fill);
|
|
141
|
+
color: var(--dsh-oauth-primary-text);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.btn.solid:hover { background: var(--dsh-oauth-primary-fill); filter: brightness(0.95); }
|
|
145
|
+
|
|
146
|
+
.btn:disabled { opacity: 0.55; cursor: progress; }
|
|
147
|
+
|
|
148
|
+
.row {
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: flex-start;
|
|
151
|
+
justify-content: space-between;
|
|
152
|
+
gap: 16px;
|
|
153
|
+
padding: 14px 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.row + .row { border-top: 0.5px solid var(--dsh-oauth-border-subtle); }
|
|
157
|
+
|
|
158
|
+
.identity {
|
|
159
|
+
display: flex;
|
|
160
|
+
gap: 12px;
|
|
161
|
+
min-width: 0;
|
|
162
|
+
flex: 1;
|
|
163
|
+
max-width: 100%;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.identity > div { min-width: 0; max-width: 100%; }
|
|
167
|
+
|
|
168
|
+
.mark { width: 18px; height: 18px; margin-top: 2px; flex: none; }
|
|
169
|
+
.mark.on { color: var(--dsh-oauth-success); }
|
|
170
|
+
.mark.off { color: var(--dsh-oauth-caption); }
|
|
171
|
+
|
|
172
|
+
.name-line {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-wrap: wrap;
|
|
175
|
+
align-items: center;
|
|
176
|
+
gap: 8px;
|
|
177
|
+
max-width: 100%;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.name { font-size: 14px; font-weight: 600; }
|
|
181
|
+
|
|
182
|
+
.badge {
|
|
183
|
+
border-radius: 6px;
|
|
184
|
+
background: var(--dsh-oauth-layer2);
|
|
185
|
+
padding: 0 6px;
|
|
186
|
+
font-size: 12px;
|
|
187
|
+
line-height: 20px;
|
|
188
|
+
color: var(--dsh-oauth-text-tertiary);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.badge.ok { color: var(--dsh-oauth-success); }
|
|
192
|
+
.badge.bad { color: var(--dsh-oauth-danger); }
|
|
193
|
+
|
|
194
|
+
.meta, .hint, .err {
|
|
195
|
+
display: block;
|
|
196
|
+
margin-top: 4px;
|
|
197
|
+
font-size: 12px;
|
|
198
|
+
color: var(--dsh-oauth-text-tertiary);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.meta code, .cli code { font-family: var(--dsh-oauth-mono); font-size: 12px; }
|
|
202
|
+
|
|
203
|
+
.cli {
|
|
204
|
+
display: flex;
|
|
205
|
+
flex-wrap: wrap;
|
|
206
|
+
align-items: center;
|
|
207
|
+
gap: 8px;
|
|
208
|
+
margin-top: 6px;
|
|
209
|
+
min-width: 0;
|
|
210
|
+
max-width: 100%;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.cli code {
|
|
214
|
+
color: var(--dsh-oauth-caption);
|
|
215
|
+
min-width: 0;
|
|
216
|
+
max-width: 100%;
|
|
217
|
+
overflow-wrap: anywhere;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.err { color: var(--dsh-oauth-danger); }
|
|
221
|
+
|
|
222
|
+
.actions { display: flex; align-items: center; gap: 6px; flex: none; }
|
|
223
|
+
.actions a.icon-btn { text-decoration: none; }
|
|
224
|
+
|
|
225
|
+
.overlay {
|
|
226
|
+
position: fixed;
|
|
227
|
+
inset: 0;
|
|
228
|
+
background: #00000080;
|
|
229
|
+
display: grid;
|
|
230
|
+
place-items: center;
|
|
231
|
+
padding: 16px;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.dialog {
|
|
235
|
+
width: min(420px, 100%);
|
|
236
|
+
background: var(--dsh-oauth-layer1);
|
|
237
|
+
color: var(--dsh-oauth-text);
|
|
238
|
+
border-radius: var(--dsh-oauth-radius);
|
|
239
|
+
box-shadow: var(--dsh-oauth-shadow);
|
|
240
|
+
padding: 22px;
|
|
241
|
+
max-height: calc(100dvh - 32px);
|
|
242
|
+
overflow-y: auto;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.dialog h2 {
|
|
246
|
+
margin: 0 0 8px;
|
|
247
|
+
font-size: 16px;
|
|
248
|
+
font-weight: 600;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.row-actions {
|
|
252
|
+
display: flex;
|
|
253
|
+
justify-content: flex-end;
|
|
254
|
+
gap: 8px;
|
|
255
|
+
margin-top: 16px;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.pull-dialog { width: min(520px, 100%); }
|
|
259
|
+
|
|
260
|
+
.choices {
|
|
261
|
+
display: flex;
|
|
262
|
+
flex-direction: column;
|
|
263
|
+
gap: 8px;
|
|
264
|
+
max-height: 280px;
|
|
265
|
+
overflow: auto;
|
|
266
|
+
margin: 12px 0;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.choice {
|
|
270
|
+
display: grid;
|
|
271
|
+
grid-template-columns: auto 1fr;
|
|
272
|
+
gap: 2px 8px;
|
|
273
|
+
align-items: center;
|
|
274
|
+
color: var(--dsh-oauth-text-secondary);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.choice code {
|
|
278
|
+
grid-column: 2;
|
|
279
|
+
font-family: var(--dsh-oauth-mono);
|
|
280
|
+
font-size: 12px;
|
|
281
|
+
color: var(--dsh-oauth-caption);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.expiry-label, .field, .chips { display: block; }
|
|
285
|
+
|
|
286
|
+
.expiry-label { margin-top: 8px; color: var(--dsh-oauth-text-secondary); font-size: 13px; }
|
|
287
|
+
|
|
288
|
+
.field {
|
|
289
|
+
width: 100%;
|
|
290
|
+
margin-top: 6px;
|
|
291
|
+
background: transparent;
|
|
292
|
+
border: 0.5px solid var(--dsh-oauth-border);
|
|
293
|
+
border-radius: var(--dsh-oauth-radius-control);
|
|
294
|
+
padding: 8px 10px;
|
|
295
|
+
color: var(--dsh-oauth-text);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
|
|
299
|
+
|
|
300
|
+
.toast {
|
|
301
|
+
position: fixed;
|
|
302
|
+
right: 20px;
|
|
303
|
+
bottom: 20px;
|
|
304
|
+
background: var(--dsh-oauth-layer2);
|
|
305
|
+
color: var(--dsh-oauth-text);
|
|
306
|
+
border-radius: var(--dsh-oauth-radius-control);
|
|
307
|
+
box-shadow: var(--dsh-oauth-shadow);
|
|
308
|
+
padding: 10px 14px;
|
|
309
|
+
font-size: 13px;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.reset { margin-top: 16px; }
|
|
313
|
+
|
|
314
|
+
.page-tools { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
|
|
315
|
+
.locale-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dsh-oauth-text-tertiary); }
|
|
316
|
+
.locale-label select { background: var(--dsh-oauth-layer1); border: 1px solid var(--dsh-oauth-border); border-radius: var(--dsh-oauth-radius-control); padding: 4px; }
|
|
317
|
+
.modal-locale { margin-top: 16px; justify-content: flex-end; }
|
|
318
|
+
.actions { flex-wrap: wrap; justify-content: flex-end; max-width: 245px; }
|
|
319
|
+
.identity > div { width: 100%; }
|
|
320
|
+
.connection-summary, .usage-panel { overflow-wrap: anywhere; }
|
|
321
|
+
.usage-panel { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--dsh-oauth-border-subtle); }
|
|
322
|
+
.usage-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
|
|
323
|
+
.usage-heading strong { font-size: 13px; font-weight: 500; }
|
|
324
|
+
.quota-item { margin-top: 9px; }
|
|
325
|
+
.quota-line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 12px; }
|
|
326
|
+
.quota-line span:last-child { text-align: right; }
|
|
327
|
+
.quota-meter { height: 4px; background: var(--dsh-oauth-layer3); border-radius: 4px; margin: 5px 0; overflow: hidden; }
|
|
328
|
+
.quota-meter span { display: block; height: 100%; background: var(--dsh-oauth-accent); }
|
|
329
|
+
.quota-item.over .quota-meter span { background: var(--dsh-oauth-danger); }
|
|
330
|
+
.quota-foot { font-size: 11px; color: var(--dsh-oauth-text-tertiary); margin: 3px 0 0; }
|
|
331
|
+
.usage-balances { margin: 8px 0; }
|
|
332
|
+
.usage-balances div { display: flex; justify-content: space-between; gap: 10px; margin-top: 5px; font-size: 12px; }
|
|
333
|
+
.usage-balances dt, .usage-balances dd { margin: 0; }
|
|
334
|
+
.usage-balances dd { text-align: right; }
|
|
335
|
+
.choice .model-capabilities { grid-column: 2; font-size: 11px; color: var(--dsh-oauth-text-tertiary); }
|
|
336
|
+
.choice { padding: 7px 0; border-bottom: 1px solid var(--dsh-oauth-border-subtle); }
|
|
337
|
+
.choice code { overflow-wrap: anywhere; }
|
|
338
|
+
.select-tools { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
|
|
339
|
+
.scope-fields { margin-top: 12px; }
|
|
340
|
+
.scope-fields summary { cursor: pointer; font-size: 12px; color: var(--dsh-oauth-text-secondary); }
|
|
341
|
+
.connection-form .field, .pull-dialog .field { background: var(--dsh-oauth-layer1); }
|
|
342
|
+
.connection-form .field::placeholder { color: var(--dsh-oauth-text-tertiary); opacity: 1; }
|
|
343
|
+
.connection-form .hint { margin-bottom: 8px; }
|
|
344
|
+
.retention-option { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 13px; }
|
|
345
|
+
.form-error:empty { display: none; }
|
|
346
|
+
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, .dialog:focus-visible { outline: 2px solid var(--dsh-oauth-accent); outline-offset: 3px; }
|
|
347
|
+
.dialog[tabindex="-1"] { outline-offset: -3px; }
|
|
348
|
+
.toast { z-index: 30; max-width: calc(100vw - 40px); }
|
|
349
|
+
.overlay { z-index: 20; }
|
|
350
|
+
[hidden] { display: none !important; }
|
|
351
|
+
|
|
352
|
+
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
|
|
353
|
+
|
|
354
|
+
@media (max-width: 760px) {
|
|
355
|
+
.app { grid-template-columns: minmax(0, 1fr); }
|
|
356
|
+
.nav { display: none; }
|
|
357
|
+
.main { padding: 20px 16px 72px; }
|
|
358
|
+
.row { flex-direction: column; }
|
|
359
|
+
.actions { max-width: none; justify-content: flex-start; width: 100%; }
|
|
360
|
+
.page-tools { flex-wrap: wrap; }
|
|
361
|
+
.dialog { padding: 18px; }
|
|
362
|
+
.row-actions { flex-wrap: wrap; }
|
|
363
|
+
.quota-line { flex-wrap: wrap; gap: 3px 8px; }
|
|
364
|
+
}
|
package/theme.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual tokens taken from the open DeepSeek Harness page
|
|
3
|
+
* (body[data-ds-dark-theme] in @deepseek-ai/dsh-client-ui-theme).
|
|
4
|
+
*
|
|
5
|
+
* Override before the panel paints:
|
|
6
|
+
*
|
|
7
|
+
* DshOAuth.applyTheme({ accent: "#679efe", radius: "16px" })
|
|
8
|
+
*
|
|
9
|
+
* Or after load, the same call updates the live page and any auth popup
|
|
10
|
+
* that reads DshOAuth.getTheme() from its opener.
|
|
11
|
+
*
|
|
12
|
+
* Static-preview hooks only; hosted OAuth always uses the harness API:
|
|
13
|
+
*
|
|
14
|
+
* DshOAuth.setLoginOpener((provider) => window.open(previewUrl))
|
|
15
|
+
* DshOAuth.onAuthorize(async (provider) => confirmPreview(provider))
|
|
16
|
+
* DshOAuth.registerProvider({ id, name, cli, docs })
|
|
17
|
+
*/
|
|
18
|
+
(function () {
|
|
19
|
+
const DARK = {
|
|
20
|
+
bg: "#151517",
|
|
21
|
+
layer1: "#232324",
|
|
22
|
+
layer2: "#2c2c2e",
|
|
23
|
+
layer3: "#353638",
|
|
24
|
+
text: "#f9fafb",
|
|
25
|
+
textSecondary: "#cfd3d6",
|
|
26
|
+
textTertiary: "#adb2b8",
|
|
27
|
+
caption: "#81858c",
|
|
28
|
+
border: "#ffffff1f",
|
|
29
|
+
borderSubtle: "#ffffff0f",
|
|
30
|
+
hover: "#ffffff14",
|
|
31
|
+
primaryFill: "#f9fafb",
|
|
32
|
+
primaryText: "#0f1115",
|
|
33
|
+
accent: "#5686fe",
|
|
34
|
+
success: "#4ed17e",
|
|
35
|
+
danger: "#f25a5a",
|
|
36
|
+
font: '-apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif',
|
|
37
|
+
mono: '"SF Mono", "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, Courier, "PingFang SC", "Microsoft YaHei"',
|
|
38
|
+
radius: "12px",
|
|
39
|
+
radiusControl: "8px",
|
|
40
|
+
shadow: "0 0 0 0.5px #ffffff29, 0 12px 32px #00000014",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const cssName = (key) => "--dsh-oauth-" + key.replace(/[A-Z]/g, (letter) => "-" + letter.toLowerCase());
|
|
44
|
+
|
|
45
|
+
let current = { ...DARK };
|
|
46
|
+
let loginOpener = null;
|
|
47
|
+
const authorizeHooks = [];
|
|
48
|
+
|
|
49
|
+
function applyTheme(partial) {
|
|
50
|
+
current = { ...current, ...(partial || {}) };
|
|
51
|
+
const root = document.documentElement;
|
|
52
|
+
for (const [key, value] of Object.entries(current)) {
|
|
53
|
+
if (value != null) root.style.setProperty(cssName(key), String(value));
|
|
54
|
+
}
|
|
55
|
+
document.dispatchEvent(new CustomEvent("dsh-oauth-theme", { detail: getTheme() }));
|
|
56
|
+
return getTheme();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getTheme() {
|
|
60
|
+
return { ...current };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function registerProvider(provider) {
|
|
64
|
+
if (!provider || typeof provider.id !== "string" || typeof provider.name !== "string") {
|
|
65
|
+
throw new TypeError("DshOAuth.registerProvider requires { id, name }");
|
|
66
|
+
}
|
|
67
|
+
const next = {
|
|
68
|
+
flow: "pkce",
|
|
69
|
+
cli: `dsh oauth login ${provider.id}`,
|
|
70
|
+
docs: "#",
|
|
71
|
+
...provider,
|
|
72
|
+
};
|
|
73
|
+
const index = PROVIDERS.findIndex((item) => item.id === next.id);
|
|
74
|
+
if (index >= 0) PROVIDERS[index] = next;
|
|
75
|
+
else PROVIDERS.push(next);
|
|
76
|
+
if (!FLOW_LABEL[next.flow]) FLOW_LABEL[next.flow] = "浏览器登录";
|
|
77
|
+
document.dispatchEvent(new CustomEvent("dsh-oauth-providers", { detail: next }));
|
|
78
|
+
return next;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
window.DshOAuth = {
|
|
82
|
+
/** Token names accepted by applyTheme. Unknown keys still become CSS variables. */
|
|
83
|
+
themeKeys: Object.keys(DARK),
|
|
84
|
+
getTheme,
|
|
85
|
+
applyTheme,
|
|
86
|
+
/**
|
|
87
|
+
* @param {(provider: {id: string, name: string}) => Window | null} opener
|
|
88
|
+
* Return the auth window. The panel marks the row "登录中" and waits for
|
|
89
|
+
* a postMessage `{ type: "dsh-oauth", provider, ok }`.
|
|
90
|
+
*/
|
|
91
|
+
setLoginOpener(opener) {
|
|
92
|
+
loginOpener = opener;
|
|
93
|
+
},
|
|
94
|
+
loginOpener() {
|
|
95
|
+
return loginOpener;
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* @param {(provider: {id: string, name: string}) => boolean | Promise<boolean>} hook
|
|
99
|
+
* Return false to keep the provider disconnected after the auth page says ok.
|
|
100
|
+
*/
|
|
101
|
+
onAuthorize(hook) {
|
|
102
|
+
authorizeHooks.push(hook);
|
|
103
|
+
return () => {
|
|
104
|
+
const index = authorizeHooks.indexOf(hook);
|
|
105
|
+
if (index >= 0) authorizeHooks.splice(index, 1);
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
async runAuthorizeHooks(provider) {
|
|
109
|
+
for (const hook of authorizeHooks) {
|
|
110
|
+
if (await hook(provider) === false) return false;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
},
|
|
114
|
+
registerProvider,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
applyTheme();
|
|
118
|
+
})();
|
package/upstreams.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"checkedOn": "2026-10-16",
|
|
3
|
+
"dshRelease": "dsh-v0.2.1-alpha.4",
|
|
4
|
+
"dshCommit": "86a402200d95fecef4529d969836f1fe13c6cb0d",
|
|
5
|
+
"packages": {
|
|
6
|
+
"@deepseek-ai/dsh": { "latest": "0.2.0-rc.2", "alpha": "0.2.1-alpha.4" },
|
|
7
|
+
"@deepseek-ai/dsh-llm-pi-ai": { "latest": "0.0.1-rc.1", "next": "0.2.0-rc.2", "alpha": "0.2.1-alpha.4" },
|
|
8
|
+
"@earendil-works/pi-ai": { "latest": "1.3.0" }
|
|
9
|
+
}
|
|
10
|
+
}
|