@sendhoney/cli 0.1.5 → 0.1.6

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 (2) hide show
  1. package/bin/sendhoney +12 -1
  2. package/package.json +1 -1
package/bin/sendhoney CHANGED
@@ -36,6 +36,16 @@ function openBrowser(url) {
36
36
  function base64Url(value) { return value.toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_') }
37
37
  function pkceChallenge(verifier) { return base64Url(createHash('sha256').update(verifier).digest()) }
38
38
 
39
+ function loginCallbackPage(success) {
40
+ const title = success ? 'You’re signed in' : 'Sign-in could not be completed'
41
+ const message = success
42
+ ? 'SendHoney CLI is connected. You can close this window and return to your terminal.'
43
+ : 'The SendHoney CLI could not complete sign-in. Close this window and try again from your terminal.'
44
+ const icon = success ? '✓' : '!'
45
+ const accent = success ? '#0f766e' : '#b42318'
46
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${title} · SendHoney</title><style>*,*:before,*:after{box-sizing:border-box}body{margin:0;min-height:100vh;display:grid;place-items:center;padding:24px;background:#f7fbfb;color:#102a2a;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.card{width:min(100%,480px);padding:40px;border:1px solid #d9e9e7;border-radius:24px;background:#fff;box-shadow:0 20px 60px #0f766e18;text-align:center}.brand{display:inline-flex;align-items:center;gap:10px;margin-bottom:32px;color:#0f766e;font-size:18px;font-weight:800;letter-spacing:-.02em}.mark{display:grid;place-items:center;width:32px;height:32px;border-radius:10px;background:#0f766e;color:#fff;font-size:20px}.status{display:grid;place-items:center;width:64px;height:64px;margin:0 auto 22px;border-radius:20px;background:${accent}18;color:${accent};font-size:32px;font-weight:800}.title{margin:0;font-size:30px;letter-spacing:-.04em}.message{margin:14px auto 0;max-width:30rem;color:#587070;font-size:16px;line-height:1.6}.hint{margin-top:28px;color:#789090;font-size:13px}</style></head><body><main class="card"><div class="brand"><span class="mark">S</span><span>SendHoney</span></div><div class="status">${icon}</div><h1 class="title">${title}</h1><p class="message">${message}</p><p class="hint">You may safely close this tab.</p></main></body></html>`
47
+ }
48
+
39
49
  async function browserLogin(args, config) {
40
50
  const authUrl = (args['auth-url'] || process.env.SENDHONEY_AUTH_URL || config.authUrl || 'https://auth.sendhoney.app').replace(/\/$/, '')
41
51
  const realm = args.realm || process.env.SENDHONEY_KEYCLOAK_REALM || config.realm || 'users'
@@ -53,7 +63,8 @@ async function browserLogin(args, config) {
53
63
  if (url.pathname !== '/') { res.end('SendHoney CLI login'); return }
54
64
  if (url.searchParams.get('state') !== state) { res.statusCode = 400; res.end('Invalid login state'); clearTimeout(timeout); server.close(); reject(new Error('invalid login state')); return }
55
65
  const code = url.searchParams.get('code'); const error = url.searchParams.get('error')
56
- res.end(error ? 'SendHoney login failed. You may close this window.' : 'SendHoney login complete. You may close this window.')
66
+ res.setHeader('Content-Type', 'text/html; charset=utf-8')
67
+ res.end(loginCallbackPage(!error))
57
68
  clearTimeout(timeout); server.close(); error ? reject(new Error(error)) : resolve({ code, callback })
58
69
  })
59
70
  const loginUrl = authorization.toString()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendhoney/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "SendHoney platform CLI for authenticated API, CRUD, release, and ThunderCompute operations.",
5
5
  "private": false,
6
6
  "bin": { "sendhoney": "bin/sendhoney" },