2023-10-04 09:30:05 +02:00
|
|
|
import { httpClientFactory } from '@/services/httpClientFactory'
|
|
|
|
|
|
|
|
const apiClient = httpClientFactory('api')
|
2023-10-05 14:05:42 +02:00
|
|
|
const webClient = httpClientFactory('web')
|
2023-10-04 09:30:05 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
/**
|
2023-10-05 14:05:42 +02:00
|
|
|
* Update a user preference
|
2023-10-04 09:30:05 +02:00
|
|
|
*
|
2023-10-05 14:05:42 +02:00
|
|
|
* @param {string} name
|
|
|
|
* @param {any} value
|
|
|
|
* @returns promise
|
2023-10-04 09:30:05 +02:00
|
|
|
*/
|
2023-10-05 14:05:42 +02:00
|
|
|
updatePreference(name, value) {
|
2023-10-04 09:30:05 +02:00
|
|
|
return apiClient.put('/user/preferences/' + name, { value: value })
|
|
|
|
},
|
2023-10-05 14:09:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all webauthn devices
|
|
|
|
*
|
|
|
|
* @param {string} name
|
|
|
|
* @param {any} value
|
|
|
|
* @returns promise
|
|
|
|
*/
|
|
|
|
getWebauthnDevices(config = {}) {
|
|
|
|
return webClient.get('/webauthn/credentials', {...config})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Revoke a webauthn device
|
|
|
|
*
|
|
|
|
* @param {string} name
|
|
|
|
* @param {any} value
|
|
|
|
* @returns promise
|
|
|
|
*/
|
|
|
|
revokeWebauthnDevice(credentialId, config = {}) {
|
|
|
|
return webClient.delete('/webauthn/credentials/' + credentialId, {...config})
|
|
|
|
},
|
2023-10-06 10:45:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all user PATs
|
|
|
|
*
|
|
|
|
* @param {*} config
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
getPersonalAccessTokens(config = {}) {
|
|
|
|
return webClient.get('/oauth/personal-access-tokens', {...config})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a user PAT
|
|
|
|
*
|
|
|
|
* @param {*} tokenId
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
deletePersonalAccessToken(tokenId, config = {}) {
|
|
|
|
return webClient.delete('/oauth/personal-access-tokens/' + tokenId, {...config})
|
|
|
|
}
|
2023-10-04 09:30:05 +02:00
|
|
|
|
|
|
|
}
|