peertube-plugin-livechat/server/lib/apikey.ts

23 lines
624 B
TypeScript
Raw Normal View History

2024-05-23 09:42:14 +00:00
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
//
// SPDX-License-Identifier: AGPL-3.0-only
import type { RegisterServerOptions } from '@peertube/peertube-types'
2021-05-05 15:06:19 +00:00
/*
For internal API, we will generate an api Key that must be provided as
GET parameter for every API call.
*/
async function getAPIKey ({ storageManager }: RegisterServerOptions): Promise<string> {
let value: string = await storageManager.getData('APIKEY')
2021-05-05 15:06:19 +00:00
if (!value) {
value = Math.random().toString(36).slice(2, 12)
await storageManager.storeData('APIKEY', value)
2021-05-05 15:06:19 +00:00
}
return value
}
export {
getAPIKey
2021-05-05 15:06:19 +00:00
}