UNPKG

n8n-nodes-feishu-lark

Version:

n8n custom nodes for n8n to interact with Feishu/Lark, including Lark Bot, Lark MCP, and Lark Trigger.

102 lines 3.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LarkTokenApi = void 0; class LarkTokenApi { constructor() { this.name = "larkApi"; this.displayName = 'Lark Tenant Token API'; this.icon = 'file:lark_icon.svg'; this.documentationUrl = 'https://open.feishu.cn/document/faq/trouble-shooting/how-to-obtain-app-id'; this.properties = [ { displayName: 'Base URL', name: 'baseUrl', type: 'options', options: [ { name: `${"https://open.feishu.cn"}`, value: `${"https://open.feishu.cn"}`, description: 'Feishu Open Platform base URL(China)', }, { name: `${"https://open.larksuite.com"}`, value: `${"https://open.larksuite.com"}`, description: 'Lark Open Platform base URL(Global)', }, ], default: [], required: true, }, { displayName: 'App ID', description: 'The unique identifier for an application on the Lark Open Platform', name: 'appid', type: 'string', default: '', }, { displayName: 'App Secret', name: 'appsecret', description: 'The secret key for the application.', type: 'string', typeOptions: { password: true, }, default: '', }, { displayName: 'AccessToken', name: 'accessToken', type: 'hidden', default: '', typeOptions: { expirable: true, }, }, ]; this.authenticate = { type: 'generic', properties: { headers: { Authorization: '=Bearer {{$credentials?.accessToken}}', }, }, }; this.test = { request: { baseURL: '={{$credentials.baseUrl}}', url: `/open-apis/auth/v3/tenant_access_token/internal`, method: 'POST', body: { app_id: '={{$credentials.appid}}', app_secret: '={{$credentials.appsecret}}', }, }, rules: [ { type: 'responseCode', properties: { value: 200, message: 'Authentication successful', }, }, ], }; } async preAuthentication(credentials) { const { code, msg, tenant_access_token } = (await this.helpers.httpRequest({ method: 'POST', url: `${credentials.baseUrl}/open-apis/auth/v3/tenant_access_token/internal`, body: { app_id: credentials.appid, app_secret: credentials.appsecret, }, })); if (code && code !== 0) { throw new Error('Authentication failed:' + code + ', ' + msg); } return { accessToken: tenant_access_token }; } } exports.LarkTokenApi = LarkTokenApi; //# sourceMappingURL=LarkTokenApi.credentials.js.map