@sendhoney/cli 0.1.10 → 0.1.12
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.md +1 -1
- package/bin/sendhoney +19 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ SendHoney platform CLI for authenticated API, CRUD, release, and ThunderCompute
|
|
|
11
11
|
npm install -g @sendhoney/cli
|
|
12
12
|
|
|
13
13
|
# npm (pinned)
|
|
14
|
-
npm install -g @sendhoney/cli@0.1.
|
|
14
|
+
npm install -g @sendhoney/cli@0.1.12
|
|
15
15
|
|
|
16
16
|
# Homebrew
|
|
17
17
|
brew tap sendhoney/tap && brew install sendhoney
|
package/bin/sendhoney
CHANGED
|
@@ -41,17 +41,18 @@ function escapeHtml(value) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function loginCallbackPage(success, organization = {}) {
|
|
44
|
-
const title = success ? '
|
|
44
|
+
const title = success ? 'CLI connected' : 'Sign-in could not be completed'
|
|
45
45
|
const message = success
|
|
46
|
-
? 'SendHoney
|
|
46
|
+
? 'Your SendHoney workspace is ready. Return to your terminal to continue.'
|
|
47
47
|
: 'The SendHoney CLI could not complete sign-in. Close this window and try again from your terminal.'
|
|
48
48
|
const icon = success ? '✓' : '!'
|
|
49
|
-
const accent = success ? '#
|
|
49
|
+
const accent = success ? '#2563eb' : '#b42318'
|
|
50
50
|
const logo = organization.logoUrl || organization.logo_url || organization.logo || organization.organization?.logoUrl || organization.organization?.logo_url || organization.organization?.logo
|
|
51
51
|
const logoUrl = /^https?:\/\//i.test(String(logo || '')) ? escapeHtml(logo) : ''
|
|
52
52
|
const clientName = escapeHtml(organization.name || organization.companyName || organization.organization?.name || 'Your workspace')
|
|
53
|
-
const clientBrand = success && logoUrl ? `<div class="client-brand"><img src="${logoUrl}" alt="${clientName} logo"><span>${clientName}</span></div>` : ''
|
|
54
|
-
|
|
53
|
+
const clientBrand = success && logoUrl ? `<div class="client-brand"><img src="${logoUrl}" alt="${clientName} logo"><span><small>Connected workspace</small><strong>${clientName}</strong></span></div>` : ''
|
|
54
|
+
const sendHoneyLogo = `<svg class="logo-mark" viewBox="0 0 40 40" aria-label="SendHoney logo" role="img"><defs><linearGradient id="sh-bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#60A5FA"/><stop offset="100%" stop-color="#2563EB"/></linearGradient><linearGradient id="sh-fg" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#ffffff" stop-opacity=".34"/><stop offset="100%" stop-color="#1D4ED8" stop-opacity=".16"/></linearGradient></defs><rect x="2.8" y="2.8" width="34.4" height="34.4" rx="10" fill="url(#sh-bg)" stroke="#93C5FD" stroke-width="1.5" transform="rotate(6 20 20)"/><rect x="2.8" y="2.8" width="34.4" height="34.4" rx="10" fill="url(#sh-fg)"/><text x="20" y="25" fill="white" font-size="13" font-weight="900" font-family="Inter,system-ui,sans-serif" text-anchor="middle">SH</text></svg>`
|
|
55
|
+
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:linear-gradient(135deg,#eff6ff,#f8fbff 55%,#eef2ff);color:#0f172a;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.card{width:min(100%,500px);padding:44px;border:1px solid #dbeafe;border-radius:28px;background:rgba(255,255,255,.96);box-shadow:0 24px 70px rgba(37,99,235,.14);text-align:center}.brand{display:inline-flex;align-items:center;gap:11px;margin-bottom:24px;color:#1d4ed8;font-size:20px;font-weight:800;letter-spacing:-.03em}.logo-mark{width:40px;height:40px}.client-brand{display:flex;align-items:center;gap:11px;width:max-content;max-width:100%;margin:0 auto 28px;padding:10px 14px;border:1px solid #dbeafe;border-radius:14px;color:#1e3a8a;font-size:14px;text-align:left}.client-brand img{width:32px;height:32px;object-fit:contain;border-radius:8px}.client-brand span{display:grid;gap:2px}.client-brand small{color:#64748b;font-size:11px;font-weight:600}.client-brand strong{font-size:14px}.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:#475569;font-size:16px;line-height:1.6}.hint{margin-top:28px;color:#64748b;font-size:13px}</style></head><body><main class="card"><div class="brand">${sendHoneyLogo}<span>SendHoney</span></div>${clientBrand}<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>`
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
async function browserLogin(args, config) {
|
|
@@ -114,7 +115,7 @@ function json(value) { process.stdout.write(`${JSON.stringify(value, null, 2)}\n
|
|
|
114
115
|
function die(message, code = 1) { process.stderr.write(`sendhoney: ${message}\n`); process.exit(code) }
|
|
115
116
|
function organizationIdFrom(value) {
|
|
116
117
|
if (!value || typeof value !== 'object') return ''
|
|
117
|
-
return String(value.orgId || value.organizationId || value.tenantId || value.organization?.id || value.organization?.orgId || value.workspace?.organizationId || value.organizations?.[0]?.id || '').trim()
|
|
118
|
+
return String(value.orgId || value.org_id || value.organizationId || value.tenantId || value.organization?.id || value.organization?.orgId || value.workspace?.organizationId || value.organizations?.[0]?.id || '').trim()
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
async function persistLoginSession(config, args, auth, tokens) {
|
|
@@ -125,8 +126,18 @@ async function persistLoginSession(config, args, auth, tokens) {
|
|
|
125
126
|
fetch(`${apiUrl.replace(/\/$/, '')}/api/v1/org/me`, { headers }).catch(() => null),
|
|
126
127
|
])
|
|
127
128
|
const user = userResponse ? await userResponse.json().catch(() => ({})) : {}
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
let organization = orgResponse ? await orgResponse.json().catch(() => ({})) : {}
|
|
130
|
+
let orgId = organizationIdFrom(organization)
|
|
131
|
+
if (!orgId && user.email) {
|
|
132
|
+
const onboardingResponse = await fetch(`${apiUrl.replace(/\/$/, '')}/organizations/onboarding-status?email=${encodeURIComponent(user.email)}`, { headers }).catch(() => null)
|
|
133
|
+
const onboarding = onboardingResponse ? await onboardingResponse.json().catch(() => ({})) : {}
|
|
134
|
+
orgId = organizationIdFrom(onboarding)
|
|
135
|
+
if (orgId) {
|
|
136
|
+
const organizationResponse = await fetch(`${apiUrl.replace(/\/$/, '')}/organizations/${encodeURIComponent(orgId)}`, { headers }).catch(() => null)
|
|
137
|
+
const fullOrganization = organizationResponse ? await organizationResponse.json().catch(() => ({})) : {}
|
|
138
|
+
organization = { ...onboarding, ...fullOrganization, orgId }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
130
141
|
const session = { authenticated: true, authenticatedAt: new Date().toISOString(), user, organization, orgId: orgId || undefined }
|
|
131
142
|
saveConfig({
|
|
132
143
|
...config, apiUrl, authUrl: auth.authUrl, realm: auth.realm, clientId: auth.clientId,
|
package/package.json
CHANGED