27 lines
908 B
JavaScript
27 lines
908 B
JavaScript
const credentials = new Map()
|
|
|
|
module.exports = {
|
|
ACCESSIBLE: {
|
|
AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: 'AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY',
|
|
},
|
|
SECURITY_LEVEL: {
|
|
SECURE_SOFTWARE: 'SECURE_SOFTWARE',
|
|
},
|
|
STORAGE_TYPE: {
|
|
AES_GCM_NO_AUTH: 'AES_GCM_NO_AUTH',
|
|
},
|
|
getGenericPassword: jest.fn(async ({ service } = {}) => (
|
|
credentials.get(service ?? 'default') ?? false
|
|
)),
|
|
setGenericPassword: jest.fn(async (username, password, { service } = {}) => {
|
|
const resolvedService = service ?? 'default'
|
|
credentials.set(resolvedService, { username, password })
|
|
return { service: resolvedService, storage: 'AES_GCM_NO_AUTH' }
|
|
}),
|
|
resetGenericPassword: jest.fn(async ({ service } = {}) => {
|
|
credentials.delete(service ?? 'default')
|
|
return true
|
|
}),
|
|
getAllGenericPasswordServices: jest.fn(async () => [...credentials.keys()]),
|
|
__reset: () => credentials.clear(),
|
|
}
|