teko-market v0.0.5
Saas Marketplace Javascript Library for Web App
A Javascript Library for integrate Teko Market to Web Application.
Library contain 2 parts:
- Authentication and Authorization (TekoID)
Market component (app switcher / login form)
Getting started
import TekoMarket from 'teko-market'
const App = props => { if (TekoMarket.auth.user.isLoggedIn())
return <HomePageView userInfo={TekoMarket.auth.user.getUserInfo()} />
return <LoginView />}
const LoginView = props => ( <p onClick={() => TekoMarket.auth.user.login()}>
Login with TekoID </p>) Installation
# With yarn
yarn add teko-market
# With npm
npm install teko-market Then you can initiate the client using TekoID:
import TekoMarket from 'teko-market'
TekoMarket .init({
clientId: 'your-client-id',
redirectUri: 'your-redirect-uri',
oauthDomain: 'https://oauth.develop.tekoapis.net'
}).then(() => {
// The initial phase is finish.
// Now you can do your logic.
const rootElement = document.getElementById('root')
ReactDOM.render(<App />, rootElement)
}) which returns a promise and resolve after finish initiating.
For advance usage, please check examples folder.
NOTE: You can also include JS SDK teko-market.js in your source code, then access the lib using window.TekoMarket.
<script src="https://<market-domain>/v1/teko-market.js"></script>
var configs = {
clientId: "<your-client-id>", // Market provides when register client auth
redirectUrl: "<your-redirect-uri>", //App provides for redirect when login successfully.
}
TekoMarket.init(config); Embed market component
Remote components (using iframe)
<div class="market-menu">
<iframe src="https://saas-marketplace.dev.teko.vn/app-switcher"></iframe>
</div>Usage
async TekoMarket.init(configs)
Configure parameters for TekoMarket can work.
| key | Type | Default value | Required |
|:------------------------|:------------|:--------------------------|:----------|
| clientId | string | | Y |
|
| redirectUri | string | protocol//hostname:port |
clientId: The ID of your client which you registered in Identity Teko.redirectUri: Your client will redirect to this uri with authorization code value after user successfully logged in. This value should match exact with one of the
NOTE: For develop environment, please specific oauthDomain to https://oauth.develop.tekoapis.net
NOTE: TekoMarket.init() function is an async function.
TekoMarket.auth.user
Please refer to https://www.npmjs.com/package/teko-oauth2
TekoMarket.auth.user.events
Please refer to https://www.npmjs.com/package/teko-oauth2