{"id":24525855,"url":"https://github.com/cidaas/cidaas-javascript-sdk","last_synced_at":"2025-04-14T14:23:50.883Z","repository":{"id":37963272,"uuid":"155366343","full_name":"Cidaas/cidaas-javascript-sdk","owner":"Cidaas","description":"With this SDK, you can integrate cidaas smoothly and with minimal effort into your javascript application. It enables you to map the most important user flows for OAuth2 and OIDC compliant authentication. Secure – Fast – And unrivaled Swabian.","archived":false,"fork":false,"pushed_at":"2024-10-22T07:56:37.000Z","size":3140,"stargazers_count":7,"open_issues_count":5,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-23T11:24:13.378Z","etag":null,"topics":["cidaas","javascript","js","oauth2","oidc","openid-connect"],"latest_commit_sha":null,"homepage":"https://www.cidaas.com","language":"TypeScript","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/Cidaas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-30T10:28:11.000Z","updated_at":"2024-10-22T07:56:59.000Z","dependencies_parsed_at":"2024-10-23T03:21:05.711Z","dependency_job_id":null,"html_url":"https://github.com/Cidaas/cidaas-javascript-sdk","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cidaas%2Fcidaas-javascript-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cidaas%2Fcidaas-javascript-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cidaas%2Fcidaas-javascript-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cidaas%2Fcidaas-javascript-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cidaas","download_url":"https://codeload.github.com/Cidaas/cidaas-javascript-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248895321,"owners_count":21179221,"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":["cidaas","javascript","js","oauth2","oidc","openid-connect"],"created_at":"2025-01-22T05:29:06.455Z","updated_at":"2025-04-14T14:23:50.872Z","avatar_url":"https://github.com/Cidaas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo](https://raw.githubusercontent.com/Cidaas/cidaas-javascript-sdk/master/logo.jpg)\n\n## About cidaas:\n[cidaas](https://www.cidaas.com)\n is a fast and secure Cloud Identity \u0026 Access Management solution that standardises what’s important and simplifies what’s complex.\n\n## Feature set includes:\n* Single Sign On (SSO) based on OAuth 2.0, OpenID Connect, SAML 2.0 \n* Multi-Factor-Authentication with more than 14 authentication methods, including TOTP and FIDO2 \n* Passwordless Authentication \n* Social Login (e.g. Facebook, Google, LinkedIn and more) as well as Enterprise Identity Provider (e.g. SAML or AD) \n* Security in Machine-to-Machine (M2M) and IoT\n\n# Cidaas Javascript SDK\n\nThis cidaas javascript SDK library is built on the top of [OIDC client typescript library](https://github.com/authts/oidc-client-ts). \n\nPlease check the [Changelog](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/CHANGELOG.md) for more information about the latest release.\n\n## Table of Contents\n\n\u003c!--ts--\u003e\n* [Overview](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/overview/overview.md)\n* [Documentation](https://cidaas.github.io/cidaas-javascript-sdk)\n* [Installation](#installation)\n* [Initialisation](#initialisation)\n* [Usage](#usage)\n* [Functions Overview](#functions-overview)\n* [Possible Error](#possible-error)\n\n### Overview\n\n[Here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/overview/overview.md) you can find general overview of cidaas javascript SDK\n\n### Documentation\n\n[Here](https://cidaas.github.io/cidaas-javascript-sdk) you can find technical documentation of cidaas javascript SDK\n\n### Installation\n\nFrom CDN\n\n```html\n\u003c!-- Replace the required \u003cversion\u003e in the script tag, example: 4.0.0. All the released tag can be found https://www.npmjs.com/package/cidaas-javascript-sdk?activeTab=versions --\u003e\n\u003cscript src=\"https://cdn.cidaas.de/javascript/oidc/\u003cversion\u003e/cidaas-javascript-sdk.min.js\"\u003e\u003c/script\u003e\n```\n\nFrom npm\n\n```\nnpm install cidaas-javascript-sdk\n```\n\n### Initialisation\n\nAfter adding the sdk library, create a local file such as **cidaas.service.ts** and define Oidc settings variable there for initializing cidaas sdk.\n\nOidc settings variable support every [OIDC Client UserManagerSettings Properties](https://authts.github.io/oidc-client-ts/interfaces/UserManagerSettings.html) which has the following notable properties:\n\n| Property Name | Required | Description |\n| ------ | ------ | ------ |\n| authority | yes | cidaas instance base url |\n| client_id | yes | client application's identifier, which could be found in cidaas admin ui |\n| redirect_uri | yes | URL to be redirected after successful login attempt. |\n| post_logout_redirect_uri | no | URL to be redirected after successful logout attempt. |\n| scope | no | the scope the application requires and requests from cidaas. The default value is 'openid' if no properties is being sent. |\n| userStore | no | define where authenticated user information will be saved on the client application. The default value is session storage if no properties is being sent. |\n| automaticSilentRenew | no | configure whether automatic token renewal will be activated. The default value is true. |\n\nan example of Oidc settings variable looks like this:\n\n```js\nconst options = {\n    authority: 'your domain base url',\n    client_id: 'your app id',\n    redirect_uri: 'your redirect url',\n    post_logout_redirect_uri: 'your post logout redirect url',\n    scope: 'openid email roles profile',\n}\n```\n\n### Configure user storage (Optional)\n\nThe following storages are supported to store authenticated user information, such as tokens information \u0026 user profile:\n* window.sessionStorage (default)\n* window.localStorage\n* InMemoryWebStorage (all Information will be cleared after browser refresh) in case user do not want to save token in window object\n\nadditionally, user can also define custom storage in the client side by implementing Storage class.\n\nIf there is no userStore properties being send in Oidc settings variable, it will use session storage by default.\n\nIn case local storage is prefered to be used, then Oidc settings can be modified as following:\n\n```js\nconst options = {\n    authority: 'your domain base url',\n    ...,\n    userStore: new WebStorageStateStore({ store: window.localStorage })\n}\n```\n\nIn case custom solution for storing authenticated user information is being used, or saving the token in memory is preferred, you can configured userStore with InMemoryWebStorage. Authenticated user information will be cleared as soon as the page is refreshed afterwards.\n\n```js\nconst options = {\n    authority: 'your domain base url',\n    ...,\n    userStore: new WebStorageStateStore({ store: new InMemoryWebStorage()})\n}\n```\n\nsee [usage](#get-tokens-and-user-profile-information-from-user-storage) to get the stored informations from user storage.\n\n### Configure automatic token renewal (Optional)\n\nBy default, The SDK will generate new tokens based on refresh token stored in user storage, one minute before the access token is expiring. To disable this behaviour, Oidc settings can be modified as following:\n\n```js\nconst options = {\n    authority: 'your domain base url',\n    ...,\n    automaticSilentRenew: false\n}\n```\n\n### Initialise the cidaas sdk using the configured options mentioned above:\n\nCidaas ConfigUserProvider have to be initialised to be added to each of the modules as dependencies:\n\nExample of Cidaas Service:\n```js\nexport class CidaasService {\n    cidaasConfigUserProvider: ConfigUserProvider;\n    authenticationService: AuthenticationService;\n    verificationService: VerificationService;\n    options: OidcSettings = { ... };\n\n    constructor() {\n        // init ConfigUserProvider\n        this.cidaasConfigUserProvider = new ConfigUserProvider(this.options);\n        // init authentication module\n        this.authenticationService = new AuthenticationService(this.cidaasConfigUserProvider);\n        // init verification module\n        this.verificationService = new VerificationService(this.cidaasConfigUserProvider);\n    }\n\n    // get authentication module\n    getAuthenticationService() {\n        return this.authenticationService;\n    }\n\n    // get verification module\n    getVerificationService() {\n        return this.verificationService\n    }\n}\n```\n\nUsage in Component:\n ```js\n // inject cidaas service\nconstructor(private cidaasService: CidaasService, ...) {}\n\n...\n\n// init each of cidaas modules which are needed in the component\nthis.cidaasAuthenticationService = this.cidaasService.getAuthenticationService();\nthis.cidaasVerificationService = this.cidaasService.getVerificationService();\n\n...\n\n// call functions from each of the modules\nthis.cidaasAuthenticationService.loginCallback();\n...\nthis.cidaasVerificationService.getMFAList(getMFAListOptions);\n...\n\n```\n\n### Usage\n\n#### Login With Browser\n\nTo login through cidaas sdk, call **loginWithBrowser()**. This will redirect you to the hosted login page.\n\n```js\ncidaasAuthenticationService.loginWithBrowser();\n```\n\nonce login is successful, it will automatically redirects you to redirect_uri you have configured in Oidc settings. You will get information such as code \u0026 state as redirect url parameter (query or fragment), which is needed to get access token.\n\nTo complete the login process, call **logincallback()**.\n\n```js\ncidaasAuthenticationService.loginCallback().then(function(response) {\n    // the response will give you login details.\n}).catch(function(ex) {\n    // your failure code here\n});\n```\n\nAfter successful loginCallback, You will get access token, along with id token and refresh token in the json response, depends on your application configuration.\n\nThere are code documentations for each of the functions with example code of how to call them individually.\n\n#### Get Tokens And User Profile Information From User Storage\n\nTo get information from user storage, call **getUserInfoFromStorage()**. This function will fetch stored information from predefined user storage (session storage, local storage or in memory)\n\n```js\ncidaasAuthenticationService.getUserInfoFromStorage().then(function(response) {\n    // the response will contains tokens \u0026 user profile information.\n}).catch(function(ex) {\n    // your failure code here\n});\n```\n\n### Functions Overview\n\nCidaas javascript SDK functions can be found on the [documentation](https://cidaas.github.io/cidaas-javascript-sdk).\n\n## Possible Error\n\nThe SDK will throws Custom Exception if something went wrong during the operation:\n\n| HTTP Status Code | When could it be thrown |\n|----------------- | ----------------------- |\n|  500 | during creation of WebAuth instance |\n|  417 | if there are any other failure |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcidaas%2Fcidaas-javascript-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcidaas%2Fcidaas-javascript-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcidaas%2Fcidaas-javascript-sdk/lists"}