{"id":28323148,"url":"https://github.com/one-click-auth/trustauthx_ts_sdk","last_synced_at":"2025-10-14T16:57:43.687Z","repository":{"id":207620029,"uuid":"718271276","full_name":"One-Click-Auth/Trustauthx_TS_SDK","owner":"One-Click-Auth","description":"Official Typescript Server-Side SDK of TrustAuthx","archived":false,"fork":false,"pushed_at":"2023-12-29T14:14:10.000Z","size":114,"stargazers_count":2,"open_issues_count":4,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-23T22:43:36.047Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/One-Click-Auth.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-11-13T18:35:34.000Z","updated_at":"2024-03-30T22:08:06.000Z","dependencies_parsed_at":"2023-12-29T15:27:19.247Z","dependency_job_id":"af100c86-7fdd-473f-a226-c7743d5f63d9","html_url":"https://github.com/One-Click-Auth/Trustauthx_TS_SDK","commit_stats":null,"previous_names":["one-click-auth/trustauthx_ts_sdk"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/One-Click-Auth/Trustauthx_TS_SDK","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-Click-Auth%2FTrustauthx_TS_SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-Click-Auth%2FTrustauthx_TS_SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-Click-Auth%2FTrustauthx_TS_SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-Click-Auth%2FTrustauthx_TS_SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/One-Click-Auth","download_url":"https://codeload.github.com/One-Click-Auth/Trustauthx_TS_SDK/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-Click-Auth%2FTrustauthx_TS_SDK/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019610,"owners_count":26086760,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-05-25T15:10:59.903Z","updated_at":"2025-10-14T16:57:43.682Z","avatar_url":"https://github.com/One-Click-Auth.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TrustAuthX SDK\n\nThe TrustAuthX SDK enables seamless integration with the TrustAuthX authentication service. This TypeScript client, `AuthLiteClient`, simplifies the interaction with TrustAuthX in your projects.\n\n## Installation\n\n```bash\nnpm install trustauthx-sdk\n```\n\n## Usage Example\n\n```typescript\nimport dotenv from 'dotenv';\nimport { AuthLiteClient } from 'trustauthx-sdk';\n\ndotenv.config();\n\n// Load your environment variables\nconst apiKey: string = process.env.API_KEY || '';\nconst apiSecret: string = process.env.API_SECRET || '';\nconst orgId: string = process.env.ORG_ID || '';\n\n// Placeholder for the user access token\nconst userAccessToken: string = 'placeholder-user-access-token';\n\nconst test = async () =\u003e {\n  // Initialize the AuthLiteClient\n  const auth = new AuthLiteClient(apiKey, apiSecret, orgId);\n\n  // Get user data using the provided user access token\n  const user = await auth.getUser(userAccessToken);\n\n  // Retrieve user information from the user access token\n  const userInfo = await auth.getUserFromToken(user.access_token);\n  console.log({ user: userInfo });\n};\n\ntest();\n```\n\nMake sure to replace the placeholder for `userAccessToken` with the actual user access token you want to use for testing. Additionally, ensure that your environment variables (`API_KEY`, `API_SECRET`, `ORG_ID`) are properly configured.\n\n### Constructor\n\n```typescript\nconstructor(apiKey: string, secretKey: string, orgId?: string)\n```\n\n- **Description:** Initializes an instance of the `AuthLiteClient` class.\n- **Parameters:**\n  - `apiKey`: The API key used for authentication.\n  - `secretKey`: The secret key used for JWT encoding.\n  - `orgId`: (Optional) The organization ID.\n\n### `jwtEncode` Method\n\n```typescript\nprivate jwtEncode(key: string, data: object): string\n```\n\n- **Description:** Encodes data into a JSON Web Token (JWT) using the provided key.\n- **Parameters:**\n  - `key`: The secret key for encoding.\n  - `data`: The data to be encoded.\n- **Returns:** The encoded JWT.\n\n### `jwtDecode` Method\n\n```typescript\nprivate jwtDecode(token: string): any\n```\n\n- **Description:** Decodes a JSON Web Token (JWT).\n- **Parameters:**\n  - `token`: The JWT to be decoded.\n- **Returns:** The decoded data.\n\n### `generateUrl` Method\n\n```typescript\ngenerateUrl(subDomain?: string): string\n```\n\n- **Description:** Generates the authentication URL.\n- **Parameters:**\n  - `subDomain`: (Optional) The subdomain for the URL.\n- **Returns:** The generated URL.\n\n### `generateEditUserUrl` Method\n\n```typescript\ngenerateEditUserUrl(accessToken: string, url: string): string\n```\n\n- **Description:** Generates the URL for editing user settings.\n- **Parameters:**\n  - `accessToken`: The user's access token.\n  - `url`: The target URL.\n- **Returns:** The generated URL.\n\n### `reAuth` Method\n\n```typescript\nasync reAuth(code: string): Promise\u003c{ email: string; uid: string }\u003e\n```\n\n- **Description:** Initiates re-authentication using a code.\n- **Parameters:**\n  - `code`: The re-authentication code.\n- **Returns:** A promise that resolves to an object containing the user's email and UID.\n\n### `getUser` Method\n\n```typescript\nasync getUser(token: string): Promise\u003cGetUser\u003e\n```\n\n- **Description:** Gets user authentication data.\n- **Parameters:**\n  - `token`: The user's authentication token.\n- **Returns:** A promise that resolves to user data.\n\n### `getAccessTokenFromRefreshToken` Method\n\n```typescript\nasync getAccessTokenFromRefreshToken(refreshToken: string): Promise\u003cany\u003e\n```\n\n- **Description:** Retrieves an access token from a refresh token.\n- **Parameters:**\n  - `refreshToken`: The refresh token.\n- **Returns:** A promise that resolves to the new access token.\n\n### `validateAccessToken` Method\n\n```typescript\nasync validateAccessToken(access_token: string): Promise\u003cboolean\u003e\n```\n\n- **Description:** Validates an access token.\n- **Parameters:**\n  - `access_token`: The access token to validate.\n- **Returns:** A promise that resolves to `true` if the token is valid, `false` otherwise.\n\n### `revokeToken` Method\n\n```typescript\nasync revokeToken(\n  accessToken: string,\n  refreshToken: string | null = null,\n  revokeAllTokens: boolean = false,\n): Promise\u003cboolean\u003e\n```\n\n- **Description:** Revokes a token.\n- **Parameters:**\n  - `accessToken`: The access token to revoke.\n  - `refreshToken`: (Optional) The refresh token.\n  - `revokeAllTokens`: (Optional) Whether to revoke all tokens.\n- **Returns:** A promise that resolves to `true` if the token revocation is successful, `false` otherwise.\n\n### `getUserFromToken` Method\n\n```typescript\nasync getUserFromToken(accessToken: string): Promise\u003c{ uid: string; email: string; img: string }\u003e\n```\n\n- **Description:** Gets user data from an access token.\n- **Parameters:**\n  - `accessToken`: The access token.\n- **Returns:** A promise that resolves to an object containing the user's UID, email, and image.\n\n### `validateTokenSet` Method\n\n```typescript\nasync validateTokenSet(\n  access_token: string,\n  refresh_token: string,\n): Promise\u003cTokenCheck\u003e\n```\n\n- **Description:** Validates a pair of access and refresh tokens.\n- **Parameters:**\n  - `access_token`: The access token to validate.\n  - `refresh_token`: The refresh token to validate.\n- **Returns:** A promise that resolves to an object containing the validation state and new tokens (if refreshed).\n\n## Support 💬\n\nIf you have any questions, feedback, or issues, please feel free to contact us at support@trustauthx.com. We are always happy to hear from you and help you with your integration.\n\n## License 📄\n\nTrustAuthX Python Connector SDK is licensed under the MIT License. See the [LICENSE] file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fone-click-auth%2Ftrustauthx_ts_sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fone-click-auth%2Ftrustauthx_ts_sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fone-click-auth%2Ftrustauthx_ts_sdk/lists"}