mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
feat(voice): add ChatGPT OAuth auth option
This commit is contained in:
1 parent
b210ab0fe4
commit
881e24485c
23 files changed
+918
-34
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
CLOUD_VOICE_AUTH_STORAGE_KEY,
|
||||
readStoredCloudVoiceAuthMode,
|
||||
writeStoredCloudVoiceAuthMode,
|
||||
} from './cloudVoiceAuth.js';
|
||||
|
||||
function memoryStorage(seed = {}) {
|
||||
const values = new Map(Object.entries(seed));
|
||||
return {
|
||||
getItem: (key) => values.get(key) ?? null,
|
||||
setItem: (key, value) => values.set(key, value),
|
||||
};
|
||||
}
|
||||
|
||||
test('cloud voice auth defaults to API key and persists OAuth independently', () => {
|
||||
const storage = memoryStorage();
|
||||
assert.equal(readStoredCloudVoiceAuthMode(storage), 'api-key');
|
||||
assert.equal(writeStoredCloudVoiceAuthMode('oauth', storage), 'oauth');
|
||||
assert.equal(readStoredCloudVoiceAuthMode(storage), 'oauth');
|
||||
assert.equal(writeStoredCloudVoiceAuthMode('unknown', storage), 'api-key');
|
||||
assert.equal(
|
||||
readStoredCloudVoiceAuthMode(
|
||||
memoryStorage({ [CLOUD_VOICE_AUTH_STORAGE_KEY]: 'oauth' }),
|
||||
),
|
||||
'oauth',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user