n8n-nodes-github-copilot 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class GitHubApiManual implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GitHubApiManual = void 0;
4
+ class GitHubApiManual {
5
+ constructor() {
6
+ this.name = 'gitHubApiManual';
7
+ this.displayName = 'GitHub API (Manual Token)';
8
+ this.documentationUrl = 'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token';
9
+ this.properties = [
10
+ {
11
+ displayName: 'Access Token',
12
+ name: 'accessToken',
13
+ type: 'string',
14
+ typeOptions: { password: true },
15
+ required: true,
16
+ default: '',
17
+ placeholder: 'gho_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
18
+ description: 'GitHub Personal Access Token with Copilot permissions. Must start with "gho_" for OAuth or "ghp_" for classic.',
19
+ },
20
+ {
21
+ displayName: 'Token Type Info',
22
+ name: 'tokenInfo',
23
+ type: 'notice',
24
+ default: '',
25
+ displayOptions: {
26
+ show: {},
27
+ },
28
+ description: 'For GitHub Copilot CLI, OAuth tokens (gho_) are recommended. Create at: GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens',
29
+ },
30
+ ];
31
+ }
32
+ }
33
+ exports.GitHubApiManual = GitHubApiManual;
@@ -62,10 +62,35 @@ class GitHubCopilot {
62
62
  credentials: [
63
63
  {
64
64
  name: 'gitHubApi',
65
- required: true,
65
+ displayName: 'GitHub API (OAuth2)',
66
+ required: false,
67
+ },
68
+ {
69
+ name: 'gitHubApiManual',
70
+ displayName: 'GitHub API (Manual Token)',
71
+ required: false,
66
72
  },
67
73
  ],
68
74
  properties: [
75
+ {
76
+ displayName: 'Authentication Type',
77
+ name: 'authType',
78
+ type: 'options',
79
+ options: [
80
+ {
81
+ name: 'OAuth2 (Automatic)',
82
+ value: 'oauth2',
83
+ description: 'Use OAuth2 authentication configured in n8n',
84
+ },
85
+ {
86
+ name: 'Manual Token',
87
+ value: 'manual',
88
+ description: 'Use manually entered GitHub token',
89
+ },
90
+ ],
91
+ default: 'manual',
92
+ description: 'Choose how to authenticate with GitHub',
93
+ },
69
94
  {
70
95
  displayName: 'Operation',
71
96
  name: 'operation',
@@ -180,7 +205,29 @@ class GitHubCopilot {
180
205
  const operation = this.getNodeParameter('operation', i);
181
206
  const prompt = this.getNodeParameter('prompt', i);
182
207
  const context = this.getNodeParameter('context', i, '');
183
- const credentials = await this.getCredentials('gitHubApi');
208
+ const authType = this.getNodeParameter('authType', i);
209
+ let accessToken;
210
+ let credentialType = '';
211
+ if (authType === 'oauth2') {
212
+ const oauthCredentials = await this.getCredentials('gitHubApi');
213
+ if ((oauthCredentials === null || oauthCredentials === void 0 ? void 0 : oauthCredentials.accessToken) && typeof oauthCredentials.accessToken === 'string') {
214
+ accessToken = oauthCredentials.accessToken;
215
+ credentialType = 'OAuth2';
216
+ }
217
+ else {
218
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'OAuth2 credentials not found or invalid. Please configure OAuth2 authentication or switch to Manual Token.');
219
+ }
220
+ }
221
+ else {
222
+ const manualCredentials = await this.getCredentials('gitHubApiManual');
223
+ if ((manualCredentials === null || manualCredentials === void 0 ? void 0 : manualCredentials.accessToken) && typeof manualCredentials.accessToken === 'string') {
224
+ accessToken = manualCredentials.accessToken;
225
+ credentialType = 'Manual Token';
226
+ }
227
+ else {
228
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Manual token credentials not found or invalid. Please configure Manual Token authentication or switch to OAuth2.');
229
+ }
230
+ }
184
231
  let command;
185
232
  let fullPrompt = prompt;
186
233
  if (context) {
@@ -221,11 +268,12 @@ class GitHubCopilot {
221
268
  default:
222
269
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
223
270
  }
224
- const accessToken = credentials.accessToken;
225
271
  const { stdout, stderr } = await execAsync(command, {
226
272
  env: {
227
273
  ...process.env,
228
274
  GH_TOKEN: accessToken,
275
+ GITHUB_TOKEN: accessToken,
276
+ GH_PAT: accessToken,
229
277
  HOME: '/opt/n8n-source/packages/cli/bin',
230
278
  },
231
279
  timeout: 30000,
@@ -244,6 +292,9 @@ class GitHubCopilot {
244
292
  operation,
245
293
  prompt: prompt,
246
294
  context: context || undefined,
295
+ authType: authType,
296
+ credentialType: credentialType,
297
+ tokenPrefix: accessToken ? accessToken.substring(0, 4) + '...' : 'none',
247
298
  language: operation === 'suggest' ? this.getNodeParameter('language', i) : undefined,
248
299
  commandType: operation === 'shell' ? this.getNodeParameter('commandType', i) : undefined,
249
300
  output: processedOutput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "description": "n8n community node for GitHub Copilot CLI integration",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",
@@ -27,7 +27,8 @@
27
27
  "n8n": {
28
28
  "n8nNodesApiVersion": 1,
29
29
  "credentials": [
30
- "dist/credentials/GitHubApi.credentials.js"
30
+ "dist/credentials/GitHubApi.credentials.js",
31
+ "dist/credentials/GitHubApiManual.credentials.js"
31
32
  ],
32
33
  "nodes": [
33
34
  "dist/nodes/GitHubCopilot/GitHubCopilot.node.js"