uniwind-pro 1.9.1 → 1.9.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/package.json +1 -2
- package/pre/cli/commands.js +1 -1
- package/pre/cli/index.js +14 -4
- package/pre/cli/utils.js +1 -1
- package/pre/consts.js +1 -0
- package/pre/keyring.js +98 -0
- package/pre/postinstall/index.js +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniwind-pro",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Uniwind Pro CLI",
|
|
6
6
|
"keywords": [
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"chokidar": "5.0.0",
|
|
37
37
|
"culori": "4.0.2",
|
|
38
38
|
"eventsource": "4.1.0",
|
|
39
|
-
"figlet": "1.9.4",
|
|
40
39
|
"inquirer": "13.2.0",
|
|
41
40
|
"jwt-decode": "4.0.0",
|
|
42
41
|
"lightningcss": "1.30.1",
|
package/pre/cli/commands.js
CHANGED
|
@@ -3,7 +3,7 @@ import chalk from 'chalk'
|
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
import { dirname, join } from 'node:path'
|
|
5
5
|
import { spawn } from 'node:child_process'
|
|
6
|
-
import { keyring } from '
|
|
6
|
+
import { keyring } from '../keyring.js'
|
|
7
7
|
import { SERVICE, UNIWIND_WEB_URL, SESSION_API_URL, BASE_URL } from '../consts.js'
|
|
8
8
|
import { getTokenSSE } from './utils.js'
|
|
9
9
|
|
package/pre/cli/index.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import figlet from 'figlet'
|
|
4
3
|
import inquirer from 'inquirer'
|
|
5
4
|
import chalk from 'chalk'
|
|
6
5
|
import { login, buy, logout, account, postinstall, usage } from './commands.js'
|
|
7
6
|
import { getSesionMetadata } from './utils.js'
|
|
7
|
+
import { formatKeyringError } from '../keyring.js'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const BANNER_ASCII = String.raw` _ _ _ _ _ ____
|
|
10
|
+
| | | |_ __ (_)_ _(_)_ __ __| | | _ \ _ __ ___
|
|
11
|
+
| | | | '_ \| \ \ /\ / / | '_ \ / _${'`'} | | |_) | '__/ _ \
|
|
12
|
+
| |_| | | | | |\ V V /| | | | | (_| | | __/| | | (_) |
|
|
13
|
+
\___/|_| |_|_| \_/\_/ |_|_| |_|\__,_| |_| |_| \___/`
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
async function interactiveMode() {
|
|
16
|
+
console.log(`\n${BANNER_ASCII}\n`)
|
|
13
17
|
|
|
14
18
|
let shouldExit = false
|
|
15
19
|
|
|
@@ -78,6 +82,12 @@ async function interactiveMode() {
|
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
interactiveMode().catch((error) => {
|
|
85
|
+
if (error.keyring) {
|
|
86
|
+
console.error(chalk.red.bold('\nCould not access the system keyring.\n'))
|
|
87
|
+
console.error(chalk.yellow(`${formatKeyringError(error)}\n`))
|
|
88
|
+
process.exit(1)
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
console.error(chalk.red(`\nAn error occurred: ${error.message}`))
|
|
82
92
|
process.exit(1)
|
|
83
93
|
})
|
package/pre/cli/utils.js
CHANGED
package/pre/consts.js
CHANGED
|
@@ -5,3 +5,4 @@ export const UNIWIND_WEB_URL = 'https://uniwind.dev'
|
|
|
5
5
|
export const BASE_URL = 'https://cdn.uniwind.dev'
|
|
6
6
|
export const INSTALLATION_URL = `${BASE_URL}/uniwind-pro`
|
|
7
7
|
export const SESSION_API_URL = `${BASE_URL}/github`
|
|
8
|
+
export const CICD_LICENSE_DOCS_URL = 'https://docs.uniwind.dev/pro/cicd-license'
|
package/pre/keyring.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { CICD_LICENSE_DOCS_URL } from './consts.js'
|
|
2
|
+
|
|
3
|
+
// The native binding is loaded lazily: on Linux it links against libsecret, so
|
|
4
|
+
// a static import crashes with ERR_DLOPEN_FAILED before any error can be shown.
|
|
5
|
+
const call = async (method, ...args) => {
|
|
6
|
+
try {
|
|
7
|
+
const { keyring } = await import('@zowe/secrets-for-zowe-sdk')
|
|
8
|
+
|
|
9
|
+
return await keyring[method](...args)
|
|
10
|
+
} catch (error) {
|
|
11
|
+
throw toKeyringError(error)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const keyring = {
|
|
16
|
+
findCredentials: (service) => call('findCredentials', service),
|
|
17
|
+
setPassword: (service, account, password) => call('setPassword', service, account, password),
|
|
18
|
+
deletePassword: (service, account) => call('deletePassword', service, account),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const isKeyringError = (error) => {
|
|
22
|
+
const message = error?.message ?? ''
|
|
23
|
+
|
|
24
|
+
return message.startsWith('[keyring]') || (error?.code === 'ERR_DLOPEN_FAILED' && message.includes('libsecret'))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Mark keyring failures via `error.keyring` so top-level handlers can print
|
|
28
|
+
// setup guidance instead of a bare native error or a stacktrace.
|
|
29
|
+
export const toKeyringError = (error) => {
|
|
30
|
+
if (isKeyringError(error)) {
|
|
31
|
+
error.keyring = true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return error
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const getLinuxReason = (message) => {
|
|
38
|
+
if (message.includes('libsecret-1.so')) {
|
|
39
|
+
return 'libsecret is not installed.'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (message.includes('Cannot autolaunch D-Bus') || message.includes('DBUS_SESSION_BUS_ADDRESS')) {
|
|
43
|
+
return 'No D-Bus session is running.'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (message.includes('org.freedesktop.secrets')) {
|
|
47
|
+
return 'No Secret Service provider (such as GNOME Keyring) is installed or running.'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (message.includes('libsecret collection') || message.includes('/org/freedesktop/secrets/collection')) {
|
|
51
|
+
return 'There is no unlocked default keyring.'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return 'The Secret Service could not be reached.'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const STORE_NAMES = {
|
|
58
|
+
darwin: 'macOS Keychain',
|
|
59
|
+
win32: 'Windows Credential Manager',
|
|
60
|
+
linux: 'system keyring (Secret Service / libsecret)',
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Plain-text guidance for a keyring failure; callers add colors.
|
|
64
|
+
export const formatKeyringError = (error, platform = process.platform) => {
|
|
65
|
+
const store = STORE_NAMES[platform] ?? 'system keyring'
|
|
66
|
+
const lines = [`Uniwind Pro stores your session in the ${store}, but it could not be accessed.`, '']
|
|
67
|
+
|
|
68
|
+
if (platform === 'linux') {
|
|
69
|
+
lines.push(
|
|
70
|
+
`Reason: ${getLinuxReason(error?.message ?? '')}`,
|
|
71
|
+
'',
|
|
72
|
+
'This is common on WSL, headless and SSH sessions. To fix it (Debian / Ubuntu):',
|
|
73
|
+
'',
|
|
74
|
+
' 1. Install a Secret Service provider:',
|
|
75
|
+
' sudo apt-get install -y gnome-keyring libsecret-1-0 dbus',
|
|
76
|
+
'',
|
|
77
|
+
' 2. If no D-Bus session is running (SSH, WSL without systemd), start a shell with one:',
|
|
78
|
+
' dbus-run-session -- bash',
|
|
79
|
+
'',
|
|
80
|
+
' 3. Create (first run) or unlock the default "login" keyring:',
|
|
81
|
+
" echo -n '<choose-a-password>' | gnome-keyring-daemon --replace --unlock --components=secrets",
|
|
82
|
+
'',
|
|
83
|
+
' 4. Run uniwind-pro again from the same shell.',
|
|
84
|
+
'',
|
|
85
|
+
'The keyring stays locked in new sessions: repeat steps 2-3 with the same password before',
|
|
86
|
+
'running uniwind-pro or installing dependencies.',
|
|
87
|
+
''
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
lines.push(
|
|
92
|
+
`For headless or agent-driven setups, you can skip the keyring with a CI/CD license: ${CICD_LICENSE_DOCS_URL}`,
|
|
93
|
+
'',
|
|
94
|
+
`Original error: ${error?.message ?? error}`
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
return lines.join('\n')
|
|
98
|
+
}
|
package/pre/postinstall/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
5
5
|
import { UNIWIND_AUTH_TOKEN, SERVICE, UNIWIND_WEB_URL, HELP_EMAIL } from '../consts.js'
|
|
6
6
|
import { downloadFromCI, downloadFromCLI } from './install.js'
|
|
7
7
|
import { formatBody, formatUnexpectedError } from './errors.js'
|
|
8
|
+
import { keyring, formatKeyringError } from '../keyring.js'
|
|
8
9
|
|
|
9
10
|
// Create bin symlinks for aliased package
|
|
10
11
|
const createBinSymlinks = () => {
|
|
@@ -50,7 +51,6 @@ const main = async () => {
|
|
|
50
51
|
return await downloadFromCI(maybeCICDToken)
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
const { keyring } = await import('@zowe/secrets-for-zowe-sdk')
|
|
54
54
|
const matchingCredentials = await keyring.findCredentials(SERVICE)
|
|
55
55
|
|
|
56
56
|
if (matchingCredentials.length !== 0) {
|
|
@@ -77,6 +77,13 @@ main().catch((error) => {
|
|
|
77
77
|
process.exit(1)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
if (error.keyring) {
|
|
81
|
+
console.log(chalk.red.bold('Installation failed: could not access the system keyring.\n'))
|
|
82
|
+
console.log(chalk.yellow(`${formatKeyringError(error)}\n`))
|
|
83
|
+
|
|
84
|
+
process.exit(1)
|
|
85
|
+
}
|
|
86
|
+
|
|
80
87
|
// Non-HTTP failure (filesystem, tar extraction, missing project, DNS/connection):
|
|
81
88
|
// the "Access denied" guidance would be misleading, so show the stacktrace instead.
|
|
82
89
|
if (!error.http) {
|