@signageos/cli 4.0.3 → 4.0.4
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 +36 -0
- package/dist/Auth/auth0Settings.d.ts +6 -1
- package/dist/Auth/auth0Settings.js +19 -6
- package/dist/Auth/loginCommand.d.ts +9 -2
- package/dist/Auth/loginCommand.js +63 -21
- package/docs/login/index.md +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,42 @@ identification=xxxxxxxxxxxxxxxxxxxx
|
|
|
80
80
|
apiSecurityToken=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
#### Custom deployment
|
|
84
|
+
|
|
85
|
+
When connecting to a non-default signageOS deployment, use the `--interactive-profile` flag during login. This will interactively prompt for connection settings:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
sos login --interactive-profile
|
|
89
|
+
# You will be prompted to enter:
|
|
90
|
+
# Server API URL: https://api.example.com
|
|
91
|
+
# Box URL: box.example.com
|
|
92
|
+
# Auth0 domain: auth0.example.com
|
|
93
|
+
# Auth0 client ID: <your-client-id>
|
|
94
|
+
# Auth0 audience: https://auth0.example.com/api/v2/
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The settings are saved to `~/.sosrc` and used for all subsequent commands automatically.
|
|
98
|
+
|
|
99
|
+
Alternatively, you can configure the settings directly in `~/.sosrc`:
|
|
100
|
+
```ini
|
|
101
|
+
apiUrl=https://api.example.com
|
|
102
|
+
boxUrl=box.example.com
|
|
103
|
+
auth0Domain=auth0.example.com
|
|
104
|
+
auth0ClientId=<your-client-id>
|
|
105
|
+
auth0Audience=https://auth0.example.com/api/v2/
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
All settings can also be overridden with environment variables (useful for CI/CD):
|
|
109
|
+
|
|
110
|
+
| Environment Variable | Config Field |
|
|
111
|
+
|---------------------|---------------|
|
|
112
|
+
| `SOS_API_URL` | `apiUrl` |
|
|
113
|
+
| `SOS_BOX_HOST` | `boxUrl` |
|
|
114
|
+
| `SOS_AUTH0_DOMAIN` | `auth0Domain` |
|
|
115
|
+
| `SOS_AUTH0_CLIENT_ID` | `auth0ClientId` |
|
|
116
|
+
| `SOS_AUTH0_AUDIENCE` | `auth0Audience` |
|
|
117
|
+
| `SOS_AUTH0_SCOPE` | `auth0Scope` |
|
|
118
|
+
|
|
83
119
|
### Applet
|
|
84
120
|
```bash
|
|
85
121
|
sos applet --help
|
|
@@ -3,6 +3,11 @@ import { Auth0Settings } from '@signageos/cli-common';
|
|
|
3
3
|
* Auth0 settings for the signageOS CLI tool (regular API).
|
|
4
4
|
*
|
|
5
5
|
* These connect to the regular signageOS API (not admin API).
|
|
6
|
-
*
|
|
6
|
+
* Precedence: environment variable > profile field in ~/.sosrc > .env default.
|
|
7
7
|
*/
|
|
8
8
|
export declare function getAuth0Settings(): Auth0Settings;
|
|
9
|
+
/**
|
|
10
|
+
* Read the Box URL from the active profile.
|
|
11
|
+
* Precedence: profile field in ~/.sosrc > environment variable (.env default).
|
|
12
|
+
*/
|
|
13
|
+
export declare function getBoxUrl(): string;
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAuth0Settings = getAuth0Settings;
|
|
4
|
+
exports.getBoxUrl = getBoxUrl;
|
|
5
|
+
const cli_common_1 = require("@signageos/cli-common");
|
|
6
|
+
const globalArgs_1 = require("../Command/globalArgs");
|
|
4
7
|
/**
|
|
5
8
|
* Auth0 settings for the signageOS CLI tool (regular API).
|
|
6
9
|
*
|
|
7
10
|
* These connect to the regular signageOS API (not admin API).
|
|
8
|
-
*
|
|
11
|
+
* Precedence: environment variable > profile field in ~/.sosrc > .env default.
|
|
9
12
|
*/
|
|
10
13
|
function getAuth0Settings() {
|
|
11
|
-
var _a, _b, _c, _d;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
15
|
+
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
12
16
|
return {
|
|
13
|
-
domain: (_a = process.env.SOS_AUTH0_DOMAIN) !== null &&
|
|
14
|
-
clientId: (
|
|
15
|
-
audience: (
|
|
16
|
-
scope: (
|
|
17
|
+
domain: (_b = (_a = (0, cli_common_1.readProfileField)('auth0Domain', profile)) !== null && _a !== void 0 ? _a : process.env.SOS_AUTH0_DOMAIN) !== null && _b !== void 0 ? _b : '',
|
|
18
|
+
clientId: (_d = (_c = (0, cli_common_1.readProfileField)('auth0ClientId', profile)) !== null && _c !== void 0 ? _c : process.env.SOS_AUTH0_CLIENT_ID) !== null && _d !== void 0 ? _d : '',
|
|
19
|
+
audience: (_f = (_e = (0, cli_common_1.readProfileField)('auth0Audience', profile)) !== null && _e !== void 0 ? _e : process.env.SOS_AUTH0_AUDIENCE) !== null && _f !== void 0 ? _f : '',
|
|
20
|
+
scope: (_h = (_g = (0, cli_common_1.readProfileField)('auth0Scope', profile)) !== null && _g !== void 0 ? _g : process.env.SOS_AUTH0_SCOPE) !== null && _h !== void 0 ? _h : '',
|
|
17
21
|
};
|
|
18
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Read the Box URL from the active profile.
|
|
25
|
+
* Precedence: profile field in ~/.sosrc > environment variable (.env default).
|
|
26
|
+
*/
|
|
27
|
+
function getBoxUrl() {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
30
|
+
return (_b = (_a = (0, cli_common_1.readProfileField)('boxUrl', profile)) !== null && _a !== void 0 ? _a : process.env.SOS_BOX_HOST) !== null && _b !== void 0 ? _b : '';
|
|
31
|
+
}
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* # Interactive login (opens browser for Auth0 authentication)
|
|
11
11
|
* sos login
|
|
12
12
|
*
|
|
13
|
+
* # Login with custom configuration (prompts for Auth0 and connection settings)
|
|
14
|
+
* sos login --interactive-profile
|
|
15
|
+
*
|
|
13
16
|
* # Login with a specific profile
|
|
14
17
|
* sos --profile staging login
|
|
15
18
|
* ```
|
|
@@ -19,7 +22,11 @@
|
|
|
19
22
|
export declare const login: {
|
|
20
23
|
name: "login";
|
|
21
24
|
description: string;
|
|
22
|
-
optionList:
|
|
25
|
+
optionList: readonly [{
|
|
26
|
+
readonly name: "interactive-profile";
|
|
27
|
+
readonly type: BooleanConstructor;
|
|
28
|
+
readonly description: "Prompt for custom Auth0 and connection settings (for custom deployments)";
|
|
29
|
+
}];
|
|
23
30
|
commands: never[];
|
|
24
|
-
run(): Promise<void>;
|
|
31
|
+
run(options: import("../Command/commandDefinition").CommandLineOptions<readonly Readonly<Readonly<import("command-line-args").OptionDefinition & import("command-line-usage").OptionDefinition>>[]>): Promise<void>;
|
|
25
32
|
};
|
|
@@ -17,7 +17,6 @@ const node_child_process_1 = require("node:child_process");
|
|
|
17
17
|
const node_os_1 = require("node:os");
|
|
18
18
|
const chalk_1 = __importDefault(require("chalk"));
|
|
19
19
|
const prompts_1 = __importDefault(require("prompts"));
|
|
20
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
21
20
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
22
21
|
const sosControlHelper_1 = require("@signageos/sdk/dist/SosHelper/sosControlHelper");
|
|
23
22
|
const cli_common_1 = require("@signageos/cli-common");
|
|
@@ -37,6 +36,13 @@ function openInBrowser(url) {
|
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
38
|
}
|
|
39
|
+
const LOGIN_OPTION_LIST = [
|
|
40
|
+
{
|
|
41
|
+
name: 'interactive-profile',
|
|
42
|
+
type: Boolean,
|
|
43
|
+
description: 'Prompt for custom Auth0 and connection settings (for custom deployments)',
|
|
44
|
+
},
|
|
45
|
+
];
|
|
40
46
|
/**
|
|
41
47
|
* Authenticates the user via the Auth0 Device Authorization Flow.
|
|
42
48
|
* Opens a browser-based verification page where the user logs in,
|
|
@@ -49,6 +55,9 @@ function openInBrowser(url) {
|
|
|
49
55
|
* # Interactive login (opens browser for Auth0 authentication)
|
|
50
56
|
* sos login
|
|
51
57
|
*
|
|
58
|
+
* # Login with custom configuration (prompts for Auth0 and connection settings)
|
|
59
|
+
* sos login --interactive-profile
|
|
60
|
+
*
|
|
52
61
|
* # Login with a specific profile
|
|
53
62
|
* sos --profile staging login
|
|
54
63
|
* ```
|
|
@@ -58,35 +67,68 @@ function openInBrowser(url) {
|
|
|
58
67
|
exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
59
68
|
name: 'login',
|
|
60
69
|
description: 'Authenticate user with signageOS via Auth0',
|
|
61
|
-
optionList:
|
|
70
|
+
optionList: LOGIN_OPTION_LIST,
|
|
62
71
|
commands: [],
|
|
63
|
-
run() {
|
|
72
|
+
run(options) {
|
|
64
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
var _a;
|
|
74
|
+
var _a, _b, _c, _d, _e, _f;
|
|
66
75
|
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
67
76
|
const configFilePath = (0, sosControlHelper_1.getConfigFilePath)();
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
const interactiveProfile = options['interactive-profile'];
|
|
78
|
+
if (interactiveProfile) {
|
|
79
|
+
(0, log_1.log)('info', `Setting up custom connection settings in ${configFilePath}.`);
|
|
80
|
+
const { inputApiUrl } = yield (0, prompts_1.default)({
|
|
81
|
+
type: 'text',
|
|
82
|
+
name: 'inputApiUrl',
|
|
83
|
+
message: 'Server API URL',
|
|
84
|
+
initial: (_a = process.env.SOS_API_URL) !== null && _a !== void 0 ? _a : 'https://api.signageos.io',
|
|
85
|
+
validate: (v) => (v.startsWith('http') ? true : 'Must be a valid URL starting with http'),
|
|
86
|
+
});
|
|
87
|
+
if (!inputApiUrl) {
|
|
88
|
+
throw new Error('API URL is required to log in.');
|
|
89
|
+
}
|
|
90
|
+
(0, cli_common_1.writeProfileField)('apiUrl', inputApiUrl.replace(/\/+$/, ''), profile);
|
|
91
|
+
const { inputBoxUrl } = yield (0, prompts_1.default)({
|
|
92
|
+
type: 'text',
|
|
93
|
+
name: 'inputBoxUrl',
|
|
94
|
+
message: 'Box URL',
|
|
95
|
+
initial: (_b = process.env.SOS_BOX_HOST) !== null && _b !== void 0 ? _b : 'box.signageos.io',
|
|
96
|
+
});
|
|
97
|
+
if (inputBoxUrl) {
|
|
98
|
+
(0, cli_common_1.writeProfileField)('boxUrl', inputBoxUrl.replace(/\/+$/, ''), profile);
|
|
99
|
+
}
|
|
100
|
+
const { inputAuth0Domain } = yield (0, prompts_1.default)({
|
|
101
|
+
type: 'text',
|
|
102
|
+
name: 'inputAuth0Domain',
|
|
103
|
+
message: 'Auth0 domain',
|
|
104
|
+
initial: (_c = process.env.SOS_AUTH0_DOMAIN) !== null && _c !== void 0 ? _c : 'auth0.signageos.io',
|
|
105
|
+
});
|
|
106
|
+
if (inputAuth0Domain) {
|
|
107
|
+
(0, cli_common_1.writeProfileField)('auth0Domain', inputAuth0Domain, profile);
|
|
108
|
+
}
|
|
109
|
+
const { inputAuth0ClientId } = yield (0, prompts_1.default)({
|
|
110
|
+
type: 'text',
|
|
111
|
+
name: 'inputAuth0ClientId',
|
|
112
|
+
message: 'Auth0 client ID',
|
|
113
|
+
initial: (_d = process.env.SOS_AUTH0_CLIENT_ID) !== null && _d !== void 0 ? _d : '',
|
|
114
|
+
});
|
|
115
|
+
if (inputAuth0ClientId) {
|
|
116
|
+
(0, cli_common_1.writeProfileField)('auth0ClientId', inputAuth0ClientId, profile);
|
|
117
|
+
}
|
|
118
|
+
const { inputAuth0Audience } = yield (0, prompts_1.default)({
|
|
119
|
+
type: 'text',
|
|
120
|
+
name: 'inputAuth0Audience',
|
|
121
|
+
message: 'Auth0 audience',
|
|
122
|
+
initial: (_e = process.env.SOS_AUTH0_AUDIENCE) !== null && _e !== void 0 ? _e : '',
|
|
123
|
+
});
|
|
124
|
+
if (inputAuth0Audience) {
|
|
125
|
+
(0, cli_common_1.writeProfileField)('auth0Audience', inputAuth0Audience, profile);
|
|
84
126
|
}
|
|
85
127
|
}
|
|
86
128
|
const auth0 = (0, auth0Settings_1.getAuth0Settings)();
|
|
87
129
|
(0, log_1.log)('info', 'Starting Auth0 Device Authorization Flow...');
|
|
88
130
|
const deviceCode = yield (0, cli_common_1.requestDeviceCode)(auth0);
|
|
89
|
-
const verificationUrl = (
|
|
131
|
+
const verificationUrl = (_f = deviceCode.verification_uri_complete) !== null && _f !== void 0 ? _f : deviceCode.verification_uri;
|
|
90
132
|
// Try to open the verification URL in the default browser
|
|
91
133
|
openInBrowser(verificationUrl);
|
|
92
134
|
console.info('');
|
package/docs/login/index.md
CHANGED
|
@@ -20,12 +20,21 @@ then stores the resulting JWT tokens in `~/.sosrc`.
|
|
|
20
20
|
sos login [options]
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Options
|
|
24
|
+
|
|
25
|
+
| Option | Description |
|
|
26
|
+
| ----------------------- | ---------------------------------------------------------------------------------- |
|
|
27
|
+
| `--interactive-profile` | Prompt for custom Auth0 and connection settings (for custom deployments) (boolean) |
|
|
28
|
+
|
|
23
29
|
## Examples
|
|
24
30
|
|
|
25
31
|
```bash
|
|
26
32
|
# Interactive login (opens browser for Auth0 authentication)
|
|
27
33
|
sos login
|
|
28
34
|
|
|
35
|
+
# Login with custom configuration (prompts for Auth0 and connection settings)
|
|
36
|
+
sos login --interactive-profile
|
|
37
|
+
|
|
29
38
|
# Login with a specific profile
|
|
30
39
|
sos --profile staging login
|
|
31
40
|
```
|