-
Notifications
You must be signed in to change notification settings - Fork 24
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
feature/invert client + providers to constructor params w/ specific interface #10
feature/invert client + providers to constructor params w/ specific interface #10
Conversation
mateodelnorte
commented
Jul 13, 2018
•
edited
Loading
edited
- refactoring rest client to composition instead of inheritance
- refactoring network providers be provided via constructor, allowing any number of providers
- refactor this.providers to array
- refactor all providers to match common interface
- refactor connect() to cycle through all specified providers
- refactor crypto usage to constructor-provided param
- refactor appSecret to be provided by env vars to both tests/sdk and services
I think we should remove the |
Can do
|
Looks like there are 5 places where crypto is used: gridplus-sdk/src/rest/client.js Line 41 in 7ca6294
gridplus-sdk/src/rest/client.js Line 103 in 7ca6294
gridplus-sdk/src/rest/client.js Line 130 in 7ca6294
gridplus-sdk/src/rest/client.js Line 137 in 7ca6294
gridplus-sdk/src/rest/client.js Line 139 in 7ca6294
Those uses consolidate to
We could pass in a cryptoProvider imp via the SDKClient constructor, which it will pass into the RestClient. We could provide implementations that will work for node, web, and react-native. Users would just specify which to use in the constructor. The imps would be pretty simple:
Usage could be something like...
|
… be refactored to separate package if needed.
Took a swack at that, in commit 5355edc above. |
Looks great. There are several crypto libs for RN so we can just swap those in depending on the build. Also I've had problems with Edit: looks like there may be a workaround within |
Sounds good. Last refactor left on this is encapsulating the providers to conform to a specific interface and moving them to be passed in through the constructor. I should be able to get it done after the SmartGrid meeting. |
Two things that need to be updated in this API (whether in this PR or not):
|
test/agent.js
Outdated
// Use React Native crypto for this series of tests. | ||
// The node.js version is faster, but we want to test both | ||
const privKey = crypto.randomBytes(32).toString('hex'); | ||
const rnCrypto = new ReactNativeCrypto(privKey); |
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.
@alex-miller-0 shouldn't we be using a means other than crypto to provide entropy to crypto/react-native?
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.
The origin of the entropy is irrelevant for cryptographic purposes. A RN app would use a different source, but I don't see any reason not to use crypto (which is simpler) in a test that will run via node
…g imports to use org namespaced name
…s shared env var for appSecret
…-interface' of github.com:GridPlus/gridplus-sdk into feature/invert-providers-to-constructor-param-and-match-interface
…-interface' of github.com:GridPlus/gridplus-sdk into feature/invert-providers-to-constructor-param-and-match-interface
…tructor-param-and-match-interface feature/invert client + providers to constructor params w/ specific interface