Files
Agent-n8n/n8n-n8n-1.109.2/packages/nodes-base/credentials/SegmentApi.credentials.ts

34 lines
754 B
TypeScript
Raw Normal View History

2025-09-08 04:48:28 +08:00
import type {
ICredentialDataDecryptedObject,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';
export class SegmentApi implements ICredentialType {
name = 'segmentApi';
displayName = 'Segment API';
documentationUrl = 'segment';
properties: INodeProperties[] = [
{
displayName: 'Write Key',
name: 'writekey',
type: 'string',
typeOptions: { password: true },
default: '',
},
];
async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
const base64Key = Buffer.from(`${credentials.writekey}:`).toString('base64');
requestOptions.headers!.Authorization = `Basic ${base64Key}`;
return requestOptions;
}
}