Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event type for cognito CustomMessage
These events are used when running a lambda for customizing the SMS / Email sent out during user signup, password reset, etc.
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 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
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,88 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
from typing import Literal | ||
|
||
if sys.version_info >= (3, 8): | ||
from typing import Dict, Optional, TypedDict | ||
else: | ||
from typing import Dict, Optional | ||
|
||
from typing_extensions import TypedDict | ||
|
||
|
||
class CognitoCustomMessageCallerContext(TypedDict): | ||
""" | ||
CognitoCustomMessageCallerContext | ||
Attributes: | ||
----------: | ||
awsSdk: str | ||
clientId: str | ||
""" | ||
|
||
awsSdk: str | ||
clientId: str | ||
|
||
|
||
class CognitoCustomMessageRequestUserAttributes(TypedDict): | ||
""" | ||
CognitoCustomMessageRequestUserAttributes | ||
Attributes: | ||
----------: | ||
phone_number_verified: bool | ||
email_verified: bool | ||
""" | ||
|
||
phone_number_verified: bool | ||
email_verified: bool | ||
|
||
|
||
class CognitoCustomMessageRequest(TypedDict): | ||
""" | ||
CognitoCustomMessageRequest | ||
Attributes: | ||
----------: | ||
userAttributes: CognitoCustomMessageRequestUserAttributes | ||
""" | ||
|
||
|
||
class CognitoCustomMessageResponse(TypedDict): | ||
""" | ||
CognitoCustomMessageResponse | ||
Attributes: | ||
----------: | ||
userAttributes: CognitoCustomMessageRequestUserAttributes | ||
""" | ||
|
||
smsMessage: str | ||
emailMessage: str | ||
emailSubject: str | ||
|
||
|
||
class CognitoCustomMessage(TypedDict): | ||
""" | ||
CognitoCustomMessage | ||
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html | ||
Attributes: | ||
---------- | ||
triggerSource: str | ||
""" | ||
|
||
version: int | ||
triggerSource: Literal[ | ||
"CustomMessage_SignUp", | ||
"CustomMessage_ResendCode", | ||
"CustomMessage_ForgotPassword", | ||
"CustomMessage_VerifyUserAttribute", | ||
] | ||
region: str | ||
userPoolId: str | ||
userName: str | ||
callerContext: CognitoCustomMessageCallerContext | ||
request: CognitoCustomMessageRequest | ||
response: CognitoCustomMessageResponse |
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,27 @@ | ||
from aws_lambda_typing.events import CognitoCustomMessage | ||
|
||
|
||
def test_cognito_custom_message_event() -> None: | ||
event: CognitoCustomMessage = { | ||
"version": 1, | ||
"triggerSource": "CustomMessage_SignUp", | ||
"region": "us-west-2", | ||
"userPoolId": "poolid", | ||
"userName": "userName", | ||
"callerContext": { | ||
"awsSdk": "1", | ||
"clientId": "jkSDFasdfnsq", | ||
}, | ||
"request": { | ||
"userAttributes": { | ||
"phone_number_verified": False, | ||
"email_verified": True, | ||
}, | ||
"codeParameter": "####", | ||
}, | ||
"response": { | ||
"smsMessage": "<custom message to be sent in the message with code parameter>", | ||
"emailMessage": "<custom message to be sent in the message with code parameter>", | ||
"emailSubject": "<custom email subject>", | ||
}, | ||
} |