n8n-nodes-github-copilot 3.8.0 → 3.10.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.
package/README.md CHANGED
@@ -154,12 +154,15 @@ gh auth token
154
154
 
155
155
  Para usar o **GitHub Copilot Chat API** (com modelos GPT-5, Claude, etc.):
156
156
 
157
- 1. **Selecione credenciais built-in**: Use **"GitHub API"** (credencial padrão do n8n)
158
- 2. **Configure a credencial**:
159
- - **GitHub Server**: `https://api.github.com`
160
- - **User**: Seu username do GitHub
161
- - **Access Token**: Token obtido via `gh auth token` (formato `gho_*`)
162
- 3. **Importante**: Apenas tokens GitHub Copilot funcionam - Personal Access Tokens (`ghp_*`) são rejeitados pela API
157
+ 1. **Use autenticação OAuth2**: Selecione **"GitHub OAuth2 API"** (credencial padrão do n8n)
158
+ 2. **Configure a credencial OAuth2**:
159
+ - **Client ID**: Seu GitHub OAuth App Client ID
160
+ - **Client Secret**: Seu GitHub OAuth App Client Secret
161
+ - **Scope**: `copilot read:org repo user`
162
+ 3. **Crie uma GitHub OAuth App**:
163
+ - Vá para GitHub → Settings → Developer settings → OAuth Apps
164
+ - Clique em "New OAuth App" e configure callback URL do n8n
165
+ 4. **Vantagens**: Autenticação segura, renovação automática de tokens, acesso organizacional
163
166
 
164
167
  ## 🎮 Como Usar
165
168
 
@@ -22,7 +22,7 @@ class GitHubCopilotChatAPI {
22
22
  outputs: ["main"],
23
23
  credentials: [
24
24
  {
25
- name: 'githubApi',
25
+ name: 'githubOAuth2Api',
26
26
  required: true,
27
27
  },
28
28
  ],
@@ -10,23 +10,24 @@ exports.estimateTokens = estimateTokens;
10
10
  exports.validateTokenLimit = validateTokenLimit;
11
11
  exports.truncateToTokenLimit = truncateToTokenLimit;
12
12
  async function makeApiRequest(context, endpoint, body, hasMedia = false) {
13
- const credentials = await context.getCredentials('githubApi');
14
- const token = credentials.accessToken;
13
+ var _a;
14
+ const credentials = await context.getCredentials('githubOAuth2Api');
15
+ console.log('🔍 OAuth2 Credentials Debug:', Object.keys(credentials));
16
+ const token = (credentials.accessToken ||
17
+ credentials.access_token ||
18
+ ((_a = credentials.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token) ||
19
+ credentials.token);
15
20
  if (!token) {
16
- throw new Error('GitHub Copilot: No access token found in credentials');
21
+ console.error(' Available credential properties:', Object.keys(credentials));
22
+ console.error('❌ Full credential object:', JSON.stringify(credentials, null, 2));
23
+ throw new Error('GitHub Copilot: No access token found in OAuth2 credentials. Available properties: ' + Object.keys(credentials).join(', '));
17
24
  }
18
- if (!token.startsWith('gho_')) {
19
- const tokenPrefix = token.substring(0, token.indexOf('_') + 1) || token.substring(0, 4);
20
- const tokenSuffix = token.length > 5 ? token.substring(token.length - 5) : token;
21
- console.error(`❌ GitHub Copilot Auth Debug: Invalid token format. Got: ${tokenPrefix}...${tokenSuffix}`);
22
- throw new Error(`GitHub Copilot API requires GitHub Copilot tokens (gho_*). ` +
23
- `Received token with prefix: ${tokenPrefix}...${tokenSuffix}. ` +
24
- `Personal Access Tokens (ghp_*) and other formats are not supported. ` +
25
- `Please obtain a GitHub Copilot access token from your organization.`);
25
+ const tokenPrefix = token.substring(0, Math.min(4, token.indexOf('_') + 1)) || token.substring(0, 4);
26
+ const tokenSuffix = token.substring(Math.max(0, token.length - 5));
27
+ console.log(`🔍 GitHub Copilot OAuth2 Debug: Using token ${tokenPrefix}...${tokenSuffix}`);
28
+ if (!token.startsWith('gho_') && !token.startsWith('ghu_') && !token.startsWith('github_pat_')) {
29
+ console.warn(`⚠️ Unexpected token format: ${tokenPrefix}...${tokenSuffix}. Trying API call anyway.`);
26
30
  }
27
- const tokenPrefix = token.substring(0, token.indexOf('_') + 1);
28
- const tokenSuffix = token.substring(token.length - 5);
29
- console.log(`🔍 GitHub Copilot Auth Debug: Using token ${tokenPrefix}...${tokenSuffix}`);
30
31
  const headers = {
31
32
  'Authorization': `Bearer ${token}`,
32
33
  'Content-Type': 'application/json',
@@ -34,7 +34,7 @@ class GitHubCopilotChatModel {
34
34
  outputNames: ['Model'],
35
35
  credentials: [
36
36
  {
37
- name: 'gitHubApiManual',
37
+ name: 'githubOAuth2Api',
38
38
  required: true,
39
39
  },
40
40
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "n8n community node for GitHub Copilot with CLI integration, Chat API access, and AI Chat Model for workflows - access GPT-5, Claude, Gemini and more using your Copilot subscription",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",
@@ -16,9 +16,9 @@
16
16
  "scripts": {
17
17
  "build": "tsc && gulp build:icons",
18
18
  "dev": "tsc --watch",
19
- "format": "prettier nodes --write",
20
- "lint": "eslint nodes package.json",
21
- "lintfix": "eslint nodes package.json --fix",
19
+ "format": "prettier nodes credentials --write",
20
+ "lint": "eslint nodes credentials package.json",
21
+ "lintfix": "eslint nodes credentials package.json --fix",
22
22
  "prepublishOnly": "npm run build && npm run lint -s"
23
23
  },
24
24
  "files": [
@@ -26,7 +26,10 @@
26
26
  ],
27
27
  "n8n": {
28
28
  "n8nNodesApiVersion": 1,
29
- "credentials": [],
29
+ "credentials": [
30
+ "dist/credentials/GitHubApi.credentials.js",
31
+ "dist/credentials/GitHubApiManual.credentials.js"
32
+ ],
30
33
  "nodes": [
31
34
  "dist/nodes/GitHubCopilot/GitHubCopilot.node.js",
32
35
  "dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js",