kord-network / kord.js Goto Github PK
View Code? Open in Web Editor NEWKORD Network JavaScript Library
License: Other
KORD Network JavaScript Library
License: Other
/**
* Get the sub-property of a META Identity Profile Claim from the claim's property
*
* @example getProfileClaimSubPropertyFromProperty('profile.name') // => 'name'
*
* @param {String} property Profile claim property
* @return {String} Profile claim sub-property
*/
export const getProfileClaimSubPropertyFromProperty = property => {
return property.replace(new RegExp(`${PROFILE_CLAIM_PREFIX}.`, 'i'), '')
}
Could use a tool like zeit/release
The year stated in the copyright line for all license information headers needs to be updated to 2018.
createIdentityClaimObject
to createVerifiableIdentityClaimObject
./**
* Utility function to create a valid META Claim object to verify a new claim
*
* @param {Object} account Ethereum account object
* @param {String} account.address Account Ethereum address
* @param {String} account.privateKey Account private key
* @param {Object} claimMessage Raw claim message
* @param {String} subject META-ID `id` of subject (hash of `username`)
* @param {Object} extraData Any extra properties to add to claim object
* @return {Object} META Claim object
*/
export const createVerifiableIdentityClaimObject = (
account,
claimMessage,
subject,
extraData = {}
) => {
return {
address: account.address,
claimHash: bufferToHex(sha3(claimMessage)),
claimMessage: claimMessage,
subject: subject,
signature: accounts.signMessage(claimMessage, account.privateKey),
...extraData,
}
}
This is used by dapps to send claim verification requests to META Identity Claims Services
UPDATE: After a brief look into the options available, this is not feasible for now.
A thin utility that can wrap all library methods would be ideal. prop-types
looks like it could do the job and can be extended with customProp
s for non-standard props (like the Ethereum-specific props).
Some props/checks we'd need for now:
META_ID_SUFFIX
PROFILE_CLAIM_PREFIX
Replace lerna run
with yarn workspace run
when available. This will remove dependency on Lerna completely.
createVerifiedIdentityClaimObject
=> valid ClaimInput
propsClaimInput: {
claim, // raw claim value
issuer, // META-ID `id` of issuer
property, // claim key
signature, // claim signed by issuer
subject, // META-ID `id` of subject
}
This is used by META Identity Claims Services when returning verified claims data.
export const createVerifiedIdentityClaimObject = (claimMessage, subject) => {
// META Claims Service config
const metaClaimsService = {
... // from somewhere
}
// set the claim value being verified
const verifiedClaimValue = claimMessage // raw claim value
// generate verified claim buffer
const verifiedClaimBuffer = sha3(Buffer.concat([
toBuffer(metaClaimsService.id), // issuer ID
toBuffer(subject), // subject ID
toBuffer(metaClaimsService.property), // claim key
toBuffer(verifiedClaimValue), // claim value
]))
// generate ECDSA signature of verified claim buffer using the MCS private key
const verifiedClaimSignatureObject = ecsign(
verifiedClaimBuffer,
Buffer.from(metaClaimsService.privateKey, 'hex')
)
// convert ECDSA signature buffer to hex value
const verifiedClaimSignature = toRpcSig(
verifiedClaimSignatureObject.v,
verifiedClaimSignatureObject.r,
verifiedClaimSignatureObject.s
)
// return response body
return {
claim: verifiedClaimValue,
issuer: metaClaimsService.id,
property: metaClaimsService.property,
signature: verifiedClaimSignature,
subject: subject,
}
}
VERSION
global to core rollup.config.js
:import replace from 'rollup-plugin-replace'
const pkg = require('./package.json')
plugins: [
replace({
values: {
RPC: JSON.stringify(process.env.RPC),
VERSION: JSON.stringify(pkg.version),
},
}),
...
]
export {
...,
version: VERSION,
}
Could also use https://github.com/thejameskyle/fixturez if it is useful.
The createProfileMetaIdentityClaim
method returns an invalid identity claim object - specifically, the returned signature
value is incorrect.
The method should actually use the createVerifiedIdentityClaimObject
to generate a valid identity claim object like so:
/**
* Create a valid META Identity Claim object for a profile claim
* This is a self-issued claim, usually referencing a Swarm hash of profile data
*
* @param {String} claimMessage Raw identity claim message
* @param {Object} issuer Claim issuer data object
* @param {String} issuer.id META Identity `id` of claim issuer
* @param {String} issuer.privateKey Private key of claim issuer
* @param {String} subProperty Type of profile claim contained in `claimMessage`
* @return {Object} Verified META Identity Claim object
*/
export const createProfileMetaIdentityClaim = (
claimMessage,
issuer,
subProperty
) => {
return createVerifiedIdentityClaimObject(
claimMessage,
{
id: issuer.id,
privateKey: issuer.privateKey,
property: `profile.${subProperty}`,
},
issuer.id
)
}
meta.js
core APIidentity
APIidentity-claims
APIclaimService
should be changed to issuer
claimService.property
should be hoisted to property
/**
* Check if a META Identity claim is a profile claim
*
* @param {Object} claim META Identity Claim object
* @return {Boolean} Profile claim boolean
*/
export const isProfileClaim = claim => {
return claim.property.startsWith(`${PROFILE_CLAIM_PREFIX}.`)
}
Explore options:
meta.js
inter-package dependenciesconfig
object from core to @meta.js/shared
to avoid unnecessary inclusion of all modules for packages that depend on config values.Replace lerna publish
with https://github.com/sindresorhus/np#release-script
Will also need this bit of config for scoped packages.
As per discussion in kord-network/go-kord#57 - add a method to create META Identity Claim objects for profile attributes such as images, common names and web addresses.
export const createProfileMetaIdentityClaim = (account, claim, subProperty) => {
return {
claim: claim, // Swarm hash
issuer: account.address, // self-issued claim
property: `profile.${subProperty}`, // eg. `profile.image`
signature: signMessage(claim, account.privateKey),
subject: account.address,
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.