Verify Clouddrop log accounts through the bearer-authenticated token endpoint
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-10-15 04:20:01 +02:00
1 parent ed5edc9222
commit 345870dcc9
1 file changed
+11 -3
+11 -3
View File
@@ -51,8 +51,16 @@ class ClouddropLogApi {
async identify(signal) {
if (!/^cd_[a-f0-9]{32}$/.test(this.apiKey)) throw new CloudLogError('INVALID_KEY');
const user = await this.call('/me', { signal });
if (typeof user.id !== 'string' || !user.id) throw new CloudLogError('INVALID_RESPONSE');
const authorization = await this.call('/upload-token', { signal });
const token = authorization?.token;
if (typeof token !== 'string' || token.length > 2048 || !/^[A-Za-z0-9_-]+$/.test(token)) {
throw new CloudLogError('INVALID_RESPONSE');
}
const [accountId, expires, signature, extra] = Buffer.from(token, 'base64url').toString('utf8').split(':');
if (!/^[A-Za-z0-9_-]{1,100}$/.test(accountId || '') || !/^\d{13}$/.test(expires || '')
|| Number(expires) <= Date.now() || !/^[a-f0-9]{64}$/.test(signature || '') || extra !== undefined) {
throw new CloudLogError('INVALID_RESPONSE');
}
const response = await this.request('https://api64.ipify.org?format=json', {
signal, maxRedirections: 0, headersTimeout: 15000, bodyTimeout: 15000,
headers: { Accept: 'application/json' }
@@ -61,7 +69,7 @@ class ClouddropLogApi {
let ip;
try { ip = JSON.parse(text).ip; } catch {}
if (response.statusCode !== 200 || !isIP(ip || '')) throw new CloudLogError('IP_UNAVAILABLE');
return { accountId: user.id, ip, folderName: ip.replaceAll(':', '_') };
return { accountId, ip, folderName: ip.replaceAll(':', '_') };
}
async ensureFolder(name, signal) {