@dotenvx/dotenvx-ops 0.23.1 → 0.23.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/CHANGELOG.md CHANGED
@@ -2,7 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- [Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.1...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.2...main)
6
+
7
+ ## [0.23.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.1...v0.23.2) (2025-12-04)
8
+
9
+ ### Changed
10
+
11
+ * Create passcard on successful login ([#11](https://github.com/dotenvx/dotenvx-ops/pull/11))
6
12
 
7
13
  ## [0.23.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.0...v0.23.1) (2025-12-03)
8
14
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.23.1",
2
+ "version": "0.23.2",
3
3
  "name": "@dotenvx/dotenvx-ops",
4
4
  "description": "Dotenvx Ops – commercial tooling for .env files",
5
5
  "author": "@motdotla",
@@ -1,25 +1,47 @@
1
1
  const { logger } = require('@dotenvx/dotenvx')
2
+ const PostRotateLogin = require('./../../../../lib/api/postRotateLogin')
3
+ const Session = require('./../../../../db/session')
2
4
  const playwrightConnect = require('./../../../../lib/helpers/playwrightConnect')
3
5
 
4
- const TIMEOUT = 1200 // visibility timeout
6
+ const TIMEOUT = 500 // visibility timeout
5
7
 
6
8
  async function login () {
7
9
  const options = this.opts()
8
10
  logger.debug(`options: ${JSON.stringify(options)}`)
9
- const { username, password } = options
11
+ const slug = 'npm'
12
+ const { org, username, password, email } = options
10
13
  const { browser, context, page } = await playwrightConnect()
14
+
15
+ const usernameSelector = 'input[type="text"]'
16
+ const passwordSelector = 'input[type="password"]'
17
+
11
18
  await page.goto('https://npmjs.com/login', { waitUntil: 'domcontentloaded' })
12
19
  await page.waitForTimeout(TIMEOUT)
13
- await page.fill('input[type="text"]', username)
20
+ await page.fill(usernameSelector, username)
14
21
  await page.waitForTimeout(TIMEOUT)
15
- await page.fill('input[type="password"]', password)
22
+ await page.fill(passwordSelector, password)
16
23
  await page.waitForTimeout(TIMEOUT)
17
24
  await page.press('input[type="password"]', 'Enter')
18
25
  await page.waitForNavigation({ timeout: 0 })
19
26
  await page.waitForSelector('img[alt="avatar"]', { state: 'visible', timeout: 0 })
20
- const storageState = JSON.stringify(await context.storageState())
27
+
28
+ const sesh = new Session() // TODO: handle scenario where constructor fails
29
+
30
+ let hostname = process.env.DOTENVX_OPS_HOSTNAME || process.env.DOTENVX_RADAR_HOSTNAME || options.hostname
31
+ if (!hostname) {
32
+ hostname = sesh.hostname()
33
+ }
34
+
35
+ let token = process.env.DOTENVX_OPS_TOKEN || process.env.DOTENVX_RADAR_TOKEN || options.token
36
+ if (!token) {
37
+ token = sesh.token()
38
+ }
39
+
40
+ const playwrightStorageStateStringified = JSON.stringify(await context.storageState())
41
+ const { uid } = await new PostRotateLogin(hostname, token, org, slug, username, password, email, playwrightStorageStateStringified).run()
42
+
21
43
  await browser.close()
22
- process.stdout.write(storageState)
44
+ process.stdout.write(uid)
23
45
  }
24
46
 
25
47
  module.exports = login
@@ -0,0 +1,9 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ async function rotate () {
4
+ const options = this.opts()
5
+ logger.debug(`options: ${JSON.stringify(options)}`)
6
+ process.stdout.write('coming soon')
7
+ }
8
+
9
+ module.exports = rotate
@@ -3,40 +3,25 @@ const { Command } = require('commander')
3
3
  const npm = new Command('npm')
4
4
 
5
5
  npm
6
- .description('npmjs.com')
6
+ .description('npm')
7
7
  .allowUnknownOption()
8
8
 
9
9
  // dotenvx-ops rotate npm login
10
10
  const loginAction = require('./../../actions/rotate/npm/login')
11
11
  npm
12
12
  .command('login')
13
- .description('interactive local login + cookie capture')
13
+ .description('connect passcard')
14
+ .requiredOption('--org <organizationSlug>')
14
15
  .requiredOption('--username <username>')
15
16
  .requiredOption('--password <password>')
17
+ .option('--email <email>')
16
18
  .action(loginAction)
17
19
 
18
- //
19
- // // dotenvx-ops settings token
20
- // const tokenAction = require('./../actions/settings/token')
21
- // settings
22
- // .command('token')
23
- // .description('print your access token (--unmask)')
24
- // .option('--unmask', 'unmask access token')
25
- // .action(tokenAction)
26
- //
27
- // // dotenvx-ops settings device
28
- // const deviceAction = require('./../actions/settings/device')
29
- // settings
30
- // .command('device')
31
- // .description('print your device pubkey (--unmask)')
32
- // .option('--unmask', 'unmask device pubkey')
33
- // .action(deviceAction)
34
- //
35
- // // dotenvx-ops settings hostname
36
- // const hostnameAction = require('./../actions/settings/hostname')
37
- // settings
38
- // .command('hostname')
39
- // .description('print hostname')
40
- // .action(hostnameAction)
41
- //
20
+ // dotenvx-ops rotate npm rotate
21
+ const rotateAction = require('./../../actions/rotate/npm/rotate')
22
+ npm
23
+ .command('rotate')
24
+ .description('rotate api key')
25
+ .action(rotateAction)
26
+
42
27
  module.exports = npm
@@ -0,0 +1,54 @@
1
+ const { http } = require('../../lib/helpers/http')
2
+ const buildApiError = require('../../lib/helpers/buildApiError')
3
+
4
+ class PostRotateLogin {
5
+ constructor (hostname, token, org, slug, username, password, email = null, playwrightStorageStateStringified) {
6
+ this.hostname = hostname || 'https://ops.dotenvx.com'
7
+ this.token = token
8
+
9
+ this.org = org
10
+ this.slug = slug
11
+ this.username = username
12
+ this.password = password
13
+ this.email = email
14
+ this.playwrightStorageStateStringified = playwrightStorageStateStringified
15
+ }
16
+
17
+ async run () {
18
+ const token = this.token
19
+ const url = `${this.hostname}/api/rotate/login`
20
+
21
+ const org = this.org
22
+ const slug = this.slug
23
+ const username = this.username
24
+ const password = this.password
25
+ const email = this.email
26
+ const playwrightStorageStateStringified = this.playwrightStorageStateStringified
27
+
28
+ const resp = await http(url, {
29
+ method: 'POST',
30
+ headers: {
31
+ Authorization: `Bearer ${token}`,
32
+ 'Content-Type': 'application/json'
33
+ },
34
+ body: JSON.stringify({
35
+ org,
36
+ slug,
37
+ username,
38
+ password,
39
+ email,
40
+ playwright_storage_state: playwrightStorageStateStringified
41
+ })
42
+ })
43
+
44
+ const json = await resp.body.json()
45
+
46
+ if (resp.statusCode >= 400) {
47
+ throw buildApiError(resp.statusCode, json)
48
+ }
49
+
50
+ return json
51
+ }
52
+ }
53
+
54
+ module.exports = PostRotateLogin