n8n-nodes-gigachat
Version:
A user-friendly GigaChat AI (Sber) nodes for n8n
78 lines • 2.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GigaChatApi = void 0;
class GigaChatApi {
constructor() {
this.name = 'gigaChatApi';
this.icon = {
light: 'file:gigachat-light.svg',
dark: 'file:gigachat-dark.svg',
};
this.displayName = 'GigaChat API';
this.documentationUrl = 'https://developers.sber.ru/docs/ru/gigachat/individuals-quickstart';
this.properties = [
{
displayName: 'Authorization key',
name: 'authorizationKey',
type: 'string',
default: '',
required: true,
description: 'Base64 encoded log:pass pair (authKey)',
typeOptions: {
password: true,
},
},
{
displayName: 'Scope',
name: 'scope',
type: 'options',
description: 'Type of account',
default: 'GIGACHAT_API_PERS',
options: [
{
name: 'GIGACHAT_API_PERS',
description: 'Individual account',
value: 'GIGACHAT_API_PERS',
},
{
name: 'GIGACHAT_API_B2B',
description: 'Business account (token packages)',
value: 'GIGACHAT_API_B2B',
},
{
name: 'GIGACHAT_API_CORP',
description: 'Business account (pay-as-you-go)',
value: 'GIGACHAT_API_CORP',
},
],
},
];
this.authenticate = {
type: 'generic',
properties: {
headers: {
Authorization: '={{"Basic " + $credentials.authorizationKey}}',
},
},
};
this.test = {
request: {
baseURL: 'https://ngw.devices.sberbank.ru:9443',
url: '/api/v2/oauth',
method: 'POST',
headers: {
RqUID: '={{"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => (c == "x" ? (Math.random() * 16 | 0) : (Math.random() * 4 | 8)).toString(16))}}',
Authorization: '={{"Basic " + $credentials.authorizationKey}}',
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/json',
},
body: {
scope: '={{$credentials.scope}}',
},
skipSslCertificateValidation: true,
},
};
}
}
exports.GigaChatApi = GigaChatApi;
//# sourceMappingURL=GigaChatApi.credentials.js.map