Integrate Web Component

Sign Partners Agreement

Go to the partners portal.
  1. 1.
    Select the market that fits best your platform.
  2. 2.
    Customize your community name, description, avatar, roles, and expected Commitment Level
  3. 3.
    Click Sign and Deploy!
  4. 4.
    Copy your partner's key to use when integrating the web component.
  5. 5.
    Customize your own SkillWallet to activate your community.

Web Component - what it does

This Web Component is SkillWallet's decentralized, role-based authentication system. It lets your users create an account, or login to your platform, in a fully decentralized way, while giving them a familiar (web2-like) experience. Each user will add their nickname and avatar, and pick a Role in your Community - after doing that, they will join your community, and claim their universal ID.

Web Component Developer notes

When a user successfully logs in their SkillWallet information is stored in the 'Session Storage' with the Key 'skillWallet'.

Pre-requisite: obtain your Partner's Key

This Web Component is cross-platform, and can be integrated on any Web framework. In order to use it, though, you will need to have a Partner's Key - you can get deploy your role-based community on the Blockchain, and receive your Partner's Key directly on our Partners Dapp.

Web Component installation

React App

  1. 1.
    Install the library npm i @skill-wallet/auth --save
  2. 2.
    Import the initialization function in the App.js/tsx (or index.js/tsx) import { InitSwAuth } from '@skill-wallet/auth';
  3. 3.
    Call the InitSwAuth function at the start of your project InitSwAuth();
  4. 4.
    Add the custom HTML tag and populate the partner-key property
Example
1
import './App.css';
2
import { InitSwAuth } from '@skill-wallet/auth;
3
​
4
function App() {
5
return (
6
<div>
7
<sw-auth partner-key="f4b83b4c8151fa92acc372a08a78c50ad5cab41f"></sw-auth>
8
</div>
9
);
10
}
11
​
12
InitSwAuth();
13
export default App;
Copied!

Angular

  1. 1.
    Install the library npm i @skill-wallet/auth --save
  2. 2.
    Import the initialization function in the app.component.ts import { InitSwAuth } from '@skill-wallet/auth';
  3. 3.
    Call the InitSwAuth function inside ngOnInit ngOnInit(): void { InitSwAuth(); }
  4. 4.
    Add the CUSTOM_ELEMENTS_SCHEMA in your app.module.ts import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
  5. 5.
    Add the custom HTML tag and populate the partner-key property
Example
app.component.ts:
1
import { Component, OnInit } from '@angular/core';
2
import { InitSwAuth } from '@skill-wallet/auth';
3
​
4
@Component({
5
selector: 'app-root',
6
templateUrl: './app.component.html',
7
styleUrls: ['./app.component.css'],
8
})
9
export class AppComponent implements OnInit {
10
ngOnInit(): void {
11
InitSwAuth();
12
}
13
title = 'ngular-app';
14
}
Copied!
app.module.ts:
1
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
2
import { BrowserModule } from '@angular/platform-browser';
3
​
4
import { AppComponent } from './app.component';
5
​
6
@NgModule({
7
schemas: [CUSTOM_ELEMENTS_SCHEMA],
8
declarations: [AppComponent],
9
imports: [BrowserModule],
10
providers: [],
11
bootstrap: [AppComponent],
12
})
13
export class AppModule {}
Copied!
app.component.ts:
1
...
2
<sw-auth
3
partner-key="your partner key here"></sw-auth>
4
...
Copied!

Vue

  1. 1.
    Install the library npm i @skill-wallet/auth --save
  2. 2.
    Import the initialization function in the App.vue import { InitSwAuth } from '@skill-wallet/auth';
  3. 3.
    Call the InitSwAuth function at the start of your project InitSwAuth();
  4. 4.
    Add the custom HTML tag and populate the partner-key property
Example
App.vue:
1
<script setup>
2
import { InitSwAuth } from "@skill-wallet/auth";
3
InitSwAuth();
4
</script>
5
​
6
<template>
7
<div class="wrapper">
8
<sw-auth
9
partner-key="0904d77ea971c3aff9e1d46410ab1600d8537641"
10
use-dev="true"
11
id="root"
12
use-button-options="true"
13
></sw-auth>
14
</div>
15
</template>
16
​
17
<style>
18
...
19
</style>
20
​
Copied!

Override button styles:

You can override all the styles of the button and the dropdown by providing CSSObjects to the InitSwAuth function.
Here's the default button style as an override:
1
InitSwAuth({
2
buttonStyles: {
3
cursor: 'pointer',
4
background: '#000000',
5
'& .MuiTypography-root': {
6
textTransform: 'none',
7
fontSize: '14px',
8
lineHeight: '25px',
9
fontWeight: '500',
10
},
11
'& .swButtonAvatar': { width: '36px', height: '36px' },
12
boxShadow: 'rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px',
13
'&:hover': {
14
background: '#FFFFFF',
15
borderColor: '#000000',
16
'& .swButtonText': {
17
color: '#000000',
18
mt: '4px',
19
},
20
},
21
height: '47px',
22
width: '180px',
23
},
24
});
Copied!
The optional dropdown (use-button-options) styles can also be overriden in the same way:
1
InitSwAuth({
2
dropdownStyles: {
3
'& .MuiMenu-list': {
4
padding: '0px',
5
},
6
'& .swButtonOption': {
7
cursor: 'pointer',
8
background: '#000000',
9
'& .swButtonOptionText': {
10
textTransform: 'none',
11
fontSize: '14px',
12
lineHeight: '25px',
13
fontWeight: '500',
14
},
15
'&:hover': {
16
background: '#FFFFFF',
17
borderColor: '#000000',
18
'& .swButtonOptionText': {
19
color: '#000000',
20
mt: '4px',
21
},
22
},
23
​
24
height: '40px',
25
width: '180px',
26
border: '0px',
27
},
28
boxShadow: 'rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px',
29
},
30
});
Copied!
NOTE: Sometimes in order to achieve your desired style you might need to override Mui styles. You can see which styles you need to override by inspecting the web component and it's elements in your browser Developer Tools.

Web Component Custom HTML element attributes:

  1. 1.
    partner-key The key you are given after signing a Partner's Agreement
  2. 2.
    use-dev Set to 'true' to use the 'Mumbai' TestNet
  3. 3.
    use-button-options If set to 'true' a dropdown will pop up when hovering over the Button. Currently, the only option is 'Logout'.

Web Component Helpful window events:

  1. 1.
    onSkillwalletLogin Dispatched when the user has 'Logged in'. This means that their skillWallet has been successfully retrieved and stored in the session storage (key is skillWallet).
  2. 2.
    onSkillWalletActivated Dispatched when a SkillWallet is successfully activated. This happens after the QR Code is scanned from the mobile app.
  3. 3.
    initSkillwalletAuth Dispatched after initialization - signifies that the web component has read the partner-key and is ready to use.
​

Congrats! πŸš€

That's it! πŸŽ‰πŸŽ‰πŸŽ‰
Your users can now create their SkillWallets and log in directly in your platform!