# @socian/socian-auth-client

> SocianAuthClient is a helper library for SocianAuth

Latest version **1.1.5** (published 2023-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @socian/socian-auth-client
pnpm add @socian/socian-auth-client
yarn add @socian/socian-auth-client
bun add @socian/socian-auth-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2023-12-10 |
| First published | 2023-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 20.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Saifur Rahman |
| Maintainers | srhasan, tamzid, mustafa23, tanvirsourov |
| Keywords | SocianAuth, Auth, Client |

## Links

- npm: https://www.npmjs.com/package/@socian/socian-auth-client
- Repository: https://github.com/Socian-Ltd/socian-auth-client-sdk
- Homepage: https://github.com/Socian-Ltd/socian-auth-client-sdk#readme
- Issues: https://github.com/Socian-Ltd/socian-auth-client-sdk/issues
- npm.io page: https://npm.io/package/@socian/socian-auth-client

## Dependencies (4)

- [react](https://npm.io/package/react.md) ^18.2.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^3.3.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.8.1
- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) ^3.0.0

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.1.5 (latest) — 2023-12-10
- 1.1.4 — 2023-12-10
- 1.1.3 — 2023-12-10
- 1.1.2 — 2023-12-10
- 1.1.1 — 2023-12-10
- 1.1.0 — 2023-12-09
- 1.0.57 — 2023-05-28
- 1.0.56 — 2023-02-02
- 1.0.55 — 2023-02-02
- 1.0.54 — 2023-01-31
- 1.0.53 — 2023-01-31
- 1.0.52 — 2023-01-31
- 1.0.51 — 2023-01-31
- 1.0.50 — 2023-01-31
- 4.0.50 — 2023-01-31
- … 14 more at https://npm.io/package/@socian/socian-auth-client/versions

## README

# Socian Auth Server - SDK - Node

npm install
npm run build

## Installation
```shell
npm i @socian/socian-auth-client
```

or  

```shell
yarn add @socian/socian-auth-client
```

## Examples

```javascript
// Sign In Example
import SocianAuthSDKClient from '@socian/socian-auth-node-sdk';

class MyClass {
	async runSignIn() {
		const authClientConfig = {
			"app_id": "socian-consumerbuzz-client_app_id_E3WDTFR77ZD7Q0J7",
			"app_secret": "socian-consumerbuzz-client_app_id_OMRHHVTAOD6A3EUG",
		}

		const authClient =   new SocianAuthSDKClient(authClientConfig)

		const credentials = {
			"email": "srhasan@socian.ai",
			"password": "password"
		}

		await authClient.signIn("credential", credentials)
		const authUser = await authClient.fetchUser()

		console.log('##### Socian Auth Server - SignIn Response #####')

		console.log({
			'intentId': authClient.getIntentId(),
			'intentObject': authClient.getIntentObject(),
			'loggedIn': authClient.getLoggedIn(),
			'authUser': authUser
		})

		if(authClient.getLoggedIn()){
			console.log("You are signed in - ", authUser?.name)
		}else{
			console.log("Sign In Failed - ", authUser?.name)
		}
	}
}

(new MyClass).runSignIn()
```

```javascript
// Sign Up Example

import SocianAuthSDKClient from '@socian/socian-auth-node-sdk';

class MyClass {
	// ...
    
	async runSignUp() {
		try{
			const authClientConfig = {
				"app_id": "socian-consumerbuzz-client_app_id_E3WDTFR77ZD7Q0J7",
				"app_secret": "socian-consumerbuzz-client_app_id_OMRHHVTAOD6A3EUG",
			}

			const authClient =   new SocianAuthSDKClient(authClientConfig)

			const randomId = this.generateId(1, 500)
			const newUserFormData = {
				"name": `AUTH SDK USER - ${randomId}`,
				"email": `auth-skd-user-${randomId}@socian.ai`,
				"password": "password"
			}

			await authClient.signUp("credential", newUserFormData)
			const newUserData = authClient.getNewUser()

			console.log('##### Socian Auth Server - Sign Up Response #####')

			console.log({
				'intentId': authClient.getIntentId(),
				'authUserEmail': newUserData?.email,
				'newUserData': newUserData
			})

			if(authClient.getNewUser()){
				console.log("Your account has been created - ", newUserData?.name)
			}else{
				console.log("Sign Up Failed.")
			}
		}catch(error) {
			console.error('Sign up Error:')
			console.error(error)
		}
	}

	generateId(min, max) {
		return Math.floor(Math.random() * (max - min + 1)) + min;
	}
}

(new MyClass).runSignUp()
```

---
_Source: https://npm.io/package/@socian/socian-auth-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
