@davidwells/cogneato 0.4.2 → 0.4.4
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/.github/workflows/claude.yml +1436 -0
- package/dist/cognito/cognito-fetch.d.ts +5 -0
- package/dist/cognito/cognito-fetch.d.ts.map +1 -1
- package/dist/cognito/cognito-fetch.js.map +1 -1
- package/dist/cognito/operations/initiate-user-srp-auth.d.ts +3 -1
- package/dist/cognito/operations/initiate-user-srp-auth.d.ts.map +1 -1
- package/dist/cognito/operations/initiate-user-srp-auth.js +2 -1
- package/dist/cognito/operations/initiate-user-srp-auth.js.map +1 -1
- package/dist/cognito/operations/respond-device-srp-auth.d.ts +3 -1
- package/dist/cognito/operations/respond-device-srp-auth.d.ts.map +1 -1
- package/dist/cognito/operations/respond-device-srp-auth.js +2 -1
- package/dist/cognito/operations/respond-device-srp-auth.js.map +1 -1
- package/dist/cognito/operations/respond-new-password-required.d.ts +3 -1
- package/dist/cognito/operations/respond-new-password-required.d.ts.map +1 -1
- package/dist/cognito/operations/respond-new-password-required.js +2 -1
- package/dist/cognito/operations/respond-new-password-required.js.map +1 -1
- package/dist/cognito/operations/respond-password-verifier.d.ts +3 -1
- package/dist/cognito/operations/respond-password-verifier.d.ts.map +1 -1
- package/dist/cognito/operations/respond-password-verifier.js +2 -1
- package/dist/cognito/operations/respond-password-verifier.js.map +1 -1
- package/dist/cognito/operations/respond-sms-mfa.d.ts +3 -1
- package/dist/cognito/operations/respond-sms-mfa.d.ts.map +1 -1
- package/dist/cognito/operations/respond-sms-mfa.js +2 -1
- package/dist/cognito/operations/respond-sms-mfa.js.map +1 -1
- package/dist/cognito/operations/respond-software-token-mfa.d.ts +3 -1
- package/dist/cognito/operations/respond-software-token-mfa.d.ts.map +1 -1
- package/dist/cognito/operations/respond-software-token-mfa.js +2 -1
- package/dist/cognito/operations/respond-software-token-mfa.js.map +1 -1
- package/dist/cognito/types/guards/guard-confirm-device-response.d.ts.map +1 -1
- package/dist/cognito/types/guards/guard-confirm-device-response.js +1 -3
- package/dist/cognito/types/guards/guard-confirm-device-response.js.map +1 -1
- package/dist/login/generator.d.ts +3 -1
- package/dist/login/generator.d.ts.map +1 -1
- package/dist/login/generator.js +7 -1
- package/dist/login/generator.js.map +1 -1
- package/dist/login/verify-device.d.ts +3 -1
- package/dist/login/verify-device.d.ts.map +1 -1
- package/dist/login/verify-device.js +3 -1
- package/dist/login/verify-device.js.map +1 -1
- package/dist/login/verify-srp.d.ts +3 -1
- package/dist/login/verify-srp.d.ts.map +1 -1
- package/dist/login/verify-srp.js +2 -1
- package/dist/login/verify-srp.js.map +1 -1
- package/dist/srp/low-level/_helpers.d.ts.map +1 -1
- package/dist/srp/low-level/_helpers.js.map +1 -1
- package/dist/srp/low-level/math.d.ts.map +1 -1
- package/dist/srp/low-level/math.js.map +1 -1
- package/package.json +10 -5
- package/src/cognito/cognito-fetch.ts +4 -1
- package/src/cognito/operations/initiate-user-srp-auth.ts +4 -1
- package/src/cognito/operations/respond-device-srp-auth.ts +4 -1
- package/src/cognito/operations/respond-new-password-required.ts +4 -1
- package/src/cognito/operations/respond-password-verifier.ts +4 -1
- package/src/cognito/operations/respond-sms-mfa.ts +4 -1
- package/src/cognito/operations/respond-software-token-mfa.ts +4 -1
- package/src/cognito/types/guards/guard-confirm-device-response.ts +1 -5
- package/src/login/generator.ts +9 -0
- package/src/login/verify-device.ts +5 -0
- package/src/login/verify-srp.ts +4 -0
- package/src/srp/low-level/_helpers.ts +2 -4
- package/src/srp/low-level/math.ts +2 -4
package/dist/login/verify-srp.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.verifySrp = void 0;
|
|
|
4
4
|
const cognito_1 = require("../cognito");
|
|
5
5
|
const srp_1 = require("../srp");
|
|
6
6
|
const util_1 = require("../util");
|
|
7
|
-
const verifySrp = async ({ region, userPoolId, clientId, password, a, challengeName, challengeParameters, deviceKey, deviceGroupKey, debug = util_1.noop, }) => {
|
|
7
|
+
const verifySrp = async ({ region, userPoolId, clientId, password, a, challengeName, challengeParameters, deviceKey, deviceGroupKey, clientMetadata, debug = util_1.noop, }) => {
|
|
8
8
|
const groupId = challengeParameters.DEVICE_KEY && deviceGroupKey
|
|
9
9
|
? deviceGroupKey
|
|
10
10
|
: util_1.stripPoolRegion(userPoolId);
|
|
@@ -21,6 +21,7 @@ const verifySrp = async ({ region, userPoolId, clientId, password, a, challengeN
|
|
|
21
21
|
claimSig,
|
|
22
22
|
challengeParameters,
|
|
23
23
|
challengeName,
|
|
24
|
+
clientMetadata,
|
|
24
25
|
debug,
|
|
25
26
|
});
|
|
26
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-srp.js","sourceRoot":"","sources":["../../src/login/verify-srp.ts"],"names":[],"mappings":";;;AAAA,wCAAqD;
|
|
1
|
+
{"version":3,"file":"verify-srp.js","sourceRoot":"","sources":["../../src/login/verify-srp.ts"],"names":[],"mappings":";;;AAAA,wCAAqD;AAGrD,gCAA2C;AAC3C,kCAAgD;AAgBzC,MAAM,SAAS,GAAG,KAAK,EAAE,EAC9B,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,CAAC,EACD,aAAa,EACb,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,GAAG,WAAI,GACD,EAAE,EAAE;IACf,MAAM,OAAO,GACX,mBAAmB,CAAC,UAAU,IAAI,cAAc;QAC9C,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,sBAAe,CAAC,UAAU,CAAC,CAAC;IAClC,MAAM,MAAM,GACV,mBAAmB,CAAC,UAAU;QAC9B,mBAAmB,CAAC,eAAe;QACnC,mBAAmB,CAAC,QAAQ,CAAC;IAE/B,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,uBAAiB,CACrD,CAAC,EACD,OAAO,EACP,MAAM,EACN,QAAQ,EACR,mBAAmB,CACpB,CAAC;IAEF,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACzC,OAAO,MAAM,iCAAuB,CAAC;QACnC,MAAM;QACN,QAAQ;QACR,SAAS;QACT,SAAS;QACT,QAAQ;QACR,mBAAmB;QACnB,aAAa;QACb,cAAc;QACd,KAAK;KACN,CAAC,CAAC;AACL,CAAC,CAAC;AA1CW,QAAA,SAAS,aA0CpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_helpers.d.ts","sourceRoot":"","sources":["../../../src/srp/low-level/_helpers.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO,QAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"_helpers.d.ts","sourceRoot":"","sources":["../../../src/srp/low-level/_helpers.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO,QAAe,MAAM,oBAA+D,CAAC;AAEzG,eAAO,MAAM,QAAQ,SAAgB,MAAM,oBAAsE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_helpers.js","sourceRoot":"","sources":["../../../src/srp/low-level/_helpers.ts"],"names":[],"mappings":";;;AAAA,qCAKoB;AACpB,yCAA0C;AAEnC,MAAM,OAAO,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"_helpers.js","sourceRoot":"","sources":["../../../src/srp/low-level/_helpers.ts"],"names":[],"mappings":";;;AAAA,qCAKoB;AACpB,yCAA0C;AAEnC,MAAM,OAAO,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE,CAAC,iBAAU,CAAC,kBAAW,CAAC,MAAM,mBAAU,CAAC,iBAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAA5F,QAAA,OAAO,WAAqF;AAElG,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE,CAAC,iBAAU,CAAC,kBAAW,CAAC,MAAM,mBAAU,CAAC,uBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAArG,QAAA,QAAQ,YAA6F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/srp/low-level/math.ts"],"names":[],"mappings":"AAYA,aAAK,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACtD,aAAK,aAAa,CAAC,CAAC,SAAS,YAAY,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,OAAO,uBAA2D,CAAC;AAEhF,eAAO,MAAM,CAAC,UAAiB,cAAc,GAAG,CAAC,oBAAoB,CAAC;AAEtE,eAAO,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/srp/low-level/math.ts"],"names":[],"mappings":"AAYA,aAAK,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACtD,aAAK,aAAa,CAAC,CAAC,SAAS,YAAY,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,OAAO,uBAA2D,CAAC;AAEhF,eAAO,MAAM,CAAC,UAAiB,cAAc,GAAG,CAAC,oBAAoB,CAAC;AAEtE,eAAO,MAAM,CAAC,uBAAkF,CAAC;AAEjG,eAAO,MAAM,CAAC,aAAoB,cAAc,GAAG,GAAG,GAAG,CAAC,oBAAsD,CAAC;AAEjH,eAAO,MAAM,CAAC,uBAMX,cAAc,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,oBACE,CAAC;AAEhD,eAAO,MAAM,CAAC,SACN,MAAM,WACH,MAAM,gBACD,MAAM,YACV,MAAM,oBAMf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../src/srp/low-level/math.ts"],"names":[],"mappings":";;;AAAA,yCAA+C;AAC/C,qCAMoB;AAEpB,qCAAgC;AAChC,yCAA+C;AAKxC,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC,kBAAW,CAAC,iBAAU,CAAC,wBAAe,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAAnE,QAAA,OAAO,WAA4D;AAEzE,MAAM,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAsB,EAAE,EAAE,CAAC,aAAM,CAAC,UAAC,EAAE,CAAC,EAAE,UAAC,CAAC,CAAC;AAAzD,QAAA,CAAC,KAAwD;AAE/D,MAAM,CAAC,GAAG,KAAK,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../src/srp/low-level/math.ts"],"names":[],"mappings":";;;AAAA,yCAA+C;AAC/C,qCAMoB;AAEpB,qCAAgC;AAChC,yCAA+C;AAKxC,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC,kBAAW,CAAC,iBAAU,CAAC,wBAAe,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAAnE,QAAA,OAAO,WAA4D;AAEzE,MAAM,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAsB,EAAE,EAAE,CAAC,aAAM,CAAC,UAAC,EAAE,CAAC,EAAE,UAAC,CAAC,CAAC;AAAzD,QAAA,CAAC,KAAwD;AAE/D,MAAM,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC,kBAAW,CAAC,MAAM,kBAAO,CAAC,KAAK,kBAAW,CAAC,UAAC,CAAC,IAAI,kBAAW,CAAC,UAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAApF,QAAA,CAAC,KAAmF;AAE1F,MAAM,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAA4B,EAAE,EAAE,CAAC,kBAAW,CAAC,MAAM,kBAAO,CAAC,aAAM,CAAC,CAAC,CAAC,GAAG,aAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAApG,QAAA,CAAC,KAAmG;AAE1G,MAAM,CAAC,GAAG,KAAK,EAAE,EACtB,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,GAC0C,EAAE,EAAE,CAC/C,aAAM,CAAC,CAAC,GAAG,CAAC,GAAG,aAAM,CAAC,UAAC,EAAE,CAAC,EAAE,UAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,UAAC,CAAC,CAAC;AAPnC,QAAA,CAAC,KAOkC;AAEzC,MAAM,CAAC,GAAG,KAAK,EACpB,IAAY,EACZ,OAAe,EACf,YAAoB,EACpB,QAAgB,EAChB,EAAE,CACF,kBAAW,CACT,MAAM,kBAAO,CACX,aAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,mBAAQ,CAAC,GAAG,OAAO,GAAG,YAAY,IAAI,QAAQ,EAAE,CAAC,CAAC,CACzE,CACF,CAAC;AAVS,QAAA,CAAC,KAUV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@davidwells/cogneato",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "low level implementation lib for use with aws cognito srp login",
|
|
5
5
|
"browser": "dist/index.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,16 +8,21 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"clean": "rm -rf tsconfig.tsbuildinfo dist",
|
|
10
10
|
"build": "npm run clean && tsc --build --force",
|
|
11
|
+
"prepare": "npm run build",
|
|
11
12
|
"watch": "tsc --build --force --watch",
|
|
12
13
|
"test": "jest",
|
|
13
14
|
"cdktest": "jest src/test/cdk",
|
|
14
15
|
"cdkdeploy": "cd src/test/cdk && cdk deploy --outputs-file cfn_out.json",
|
|
15
16
|
"cdkdestroy": "cd src/test/cdk && cdk destroy",
|
|
16
|
-
"createTestUsers": "cd src/test && ts-node createTestUsers > test_users_out.json"
|
|
17
|
+
"createTestUsers": "cd src/test && ts-node createTestUsers > test_users_out.json",
|
|
18
|
+
"publish": "git push origin && git push origin --tags",
|
|
19
|
+
"release:patch": "npm version patch && npm publish",
|
|
20
|
+
"release:minor": "npm version minor && npm publish",
|
|
21
|
+
"release:major": "npm version major && npm publish"
|
|
17
22
|
},
|
|
18
23
|
"repository": {
|
|
19
24
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/
|
|
25
|
+
"url": "git+https://github.com/DavidWells/cogneato.git"
|
|
21
26
|
},
|
|
22
27
|
"keywords": [
|
|
23
28
|
"cognito",
|
|
@@ -28,9 +33,9 @@
|
|
|
28
33
|
"author": "Paul Nilsson",
|
|
29
34
|
"license": "MIT",
|
|
30
35
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/
|
|
36
|
+
"url": "https://github.com/DavidWells/cogneato/issues"
|
|
32
37
|
},
|
|
33
|
-
"homepage": "https://github.com/
|
|
38
|
+
"homepage": "https://github.com/DavidWells/cogneato#readme",
|
|
34
39
|
"devDependencies": {
|
|
35
40
|
"@aws-cdk/assert": "1.85.0",
|
|
36
41
|
"@aws-cdk/aws-cognito": "^1.85.0",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { noop } from "../util";
|
|
2
2
|
import { callCognito } from "../platform";
|
|
3
3
|
|
|
4
|
+
export type TClientMetadata = Record<string, string>;
|
|
5
|
+
|
|
4
6
|
const identityActions = [
|
|
5
7
|
'GetId',
|
|
6
8
|
'GetCredentialsForIdentity'
|
|
@@ -110,13 +112,14 @@ type TRespondToAuthChallengeParams =
|
|
|
110
112
|
type TCognitoFetchArgs = { debug?: (trace: any) => void } & (
|
|
111
113
|
| {
|
|
112
114
|
operation: "InitiateAuth";
|
|
113
|
-
args: TInitiateAuthParams & { ClientId: string };
|
|
115
|
+
args: TInitiateAuthParams & { ClientId: string; ClientMetadata?: TClientMetadata };
|
|
114
116
|
}
|
|
115
117
|
| {
|
|
116
118
|
operation: "RespondToAuthChallenge";
|
|
117
119
|
args: TRespondToAuthChallengeParams & {
|
|
118
120
|
ClientId: string;
|
|
119
121
|
Session: string | undefined;
|
|
122
|
+
ClientMetadata?: TClientMetadata;
|
|
120
123
|
};
|
|
121
124
|
}
|
|
122
125
|
| {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SRPError, noop } from "../../util";
|
|
2
|
-
import { cognitoFetch } from "../cognito-fetch";
|
|
2
|
+
import { cognitoFetch, TClientMetadata } from "../cognito-fetch";
|
|
3
3
|
import { guardInitiateUserSrpResponse } from "../types";
|
|
4
4
|
|
|
5
5
|
type TInitiateUserSRPAuthParams = {
|
|
@@ -8,6 +8,7 @@ type TInitiateUserSRPAuthParams = {
|
|
|
8
8
|
username: string;
|
|
9
9
|
deviceKey?: string;
|
|
10
10
|
srpA: string;
|
|
11
|
+
clientMetadata?: TClientMetadata;
|
|
11
12
|
debug?: (trace: any) => void;
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -17,6 +18,7 @@ export const initiateUserSRPAuth = async ({
|
|
|
17
18
|
clientId,
|
|
18
19
|
deviceKey,
|
|
19
20
|
srpA,
|
|
21
|
+
clientMetadata,
|
|
20
22
|
debug = noop,
|
|
21
23
|
}: TInitiateUserSRPAuthParams) => {
|
|
22
24
|
const response = await cognitoFetch({
|
|
@@ -30,6 +32,7 @@ export const initiateUserSRPAuth = async ({
|
|
|
30
32
|
SRP_A: srpA,
|
|
31
33
|
DEVICE_KEY: deviceKey,
|
|
32
34
|
},
|
|
35
|
+
ClientMetadata: clientMetadata,
|
|
33
36
|
},
|
|
34
37
|
debug,
|
|
35
38
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SRPError, noop } from "../../util";
|
|
2
|
-
import { cognitoFetch } from "../cognito-fetch";
|
|
2
|
+
import { cognitoFetch, TClientMetadata } from "../cognito-fetch";
|
|
3
3
|
import { guardInitiateDeviceSrpResponse } from "../types";
|
|
4
4
|
|
|
5
5
|
type TRespondDeviceSRPAuthParams = {
|
|
@@ -8,6 +8,7 @@ type TRespondDeviceSRPAuthParams = {
|
|
|
8
8
|
username: string;
|
|
9
9
|
deviceKey: string;
|
|
10
10
|
srpA: string;
|
|
11
|
+
clientMetadata?: TClientMetadata;
|
|
11
12
|
debug?: (trace: any) => void;
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -17,6 +18,7 @@ export const respondDeviceSRPAuth = async ({
|
|
|
17
18
|
clientId,
|
|
18
19
|
deviceKey,
|
|
19
20
|
srpA,
|
|
21
|
+
clientMetadata,
|
|
20
22
|
debug = noop,
|
|
21
23
|
}: TRespondDeviceSRPAuthParams) => {
|
|
22
24
|
const response = await cognitoFetch({
|
|
@@ -31,6 +33,7 @@ export const respondDeviceSRPAuth = async ({
|
|
|
31
33
|
DEVICE_KEY: deviceKey,
|
|
32
34
|
},
|
|
33
35
|
Session: undefined,
|
|
36
|
+
ClientMetadata: clientMetadata,
|
|
34
37
|
},
|
|
35
38
|
debug,
|
|
36
39
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SRPError, noop } from "../../util";
|
|
2
|
-
import { cognitoFetch } from "../cognito-fetch";
|
|
2
|
+
import { cognitoFetch, TClientMetadata } from "../cognito-fetch";
|
|
3
3
|
import {
|
|
4
4
|
guardAuthenticationResultResponse,
|
|
5
5
|
guardDeviceChallengeResponse,
|
|
@@ -12,6 +12,7 @@ type TRespondNewPasswordRequiredParams = {
|
|
|
12
12
|
clientId: string;
|
|
13
13
|
challengeResponses: { username: string; newPassword: string };
|
|
14
14
|
session: string;
|
|
15
|
+
clientMetadata?: TClientMetadata;
|
|
15
16
|
debug?: (trace: any) => void;
|
|
16
17
|
};
|
|
17
18
|
|
|
@@ -20,6 +21,7 @@ export const respondNewPasswordRequired = async ({
|
|
|
20
21
|
clientId,
|
|
21
22
|
challengeResponses,
|
|
22
23
|
session,
|
|
24
|
+
clientMetadata,
|
|
23
25
|
debug = noop,
|
|
24
26
|
}: TRespondNewPasswordRequiredParams) => {
|
|
25
27
|
const response = await cognitoFetch({
|
|
@@ -33,6 +35,7 @@ export const respondNewPasswordRequired = async ({
|
|
|
33
35
|
USERNAME: challengeResponses.username,
|
|
34
36
|
NEW_PASSWORD: challengeResponses.newPassword,
|
|
35
37
|
},
|
|
38
|
+
ClientMetadata: clientMetadata,
|
|
36
39
|
},
|
|
37
40
|
debug,
|
|
38
41
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SRPError, noop } from "../../util";
|
|
2
|
-
import { cognitoFetch } from "../cognito-fetch";
|
|
2
|
+
import { cognitoFetch, TClientMetadata } from "../cognito-fetch";
|
|
3
3
|
import {
|
|
4
4
|
guardAuthenticationResultResponse,
|
|
5
5
|
guardDeviceChallengeResponse,
|
|
@@ -17,6 +17,7 @@ type TRespondPasswordVerifierParams = {
|
|
|
17
17
|
challengeParameters: TSRPChallengeParameters;
|
|
18
18
|
timestamp: string;
|
|
19
19
|
claimSig: string;
|
|
20
|
+
clientMetadata?: TClientMetadata;
|
|
20
21
|
debug?: (trace: any) => void;
|
|
21
22
|
};
|
|
22
23
|
|
|
@@ -28,6 +29,7 @@ export const respondPasswordVerifier = async ({
|
|
|
28
29
|
challengeParameters,
|
|
29
30
|
timestamp,
|
|
30
31
|
claimSig,
|
|
32
|
+
clientMetadata,
|
|
31
33
|
debug = noop,
|
|
32
34
|
}: TRespondPasswordVerifierParams) => {
|
|
33
35
|
const devKey = deviceKey!;
|
|
@@ -53,6 +55,7 @@ export const respondPasswordVerifier = async ({
|
|
|
53
55
|
TIMESTAMP: timestamp,
|
|
54
56
|
},
|
|
55
57
|
Session: undefined,
|
|
58
|
+
ClientMetadata: clientMetadata,
|
|
56
59
|
},
|
|
57
60
|
debug,
|
|
58
61
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SRPError, noop } from "../../util";
|
|
2
|
-
import { cognitoFetch } from "../cognito-fetch";
|
|
2
|
+
import { cognitoFetch, TClientMetadata } from "../cognito-fetch";
|
|
3
3
|
import {
|
|
4
4
|
guardAuthenticationResultResponse,
|
|
5
5
|
guardDeviceChallengeResponse,
|
|
@@ -10,6 +10,7 @@ type TRespondSmsMfaParams = {
|
|
|
10
10
|
clientId: string;
|
|
11
11
|
challengeResponses: { username: string; mfaCode: string; deviceKey?: string };
|
|
12
12
|
session: string;
|
|
13
|
+
clientMetadata?: TClientMetadata;
|
|
13
14
|
debug?: (trace: any) => void;
|
|
14
15
|
};
|
|
15
16
|
|
|
@@ -18,6 +19,7 @@ export const respondSmsMfa = async ({
|
|
|
18
19
|
clientId,
|
|
19
20
|
challengeResponses,
|
|
20
21
|
session,
|
|
22
|
+
clientMetadata,
|
|
21
23
|
debug = noop,
|
|
22
24
|
}: TRespondSmsMfaParams) => {
|
|
23
25
|
const response = await cognitoFetch({
|
|
@@ -32,6 +34,7 @@ export const respondSmsMfa = async ({
|
|
|
32
34
|
SMS_MFA_CODE: challengeResponses.mfaCode,
|
|
33
35
|
DEVICE_KEY: challengeResponses.deviceKey,
|
|
34
36
|
},
|
|
37
|
+
ClientMetadata: clientMetadata,
|
|
35
38
|
},
|
|
36
39
|
debug,
|
|
37
40
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SRPError, noop } from "../../util";
|
|
2
|
-
import { cognitoFetch } from "../cognito-fetch";
|
|
2
|
+
import { cognitoFetch, TClientMetadata } from "../cognito-fetch";
|
|
3
3
|
import {
|
|
4
4
|
guardAuthenticationResultResponse,
|
|
5
5
|
guardDeviceChallengeResponse,
|
|
@@ -10,6 +10,7 @@ type TRespondSoftwareTokenMfaParams = {
|
|
|
10
10
|
clientId: string;
|
|
11
11
|
challengeResponses: { username: string; mfaCode: string; deviceKey?: string };
|
|
12
12
|
session: string;
|
|
13
|
+
clientMetadata?: TClientMetadata;
|
|
13
14
|
debug?: (trace: any) => void;
|
|
14
15
|
};
|
|
15
16
|
|
|
@@ -18,6 +19,7 @@ export const respondSoftwareTokenMfa = async ({
|
|
|
18
19
|
clientId,
|
|
19
20
|
challengeResponses,
|
|
20
21
|
session,
|
|
22
|
+
clientMetadata,
|
|
21
23
|
debug = noop,
|
|
22
24
|
}: TRespondSoftwareTokenMfaParams) => {
|
|
23
25
|
const response = await cognitoFetch({
|
|
@@ -32,6 +34,7 @@ export const respondSoftwareTokenMfa = async ({
|
|
|
32
34
|
SOFTWARE_TOKEN_MFA_CODE: challengeResponses.mfaCode,
|
|
33
35
|
DEVICE_KEY: challengeResponses.deviceKey,
|
|
34
36
|
},
|
|
37
|
+
ClientMetadata: clientMetadata,
|
|
35
38
|
},
|
|
36
39
|
debug,
|
|
37
40
|
});
|
|
@@ -3,11 +3,7 @@ export type TConfirmDeviceResponse = { UserConfirmationNecessary: boolean };
|
|
|
3
3
|
export const guardConfirmDeviceResponse = (
|
|
4
4
|
thing: any
|
|
5
5
|
): thing is TConfirmDeviceResponse => {
|
|
6
|
-
if (
|
|
7
|
-
typeof thing === "object" &&
|
|
8
|
-
(thing.UserConfirmationNecessary === true ||
|
|
9
|
-
thing.UserConfirmationNecessary === false)
|
|
10
|
-
) {
|
|
6
|
+
if (typeof thing === "object" && (thing.UserConfirmationNecessary === true || thing.UserConfirmationNecessary === false)) {
|
|
11
7
|
return true;
|
|
12
8
|
}
|
|
13
9
|
return false;
|
package/src/login/generator.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
guardSmsMfaResponse,
|
|
13
13
|
guardSoftwareTokenMfaResponse,
|
|
14
14
|
} from "../cognito/types";
|
|
15
|
+
import { TClientMetadata } from "../cognito/cognito-fetch";
|
|
15
16
|
import {
|
|
16
17
|
TCognitoAuthenticationResultResponse,
|
|
17
18
|
TAuthResponse,
|
|
@@ -55,6 +56,7 @@ export type TSrpLoginParams = {
|
|
|
55
56
|
autoRememberDevice: Parameters<
|
|
56
57
|
typeof confirmDevice
|
|
57
58
|
>["0"]["autoRememberDevice"];
|
|
59
|
+
clientMetadata?: TClientMetadata;
|
|
58
60
|
debugTracing?: boolean;
|
|
59
61
|
};
|
|
60
62
|
|
|
@@ -69,6 +71,7 @@ export async function* srpLogin({
|
|
|
69
71
|
device,
|
|
70
72
|
autoConfirmDevice,
|
|
71
73
|
autoRememberDevice,
|
|
74
|
+
clientMetadata,
|
|
72
75
|
debugTracing,
|
|
73
76
|
}: TSrpLoginParams): TSrpLoginResponse {
|
|
74
77
|
const debugTraces: any[] = [];
|
|
@@ -156,6 +159,7 @@ export async function* srpLogin({
|
|
|
156
159
|
username,
|
|
157
160
|
deviceKey: device?.key,
|
|
158
161
|
srpA: bigIntToHex(A),
|
|
162
|
+
clientMetadata,
|
|
159
163
|
debug,
|
|
160
164
|
};
|
|
161
165
|
debug("calling initiateUserSRPAuth");
|
|
@@ -173,6 +177,7 @@ export async function* srpLogin({
|
|
|
173
177
|
challengeParameters: responseA.ChallengeParameters,
|
|
174
178
|
deviceKey: device?.key,
|
|
175
179
|
deviceGroupKey: device?.groupKey,
|
|
180
|
+
clientMetadata,
|
|
176
181
|
debug,
|
|
177
182
|
};
|
|
178
183
|
debug("calling verifySrp");
|
|
@@ -204,6 +209,7 @@ export async function* srpLogin({
|
|
|
204
209
|
username: responseA.ChallengeParameters.USERNAME,
|
|
205
210
|
},
|
|
206
211
|
session: nextResponse.Session,
|
|
212
|
+
clientMetadata,
|
|
207
213
|
debug,
|
|
208
214
|
});
|
|
209
215
|
}
|
|
@@ -242,6 +248,7 @@ export async function* srpLogin({
|
|
|
242
248
|
deviceKey: device?.key,
|
|
243
249
|
},
|
|
244
250
|
session,
|
|
251
|
+
clientMetadata,
|
|
245
252
|
debug,
|
|
246
253
|
});
|
|
247
254
|
valid = true;
|
|
@@ -294,6 +301,7 @@ export async function* srpLogin({
|
|
|
294
301
|
deviceKey: device?.key,
|
|
295
302
|
},
|
|
296
303
|
session,
|
|
304
|
+
clientMetadata,
|
|
297
305
|
debug,
|
|
298
306
|
});
|
|
299
307
|
valid = true;
|
|
@@ -328,6 +336,7 @@ export async function* srpLogin({
|
|
|
328
336
|
username:
|
|
329
337
|
responseA.ChallengeParameters.USER_ID_FOR_SRP ||
|
|
330
338
|
responseA.ChallengeParameters.USERNAME,
|
|
339
|
+
clientMetadata,
|
|
331
340
|
debug,
|
|
332
341
|
});
|
|
333
342
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { respondDeviceSRPAuth } from "../cognito";
|
|
2
|
+
import { TClientMetadata } from "../cognito/cognito-fetch";
|
|
2
3
|
import { guardAuthenticationResultResponse } from "../cognito/types";
|
|
3
4
|
import { makeSrpSession } from "../srp";
|
|
4
5
|
import { bigIntToHex, SRPError, noop } from "../util";
|
|
@@ -12,6 +13,7 @@ type TVerifyDevice = {
|
|
|
12
13
|
deviceGroupKey: string;
|
|
13
14
|
password: string;
|
|
14
15
|
username: string;
|
|
16
|
+
clientMetadata?: TClientMetadata;
|
|
15
17
|
debug?: (trace: any) => void;
|
|
16
18
|
};
|
|
17
19
|
|
|
@@ -23,6 +25,7 @@ export const verifyDevice = async ({
|
|
|
23
25
|
deviceGroupKey,
|
|
24
26
|
password,
|
|
25
27
|
username,
|
|
28
|
+
clientMetadata,
|
|
26
29
|
debug = noop,
|
|
27
30
|
}: TVerifyDevice) => {
|
|
28
31
|
const { a, A } = await makeSrpSession();
|
|
@@ -33,6 +36,7 @@ export const verifyDevice = async ({
|
|
|
33
36
|
username,
|
|
34
37
|
deviceKey,
|
|
35
38
|
srpA: bigIntToHex(A),
|
|
39
|
+
clientMetadata,
|
|
36
40
|
debug,
|
|
37
41
|
});
|
|
38
42
|
debug({ responseA });
|
|
@@ -48,6 +52,7 @@ export const verifyDevice = async ({
|
|
|
48
52
|
challengeParameters: responseA.ChallengeParameters,
|
|
49
53
|
deviceKey,
|
|
50
54
|
deviceGroupKey,
|
|
55
|
+
clientMetadata,
|
|
51
56
|
debug,
|
|
52
57
|
});
|
|
53
58
|
debug({ responseB });
|
package/src/login/verify-srp.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { respondPasswordVerifier } from "../cognito";
|
|
2
|
+
import { TClientMetadata } from "../cognito/cognito-fetch";
|
|
2
3
|
import { TSRPChallengeParameters } from "../cognito/types";
|
|
3
4
|
import { calculateClaimSig } from "../srp";
|
|
4
5
|
import { stripPoolRegion, noop } from "../util";
|
|
@@ -13,6 +14,7 @@ type TVerifySrp = {
|
|
|
13
14
|
challengeParameters: TSRPChallengeParameters;
|
|
14
15
|
deviceKey: string | undefined;
|
|
15
16
|
deviceGroupKey: string | undefined;
|
|
17
|
+
clientMetadata?: TClientMetadata;
|
|
16
18
|
debug?: (trace: any) => void;
|
|
17
19
|
};
|
|
18
20
|
|
|
@@ -26,6 +28,7 @@ export const verifySrp = async ({
|
|
|
26
28
|
challengeParameters,
|
|
27
29
|
deviceKey,
|
|
28
30
|
deviceGroupKey,
|
|
31
|
+
clientMetadata,
|
|
29
32
|
debug = noop,
|
|
30
33
|
}: TVerifySrp) => {
|
|
31
34
|
const groupId =
|
|
@@ -54,6 +57,7 @@ export const verifySrp = async ({
|
|
|
54
57
|
claimSig,
|
|
55
58
|
challengeParameters,
|
|
56
59
|
challengeName,
|
|
60
|
+
clientMetadata,
|
|
57
61
|
debug,
|
|
58
62
|
});
|
|
59
63
|
};
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
} from "../../util";
|
|
7
7
|
import { hashSha256 } from "../../crypto";
|
|
8
8
|
|
|
9
|
-
export const hashHex = async (hex: string) =>
|
|
10
|
-
uint8ToHex(abufToUint8(await hashSha256(hexToUint8(hex))));
|
|
9
|
+
export const hashHex = async (hex: string) => uint8ToHex(abufToUint8(await hashSha256(hexToUint8(hex))));
|
|
11
10
|
|
|
12
|
-
export const hashUtf8 = async (utf8: string) =>
|
|
13
|
-
uint8ToHex(abufToUint8(await hashSha256(codePointToUint8(utf8))));
|
|
11
|
+
export const hashUtf8 = async (utf8: string) => uint8ToHex(abufToUint8(await hashSha256(codePointToUint8(utf8))));
|
|
@@ -17,11 +17,9 @@ export const aCreate = async () => hexToBigInt(uint8ToHex(getRandomValues(32)));
|
|
|
17
17
|
|
|
18
18
|
export const A = async ({ a }: TBigIntRecord<"a">) => modPow(g, a, N);
|
|
19
19
|
|
|
20
|
-
export const k = async () =>
|
|
21
|
-
hexToBigInt(await hashHex(`00${bigIntToHex(N)}0${bigIntToHex(g)}`));
|
|
20
|
+
export const k = async () => hexToBigInt(await hashHex(`00${bigIntToHex(N)}0${bigIntToHex(g)}`));
|
|
22
21
|
|
|
23
|
-
export const u = async ({ A, B }: TBigIntRecord<"A" | "B">) =>
|
|
24
|
-
hexToBigInt(await hashHex(padHex(A) + padHex(B)));
|
|
22
|
+
export const u = async ({ A, B }: TBigIntRecord<"A" | "B">) => hexToBigInt(await hashHex(padHex(A) + padHex(B)));
|
|
25
23
|
|
|
26
24
|
export const S = async ({
|
|
27
25
|
u,
|