Compare commits

...

4 Commits

Author SHA1 Message Date
Jill Regan
dd76a122aa Update dists 2026-02-26 11:22:17 -05:00
Jill Regan
a665f2c1ab Merge pull request #135 from 1Password/jill/validate-secret-reference
Add secret ref validation
2026-02-23 11:42:24 -05:00
Jill Regan
398c918d60 Fix format 2026-02-23 08:13:30 -05:00
Jill Regan
dc90451a94 Apply code suggestions 2026-02-22 12:31:37 -05:00
5 changed files with 3033 additions and 458 deletions

File diff suppressed because one or more lines are too long

BIN
dist/core_bg.wasm vendored Normal file

Binary file not shown.

2601
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -356,7 +356,7 @@ describe("loadSecrets when using Service Account", () => {
describe("secret reference validation", () => {
it("fails with clear message when a secret reference is invalid", async () => {
process.env.MY_SECRET = "op://invalid/ref/form";
process.env.MY_SECRET = "op://x";
(Secrets.validateSecretReference as jest.Mock).mockImplementationOnce(
() => {
throw new Error("invalid reference format");
@@ -379,7 +379,6 @@ describe("loadSecrets when using Service Account", () => {
}
},
);
mockResolve.mockResolvedValue("value1");
await expect(loadSecrets(false)).rejects.toThrow(
"Invalid secret reference(s): OTHER",

View File

@@ -38,7 +38,7 @@ const getEnvVarNamesWithSecretRefs = (): string[] =>
);
const validateSecretRefs = (envNames: string[]): void => {
const invalid: string[] = [];
const invalid: { name: string; message: string }[] = [];
for (const envName of envNames) {
const ref = process.env[envName];
@@ -48,15 +48,18 @@ const validateSecretRefs = (envNames: string[]): void => {
try {
Secrets.validateSecretReference(ref);
} catch {
invalid.push(envName);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
invalid.push({ name: envName, message });
}
}
// Throw an error if any secret references are invalid
if (invalid.length > 0) {
const names = invalid.join(", ");
throw new Error(`Invalid secret reference(s): ${names}`);
const details = invalid
.map(({ name, message }) => `${name}: ${message}`)
.join("; ");
throw new Error(`Invalid secret reference(s): ${details}`);
}
};