mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
Rename files
This commit is contained in:
41
ts/util/smartling.node.ts
Normal file
41
ts/util/smartling.node.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { version } from './packageJson.node.js';
|
||||
import { getUserAgent } from './getUserAgent.node.js';
|
||||
|
||||
type AuthenticateOptionsType = Readonly<{
|
||||
userIdentifier: string;
|
||||
userSecret: string;
|
||||
}>;
|
||||
|
||||
export const API_BASE = new URL('https://api.smartling.com/');
|
||||
export const PROJECT_ID = 'ef62d1ebb';
|
||||
|
||||
export async function authenticate({
|
||||
userIdentifier,
|
||||
userSecret,
|
||||
}: AuthenticateOptionsType): Promise<Headers> {
|
||||
const res = await fetch(new URL('./auth-api/v2/authenticate', API_BASE), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userIdentifier,
|
||||
userSecret,
|
||||
}),
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error('Failed to authenticate with Smartling');
|
||||
}
|
||||
|
||||
const {
|
||||
response: { data: auth },
|
||||
} = await res.json();
|
||||
|
||||
return new Headers({
|
||||
authorization: `${auth.tokenType} ${auth.accessToken}`,
|
||||
'user-agent': getUserAgent(version),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user