@theholocron/kyber 5.0.0-alpha.363 → 5.0.0-alpha.364

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.
@@ -43,6 +43,17 @@ export declare function hasCredentials(source: string): boolean;
43
43
  * vendor's). `undefined` when no source has one.
44
44
  */
45
45
  export declare function getCredential(...names: string[]): string | undefined;
46
+ /** A value found in the store, with the source that had it and the name it was found under. */
47
+ export interface FoundCredential {
48
+ /** The value. A secret: callers must not print it. */
49
+ value: string;
50
+ /** The source that returned it, as it was given to {@link setCredentials} (for example `1password:Holocron`). */
51
+ source: string;
52
+ /** Which of the names asked for had it. */
53
+ name: string;
54
+ }
55
+ /** Like {@link getCredential}, but also says which source and which name the value came from, for a report. */
56
+ export declare function findCredential(...names: string[]): FoundCredential | undefined;
46
57
  /** Forget every source. For tests, and for a process that wants the next load to read the providers again. */
47
58
  export declare function clearCredentials(): void;
48
59
  /**
package/dist/secrets.mjs CHANGED
@@ -49,9 +49,17 @@ function hasCredentials(source) {
49
49
  * vendor's). `undefined` when no source has one.
50
50
  */
51
51
  function getCredential(...names) {
52
- for (const variables of sources.values()) for (const name of names) {
52
+ return findCredential(...names)?.value;
53
+ }
54
+ /** Like {@link getCredential}, but also says which source and which name the value came from, for a report. */
55
+ function findCredential(...names) {
56
+ for (const [source, variables] of sources) for (const name of names) {
53
57
  const value = variables[name];
54
- if (value) return value;
58
+ if (value) return {
59
+ value,
60
+ source,
61
+ name
62
+ };
55
63
  }
56
64
  }
57
65
  /** Forget every source. For tests, and for a process that wants the next load to read the providers again. */
@@ -469,4 +477,4 @@ function createResolveToken(config) {
469
477
  function resolveValue(names, env) {
470
478
  return firstEnv(env, ...names) ?? getCredential(...names);
471
479
  }
472
- export { AuthError, DOTENV_FILE, TokenParseError, clearCredentials, copyToClipboard, createFeatureResolver, createKeyring, createPrivateFile, createResolveToken, dotenvLine, finishCredentialsFile, getCredential, hasCredentials, isGitIgnored, parseTokenArgs, readDotenvFile, resolveValue, setCredentials, shredFile, writeCredentialsFile };
480
+ export { AuthError, DOTENV_FILE, TokenParseError, clearCredentials, copyToClipboard, createFeatureResolver, createKeyring, createPrivateFile, createResolveToken, dotenvLine, findCredential, finishCredentialsFile, getCredential, hasCredentials, isGitIgnored, parseTokenArgs, readDotenvFile, resolveValue, setCredentials, shredFile, writeCredentialsFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/kyber",
3
- "version": "5.0.0-alpha.363",
3
+ "version": "5.0.0-alpha.364",
4
4
  "description": "The reusable parts of a command-line tool: terminal output, prompts, the interactive menu, the update notifier, safe handling of tokens, a test harness and the global flags.",
5
5
  "keywords": [
6
6
  "cli",
@@ -105,12 +105,12 @@
105
105
  "typescript": "^5.9.3",
106
106
  "vitest": "^5.0.5",
107
107
  "yargs": "^18.1.0",
108
- "@theholocron/datapad": "5.0.0-alpha.363",
109
- "@theholocron/eslint-config": "^8.9.0-alpha.9",
110
- "@theholocron/observability": "0.7.0-alpha.1",
111
- "@theholocron/tsconfig": "^8.9.0-alpha.9",
112
- "@theholocron/vitest-config": "^8.9.0-alpha.9",
113
- "@theholocron/tsdown-config": "^8.9.0-alpha.9"
108
+ "@theholocron/datapad": "5.0.0-alpha.364",
109
+ "@theholocron/eslint-config": "^8.9.0-alpha.11",
110
+ "@theholocron/tsconfig": "^8.9.0-alpha.11",
111
+ "@theholocron/observability": "0.7.0-alpha.2",
112
+ "@theholocron/vitest-config": "^8.9.0-alpha.11",
113
+ "@theholocron/tsdown-config": "^8.9.0-alpha.11"
114
114
  },
115
115
  "peerDependencies": {
116
116
  "@inquirer/prompts": "^8.0.0",
@@ -121,8 +121,8 @@
121
121
  "dotenv": "^17.0.0",
122
122
  "ora": "^9.0.0",
123
123
  "yargs": "^18.0.0",
124
- "@theholocron/datapad": "^5.0.0-alpha.363",
125
- "@theholocron/observability": "^0.7.0-alpha.1"
124
+ "@theholocron/datapad": "^5.0.0-alpha.364",
125
+ "@theholocron/observability": "^0.7.0-alpha.2"
126
126
  },
127
127
  "peerDependenciesMeta": {
128
128
  "@inquirer/prompts": {