Skip to content

Commit

Permalink
Merge branch 'next' into next-storage-list
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinkumar6 authored Aug 9, 2023
2 parents 2ac0bc5 + b58034b commit 1c5032d
Show file tree
Hide file tree
Showing 10 changed files with 2,265 additions and 141 deletions.
279 changes: 140 additions & 139 deletions packages/auth/package.json
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"
}
}
1 change: 1 addition & 0 deletions packages/auth/src/Auth.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/errors/utils/assertServiceError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export function assertServiceError(
): asserts error is ServiceError {
if (
!error ||
(error as ServiceError).name === Error.name ||
!((error as ServiceError).name && (error as ServiceError).message)
(error as ServiceError).name === 'Error' ||
error instanceof TypeError
) {
throw new AuthError({
name: AmplifyErrorString.UNKNOWN,
Expand Down
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',
});
Loading

0 comments on commit 1c5032d

Please sign in to comment.