forked from aws-amplify/amplify-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into next-storage-list
- Loading branch information
Showing
10 changed files
with
2,265 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,141 +1,142 @@ | ||
{ | ||
"name": "@aws-amplify/auth", | ||
"version": "6.0.0", | ||
"description": "Auth category of aws-amplify", | ||
"main": "./lib/index.js", | ||
"module": "./lib-esm/index.js", | ||
"typings": "./lib-esm/index.d.ts", | ||
"react-native": "./lib-esm/index.js", | ||
"sideEffects": [ | ||
"./lib/Auth.js", | ||
"./lib-esm/Auth.js" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"test": "yarn lint --fix && jest -w 1 --coverage", | ||
"test:size": "size-limit", | ||
"build-with-test": "npm test && npm run build", | ||
"build:cjs": "node ./build es5 && webpack && webpack --config ./webpack.config.dev.js", | ||
"build:esm": "node ./build es6", | ||
"build:cjs:watch": "node ./build es5 --watch", | ||
"build:esm:watch": "node ./build es6 --watch", | ||
"build": "npm run clean && npm run build:esm && npm run build:cjs", | ||
"clean": "npm run clean:size && rimraf lib-esm lib dist", | ||
"clean:size": "rimraf dual-publish-tmp tmp*", | ||
"format": "echo \"Not implemented\"", | ||
"lint": "tslint '{__tests__,src}/**/*.ts' && npm run ts-coverage", | ||
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 77.44" | ||
}, | ||
"typesVersions": { | ||
">=3.8": { | ||
"*": [ | ||
"./lib-esm/index.d.ts" | ||
], | ||
"cognito": [ | ||
"./lib-esm/providers/cognito/index.d.ts" | ||
] | ||
} | ||
}, | ||
"exports": { | ||
".": { | ||
"types": "./lib-esm/index.d.ts", | ||
"import": "./lib-esm/index.js", | ||
"require": "./lib/index.js" | ||
}, | ||
"./cognito": { | ||
"types": "./lib-esm/providers/cognito/index.d.ts", | ||
"import": "./lib-esm/providers/cognito/index.js", | ||
"require": "./lib/providers/cognito/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/aws-amplify/amplify-js.git" | ||
}, | ||
"author": "Amazon Web Services", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/aws/aws-amplify/issues" | ||
}, | ||
"homepage": "https://aws-amplify.github.io/", | ||
"files": [ | ||
"lib", | ||
"lib-esm", | ||
"src", | ||
"**/package.json" | ||
], | ||
"dependencies": { | ||
"amazon-cognito-identity-js": "6.4.0", | ||
"tslib": "^2.5.0", | ||
"url": "0.11.0" | ||
}, | ||
"peerDependencies": { | ||
"@aws-amplify/core": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@aws-amplify/core": "6.0.0", | ||
"@aws-sdk/client-cognito-identity": "3.54.0", | ||
"@aws-sdk/client-cognito-identity-provider": "3.54.0", | ||
"@jest/test-sequencer": "^24.9.0" | ||
}, | ||
"size-limit": [ | ||
{ | ||
"name": "Auth (top-level class)", | ||
"path": "./lib-esm/index.js", | ||
"import": "{ Amplify, Auth }", | ||
"limit": "55.1 kB" | ||
} | ||
], | ||
"jest": { | ||
"globals": { | ||
"ts-jest": { | ||
"diagnostics": true, | ||
"tsConfig": { | ||
"lib": [ | ||
"es5", | ||
"es2015", | ||
"dom", | ||
"esnext.asynciterable", | ||
"es2017.object" | ||
], | ||
"allowJs": true | ||
} | ||
} | ||
}, | ||
"transform": { | ||
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest" | ||
}, | ||
"preset": "ts-jest", | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$", | ||
"testPathIgnorePatterns": [ | ||
"__tests__/providers/.*/testUtils" | ||
], | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"json", | ||
"jsx" | ||
], | ||
"testEnvironment": "jsdom", | ||
"testURL": "http://localhost/", | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 0, | ||
"functions": 0, | ||
"lines": 0, | ||
"statements": 0 | ||
} | ||
}, | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"dist", | ||
"lib", | ||
"lib-esm" | ||
], | ||
"testSequencer": "./testSequencer.js" | ||
} | ||
"name": "@aws-amplify/auth", | ||
"version": "6.0.0", | ||
"description": "Auth category of aws-amplify", | ||
"main": "./lib/index.js", | ||
"module": "./lib-esm/index.js", | ||
"typings": "./lib-esm/index.d.ts", | ||
"react-native": "./lib-esm/index.js", | ||
"sideEffects": [ | ||
"./lib/Auth.js", | ||
"./lib-esm/Auth.js" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"test": "yarn lint --fix && jest -w 1 --coverage", | ||
"test:size": "size-limit", | ||
"build-with-test": "npm test && npm run build", | ||
"build:cjs": "rimraf lib && tsc -m commonjs --outDir lib && webpack && webpack --config ./webpack.config.dev.js", | ||
"build:esm": "rimraf lib-esm && tsc -m esnext --outDir lib-esm", | ||
"build:cjs:watch": "tsc -m commonjs --outDir lib --watch", | ||
"build:esm:watch": "tsc -m esnext --outDir lib-esm --watch", | ||
"build": "npm run clean && npm run build:esm && npm run build:cjs", | ||
"clean": "npm run clean:size && rimraf lib-esm lib dist", | ||
"clean:size": "rimraf dual-publish-tmp tmp*", | ||
"format": "echo \"Not implemented\"", | ||
"lint": "tslint '{__tests__,src}/**/*.ts' && npm run ts-coverage", | ||
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 77.44" | ||
}, | ||
"typesVersions": { | ||
">=3.8": { | ||
"*": [ | ||
"./lib-esm/index.d.ts" | ||
], | ||
"cognito": [ | ||
"./lib-esm/providers/cognito/index.d.ts" | ||
] | ||
} | ||
}, | ||
"exports": { | ||
".": { | ||
"types": "./lib-esm/index.d.ts", | ||
"import": "./lib-esm/index.js", | ||
"require": "./lib/index.js" | ||
}, | ||
"./cognito": { | ||
"types": "./lib-esm/providers/cognito/index.d.ts", | ||
"import": "./lib-esm/providers/cognito/index.js", | ||
"require": "./lib/providers/cognito/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/aws-amplify/amplify-js.git" | ||
}, | ||
"author": "Amazon Web Services", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/aws/aws-amplify/issues" | ||
}, | ||
"homepage": "https://aws-amplify.github.io/", | ||
"files": [ | ||
"lib", | ||
"lib-esm", | ||
"src", | ||
"**/package.json" | ||
], | ||
"dependencies": { | ||
"amazon-cognito-identity-js": "6.4.0", | ||
"tslib": "^2.5.0", | ||
"url": "0.11.0", | ||
"typescript": "5.0.2" | ||
}, | ||
"peerDependencies": { | ||
"@aws-amplify/core": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@aws-amplify/core": "6.0.0", | ||
"@aws-sdk/client-cognito-identity": "3.54.0", | ||
"@aws-sdk/client-cognito-identity-provider": "3.54.0", | ||
"@jest/test-sequencer": "^24.9.0" | ||
}, | ||
"size-limit": [ | ||
{ | ||
"name": "Auth (top-level class)", | ||
"path": "./lib-esm/index.js", | ||
"import": "{ Amplify, Auth }", | ||
"limit": "55.1 kB" | ||
} | ||
], | ||
"jest": { | ||
"globals": { | ||
"ts-jest": { | ||
"diagnostics": true, | ||
"tsConfig": { | ||
"lib": [ | ||
"es5", | ||
"es2015", | ||
"dom", | ||
"esnext.asynciterable", | ||
"es2017.object" | ||
], | ||
"allowJs": true | ||
} | ||
} | ||
}, | ||
"transform": { | ||
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest" | ||
}, | ||
"preset": "ts-jest", | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$", | ||
"testPathIgnorePatterns": [ | ||
"__tests__/providers/.*/testUtils" | ||
], | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"json", | ||
"jsx" | ||
], | ||
"testEnvironment": "jsdom", | ||
"testURL": "http://localhost/", | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 0, | ||
"functions": 0, | ||
"lines": 0, | ||
"statements": 0 | ||
} | ||
}, | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"dist", | ||
"lib", | ||
"lib-esm" | ||
], | ||
"testSequencer": "./testSequencer.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/auth/src/providers/cognito/utils/clients/CognitoIdentityProvider/base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { | ||
Endpoint, | ||
EndpointResolverOptions, | ||
Headers, | ||
HttpRequest, | ||
HttpResponse, | ||
Middleware, | ||
getDnsSuffix, | ||
unauthenticatedHandler, | ||
parseJsonError, | ||
getRetryDecider, | ||
jitteredBackoff, | ||
} from '@aws-amplify/core/internals/aws-client-utils'; | ||
import { getAmplifyUserAgent } from '@aws-amplify/core'; | ||
import { composeTransferHandler } from '@aws-amplify/core/internals/aws-client-utils/composers'; | ||
|
||
/** | ||
* The service name used to sign requests if the API requires authentication. | ||
*/ | ||
const SERVICE_NAME = 'cognito-idp'; | ||
|
||
/** | ||
* The endpoint resolver function that returns the endpoint URL for a given region. | ||
*/ | ||
const endpointResolver = ({ region }: EndpointResolverOptions) => ({ | ||
url: new URL(`https://${SERVICE_NAME}.${region}.${getDnsSuffix(region)}`), | ||
}); | ||
|
||
/** | ||
* A Cognito Identity-specific middleware that disables caching for all requests. | ||
*/ | ||
const disableCacheMiddleware: Middleware<HttpRequest, HttpResponse, {}> = | ||
() => (next, context) => | ||
async function disableCacheMiddleware(request) { | ||
request.headers['cache-control'] = 'no-store'; | ||
return next(request); | ||
}; | ||
|
||
/** | ||
* A Cognito Identity-specific transfer handler that does NOT sign requests, and | ||
* disables caching. | ||
* | ||
* @internal | ||
*/ | ||
export const cognitoUserPoolTransferHandler = composeTransferHandler< | ||
[Parameters<typeof disableCacheMiddleware>[0]], | ||
HttpRequest, | ||
HttpResponse, | ||
typeof unauthenticatedHandler | ||
>(unauthenticatedHandler, [disableCacheMiddleware]); | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const defaultConfig = { | ||
service: SERVICE_NAME, | ||
endpointResolver, | ||
retryDecider: getRetryDecider(parseJsonError), | ||
computeDelay: jitteredBackoff, | ||
userAgentValue: getAmplifyUserAgent(), | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const getSharedHeaders = (operation: string): Headers => ({ | ||
'content-type': 'application/x-amz-json-1.1', | ||
'x-amz-target': `AWSCognitoIdentityProviderService.${operation}`, | ||
}); | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const buildHttpRpcRequest = ( | ||
{ url }: Endpoint, | ||
headers: Headers, | ||
body: any | ||
): HttpRequest => ({ | ||
headers, | ||
url, | ||
body, | ||
method: 'POST', | ||
}); |
Oops, something went wrong.