n8n-nodes-feishu-fork
Version:
n8n custom nodes for n8n to interact with Feishu/Lark, including Lark Bot, Lark MCP, and Lark Trigger.
49 lines • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class RequestUtils {
static async originRequest(options, clearAccessToken = false) {
const authenticationMethod = this.getNodeParameter('authentication', 0, "larkApi");
const credentials = await this.getCredentials(authenticationMethod);
options.baseURL = credentials.baseUrl;
if (authenticationMethod === "larkApi") {
const additionalCredentialOptions = {
credentialsDecrypted: {
id: "33f755b6-3486-4507-9049-1407c6ddfc91",
name: "larkApi",
type: "lark",
data: {
...credentials,
accessToken: clearAccessToken ? '' : credentials.accessToken,
},
},
};
return this.helpers.httpRequestWithAuthentication.call(this, authenticationMethod, options, additionalCredentialOptions);
}
return this.helpers.httpRequestWithAuthentication.call(this, authenticationMethod, options);
}
static async request(options) {
if (options.json === undefined)
options.json = true;
return RequestUtils.originRequest.call(this, options).catch((error) => {
if (error.context && error.context.data) {
let errorData = {};
if (error.context.data.code) {
errorData = error.context.data;
}
else {
errorData = JSON.parse(Buffer.from(error.context.data).toString('utf-8'));
}
const { code, msg } = errorData;
if (code === 99991663) {
return RequestUtils.originRequest.call(this, options, true);
}
if (code !== 0) {
throw new Error(`Request Lark API Error: ${code}, ${msg}`);
}
}
throw error;
});
}
}
exports.default = RequestUtils;
//# sourceMappingURL=RequestUtils.js.map