@qui-cli/env-1password 1.0.5 → 1.1.0
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/CHANGELOG.md +7 -0
- package/README.md +25 -3
- package/dist/1Password.d.ts +11 -1
- package/dist/1Password.js +57 -12
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.1.0](https://github.com/battis/qui-cli/compare/env-1password/1.0.5...env-1password/1.1.0) (2025-12-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* opAccount and opToken args for env-1password (if 1Password CLI present) ([c107a88](https://github.com/battis/qui-cli/commit/c107a884d661e324e46c1bfd2d561934f5694de6))
|
|
11
|
+
|
|
5
12
|
## [1.0.5](https://github.com/battis/qui-cli/compare/env-1password/1.0.4...env-1password/1.0.5) (2025-11-12)
|
|
6
13
|
|
|
7
14
|
|
package/README.md
CHANGED
|
@@ -62,18 +62,40 @@ Whether or not to load the `.env` file into `process.env` immediately. Defaults
|
|
|
62
62
|
|
|
63
63
|
Path to desired `.env` file relative to `root`. Defaults to `'.env'`;
|
|
64
64
|
|
|
65
|
+
### `opToken`
|
|
66
|
+
|
|
67
|
+
1Password service account token
|
|
68
|
+
|
|
69
|
+
### `opItem`
|
|
70
|
+
|
|
71
|
+
Name or ID of the 1Password API Credential item storing the 1Password service account token
|
|
72
|
+
|
|
73
|
+
### `opAccount`
|
|
74
|
+
|
|
75
|
+
1Password account to use (if signed into multiple)
|
|
76
|
+
|
|
65
77
|
## Options
|
|
66
78
|
|
|
67
|
-
`
|
|
79
|
+
The configuration options `opToken`, `opItem`, and `opAccount` may all be passed as command-line options. For example:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
example --opToken "$(op item get ServiceAccountToken)"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If the [1Password CLI tool](https://developer.1password.com/docs/cli) is installed, then `opItem` and `opAccount` can be used:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
example --opItem ServiceAccountToken
|
|
89
|
+
```
|
|
68
90
|
|
|
69
91
|
## Initialization
|
|
70
92
|
|
|
71
|
-
`Env`
|
|
93
|
+
`Env` loads the specified `.env` file into `process.env`. If 1Password secret references are found in the environment, those references are loaded into the `process.env` from the 1Password vault (if a service account token is provided).
|
|
72
94
|
|
|
73
95
|
## API
|
|
74
96
|
|
|
75
97
|
```ts
|
|
76
|
-
import { Env } from '@qui-cli/env';
|
|
98
|
+
import { Env } from '@qui-cli/env-1password';
|
|
77
99
|
```
|
|
78
100
|
|
|
79
101
|
### `Env.parse(file?)`
|
package/dist/1Password.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { Env } from '@qui-cli/env';
|
|
2
2
|
import * as Plugin from '@qui-cli/plugin';
|
|
3
3
|
export type Configuration = Plugin.Configuration & Env.Configuration & {
|
|
4
|
+
/** 1Password service account token */
|
|
5
|
+
opToken?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Name or ID of the 1Password API Credential item storing the 1Password
|
|
8
|
+
* service account token
|
|
9
|
+
*/
|
|
10
|
+
opItem?: string;
|
|
11
|
+
/** 1Password account to use (if signed into multiple) */
|
|
12
|
+
opAccount?: string;
|
|
13
|
+
/** @deprecated Use {@link opToken} */
|
|
4
14
|
serviceAccountToken?: string;
|
|
5
15
|
};
|
|
6
16
|
export declare const name = "env-1password";
|
|
7
|
-
export declare function configure(
|
|
17
|
+
export declare function configure(proposal?: Configuration): Promise<void>;
|
|
8
18
|
export declare function options(): Plugin.Options;
|
|
9
19
|
export declare function init({ values }: Plugin.ExpectedArguments<typeof options>): Promise<void>;
|
|
10
20
|
export declare function parse(file?: string): Promise<import("dotenv").DotenvParseOutput>;
|
package/dist/1Password.js
CHANGED
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
import { createClient } from '@1password/sdk';
|
|
2
2
|
import { importLocal } from '@battis/import-package-json';
|
|
3
|
+
import { Colors } from '@qui-cli/colors';
|
|
3
4
|
import { Env } from '@qui-cli/env';
|
|
5
|
+
import { Log } from '@qui-cli/log';
|
|
6
|
+
import { Shell } from '@qui-cli/shell';
|
|
4
7
|
import path from 'node:path';
|
|
5
8
|
export const name = 'env-1password';
|
|
6
9
|
let client = undefined;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const config = {};
|
|
11
|
+
export async function configure(proposal = {}) {
|
|
12
|
+
for (const key in proposal) {
|
|
13
|
+
if (proposal[key] !== undefined) {
|
|
14
|
+
config[key] = proposal[key];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
config.opToken = config.opToken || config.serviceAccountToken;
|
|
18
|
+
await Env.configure({ ...config, load: false });
|
|
19
|
+
if (config.opItem && !config.opToken) {
|
|
20
|
+
const silent = Shell.isSilent();
|
|
21
|
+
const showCommands = Shell.commandsShown();
|
|
22
|
+
Shell.configure({ silent: true, showCommands: false });
|
|
23
|
+
const { stdout, stderr } = Shell.exec(`op item get ${config.opAccount ? `--account "${config.opAccount}" ` : ''}--reveal "${config.opItem}"`);
|
|
24
|
+
if (stdout.length) {
|
|
25
|
+
config.opToken = stdout;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
Log.fatal(stderr);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
Shell.configure({ silent, showCommands });
|
|
32
|
+
}
|
|
33
|
+
if (config.opToken) {
|
|
12
34
|
const pkg = await importLocal(path.join(import.meta.dirname, '../package.json'));
|
|
13
35
|
client = await createClient({
|
|
14
|
-
auth,
|
|
36
|
+
auth: config.opToken,
|
|
15
37
|
integrationName: pkg.name.replace(/^(\/|@)/, '').replace(/[/@]+/g, '-'),
|
|
16
38
|
integrationVersion: pkg.version
|
|
17
39
|
});
|
|
18
|
-
if (load) {
|
|
40
|
+
if (config.load) {
|
|
19
41
|
await parse();
|
|
20
42
|
}
|
|
21
43
|
}
|
|
22
|
-
else if (load) {
|
|
44
|
+
else if (config.load) {
|
|
23
45
|
await Env.parse();
|
|
24
46
|
}
|
|
25
47
|
}
|
|
@@ -28,13 +50,36 @@ export function options() {
|
|
|
28
50
|
man: [
|
|
29
51
|
{
|
|
30
52
|
level: 1,
|
|
31
|
-
text: '1Password integration'
|
|
32
|
-
}
|
|
53
|
+
text: '1Password environment integration'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
text: 'Store 1Password secret references in your environment, rather than the actual secrets.'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
text: `If 1Password secret references are stored in the environment, a 1Password service account token is required to access the secret values, which will be loaded into ${Colors.value('process.env')}. The service account token can be passed directly as the ${Colors.optionArg('--opToken')} argument (e.g. ${Colors.command(`${Colors.keyword('example')} --opToken "(${Colors.keyword('op')} item get SERVICE_ACCOUNT_TOKEN)"`)}) or, if the 1Password CLI tool is also installed, by simply passing the name or ID of the API Credential in your 1Password vault that holds the service account token (e.g. ${Colors.command(`${Colors.keyword('example')} --opItem SERVICE_ACCOUNT_TOKEN`)}). If you are signed into multiple 1Password account, use the ${Colors.optionArg('--opAccount')} argument to specify the account containing the token.`
|
|
60
|
+
},
|
|
61
|
+
{ text: Colors.url('https://developer.1password.com/docs/cli') }
|
|
33
62
|
],
|
|
34
63
|
opt: {
|
|
64
|
+
opAccount: {
|
|
65
|
+
description: `1Password account to use (if signed into multiple)`,
|
|
66
|
+
hint: 'example.1password.com',
|
|
67
|
+
default: config.opAccount
|
|
68
|
+
},
|
|
69
|
+
opItem: {
|
|
70
|
+
description: `Name or ID of the 1Password API Credential item storing the 1Password service account token`,
|
|
71
|
+
default: config.opItem
|
|
72
|
+
},
|
|
73
|
+
opToken: {
|
|
74
|
+
description: `1Password service account token`,
|
|
75
|
+
secret: true,
|
|
76
|
+
default: config.opToken || config.serviceAccountToken
|
|
77
|
+
},
|
|
35
78
|
serviceAccountToken: {
|
|
36
|
-
description: `1Password service account token
|
|
37
|
-
|
|
79
|
+
description: `1Password service account token`,
|
|
80
|
+
hint: 'Deprecated',
|
|
81
|
+
secret: true,
|
|
82
|
+
default: config.serviceAccountToken
|
|
38
83
|
}
|
|
39
84
|
}
|
|
40
85
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qui-cli/env-1password",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "@qui-cli Plugin: Standardized environment configuration",
|
|
5
5
|
"homepage": "https://github.com/battis/qui-cli/tree/main/packages/env-1password#readme",
|
|
6
6
|
"repository": {
|
|
@@ -22,15 +22,18 @@
|
|
|
22
22
|
"dotenv": "^17.2.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@tsconfig/node20": "^20.1.
|
|
26
|
-
"@types/node": "^24.10.
|
|
27
|
-
"commit-and-tag-version": "^12.6.
|
|
25
|
+
"@tsconfig/node20": "^20.1.8",
|
|
26
|
+
"@types/node": "^24.10.3",
|
|
27
|
+
"commit-and-tag-version": "^12.6.1",
|
|
28
28
|
"del-cli": "^6.0.0",
|
|
29
29
|
"npm-run-all": "^4.1.5",
|
|
30
30
|
"typescript": "^5.9.3",
|
|
31
|
-
"@qui-cli/
|
|
31
|
+
"@qui-cli/env": "5.0.2",
|
|
32
|
+
"@qui-cli/colors": "3.1.1",
|
|
32
33
|
"@qui-cli/plugin": "4.0.0",
|
|
33
|
-
"@qui-cli/
|
|
34
|
+
"@qui-cli/log": "4.0.1",
|
|
35
|
+
"@qui-cli/root": "3.0.4",
|
|
36
|
+
"@qui-cli/shell": "3.0.3"
|
|
34
37
|
},
|
|
35
38
|
"peerDependencies": {
|
|
36
39
|
"@qui-cli/env": "5.x",
|