1.1.5 • Published 5 months ago

@socian/socian-auth-client v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Socian Auth Server - SDK - Node

npm install npm run build

Installation

npm i @socian/socian-auth-client

or

yarn add @socian/socian-auth-client

Examples

// 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()
// 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()
1.1.1

5 months ago

1.1.5

5 months ago

1.1.4

5 months ago

1.1.3

5 months ago

1.1.2

5 months ago

1.1.0

5 months ago

1.0.57

12 months ago

1.0.56

1 year ago

1.0.55

1 year ago

1.0.54

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

4.0.50

1 year ago

1.0.49

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago