Files
mem0/integrations/n8n-nodes-mem0/credentials/Mem0Api.credentials.ts
T
Himanshu-Sangshetti 7417f87252 fix(n8n): address review feedback and pass the verification scanner
- Telemetry: replace client-side PostHog (which read process.env, banned in
  verified nodes) with first-party `source: "N8N"` attribution on API requests,
  mirroring OpenClaw. Removes the undisclosed-collection concern entirely.
- Verification-scanner fixes: add credential icon, use NodeConnectionTypes.Main
  instead of the 'main' literal, wrap error paths in NodeApiError, stop shipping
  .d.ts / tsbuildinfo, and align the local eslint config with the scanner.
- Add offline unit tests (jest): entity-id guard, JSON-parse errors, poll-timeout
  loop, source attribution, and Return All pagination.
- Get Many: add a Return All option that pages through all memories.
- Docs: README telemetry note and an AGENTS.md Key Directories row.

Verified: build + tsc + eslint + 5 unit tests + live E2E against api.mem0.ai, and
the packed tarball passes @n8n/scan-community-package with zero violations.
2026-07-23 19:34:00 +05:30

57 lines
1.3 KiB
TypeScript

import {
IAuthenticateGeneric,
Icon,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class Mem0Api implements ICredentialType {
name = 'mem0Api';
displayName = 'Mem0 API';
icon: Icon = 'file:mem0.svg';
documentationUrl = 'https://docs.mem0.ai/platform/quickstart';
properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
typeOptions: { password: true },
default: '',
required: true,
description: 'Your Mem0 API key (starts with "m0-"). Create one at app.mem0.ai → Settings → API Keys.',
},
{
displayName: 'Base URL',
name: 'baseUrl',
type: 'string',
default: 'https://api.mem0.ai',
description: 'Mem0 API base URL. Override only for self-hosted or non-default deployments.',
},
];
// Injects "Authorization: Token <apiKey>" on every request, matching the
// scheme used by Mem0's official SDKs (Authorization: Token m0-...).
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Token {{$credentials.apiKey}}',
},
},
};
// Cheap authenticated GET; validates the key when the user clicks "Test".
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.baseUrl}}',
url: '/v1/ping/',
method: 'GET',
},
};
}