@vasanthcambium/marketplace-auth 0.1.1 → 0.1.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionGate.d.ts","sourceRoot":"","sources":["../../src/react/SessionGate.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SessionGate.d.ts","sourceRoot":"","sources":["../../src/react/SessionGate.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAA4B,MAAM,OAAO,CAAC;AAIjE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAUnE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { useSession } from './useSession.js';
|
|
3
|
-
import {
|
|
4
|
+
import { SessionExpiredError } from '../shared/errors.js';
|
|
4
5
|
/**
|
|
5
6
|
* Renders children only when a valid session exists.
|
|
6
7
|
* Shows a loading screen while the session check is in flight.
|
|
@@ -21,14 +22,41 @@ function AuthScreen({ error }) {
|
|
|
21
22
|
if (error instanceof SessionExpiredError) {
|
|
22
23
|
return (_jsxs(Screen, { children: [_jsx("h1", { style: styles.heading, children: "Session Expired" }), _jsx("p", { style: styles.body, children: "Your session has expired. Please re-launch this app from cnMaestro." })] }));
|
|
23
24
|
}
|
|
24
|
-
if (isDev)
|
|
25
|
-
|
|
26
|
-
return (_jsxs(Screen, { children: [_jsx("div", { style: styles.devBadge, children: "DEV MODE" }), _jsx("h1", { style: styles.heading, children: "NBI credentials not configured" }), _jsx("p", { style: styles.body, children: status === 502
|
|
27
|
-
? 'The dev proxy could not authenticate — credentials are missing or wrong.'
|
|
28
|
-
: `Could not reach the API${status ? ` (HTTP ${status})` : ''}.` }), _jsxs("ol", { style: styles.list, children: [_jsxs("li", { children: ["Copy ", _jsx("code", { style: styles.code, children: ".env.development.example" }), " \u2192 ", _jsx("code", { style: styles.code, children: ".env.development" })] }), _jsxs("li", { children: ["Fill in ", _jsx("code", { style: styles.code, children: "NBI_CLIENT_ID" }), " and ", _jsx("code", { style: styles.code, children: "NBI_CLIENT_SECRET" }), " from your cnMaestro tenant (Settings \u2192 API Access)"] }), _jsx("li", { children: "Restart the dev server" })] })] }));
|
|
29
|
-
}
|
|
25
|
+
if (isDev)
|
|
26
|
+
return _jsx(DevLoginForm, {});
|
|
30
27
|
return (_jsxs(Screen, { children: [_jsx("h1", { style: styles.heading, children: "Not Authenticated" }), _jsx("p", { style: styles.body, children: "Please launch this app from the cnMaestro marketplace." })] }));
|
|
31
28
|
}
|
|
29
|
+
function DevLoginForm() {
|
|
30
|
+
const [cfDomain, setCfDomain] = useState('');
|
|
31
|
+
const [clientId, setClientId] = useState('');
|
|
32
|
+
const [clientSecret, setClientSecret] = useState('');
|
|
33
|
+
const [busy, setBusy] = useState(false);
|
|
34
|
+
const [err, setErr] = useState(null);
|
|
35
|
+
async function handleSubmit(e) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
setBusy(true);
|
|
38
|
+
setErr(null);
|
|
39
|
+
try {
|
|
40
|
+
const res = await fetch('/api/__dev-auth__', {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: { 'content-type': 'application/json' },
|
|
43
|
+
body: JSON.stringify({ cfDomain, clientId, clientSecret }),
|
|
44
|
+
});
|
|
45
|
+
if (!res.ok) {
|
|
46
|
+
const j = await res.json().catch(() => ({}));
|
|
47
|
+
setErr(j.error ?? `Server error (${res.status})`);
|
|
48
|
+
setBusy(false);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
window.location.reload();
|
|
52
|
+
}
|
|
53
|
+
catch (ex) {
|
|
54
|
+
setErr(String(ex));
|
|
55
|
+
setBusy(false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return (_jsxs(Screen, { children: [_jsx("div", { style: styles.devBadge, children: "DEV MODE" }), _jsx("h1", { style: styles.heading, children: "Connect to cnMaestro" }), _jsx("p", { style: styles.body, children: "Enter your NBI API credentials to start the local dev session." }), _jsxs("form", { onSubmit: handleSubmit, style: styles.form, children: [_jsxs("label", { style: styles.label, children: ["Platform URL", _jsx("input", { style: styles.input, type: "url", value: cfDomain, onChange: (e) => setCfDomain(e.target.value.replace(/\/$/, '')), placeholder: "https://dev.test-easy-apps.cloud.cambiumnetworks.com", required: true, autoFocus: true, autoComplete: "off" })] }), _jsxs("label", { style: styles.label, children: ["Client ID", _jsx("input", { style: styles.input, type: "text", value: clientId, onChange: (e) => setClientId(e.target.value), placeholder: "your-client-id", required: true })] }), _jsxs("label", { style: styles.label, children: ["Client Secret", _jsx("input", { style: styles.input, type: "password", value: clientSecret, onChange: (e) => setClientSecret(e.target.value), placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", autoComplete: "off", required: true })] }), err && _jsx("p", { style: styles.formError, children: err }), _jsx("button", { type: "submit", style: styles.button, disabled: busy, children: busy ? 'Connecting…' : 'Connect' })] })] }));
|
|
59
|
+
}
|
|
32
60
|
function Screen({ children }) {
|
|
33
61
|
return (_jsx("div", { style: styles.screen, children: _jsx("div", { style: styles.card, children: children }) }));
|
|
34
62
|
}
|
|
@@ -53,15 +81,29 @@ const styles = {
|
|
|
53
81
|
margin: '0 0 0.75rem', color: '#003A70', fontSize: '1.4rem',
|
|
54
82
|
},
|
|
55
83
|
body: {
|
|
56
|
-
margin: '0 0
|
|
84
|
+
margin: '0 0 1.5rem', color: '#374151', lineHeight: 1.5,
|
|
57
85
|
},
|
|
58
86
|
muted: { color: '#6b7280' },
|
|
59
|
-
|
|
60
|
-
|
|
87
|
+
form: {
|
|
88
|
+
display: 'flex', flexDirection: 'column', gap: '1rem',
|
|
89
|
+
},
|
|
90
|
+
label: {
|
|
91
|
+
display: 'flex', flexDirection: 'column', gap: '0.35rem',
|
|
92
|
+
fontSize: '0.875rem', fontWeight: 600, color: '#374151',
|
|
93
|
+
},
|
|
94
|
+
input: {
|
|
95
|
+
border: '1px solid #d2d6dc', borderRadius: '6px',
|
|
96
|
+
padding: '0.5rem 0.75rem', fontSize: '0.9rem',
|
|
97
|
+
fontFamily: 'inherit', outline: 'none',
|
|
98
|
+
},
|
|
99
|
+
button: {
|
|
100
|
+
background: '#003A70', color: '#ffffff', border: 0,
|
|
101
|
+
borderRadius: '6px', padding: '0.6rem 1.25rem',
|
|
102
|
+
fontSize: '0.95rem', fontFamily: 'inherit',
|
|
103
|
+
cursor: 'pointer', fontWeight: 600, marginTop: '0.25rem',
|
|
61
104
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
padding: '0.1rem 0.35rem', fontSize: '0.875em', fontFamily: 'monospace',
|
|
105
|
+
formError: {
|
|
106
|
+
margin: 0, color: '#D9027D', fontSize: '0.875rem',
|
|
65
107
|
},
|
|
66
108
|
};
|
|
67
109
|
//# sourceMappingURL=SessionGate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionGate.js","sourceRoot":"","sources":["../../src/react/SessionGate.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"SessionGate.js","sourceRoot":"","sources":["../../src/react/SessionGate.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ1D;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAoB;IAClE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE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