Skip to content

SelfKeyFoundation/relying-party-direct-demo

Repository files navigation

Login With Selfkey Demo for direct integrations

Contents

Usage

Install

git clone https://github.com/SelfKeyFoundation/relying-party-direct-demo.git
cd relying-party-direct-demo
npm install

Run

npm start

Run dev

npm run start-dev

SDK code examples

From routes/lws.js

// validate jwt token as challenge or access token
const decoded = await (tokenType === 'challenge'
	? sk.auth.validateChallengeToken(tokenString, JWT_ALGORITHM, JWT_SECRET)
	: sk.auth.validateAccessToken(tokenString, JWT_ALGORITHM, JWT_SECRET));
attributeManager = await sk.identity.AttributeManager.createWithSelfkeyRepository();
const challengeToken = await sk.auth.generateChallengeToken(did, JWT_ALGORITHM, JWT_SECRET)
const isValid = await sk.auth.verifyChallengeSignature(nonce, signature, did);
const accessToken = await sk.auth.generateAccessToken(did, JWT_ALGORITHM, JWT_SECRET);
// Validate attributes based on requirements (LWS_TEMPLATE)
const {
	attributes: validated,
	errors,
	valid
} = await req.attributeManager.validateAttributes(attributes, LWS_TEMPLATE);
// create a human readable attribute map
// [{schemaId: 'http://platform.selfkey.org/schema/attribute/first-name.json', data: 'first name'}]
// Becomes
// { firstName: {schemaId: 'http://platform.selfkey.org/schema/attribute/first-name.json', data: 'first name'}}
attributes = sk.identity.utils.attributeMapBySchema(validated);
const jwt = await sk.jwt.issueJWT(did, JWT_ALGORITHM, JWT_SECRET);
const decoded = await sk.jwt.validateJWT(token, JWT_ALGORITHM, JWT_SECRET);

License

The GPL-3.0 License

Copyright (c) 2018 SelfKey Foundation https://selfkey.org/

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published