n8n-nodes-jmap 0.1.0 → 0.1.1
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.
|
@@ -64,7 +64,7 @@ async function makeJmapRequest(context, method, endpoint, body) {
|
|
|
64
64
|
const url = endpoint.startsWith('http') ? endpoint : `${serverUrl}${endpoint}`;
|
|
65
65
|
if (authType === 'jmapOAuth2Api') {
|
|
66
66
|
// Use n8n's built-in OAuth2 authentication
|
|
67
|
-
const response = await context.helpers.
|
|
67
|
+
const response = await context.helpers.httpRequestWithAuthentication.call(context, 'jmapOAuth2Api', {
|
|
68
68
|
method,
|
|
69
69
|
url,
|
|
70
70
|
headers: {
|
|
@@ -80,29 +80,25 @@ async function makeJmapRequest(context, method, endpoint, body) {
|
|
|
80
80
|
// Use Basic Auth or Bearer Token
|
|
81
81
|
const credentials = await context.getCredentials('jmapApi');
|
|
82
82
|
const authMethod = credentials.authMethod || 'basicAuth';
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
headers: {
|
|
87
|
-
'Content-Type': 'application/json',
|
|
88
|
-
Accept: 'application/json',
|
|
89
|
-
},
|
|
90
|
-
body,
|
|
91
|
-
json: true,
|
|
83
|
+
const headers = {
|
|
84
|
+
'Content-Type': 'application/json',
|
|
85
|
+
Accept: 'application/json',
|
|
92
86
|
};
|
|
93
87
|
if (authMethod === 'basicAuth') {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
pass: credentials.password,
|
|
97
|
-
};
|
|
88
|
+
const authString = Buffer.from(`${credentials.email}:${credentials.password}`).toString('base64');
|
|
89
|
+
headers.Authorization = `Basic ${authString}`;
|
|
98
90
|
}
|
|
99
91
|
else if (authMethod === 'bearerToken') {
|
|
100
|
-
|
|
101
|
-
...options.headers,
|
|
102
|
-
Authorization: `Bearer ${credentials.accessToken}`,
|
|
103
|
-
};
|
|
92
|
+
headers.Authorization = `Bearer ${credentials.accessToken}`;
|
|
104
93
|
}
|
|
105
|
-
const
|
|
94
|
+
const options = {
|
|
95
|
+
method,
|
|
96
|
+
url,
|
|
97
|
+
headers,
|
|
98
|
+
body,
|
|
99
|
+
json: true,
|
|
100
|
+
};
|
|
101
|
+
const response = await context.helpers.httpRequest(options);
|
|
106
102
|
return response;
|
|
107
103
|
}
|
|
108
104
|
}
|
|
@@ -435,32 +431,31 @@ async function downloadBlob(accountId, blobId, name, type) {
|
|
|
435
431
|
.replace('{name}', encodeURIComponent(name))
|
|
436
432
|
.replace('{type}', encodeURIComponent(type));
|
|
437
433
|
if (authType === 'jmapOAuth2Api') {
|
|
438
|
-
const response = await this.helpers.
|
|
434
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'jmapOAuth2Api', {
|
|
439
435
|
method: 'GET',
|
|
440
436
|
url: downloadUrl,
|
|
441
|
-
encoding:
|
|
437
|
+
encoding: 'arraybuffer',
|
|
442
438
|
});
|
|
443
|
-
return response;
|
|
439
|
+
return Buffer.from(response);
|
|
444
440
|
}
|
|
445
441
|
else {
|
|
446
442
|
const credentials = await this.getCredentials('jmapApi');
|
|
447
443
|
const authMethod = credentials.authMethod || 'basicAuth';
|
|
448
|
-
const
|
|
449
|
-
method: 'GET',
|
|
450
|
-
uri: downloadUrl,
|
|
451
|
-
encoding: null,
|
|
452
|
-
};
|
|
444
|
+
const headers = {};
|
|
453
445
|
if (authMethod === 'basicAuth') {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
pass: credentials.password,
|
|
457
|
-
};
|
|
446
|
+
const authString = Buffer.from(`${credentials.email}:${credentials.password}`).toString('base64');
|
|
447
|
+
headers.Authorization = `Basic ${authString}`;
|
|
458
448
|
}
|
|
459
449
|
else if (authMethod === 'bearerToken') {
|
|
460
|
-
|
|
461
|
-
Authorization: `Bearer ${credentials.accessToken}`,
|
|
462
|
-
};
|
|
450
|
+
headers.Authorization = `Bearer ${credentials.accessToken}`;
|
|
463
451
|
}
|
|
464
|
-
|
|
452
|
+
const options = {
|
|
453
|
+
method: 'GET',
|
|
454
|
+
url: downloadUrl,
|
|
455
|
+
headers,
|
|
456
|
+
encoding: 'arraybuffer',
|
|
457
|
+
};
|
|
458
|
+
const response = await this.helpers.httpRequest(options);
|
|
459
|
+
return Buffer.from(response);
|
|
465
460
|
}
|
|
466
461
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-jmap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "n8n community node for JMAP email protocol (RFC 8620/8621) - Works with Apache James, Twake Mail, Fastmail, and other JMAP-compatible servers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|