n8n/packages/nodes-base/credentials/SegmentApi.credentials.ts
Iván Ovejero dec19585bc
refactor: Enforce expanded sensitive inputs rules (no-changelog) (#6815)
* refactor: Enforce expanded sensitive inputs rules (no-changelog)

* refactor: Add extra exemption

* fix: Add setting to `sessionToken` fields

* fix: Restore for `hidden` fields

* fix: More edge case exemptions

* fix: One more
2023-08-01 13:08:25 +02:00

34 lines
754 B
TypeScript

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;
}
}