@outputai/credentials 0.1.11-next.c29eb94.0 → 0.1.11-next.c4f84d5.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/dist/credentials.spec.js +64 -0
- package/package.json +2 -2
package/dist/credentials.spec.js
CHANGED
|
@@ -359,6 +359,70 @@ describe('credentials module', () => {
|
|
|
359
359
|
expect(readFileSync).toHaveBeenCalledTimes(2);
|
|
360
360
|
});
|
|
361
361
|
});
|
|
362
|
+
describe('resolveCredentialRefs', () => {
|
|
363
|
+
const refKey = generateKey();
|
|
364
|
+
const refCiphertext = encrypt(YAML_CONTENT, refKey);
|
|
365
|
+
const loadResolveCredentialRefs = async () => {
|
|
366
|
+
vi.resetModules();
|
|
367
|
+
const mod = await import('./index.js');
|
|
368
|
+
return mod.resolveCredentialRefs;
|
|
369
|
+
};
|
|
370
|
+
afterEach(() => {
|
|
371
|
+
delete process.env.ANTHROPIC_API_KEY;
|
|
372
|
+
delete process.env.OPENAI_API_KEY;
|
|
373
|
+
});
|
|
374
|
+
it('should resolve credential: env vars to decrypted values', async () => {
|
|
375
|
+
process.env.OUTPUT_CREDENTIALS_KEY = refKey;
|
|
376
|
+
process.env.ANTHROPIC_API_KEY = 'credential:anthropic.api_key';
|
|
377
|
+
vi.doMock('node:fs', () => ({
|
|
378
|
+
readFileSync: () => refCiphertext,
|
|
379
|
+
existsSync: (path) => path.endsWith('credentials.yml.enc')
|
|
380
|
+
}));
|
|
381
|
+
const resolve = await loadResolveCredentialRefs();
|
|
382
|
+
const resolved = resolve();
|
|
383
|
+
expect(resolved).toEqual(['ANTHROPIC_API_KEY']);
|
|
384
|
+
expect(process.env.ANTHROPIC_API_KEY).toBe('sk-ant-test');
|
|
385
|
+
});
|
|
386
|
+
it('should leave non-credential env vars unchanged', async () => {
|
|
387
|
+
process.env.OUTPUT_CREDENTIALS_KEY = refKey;
|
|
388
|
+
process.env.ANTHROPIC_API_KEY = 'sk-ant-already-set';
|
|
389
|
+
vi.doMock('node:fs', () => ({
|
|
390
|
+
readFileSync: () => refCiphertext,
|
|
391
|
+
existsSync: (path) => path.endsWith('credentials.yml.enc')
|
|
392
|
+
}));
|
|
393
|
+
const resolve = await loadResolveCredentialRefs();
|
|
394
|
+
const resolved = resolve();
|
|
395
|
+
expect(resolved).toEqual([]);
|
|
396
|
+
expect(process.env.ANTHROPIC_API_KEY).toBe('sk-ant-already-set');
|
|
397
|
+
});
|
|
398
|
+
it('should skip credential refs that do not resolve to a value', async () => {
|
|
399
|
+
process.env.OUTPUT_CREDENTIALS_KEY = refKey;
|
|
400
|
+
process.env.OPENAI_API_KEY = 'credential:nonexistent.path';
|
|
401
|
+
vi.doMock('node:fs', () => ({
|
|
402
|
+
readFileSync: () => refCiphertext,
|
|
403
|
+
existsSync: (path) => path.endsWith('credentials.yml.enc')
|
|
404
|
+
}));
|
|
405
|
+
const resolve = await loadResolveCredentialRefs();
|
|
406
|
+
const resolved = resolve();
|
|
407
|
+
expect(resolved).toEqual([]);
|
|
408
|
+
expect(process.env.OPENAI_API_KEY).toBe('credential:nonexistent.path');
|
|
409
|
+
});
|
|
410
|
+
it('should resolve multiple credential refs in one call', async () => {
|
|
411
|
+
process.env.OUTPUT_CREDENTIALS_KEY = refKey;
|
|
412
|
+
process.env.ANTHROPIC_API_KEY = 'credential:anthropic.api_key';
|
|
413
|
+
process.env.OPENAI_API_KEY = 'credential:aws.secret';
|
|
414
|
+
vi.doMock('node:fs', () => ({
|
|
415
|
+
readFileSync: () => refCiphertext,
|
|
416
|
+
existsSync: (path) => path.endsWith('credentials.yml.enc')
|
|
417
|
+
}));
|
|
418
|
+
const resolve = await loadResolveCredentialRefs();
|
|
419
|
+
const resolved = resolve();
|
|
420
|
+
expect(resolved).toContain('ANTHROPIC_API_KEY');
|
|
421
|
+
expect(resolved).toContain('OPENAI_API_KEY');
|
|
422
|
+
expect(process.env.ANTHROPIC_API_KEY).toBe('sk-ant-test');
|
|
423
|
+
expect(process.env.OPENAI_API_KEY).toBe('aws-secret');
|
|
424
|
+
});
|
|
425
|
+
});
|
|
362
426
|
describe('custom provider', () => {
|
|
363
427
|
it('should use a custom provider when set via registry', async () => {
|
|
364
428
|
const customProvider = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outputai/credentials",
|
|
3
|
-
"version": "0.1.11-next.
|
|
3
|
+
"version": "0.1.11-next.c4f84d5.0",
|
|
4
4
|
"description": "Encrypted credentials management for Output.ai workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"js-yaml": "4.1.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@outputai/core": "0.1.11-next.
|
|
24
|
+
"@outputai/core": "0.1.11-next.c4f84d5.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/js-yaml": "4.0.9"
|