@pakoor/n8n-nodes-instagram 0.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.
Files changed (51) hide show
  1. package/README.md +271 -0
  2. package/dist/__tests__/helpers/index.d.ts +2 -0
  3. package/dist/__tests__/helpers/index.d.ts.map +1 -0
  4. package/dist/__tests__/helpers/index.js +18 -0
  5. package/dist/__tests__/helpers/index.js.map +1 -0
  6. package/dist/__tests__/helpers/testUtils.d.ts +104 -0
  7. package/dist/__tests__/helpers/testUtils.d.ts.map +1 -0
  8. package/dist/__tests__/helpers/testUtils.js +175 -0
  9. package/dist/__tests__/helpers/testUtils.js.map +1 -0
  10. package/dist/credentials/InstagramAccessTokenApi.credentials.d.ts +19 -0
  11. package/dist/credentials/InstagramAccessTokenApi.credentials.d.ts.map +1 -0
  12. package/dist/credentials/InstagramAccessTokenApi.credentials.js +130 -0
  13. package/dist/credentials/InstagramAccessTokenApi.credentials.js.map +1 -0
  14. package/dist/credentials/InstagramOAuth2Api.credentials.d.ts +20 -0
  15. package/dist/credentials/InstagramOAuth2Api.credentials.d.ts.map +1 -0
  16. package/dist/credentials/InstagramOAuth2Api.credentials.js +177 -0
  17. package/dist/credentials/InstagramOAuth2Api.credentials.js.map +1 -0
  18. package/dist/index.d.ts +5 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +23 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/nodes/Instagram/Instagram.node.d.ts +10 -0
  23. package/dist/nodes/Instagram/Instagram.node.d.ts.map +1 -0
  24. package/dist/nodes/Instagram/Instagram.node.js +1152 -0
  25. package/dist/nodes/Instagram/Instagram.node.js.map +1 -0
  26. package/dist/nodes/Instagram/InstagramTrigger.node.d.ts +61 -0
  27. package/dist/nodes/Instagram/InstagramTrigger.node.d.ts.map +1 -0
  28. package/dist/nodes/Instagram/InstagramTrigger.node.js +315 -0
  29. package/dist/nodes/Instagram/InstagramTrigger.node.js.map +1 -0
  30. package/dist/nodes/Instagram/instagram.svg +15 -0
  31. package/dist/services/InstagramApiClient.d.ts +261 -0
  32. package/dist/services/InstagramApiClient.d.ts.map +1 -0
  33. package/dist/services/InstagramApiClient.js +548 -0
  34. package/dist/services/InstagramApiClient.js.map +1 -0
  35. package/dist/services/TokenManager.d.ts +73 -0
  36. package/dist/services/TokenManager.d.ts.map +1 -0
  37. package/dist/services/TokenManager.js +150 -0
  38. package/dist/services/TokenManager.js.map +1 -0
  39. package/dist/services/ValidationUtils.d.ts +44 -0
  40. package/dist/services/ValidationUtils.d.ts.map +1 -0
  41. package/dist/services/ValidationUtils.js +203 -0
  42. package/dist/services/ValidationUtils.js.map +1 -0
  43. package/dist/services/WebhookHandler.d.ts +206 -0
  44. package/dist/services/WebhookHandler.d.ts.map +1 -0
  45. package/dist/services/WebhookHandler.js +261 -0
  46. package/dist/services/WebhookHandler.js.map +1 -0
  47. package/dist/services/index.d.ts +5 -0
  48. package/dist/services/index.d.ts.map +1 -0
  49. package/dist/services/index.js +21 -0
  50. package/dist/services/index.js.map +1 -0
  51. package/package.json +69 -0
package/README.md ADDED
@@ -0,0 +1,271 @@
1
+ # n8n-nodes-instagram
2
+
3
+ n8n community node for Instagram Messaging API integration. This package provides OAuth2/Access Token authentication, messaging capabilities, content publishing, comment management, and webhook-based event handling through the Instagram Graph API.
4
+
5
+ ## Features
6
+
7
+ - **OAuth2 & Access Token Authentication** - Secure connection with automatic token refresh
8
+ - **Messaging** - Send text, images, audio, video, buttons, carousels, and quick replies
9
+ - **User Management** - Retrieve user profiles and account information
10
+ - **Comment Management** - Get, reply, delete, and moderate comments
11
+ - **Content Publishing** - Create posts, carousels, stories, and reels
12
+ - **Media Management** - List and retrieve media details
13
+ - **Webhook Triggers** - Receive real-time messaging and content events
14
+
15
+ ## Installation
16
+
17
+ ### Community Nodes (Recommended)
18
+
19
+ 1. Go to **Settings > Community Nodes**
20
+ 2. Select **Install**
21
+ 3. Enter `n8n-nodes-instagram` and confirm
22
+
23
+ ### Manual Installation
24
+
25
+ ```bash
26
+ npm install n8n-nodes-instagram
27
+ ```
28
+
29
+ Or in your n8n installation directory:
30
+
31
+ ```bash
32
+ cd ~/.n8n/custom
33
+ npm install n8n-nodes-instagram
34
+ ```
35
+
36
+ ## Prerequisites
37
+
38
+ - Instagram Business Account or Creator Account
39
+ - Facebook Page connected to your Instagram account
40
+ - Meta Developer App with Instagram Graph API enabled
41
+
42
+ ### Required Permissions
43
+
44
+ - `instagram_basic` - Basic account information
45
+ - `instagram_manage_messages` - Send and receive messages
46
+ - `instagram_manage_comments` - Manage comments
47
+ - `instagram_content_publish` - Publish content
48
+ - `pages_show_list` - Access connected Facebook pages
49
+ - `pages_read_engagement` - Read page engagement data
50
+
51
+ ## Quick Start
52
+
53
+ ### 1. Set Up Credentials
54
+
55
+ #### OAuth2 (Recommended)
56
+ 1. Create a Meta Developer App at [developers.facebook.com](https://developers.facebook.com)
57
+ 2. Add Instagram Graph API product
58
+ 3. In n8n, create new **Instagram OAuth2 API** credentials
59
+ 4. Enter your App ID and App Secret
60
+ 5. Click **Connect** to authorize
61
+
62
+ #### Access Token
63
+ 1. Generate a long-lived access token from Meta Developer Console
64
+ 2. In n8n, create new **Instagram Access Token API** credentials
65
+ 3. Paste your access token
66
+ 4. Account ID will be auto-discovered
67
+
68
+ ### 2. Create Your First Workflow
69
+
70
+ 1. Add an **Instagram** node to your workflow
71
+ 2. Select your credentials
72
+ 3. Choose a resource and operation
73
+ 4. Configure the parameters
74
+ 5. Execute the workflow
75
+
76
+ ## Node Operations
77
+
78
+ ### Instagram Node
79
+
80
+ #### Message Operations
81
+
82
+ | Operation | Description |
83
+ |-----------|-------------|
84
+ | Send Text | Send a text message to a user |
85
+ | Send Image | Send an image message via URL |
86
+ | Send Audio | Send an audio message via URL |
87
+ | Send Video | Send a video message via URL |
88
+ | Send Button Template | Send interactive buttons |
89
+ | Send Generic Template | Send a carousel of cards |
90
+ | Send Quick Replies | Send quick reply options |
91
+
92
+ #### User Operations
93
+
94
+ | Operation | Description |
95
+ |-----------|-------------|
96
+ | Get Profile | Get a user's profile by IGSID |
97
+ | Get My Profile | Get your Instagram Business Account info |
98
+
99
+ #### Comment Operations
100
+
101
+ | Operation | Description |
102
+ |-----------|-------------|
103
+ | Get Comments | Get comments on a media post |
104
+ | Get Replies | Get replies to a comment |
105
+ | Reply | Post a public reply to a comment |
106
+ | Send Private Reply | Send a DM to a commenter (within 7 days) |
107
+ | Delete | Delete a comment |
108
+ | Toggle Visibility | Hide or unhide a comment |
109
+
110
+ #### Post Operations
111
+
112
+ | Operation | Description |
113
+ |-----------|-------------|
114
+ | Create Single | Create a single image/video post |
115
+ | Create Carousel | Create a carousel post (2-10 items) |
116
+ | Publish | Publish a media container |
117
+
118
+ #### Story Operations
119
+
120
+ | Operation | Description |
121
+ |-----------|-------------|
122
+ | Create | Create a story (image or video) |
123
+
124
+ #### Reel Operations
125
+
126
+ | Operation | Description |
127
+ |-----------|-------------|
128
+ | Create | Create a reel (video up to 60 seconds) |
129
+
130
+ #### Media Operations
131
+
132
+ | Operation | Description |
133
+ |-----------|-------------|
134
+ | List | List your media with pagination |
135
+ | Get | Get details of a specific media |
136
+ | Get Children | Get items in a carousel post |
137
+
138
+ ### Instagram Trigger Node
139
+
140
+ Receives webhook events from Instagram with dual outputs:
141
+
142
+ | Output | Events |
143
+ |--------|--------|
144
+ | Messaging Events | Messages, Postbacks, Opt-ins |
145
+ | Content Events | Comments, Mentions |
146
+
147
+ ## Usage Examples
148
+
149
+ ### Send a Text Message
150
+
151
+ ```json
152
+ {
153
+ "resource": "message",
154
+ "operation": "sendText",
155
+ "recipientId": "{{$json.sender_id}}",
156
+ "text": "Hello! Thanks for reaching out."
157
+ }
158
+ ```
159
+
160
+ ### Send Button Template
161
+
162
+ ```json
163
+ {
164
+ "resource": "message",
165
+ "operation": "sendButtonTemplate",
166
+ "recipientId": "{{$json.sender_id}}",
167
+ "text": "How can I help you?",
168
+ "buttons": [
169
+ { "type": "postback", "title": "View Products", "payload": "PRODUCTS" },
170
+ { "type": "web_url", "title": "Visit Website", "url": "https://example.com" }
171
+ ]
172
+ }
173
+ ```
174
+
175
+ ### Create and Publish a Post
176
+
177
+ ```json
178
+ // Step 1: Create container
179
+ {
180
+ "resource": "post",
181
+ "operation": "createSingle",
182
+ "mediaType": "IMAGE",
183
+ "mediaUrl": "https://example.com/image.jpg",
184
+ "caption": "Check out our new product! #newproduct"
185
+ }
186
+
187
+ // Step 2: Publish (use container ID from step 1)
188
+ {
189
+ "resource": "post",
190
+ "operation": "publish",
191
+ "containerId": "{{$json.id}}"
192
+ }
193
+ ```
194
+
195
+ ### Reply to Comments Automatically
196
+
197
+ Use the Instagram Trigger to receive comment events, then reply:
198
+
199
+ ```json
200
+ {
201
+ "resource": "comment",
202
+ "operation": "reply",
203
+ "commentId": "{{$json.id}}",
204
+ "message": "Thanks for your comment! 🙏"
205
+ }
206
+ ```
207
+
208
+ ## Validation Limits
209
+
210
+ | Field | Limit |
211
+ |-------|-------|
212
+ | Text message | 1000 characters |
213
+ | Button count | 3 maximum |
214
+ | Button title | 20 characters |
215
+ | Quick replies | 13 maximum |
216
+ | Carousel items | 2-10 items |
217
+ | User tags | 20 maximum |
218
+ | Tag position (x, y) | 0-1 range |
219
+ | Reel duration | 60 seconds |
220
+
221
+ ## Webhook Setup
222
+
223
+ To use the Instagram Trigger node:
224
+
225
+ 1. Deploy your n8n instance with a public URL
226
+ 2. Add the Instagram Trigger node to a workflow
227
+ 3. Activate the workflow
228
+ 4. Configure the webhook URL in your Meta App:
229
+ - Go to your Meta App > Webhooks
230
+ - Subscribe to `instagram` webhooks
231
+ - Enter your n8n webhook URL
232
+ - Select events: `messages`, `messaging_postbacks`, `comments`, `mentions`
233
+
234
+ ## Error Handling
235
+
236
+ The node provides detailed error information:
237
+
238
+ | Error Code | Description | Suggestion |
239
+ |------------|-------------|------------|
240
+ | 4 | Rate limit exceeded | Wait and retry |
241
+ | 190 | Invalid access token | Reconnect credentials |
242
+ | 100 | Invalid parameter | Check input values |
243
+ | 10 | Permission denied | Check app permissions |
244
+
245
+ Enable **Continue On Fail** in node settings for graceful error handling in workflows.
246
+
247
+ ## Development
248
+
249
+ ```bash
250
+ # Install dependencies
251
+ npm install
252
+
253
+ # Build
254
+ npm run build
255
+
256
+ # Run tests
257
+ npm test
258
+
259
+ # Lint
260
+ npm run lint
261
+ ```
262
+
263
+ ## License
264
+
265
+ MIT
266
+
267
+ ## Links
268
+
269
+ - [Instagram Graph API Documentation](https://developers.facebook.com/docs/instagram-api)
270
+ - [n8n Community Nodes](https://docs.n8n.io/integrations/community-nodes/)
271
+ - [Meta Developer Portal](https://developers.facebook.com)
@@ -0,0 +1,2 @@
1
+ export * from './testUtils';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./testUtils"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Test Utilities and Helpers
3
+ * Common utilities for unit and property-based testing
4
+ */
5
+ import * as fc from 'fast-check';
6
+ /**
7
+ * Fast-check configuration for property-based tests
8
+ * Minimum 100 iterations per property as per design requirements
9
+ */
10
+ export declare const fcConfig: fc.Parameters<unknown>;
11
+ /**
12
+ * Generate a random string of specified length
13
+ */
14
+ export declare const arbString: (maxLength: number) => fc.Arbitrary<string>;
15
+ /**
16
+ * Generate a random non-empty string
17
+ */
18
+ export declare const arbNonEmptyString: (maxLength: number) => fc.Arbitrary<string>;
19
+ /**
20
+ * Generate a valid HTTPS URL
21
+ */
22
+ export declare const arbHttpsUrl: () => fc.Arbitrary<string>;
23
+ /**
24
+ * Generate an invalid (non-HTTPS) URL
25
+ */
26
+ export declare const arbNonHttpsUrl: () => fc.Arbitrary<string>;
27
+ /**
28
+ * Generate a valid Instagram-scoped User ID (IGSID)
29
+ */
30
+ export declare const arbIgsid: () => fc.Arbitrary<string>;
31
+ /**
32
+ * Generate a valid button title (max 20 chars)
33
+ */
34
+ export declare const arbButtonTitle: () => fc.Arbitrary<string>;
35
+ /**
36
+ * Generate a valid button
37
+ */
38
+ export declare const arbButton: () => fc.Arbitrary<{
39
+ type: "web_url" | "postback";
40
+ title: string;
41
+ url?: string;
42
+ payload?: string;
43
+ }>;
44
+ /**
45
+ * Generate a valid quick reply
46
+ */
47
+ export declare const arbQuickReply: () => fc.Arbitrary<{
48
+ content_type: "text";
49
+ title: string;
50
+ payload: string;
51
+ image_url?: string;
52
+ }>;
53
+ /**
54
+ * Generate a valid user tag with position
55
+ */
56
+ export declare const arbUserTag: () => fc.Arbitrary<{
57
+ username: string;
58
+ x: number;
59
+ y: number;
60
+ }>;
61
+ /**
62
+ * Generate a timestamp within a specific range
63
+ */
64
+ export declare const arbTimestamp: (daysAgo?: number) => fc.Arbitrary<number>;
65
+ /**
66
+ * Generate a future timestamp
67
+ */
68
+ export declare const arbFutureTimestamp: (daysAhead?: number) => fc.Arbitrary<number>;
69
+ /**
70
+ * Generate a webhook signature
71
+ */
72
+ export declare const arbWebhookSignature: () => fc.Arbitrary<string>;
73
+ /**
74
+ * Generate a valid webhook verify token
75
+ */
76
+ export declare const arbVerifyToken: () => fc.Arbitrary<string>;
77
+ /**
78
+ * Generate a webhook challenge string
79
+ */
80
+ export declare const arbChallenge: () => fc.Arbitrary<string>;
81
+ /**
82
+ * Helper to create a mock n8n execution context
83
+ */
84
+ export declare function createMockExecutionContext(): {
85
+ getInputData: jest.Mock<any, any, any>;
86
+ getNodeParameter: jest.Mock<any, any, any>;
87
+ getCredentials: jest.Mock<any, any, any>;
88
+ continueOnFail: jest.Mock<any, any, any>;
89
+ helpers: {
90
+ request: jest.Mock<any, any, any>;
91
+ requestWithAuthentication: jest.Mock<any, any, any>;
92
+ };
93
+ };
94
+ /**
95
+ * Helper to create a mock webhook context
96
+ */
97
+ export declare function createMockWebhookContext(): {
98
+ getRequestObject: jest.Mock<any, any, any>;
99
+ getQueryData: jest.Mock<any, any, any>;
100
+ getBodyData: jest.Mock<any, any, any>;
101
+ getNodeParameter: jest.Mock<any, any, any>;
102
+ getHeaderData: jest.Mock<any, any, any>;
103
+ };
104
+ //# sourceMappingURL=testUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAI3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,KAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CACvC,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM,KAAG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AM,mBAAmB,QAAO,EAAE,CAAC,SAAS,CAAC,MAAM,CACqB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,cAAc,QAAO,EAAE,CAAC,SAAS,CAAC,MAAM,CACT,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,EAAE,CAAC,SAAS,CAAC,MAAM,CACL,CAAC;AAE/C;;GAEG;AACH,wBAAgB,0BAA0B;;;;;;;;;EAWzC;AAED;;GAEG;AACH,wBAAgB,wBAAwB;;;;;;EAQvC"}
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ /**
3
+ * Test Utilities and Helpers
4
+ * Common utilities for unit and property-based testing
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.arbChallenge = exports.arbVerifyToken = exports.arbWebhookSignature = exports.arbFutureTimestamp = exports.arbTimestamp = exports.arbUserTag = exports.arbQuickReply = exports.arbButton = exports.arbButtonTitle = exports.arbIgsid = exports.arbNonHttpsUrl = exports.arbHttpsUrl = exports.arbNonEmptyString = exports.arbString = exports.fcConfig = void 0;
41
+ exports.createMockExecutionContext = createMockExecutionContext;
42
+ exports.createMockWebhookContext = createMockWebhookContext;
43
+ const fc = __importStar(require("fast-check"));
44
+ /**
45
+ * Fast-check configuration for property-based tests
46
+ * Minimum 100 iterations per property as per design requirements
47
+ */
48
+ exports.fcConfig = {
49
+ numRuns: 100,
50
+ verbose: false,
51
+ seed: Date.now(),
52
+ };
53
+ /**
54
+ * Generate a random string of specified length
55
+ */
56
+ const arbString = (maxLength) => fc.string({ maxLength });
57
+ exports.arbString = arbString;
58
+ /**
59
+ * Generate a random non-empty string
60
+ */
61
+ const arbNonEmptyString = (maxLength) => fc.string({ minLength: 1, maxLength });
62
+ exports.arbNonEmptyString = arbNonEmptyString;
63
+ /**
64
+ * Generate a valid HTTPS URL
65
+ */
66
+ const arbHttpsUrl = () => fc.webUrl({ validSchemes: ['https'] });
67
+ exports.arbHttpsUrl = arbHttpsUrl;
68
+ /**
69
+ * Generate an invalid (non-HTTPS) URL
70
+ */
71
+ const arbNonHttpsUrl = () => fc.oneof(fc.webUrl({ validSchemes: ['http'] }), fc.constant('ftp://example.com/file'), fc.constant('file:///path/to/file'));
72
+ exports.arbNonHttpsUrl = arbNonHttpsUrl;
73
+ /**
74
+ * Generate a valid Instagram-scoped User ID (IGSID)
75
+ */
76
+ const arbIgsid = () => fc.stringOf(fc.constantFrom('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), {
77
+ minLength: 10,
78
+ maxLength: 20,
79
+ });
80
+ exports.arbIgsid = arbIgsid;
81
+ /**
82
+ * Generate a valid button title (max 20 chars)
83
+ */
84
+ const arbButtonTitle = () => fc.string({ minLength: 1, maxLength: 20 });
85
+ exports.arbButtonTitle = arbButtonTitle;
86
+ /**
87
+ * Generate a valid button
88
+ */
89
+ const arbButton = () => fc.record({
90
+ type: fc.constantFrom('web_url', 'postback'),
91
+ title: (0, exports.arbButtonTitle)(),
92
+ url: fc.option((0, exports.arbHttpsUrl)(), { nil: undefined }),
93
+ payload: fc.option(fc.string({ maxLength: 100 }), { nil: undefined }),
94
+ });
95
+ exports.arbButton = arbButton;
96
+ /**
97
+ * Generate a valid quick reply
98
+ */
99
+ const arbQuickReply = () => fc.record({
100
+ content_type: fc.constant('text'),
101
+ title: fc.string({ minLength: 1, maxLength: 20 }),
102
+ payload: fc.string({ minLength: 1, maxLength: 100 }),
103
+ image_url: fc.option((0, exports.arbHttpsUrl)(), { nil: undefined }),
104
+ });
105
+ exports.arbQuickReply = arbQuickReply;
106
+ /**
107
+ * Generate a valid user tag with position
108
+ */
109
+ const arbUserTag = () => fc.record({
110
+ username: fc.string({ minLength: 1, maxLength: 30 }),
111
+ x: fc.float({ min: 0, max: 1, noNaN: true }),
112
+ y: fc.float({ min: 0, max: 1, noNaN: true }),
113
+ });
114
+ exports.arbUserTag = arbUserTag;
115
+ /**
116
+ * Generate a timestamp within a specific range
117
+ */
118
+ const arbTimestamp = (daysAgo = 30) => {
119
+ const now = Date.now();
120
+ const past = now - daysAgo * 24 * 60 * 60 * 1000;
121
+ return fc.integer({ min: past, max: now });
122
+ };
123
+ exports.arbTimestamp = arbTimestamp;
124
+ /**
125
+ * Generate a future timestamp
126
+ */
127
+ const arbFutureTimestamp = (daysAhead = 60) => {
128
+ const now = Date.now();
129
+ const future = now + daysAhead * 24 * 60 * 60 * 1000;
130
+ return fc.integer({ min: now, max: future });
131
+ };
132
+ exports.arbFutureTimestamp = arbFutureTimestamp;
133
+ /**
134
+ * Generate a webhook signature
135
+ */
136
+ const arbWebhookSignature = () => fc.hexaString({ minLength: 64, maxLength: 64 }).map((hex) => `sha256=${hex}`);
137
+ exports.arbWebhookSignature = arbWebhookSignature;
138
+ /**
139
+ * Generate a valid webhook verify token
140
+ */
141
+ const arbVerifyToken = () => fc.string({ minLength: 8, maxLength: 64 });
142
+ exports.arbVerifyToken = arbVerifyToken;
143
+ /**
144
+ * Generate a webhook challenge string
145
+ */
146
+ const arbChallenge = () => fc.string({ minLength: 10, maxLength: 100 });
147
+ exports.arbChallenge = arbChallenge;
148
+ /**
149
+ * Helper to create a mock n8n execution context
150
+ */
151
+ function createMockExecutionContext() {
152
+ return {
153
+ getInputData: jest.fn().mockReturnValue([{ json: {} }]),
154
+ getNodeParameter: jest.fn(),
155
+ getCredentials: jest.fn(),
156
+ continueOnFail: jest.fn().mockReturnValue(false),
157
+ helpers: {
158
+ request: jest.fn(),
159
+ requestWithAuthentication: jest.fn(),
160
+ },
161
+ };
162
+ }
163
+ /**
164
+ * Helper to create a mock webhook context
165
+ */
166
+ function createMockWebhookContext() {
167
+ return {
168
+ getRequestObject: jest.fn(),
169
+ getQueryData: jest.fn(),
170
+ getBodyData: jest.fn(),
171
+ getNodeParameter: jest.fn(),
172
+ getHeaderData: jest.fn(),
173
+ };
174
+ }
175
+ //# sourceMappingURL=testUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/testUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IH,gEAWC;AAKD,4DAQC;AApKD,+CAAiC;AAEjC;;;GAGG;AACU,QAAA,QAAQ,GAA2B;IAC9C,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;CACjB,CAAC;AAEF;;GAEG;AACI,MAAM,SAAS,GAAG,CAAC,SAAiB,EAAwB,EAAE,CACnE,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;AADd,QAAA,SAA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C;AADhC,QAAA,cAAc,kBACkB;AAE7C;;GAEG;AACI,MAAM,YAAY,GAAG,GAAyB,EAAE,CACrD,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;AADlC,QAAA,YAAY,gBACsB;AAE/C;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO;QACL,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACvD,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;QAChD,OAAO,EAAE;YACP,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;YAClB,yBAAyB,EAAE,IAAI,CAAC,EAAE,EAAE;SACrC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB;IACtC,OAAO;QACL,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE;QACvB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;KACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { IAuthenticateGeneric, ICredentialDataDecryptedObject, ICredentialTestRequest, ICredentialType, IHttpRequestHelper, INodeProperties } from 'n8n-workflow';
2
+ export declare class InstagramAccessTokenApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ test: ICredentialTestRequest;
9
+ /**
10
+ * Pre-authentication hook to validate token and auto-discover Instagram Business Account ID
11
+ *
12
+ * Requirements:
13
+ * - 2.1: Validate token against Instagram Graph API
14
+ * - 2.2: Auto-discover Instagram Business Account ID
15
+ * - 2.3: Return descriptive error for invalid tokens
16
+ */
17
+ preAuthentication(this: IHttpRequestHelper, credentials: ICredentialDataDecryptedObject): Promise<ICredentialDataDecryptedObject>;
18
+ }
19
+ //# sourceMappingURL=InstagramAccessTokenApi.credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstagramAccessTokenApi.credentials.d.ts","sourceRoot":"","sources":["../../src/credentials/InstagramAccessTokenApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,eAAe,EAChB,MAAM,cAAc,CAAC;AAmCtB,qBAAa,uBAAwB,YAAW,eAAe;IAC7D,IAAI,SAA6B;IACjC,WAAW,SAAgC;IAC3C,gBAAgB,SAAyD;IAEzE,UAAU,EAAE,eAAe,EAAE,CAmB3B;IAEF,YAAY,EAAE,oBAAoB,CAOhC;IAEF,IAAI,EAAE,sBAAsB,CAQ1B;IAEF;;;;;;;OAOG;IACG,iBAAiB,CACrB,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,8BAA8B,GAC1C,OAAO,CAAC,8BAA8B,CAAC;CAmF3C"}