Files
n8n/packages/nodes-base/nodes/Aws/Cognito/transport/index.ts
T
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

72 lines
1.7 KiB
TypeScript

import type {
ILoadOptionsFunctions,
IPollFunctions,
IHttpRequestOptions,
IExecuteSingleFunctions,
IDataObject,
IHttpRequestMethods,
} from 'n8n-workflow';
import type { AwsIamCredentialsType } from '../../../../credentials/common/aws/types';
export async function awsApiRequest(
this: ILoadOptionsFunctions | IPollFunctions | IExecuteSingleFunctions,
method: IHttpRequestMethods,
action: string,
body: string,
): Promise<any> {
const credentialsType = 'aws';
const credentials = await this.getCredentials<AwsIamCredentialsType>(credentialsType);
const requestOptions: IHttpRequestOptions = {
url: '',
method,
body,
headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': `AWSCognitoIdentityProviderService.${action}`,
},
qs: {
service: 'cognito-idp',
_region: credentials.region,
},
};
return await this.helpers.httpRequestWithAuthentication.call(
this,
credentialsType,
requestOptions,
);
}
export async function awsApiRequestAllItems(
this: ILoadOptionsFunctions | IPollFunctions | IExecuteSingleFunctions,
method: IHttpRequestMethods,
action: string,
body: IDataObject,
propertyName: string,
): Promise<IDataObject[]> {
const returnData: IDataObject[] = [];
let nextToken: string | undefined;
do {
const requestBody: IDataObject = {
...body,
...(nextToken ? { NextToken: nextToken } : {}),
};
const response = (await awsApiRequest.call(
this,
method,
action,
JSON.stringify(requestBody),
)) as IDataObject;
const items = (response[propertyName] ?? []) as IDataObject[];
returnData.push(...items);
nextToken = response.NextToken as string | undefined;
} while (nextToken);
return returnData;
}