-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fula-sec to react-gallery app #149
Conversation
ghorbani-m
commented
Apr 17, 2022
- Fixed some issue in fula-sec library.
- Added fula-sec library to the react-gallery
these should not be part of PR
Fix indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
but changing the indent will make a hell of conflicts.
let importedmem = await fullaDID.importMnemonic(result.mnemonic); | ||
let {privateKey, authDID} = result | ||
should().not.Throw | ||
expect(JSON.stringify({privateKey, authDID})).to.equal(JSON.stringify(importedmem)); | ||
}); | ||
// it('3- Create random DID and importMnemonic', async () => { | ||
// const fullaDID = new FullaDID(); | ||
// let result = await fullaDID.create(); | ||
// let importedmem = await fullaDID.importMnemonic(result.mnemonic); | ||
// let {privateKey, authDID} = result | ||
// should().not.Throw | ||
// expect(JSON.stringify({privateKey, authDID})).to.equal(JSON.stringify(importedmem)); | ||
// }); | ||
|
||
it('4- Create random DID and importMnemonic', async () => { | ||
const fullaDID = new FullaDID(); | ||
let result = await fullaDID.create(); | ||
let importedpk = await fullaDID.importPrivateKey(result.privateKey); | ||
let {privateKey, authDID} = result | ||
should().not.Throw | ||
expect(JSON.stringify({privateKey, authDID})).to.equal(JSON.stringify(importedpk)); | ||
}); | ||
// it('4- Create random DID and importMnemonic', async () => { | ||
// const fullaDID = new FullaDID(); | ||
// let result = await fullaDID.create(); | ||
// let importedpk = await fullaDID.importPrivateKey(result.privateKey); | ||
// let {privateKey, authDID} = result | ||
// should().not.Throw | ||
// expect(JSON.stringify({privateKey, authDID})).to.equal(JSON.stringify(importedpk)); | ||
// }); | ||
|
||
it('5- importMnemonic correct mnemoic', async () => { | ||
let meta = { | ||
mnemonic: 'mercy drip similar hole oil lock blast absent medal slam world sweet', | ||
privateKey: 'f0396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5', | ||
authDID: 'did:key:z6MkeuGvVYEa5ooKyjYqYaLoWagyhFJetc7jmT3kRw9KCfAN' | ||
}; | ||
const fullaDID = new FullaDID(); | ||
let importedpk = await fullaDID.importMnemonic(meta.mnemonic.toString()); | ||
let {privateKey, authDID} = meta | ||
should().not.Throw | ||
expect(JSON.stringify({privateKey, authDID})).to.equal(JSON.stringify(importedpk)); | ||
}); | ||
// it('5- importMnemonic correct mnemoic', async () => { | ||
// let meta = { | ||
// mnemonic: 'mercy drip similar hole oil lock blast absent medal slam world sweet', | ||
// privateKey: 'f0396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5', | ||
// authDID: 'did:key:z6MkeuGvVYEa5ooKyjYqYaLoWagyhFJetc7jmT3kRw9KCfAN' | ||
// }; | ||
// const fullaDID = new FullaDID(); | ||
// let importedpk = await fullaDID.importMnemonic(meta.mnemonic.toString()); | ||
// let {privateKey, authDID} = meta | ||
// should().not.Throw | ||
// expect(JSON.stringify({privateKey, authDID})).to.equal(JSON.stringify(importedpk)); | ||
// }); | ||
|
||
it('5- import wrog Mnemonic 1', async () => { | ||
let meta = { | ||
mnemonic: 'mercy drip similar hole oil lock blast absent medal slam world sweet', | ||
privateKey: 'ff396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5', | ||
authDID: 'did:key:z6MkeuGvVYEa5ooKyjYqYaLoWagyhFJetc7jmT3kRw9KCfAN' | ||
}; | ||
const fullaDID = new FullaDID(); | ||
let importedpk = await fullaDID.importMnemonic(meta.mnemonic.toString()); | ||
let {privateKey, authDID} = meta | ||
expect(JSON.stringify({privateKey, authDID})).not.to.equal(JSON.stringify(importedpk)); | ||
}); | ||
// it('5- import wrog Mnemonic 1', async () => { | ||
// let meta = { | ||
// mnemonic: 'mercy drip similar hole oil lock blast absent medal slam world sweet', | ||
// privateKey: 'ff396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5', | ||
// authDID: 'did:key:z6MkeuGvVYEa5ooKyjYqYaLoWagyhFJetc7jmT3kRw9KCfAN' | ||
// }; | ||
// const fullaDID = new FullaDID(); | ||
// let importedpk = await fullaDID.importMnemonic(meta.mnemonic.toString()); | ||
// let {privateKey, authDID} = meta | ||
// expect(JSON.stringify({privateKey, authDID})).not.to.equal(JSON.stringify(importedpk)); | ||
// }); | ||
|
||
it('6- Import wrog privateKey 2', async () => { | ||
let meta = { | ||
privateKey: 'ff396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5', | ||
authDID: 'did:key:z6MkeuGvVYEa5ooKyjYqYaLoWagyhFJetc7jmT3kRw9KCfAN' | ||
}; | ||
const fullaDID = new FullaDID(); | ||
let importedpk = await fullaDID.importMnemonic(meta.privateKey.toString()); | ||
expect(JSON.stringify(meta)).not.to.equal(JSON.stringify(importedpk)); | ||
}); | ||
}); No newline at end of file | ||
// it('6- Import wrog privateKey 2', async () => { | ||
// let meta = { | ||
// privateKey: 'ff396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5', | ||
// authDID: 'did:key:z6MkeuGvVYEa5ooKyjYqYaLoWagyhFJetc7jmT3kRw9KCfAN' | ||
// }; | ||
// const fullaDID = new FullaDID(); | ||
// let importedpk = await fullaDID.importMnemonic(meta.privateKey.toString()); | ||
// expect(JSON.stringify(meta)).not.to.equal(JSON.stringify(importedpk)); | ||
// }); | ||
// }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why test are commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We needed to change some libraries to resolve the browser compatibility issue, and so we need to review the unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghorbani-m
Let's make them work before merging the pull request. if you want i can look in to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, could you have a look at it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We Have new mix of typescript + ESM + esbuild + mocha !
I'm going to be a bad day!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruffiano89 @ghorbani-m
I fix the build but the test wont pass here is the output:
Asymetric Encription
1) 1- Issuer encryptes string with pubKey and decrypts with priKey
2) 2- Issuer encryptes string with pubKey and Audience decrypts with priKey
3) 3- Issuer encryptes string with [A, B] pubKey and Audience decrypts with priKey
4) 4- Unknown audience attempting to decrypt with own priKey
Tagged Encription
jwe: {
protected: 'eyJlbmMiOiJYQzIwUCJ9',
iv: 'Mp6qYGQNRd0rI3-FF09ydN_tO8zSFghF',
ciphertext: 'JgLUo6tM7iIZCrfnHJoTZEkz2_L9xjcALkZSoIhjBeAWezlfqTGtSQ2BYDCrdMil',
tag: 'XCyAlsqq4SWtXa8Om-eLDQ',
recipients: [
{
encrypted_key: 'SKnLZHxgA0f7FHJc71EF9etekQFSnM-3a6B0ncIQBOc',
header: [Object]
}
]
}
✔ 1- Add DID address to encrypt (539ms)
DID
✔ 1- Create random DID (598ms)
✔ 2- Create random DID and Backup (186ms)
✔ 3- Create random DID and Backup (170ms)
✔ 3- Create random DID and importMnemonic (293ms)
✔ 4- Create random DID and importMnemonic (215ms)
5) 5- importMnemonic correct mnemoic
✔ 5- import wrog Mnemonic 1 (86ms)
6) 6- Import wrog privateKey 2
7 passing (3s)
6 failing
1) Asymetric Encription
1- Issuer encryptes string with pubKey and decrypts with priKey:
Error: x25519: seed must be 32 bytes
at generateKeyPairFromSeed2 (dist/test/asym.enc.test.cjs:4718:15)
at new AsymEncryption (dist/test/asym.enc.test.cjs:61088:65)
at /home/farhoud/workspace/functionland/fula-farhoud/libraries/fula-sec/dist/test/asym.enc.test.cjs:63774:21
at Generator.next (<anonymous>)
at fulfilled (dist/test/asym.enc.test.cjs:27:24)
2) Asymetric Encription
2- Issuer encryptes string with pubKey and Audience decrypts with priKey:
Error: x25519: seed must be 32 bytes
at generateKeyPairFromSeed2 (dist/test/asym.enc.test.cjs:4718:15)
at new AsymEncryption (dist/test/asym.enc.test.cjs:61088:65)
at /home/farhoud/workspace/functionland/fula-farhoud/libraries/fula-sec/dist/test/asym.enc.test.cjs:63787:23
at Generator.next (<anonymous>)
at fulfilled (dist/test/asym.enc.test.cjs:27:24)
3) Asymetric Encription
3- Issuer encryptes string with [A, B] pubKey and Audience decrypts with priKey:
Error: x25519: seed must be 32 bytes
at generateKeyPairFromSeed2 (dist/test/asym.enc.test.cjs:4718:15)
at new AsymEncryption (dist/test/asym.enc.test.cjs:61088:65)
at /home/farhoud/workspace/functionland/fula-farhoud/libraries/fula-sec/dist/test/asym.enc.test.cjs:63803:23
at Generator.next (<anonymous>)
at fulfilled (dist/test/asym.enc.test.cjs:27:24)
4) Asymetric Encription
4- Unknown audience attempting to decrypt with own priKey:
Error: x25519: seed must be 32 bytes
at generateKeyPairFromSeed2 (dist/test/asym.enc.test.cjs:4718:15)
at new AsymEncryption (dist/test/asym.enc.test.cjs:61088:65)
at /home/farhoud/workspace/functionland/fula-farhoud/libraries/fula-sec/dist/test/asym.enc.test.cjs:63825:23
at Generator.next (<anonymous>)
at fulfilled (dist/test/asym.enc.test.cjs:27:24)
5) DID
5- importMnemonic correct mnemoic:
AssertionError: expected '{"privateKey":"f0396d82b24b3f8f200cc2…' to equal '{"privateKey":"0xf0396d82b24b3f8f200c…'
+ expected - actual
-{"privateKey":"f0396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5","authDID":"did:key:z6MkeuGvVYEa5ooKyjYqYaLoWagyhFJetc7jmT3kRw9KCfAN"}
+{"privateKey":"0xf0396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5","authDID":"did:key:z6MkeuGvVYEa5ooKyjYqYaLoWagyhFJetc7jmT3kRw9KCfAN"}
at /home/farhoud/workspace/functionland/fula-farhoud/libraries/fula-sec/dist/test/wallet.test.cjs:63567:56
at Generator.next (<anonymous>)
at fulfilled (dist/test/wallet.test.cjs:27:24)
6) DID
6- Import wrog privateKey 2:
Error: invalid mnemonic
at mnemonicToEntropy (dist/test/wallet.test.cjs:34864:15)
at Function.HDNode2.fromMnemonic (dist/test/wallet.test.cjs:34815:38)
at FulaDID.<anonymous> (dist/test/wallet.test.cjs:63496:51)
at Generator.next (<anonymous>)
at /home/farhoud/workspace/functionland/fula-farhoud/libraries/fula-sec/dist/test/wallet.test.cjs:40:61
at new Promise (<anonymous>)
at __async (dist/test/wallet.test.cjs:24:10)
at FulaDID.importMnemonic (dist/test/wallet.test.cjs:63495:12)
at /home/farhoud/workspace/functionland/fula-farhoud/libraries/fula-sec/dist/test/wallet.test.cjs:63586:38
at Generator.next (<anonymous>)
at /home/farhoud/workspace/functionland/fula-farhoud/libraries/fula-sec/dist/test/wallet.test.cjs:40:61
at new Promise (<anonymous>)
at __async (dist/test/wallet.test.cjs:24:10)
at Context.<anonymous> (dist/test/wallet.test.cjs:63580:43)
at processImmediate (node:internal/timers:464:21)
The script failed with exit code 6
@@ -8,10 +8,11 @@ | |||
"@testing-library/user-event": "^13.5.0", | |||
"react": "^17.0.2", | |||
"react-dom": "~17.0.2", | |||
"react-scripts": "5.0.0", | |||
"react-scripts": "5.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you also have to change react-todo-app, react-script
version so rush check wont fail
I have fixed the conflicts. |
Look like there is something wrong with the react-gallery package.json |
Fixed. |
Add enc/dec tests to fula-client
duplicated |