├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── amplify ├── .config │ └── project-config.json └── backend │ ├── api │ └── allamplifychatt │ │ ├── build │ │ ├── resolvers │ │ │ ├── Conversation.associated.request │ │ │ ├── Conversation.associated.response │ │ │ ├── Conversation.messages.request │ │ │ ├── Conversation.messages.response │ │ │ ├── ConvoLink.conversation.request │ │ │ ├── ConvoLink.conversation.response │ │ │ ├── ConvoLink.user.request │ │ │ ├── ConvoLink.user.response │ │ │ ├── Message.author.request │ │ │ ├── Message.author.response │ │ │ ├── Message.conversation.request │ │ │ ├── Message.conversation.response │ │ │ ├── Mutation.createConvo.request │ │ │ ├── Mutation.createConvo.response │ │ │ ├── Mutation.createConvoLink.request │ │ │ ├── Mutation.createConvoLink.response │ │ │ ├── Mutation.createMessage.request │ │ │ ├── Mutation.createMessage.response │ │ │ ├── Mutation.createUser.request │ │ │ ├── Mutation.createUser.response │ │ │ ├── Mutation.deleteMessage.request │ │ │ ├── Mutation.deleteMessage.response │ │ │ ├── Mutation.deleteUser.request │ │ │ ├── Mutation.deleteUser.response │ │ │ ├── Mutation.updateConvoLink.request │ │ │ ├── Mutation.updateConvoLink.response │ │ │ ├── Mutation.updateMessage.request │ │ │ ├── Mutation.updateMessage.response │ │ │ ├── Mutation.updateUser.request │ │ │ ├── Mutation.updateUser.response │ │ │ ├── Query.getConvo.request │ │ │ ├── Query.getConvo.response │ │ │ ├── Query.getUser.request │ │ │ ├── Query.getUser.response │ │ │ ├── Query.listUsers.request │ │ │ ├── Query.listUsers.response │ │ │ ├── User.conversations.request │ │ │ ├── User.conversations.response │ │ │ ├── User.messages.request │ │ │ └── User.messages.response │ │ └── schema.graphql │ │ ├── cloudformation-template.json │ │ ├── parameters.json │ │ └── schema.graphql │ ├── auth │ └── auth │ │ ├── auth-cloudformation-template.yml │ │ └── parameters.json │ └── backend-config.json ├── package.json ├── public ├── favicon.ico ├── index.html └── manifest.json └── src ├── App.js ├── App.test.js ├── Router.js ├── Routes.js ├── assets ├── chattlogo.png ├── hero1.jpg └── hero2.jpg ├── components ├── Conversation.js ├── Conversations.js ├── Footer.js ├── Header.js ├── Loading.js ├── Overlay.js ├── Profile.js └── Users.js ├── graphql.js ├── graphql ├── mutations.js ├── queries.js ├── schema.json └── subscriptions.js ├── index.css ├── index.js ├── logo.svg ├── mobx └── UserStore.js ├── serviceWorker.js └── theme.js /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | #amplify 26 | amplify/\#current-cloud-backend 27 | amplify/.config/local-* 28 | amplify/backend/amplify-meta.json 29 | aws-exports.js 30 | awsconfiguration.json 31 | amplify/team-provider-info.json 32 | src/aws-exports.js 33 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check [existing open](https://github.com/aws-samples/aws-appsync-chat/issues), or [recently closed](https://github.com/aws-samples/aws-appsync-chat/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws-samples/aws-appsync-chat/labels/help%20wanted) issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](https://github.com/aws-samples/aws-appsync-chat/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. 62 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | AWS AppSync Chat 2 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |  2 | 3 | ## Chatt 4 | 5 | Real-Time Offline Ready Chat App written with GraphQL, AWS AppSync, & AWS Amplify 6 | 7 | ## Features 8 | 9 | - User management 10 | - Routing (React Router) 11 | - Real-time 12 | - Offline ready (conflict resolution handled for you when user comes back online) 13 | 14 | ## Technologies 15 | 16 | - AWS AppSync 17 | - AWS Amplify 18 | - GraphQL 19 | - MobX 20 | - React Router 21 | - React Apollo 22 | - Glamor 23 | 24 | ## Screens 25 | 26 |  27 | 28 | ## Building the App (automated) 29 | 30 | This project contains an Amplify project (`/amplify`) already configured & ready to be deployed. Deploying this project will create the following resources in your account: an authentication configuration using Amazon Cognito, an AWS AppSync GraphQL API, & a DynamoDB table. 31 | 32 | 1. Make sure you are on the newest version of the AWS Amplify CLI 33 | 34 | ```sh 35 | npm install -g @aws-amplify/cli 36 | ``` 37 | 38 | > You must also have the CLI configured with a user from your AWS account (`amplify configure`). For a walkthrough of how to do this, check out [this](https://www.youtube.com/watch?v=fWbM5DLh25U) video. 39 | 40 | 2. Clone Chatt 41 | 42 | ```sh 43 | git clone https://github.com/aws-samples/aws-appsync-chat.git 44 | ``` 45 | 46 | 3. Install dependencies 47 | 48 | ```sh 49 | npm install 50 | ``` 51 | 52 | 4. Initialize the amplify project 53 | 54 | ```sh 55 | amplify init 56 | ``` 57 | - Enter a name for the environment __master__ 58 | 59 | 5. Push the new resources to the cloud 60 | 61 | ```sh 62 | amplify push 63 | ``` 64 | 65 | 6. Run the project 66 | 67 | ```sh 68 | npm start 69 | ``` 70 | 71 | 7. Deleting the project resources 72 | 73 | If you'd like to tear down the project & delete all of the resources created by this project, run the `delete` command. 74 | 75 | ```sh 76 | amplify delete 77 | ``` 78 | 79 | 80 | ## Building the App (manually) 81 | 82 | You can also manually set up your resources if you would like. If you would like to manually create & configure the resources for this project, follow these steps: 83 | 84 | 1. Install & configure the Amplify CLI 85 | 86 | ```sh 87 | npm install -g @aws-amplify 88 | 89 | amplify configure 90 | ``` 91 | 92 | 2. Clone Chatt 93 | 94 | ```sh 95 | git clone https://github.com/aws-samples/aws-appsync-chat.git 96 | ``` 97 | 98 | 3. Install dependencies 99 | 100 | ```sh 101 | npm install 102 | ``` 103 | 104 | 4. Delete the amplify folder 105 | 106 | 5. Initialize a new Amplify project 107 | 108 | ```sh 109 | amplify init 110 | ``` 111 | 112 | 6. Add authentication 113 | 114 | ```sh 115 | amplify add auth 116 | ``` 117 | 118 | > Here, either choose the default security choice or configure your own. 119 | 120 | 7. Add the api 121 | 122 | ```sh 123 | amplify add api 124 | ``` 125 | 126 | > Choose Cognito User Pools as the authentication type. 127 | > When prompted for the GraphQL schema, use the following schema: 128 | 129 | ```graphql 130 | type User 131 | @model 132 | @auth(rules: [{ allow: owner, ownerField: "id", queries: null }]) { 133 | id: ID! 134 | username: String! 135 | conversations: [ConvoLink] @connection(name: "UserLinks") 136 | messages: [Message] @connection(name: "UserMessages") 137 | createdAt: String 138 | updatedAt: String 139 | } 140 | 141 | type Conversation 142 | @model( 143 | mutations: { create: "createConvo" } 144 | queries: { get: "getConvo" } 145 | subscriptions: null 146 | ) 147 | @auth(rules: [{ allow: owner, ownerField: "members" }]) { 148 | id: ID! 149 | messages: [Message] @connection(name: "ConvoMsgs", sortField: "createdAt") 150 | associated: [ConvoLink] @connection(name: "AssociatedLinks") 151 | name: String! 152 | members: [String!]! 153 | createdAt: String 154 | updatedAt: String 155 | } 156 | 157 | type Message 158 | @model(subscriptions: null, queries: null) 159 | @auth(rules: [{ allow: owner, ownerField: "authorId" }]) { 160 | id: ID! 161 | author: User @connection(name: "UserMessages", keyField: "authorId") 162 | authorId: String 163 | content: String! 164 | conversation: Conversation! @connection(name: "ConvoMsgs") 165 | messageConversationId: ID! 166 | createdAt: String 167 | updatedAt: String 168 | } 169 | 170 | type ConvoLink 171 | @model( 172 | mutations: { create: "createConvoLink", update: "updateConvoLink" } 173 | queries: null 174 | subscriptions: null 175 | ) { 176 | id: ID! 177 | user: User! @connection(name: "UserLinks") 178 | convoLinkUserId: ID 179 | conversation: Conversation! @connection(name: "AssociatedLinks") 180 | convoLinkConversationId: ID! 181 | createdAt: String 182 | updatedAt: String 183 | } 184 | 185 | type Subscription { 186 | onCreateConvoLink(convoLinkUserId: ID!): ConvoLink 187 | @aws_subscribe(mutations: ["createConvoLink"]) 188 | onCreateMessage(messageConversationId: ID!): Message 189 | @aws_subscribe(mutations: ["createMessage"]) 190 | } 191 | ``` 192 | 193 | 8. Run the `push` command to create the resources in your account: 194 | 195 | ```sh 196 | amplify push 197 | ``` 198 | 199 | 9. Run the project 200 | 201 | ```sh 202 | npm start 203 | ``` 204 | 205 | 10. Deleting the project resources 206 | 207 | If you'd like to tear down the project & delete all of the resources created by this project, run the `delete` command. 208 | 209 | ```sh 210 | amplify delete 211 | ``` 212 | 213 | ## Hosting with the AWS Amplify Console 214 | 215 | The [AWS Amplify Console](https://console.amplify.aws) provides continuous deployment and hosting for modern web apps (single page apps and static site generators) with serverless backends. Continuous deployment allows developers to deploy updates to either the frontend or backend (Lambda functions, GraphQL resolvers) on every code commit to the Git repository. 216 | 217 | 1. Push your code to a Git repository of your choice. 218 | 1. Login to the [AWS Amplify Console](https://console.aws.amazon.com/amplify/home) and choose **Connect app** 219 | 1. Connect your repository and branch. 220 | 1. Accept the default build settings. 221 | 1. Give the Amplify Console permission to deploy backend resources with your frontend. This will allow the Console to detect changes to your backend on every code commit. If you do not have a service role, follow the prompts to create one. 222 | 1. Review your changes and then choose **Save and deploy**. You app will now be available at `https://master.unique-id.amplifyapp.com`. 223 | 224 | ## About 225 | 226 | ### Schema 227 | 228 | This application utilizes 4 database tables: 229 | 230 | - User table (stores user's identity information) 231 | - Conversation table (stores conversations) 232 | - Messages table (stores messages) 233 | - ConvoLinkTable (stores relations between conversations & users) 234 | 235 | ## License 236 | 237 | This library is licensed under the Apache 2.0 License. 238 | -------------------------------------------------------------------------------- /amplify/.config/project-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "chatt", 3 | "version": "1.0", 4 | "frontend": "javascript", 5 | "javascript": { 6 | "framework": "react", 7 | "config": { 8 | "SourceDir": "src", 9 | "DistributionDir": "build", 10 | "BuildCommand": "npm run-script build", 11 | "StartCommand": "npm run-script start" 12 | } 13 | }, 14 | "providers": [ 15 | "awscloudformation" 16 | ] 17 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Conversation.associated.request: -------------------------------------------------------------------------------- 1 | #set( $limit = $util.defaultIfNull($context.args.limit, 10) ) 2 | { 3 | "version": "2017-02-28", 4 | "operation": "Query", 5 | "query": { 6 | "expression": "#connectionAttribute = :connectionAttribute", 7 | "expressionNames": { 8 | "#connectionAttribute": "convoLinkConversationId" 9 | }, 10 | "expressionValues": { 11 | ":connectionAttribute": { 12 | "S": "$context.source.id" 13 | } 14 | } 15 | }, 16 | "scanIndexForward": #if( $context.args.sortDirection ) 17 | #if( $context.args.sortDirection == "ASC" ) 18 | true 19 | #else 20 | false 21 | #end 22 | #else 23 | true 24 | #end, 25 | "filter": #if( $context.args.filter ) 26 | $util.transform.toDynamoDBFilterExpression($ctx.args.filter) 27 | #else 28 | null 29 | #end, 30 | "limit": $limit, 31 | "nextToken": #if( $context.args.nextToken ) 32 | "$context.args.nextToken" 33 | #else 34 | null 35 | #end, 36 | "index": "gsi-AssociatedLinks" 37 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Conversation.associated.response: -------------------------------------------------------------------------------- 1 | #if( !$result ) 2 | #set( $result = $ctx.result ) 3 | #end 4 | $util.toJson($result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Conversation.messages.request: -------------------------------------------------------------------------------- 1 | #set( $limit = $util.defaultIfNull($context.args.limit, 10) ) 2 | { 3 | "version": "2017-02-28", 4 | "operation": "Query", 5 | "query": { 6 | "expression": "#connectionAttribute = :connectionAttribute", 7 | "expressionNames": { 8 | "#connectionAttribute": "messageConversationId" 9 | }, 10 | "expressionValues": { 11 | ":connectionAttribute": { 12 | "S": "$context.source.id" 13 | } 14 | } 15 | }, 16 | "scanIndexForward": #if( $context.args.sortDirection ) 17 | #if( $context.args.sortDirection == "ASC" ) 18 | true 19 | #else 20 | false 21 | #end 22 | #else 23 | true 24 | #end, 25 | "filter": #if( $context.args.filter ) 26 | $util.transform.toDynamoDBFilterExpression($ctx.args.filter) 27 | #else 28 | null 29 | #end, 30 | "limit": $limit, 31 | "nextToken": #if( $context.args.nextToken ) 32 | "$context.args.nextToken" 33 | #else 34 | null 35 | #end, 36 | "index": "gsi-ConvoMsgs" 37 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Conversation.messages.response: -------------------------------------------------------------------------------- 1 | #if( !$result ) 2 | #set( $result = $ctx.result ) 3 | #end 4 | $util.toJson($result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/ConvoLink.conversation.request: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2017-02-28", 3 | "operation": "GetItem", 4 | "key": { 5 | "id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.convoLinkConversationId, "___xamznone____")) 6 | } 7 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/ConvoLink.conversation.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/ConvoLink.user.request: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2017-02-28", 3 | "operation": "GetItem", 4 | "key": { 5 | "id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.convoLinkUserId, "___xamznone____")) 6 | } 7 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/ConvoLink.user.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Message.author.request: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2017-02-28", 3 | "operation": "GetItem", 4 | "key": { 5 | "id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.authorId, "___xamznone____")) 6 | } 7 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Message.author.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Message.conversation.request: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2017-02-28", 3 | "operation": "GetItem", 4 | "key": { 5 | "id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.messageConversationId, "___xamznone____")) 6 | } 7 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Message.conversation.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.createConvo.request: -------------------------------------------------------------------------------- 1 | ## No Static Group Authorization Rules ** 2 | 3 | 4 | ## No Dynamic Group Authorization Rules ** 5 | 6 | 7 | ## [Start] Owner Authorization Checks ** 8 | #set( $isOwnerAuthorized = false ) 9 | ## Authorization rule: { allow: "owner", ownerField: "members", identityField: "cognito:username" } ** 10 | #set( $allowedOwners0 = $util.defaultIfNull($ctx.args.input.members, null) ) 11 | #set( $identityValue = $util.defaultIfNull($ctx.identity.claims.get("username"), $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____")) ) 12 | #if( $util.isList($allowedOwners0) ) 13 | #foreach( $allowedOwner in $allowedOwners0 ) 14 | #if( $allowedOwner == $identityValue ) 15 | #set( $isOwnerAuthorized = true ) 16 | #end 17 | #end 18 | #end 19 | #if( $util.isString($allowedOwners0) ) 20 | #if( $allowedOwners0 == $identityValue ) 21 | #set( $isOwnerAuthorized = true ) 22 | #end 23 | #end 24 | #if( $util.isNull($allowedOwners0) && (! $ctx.args.input.containsKey("members")) ) 25 | $util.qr($ctx.args.input.put("members", ["$identityValue"])) 26 | #set( $isOwnerAuthorized = true ) 27 | #end 28 | ## [End] Owner Authorization Checks ** 29 | 30 | 31 | ## [Start] Throw if unauthorized ** 32 | #if( !($isStaticGroupAuthorized == true || $isDynamicGroupAuthorized == true || $isOwnerAuthorized == true) ) 33 | $util.unauthorized() 34 | #end 35 | ## [End] Throw if unauthorized ** 36 | 37 | ## [Start] Prepare DynamoDB PutItem Request. ** 38 | $util.qr($context.args.input.put("createdAt", $util.time.nowISO8601())) 39 | $util.qr($context.args.input.put("updatedAt", $util.time.nowISO8601())) 40 | $util.qr($context.args.input.put("__typename", "Conversation")) 41 | { 42 | "version": "2017-02-28", 43 | "operation": "PutItem", 44 | "key": { 45 | "id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.args.input.id, $util.autoId())) 46 | }, 47 | "attributeValues": $util.dynamodb.toMapValuesJson($context.args.input), 48 | "condition": { 49 | "expression": "attribute_not_exists(#id)", 50 | "expressionNames": { 51 | "#id": "id" 52 | } 53 | } 54 | } 55 | ## [End] Prepare DynamoDB PutItem Request. ** -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.createConvo.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.createConvoLink.request: -------------------------------------------------------------------------------- 1 | ## [Start] Prepare DynamoDB PutItem Request. ** 2 | $util.qr($context.args.input.put("createdAt", $util.time.nowISO8601())) 3 | $util.qr($context.args.input.put("updatedAt", $util.time.nowISO8601())) 4 | $util.qr($context.args.input.put("__typename", "ConvoLink")) 5 | { 6 | "version": "2017-02-28", 7 | "operation": "PutItem", 8 | "key": { 9 | "id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.args.input.id, $util.autoId())) 10 | }, 11 | "attributeValues": $util.dynamodb.toMapValuesJson($context.args.input), 12 | "condition": { 13 | "expression": "attribute_not_exists(#id)", 14 | "expressionNames": { 15 | "#id": "id" 16 | } 17 | } 18 | } 19 | ## [End] Prepare DynamoDB PutItem Request. ** -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.createConvoLink.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.createMessage.request: -------------------------------------------------------------------------------- 1 | ## No Static Group Authorization Rules ** 2 | 3 | 4 | ## No Dynamic Group Authorization Rules ** 5 | 6 | 7 | ## [Start] Owner Authorization Checks ** 8 | #set( $isOwnerAuthorized = false ) 9 | ## Authorization rule: { allow: "owner", ownerField: "authorId", identityField: "cognito:username" } ** 10 | #set( $allowedOwners0 = $util.defaultIfNull($ctx.args.input.authorId, null) ) 11 | #set( $identityValue = $util.defaultIfNull($ctx.identity.claims.get("username"), $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____")) ) 12 | #if( $util.isList($allowedOwners0) ) 13 | #foreach( $allowedOwner in $allowedOwners0 ) 14 | #if( $allowedOwner == $identityValue ) 15 | #set( $isOwnerAuthorized = true ) 16 | #end 17 | #end 18 | #end 19 | #if( $util.isString($allowedOwners0) ) 20 | #if( $allowedOwners0 == $identityValue ) 21 | #set( $isOwnerAuthorized = true ) 22 | #end 23 | #end 24 | #if( $util.isNull($allowedOwners0) && (! $ctx.args.input.containsKey("authorId")) ) 25 | $util.qr($ctx.args.input.put("authorId", $identityValue)) 26 | #set( $isOwnerAuthorized = true ) 27 | #end 28 | ## [End] Owner Authorization Checks ** 29 | 30 | 31 | ## [Start] Throw if unauthorized ** 32 | #if( !($isStaticGroupAuthorized == true || $isDynamicGroupAuthorized == true || $isOwnerAuthorized == true) ) 33 | $util.unauthorized() 34 | #end 35 | ## [End] Throw if unauthorized ** 36 | 37 | ## [Start] Prepare DynamoDB PutItem Request. ** 38 | $util.qr($context.args.input.put("createdAt", $util.time.nowISO8601())) 39 | $util.qr($context.args.input.put("updatedAt", $util.time.nowISO8601())) 40 | $util.qr($context.args.input.put("__typename", "Message")) 41 | { 42 | "version": "2017-02-28", 43 | "operation": "PutItem", 44 | "key": { 45 | "id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.args.input.id, $util.autoId())) 46 | }, 47 | "attributeValues": $util.dynamodb.toMapValuesJson($context.args.input), 48 | "condition": { 49 | "expression": "attribute_not_exists(#id)", 50 | "expressionNames": { 51 | "#id": "id" 52 | } 53 | } 54 | } 55 | ## [End] Prepare DynamoDB PutItem Request. ** -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.createMessage.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.createUser.request: -------------------------------------------------------------------------------- 1 | ## No Static Group Authorization Rules ** 2 | 3 | 4 | ## No Dynamic Group Authorization Rules ** 5 | 6 | 7 | ## [Start] Owner Authorization Checks ** 8 | #set( $isOwnerAuthorized = false ) 9 | ## Authorization rule: { allow: "owner", ownerField: "id", identityField: "cognito:username" } ** 10 | #set( $allowedOwners0 = $util.defaultIfNull($ctx.args.input.id, null) ) 11 | #set( $identityValue = $util.defaultIfNull($ctx.identity.claims.get("username"), $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____")) ) 12 | #if( $util.isList($allowedOwners0) ) 13 | #foreach( $allowedOwner in $allowedOwners0 ) 14 | #if( $allowedOwner == $identityValue ) 15 | #set( $isOwnerAuthorized = true ) 16 | #end 17 | #end 18 | #end 19 | #if( $util.isString($allowedOwners0) ) 20 | #if( $allowedOwners0 == $identityValue ) 21 | #set( $isOwnerAuthorized = true ) 22 | #end 23 | #end 24 | #if( $util.isNull($allowedOwners0) && (! $ctx.args.input.containsKey("id")) ) 25 | $util.qr($ctx.args.input.put("id", $identityValue)) 26 | #set( $isOwnerAuthorized = true ) 27 | #end 28 | ## [End] Owner Authorization Checks ** 29 | 30 | 31 | ## [Start] Throw if unauthorized ** 32 | #if( !($isStaticGroupAuthorized == true || $isDynamicGroupAuthorized == true || $isOwnerAuthorized == true) ) 33 | $util.unauthorized() 34 | #end 35 | ## [End] Throw if unauthorized ** 36 | 37 | ## [Start] Prepare DynamoDB PutItem Request. ** 38 | $util.qr($context.args.input.put("createdAt", $util.time.nowISO8601())) 39 | $util.qr($context.args.input.put("updatedAt", $util.time.nowISO8601())) 40 | $util.qr($context.args.input.put("__typename", "User")) 41 | { 42 | "version": "2017-02-28", 43 | "operation": "PutItem", 44 | "key": { 45 | "id": $util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.args.input.id, $util.autoId())) 46 | }, 47 | "attributeValues": $util.dynamodb.toMapValuesJson($context.args.input), 48 | "condition": { 49 | "expression": "attribute_not_exists(#id)", 50 | "expressionNames": { 51 | "#id": "id" 52 | } 53 | } 54 | } 55 | ## [End] Prepare DynamoDB PutItem Request. ** -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.createUser.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.deleteMessage.request: -------------------------------------------------------------------------------- 1 | ## No Static Group Authorization Rules ** 2 | 3 | 4 | #if( ! $isStaticGroupAuthorized ) 5 | ## No Dynamic Group Authorization Rules ** 6 | 7 | 8 | ## [Start] Owner Authorization Checks ** 9 | #set( $ownerAuthExpressions = [] ) 10 | #set( $ownerAuthExpressionValues = {} ) 11 | #set( $ownerAuthExpressionNames = {} ) 12 | ## Authorization rule: { allow: "owner", ownerField: "authorId", identityField: "cognito:username" } ** 13 | $util.qr($ownerAuthExpressions.add("#owner0 = :identity0")) 14 | $util.qr($ownerAuthExpressionNames.put("#owner0", "authorId")) 15 | $util.qr($ownerAuthExpressionValues.put(":identity0", $util.dynamodb.toDynamoDB($util.defaultIfNull($ctx.identity.claims.get("username"), $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____"))))) 16 | ## [End] Owner Authorization Checks ** 17 | 18 | 19 | ## [Start] Collect Auth Condition ** 20 | #set( $authCondition = { 21 | "expression": "", 22 | "expressionNames": {}, 23 | "expressionValues": {} 24 | } ) 25 | #set( $totalAuthExpression = "" ) 26 | ## Add dynamic group auth conditions if they exist ** 27 | #if( $groupAuthExpressions ) 28 | #foreach( $authExpr in $groupAuthExpressions ) 29 | #set( $totalAuthExpression = "$totalAuthExpression $authExpr" ) 30 | #if( $foreach.hasNext ) 31 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 32 | #end 33 | #end 34 | #end 35 | #if( $groupAuthExpressionNames ) 36 | $util.qr($authCondition.expressionNames.putAll($groupAuthExpressionNames)) 37 | #end 38 | #if( $groupAuthExpressionValues ) 39 | $util.qr($authCondition.expressionValues.putAll($groupAuthExpressionValues)) 40 | #end 41 | ## Add owner auth conditions if they exist ** 42 | #if( $totalAuthExpression != "" && $ownerAuthExpressions && $ownerAuthExpressions.size() > 0 ) 43 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 44 | #end 45 | #if( $ownerAuthExpressions ) 46 | #foreach( $authExpr in $ownerAuthExpressions ) 47 | #set( $totalAuthExpression = "$totalAuthExpression $authExpr" ) 48 | #if( $foreach.hasNext ) 49 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 50 | #end 51 | #end 52 | #end 53 | #if( $ownerAuthExpressionNames ) 54 | $util.qr($authCondition.expressionNames.putAll($ownerAuthExpressionNames)) 55 | #end 56 | #if( $ownerAuthExpressionValues ) 57 | $util.qr($authCondition.expressionValues.putAll($ownerAuthExpressionValues)) 58 | #end 59 | ## Set final expression if it has changed. ** 60 | #if( $totalAuthExpression != "" ) 61 | #set( $authCondition.expression = "($totalAuthExpression)" ) 62 | #end 63 | ## [End] Collect Auth Condition ** 64 | #end 65 | 66 | 67 | ## [Start] Throw if unauthorized ** 68 | #if( !($isStaticGroupAuthorized == true || ($authCondition && $authCondition.expression != "")) ) 69 | $util.unauthorized() 70 | #end 71 | ## [End] Throw if unauthorized ** 72 | 73 | #if( $authCondition ) 74 | #set( $condition = $authCondition ) 75 | $util.qr($condition.put("expression", "$condition.expression AND attribute_exists(#id)")) 76 | $util.qr($condition.expressionNames.put("#id", "id")) 77 | #else 78 | #set( $condition = { 79 | "expression": "attribute_exists(#id)", 80 | "expressionNames": { 81 | "#id": "id" 82 | } 83 | } ) 84 | #end 85 | #if( $versionedCondition ) 86 | $util.qr($condition.put("expression", "($condition.expression) AND $versionedCondition.expression")) 87 | $util.qr($condition.expressionNames.putAll($versionedCondition.expressionNames)) 88 | #set( $expressionValues = $util.defaultIfNull($condition.expressionValues, {}) ) 89 | $util.qr($expressionValues.putAll($versionedCondition.expressionValues)) 90 | #set( $condition.expressionValues = $expressionValues ) 91 | #end 92 | { 93 | "version": "2017-02-28", 94 | "operation": "DeleteItem", 95 | "key": { 96 | "id": $util.dynamodb.toDynamoDBJson($ctx.args.input.id) 97 | }, 98 | "condition": $util.toJson($condition) 99 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.deleteMessage.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.deleteUser.request: -------------------------------------------------------------------------------- 1 | ## No Static Group Authorization Rules ** 2 | 3 | 4 | #if( ! $isStaticGroupAuthorized ) 5 | ## No Dynamic Group Authorization Rules ** 6 | 7 | 8 | ## [Start] Owner Authorization Checks ** 9 | #set( $ownerAuthExpressions = [] ) 10 | #set( $ownerAuthExpressionValues = {} ) 11 | #set( $ownerAuthExpressionNames = {} ) 12 | ## Authorization rule: { allow: "owner", ownerField: "id", identityField: "cognito:username" } ** 13 | $util.qr($ownerAuthExpressions.add("#owner0 = :identity0")) 14 | $util.qr($ownerAuthExpressionNames.put("#owner0", "id")) 15 | $util.qr($ownerAuthExpressionValues.put(":identity0", $util.dynamodb.toDynamoDB($util.defaultIfNull($ctx.identity.claims.get("username"), $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____"))))) 16 | ## [End] Owner Authorization Checks ** 17 | 18 | 19 | ## [Start] Collect Auth Condition ** 20 | #set( $authCondition = { 21 | "expression": "", 22 | "expressionNames": {}, 23 | "expressionValues": {} 24 | } ) 25 | #set( $totalAuthExpression = "" ) 26 | ## Add dynamic group auth conditions if they exist ** 27 | #if( $groupAuthExpressions ) 28 | #foreach( $authExpr in $groupAuthExpressions ) 29 | #set( $totalAuthExpression = "$totalAuthExpression $authExpr" ) 30 | #if( $foreach.hasNext ) 31 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 32 | #end 33 | #end 34 | #end 35 | #if( $groupAuthExpressionNames ) 36 | $util.qr($authCondition.expressionNames.putAll($groupAuthExpressionNames)) 37 | #end 38 | #if( $groupAuthExpressionValues ) 39 | $util.qr($authCondition.expressionValues.putAll($groupAuthExpressionValues)) 40 | #end 41 | ## Add owner auth conditions if they exist ** 42 | #if( $totalAuthExpression != "" && $ownerAuthExpressions && $ownerAuthExpressions.size() > 0 ) 43 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 44 | #end 45 | #if( $ownerAuthExpressions ) 46 | #foreach( $authExpr in $ownerAuthExpressions ) 47 | #set( $totalAuthExpression = "$totalAuthExpression $authExpr" ) 48 | #if( $foreach.hasNext ) 49 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 50 | #end 51 | #end 52 | #end 53 | #if( $ownerAuthExpressionNames ) 54 | $util.qr($authCondition.expressionNames.putAll($ownerAuthExpressionNames)) 55 | #end 56 | #if( $ownerAuthExpressionValues ) 57 | $util.qr($authCondition.expressionValues.putAll($ownerAuthExpressionValues)) 58 | #end 59 | ## Set final expression if it has changed. ** 60 | #if( $totalAuthExpression != "" ) 61 | #set( $authCondition.expression = "($totalAuthExpression)" ) 62 | #end 63 | ## [End] Collect Auth Condition ** 64 | #end 65 | 66 | 67 | ## [Start] Throw if unauthorized ** 68 | #if( !($isStaticGroupAuthorized == true || ($authCondition && $authCondition.expression != "")) ) 69 | $util.unauthorized() 70 | #end 71 | ## [End] Throw if unauthorized ** 72 | 73 | #if( $authCondition ) 74 | #set( $condition = $authCondition ) 75 | $util.qr($condition.put("expression", "$condition.expression AND attribute_exists(#id)")) 76 | $util.qr($condition.expressionNames.put("#id", "id")) 77 | #else 78 | #set( $condition = { 79 | "expression": "attribute_exists(#id)", 80 | "expressionNames": { 81 | "#id": "id" 82 | } 83 | } ) 84 | #end 85 | #if( $versionedCondition ) 86 | $util.qr($condition.put("expression", "($condition.expression) AND $versionedCondition.expression")) 87 | $util.qr($condition.expressionNames.putAll($versionedCondition.expressionNames)) 88 | #set( $expressionValues = $util.defaultIfNull($condition.expressionValues, {}) ) 89 | $util.qr($expressionValues.putAll($versionedCondition.expressionValues)) 90 | #set( $condition.expressionValues = $expressionValues ) 91 | #end 92 | { 93 | "version": "2017-02-28", 94 | "operation": "DeleteItem", 95 | "key": { 96 | "id": $util.dynamodb.toDynamoDBJson($ctx.args.input.id) 97 | }, 98 | "condition": $util.toJson($condition) 99 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.deleteUser.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.updateConvoLink.request: -------------------------------------------------------------------------------- 1 | #if( $authCondition && $authCondition.expression != "" ) 2 | #set( $condition = $authCondition ) 3 | $util.qr($condition.put("expression", "$condition.expression AND attribute_exists(#id)")) 4 | $util.qr($condition.expressionNames.put("#id", "id")) 5 | #else 6 | #set( $condition = { 7 | "expression": "attribute_exists(#id)", 8 | "expressionNames": { 9 | "#id": "id" 10 | }, 11 | "expressionValues": {} 12 | } ) 13 | #end 14 | ## Automatically set the updatedAt timestamp. ** 15 | $util.qr($context.args.input.put("updatedAt", $util.time.nowISO8601())) 16 | $util.qr($context.args.input.put("__typename", "ConvoLink")) 17 | ## Update condition if type is @versioned ** 18 | #if( $versionedCondition ) 19 | $util.qr($condition.put("expression", "($condition.expression) AND $versionedCondition.expression")) 20 | $util.qr($condition.expressionNames.putAll($versionedCondition.expressionNames)) 21 | $util.qr($condition.expressionValues.putAll($versionedCondition.expressionValues)) 22 | #end 23 | #set( $expNames = {} ) 24 | #set( $expValues = {} ) 25 | #set( $expSet = {} ) 26 | #set( $expAdd = {} ) 27 | #set( $expRemove = [] ) 28 | #foreach( $entry in $util.map.copyAndRemoveAllKeys($context.args.input, ["id"]).entrySet() ) 29 | #if( $util.isNull($entry.value) ) 30 | #set( $discard = $expRemove.add("#$entry.key") ) 31 | $util.qr($expNames.put("#$entry.key", "$entry.key")) 32 | #else 33 | $util.qr($expSet.put("#$entry.key", ":$entry.key")) 34 | $util.qr($expNames.put("#$entry.key", "$entry.key")) 35 | $util.qr($expValues.put(":$entry.key", $util.dynamodb.toDynamoDB($entry.value))) 36 | #end 37 | #end 38 | #set( $expression = "" ) 39 | #if( !$expSet.isEmpty() ) 40 | #set( $expression = "SET" ) 41 | #foreach( $entry in $expSet.entrySet() ) 42 | #set( $expression = "$expression $entry.key = $entry.value" ) 43 | #if( $foreach.hasNext() ) 44 | #set( $expression = "$expression," ) 45 | #end 46 | #end 47 | #end 48 | #if( !$expAdd.isEmpty() ) 49 | #set( $expression = "$expression ADD" ) 50 | #foreach( $entry in $expAdd.entrySet() ) 51 | #set( $expression = "$expression $entry.key $entry.value" ) 52 | #if( $foreach.hasNext() ) 53 | #set( $expression = "$expression," ) 54 | #end 55 | #end 56 | #end 57 | #if( !$expRemove.isEmpty() ) 58 | #set( $expression = "$expression REMOVE" ) 59 | #foreach( $entry in $expRemove ) 60 | #set( $expression = "$expression $entry" ) 61 | #if( $foreach.hasNext() ) 62 | #set( $expression = "$expression," ) 63 | #end 64 | #end 65 | #end 66 | #set( $update = {} ) 67 | $util.qr($update.put("expression", "$expression")) 68 | #if( !$expNames.isEmpty() ) 69 | $util.qr($update.put("expressionNames", $expNames)) 70 | #end 71 | #if( !$expValues.isEmpty() ) 72 | $util.qr($update.put("expressionValues", $expValues)) 73 | #end 74 | { 75 | "version": "2017-02-28", 76 | "operation": "UpdateItem", 77 | "key": { 78 | "id": { 79 | "S": "$context.args.input.id" 80 | } 81 | }, 82 | "update": $util.toJson($update), 83 | "condition": $util.toJson($condition) 84 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.updateConvoLink.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.updateMessage.request: -------------------------------------------------------------------------------- 1 | ## No Static Group Authorization Rules ** 2 | 3 | 4 | #if( ! $isStaticGroupAuthorized ) 5 | ## No Dynamic Group Authorization Rules ** 6 | 7 | 8 | ## [Start] Owner Authorization Checks ** 9 | #set( $ownerAuthExpressions = [] ) 10 | #set( $ownerAuthExpressionValues = {} ) 11 | #set( $ownerAuthExpressionNames = {} ) 12 | ## Authorization rule: { allow: "owner", ownerField: "authorId", identityField: "cognito:username" } ** 13 | $util.qr($ownerAuthExpressions.add("#owner0 = :identity0")) 14 | $util.qr($ownerAuthExpressionNames.put("#owner0", "authorId")) 15 | $util.qr($ownerAuthExpressionValues.put(":identity0", $util.dynamodb.toDynamoDB($util.defaultIfNull($ctx.identity.claims.get("username"), $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____"))))) 16 | ## [End] Owner Authorization Checks ** 17 | 18 | 19 | ## [Start] Collect Auth Condition ** 20 | #set( $authCondition = { 21 | "expression": "", 22 | "expressionNames": {}, 23 | "expressionValues": {} 24 | } ) 25 | #set( $totalAuthExpression = "" ) 26 | ## Add dynamic group auth conditions if they exist ** 27 | #if( $groupAuthExpressions ) 28 | #foreach( $authExpr in $groupAuthExpressions ) 29 | #set( $totalAuthExpression = "$totalAuthExpression $authExpr" ) 30 | #if( $foreach.hasNext ) 31 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 32 | #end 33 | #end 34 | #end 35 | #if( $groupAuthExpressionNames ) 36 | $util.qr($authCondition.expressionNames.putAll($groupAuthExpressionNames)) 37 | #end 38 | #if( $groupAuthExpressionValues ) 39 | $util.qr($authCondition.expressionValues.putAll($groupAuthExpressionValues)) 40 | #end 41 | ## Add owner auth conditions if they exist ** 42 | #if( $totalAuthExpression != "" && $ownerAuthExpressions && $ownerAuthExpressions.size() > 0 ) 43 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 44 | #end 45 | #if( $ownerAuthExpressions ) 46 | #foreach( $authExpr in $ownerAuthExpressions ) 47 | #set( $totalAuthExpression = "$totalAuthExpression $authExpr" ) 48 | #if( $foreach.hasNext ) 49 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 50 | #end 51 | #end 52 | #end 53 | #if( $ownerAuthExpressionNames ) 54 | $util.qr($authCondition.expressionNames.putAll($ownerAuthExpressionNames)) 55 | #end 56 | #if( $ownerAuthExpressionValues ) 57 | $util.qr($authCondition.expressionValues.putAll($ownerAuthExpressionValues)) 58 | #end 59 | ## Set final expression if it has changed. ** 60 | #if( $totalAuthExpression != "" ) 61 | #set( $authCondition.expression = "($totalAuthExpression)" ) 62 | #end 63 | ## [End] Collect Auth Condition ** 64 | #end 65 | 66 | 67 | ## [Start] Throw if unauthorized ** 68 | #if( !($isStaticGroupAuthorized == true || ($authCondition && $authCondition.expression != "")) ) 69 | $util.unauthorized() 70 | #end 71 | ## [End] Throw if unauthorized ** 72 | 73 | #if( $authCondition && $authCondition.expression != "" ) 74 | #set( $condition = $authCondition ) 75 | $util.qr($condition.put("expression", "$condition.expression AND attribute_exists(#id)")) 76 | $util.qr($condition.expressionNames.put("#id", "id")) 77 | #else 78 | #set( $condition = { 79 | "expression": "attribute_exists(#id)", 80 | "expressionNames": { 81 | "#id": "id" 82 | }, 83 | "expressionValues": {} 84 | } ) 85 | #end 86 | ## Automatically set the updatedAt timestamp. ** 87 | $util.qr($context.args.input.put("updatedAt", $util.time.nowISO8601())) 88 | $util.qr($context.args.input.put("__typename", "Message")) 89 | ## Update condition if type is @versioned ** 90 | #if( $versionedCondition ) 91 | $util.qr($condition.put("expression", "($condition.expression) AND $versionedCondition.expression")) 92 | $util.qr($condition.expressionNames.putAll($versionedCondition.expressionNames)) 93 | $util.qr($condition.expressionValues.putAll($versionedCondition.expressionValues)) 94 | #end 95 | #set( $expNames = {} ) 96 | #set( $expValues = {} ) 97 | #set( $expSet = {} ) 98 | #set( $expAdd = {} ) 99 | #set( $expRemove = [] ) 100 | #foreach( $entry in $util.map.copyAndRemoveAllKeys($context.args.input, ["id"]).entrySet() ) 101 | #if( $util.isNull($entry.value) ) 102 | #set( $discard = $expRemove.add("#$entry.key") ) 103 | $util.qr($expNames.put("#$entry.key", "$entry.key")) 104 | #else 105 | $util.qr($expSet.put("#$entry.key", ":$entry.key")) 106 | $util.qr($expNames.put("#$entry.key", "$entry.key")) 107 | $util.qr($expValues.put(":$entry.key", $util.dynamodb.toDynamoDB($entry.value))) 108 | #end 109 | #end 110 | #set( $expression = "" ) 111 | #if( !$expSet.isEmpty() ) 112 | #set( $expression = "SET" ) 113 | #foreach( $entry in $expSet.entrySet() ) 114 | #set( $expression = "$expression $entry.key = $entry.value" ) 115 | #if( $foreach.hasNext() ) 116 | #set( $expression = "$expression," ) 117 | #end 118 | #end 119 | #end 120 | #if( !$expAdd.isEmpty() ) 121 | #set( $expression = "$expression ADD" ) 122 | #foreach( $entry in $expAdd.entrySet() ) 123 | #set( $expression = "$expression $entry.key $entry.value" ) 124 | #if( $foreach.hasNext() ) 125 | #set( $expression = "$expression," ) 126 | #end 127 | #end 128 | #end 129 | #if( !$expRemove.isEmpty() ) 130 | #set( $expression = "$expression REMOVE" ) 131 | #foreach( $entry in $expRemove ) 132 | #set( $expression = "$expression $entry" ) 133 | #if( $foreach.hasNext() ) 134 | #set( $expression = "$expression," ) 135 | #end 136 | #end 137 | #end 138 | #set( $update = {} ) 139 | $util.qr($update.put("expression", "$expression")) 140 | #if( !$expNames.isEmpty() ) 141 | $util.qr($update.put("expressionNames", $expNames)) 142 | #end 143 | #if( !$expValues.isEmpty() ) 144 | $util.qr($update.put("expressionValues", $expValues)) 145 | #end 146 | { 147 | "version": "2017-02-28", 148 | "operation": "UpdateItem", 149 | "key": { 150 | "id": { 151 | "S": "$context.args.input.id" 152 | } 153 | }, 154 | "update": $util.toJson($update), 155 | "condition": $util.toJson($condition) 156 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.updateMessage.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.updateUser.request: -------------------------------------------------------------------------------- 1 | ## No Static Group Authorization Rules ** 2 | 3 | 4 | #if( ! $isStaticGroupAuthorized ) 5 | ## No Dynamic Group Authorization Rules ** 6 | 7 | 8 | ## [Start] Owner Authorization Checks ** 9 | #set( $ownerAuthExpressions = [] ) 10 | #set( $ownerAuthExpressionValues = {} ) 11 | #set( $ownerAuthExpressionNames = {} ) 12 | ## Authorization rule: { allow: "owner", ownerField: "id", identityField: "cognito:username" } ** 13 | $util.qr($ownerAuthExpressions.add("#owner0 = :identity0")) 14 | $util.qr($ownerAuthExpressionNames.put("#owner0", "id")) 15 | $util.qr($ownerAuthExpressionValues.put(":identity0", $util.dynamodb.toDynamoDB($util.defaultIfNull($ctx.identity.claims.get("username"), $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____"))))) 16 | ## [End] Owner Authorization Checks ** 17 | 18 | 19 | ## [Start] Collect Auth Condition ** 20 | #set( $authCondition = { 21 | "expression": "", 22 | "expressionNames": {}, 23 | "expressionValues": {} 24 | } ) 25 | #set( $totalAuthExpression = "" ) 26 | ## Add dynamic group auth conditions if they exist ** 27 | #if( $groupAuthExpressions ) 28 | #foreach( $authExpr in $groupAuthExpressions ) 29 | #set( $totalAuthExpression = "$totalAuthExpression $authExpr" ) 30 | #if( $foreach.hasNext ) 31 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 32 | #end 33 | #end 34 | #end 35 | #if( $groupAuthExpressionNames ) 36 | $util.qr($authCondition.expressionNames.putAll($groupAuthExpressionNames)) 37 | #end 38 | #if( $groupAuthExpressionValues ) 39 | $util.qr($authCondition.expressionValues.putAll($groupAuthExpressionValues)) 40 | #end 41 | ## Add owner auth conditions if they exist ** 42 | #if( $totalAuthExpression != "" && $ownerAuthExpressions && $ownerAuthExpressions.size() > 0 ) 43 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 44 | #end 45 | #if( $ownerAuthExpressions ) 46 | #foreach( $authExpr in $ownerAuthExpressions ) 47 | #set( $totalAuthExpression = "$totalAuthExpression $authExpr" ) 48 | #if( $foreach.hasNext ) 49 | #set( $totalAuthExpression = "$totalAuthExpression OR" ) 50 | #end 51 | #end 52 | #end 53 | #if( $ownerAuthExpressionNames ) 54 | $util.qr($authCondition.expressionNames.putAll($ownerAuthExpressionNames)) 55 | #end 56 | #if( $ownerAuthExpressionValues ) 57 | $util.qr($authCondition.expressionValues.putAll($ownerAuthExpressionValues)) 58 | #end 59 | ## Set final expression if it has changed. ** 60 | #if( $totalAuthExpression != "" ) 61 | #set( $authCondition.expression = "($totalAuthExpression)" ) 62 | #end 63 | ## [End] Collect Auth Condition ** 64 | #end 65 | 66 | 67 | ## [Start] Throw if unauthorized ** 68 | #if( !($isStaticGroupAuthorized == true || ($authCondition && $authCondition.expression != "")) ) 69 | $util.unauthorized() 70 | #end 71 | ## [End] Throw if unauthorized ** 72 | 73 | #if( $authCondition && $authCondition.expression != "" ) 74 | #set( $condition = $authCondition ) 75 | $util.qr($condition.put("expression", "$condition.expression AND attribute_exists(#id)")) 76 | $util.qr($condition.expressionNames.put("#id", "id")) 77 | #else 78 | #set( $condition = { 79 | "expression": "attribute_exists(#id)", 80 | "expressionNames": { 81 | "#id": "id" 82 | }, 83 | "expressionValues": {} 84 | } ) 85 | #end 86 | ## Automatically set the updatedAt timestamp. ** 87 | $util.qr($context.args.input.put("updatedAt", $util.time.nowISO8601())) 88 | $util.qr($context.args.input.put("__typename", "User")) 89 | ## Update condition if type is @versioned ** 90 | #if( $versionedCondition ) 91 | $util.qr($condition.put("expression", "($condition.expression) AND $versionedCondition.expression")) 92 | $util.qr($condition.expressionNames.putAll($versionedCondition.expressionNames)) 93 | $util.qr($condition.expressionValues.putAll($versionedCondition.expressionValues)) 94 | #end 95 | #set( $expNames = {} ) 96 | #set( $expValues = {} ) 97 | #set( $expSet = {} ) 98 | #set( $expAdd = {} ) 99 | #set( $expRemove = [] ) 100 | #foreach( $entry in $util.map.copyAndRemoveAllKeys($context.args.input, ["id"]).entrySet() ) 101 | #if( $util.isNull($entry.value) ) 102 | #set( $discard = $expRemove.add("#$entry.key") ) 103 | $util.qr($expNames.put("#$entry.key", "$entry.key")) 104 | #else 105 | $util.qr($expSet.put("#$entry.key", ":$entry.key")) 106 | $util.qr($expNames.put("#$entry.key", "$entry.key")) 107 | $util.qr($expValues.put(":$entry.key", $util.dynamodb.toDynamoDB($entry.value))) 108 | #end 109 | #end 110 | #set( $expression = "" ) 111 | #if( !$expSet.isEmpty() ) 112 | #set( $expression = "SET" ) 113 | #foreach( $entry in $expSet.entrySet() ) 114 | #set( $expression = "$expression $entry.key = $entry.value" ) 115 | #if( $foreach.hasNext() ) 116 | #set( $expression = "$expression," ) 117 | #end 118 | #end 119 | #end 120 | #if( !$expAdd.isEmpty() ) 121 | #set( $expression = "$expression ADD" ) 122 | #foreach( $entry in $expAdd.entrySet() ) 123 | #set( $expression = "$expression $entry.key $entry.value" ) 124 | #if( $foreach.hasNext() ) 125 | #set( $expression = "$expression," ) 126 | #end 127 | #end 128 | #end 129 | #if( !$expRemove.isEmpty() ) 130 | #set( $expression = "$expression REMOVE" ) 131 | #foreach( $entry in $expRemove ) 132 | #set( $expression = "$expression $entry" ) 133 | #if( $foreach.hasNext() ) 134 | #set( $expression = "$expression," ) 135 | #end 136 | #end 137 | #end 138 | #set( $update = {} ) 139 | $util.qr($update.put("expression", "$expression")) 140 | #if( !$expNames.isEmpty() ) 141 | $util.qr($update.put("expressionNames", $expNames)) 142 | #end 143 | #if( !$expValues.isEmpty() ) 144 | $util.qr($update.put("expressionValues", $expValues)) 145 | #end 146 | { 147 | "version": "2017-02-28", 148 | "operation": "UpdateItem", 149 | "key": { 150 | "id": { 151 | "S": "$context.args.input.id" 152 | } 153 | }, 154 | "update": $util.toJson($update), 155 | "condition": $util.toJson($condition) 156 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Mutation.updateUser.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Query.getConvo.request: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2017-02-28", 3 | "operation": "GetItem", 4 | "key": { 5 | "id": $util.dynamodb.toDynamoDBJson($ctx.args.id) 6 | } 7 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Query.getConvo.response: -------------------------------------------------------------------------------- 1 | ## No Static Group Authorization Rules ** 2 | 3 | 4 | ## No Dynamic Group Authorization Rules ** 5 | 6 | 7 | ## [Start] Owner Authorization Checks ** 8 | #set( $isOwnerAuthorized = $util.defaultIfNull($isOwnerAuthorized, false) ) 9 | ## Authorization rule: { allow: "owner", ownerField: "members", identityField: "cognito:username" } ** 10 | #set( $allowedOwners0 = $ctx.result.members ) 11 | #set( $identityValue = $util.defaultIfNull($ctx.identity.claims.get("username"), $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____")) ) 12 | #if( $util.isList($allowedOwners0) ) 13 | #foreach( $allowedOwner in $allowedOwners0 ) 14 | #if( $allowedOwner == $identityValue ) 15 | #set( $isOwnerAuthorized = true ) 16 | #end 17 | #end 18 | #end 19 | #if( $util.isString($allowedOwners0) ) 20 | #if( $allowedOwners0 == $identityValue ) 21 | #set( $isOwnerAuthorized = true ) 22 | #end 23 | #end 24 | ## [End] Owner Authorization Checks ** 25 | 26 | 27 | ## [Start] Throw if unauthorized ** 28 | #if( !($isStaticGroupAuthorized == true || $isDynamicGroupAuthorized == true || $isOwnerAuthorized == true) ) 29 | $util.unauthorized() 30 | #end 31 | ## [End] Throw if unauthorized ** 32 | 33 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Query.getUser.request: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2017-02-28", 3 | "operation": "GetItem", 4 | "key": { 5 | "id": $util.dynamodb.toDynamoDBJson($ctx.args.id) 6 | } 7 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Query.getUser.response: -------------------------------------------------------------------------------- 1 | $util.toJson($context.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Query.listUsers.request: -------------------------------------------------------------------------------- 1 | #set( $limit = $util.defaultIfNull($context.args.limit, 10) ) 2 | { 3 | "version": "2017-02-28", 4 | "operation": "Scan", 5 | "filter": #if( $context.args.filter ) 6 | $util.transform.toDynamoDBFilterExpression($ctx.args.filter) 7 | #else 8 | null 9 | #end, 10 | "limit": $limit, 11 | "nextToken": #if( $context.args.nextToken ) 12 | "$context.args.nextToken" 13 | #else 14 | null 15 | #end 16 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/Query.listUsers.response: -------------------------------------------------------------------------------- 1 | $util.toJson($ctx.result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/User.conversations.request: -------------------------------------------------------------------------------- 1 | #set( $limit = $util.defaultIfNull($context.args.limit, 10) ) 2 | { 3 | "version": "2017-02-28", 4 | "operation": "Query", 5 | "query": { 6 | "expression": "#connectionAttribute = :connectionAttribute", 7 | "expressionNames": { 8 | "#connectionAttribute": "convoLinkUserId" 9 | }, 10 | "expressionValues": { 11 | ":connectionAttribute": { 12 | "S": "$context.source.id" 13 | } 14 | } 15 | }, 16 | "scanIndexForward": #if( $context.args.sortDirection ) 17 | #if( $context.args.sortDirection == "ASC" ) 18 | true 19 | #else 20 | false 21 | #end 22 | #else 23 | true 24 | #end, 25 | "filter": #if( $context.args.filter ) 26 | $util.transform.toDynamoDBFilterExpression($ctx.args.filter) 27 | #else 28 | null 29 | #end, 30 | "limit": $limit, 31 | "nextToken": #if( $context.args.nextToken ) 32 | "$context.args.nextToken" 33 | #else 34 | null 35 | #end, 36 | "index": "gsi-UserLinks" 37 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/User.conversations.response: -------------------------------------------------------------------------------- 1 | #if( !$result ) 2 | #set( $result = $ctx.result ) 3 | #end 4 | $util.toJson($result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/User.messages.request: -------------------------------------------------------------------------------- 1 | #set( $limit = $util.defaultIfNull($context.args.limit, 10) ) 2 | { 3 | "version": "2017-02-28", 4 | "operation": "Query", 5 | "query": { 6 | "expression": "#connectionAttribute = :connectionAttribute", 7 | "expressionNames": { 8 | "#connectionAttribute": "messageAuthorId" 9 | }, 10 | "expressionValues": { 11 | ":connectionAttribute": { 12 | "S": "$context.source.id" 13 | } 14 | } 15 | }, 16 | "scanIndexForward": #if( $context.args.sortDirection ) 17 | #if( $context.args.sortDirection == "ASC" ) 18 | true 19 | #else 20 | false 21 | #end 22 | #else 23 | true 24 | #end, 25 | "filter": #if( $context.args.filter ) 26 | $util.transform.toDynamoDBFilterExpression($ctx.args.filter) 27 | #else 28 | null 29 | #end, 30 | "limit": $limit, 31 | "nextToken": #if( $context.args.nextToken ) 32 | "$context.args.nextToken" 33 | #else 34 | null 35 | #end, 36 | "index": "gsi-UserMessages" 37 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/resolvers/User.messages.response: -------------------------------------------------------------------------------- 1 | #if( !$result ) 2 | #set( $result = $ctx.result ) 3 | #end 4 | $util.toJson($result) -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/build/schema.graphql: -------------------------------------------------------------------------------- 1 | type User { 2 | id: ID! 3 | username: String! 4 | conversations(filter: ModelConvoLinkFilterInput, sortDirection: ModelSortDirection, limit: Int, nextToken: String): ModelConvoLinkConnection 5 | messages(filter: ModelMessageFilterInput, sortDirection: ModelSortDirection, limit: Int, nextToken: String): ModelMessageConnection 6 | createdAt: String 7 | updatedAt: String 8 | } 9 | 10 | type Conversation { 11 | id: ID! 12 | messages(filter: ModelMessageFilterInput, sortDirection: ModelSortDirection, limit: Int, nextToken: String): ModelMessageConnection 13 | associated(filter: ModelConvoLinkFilterInput, sortDirection: ModelSortDirection, limit: Int, nextToken: String): ModelConvoLinkConnection 14 | name: String! 15 | members: [String!]! 16 | createdAt: String 17 | updatedAt: String 18 | } 19 | 20 | type Message { 21 | id: ID! 22 | author: User 23 | authorId: String 24 | content: String! 25 | conversation: Conversation! 26 | messageConversationId: ID! 27 | createdAt: String 28 | updatedAt: String 29 | } 30 | 31 | type ConvoLink { 32 | id: ID! 33 | user: User! 34 | convoLinkUserId: ID 35 | conversation: Conversation! 36 | convoLinkConversationId: ID! 37 | createdAt: String 38 | updatedAt: String 39 | } 40 | 41 | type Subscription { 42 | onCreateConvoLink(convoLinkUserId: ID!): ConvoLink @aws_subscribe(mutations: ["createConvoLink"]) 43 | onCreateMessage(messageConversationId: ID!): Message @aws_subscribe(mutations: ["createMessage"]) 44 | onCreateUser: User @aws_subscribe(mutations: ["createUser"]) 45 | onUpdateUser: User @aws_subscribe(mutations: ["updateUser"]) 46 | onDeleteUser: User @aws_subscribe(mutations: ["deleteUser"]) 47 | } 48 | 49 | enum ModelSortDirection { 50 | ASC 51 | DESC 52 | } 53 | 54 | type ModelUserConnection { 55 | items: [User] 56 | nextToken: String 57 | } 58 | 59 | input ModelStringFilterInput { 60 | ne: String 61 | eq: String 62 | le: String 63 | lt: String 64 | ge: String 65 | gt: String 66 | contains: String 67 | notContains: String 68 | between: [String] 69 | beginsWith: String 70 | } 71 | 72 | input ModelIDFilterInput { 73 | ne: ID 74 | eq: ID 75 | le: ID 76 | lt: ID 77 | ge: ID 78 | gt: ID 79 | contains: ID 80 | notContains: ID 81 | between: [ID] 82 | beginsWith: ID 83 | } 84 | 85 | input ModelIntFilterInput { 86 | ne: Int 87 | eq: Int 88 | le: Int 89 | lt: Int 90 | ge: Int 91 | gt: Int 92 | contains: Int 93 | notContains: Int 94 | between: [Int] 95 | } 96 | 97 | input ModelFloatFilterInput { 98 | ne: Float 99 | eq: Float 100 | le: Float 101 | lt: Float 102 | ge: Float 103 | gt: Float 104 | contains: Float 105 | notContains: Float 106 | between: [Float] 107 | } 108 | 109 | input ModelBooleanFilterInput { 110 | ne: Boolean 111 | eq: Boolean 112 | } 113 | 114 | input ModelUserFilterInput { 115 | id: ModelIDFilterInput 116 | username: ModelStringFilterInput 117 | createdAt: ModelStringFilterInput 118 | updatedAt: ModelStringFilterInput 119 | and: [ModelUserFilterInput] 120 | or: [ModelUserFilterInput] 121 | not: ModelUserFilterInput 122 | } 123 | 124 | type Query { 125 | getUser(id: ID!): User 126 | listUsers(filter: ModelUserFilterInput, limit: Int, nextToken: String): ModelUserConnection 127 | getConvo(id: ID!): Conversation 128 | } 129 | 130 | input CreateUserInput { 131 | id: ID 132 | username: String! 133 | createdAt: String 134 | updatedAt: String 135 | } 136 | 137 | input UpdateUserInput { 138 | id: ID! 139 | username: String 140 | createdAt: String 141 | updatedAt: String 142 | } 143 | 144 | input DeleteUserInput { 145 | id: ID 146 | } 147 | 148 | type Mutation { 149 | createUser(input: CreateUserInput!): User 150 | updateUser(input: UpdateUserInput!): User 151 | deleteUser(input: DeleteUserInput!): User 152 | createConvo(input: CreateConversationInput!): Conversation 153 | createMessage(input: CreateMessageInput!): Message 154 | updateMessage(input: UpdateMessageInput!): Message 155 | deleteMessage(input: DeleteMessageInput!): Message 156 | createConvoLink(input: CreateConvoLinkInput!): ConvoLink 157 | updateConvoLink(input: UpdateConvoLinkInput!): ConvoLink 158 | } 159 | 160 | input CreateConversationInput { 161 | id: ID 162 | name: String! 163 | members: [String!]! 164 | createdAt: String 165 | updatedAt: String 166 | } 167 | 168 | input UpdateConversationInput { 169 | id: ID! 170 | name: String 171 | members: [String!] 172 | createdAt: String 173 | updatedAt: String 174 | } 175 | 176 | input DeleteConversationInput { 177 | id: ID 178 | } 179 | 180 | input CreateMessageInput { 181 | id: ID 182 | authorId: String 183 | content: String! 184 | messageConversationId: ID! 185 | createdAt: String 186 | updatedAt: String 187 | } 188 | 189 | input UpdateMessageInput { 190 | id: ID! 191 | authorId: String 192 | content: String 193 | messageConversationId: ID 194 | createdAt: String 195 | updatedAt: String 196 | } 197 | 198 | input DeleteMessageInput { 199 | id: ID 200 | } 201 | 202 | input CreateConvoLinkInput { 203 | id: ID 204 | convoLinkUserId: ID 205 | convoLinkConversationId: ID! 206 | createdAt: String 207 | updatedAt: String 208 | } 209 | 210 | input UpdateConvoLinkInput { 211 | id: ID! 212 | convoLinkUserId: ID 213 | convoLinkConversationId: ID 214 | createdAt: String 215 | updatedAt: String 216 | } 217 | 218 | input DeleteConvoLinkInput { 219 | id: ID 220 | } 221 | 222 | type ModelConvoLinkConnection { 223 | items: [ConvoLink] 224 | nextToken: String 225 | } 226 | 227 | input ModelConvoLinkFilterInput { 228 | id: ModelIDFilterInput 229 | convoLinkUserId: ModelIDFilterInput 230 | convoLinkConversationId: ModelIDFilterInput 231 | createdAt: ModelStringFilterInput 232 | updatedAt: ModelStringFilterInput 233 | and: [ModelConvoLinkFilterInput] 234 | or: [ModelConvoLinkFilterInput] 235 | not: ModelConvoLinkFilterInput 236 | } 237 | 238 | type ModelMessageConnection { 239 | items: [Message] 240 | nextToken: String 241 | } 242 | 243 | input ModelMessageFilterInput { 244 | id: ModelIDFilterInput 245 | authorId: ModelStringFilterInput 246 | content: ModelStringFilterInput 247 | messageConversationId: ModelIDFilterInput 248 | createdAt: ModelStringFilterInput 249 | updatedAt: ModelStringFilterInput 250 | and: [ModelMessageFilterInput] 251 | or: [ModelMessageFilterInput] 252 | not: ModelMessageFilterInput 253 | } 254 | -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "AppSyncApiName": "allamplifychatt", 3 | "AuthCognitoUserPoolId": { 4 | "Fn::GetAtt": [ 5 | "authauth", 6 | "Outputs.UserPoolId" 7 | ] 8 | }, 9 | "schemaGraphql": "s3://chatt-20190127125226-deployment/amplify-appsync-files/schema.graphql.1548622472981", 10 | "ResolverBucket": "chatt-20190127125226-deployment", 11 | "ResolverRootKey": "amplify-appsync-files", 12 | "DeploymentTimestamp": "1548622472981" 13 | } -------------------------------------------------------------------------------- /amplify/backend/api/allamplifychatt/schema.graphql: -------------------------------------------------------------------------------- 1 | type User 2 | @model 3 | @auth(rules: [{ allow: owner, ownerField: "id", queries: null }]) { 4 | id: ID! 5 | username: String! 6 | conversations: [ConvoLink] @connection(name: "UserLinks") 7 | messages: [Message] @connection(name: "UserMessages") 8 | createdAt: String 9 | updatedAt: String 10 | } 11 | 12 | type Conversation 13 | @model( 14 | mutations: { create: "createConvo" } 15 | queries: { get: "getConvo" } 16 | subscriptions: null 17 | ) 18 | @auth(rules: [{ allow: owner, ownerField: "members" }]) { 19 | id: ID! 20 | messages: [Message] @connection(name: "ConvoMsgs", sortField: "createdAt") 21 | associated: [ConvoLink] @connection(name: "AssociatedLinks") 22 | name: String! 23 | members: [String!]! 24 | createdAt: String 25 | updatedAt: String 26 | } 27 | 28 | type Message 29 | @model(subscriptions: null, queries: null) 30 | @auth(rules: [{ allow: owner, ownerField: "authorId" }]) { 31 | id: ID! 32 | author: User @connection(name: "UserMessages", keyField: "authorId") 33 | authorId: String 34 | content: String! 35 | conversation: Conversation! @connection(name: "ConvoMsgs") 36 | messageConversationId: ID! 37 | createdAt: String 38 | updatedAt: String 39 | } 40 | 41 | type ConvoLink 42 | @model( 43 | mutations: { create: "createConvoLink", update: "updateConvoLink" } 44 | queries: null 45 | subscriptions: null 46 | ) { 47 | id: ID! 48 | user: User! @connection(name: "UserLinks") 49 | convoLinkUserId: ID 50 | conversation: Conversation! @connection(name: "AssociatedLinks") 51 | convoLinkConversationId: ID! 52 | createdAt: String 53 | updatedAt: String 54 | } 55 | 56 | type Subscription { 57 | onCreateConvoLink(convoLinkUserId: ID!): ConvoLink 58 | @aws_subscribe(mutations: ["createConvoLink"]) 59 | onCreateMessage(messageConversationId: ID!): Message 60 | @aws_subscribe(mutations: ["createMessage"]) 61 | } -------------------------------------------------------------------------------- /amplify/backend/auth/auth/auth-cloudformation-template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | 3 | Parameters: 4 | env: 5 | Type: String 6 | authRoleName: 7 | Type: String 8 | unauthRoleName: 9 | Type: String 10 | authRoleArn: 11 | Type: String 12 | unauthRoleArn: 13 | Type: String 14 | 15 | 16 | identityPoolName: 17 | Type: String 18 | 19 | allowUnauthenticatedIdentities: 20 | Type: String 21 | 22 | thirdPartyAuth: 23 | Type: String 24 | 25 | lambdaLogPolicy: 26 | Type: String 27 | 28 | openIdLambdaRoleName: 29 | Type: String 30 | 31 | openIdRolePolicy: 32 | Type: String 33 | 34 | openIdLambdaIAMPolicy: 35 | Type: String 36 | 37 | openIdLogPolicy: 38 | Type: String 39 | 40 | userPoolName: 41 | Type: String 42 | 43 | autoVerifiedAttributes: 44 | Type: CommaDelimitedList 45 | 46 | mfaConfiguration: 47 | Type: String 48 | 49 | mfaTypes: 50 | Type: CommaDelimitedList 51 | 52 | roleName: 53 | Type: String 54 | 55 | roleExternalId: 56 | Type: String 57 | 58 | policyName: 59 | Type: String 60 | 61 | smsAuthenticationMessage: 62 | Type: String 63 | 64 | smsVerificationMessage: 65 | Type: String 66 | 67 | emailVerificationSubject: 68 | Type: String 69 | 70 | emailVerificationMessage: 71 | Type: String 72 | 73 | defaultPasswordPolicy: 74 | Type: String 75 | 76 | passwordPolicyMinLength: 77 | Type: Number 78 | 79 | passwordPolicyCharacters: 80 | Type: CommaDelimitedList 81 | 82 | requiredAttributes: 83 | Type: CommaDelimitedList 84 | 85 | userpoolClientName: 86 | Type: String 87 | 88 | userpoolClientGenerateSecret: 89 | Type: String 90 | 91 | userpoolClientRefreshTokenValidity: 92 | Type: Number 93 | 94 | userpoolClientReadAttributes: 95 | Type: CommaDelimitedList 96 | 97 | mfaLambdaRole: 98 | Type: String 99 | 100 | mfaLambdaLogPolicy: 101 | Type: String 102 | 103 | mfaPassRolePolicy: 104 | Type: String 105 | 106 | mfaLambdaIAMPolicy: 107 | Type: String 108 | 109 | userpoolClientLambdaRole: 110 | Type: String 111 | 112 | userpoolClientLogPolicy: 113 | Type: String 114 | 115 | userpoolClientLambdaPolicy: 116 | Type: String 117 | 118 | userpoolClientSetAttributes: 119 | Type: String 120 | 121 | useDefault: 122 | Type: String 123 | 124 | authSelections: 125 | Type: String 126 | 127 | resourceName: 128 | Type: String 129 | 130 | Conditions: 131 | ShouldNotCreateEnvResources: !Equals [ !Ref env, NONE ] 132 | 133 | Resources: 134 | 135 | # BEGIN SNS ROLE RESOURCE 136 | SNSRole: 137 | # Created to allow the UserPool SMS Config to publish via the Simple Notification Service during MFA Process 138 | Type: AWS::IAM::Role 139 | Properties: 140 | RoleName: !If [ShouldNotCreateEnvResources, !Ref roleName, !Join ['',[!Ref roleName, '-', !Ref env]]] 141 | AssumeRolePolicyDocument: 142 | Version: "2012-10-17" 143 | Statement: 144 | - Sid: "" 145 | Effect: "Allow" 146 | Principal: 147 | Service: "cognito-idp.amazonaws.com" 148 | Action: 149 | - "sts:AssumeRole" 150 | Condition: 151 | StringEquals: 152 | sts:ExternalId: !Ref roleExternalId 153 | Policies: 154 | - 155 | PolicyName: !Ref policyName 156 | PolicyDocument: 157 | Version: "2012-10-17" 158 | Statement: 159 | - 160 | Effect: "Allow" 161 | Action: 162 | - "sns:Publish" 163 | Resource: "*" 164 | # BEGIN USER POOL RESOURCES 165 | UserPool: 166 | # Created upon user selection 167 | # Depends on SNS Role for Arn if MFA is enabled 168 | Type: AWS::Cognito::UserPool 169 | Properties: 170 | UserPoolName: !If [ShouldNotCreateEnvResources, !Ref userPoolName, !Join ['',[!Ref userPoolName, '-', !Ref env]]] 171 | Schema: 172 | 173 | - 174 | Name: email 175 | Required: true 176 | Mutable: true 177 | 178 | 179 | AutoVerifiedAttributes: !Ref autoVerifiedAttributes 180 | 181 | 182 | EmailVerificationMessage: !Ref emailVerificationMessage 183 | EmailVerificationSubject: !Ref emailVerificationSubject 184 | 185 | Policies: 186 | PasswordPolicy: 187 | MinimumLength: !Ref passwordPolicyMinLength 188 | RequireLowercase: true 189 | RequireNumbers: true 190 | RequireSymbols: true 191 | RequireUppercase: true 192 | MfaConfiguration: !Ref mfaConfiguration 193 | SmsVerificationMessage: !Ref smsVerificationMessage 194 | SmsConfiguration: 195 | SnsCallerArn: !GetAtt SNSRole.Arn 196 | ExternalId: !Ref roleExternalId 197 | 198 | UserPoolClientWeb: 199 | # Created provide application access to user pool 200 | # Depends on UserPool for ID reference 201 | Type: "AWS::Cognito::UserPoolClient" 202 | Properties: 203 | ClientName: auth_app_clientWeb 204 | 205 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity 206 | UserPoolId: !Ref UserPool 207 | DependsOn: UserPool 208 | UserPoolClient: 209 | # Created provide application access to user pool 210 | # Depends on UserPool for ID reference 211 | Type: "AWS::Cognito::UserPoolClient" 212 | Properties: 213 | ClientName: !Ref userpoolClientName 214 | 215 | GenerateSecret: !Ref userpoolClientGenerateSecret 216 | RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity 217 | UserPoolId: !Ref UserPool 218 | DependsOn: UserPool 219 | # BEGIN USER POOL LAMBDA RESOURCES 220 | UserPoolClientRole: 221 | # Created to execute Lambda which gets userpool app client config values 222 | Type: 'AWS::IAM::Role' 223 | Properties: 224 | RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',[!Ref userpoolClientLambdaRole, '-', !Ref env]]] 225 | AssumeRolePolicyDocument: 226 | Version: '2012-10-17' 227 | Statement: 228 | - Effect: Allow 229 | Principal: 230 | Service: 231 | - lambda.amazonaws.com 232 | Action: 233 | - 'sts:AssumeRole' 234 | DependsOn: UserPoolClient 235 | UserPoolClientLambda: 236 | # Lambda which gets userpool app client config values 237 | # Depends on UserPool for id 238 | # Depends on UserPoolClientRole for role ARN 239 | Type: 'AWS::Lambda::Function' 240 | Properties: 241 | Code: 242 | ZipFile: !Join 243 | - |+ 244 | - - 'const response = require(''cfn-response'');' 245 | - 'const aws = require(''aws-sdk'');' 246 | - 'const identity = new aws.CognitoIdentityServiceProvider();' 247 | - 'exports.handler = (event, context, callback) => {' 248 | - ' if (event.RequestType == ''Delete'') { ' 249 | - ' response.send(event, context, response.SUCCESS, {})' 250 | - ' }' 251 | - ' if (event.RequestType == ''Update'' || event.RequestType == ''Create'') {' 252 | - ' const params = {' 253 | - ' ClientId: event.ResourceProperties.clientId,' 254 | - ' UserPoolId: event.ResourceProperties.userpoolId' 255 | - ' };' 256 | - ' identity.describeUserPoolClient(params).promise()' 257 | - ' .then((res) => {' 258 | - ' response.send(event, context, response.SUCCESS, {''appSecret'': res.UserPoolClient.ClientSecret});' 259 | - ' })' 260 | - ' .catch((err) => {' 261 | - ' response.send(event, context, response.FAILURE, {err});' 262 | - ' });' 263 | - ' }' 264 | - '};' 265 | Handler: index.handler 266 | Runtime: nodejs8.10 267 | Timeout: '300' 268 | Role: !GetAtt 269 | - UserPoolClientRole 270 | - Arn 271 | DependsOn: UserPoolClientRole 272 | UserPoolClientLambdaPolicy: 273 | # Sets userpool policy for the role that executes the Userpool Client Lambda 274 | # Depends on UserPool for Arn 275 | # Marked as depending on UserPoolClientRole for easier to understand CFN sequencing 276 | Type: 'AWS::IAM::Policy' 277 | Properties: 278 | PolicyName: !Ref userpoolClientLambdaPolicy 279 | Roles: 280 | - !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',[!Ref userpoolClientLambdaRole, '-', !Ref env]]] 281 | PolicyDocument: 282 | Version: '2012-10-17' 283 | Statement: 284 | - Effect: Allow 285 | Action: 286 | - 'cognito-idp:DescribeUserPoolClient' 287 | Resource: !GetAtt UserPool.Arn 288 | DependsOn: UserPoolClientLambda 289 | UserPoolClientLogPolicy: 290 | # Sets log policy for the role that executes the Userpool Client Lambda 291 | # Depends on UserPool for Arn 292 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing 293 | Type: 'AWS::IAM::Policy' 294 | Properties: 295 | PolicyName: !Ref userpoolClientLogPolicy 296 | Roles: 297 | - !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',[!Ref userpoolClientLambdaRole, '-', !Ref env]]] 298 | PolicyDocument: 299 | Version: 2012-10-17 300 | Statement: 301 | - Effect: Allow 302 | Action: 303 | - 'logs:CreateLogGroup' 304 | - 'logs:CreateLogStream' 305 | - 'logs:PutLogEvents' 306 | Resource: !Sub 307 | - arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:* 308 | - { region: !Ref "AWS::Region", account: !Ref "AWS::AccountId", lambda: !Ref UserPoolClientLambda} 309 | DependsOn: UserPoolClientLambdaPolicy 310 | UserPoolClientInputs: 311 | # Values passed to Userpool client Lambda 312 | # Depends on UserPool for Id 313 | # Depends on UserPoolClient for Id 314 | # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing 315 | Type: 'Custom::LambdaCallout' 316 | Properties: 317 | ServiceToken: !GetAtt UserPoolClientLambda.Arn 318 | clientId: !Ref UserPoolClient 319 | userpoolId: !Ref UserPool 320 | DependsOn: UserPoolClientLogPolicy 321 | 322 | 323 | # BEGIN IDENTITY POOL RESOURCES 324 | 325 | 326 | IdentityPool: 327 | # Always created 328 | Type: AWS::Cognito::IdentityPool 329 | Properties: 330 | IdentityPoolName: !If [ShouldNotCreateEnvResources, 'allamplifychatt', !Join ['',['allamplifychatt', '__', !Ref env]]] 331 | 332 | CognitoIdentityProviders: 333 | - ClientId: !Ref UserPoolClient 334 | ProviderName: !Sub 335 | - cognito-idp.${region}.amazonaws.com/${client} 336 | - { region: !Ref "AWS::Region", client: !Ref UserPool} 337 | - ClientId: !Ref UserPoolClientWeb 338 | ProviderName: !Sub 339 | - cognito-idp.${region}.amazonaws.com/${client} 340 | - { region: !Ref "AWS::Region", client: !Ref UserPool} 341 | 342 | AllowUnauthenticatedIdentities: !Ref allowUnauthenticatedIdentities 343 | 344 | 345 | DependsOn: UserPoolClientInputs 346 | 347 | 348 | IdentityPoolRoleMap: 349 | # Created to map Auth and Unauth roles to the identity pool 350 | # Depends on Identity Pool for ID ref 351 | Type: AWS::Cognito::IdentityPoolRoleAttachment 352 | Properties: 353 | IdentityPoolId: !Ref IdentityPool 354 | Roles: 355 | unauthenticated: !Ref unauthRoleArn 356 | authenticated: !Ref authRoleArn 357 | DependsOn: IdentityPool 358 | 359 | 360 | Outputs : 361 | 362 | IdentityPoolId: 363 | Value: !Ref 'IdentityPool' 364 | Description: Id for the identity pool 365 | IdentityPoolName: 366 | Value: !GetAtt IdentityPool.Name 367 | 368 | 369 | UserPoolId: 370 | Value: !Ref 'UserPool' 371 | Description: Id for the user pool 372 | UserPoolName: 373 | Value: !Ref userPoolName 374 | AppClientIDWeb: 375 | Value: !Ref 'UserPoolClientWeb' 376 | Description: The user pool app client id for web 377 | AppClientID: 378 | Value: !Ref 'UserPoolClient' 379 | Description: The user pool app client id 380 | AppClientSecret: 381 | Value: !GetAtt UserPoolClientInputs.appSecret 382 | 383 | 384 | 385 | 386 | 387 | 388 | -------------------------------------------------------------------------------- /amplify/backend/auth/auth/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "identityPoolName": "allamplifychatt", 3 | "allowUnauthenticatedIdentities": false, 4 | "thirdPartyAuth": false, 5 | "lambdaLogPolicy": "auth_lambda_log_policy", 6 | "openIdLambdaRoleName": "auth_openid_lambda_role", 7 | "openIdRolePolicy": "auth_openid_pass_role_policy", 8 | "openIdLambdaIAMPolicy": "auth_openid_lambda_iam_policy", 9 | "openIdLogPolicy": "auth_openid_lambda_log_policy", 10 | "userPoolName": "allamplifychattuserpool", 11 | "autoVerifiedAttributes": [ 12 | "email" 13 | ], 14 | "mfaConfiguration": "OFF", 15 | "mfaTypes": [ 16 | "SMS Text Message" 17 | ], 18 | "roleName": "auth_sns-role", 19 | "roleExternalId": "auth_role_external_id", 20 | "policyName": "auth-sns-policy", 21 | "smsAuthenticationMessage": "Your authentication code is {####}", 22 | "smsVerificationMessage": "Your verification code is {####}", 23 | "emailVerificationSubject": "Your verification code", 24 | "emailVerificationMessage": "Your verification code is {####}", 25 | "defaultPasswordPolicy": false, 26 | "passwordPolicyMinLength": 8, 27 | "passwordPolicyCharacters": [ 28 | "Requires Lowercase", 29 | "Requires Uppercase", 30 | "Requires Numbers", 31 | "Requires Symbols" 32 | ], 33 | "requiredAttributes": [ 34 | "email" 35 | ], 36 | "userpoolClientName": "auth_app_client", 37 | "userpoolClientGenerateSecret": true, 38 | "userpoolClientRefreshTokenValidity": 30, 39 | "userpoolClientReadAttributes": [ 40 | "email" 41 | ], 42 | "mfaLambdaRole": "auth_totp_lambda_role", 43 | "mfaLambdaLogPolicy": "auth_totp_lambda_log_policy", 44 | "mfaPassRolePolicy": "auth_totp_pass_role_policy", 45 | "mfaLambdaIAMPolicy": "auth_totp_lambda_iam_policy", 46 | "userpoolClientLambdaRole": "auth_userpoolclient_lambda_role", 47 | "userpoolClientLogPolicy": "auth_userpoolclient_lambda_log_policy", 48 | "userpoolClientLambdaPolicy": "auth_userpoolclient_lambda_iam_policy", 49 | "userpoolClientSetAttributes": false, 50 | "useDefault": "manual", 51 | "authSelections": "identityPoolAndUserPool", 52 | "resourceName": "auth", 53 | "authRoleName": { 54 | "Ref": "AuthRoleName" 55 | }, 56 | "unauthRoleName": { 57 | "Ref": "UnauthRoleName" 58 | }, 59 | "authRoleArn": { 60 | "Fn::GetAtt": [ 61 | "AuthRole", 62 | "Arn" 63 | ] 64 | }, 65 | "unauthRoleArn": { 66 | "Fn::GetAtt": [ 67 | "UnauthRole", 68 | "Arn" 69 | ] 70 | } 71 | } -------------------------------------------------------------------------------- /amplify/backend/backend-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "auth": { 3 | "auth": { 4 | "service": "Cognito", 5 | "providerPlugin": "awscloudformation" 6 | } 7 | }, 8 | "api": { 9 | "allamplifychatt": { 10 | "service": "AppSync", 11 | "providerPlugin": "awscloudformation", 12 | "output": { 13 | "securityType": "AMAZON_COGNITO_USER_POOLS" 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-chat", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "aws-amplify": "^2.2.6", 7 | "aws-amplify-react": "^3.1.7", 8 | "aws-appsync": "^3.0.2", 9 | "glamor": "^2.20.40", 10 | "graphql-tag": "^2.10.3", 11 | "mobx": "^5.15.4", 12 | "mobx-react": "^6.1.8", 13 | "react": "^16.6.3", 14 | "react-apollo": "^3.1.3", 15 | "react-dom": "^16.6.3", 16 | "react-icons": "^3.9.0", 17 | "react-router-dom": "^4.3.1", 18 | "react-scripts": "2.1.1" 19 | }, 20 | "scripts": { 21 | "start": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "eslintConfig": { 27 | "extends": "react-app" 28 | }, 29 | "browserslist": [ 30 | ">0.2%", 31 | "not dead", 32 | "not ie <= 11", 33 | "not op_mini all" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-appsync-chat/5770183dce67f010baf8bfa80d572e39c73c9669/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 23 |404 no route found
} /> 18 |{conversationName}
54 |{m.content}
61 |Conversations
26 | { 27 | conversations.map((item, i) => ( 28 | 29 |{item.name}
32 |Convos
17 | 18 | 22 |Users
23 | 24 | 28 |Profile
29 | 30 |New Conversation
35 |Create new conversation with {username}?
36 | 37 |Yes
39 |Cancel
42 |Profile
23 |Username: {username}
24 |Email: {email}
25 |Sign Out
27 |Users
36 | { 37 | users.map((u, i) => ( 38 |{u.username}
44 |