2.0.1 • Published 1 year ago

identix-sso-client-js v2.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

npm.io

Identix SSO Client JS. Typescript supported.

License

This code licensed under MIT license.

MIT License

Installation

Install client with npm

npm install identix-sso-client-js

Usage/Examples

Client authentication

import {SsoService} from "identix-sso-client-js";

const ssoService = new SsoService('https://sso-api-dev.identix.space/graphql');
const clientDid = 'did:ever:123456';
const otcDid = await ssoService.requestClientLogin(clientDid)
const signedOtcDid = 'signed_' + otcDid;
const sessionTokenDid = await ssoService.attemptClientLogin(clientDid, signedOtcDid);
console.log(sessionTokenDid);

User authentication

try {
    await ssoService.validateUserSession(sessionTokenDid, userSessionDid);
} catch (e) {
    console.log(e); // User session is invalid
}
const user = await ssoService.getCurrentUserInfo(sessionTokenDid, userSessionDid);
console.log(user);

Sign / verify data

const message = 'Hello World';
const privateKey: string = ED25519Signer.Uint8ArrayToHex(ed.utils.randomPrivateKey());
const publicKey: string = ED25519Signer.Uint8ArrayToHex(await ed.getPublicKey(privateKey));

const signature = await ED25519Signer.signMessage({
    message,
    privateKey
});
console.log({signature});

const isValid = await ED25519Signer.verifyMessage({
    message,
    signature,
    publicKey
});
console.log({isValid});
2.0.1

1 year ago

2.0.0

1 year ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.6

2 years ago

1.1.2

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago