n8n-nodes-github-copilot 1.1.4 → 1.1.6
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.
|
@@ -87,6 +87,11 @@ class GitHubCopilot {
|
|
|
87
87
|
name: 'authType',
|
|
88
88
|
type: 'options',
|
|
89
89
|
options: [
|
|
90
|
+
{
|
|
91
|
+
name: 'Local CLI Authentication',
|
|
92
|
+
value: 'local',
|
|
93
|
+
description: 'Use GitHub CLI local authentication (recommended)',
|
|
94
|
+
},
|
|
90
95
|
{
|
|
91
96
|
name: 'OAuth2 (Automatic)',
|
|
92
97
|
value: 'oauth2',
|
|
@@ -98,7 +103,7 @@ class GitHubCopilot {
|
|
|
98
103
|
description: 'Use manually entered GitHub token',
|
|
99
104
|
},
|
|
100
105
|
],
|
|
101
|
-
default: '
|
|
106
|
+
default: 'local',
|
|
102
107
|
description: 'Choose how to authenticate with GitHub',
|
|
103
108
|
},
|
|
104
109
|
{
|
|
@@ -208,7 +213,6 @@ class GitHubCopilot {
|
|
|
208
213
|
};
|
|
209
214
|
}
|
|
210
215
|
async execute() {
|
|
211
|
-
var _a;
|
|
212
216
|
const items = this.getInputData();
|
|
213
217
|
const returnData = [];
|
|
214
218
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -219,19 +223,22 @@ class GitHubCopilot {
|
|
|
219
223
|
const authType = this.getNodeParameter('authType', i);
|
|
220
224
|
let accessToken;
|
|
221
225
|
let credentialType = '';
|
|
222
|
-
if (authType === '
|
|
226
|
+
if (authType === 'local') {
|
|
227
|
+
credentialType = 'Local CLI';
|
|
228
|
+
accessToken = undefined;
|
|
229
|
+
}
|
|
230
|
+
else if (authType === 'oauth2') {
|
|
223
231
|
const oauthCredentials = await this.getCredentials('gitHubApi');
|
|
224
232
|
console.log('OAuth2 credentials object:', JSON.stringify(oauthCredentials, null, 2));
|
|
225
233
|
const creds = oauthCredentials;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
((_a = creds === null || creds === void 0 ? void 0 : creds.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token);
|
|
230
|
-
if (accessToken && typeof accessToken === 'string') {
|
|
234
|
+
const oauthTokenData = creds === null || creds === void 0 ? void 0 : creds.oauthTokenData;
|
|
235
|
+
if ((oauthTokenData === null || oauthTokenData === void 0 ? void 0 : oauthTokenData.access_token) && typeof oauthTokenData.access_token === 'string') {
|
|
236
|
+
accessToken = oauthTokenData.access_token;
|
|
231
237
|
credentialType = 'OAuth2';
|
|
238
|
+
console.log('Using OAuth2 token from oauthTokenData.access_token:', accessToken.substring(0, 8) + '...');
|
|
232
239
|
}
|
|
233
240
|
else {
|
|
234
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `OAuth2 token not found. Available fields: ${Object.keys(oauthCredentials || {}).join(', ')}. Please switch to Manual Token.`);
|
|
241
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `OAuth2 token not found in oauthTokenData.access_token. Available fields: ${Object.keys(oauthCredentials || {}).join(', ')}. Please switch to Manual Token.`);
|
|
235
242
|
}
|
|
236
243
|
}
|
|
237
244
|
else {
|
|
@@ -239,6 +246,8 @@ class GitHubCopilot {
|
|
|
239
246
|
if ((manualCredentials === null || manualCredentials === void 0 ? void 0 : manualCredentials.accessToken) && typeof manualCredentials.accessToken === 'string') {
|
|
240
247
|
accessToken = manualCredentials.accessToken;
|
|
241
248
|
credentialType = 'Manual Token';
|
|
249
|
+
const tokenPrefix = accessToken.substring(0, 4);
|
|
250
|
+
console.log('Using manual token with prefix:', tokenPrefix + '...');
|
|
242
251
|
}
|
|
243
252
|
else {
|
|
244
253
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Manual token credentials not found or invalid. Please configure Manual Token authentication or switch to OAuth2.');
|
|
@@ -288,19 +297,22 @@ class GitHubCopilot {
|
|
|
288
297
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
|
|
289
298
|
}
|
|
290
299
|
console.log('Executing command:', command);
|
|
291
|
-
console.log('
|
|
292
|
-
console.log('Token
|
|
300
|
+
console.log('Auth type:', authType);
|
|
301
|
+
console.log('Token prefix:', accessToken ? accessToken.substring(0, 8) + '...' : 'none (using local CLI auth)');
|
|
302
|
+
console.log('Token type:', accessToken ? (accessToken.startsWith('gho_') ? 'OAuth' : accessToken.startsWith('ghp_') ? 'Classic' : 'Unknown') : 'Local CLI');
|
|
293
303
|
let stdout = '';
|
|
294
304
|
let stderr = '';
|
|
295
305
|
try {
|
|
306
|
+
const envVars = {
|
|
307
|
+
...process.env,
|
|
308
|
+
HOME: '/opt/n8n-source/packages/cli/bin',
|
|
309
|
+
};
|
|
310
|
+
if (authType !== 'local' && accessToken) {
|
|
311
|
+
envVars.GH_TOKEN = accessToken;
|
|
312
|
+
envVars.GITHUB_TOKEN = accessToken;
|
|
313
|
+
}
|
|
296
314
|
const result = await execAsync(command, {
|
|
297
|
-
env:
|
|
298
|
-
...process.env,
|
|
299
|
-
GH_TOKEN: accessToken,
|
|
300
|
-
GITHUB_TOKEN: accessToken,
|
|
301
|
-
GH_PAT: accessToken,
|
|
302
|
-
HOME: '/opt/n8n-source/packages/cli/bin',
|
|
303
|
-
},
|
|
315
|
+
env: envVars,
|
|
304
316
|
timeout: 30000,
|
|
305
317
|
maxBuffer: 1024 * 1024,
|
|
306
318
|
});
|
package/package.json
CHANGED