-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support device SRP challenge (#44)
* wip * initial working demo * logic to handle device SRP * unit tests for device srp flow * initial working integration test for device srp flow (at least for sdk v3) * initial working integrations tests * update docs * fix access to gh secrets * eslint formatting * rm demo package * mv totp-generator from dependencies to dev-dependencies since its only used in tests
- Loading branch information
1 parent
284326a
commit ce195c3
Showing
22 changed files
with
2,923 additions
and
492 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,9 +1,7 @@ | ||
name: test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { CognitoIdentityProviderClient, SignUpCommand } from "@aws-sdk/client-cognito-identity-provider"; | ||
import { CognitoIdentityServiceProvider } from "aws-sdk"; | ||
|
||
import { createSecretHash } from "../../cognito-srp-helper"; | ||
|
||
type SignupOptionsV2 = { | ||
username: string; | ||
password: string; | ||
cognitoIdentityServiceProvider: CognitoIdentityServiceProvider; | ||
clientId: string; | ||
secretId: string; | ||
}; | ||
|
||
export const signupV2 = async (options: SignupOptionsV2) => { | ||
const { username, password, cognitoIdentityServiceProvider, clientId, secretId } = options; | ||
const secretHash = createSecretHash(username, clientId, secretId); | ||
|
||
return cognitoIdentityServiceProvider | ||
.signUp({ | ||
ClientId: clientId, | ||
Username: username, | ||
Password: password, | ||
SecretHash: secretHash, | ||
}) | ||
.promise(); | ||
}; | ||
|
||
type SignupOptionsV3 = { | ||
username: string; | ||
password: string; | ||
cognitoIdentityProviderClient: CognitoIdentityProviderClient; | ||
clientId: string; | ||
secretId: string; | ||
}; | ||
|
||
export const signupV3 = async (options: SignupOptionsV3) => { | ||
const { username, password, cognitoIdentityProviderClient, clientId, secretId } = options; | ||
const secretHash = createSecretHash(username, clientId, secretId); | ||
|
||
await cognitoIdentityProviderClient | ||
.send( | ||
// There's a pre-signup trigger to auto-confirm new users, so no need to Confirm post signup | ||
new SignUpCommand({ | ||
ClientId: clientId, | ||
Username: username, | ||
Password: password, | ||
SecretHash: secretHash, | ||
}), | ||
) | ||
.catch((err) => { | ||
throw err; | ||
}); | ||
}; |
Oops, something went wrong.