Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@geens_npo/defined-id
Advanced tools
An open-source library with the core components for the defined.id identity solution built on the [NEM Blockchain](https://nem.io/).
An open-source library with the core components for the defined.id identity solution built on the NEM Blockchain.
npm install @geens_npo/defined-id
Import Defined.id package.
Example:
import "@geens_npo/defined-id";
//to import specific module
import {SecurityService} from "@geens_npo/defined-id";
Initializes derived keys based on a password.
Example:
const password = "password";
const derivedKey = SecurityService.scrypt(password);
Generate random seed.
Example:
const seed = SeedService.generateSeed();
Generate key.
Example:
const keyId = 1;
const seed = "b8e4c8c72e5ac28d01d2712729cd381548e8a4982df82b97f4778179165aa4b1eaae41dc54a6328721b05fd1025736d80cc19e9bc4abe6423a85c1114a4b6188";
const personaId = 1;
const connectionId = 2;
const key = new Key(
// @ts-ignore
Purposes.find(keyId),
seed,
personaId,
connectionId
);
Example:
const didProver = "did:defined:166evUDhpSSq23xP26oeQ4uNZNZce1KFFP";
const didVerifier = "did:defined:1ATaPiJdX2u4NHeYVux1iYcdDCTrXpdoxC";
const poo = new ProofOfOwnership(didProver, didVerifier, key.publicKey);
const errors = ProofOfOwnershipService.proveOwnership(poo, key.privateKey64);
Verify a proof of ownership for a public key.
Example:
const didProver = "did:defined:166evUDhpSSq23xP26oeQ4uNZNZce1KFFP";
const didVerifier = "did:defined:1ATaPiJdX2u4NHeYVux1iYcdDCTrXpdoxC";
const signature = "YFipwAdFVonV4/9zQjPdzPLArX181RAaK3UvXixQ7Rg0lX/sz8FLEK4sJU+2zJhAPHIFlNyD87+9wsBWTRf1Aw==";
const publicKeyBytes = Buffer.from("ccc98085b11e5b96c614036294be077d0b66a272b6476d3ba7eb440a3c2df00d", "hex");
const timestampDate: Date = new Date(1548947150636);
const poo: ProofOfOwnership = new ProofOfOwnership(didProver, didVerifier, publicKeyBytes, timestampDate, signature);
const errors = ProofOfOwnershipService.verify(poo);
Generate DID.
Example:
const method = "defined";
const nemPublicKey = "D98C8B7478E0255127E24B7C0752B78B5D4A90F1454FA9D8CD262ABF665B2B1B";
const did: Did = new Did(method, nemPublicKey);
DID document generation.
Example:
const services : IService[] = [
{ "did" : did.format(),
"serviceName": "openid",
"type": "OpenIdConnectVersion1.0Service",
"serviceEndpoint": "https://openid.example.com/"
},
{ "did" : did.format(),
"serviceName": "vcr",
"type": "CredentialRepositoryService",
"serviceEndpoint": "https://repository.example.com/service/8377464"
},
{ "did" : did.format(),
"serviceName": "xdi",
"type": "XdiService",
"serviceEndpoint": "https://xdi.example.com/8377464"
}
];
const publicKey : IPublicKey =
{
"id": did.format() + "#authentication-key-1",
"owner": did.format(),
"type": "Ed25519VerificationKey2018",
"publicKeyHex": key.publicKey.toString('hex').toUpperCase(),
}
const didDocument: IDidDocument = {
context: ['https://w3id.org/did/v1', 'https://w3id.org/security/v1'],
id: did.format(),
salt: did.salt,
publicKey: [publicKey],
service: services,
created: (new Date()).toISOString()
};
Verifiable claim document generation.
Example:
const context = ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/security/v2'];
const type = ['VerifiableCredential'];
const issuer = "Defined.id";
const claim = {
"id": "http://defined.id/vc/1",
"firstName": "Defined",
"lastName": "Id"
};
const issuanceDate = "2018-10-10";
const expirationDate = "2020-10-10";
const document: IVerifiableClaimDocument = {
context: context,
id: did.format(),
type: type,
issuer: issuer,
claim: claim,
issuanceDate: issuanceDate,
expirationDate: expirationDate
};
Add proof to a document.
Example:
const document = {
"context": [
"https://w3id.org/did/v1",
"https://w3id.org/security/v1"
],
"id": "did:defined:166evUDhpSSq23xP26oeQ4uNZNZce1KFFP",
"salt": "52e1aea9-c6ac-4af2-bec0-aaf9cd30a182",
"publicKey": [
{
"id": "did:defined:166evUDhpSSq23xP26oeQ4uNZNZce1KFFP#authentication-key-1",
"owner": "did:defined:166evUDhpSSq23xP26oeQ4uNZNZce1KFFP",
"type": "Ed25519VerificationKey2018",
"publicKeyHex": "0023757068c19dd7b51531ed327c0e000e7f737a3611a7374015618988aa733bb8"
},
{
"id": "did:defined:166evUDhpSSq23xP26oeQ4uNZNZce1KFFP#granting-key-2",
"owner": "did:defined:166evUDhpSSq23xP26oeQ4uNZNZce1KFFP",
"type": "Ed25519VerificationKey2018",
"publicKeyHex": "00e8b5ce1df5c8984511591967b17ae0913581e2daca7b403507536b0294c6eacd"
}
],
"service": [
{
"serviceName": "openid",
"type": "OpenIdConnectVersion1.0Service",
"serviceEndpoint": "https://openid.example.com/"
},
{
"serviceName": "vcr",
"type": "CredentialRepositoryService",
"serviceEndpoint": "https://repository.example.com/service/8377464"
},
{
"serviceName": "xdi",
"type": "XdiService",
"serviceEndpoint": "https://xdi.example.com/8377464"
}
],
"created": "2019-03-01T09:53:34.698Z"
};
const proofDocument = ProofOfDocumentService.generateProof(document, key.key, "http://www.defined.id");
Generate document sha256 hash.
Example:
const documentHash = SecurityService.sha256StringHash(JSON.stringify(didDocument))
Example:
const nemCatapultBlockchain = "PublicTestnet";
const documentHash = "caf6c9e744640159cc972fc83bbb44e09141cfc2c205274cb9cb08a583bbeec5";
const nemAccount = new NemAccount(key.key, nemCatapultBlockchain);
const nodeUri = "http://localhost:3000";
NemTransactionService.timestampTransaction(nemAccount, documentHash, nodeUri).then((transaction) => {
console.log(transaction);
}).catch((error) => {
console.log(error);
})
Example:
const nemPublicKey = "D98C8B7478E0255127E24B7C0752B78B5D4A90F1454FA9D8CD262ABF665B2B1B";
const nemCatapultBlockchain = "PublicTestnet";
const documentHash = "caf6c9e744640159cc972fc83bbb44e09141cfc2c205274cb9cb08a583bbeec5";
const nodeUri = "http://localhost:3000";
return NemTransactionService.getTransactionIndexForHash(nemPublicKey, documentHash, nodeUri, nemCatapultBlockchain).then((result) => {
let info;
switch (result) {
case -1:
info = "Hash was not registered";
break;
case 0:
info = "Hash was registered";
break;
default:
info = "Hash was registered but is outdated";
break;
}
}).catch((error) => {
console.log(error);
})
Clone Github repository to run tests:
git clone https://github.com/GeensNPO/Defined.id.git
Install npm packages:
npm install
Run tests:
npm test
This project is developed and maintained by Geens NPO. Contributions are welcome and appreciated. Feel free to start an issue or create a pull request.
Copyright (c) 2019 Geens NPO. Licensed under the LGPL v3.
FAQs
An open-source library with the core components for the defined.id identity solution built on the [NEM Blockchain](https://nem.io/).
We found that @geens_npo/defined-id demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.