@aws-amplify/auth 6.10.2-unstable.e888e7c.0 → 6.10.2
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.
- package/dist/cjs/client/flows/shared/handlePasswordSRP.js +5 -3
- package/dist/cjs/client/flows/shared/handlePasswordSRP.js.map +1 -1
- package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPassword.js +2 -2
- package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPassword.js.map +1 -1
- package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.js +5 -3
- package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.js.map +1 -1
- package/dist/cjs/client/flows/userAuth/handleUserAuthFlow.js +2 -2
- package/dist/cjs/client/flows/userAuth/handleUserAuthFlow.js.map +1 -1
- package/dist/cjs/client/flows/userAuth/handleWebAuthnSignInResult.js +4 -4
- package/dist/cjs/client/flows/userAuth/handleWebAuthnSignInResult.js.map +1 -1
- package/dist/cjs/client/flows/userAuth/types.js +6 -0
- package/dist/cjs/client/flows/userAuth/types.js.map +1 -0
- package/dist/cjs/providers/cognito/apis/confirmSignIn.js +2 -1
- package/dist/cjs/providers/cognito/apis/confirmSignIn.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js +4 -2
- package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js +2 -1
- package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithSRP.js +2 -1
- package/dist/cjs/providers/cognito/apis/signInWithSRP.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js +2 -1
- package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js +4 -2
- package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/getNewDeviceMetadata.js +64 -0
- package/dist/cjs/providers/cognito/utils/getNewDeviceMetadata.js.map +1 -0
- package/dist/cjs/providers/cognito/utils/handleDeviceSRPAuth.js +88 -0
- package/dist/cjs/providers/cognito/utils/handleDeviceSRPAuth.js.map +1 -0
- package/dist/cjs/providers/cognito/utils/handlePasswordVerifierChallenge.js +79 -0
- package/dist/cjs/providers/cognito/utils/handlePasswordVerifierChallenge.js.map +1 -0
- package/dist/cjs/providers/cognito/utils/retryOnResourceNotFoundException.js +28 -0
- package/dist/cjs/providers/cognito/utils/retryOnResourceNotFoundException.js.map +1 -0
- package/dist/cjs/providers/cognito/utils/setActiveSignInUsername.js +13 -0
- package/dist/cjs/providers/cognito/utils/setActiveSignInUsername.js.map +1 -0
- package/dist/cjs/providers/cognito/utils/signInHelpers.js +23 -227
- package/dist/cjs/providers/cognito/utils/signInHelpers.js.map +1 -1
- package/dist/esm/client/flows/shared/handlePasswordSRP.mjs +3 -1
- package/dist/esm/client/flows/shared/handlePasswordSRP.mjs.map +1 -1
- package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPassword.mjs +1 -1
- package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPassword.mjs.map +1 -1
- package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs +3 -1
- package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs.map +1 -1
- package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs +1 -1
- package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs.map +1 -1
- package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.d.ts +2 -2
- package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.mjs +3 -3
- package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.mjs.map +1 -1
- package/dist/esm/client/flows/userAuth/types.d.ts +6 -0
- package/dist/esm/client/flows/userAuth/types.mjs +2 -0
- package/dist/esm/client/flows/userAuth/types.mjs.map +1 -0
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs +2 -1
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomAuth.mjs +3 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs +2 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithSRP.mjs +2 -1
- package/dist/esm/providers/cognito/apis/signInWithSRP.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithUserAuth.mjs +2 -1
- package/dist/esm/providers/cognito/apis/signInWithUserAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs +3 -1
- package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.d.ts +17 -0
- package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs +71 -0
- package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs.map +1 -0
- package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.d.ts +13 -0
- package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.mjs +97 -0
- package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.mjs.map +1 -0
- package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.d.ts +6 -0
- package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs +88 -0
- package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs.map +1 -0
- package/dist/esm/providers/cognito/utils/retryOnResourceNotFoundException.d.ts +7 -0
- package/dist/esm/providers/cognito/utils/retryOnResourceNotFoundException.mjs +26 -0
- package/dist/esm/providers/cognito/utils/retryOnResourceNotFoundException.mjs.map +1 -0
- package/dist/esm/providers/cognito/utils/setActiveSignInUsername.d.ts +1 -0
- package/dist/esm/providers/cognito/utils/setActiveSignInUsername.mjs +12 -0
- package/dist/esm/providers/cognito/utils/setActiveSignInUsername.mjs.map +1 -0
- package/dist/esm/providers/cognito/utils/signInHelpers.d.ts +2 -26
- package/dist/esm/providers/cognito/utils/signInHelpers.mjs +18 -220
- package/dist/esm/providers/cognito/utils/signInHelpers.mjs.map +1 -1
- package/package.json +106 -106
- package/src/client/flows/shared/handlePasswordSRP.ts +3 -5
- package/src/client/flows/userAuth/handleSelectChallengeWithPassword.ts +1 -1
- package/src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.ts +3 -5
- package/src/client/flows/userAuth/handleUserAuthFlow.ts +1 -1
- package/src/client/flows/userAuth/handleWebAuthnSignInResult.ts +6 -8
- package/src/client/flows/userAuth/types.ts +15 -0
- package/src/providers/cognito/apis/confirmSignIn.ts +1 -1
- package/src/providers/cognito/apis/signInWithCustomAuth.ts +2 -2
- package/src/providers/cognito/apis/signInWithCustomSRPAuth.ts +1 -1
- package/src/providers/cognito/apis/signInWithSRP.ts +1 -1
- package/src/providers/cognito/apis/signInWithUserAuth.ts +1 -1
- package/src/providers/cognito/apis/signInWithUserPassword.ts +2 -2
- package/src/providers/cognito/utils/getNewDeviceMetadata.ts +88 -0
- package/src/providers/cognito/utils/handleDeviceSRPAuth.ts +146 -0
- package/src/providers/cognito/utils/handlePasswordVerifierChallenge.ts +106 -0
- package/src/providers/cognito/utils/retryOnResourceNotFoundException.ts +34 -0
- package/src/providers/cognito/utils/setActiveSignInUsername.ts +10 -0
- package/src/providers/cognito/utils/signInHelpers.ts +19 -327
package/package.json
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
2
|
+
"name": "@aws-amplify/auth",
|
|
3
|
+
"version": "6.10.2",
|
|
4
|
+
"description": "Auth category of aws-amplify",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.mjs",
|
|
7
|
+
"typings": "./dist/esm/index.d.ts",
|
|
8
|
+
"react-native": "./src/index.ts",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/cjs/providers/cognito/apis/signInWithRedirect.js",
|
|
11
|
+
"./dist/esm/providers/cognito/apis/signInWithRedirect.mjs",
|
|
12
|
+
"./dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js",
|
|
13
|
+
"./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "yarn lint --fix && jest -w 1 --coverage --logHeapUsage",
|
|
20
|
+
"build-with-test": "npm test && npm run build",
|
|
21
|
+
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
|
|
22
|
+
"build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
|
|
23
|
+
"build:watch": "npm run build:esm-cjs -- --watch",
|
|
24
|
+
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
|
|
25
|
+
"clean": "npm run clean:size && rimraf lib-esm lib dist",
|
|
26
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
27
|
+
"format": "echo \"Not implemented\"",
|
|
28
|
+
"lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
|
|
29
|
+
"lint:fix": "eslint '**/*.{ts,tsx}' --fix",
|
|
30
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 91.18"
|
|
31
|
+
},
|
|
32
|
+
"typesVersions": {
|
|
33
|
+
">=4.2": {
|
|
34
|
+
"cognito": [
|
|
35
|
+
"./dist/esm/providers/cognito/index.d.ts"
|
|
36
|
+
],
|
|
37
|
+
"cognito/server": [
|
|
38
|
+
"./dist/esm/providers/cognito/apis/server/index.d.ts"
|
|
39
|
+
],
|
|
40
|
+
"server": [
|
|
41
|
+
"./dist/esm/server.d.ts"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./dist/esm/index.d.ts",
|
|
48
|
+
"import": "./dist/esm/index.mjs",
|
|
49
|
+
"require": "./dist/cjs/index.js",
|
|
50
|
+
"react-native": "./src/index.ts"
|
|
51
|
+
},
|
|
52
|
+
"./cognito": {
|
|
53
|
+
"types": "./dist/esm/providers/cognito/index.d.ts",
|
|
54
|
+
"import": "./dist/esm/providers/cognito/index.mjs",
|
|
55
|
+
"require": "./dist/cjs/providers/cognito/index.js",
|
|
56
|
+
"react-native": "./src/providers/cognito/index.ts"
|
|
57
|
+
},
|
|
58
|
+
"./cognito/server": {
|
|
59
|
+
"types": "./dist/esm/providers/cognito/apis/server/index.d.ts",
|
|
60
|
+
"import": "./dist/esm/providers/cognito/apis/server/index.mjs",
|
|
61
|
+
"require": "./dist/cjs/providers/cognito/apis/server/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./server": {
|
|
64
|
+
"types": "./dist/esm/server.d.ts",
|
|
65
|
+
"import": "./dist/esm/server.mjs",
|
|
66
|
+
"require": "./dist/cjs/server.js"
|
|
67
|
+
},
|
|
68
|
+
"./enable-oauth-listener": {
|
|
69
|
+
"types": "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.d.ts",
|
|
70
|
+
"import": "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs",
|
|
71
|
+
"require": "./dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js"
|
|
72
|
+
},
|
|
73
|
+
"./package.json": "./package.json"
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
78
|
+
},
|
|
79
|
+
"author": "Amazon Web Services",
|
|
80
|
+
"license": "Apache-2.0",
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://aws-amplify.github.io/",
|
|
85
|
+
"files": [
|
|
86
|
+
"dist/cjs",
|
|
87
|
+
"dist/esm",
|
|
88
|
+
"src",
|
|
89
|
+
"cognito",
|
|
90
|
+
"server",
|
|
91
|
+
"enable-oauth-listener"
|
|
92
|
+
],
|
|
93
|
+
"dependencies": {
|
|
94
|
+
"@aws-crypto/sha256-js": "5.2.0",
|
|
95
|
+
"@smithy/types": "^3.3.0",
|
|
96
|
+
"tslib": "^2.5.0"
|
|
97
|
+
},
|
|
98
|
+
"peerDependencies": {
|
|
99
|
+
"@aws-amplify/core": "^6.1.0"
|
|
100
|
+
},
|
|
101
|
+
"devDependencies": {
|
|
102
|
+
"@aws-amplify/core": "6.9.3",
|
|
103
|
+
"@aws-amplify/react-native": "1.1.7",
|
|
104
|
+
"@jest/test-sequencer": "^29.7.0",
|
|
105
|
+
"typescript": "5.0.2"
|
|
106
|
+
},
|
|
107
|
+
"gitHead": "de14a78391a3ca7ef7c804f42d728cfab5cf0755"
|
|
108
108
|
}
|
|
@@ -13,16 +13,14 @@ import {
|
|
|
13
13
|
RespondToAuthChallengeCommandOutput,
|
|
14
14
|
} from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
|
|
15
15
|
import { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';
|
|
16
|
-
import {
|
|
17
|
-
handlePasswordVerifierChallenge,
|
|
18
|
-
retryOnResourceNotFoundException,
|
|
19
|
-
setActiveSignInUsername,
|
|
20
|
-
} from '../../../providers/cognito/utils/signInHelpers';
|
|
21
16
|
import { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';
|
|
22
17
|
import { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';
|
|
23
18
|
import { getRegionFromUserPoolId } from '../../../foundation/parsers';
|
|
24
19
|
import { getAuthUserAgentValue } from '../../../utils';
|
|
25
20
|
import { AuthFactorType } from '../../../providers/cognito/types/models';
|
|
21
|
+
import { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge';
|
|
22
|
+
import { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';
|
|
23
|
+
import { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';
|
|
26
24
|
|
|
27
25
|
interface HandlePasswordSRPInput {
|
|
28
26
|
username: string;
|
|
@@ -11,7 +11,7 @@ import { getRegionFromUserPoolId } from '../../../foundation/parsers';
|
|
|
11
11
|
import { getAuthUserAgentValue } from '../../../utils';
|
|
12
12
|
import { getUserContextData } from '../../../providers/cognito/utils/userContextData';
|
|
13
13
|
import { RespondToAuthChallengeCommandOutput } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
|
|
14
|
-
import { setActiveSignInUsername } from '../../../providers/cognito/utils/
|
|
14
|
+
import { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Handles the SELECT_CHALLENGE response specifically for Password authentication.
|
|
@@ -16,11 +16,9 @@ import { getRegionFromUserPoolId } from '../../../foundation/parsers';
|
|
|
16
16
|
import { getAuthUserAgentValue } from '../../../utils';
|
|
17
17
|
import { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';
|
|
18
18
|
import { getUserContextData } from '../../../providers/cognito/utils/userContextData';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
setActiveSignInUsername,
|
|
23
|
-
} from '../../../providers/cognito/utils/signInHelpers';
|
|
19
|
+
import { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';
|
|
20
|
+
import { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';
|
|
21
|
+
import { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge';
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* Handles the SELECT_CHALLENGE response specifically for Password SRP authentication.
|
|
@@ -18,7 +18,7 @@ import { getAuthUserAgentValue } from '../../../utils';
|
|
|
18
18
|
import { handlePasswordSRP } from '../shared/handlePasswordSRP';
|
|
19
19
|
import { assertValidationError } from '../../../errors/utils/assertValidationError';
|
|
20
20
|
import { AuthValidationErrorCode } from '../../../errors/types/validation';
|
|
21
|
-
import { setActiveSignInUsername } from '../../../providers/cognito/utils/
|
|
21
|
+
import { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';
|
|
22
22
|
|
|
23
23
|
export interface HandleUserAuthFlowInput {
|
|
24
24
|
username: string;
|
|
@@ -17,12 +17,7 @@ import { getRegionFromUserPoolId } from '../../../foundation/parsers';
|
|
|
17
17
|
import { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';
|
|
18
18
|
import { cacheCognitoTokens } from '../../../providers/cognito/tokenProvider/cacheTokens';
|
|
19
19
|
import { dispatchSignedInHubEvent } from '../../../providers/cognito/utils/dispatchSignedInHubEvent';
|
|
20
|
-
import {
|
|
21
|
-
getNewDeviceMetadata,
|
|
22
|
-
getSignInResult,
|
|
23
|
-
} from '../../../providers/cognito/utils/signInHelpers';
|
|
24
20
|
import { setActiveSignInState, signInStore } from '../../../client/utils/store';
|
|
25
|
-
import { AuthSignInOutput } from '../../../types';
|
|
26
21
|
import { getAuthUserAgentValue } from '../../../utils';
|
|
27
22
|
import { getPasskey } from '../../utils/passkey';
|
|
28
23
|
import {
|
|
@@ -30,10 +25,13 @@ import {
|
|
|
30
25
|
assertPasskeyError,
|
|
31
26
|
} from '../../utils/passkey/errors';
|
|
32
27
|
import { AuthError } from '../../../errors/AuthError';
|
|
28
|
+
import { getNewDeviceMetadata } from '../../../providers/cognito/utils/getNewDeviceMetadata';
|
|
29
|
+
|
|
30
|
+
import { WebAuthnSignInResult } from './types';
|
|
33
31
|
|
|
34
32
|
export async function handleWebAuthnSignInResult(
|
|
35
33
|
challengeParameters: ChallengeParameters,
|
|
36
|
-
): Promise<
|
|
34
|
+
): Promise<WebAuthnSignInResult> {
|
|
37
35
|
const authConfig = Amplify.getConfig().Auth?.Cognito;
|
|
38
36
|
assertTokenProviderConfig(authConfig);
|
|
39
37
|
const { username, signInSession, signInDetails, challengeName } =
|
|
@@ -119,8 +117,8 @@ export async function handleWebAuthnSignInResult(
|
|
|
119
117
|
});
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
return
|
|
120
|
+
return {
|
|
123
121
|
challengeName: nextChallengeName as ChallengeName,
|
|
124
122
|
challengeParameters: nextChallengeParameters as ChallengeParameters,
|
|
125
|
-
}
|
|
123
|
+
};
|
|
126
124
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ChallengeName,
|
|
6
|
+
ChallengeParameters,
|
|
7
|
+
} from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
|
|
8
|
+
import { AuthSignInOutput } from '../../../types';
|
|
9
|
+
|
|
10
|
+
export type WebAuthnSignInResult =
|
|
11
|
+
| AuthSignInOutput
|
|
12
|
+
| {
|
|
13
|
+
challengeName: ChallengeName;
|
|
14
|
+
challengeParameters: ChallengeParameters;
|
|
15
|
+
};
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from '../../../client/utils/store';
|
|
18
18
|
import { AuthError } from '../../../errors/AuthError';
|
|
19
19
|
import {
|
|
20
|
-
getNewDeviceMetadata,
|
|
21
20
|
getSignInResult,
|
|
22
21
|
getSignInResultFromError,
|
|
23
22
|
handleChallengeName,
|
|
@@ -33,6 +32,7 @@ import {
|
|
|
33
32
|
ChallengeName,
|
|
34
33
|
ChallengeParameters,
|
|
35
34
|
} from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
|
|
35
|
+
import { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Continues or completes the sign in process when required by the initial call to `signIn`.
|
|
@@ -9,11 +9,9 @@ import { assertValidationError } from '../../../errors/utils/assertValidationErr
|
|
|
9
9
|
import { assertServiceError } from '../../../errors/utils/assertServiceError';
|
|
10
10
|
import {
|
|
11
11
|
getActiveSignInUsername,
|
|
12
|
-
getNewDeviceMetadata,
|
|
13
12
|
getSignInResult,
|
|
14
13
|
getSignInResultFromError,
|
|
15
14
|
handleCustomAuthFlowWithoutSRP,
|
|
16
|
-
retryOnResourceNotFoundException,
|
|
17
15
|
} from '../utils/signInHelpers';
|
|
18
16
|
import { InitiateAuthException } from '../types/errors';
|
|
19
17
|
import {
|
|
@@ -32,6 +30,8 @@ import {
|
|
|
32
30
|
} from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
|
|
33
31
|
import { tokenOrchestrator } from '../tokenProvider';
|
|
34
32
|
import { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';
|
|
33
|
+
import { retryOnResourceNotFoundException } from '../utils/retryOnResourceNotFoundException';
|
|
34
|
+
import { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Signs a user in using a custom authentication flow without password
|
|
@@ -9,7 +9,6 @@ import { assertValidationError } from '../../../errors/utils/assertValidationErr
|
|
|
9
9
|
import { assertServiceError } from '../../../errors/utils/assertServiceError';
|
|
10
10
|
import {
|
|
11
11
|
getActiveSignInUsername,
|
|
12
|
-
getNewDeviceMetadata,
|
|
13
12
|
getSignInResult,
|
|
14
13
|
getSignInResultFromError,
|
|
15
14
|
handleCustomSRPAuthFlow,
|
|
@@ -34,6 +33,7 @@ import {
|
|
|
34
33
|
} from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
|
|
35
34
|
import { tokenOrchestrator } from '../tokenProvider';
|
|
36
35
|
import { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';
|
|
36
|
+
import { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Signs a user in using a custom authentication flow with SRP
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from '../types/errors';
|
|
18
18
|
import {
|
|
19
19
|
getActiveSignInUsername,
|
|
20
|
-
getNewDeviceMetadata,
|
|
21
20
|
getSignInResult,
|
|
22
21
|
getSignInResultFromError,
|
|
23
22
|
handleUserSRPAuthFlow,
|
|
@@ -34,6 +33,7 @@ import {
|
|
|
34
33
|
import { cacheCognitoTokens } from '../tokenProvider/cacheTokens';
|
|
35
34
|
import { tokenOrchestrator } from '../tokenProvider';
|
|
36
35
|
import { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';
|
|
36
|
+
import { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';
|
|
37
37
|
|
|
38
38
|
import { resetAutoSignIn } from './autoSignIn';
|
|
39
39
|
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from '../types/errors';
|
|
18
18
|
import {
|
|
19
19
|
getActiveSignInUsername,
|
|
20
|
-
getNewDeviceMetadata,
|
|
21
20
|
getSignInResult,
|
|
22
21
|
getSignInResultFromError,
|
|
23
22
|
} from '../utils/signInHelpers';
|
|
@@ -38,6 +37,7 @@ import {
|
|
|
38
37
|
HandleUserAuthFlowInput,
|
|
39
38
|
handleUserAuthFlow,
|
|
40
39
|
} from '../../../client/flows/userAuth/handleUserAuthFlow';
|
|
40
|
+
import { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';
|
|
41
41
|
|
|
42
42
|
import { resetAutoSignIn } from './autoSignIn';
|
|
43
43
|
|
|
@@ -13,11 +13,9 @@ import {
|
|
|
13
13
|
} from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
|
|
14
14
|
import {
|
|
15
15
|
getActiveSignInUsername,
|
|
16
|
-
getNewDeviceMetadata,
|
|
17
16
|
getSignInResult,
|
|
18
17
|
getSignInResultFromError,
|
|
19
18
|
handleUserPasswordAuthFlow,
|
|
20
|
-
retryOnResourceNotFoundException,
|
|
21
19
|
} from '../utils/signInHelpers';
|
|
22
20
|
import { InitiateAuthException } from '../types/errors';
|
|
23
21
|
import {
|
|
@@ -32,6 +30,8 @@ import {
|
|
|
32
30
|
import { cacheCognitoTokens } from '../tokenProvider/cacheTokens';
|
|
33
31
|
import { tokenOrchestrator } from '../tokenProvider';
|
|
34
32
|
import { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';
|
|
33
|
+
import { retryOnResourceNotFoundException } from '../utils/retryOnResourceNotFoundException';
|
|
34
|
+
import { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';
|
|
35
35
|
|
|
36
36
|
import { resetAutoSignIn } from './autoSignIn';
|
|
37
37
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
base64Encoder,
|
|
6
|
+
getDeviceName,
|
|
7
|
+
} from '@aws-amplify/core/internals/utils';
|
|
8
|
+
|
|
9
|
+
import { DeviceMetadata } from '../tokenProvider/types';
|
|
10
|
+
import { createConfirmDeviceClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';
|
|
11
|
+
import { createCognitoUserPoolEndpointResolver } from '../factories';
|
|
12
|
+
import { NewDeviceMetadataType } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
|
|
13
|
+
import { getRegionFromUserPoolId } from '../../../foundation/parsers';
|
|
14
|
+
|
|
15
|
+
import { getAuthenticationHelper, getBytesFromHex } from './srp';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This function is used to kick off the device management flow.
|
|
19
|
+
*
|
|
20
|
+
* If an error is thrown while generating a hash device or calling the `ConfirmDevice`
|
|
21
|
+
* client, then this API will ignore the error and return undefined. Otherwise the authentication
|
|
22
|
+
* flow will not complete and the user won't be able to be signed in.
|
|
23
|
+
*
|
|
24
|
+
* @returns DeviceMetadata | undefined
|
|
25
|
+
*/
|
|
26
|
+
export async function getNewDeviceMetadata({
|
|
27
|
+
userPoolId,
|
|
28
|
+
userPoolEndpoint,
|
|
29
|
+
newDeviceMetadata,
|
|
30
|
+
accessToken,
|
|
31
|
+
}: {
|
|
32
|
+
userPoolId: string;
|
|
33
|
+
userPoolEndpoint: string | undefined;
|
|
34
|
+
newDeviceMetadata?: NewDeviceMetadataType;
|
|
35
|
+
accessToken?: string;
|
|
36
|
+
}): Promise<DeviceMetadata | undefined> {
|
|
37
|
+
if (!newDeviceMetadata) return undefined;
|
|
38
|
+
const userPoolName = userPoolId.split('_')[1] || '';
|
|
39
|
+
const authenticationHelper = await getAuthenticationHelper(userPoolName);
|
|
40
|
+
const deviceKey = newDeviceMetadata?.DeviceKey;
|
|
41
|
+
const deviceGroupKey = newDeviceMetadata?.DeviceGroupKey;
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await authenticationHelper.generateHashDevice(
|
|
45
|
+
deviceGroupKey ?? '',
|
|
46
|
+
deviceKey ?? '',
|
|
47
|
+
);
|
|
48
|
+
} catch (errGenHash) {
|
|
49
|
+
// TODO: log error here
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const deviceSecretVerifierConfig = {
|
|
54
|
+
Salt: base64Encoder.convert(
|
|
55
|
+
getBytesFromHex(authenticationHelper.getSaltToHashDevices()),
|
|
56
|
+
),
|
|
57
|
+
PasswordVerifier: base64Encoder.convert(
|
|
58
|
+
getBytesFromHex(authenticationHelper.getVerifierDevices()),
|
|
59
|
+
),
|
|
60
|
+
};
|
|
61
|
+
const randomPassword = authenticationHelper.getRandomPassword();
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const confirmDevice = createConfirmDeviceClient({
|
|
65
|
+
endpointResolver: createCognitoUserPoolEndpointResolver({
|
|
66
|
+
endpointOverride: userPoolEndpoint,
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
await confirmDevice(
|
|
70
|
+
{ region: getRegionFromUserPoolId(userPoolId) },
|
|
71
|
+
{
|
|
72
|
+
AccessToken: accessToken,
|
|
73
|
+
DeviceName: await getDeviceName(),
|
|
74
|
+
DeviceKey: newDeviceMetadata?.DeviceKey,
|
|
75
|
+
DeviceSecretVerifierConfig: deviceSecretVerifierConfig,
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
deviceKey,
|
|
81
|
+
deviceGroupKey,
|
|
82
|
+
randomPassword,
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
// TODO: log error here
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|