Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cognito-gateway
Advanced tools
import cognitoGateway from 'cognito-gateway';
export const {
signIn,
signUp,
signOutGlobal,
signUpConfirm,
signUpConfirmResend,
refreshToken,
changePassword,
forgotPasswordRequest,
forgotPasswordConfirm,
userGet,
userDelete
} from cognitoGateway({
headers: {
'Access-Control-Allow-Origin': '*'
},
preSignIn: (requestBody) => requestBody, // custom pre auth logic
postSignIn: (responseBody) => responseBody, // custom post auth logic
// more hooks
});
headers
: Object<string, string>
An object containing any headers to be added to the http response.
Hooks are called at various points throughout the signup and authentication process. They can be used to add custom authentication or perform additional actions in response to authentication or signup. All hooks are async so you can return a promise. The promise should resolve to an object in the same structure as the request or response body. If the promise is rejected or an error is thrown during the hook execution then cognitoGateway will create a http response from the err.statusCode
and err.message
properies of the promise rejection payload or thrown error.
The available hooks are:
preSignIn(
requestBody: {
username: string,
password: string
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postSignIn(
error: ?GromitError,
responseBody: ?{
accessToken: string,
refreshToken: string,
idToken: string,
time: number
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preSignUp(
requestBody: {
username: string,
password: string,
attributes: Object
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postSignUp(
error: ?GromitError,
responseBody: ?{
user: {
username: string,
attributes: Object
}
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preSignOutGlobal(
requestBody: {},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postSignOutGlobal(
error: ?GromitError,
responseBody: ?{status: 'success'},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preSignUpConfirm(
requestBody: {
username: string,
verificationCode: string
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postSignUpConfirm(
error: ?GromitError,
responseBody: ?{status: 'success'},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preSignUpConfirmResend(
requestBody: {
username: string
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postSignUpConfirmResend(
error: ?GromitError,
responseBody: ?{status: 'success'},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preRefreshToken(
requestBody: {refreshToken: string},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postRefreshToken(
error: ?GromitError,
responseBody: ?{
accessToken: string,
idToken: string
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preChangePassword(
requestBody: {
password: string,
newPassword: string,
accessToken: string
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postChangePassword(
error: ?GromitError,
responseBody: ?{status: 'success'},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preForgotPasswordRequest(
requestBody: {
username: string
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postForgotPasswordRequest(
error: ?GromitError,
responseBody: ?{status: 'success'},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preForgotPasswordConfirm(
requestBody: {
username: string,
confirmationCode: string,
password: string
},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postForgotPasswordConfirm(
error: ?GromitError,
responseBody: ?{status: 'success'},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preUserGet(
requestBody: {},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postUserGet(
error: ?GromitError,
responseBody: ?{status: 'success'},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
preUserDelete(
requestBody: {},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<requestBody>
postUserDelete(
error: ?GromitError,
responseBody: ?{status: 'success'},
httpEvent: AWSLambdaEvent,
lambdaContext: AWSLambdaContext
) => Promise<responseBody>
Request a set of tokens via a username and password
path: /signIn
method: post
requestBody:
username: string
password: string
responseBody:
accessToken: string
refreshToken: string
idToken: string
time: int
Request a new access and id token via a refresh token
path: /refreshToken
method: post
requestBody:
refreshToken: string
responseBody:
accessToken: string
idToken: string
Sign a user out from all services.
path: /signOutGlobal
method: post
headers:
Authorization: 'Bearer {accessToken}'
responseBody:
status: string
Request the creation of a new user
path: /signUp
method: post
requestBody:
username: string
password: string
attributes: array
responseBody:
user: cognitoUser
verificationAttribute: string
verificationMedium: string
verificationValue: string
Confirm a user via a verification code
path: /signUpConfirm
method: post
requestBody:
username: string
verificationCode: string
responseBody:
status: string
Request a new verification code via username
path: /signUpConfirmResend
method: post
requestBody:
username: string
responseBody:
verificationAttribute: string
verificationMedium: string
verificationValue: string
Request user information via a token
path: /user
method: get
headers:
Authorization: 'Bearer {accessToken}'
responseBody: CognitoUser
Delete a user via a token
path: /user
method: delete
headers:
Authorization: 'Bearer {accessToken}'
responseBody:
status: string
FAQs
A gateway lambda for dealing with cognito apis
We found that cognito-gateway demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.