@vercel/oidc 3.2.1 → 3.3.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @vercel/oidc
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 24686d0: Add configurable auth token storage with keyring-backed persistence and file fallback support.
8
+
9
+ ### Patch Changes
10
+
11
+ - 56c9f89: add missing prettier dev dependency
12
+ - Updated dependencies [24686d0]
13
+ - Updated dependencies [d36ee35]
14
+ - Updated dependencies [56c9f89]
15
+ - @vercel/cli-auth@0.1.0
16
+
3
17
  ## 3.2.1
4
18
 
5
19
  ### Patch Changes
@@ -1,7 +1,9 @@
1
1
  /**
2
- * Auth configuration stored in ~/.../com.vercel.cli/auth.json
2
+ * Auth configuration stored in ~/.../com.vercel.cli/auth.json or OS keyring
3
3
  */
4
4
  export interface AuthConfig {
5
+ '// Note'?: string;
6
+ '// Docs'?: string;
5
7
  /** An `access_token` obtained using the OAuth Device Authorization flow. */
6
8
  token?: string;
7
9
  /** A `refresh_token` obtained using the OAuth Device Authorization flow. */
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var auth_config_exports = {};
30
20
  __export(auth_config_exports, {
@@ -33,40 +23,35 @@ __export(auth_config_exports, {
33
23
  writeAuthConfig: () => writeAuthConfig
34
24
  });
35
25
  module.exports = __toCommonJS(auth_config_exports);
36
- var fs = __toESM(require("fs"));
37
- var path = __toESM(require("path"));
38
26
  var import_token_util = require("./token-util");
39
- function getAuthConfigPath() {
27
+ const {
28
+ clearAllCredentialsStrict,
29
+ hasCredentials,
30
+ readCredentials,
31
+ writeCredentials
32
+ } = require("@vercel/cli-auth/credentials-store.js");
33
+ function getAuthConfigDir() {
40
34
  const dataDir = (0, import_token_util.getVercelDataDir)();
41
35
  if (!dataDir) {
42
36
  throw new Error(
43
37
  `Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`
44
38
  );
45
39
  }
46
- return path.join(dataDir, "auth.json");
40
+ return dataDir;
47
41
  }
48
42
  function readAuthConfig() {
49
43
  try {
50
- const authPath = getAuthConfigPath();
51
- if (!fs.existsSync(authPath)) {
52
- return null;
53
- }
54
- const content = fs.readFileSync(authPath, "utf8");
55
- if (!content) {
56
- return null;
57
- }
58
- return JSON.parse(content);
44
+ return readCredentials(getAuthConfigDir());
59
45
  } catch (_error) {
60
46
  return null;
61
47
  }
62
48
  }
63
49
  function writeAuthConfig(config) {
64
- const authPath = getAuthConfigPath();
65
- const authDir = path.dirname(authPath);
66
- if (!fs.existsSync(authDir)) {
67
- fs.mkdirSync(authDir, { mode: 504, recursive: true });
50
+ if (hasCredentials(config)) {
51
+ writeCredentials(getAuthConfigDir(), config);
52
+ return;
68
53
  }
69
- fs.writeFileSync(authPath, JSON.stringify(config, null, 2), { mode: 384 });
54
+ clearAllCredentialsStrict(getAuthConfigDir());
70
55
  }
71
56
  function isValidAccessToken(authConfig, expirationBufferMs = 0) {
72
57
  if (!authConfig.token)
@@ -54,6 +54,10 @@ import_vitest.vi.mock("./get-context", () => ({
54
54
  fs.mkdirSync(path.join(rootDir, ".vercel"), {
55
55
  recursive: true
56
56
  });
57
+ fs.writeFileSync(
58
+ path.join(cliDataDir, "config.json"),
59
+ JSON.stringify({ authTokenStorage: "file" })
60
+ );
57
61
  import_vitest.vi.spyOn(process, "cwd").mockReturnValue(rootDir);
58
62
  import_vitest.vi.mocked(import_token_io.findRootDir).mockReturnValue(rootDir);
59
63
  import_vitest.vi.mocked(import_token_io.getUserDataDir).mockReturnValue(userDataDir);
@@ -49,7 +49,14 @@ import_vitest.vi.mock("./token-io");
49
49
  fs.mkdirSync(path.join(rootDir, ".vercel"), {
50
50
  recursive: true
51
51
  });
52
- fs.writeFileSync(path.join(cliDataDir, "auth.json"), '{token: "test"}');
52
+ fs.writeFileSync(
53
+ path.join(cliDataDir, "config.json"),
54
+ JSON.stringify({ authTokenStorage: "file" })
55
+ );
56
+ fs.writeFileSync(
57
+ path.join(cliDataDir, "auth.json"),
58
+ JSON.stringify({ token: "test" })
59
+ );
53
60
  fs.writeFileSync(
54
61
  path.join(rootDir, ".vercel", "project.json"),
55
62
  JSON.stringify({ projectId })
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "require": "./dist/index.js"
18
18
  }
19
19
  },
20
- "version": "3.2.1",
20
+ "version": "3.3.0",
21
21
  "repository": {
22
22
  "directory": "packages/oidc",
23
23
  "type": "git",
@@ -26,7 +26,11 @@
26
26
  "bugs": {
27
27
  "url": "https://github.com/vercel/vercel/issues"
28
28
  },
29
+ "dependencies": {
30
+ "@vercel/cli-auth": "0.1.0"
31
+ },
29
32
  "devDependencies": {
33
+ "prettier": "3.8.3",
30
34
  "tinyspawn": "1.3.1",
31
35
  "typedoc": "0.24.6",
32
36
  "typedoc-plugin-markdown": "3.15.2",