This is a JS SDK library specifically for MySM SSO.
Testing
npm run test
Deployment
To update SDK JS library, stage value can be dev, qa and prod:
npm run build:js:{stage}
To publish on NPM:
npm run publish:package:{stage}
How to Use Packages
As a script tag library:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script src="/path/to/sdk/sm-sso-sdk-1.0.0.js"></script>
<script>
(function() {
const sso = new mySM.SSO({
env: 'dev',
apiKey: 'your api key',
appId: 'you app id here',
appSecret: 'your app secret here',
withPopup: true
});
const loginPayload = {
customer_email: 'test@email.com',
customer_password: 'Qwerty@12345'
}
sso.login(loginPayload)
.then(function(response){
})
.catch(function(error){
});
})();
</script>
</body>
</html>
As an NPM module:
import {SSO, IInitParams, ILogin} from 'sm-sso-sdk';
...
const ssoConfig: IInitParams = {
env: 'dev',
apiKey: 'your api key',
appId: 'you app id here',
appSecret: 'your app secret here',
withPopup: true
};
const sso = new SSO(ssoConfig);
const loginPayload: ILogin = {
customer_email: 'test@email.com',
customer_password: 'Qwerty@12345'
}
sso.login(loginPayload)
.then(response => {
})
.catch(error => {
});
Available Functions
Auth Popup
sso.showAuthPopup();
sso.authPopupCallback((response, error)=>{
console.log({ response, error })
});
Login
sso.login({
customer_email: 'test@email.com',
customer_password: 'Qwerty@12345'
})
.then(response => {
})
.catch(error => {
});
Logged User
sso.loggedUser('token you received from login');
Is Logged User
sso.isLoggedUser();
Logout User
sso.logoutUser('token you received from login');
Register
sso.register({
customer_firstname: 'fnametest',
customer_lastname: 'lnametest',
customer_mobile: 639101234567,
customer_email: 'test@yopmail.com',
customer_password: 'Qwerty@123'
})
.then(response => {
})
.catch(error => {
});
Forgot Password
sso.forgotPassword({
customer_mobile: 639101234567,
customer_email: 'test@yopmail.com'
})
.then(response => {
})
.catch(error => {
});
Activate Account
sso.activateAccount({
customer_otp: '123456',
customer_mobile: 639101234567,
customer_email: 'test@yopmail.com'
})
.then(response => {
})
.catch(error => {
});
Verify Account
sso.verifyAccount({
token: 't0k3n'
})
.then(response => {
})
.catch(error => {
});
Resend Verification
sso.resendVerification({
token: 't0k3n'
})
.then(response => {
})
.catch(error => {
});
Get User
sso.getUser('12345', 't0k3n')
.then(response => {
})
.catch(error => {
});
Update User
sso.updateUser('12345', 't0k3n', {
customer_firstname: 'updated first name'
})
.then(response => {
})
.catch(error => {
});
User Exists
sso.userExists('test@yopmail.com')
.then(response => {
})
.catch(error => {
});
Delete User
sso.deleteUser('12345', 't0k3n', 'password')
.then(response => {
})
.catch(error => {
});
Get User Token
sso.userToken();
Get App Token
sso.appToken();