{"id":13536706,"url":"https://github.com/Liftric/cognito-idp","last_synced_at":"2025-04-02T03:30:59.240Z","repository":{"id":40562685,"uuid":"278147738","full_name":"Liftric/cognito-idp","owner":"Liftric","description":"Lightweight AWS Cognito Identity Provider client for Kotlin Multiplatform and Typescript projects.","archived":false,"fork":false,"pushed_at":"2023-11-30T07:43:26.000Z","size":532,"stargazers_count":33,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T09:53:30.671Z","etag":null,"topics":["android","auth","aws","aws-cognito","cognito","cognito-api","cognito-idp","hacktoberfest","identity-provider","ios","kotlin","kotlin-multiplatform","kotlin-native","liftric","typescript"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Liftric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"Contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-07-08T17:03:51.000Z","updated_at":"2025-02-21T09:56:28.000Z","dependencies_parsed_at":"2023-10-15T13:21:20.267Z","dependency_job_id":"2f3f64ea-e51e-4fe5-a9ac-ae0eb3e915b3","html_url":"https://github.com/Liftric/cognito-idp","commit_stats":null,"previous_names":["liftric/auth"],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Liftric%2Fcognito-idp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Liftric%2Fcognito-idp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Liftric%2Fcognito-idp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Liftric%2Fcognito-idp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Liftric","download_url":"https://codeload.github.com/Liftric/cognito-idp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246750975,"owners_count":20827811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","auth","aws","aws-cognito","cognito","cognito-api","cognito-idp","hacktoberfest","identity-provider","ios","kotlin","kotlin-multiplatform","kotlin-native","liftric","typescript"],"created_at":"2024-08-01T09:00:47.572Z","updated_at":"2025-04-02T03:30:58.750Z","avatar_url":"https://github.com/Liftric.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":["Network","🧩 Service SDK"],"readme":"![CI](https://github.com/Liftric/cognito-idp/workflows/CI/badge.svg) \n![maven-central](https://img.shields.io/maven-central/v/com.liftric/cognito-idp?label=Maven%20Central) \n![OSS Sonatype (Releases)](https://img.shields.io/nexus/r/com.liftric/cognito-idp?label=Sonatype%20OSSRH%20%28Releases%29\u0026server=https%3A%2F%2Fs01.oss.sonatype.org)\n![npm (scoped)](https://img.shields.io/npm/v/@liftric/cognito-idp)\n![platforms](https://img.shields.io/badge/platforms-android%20%7C%20ios%20%7C%20jvm%20%7C%20js-blue)\n# Cognito-idp\n\nLightweight AWS Cognito Identity Provider client for Kotlin Multiplatform and Typescript projects.\n\n\u003e Not all requests, errors, and auth flows are implemented.  \n\u003e Feel free to [contribute](Contributing.md) if there is something missing for you.\n\n\u003e Version 2 introduced breaking changes, please refer to the [migration](Migrating.md) document for help.\n\n## Import\n\n### Kotlin\n\n#### Gradle \n\n```kotlin\nsourceSets {\n    val commonMain by getting {\n        dependencies {\n            implementation(\"com.liftric:cognito-idp:\u003cversion\u003e\")\n        }\n    }\n}\n```\n\n### Typescript\n\n#### Yarn\n```bash\nyarn add @liftric/cognito-idp@\u003cversion\u003e\n```\n#### npm\n```sh\nnpm i @liftric/cognito-idp@\u003cversion\u003e\n```\n\n## How-to\n\n### Init\n\n#### Kotlin\n\n```kotlin\nval provider = IdentityProviderClient(\"\u003cregion\u003e\", \"\u003cclientId\u003e\") \n```\n\n#### Typescript\n\n```typescript\nimport {IdentityProviderClientJS} from '@liftric/cognito-idp';\n\nconst provider = new IdentityProviderClientJS('\u003cregion\u003e', '\u003cclientId\u003e');\n```\n\n### Usage\n\n#### Kotlin\n\nAll methods are suspending and return a `Result\u003cT\u003e`, which wraps the desired object `T` on success or a `Throwable` on failure.\n\n```kotlin\nprovider.signUp(\"user\", \"password\").fold(\n    onSuccess = {\n        // Do something\n    },\n    onFailure = {\n        // Handle exceptions\n    }\n)\n```\n\n#### Typescript\n\nAll methods return a [Promise](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u003cT\u003e object.\n\n### Errors\n\nRequest related exceptions are defined as a sealed class of type `IdentityProviderException`. They contain the http `status` code and the `message`. Common AWS exceptions are implemented as subclasses. In case that we don't have implemented the exception type it will default to `IdentityProviderException.Unknown`, which will contain the AWS exception `type`.\n\nNetwork related exceptions (e.g. no internet) are of type `IOException`.\n\n### Requests \n\n#### Sign Up\n\nSigns up the user.\n\nAttributes are optional.\n\n```kotlin\nval attribute = UserAttribute(\"email\", \"name@url.tld\")\nsignUp(\"\u003cusername\u003e\", \"\u003cpassword\u003e\", listOf(attribute)): Result\u003cSignUpResponse\u003e\n```\n\n#### Confirm Sign Up\n\nConfirms the sign up (also the delivery medium).\n\n```kotlin\nconfirmSignUp(\"\u003cusername\u003e\", \"\u003cconfirmationCode\u003e\"): Result\u003cUnit\u003e\n```\n\n#### Resend Confirmation Code\n\nResends the confirmation code.\n\n```kotlin\nresendConfirmationCode(\"\u003cusername\u003e\"): Result\u003cCodeDeliveryDetails\u003e\n```\n\n#### Sign In\n\nSigns in the users.\n\n```kotlin\nsignIn(\"\u003cusername\u003e\", \"\u003cpassword\u003e\"): Result\u003cSignInResponse\u003e\n```\n\n#### Respond To Auth Challenge\n\nResponds to the auth challenge of the sign in response.\n\n```kotlin\nval challengeResponses = mapOf\u003cString, String\u003e()\nrespondToAuthChallenge(\"\u003cchallengeName\u003e\", challengeResponses, \"\u003csession\u003e\"): Result\u003cSignInResponse\u003e\n```\n\n#### Refresh access token\n\nRefreshes access token based on refresh token that's retrieved from an earlier sign in.\n\n```kotlin\nval signInResponse: SignInResponse = ... // from earlier login or refresh\nval refreshToken = signInResponse.AuthenticationResult.RefreshToken\nrefresh(refreshToken): Result\u003cSignInResponse\u003e\n```\n\n#### Get Claims\n\nYou can retrieve the claims of both the IdTokens' and AccessTokens' payload by converting them to either a `CognitoIdToken` or `CognitoAccessToken`\n\n```kotlin\nval idToken = CognitoIdToken(idTokenString)\nval phoneNumber = idToken.claims.phoneNumber\nval sub = idToken.claims.sub\n```\n\nCustom attributes of the IdToken get mapped into `customAttributes`.\n\nYou have to drop the `custom:` prefix.\n\n```kotlin\nval twitter = idToken.claims.customAttributes[\"twitter\"]\n```\n\n#### Get User\n\nReturns the users attributes and metadata on success.\n\nMore info about this in the [official documentation](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUser.html).\n\n```kotlin\ngetUser(\"\u003caccessToken\u003e\"): Result\u003cGetUserResponse\u003e\n```\n\n#### Update User Attributes\n\nUpdates the users attributes (e.g. email, phone number, ...).\n\n```kotlin\nval attributes: List\u003cUserAttribute\u003e = ...\nupdateUserAttributes(\"\u003caccessToken\u003e\", attributes): Result\u003cUpdateUserAttributesResponse\u003e\n```\n\n#### Change Password\n\nUpdates the users password \n\n```kotlin\nchangePassword(\"\u003caccessToken\u003e\", \"\u003ccurrentPassword\u003e\", \"\u003cnewPassword\u003e\"): Result\u003cUnit\u003e\n```\n\n#### Forgot Password\n\nInvokes password forgot and sends a confirmation code the the users' delivery medium.\n\nMore info about the ForgotPasswordResponse in the [official documentation](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CodeDeliveryDetailsType.html).\n\n```kotlin\nforgotPassword(\"\u003cusername\u003e\"): Result\u003cForgotPasswordResponse\u003e\n```\n\n#### Confirm Forgot Password\n\nConfirms forgot password.\n\n```kotlin\nconfirmForgotPassword(\"\u003cconfirmationCode\u003e\", \"\u003cusername\u003e\", \"\u003cnewPassword\u003e\"): Result\u003cUnit\u003e\n```\n\n#### Get user Attribute Verification Code\n\nGets the user attribute verification code for the specified attribute name\n\n```kotlin\ngetUserAttributeVerificationCode(\"\u003caccessToken\u003e\", \"\u003cattributeName\u003e\", \"\u003cclientMetadata\u003e\"): Result\u003cGetAttributeVerificationCodeResponse\u003e\n```\n\n#### Verify User Attribute\n\nVerifies the specified user attribute.\n\n```kotlin\nverifyUserAttribute(\"\u003caccessToken\u003e\", \"\u003cattributeName\u003e\", \"\u003cconfirmationCode\u003e\"): Result\u003cUnit\u003e\n```\n\n#### Sign Out\n\nSigns out the user globally.\n\n```kotlin\nsignOut(\"\u003caccessToken\u003e\"): Result\u003cSignOutResponse\u003e\n```\n\n#### Revoke Token\n\nRevokes all access tokens generated by the refresh token.\n\n```kotlin\nrevokeToken(\"\u003crefreshToken\u003e\"): Result\u003cUnit\u003e\n```\n\n\n#### Associate Software Token\n\nAssociate software token. Either with access token or session (not both).\n\n```kotlin\nassociateSoftwareToken(\"\u003caccessToken\u003e\", \"\u003csession\"): Result\u003cAssociateSoftwareTokenResponse\u003e\n```\n\n#### Verify Software Token\n\nVerifies software token. Either with access token or session (not both).\n\n```kotlin\nverifySoftwareToken(\"\u003caccessToken\u003e\", \"\u003cfriendlyDeviceName\u003e\", \"\u003csession\", \"\u003cuserCode\u003e\"): Result\u003cVerifySoftwareTokenResponse\u003e\n```\n\n#### Set User MFA Preference\n\nSet MFA preferences.\n\n```kotlin\nval smsMfaSettings = null\nval softwareTokenMfaSettings = MfaSettings(true, true)\nsetUserMFAPreference(\"\u003caccessToken\u003e\", smsMfaSettings, softwareTokenMfaSettings): Result\u003cUnit\u003e\n```\n\n#### Delete User\n\nDeletes the user from the user pool.\n\n```kotlin\ndeleteUser(\"\u003caccessToken\u003e\"): Result\u003cUnit\u003e\n```\n\n## License\n\nCognito-idp is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLiftric%2Fcognito-idp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLiftric%2Fcognito-idp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLiftric%2Fcognito-idp/lists"}