@gatemux/dsh-gatemux-login-core 1.1.0 → 1.1.2
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/account.js +154 -14
- package/package.json +1 -1
package/account.js
CHANGED
|
@@ -41,6 +41,17 @@ const DEFAULT_ISSUER = 'https://rest.gatemux.ai'
|
|
|
41
41
|
const DEFAULT_CONSOLE_ORIGIN = 'https://gatemux.ai'
|
|
42
42
|
/** Exact callback path registered for this application; loopback permits any port. */
|
|
43
43
|
const CALLBACK_PATH = '/callback'
|
|
44
|
+
|
|
45
|
+
/** Escape text interpolated into the fixed callback page. */
|
|
46
|
+
function escapeHtml(value) {
|
|
47
|
+
return String(value).replace(/[&<>"']/gu, (character) => ({
|
|
48
|
+
'&': '&',
|
|
49
|
+
'<': '<',
|
|
50
|
+
'>': '>',
|
|
51
|
+
'"': '"',
|
|
52
|
+
"'": ''',
|
|
53
|
+
})[character])
|
|
54
|
+
}
|
|
44
55
|
/**
|
|
45
56
|
* Credential slot. Deliberately not region-scoped: only one region bundle can
|
|
46
57
|
* be loaded at a time, and a grant is bound to the issuer that minted it
|
|
@@ -288,7 +299,10 @@ export class GateMuxAccount extends DeepSeekAccount {
|
|
|
288
299
|
|
|
289
300
|
async getProfile(client) {
|
|
290
301
|
const lifetime = this.detailsLifetime
|
|
291
|
-
|
|
302
|
+
// The settings page opens long after the one-hour access token expires;
|
|
303
|
+
// reading the stored grant directly would hand the account endpoint an
|
|
304
|
+
// expired token, and its 401 would delete a perfectly refreshable grant.
|
|
305
|
+
const grant = await this.freshGrant()
|
|
292
306
|
if (grant === null || lifetime.signal.aborted) return null
|
|
293
307
|
const identity = await this.readIdentity(grant, lifetime, client)
|
|
294
308
|
if (this.detailsLifetime !== lifetime) return null
|
|
@@ -304,7 +318,9 @@ export class GateMuxAccount extends DeepSeekAccount {
|
|
|
304
318
|
*/
|
|
305
319
|
async getBalance(client) {
|
|
306
320
|
const lifetime = this.detailsLifetime
|
|
307
|
-
|
|
321
|
+
// Same rule as getProfile: the wallet call must use a token that is valid
|
|
322
|
+
// now, not the one that happened to be stored when the page was opened.
|
|
323
|
+
const grant = await this.freshGrant()
|
|
308
324
|
if (grant === null || lifetime.signal.aborted) return null
|
|
309
325
|
const body = await this.callApi(this.accountEndpoint, grant, lifetime, client)
|
|
310
326
|
if (this.detailsLifetime !== lifetime) return null
|
|
@@ -360,8 +376,8 @@ export class GateMuxAccount extends DeepSeekAccount {
|
|
|
360
376
|
// GateMux serves no hosted completion page, so this tab is the only place
|
|
361
377
|
// the result is visible; answering 204 would leave it blank.
|
|
362
378
|
this.writeCallbackPage(attempt, 'Signed in', attempt.loginSource === 'web'
|
|
363
|
-
? '
|
|
364
|
-
: '
|
|
379
|
+
? "You're connected. Close this tab and continue in the original tab."
|
|
380
|
+
: "You're connected. Close this tab and continue in DeepSeek Harness.")
|
|
365
381
|
} else {
|
|
366
382
|
attempt.callback?.writeHead(204, { 'cache-control': 'no-store' }).end()
|
|
367
383
|
}
|
|
@@ -784,29 +800,153 @@ export class GateMuxAccount extends DeepSeekAccount {
|
|
|
784
800
|
|
|
785
801
|
|
|
786
802
|
/**
|
|
787
|
-
* Answer the browser tab the flow was authorized in with a
|
|
788
|
-
* application opens that tab outside itself and never reads this response,
|
|
789
|
-
* the page exists only for the person looking at it
|
|
790
|
-
*
|
|
803
|
+
* Answer the browser tab the flow was authorized in with a self-contained page.
|
|
804
|
+
* The application opens that tab outside itself and never reads this response,
|
|
805
|
+
* so the page exists only for the person looking at it. Styles are inline so
|
|
806
|
+
* the page needs no network; no script runs, and the policy still forbids every
|
|
807
|
+
* source except those styles.
|
|
791
808
|
* @param attempt - in-flight attempt whose callback is being answered.
|
|
792
809
|
* @param title - page title and heading.
|
|
793
810
|
* @param message - what the person should do next.
|
|
811
|
+
* @param ok - whether the attempt succeeded, which selects the icon and accent.
|
|
794
812
|
*/
|
|
795
|
-
writeCallbackPage(attempt, title, message) {
|
|
813
|
+
writeCallbackPage(attempt, title, message, ok = true) {
|
|
814
|
+
const safeTitle = escapeHtml(title)
|
|
815
|
+
const safeMessage = escapeHtml(message)
|
|
816
|
+
const accent = ok ? '#0f9d58' : '#d93025'
|
|
817
|
+
const badgeTint = ok ? 'rgba(15, 157, 88, .11)' : 'rgba(217, 48, 37, .10)'
|
|
818
|
+
const badgeLine = ok ? 'rgba(15, 157, 88, .18)' : 'rgba(217, 48, 37, .16)'
|
|
819
|
+
const icon = ok
|
|
820
|
+
? '<path d="M20 6 9 17l-5-5"/>'
|
|
821
|
+
: '<path d="M12 8v5"/><path d="M12 17h.01"/>'
|
|
796
822
|
attempt.callback?.writeHead(200, {
|
|
797
823
|
'content-type': 'text/html; charset=utf-8',
|
|
798
824
|
'cache-control': 'no-store',
|
|
799
|
-
'content-security-policy':
|
|
825
|
+
'content-security-policy': "default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",
|
|
800
826
|
'referrer-policy': 'no-referrer',
|
|
801
|
-
|
|
802
|
-
|
|
827
|
+
'x-content-type-options': 'nosniff',
|
|
828
|
+
}).end(`<!doctype html>
|
|
829
|
+
<html lang="en">
|
|
830
|
+
<head>
|
|
831
|
+
<meta charset="utf-8">
|
|
832
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
833
|
+
<meta name="color-scheme" content="light dark">
|
|
834
|
+
<title>${safeTitle} · GateMux</title>
|
|
835
|
+
<style>
|
|
836
|
+
:root {
|
|
837
|
+
color-scheme: light dark;
|
|
838
|
+
--accent: ${accent};
|
|
839
|
+
--badge-bg: ${badgeTint};
|
|
840
|
+
--badge-line: ${badgeLine};
|
|
841
|
+
--bg: #f5f6fa;
|
|
842
|
+
--bg-accent: #eef1ff;
|
|
843
|
+
--card: #ffffff;
|
|
844
|
+
--text: #171a21;
|
|
845
|
+
--muted: #626b7a;
|
|
846
|
+
--line: #e7e9f0;
|
|
847
|
+
--shadow: 0 24px 64px rgba(23, 26, 33, .10), 0 2px 8px rgba(23, 26, 33, .04);
|
|
848
|
+
}
|
|
849
|
+
@media (prefers-color-scheme: dark) {
|
|
850
|
+
:root {
|
|
851
|
+
--bg: #0d0f14;
|
|
852
|
+
--bg-accent: #141827;
|
|
853
|
+
--card: #171a22;
|
|
854
|
+
--text: #f1f3f8;
|
|
855
|
+
--muted: #9aa3b2;
|
|
856
|
+
--line: #262b37;
|
|
857
|
+
--shadow: 0 24px 64px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .25);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
* { box-sizing: border-box; }
|
|
861
|
+
body {
|
|
862
|
+
margin: 0;
|
|
863
|
+
min-height: 100vh;
|
|
864
|
+
display: grid;
|
|
865
|
+
place-items: center;
|
|
866
|
+
padding: 24px;
|
|
867
|
+
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
|
|
868
|
+
color: var(--text);
|
|
869
|
+
background:
|
|
870
|
+
radial-gradient(900px 520px at 50% -12%, var(--bg-accent), transparent 70%),
|
|
871
|
+
var(--bg);
|
|
872
|
+
-webkit-font-smoothing: antialiased;
|
|
873
|
+
}
|
|
874
|
+
.card {
|
|
875
|
+
width: min(100%, 440px);
|
|
876
|
+
padding: 44px 40px 32px;
|
|
877
|
+
border: 1px solid var(--line);
|
|
878
|
+
border-radius: 24px;
|
|
879
|
+
background: var(--card);
|
|
880
|
+
box-shadow: var(--shadow);
|
|
881
|
+
text-align: center;
|
|
882
|
+
}
|
|
883
|
+
.badge {
|
|
884
|
+
width: 64px;
|
|
885
|
+
height: 64px;
|
|
886
|
+
margin: 0 auto 22px;
|
|
887
|
+
display: grid;
|
|
888
|
+
place-items: center;
|
|
889
|
+
border-radius: 20px;
|
|
890
|
+
color: var(--accent);
|
|
891
|
+
background: var(--badge-bg);
|
|
892
|
+
border: 1px solid var(--badge-line);
|
|
893
|
+
}
|
|
894
|
+
.badge svg { width: 30px; height: 30px; }
|
|
895
|
+
.eyebrow {
|
|
896
|
+
margin: 0 0 8px;
|
|
897
|
+
font-size: 12px;
|
|
898
|
+
font-weight: 600;
|
|
899
|
+
letter-spacing: .14em;
|
|
900
|
+
text-transform: uppercase;
|
|
901
|
+
color: var(--muted);
|
|
902
|
+
}
|
|
903
|
+
h1 {
|
|
904
|
+
margin: 0 0 12px;
|
|
905
|
+
font-size: 28px;
|
|
906
|
+
line-height: 1.15;
|
|
907
|
+
letter-spacing: -.025em;
|
|
908
|
+
font-weight: 650;
|
|
909
|
+
}
|
|
910
|
+
.lead {
|
|
911
|
+
margin: 0 auto;
|
|
912
|
+
max-width: 330px;
|
|
913
|
+
font-size: 15px;
|
|
914
|
+
line-height: 1.6;
|
|
915
|
+
color: var(--muted);
|
|
916
|
+
}
|
|
917
|
+
.footer {
|
|
918
|
+
margin: 28px 0 0;
|
|
919
|
+
padding-top: 18px;
|
|
920
|
+
border-top: 1px solid var(--line);
|
|
921
|
+
font-size: 12px;
|
|
922
|
+
color: var(--muted);
|
|
923
|
+
}
|
|
924
|
+
.footer span { margin: 0 6px; opacity: .5; }
|
|
925
|
+
@media (max-width: 480px) {
|
|
926
|
+
.card { padding: 34px 24px 26px; border-radius: 20px; }
|
|
927
|
+
h1 { font-size: 24px; }
|
|
928
|
+
}
|
|
929
|
+
</style>
|
|
930
|
+
</head>
|
|
931
|
+
<body>
|
|
932
|
+
<main class="card" role="status" aria-live="polite">
|
|
933
|
+
<div class="badge" aria-hidden="true">
|
|
934
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">${icon}</svg>
|
|
935
|
+
</div>
|
|
936
|
+
<p class="eyebrow">${ok ? 'GateMux account' : 'GateMux sign-in'}</p>
|
|
937
|
+
<h1>${safeTitle}</h1>
|
|
938
|
+
<p class="lead">${safeMessage}</p>
|
|
939
|
+
<p class="footer">DeepSeek Harness <span>·</span> GateMux</p>
|
|
940
|
+
</main>
|
|
941
|
+
</body>
|
|
942
|
+
</html>`)
|
|
803
943
|
}
|
|
804
944
|
|
|
805
945
|
/** Return the browser to the application after a failed exchange. */
|
|
806
946
|
finishFailedCallback(attempt) {
|
|
807
947
|
this.writeCallbackPage(attempt, 'Sign-in failed', attempt.loginSource === 'web'
|
|
808
|
-
?
|
|
809
|
-
:
|
|
948
|
+
? "The sign-in didn't complete. Close this tab and try again in the original tab."
|
|
949
|
+
: "The sign-in didn't complete. Close this tab and try again in DeepSeek Harness.", false)
|
|
810
950
|
}
|
|
811
951
|
}
|
|
812
952
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gatemux/dsh-gatemux-login-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "GateMux account provider and model route for DeepSeek Harness. Shared code; install a region bundle instead of this package.",
|
|
6
6
|
"publishConfig": {
|