Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Fixed transpilations errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Exulansis committed Nov 17, 2018
1 parent 53d1e4a commit cb19ebd
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 102 deletions.
18 changes: 12 additions & 6 deletions config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// Private key associated with the service's identity
export const privateIdentityKey = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
import { IConstraint } from 'jolocom-lib/js/interactionTokens/interactionTokens.types'

// Where is your service deployed. E.g. https://demo-sso.jolocom.com
export const serviceUrl = ''
/**
* The seed to instantiate a vaulted key provider and password for seed encryption / decryption
* The need to persist the seed in clear text will be addressed in the next minor release
*/
export const seed = Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex')
export const password = 'correct horse battery staple'

// What credentials do you require during authentication, and associated constraints
/** Where is your service deployed. E.g. https://demo-sso.jolocom.com */
export const serviceUrl = 'https://demo-sso.jolocom.com'

/** What credentials do you require during authentication, and associated constraints */
export const credentialRequirements = [
{
type: ['Credential', 'ProofOfNameCredential'],
constraints: [{ '==': [true, true] }]
constraints: [] as IConstraint[]
}
]
5 changes: 3 additions & 2 deletions server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { configureRoutes } from './routes'
import { configureRedisClient } from './redis'
import { configureSockets } from './sockets'
import { JolocomLib } from 'jolocom-lib'
import { password, demoVault } from '../config'
import { password, seed } from '../config'

const app = express()
const server = new http.Server(app)
Expand All @@ -20,8 +20,9 @@ app.use(cors())

const { getAsync, setAsync, delAsync } = configureRedisClient()
const registry = JolocomLib.registries.jolocom.create()
const vaultedKeyProvider = new JolocomLib.keyProvider(seed, password)

registry.authenticate(demoVault, {derivationPath: JolocomLib.KeyTypes.jolocomIdentityKey, encryptionPass: password})
registry.authenticate(vaultedKeyProvider, {derivationPath: JolocomLib.KeyTypes.jolocomIdentityKey, encryptionPass: password})
.then(identityWallet => {
configureRoutes(app, {setAsync, getAsync, delAsync}, identityWallet, password)
configureSockets(server, identityWallet, password, new DbWatcher(getAsync), {getAsync, setAsync, delAsync})
Expand Down
24 changes: 16 additions & 8 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { CredentialResponse } from 'jolocom-lib/js/interactionFlows/credentialResponse/credentialResponse'
import { JolocomLib } from 'jolocom-lib'
import { getIssuerPublicKey } from 'jolocom-lib/js/utils/helper'
import { CredentialResponse } from 'jolocom-lib/js/interactionTokens/credentialResponse'

export const validateCredentialSignatures = async (credentialResponse: CredentialResponse): Promise<boolean> => {
const suppliedCredentials = credentialResponse.getSuppliedCredentials()
const registry = JolocomLib.registry.jolocom.create()

const credSignatureValidity = await Promise.all(suppliedCredentials.map(cred => registry.validateSignature(cred)))
const suppliedCredentials = credentialResponse.suppliedCredentials
const registry = JolocomLib.registries.jolocom.create()

/** The process of performing batch verifications will be improved soon */
const credSignatureValidity = await Promise.all(
suppliedCredentials.map(async cred => {
const issuer = await registry.resolve(cred.issuer)
const issuerPublicKey = getIssuerPublicKey(cred.signer.keyId, issuer.didDocument)
return JolocomLib.keyProvider.verifyDigestable(issuerPublicKey, cred)
})
)

if (!credSignatureValidity.every(entry => entry)) {
throw new Error('Invalid signature on presented credentials')
Expand All @@ -28,8 +36,8 @@ export const extractDataFromClaims = (credentialResponse: CredentialResponse): I
familyName: ''
}

credentialResponse.getSuppliedCredentials().forEach(credential => {
const claim = credential.getCredentialSection()
credentialResponse.suppliedCredentials.forEach(credential => {
const { claim } = credential
response = { ...response, ...claim }
})

Expand All @@ -40,4 +48,4 @@ export const randomString = (length: number) => {
return Math.random()
.toString(36)
.substr(2, length)
}
}
128 changes: 42 additions & 86 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1790,10 +1790,6 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

bech32@^1.1.2:
version "1.1.3"
resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.3.tgz#bd47a8986bbb3eec34a56a097a84b8d3e9a2dfcd"

better-assert@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522"
Expand All @@ -1804,10 +1800,6 @@ big.js@^3.1.3:
version "3.2.0"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e"

bigi@^1.1.0, bigi@^1.4.0:
version "1.4.2"
resolved "https://registry.yarnpkg.com/bigi/-/bigi-1.4.2.tgz#9c665a95f88b8b08fc05cfd731f561859d725825"

"bignumber.js@git+https://github.com/debris/bignumber.js#master":
version "2.0.7"
resolved "git+https://github.com/debris/bignumber.js#c7a38de919ed75e6fb6ba38051986e294b328df9"
Expand All @@ -1824,7 +1816,18 @@ bindings@^1.2.1, bindings@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"

bip39@^2.2.0, bip39@^2.5.0:
bip32@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/bip32/-/bip32-1.0.2.tgz#982e2ad2cae6fc6a2f53dda3e6c3be9364674b28"
dependencies:
bs58check "^2.1.1"
create-hash "^1.2.0"
create-hmac "^1.1.7"
tiny-secp256k1 "^1.0.0"
typeforce "^1.11.5"
wif "^2.0.6"

bip39@^2.2.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/bip39/-/bip39-2.5.0.tgz#51cbd5179460504a63ea3c000db3f787ca051235"
dependencies:
Expand All @@ -1834,36 +1837,12 @@ bip39@^2.2.0, bip39@^2.5.0:
safe-buffer "^5.0.1"
unorm "^1.3.3"

bip66@^1.1.0, bip66@^1.1.3:
bip66@^1.1.3:
version "1.1.5"
resolved "https://registry.yarnpkg.com/bip66/-/bip66-1.1.5.tgz#01fa8748785ca70955d5011217d1b3139969ca22"
dependencies:
safe-buffer "^5.0.1"

bitcoin-ops@^1.3.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/bitcoin-ops/-/bitcoin-ops-1.4.1.tgz#e45de620398e22fd4ca6023de43974ff42240278"

bitcoinjs-lib@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-3.3.2.tgz#780c9c53ecb1222adb463b58bef26386067b609a"
dependencies:
bech32 "^1.1.2"
bigi "^1.4.0"
bip66 "^1.1.0"
bitcoin-ops "^1.3.0"
bs58check "^2.0.0"
create-hash "^1.1.0"
create-hmac "^1.1.3"
ecurve "^1.0.0"
merkle-lib "^2.0.10"
pushdata-bitcoin "^1.0.1"
randombytes "^2.0.1"
safe-buffer "^5.0.1"
typeforce "^1.11.3"
varuint-bitcoin "^1.0.4"
wif "^2.0.1"

bl@^1.0.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c"
Expand Down Expand Up @@ -1905,7 +1884,7 @@ bn.js@^3.1.1, bn.js@^3.1.2:
version "3.3.0"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-3.3.0.tgz#1138e577889fdc97bbdab51844f2190dfc0ae3d7"

bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.11.0, bn.js@^4.11.3, bn.js@^4.11.6, bn.js@^4.4.0:
bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.11.0, bn.js@^4.11.3, bn.js@^4.11.6, bn.js@^4.11.8, bn.js@^4.4.0:
version "4.11.8"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f"

Expand Down Expand Up @@ -2090,7 +2069,7 @@ bs58@^4.0.0:
dependencies:
base-x "^3.0.2"

bs58check@<3.0.0, bs58check@^2.0.0, bs58check@^2.1.2:
bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc"
dependencies:
Expand Down Expand Up @@ -2391,9 +2370,9 @@ clap@^1.0.9:
dependencies:
chalk "^1.1.3"

class-transformer@^0.1.9:
version "0.1.9"
resolved "https://registry.yarnpkg.com/class-transformer/-/class-transformer-0.1.9.tgz#29977c528233ca014e6fd9523327ebd31d11ca54"
class-transformer@^0.1.10:
version "0.1.10"
resolved "https://registry.yarnpkg.com/class-transformer/-/class-transformer-0.1.10.tgz#350f168ebb4c1f87edb18b98dd973681fc20fff7"

class-utils@^0.3.5:
version "0.3.6"
Expand Down Expand Up @@ -2709,7 +2688,7 @@ create-ecdh@^4.0.0:
bn.js "^4.1.0"
elliptic "^6.0.0"

create-hash@^1.1.0, create-hash@^1.1.1, create-hash@^1.1.2:
create-hash@^1.1.0, create-hash@^1.1.1, create-hash@^1.1.2, create-hash@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196"
dependencies:
Expand All @@ -2719,7 +2698,7 @@ create-hash@^1.1.0, create-hash@^1.1.1, create-hash@^1.1.2:
ripemd160 "^2.0.1"
sha.js "^2.4.0"

create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.3, create-hmac@^1.1.4:
create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4, create-hmac@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff"
dependencies:
Expand Down Expand Up @@ -3271,13 +3250,6 @@ ecc-jsbn@~0.1.1:
jsbn "~0.1.0"
safer-buffer "^2.1.0"

ecurve@^1.0.0:
version "1.0.6"
resolved "https://registry.yarnpkg.com/ecurve/-/ecurve-1.0.6.tgz#dfdabbb7149f8d8b78816be5a7d5b83fcf6de797"
dependencies:
bigi "^1.1.0"
safe-buffer "^5.0.1"

[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
Expand Down Expand Up @@ -5330,14 +5302,14 @@ [email protected]:
import-local "^1.0.0"
jest-cli "^22.4.2"

jolocom-lib@^2.0.12:
version "2.0.12"
resolved "https://registry.yarnpkg.com/jolocom-lib/-/jolocom-lib-2.0.12.tgz#4fff5bbaed8e98d45c0e76eb4015314b8bd556f4"
jolocom-lib@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/jolocom-lib/-/jolocom-lib-2.1.1.tgz#e5de4ae7bfe73ee8179634b24abca739184b2bf6"
dependencies:
base64url "^3.0.0"
bip39 "^2.5.0"
bitcoinjs-lib "^3.3.2"
class-transformer "^0.1.9"
bip32 "^1.0.2"
class-transformer "^0.1.10"
create-hash "^1.2.0"
cred-types-jolocom-core "^0.0.9"
detect-node "^2.0.4"
ethereumjs-util "^5.2.0"
Expand All @@ -5346,13 +5318,11 @@ jolocom-lib@^2.0.12:
json-logic-js "^1.2.2"
jsonld "^1.0.1"
jsontokens "^0.7.8"
moment "^2.22.2"
node-fetch "^2.1.2"
qrcode "^1.2.0"
reflect-metadata "^0.1.12"
secp256k1 "^3.5.0"
sinon-chai "^3.2.0"
sjcl "^1.0.7"
tiny-secp256k1 "^1.0.1"

jolocom-registry-contract@^0.1.7:
version "0.1.7"
Expand Down Expand Up @@ -5994,10 +5964,6 @@ merge@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da"

merkle-lib@^2.0.10:
version "2.0.10"
resolved "https://registry.yarnpkg.com/merkle-lib/-/merkle-lib-2.0.10.tgz#82b8dbae75e27a7785388b73f9d7725d0f6f3326"

merkle-patricia-tree@^2.1.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz#982ca1b5a0fde00eed2f6aeed1f9152860b8208a"
Expand Down Expand Up @@ -6167,10 +6133,6 @@ mock-fs@^4.1.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.7.0.tgz#9f17e219cacb8094f4010e0a8c38589e2b33c299"

moment@^2.22.2:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"

mout@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/mout/-/mout-0.11.1.tgz#ba3611df5f0e5b1ffbfd01166b8f02d1f5fa2b99"
Expand Down Expand Up @@ -7269,12 +7231,6 @@ punycode@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"

pushdata-bitcoin@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/pushdata-bitcoin/-/pushdata-bitcoin-1.0.1.tgz#15931d3cd967ade52206f523aa7331aef7d43af7"
dependencies:
bitcoin-ops "^1.3.0"

q@^1.1.2:
version "1.5.1"
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
Expand Down Expand Up @@ -8051,7 +8007,7 @@ scryptsy@^1.2.1:
dependencies:
pbkdf2 "^3.0.3"

secp256k1@^3.0.1, secp256k1@^3.5.0:
secp256k1@^3.0.1:
version "3.5.2"
resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-3.5.2.tgz#f95f952057310722184fe9c914e6b71281f2f2ae"
dependencies:
Expand Down Expand Up @@ -8243,10 +8199,6 @@ sinon-chai@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-3.2.0.tgz#ed995e13a8a3cfccec18f218d9b767edc47e0715"

sjcl@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/sjcl/-/sjcl-1.0.7.tgz#32b365a50dc9bba26b88ba3c9df8ea34217d9f45"

slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
Expand Down Expand Up @@ -8806,6 +8758,16 @@ timers-browserify@^2.0.4:
dependencies:
setimmediate "^1.0.4"

tiny-secp256k1@^1.0.0, tiny-secp256k1@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/tiny-secp256k1/-/tiny-secp256k1-1.0.1.tgz#fc6f96529c22b92be91e12de4040fdd9245f7835"
dependencies:
bindings "^1.3.0"
bn.js "^4.11.8"
create-hmac "^1.1.7"
elliptic "^6.4.0"
nan "^2.10.0"

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
Expand Down Expand Up @@ -9019,9 +8981,9 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typeforce@^1.11.3:
version "1.13.2"
resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.13.2.tgz#8978fe69c5b7da34dfdc9f3eef08866ce1a7bdaa"
typeforce@^1.11.5:
version "1.16.0"
resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.16.0.tgz#060f871420f4ed90d411e0606bebc62a0889ad55"

typescript@^2.6.2:
version "2.9.2"
Expand Down Expand Up @@ -9305,12 +9267,6 @@ value-equal@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.4.0.tgz#c5bdd2f54ee093c04839d71ce2e4758a6890abc7"

varuint-bitcoin@^1.0.4:
version "1.1.0"
resolved "https://registry.yarnpkg.com/varuint-bitcoin/-/varuint-bitcoin-1.1.0.tgz#7a343f50537607af6a3059312b9782a170894540"
dependencies:
safe-buffer "^5.1.1"

vary@^1, vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
Expand Down Expand Up @@ -9794,7 +9750,7 @@ wide-align@^1.1.0:
dependencies:
string-width "^1.0.2 || 2"

wif@^2.0.1:
wif@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/wif/-/wif-2.0.6.tgz#08d3f52056c66679299726fade0d432ae74b4704"
dependencies:
Expand Down

0 comments on commit cb19ebd

Please sign in to comment.