n8n-nodes-onedrive-business 1.1.7 → 1.1.9

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.
@@ -31,6 +31,10 @@ export declare function resolveSubscriptionResource(location: DriveLocation): st
31
31
  * - Encodes special characters
32
32
  */
33
33
  export declare function sanitizePath(path: string): string;
34
+ /**
35
+ * Validate Microsoft Graph item ID format
36
+ */
37
+ export declare function isValidItemId(itemId: string): boolean;
34
38
  /**
35
39
  * Build the full item path for OneDrive API
36
40
  *
@@ -68,10 +72,6 @@ export declare function parseRetryAfter(retryAfterHeader?: string): number;
68
72
  * Used for clientState in webhook subscriptions
69
73
  */
70
74
  export declare function generateSecureRandomString(length?: number): string;
71
- /**
72
- * Validate Microsoft Graph item ID format
73
- */
74
- export declare function isValidItemId(itemId: string): boolean;
75
75
  /**
76
76
  * Check if an item is a file (vs folder)
77
77
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseGraphError = exports.cleanupProcessedVersions = exports.buildVersionKey = exports.getMimeType = exports.isFolder = exports.isFile = exports.isValidItemId = exports.generateSecureRandomString = exports.parseRetryAfter = exports.sleep = exports.calculateBackoffDelay = exports.formatBytes = exports.getFileExtension = exports.buildItemPath = exports.sanitizePath = exports.resolveSubscriptionResource = exports.resolveDrivePath = void 0;
3
+ exports.parseGraphError = exports.cleanupProcessedVersions = exports.buildVersionKey = exports.getMimeType = exports.isFolder = exports.isFile = exports.generateSecureRandomString = exports.parseRetryAfter = exports.sleep = exports.calculateBackoffDelay = exports.formatBytes = exports.getFileExtension = exports.buildItemPath = exports.isValidItemId = exports.sanitizePath = exports.resolveSubscriptionResource = exports.resolveDrivePath = void 0;
4
4
  /**
5
5
  * Helper Functions for OneDrive Business Node
6
6
  *
@@ -64,6 +64,23 @@ function sanitizePath(path) {
64
64
  return encodedParts.join('/');
65
65
  }
66
66
  exports.sanitizePath = sanitizePath;
67
+ /**
68
+ * Validate Microsoft Graph item ID format
69
+ */
70
+ function isValidItemId(itemId) {
71
+ if (!itemId || typeof itemId !== 'string') {
72
+ return false;
73
+ }
74
+ // Graph item IDs are base64-encoded strings but can vary.
75
+ // Use a heuristic: if it contains slash or colon, it's definitely a path.
76
+ // If it's a long string without path separators, treat as ID.
77
+ if (!itemId || typeof itemId !== 'string') {
78
+ return false;
79
+ }
80
+ // Reverting to strict Regex from v1.1.5 to ensure stability
81
+ return /^[A-Za-z0-9!_\-=]+$/.test(itemId);
82
+ }
83
+ exports.isValidItemId = isValidItemId;
67
84
  /**
68
85
  * Build the full item path for OneDrive API
69
86
  *
@@ -76,9 +93,13 @@ function buildItemPath(drivePath, itemPath, itemId) {
76
93
  return `${drivePath}/items/${itemId}`;
77
94
  }
78
95
  if (itemPath) {
79
- // Strip standard Graph API prefixes if present
96
+ // Strip out duplicated drive root prefixes to fix "itemNotFound" errors
80
97
  // Matches: /drive/root:, drive/root:, /drives/{id}/root:, drives/{id}/root:
81
98
  let cleanPath = itemPath.replace(/^(\/)?(drive|drives\/[^\/]+)\/root:/i, '');
99
+ // Also remove any leading slash if present after replacement
100
+ if (cleanPath.startsWith('/')) {
101
+ cleanPath = cleanPath.substring(1);
102
+ }
82
103
  const sanitized = sanitizePath(cleanPath);
83
104
  if (sanitized) {
84
105
  return `${drivePath}/root:/${sanitized}`;
@@ -166,18 +187,6 @@ function generateSecureRandomString(length = 32) {
166
187
  return result;
167
188
  }
168
189
  exports.generateSecureRandomString = generateSecureRandomString;
169
- /**
170
- * Validate Microsoft Graph item ID format
171
- */
172
- function isValidItemId(itemId) {
173
- if (!itemId || typeof itemId !== 'string') {
174
- return false;
175
- }
176
- // Graph item IDs are typically base64-encoded strings
177
- // They should not contain spaces or special characters except !, _, -, and =
178
- return /^[A-Za-z0-9!_\-=]+$/.test(itemId);
179
- }
180
- exports.isValidItemId = isValidItemId;
181
190
  /**
182
191
  * Check if an item is a file (vs folder)
183
192
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-onedrive-business",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "n8n custom node for OneDrive Business with robust deduplication and webhook triggers",
5
5
  "keywords": [
6
6
  "n8n",