-
Notifications
You must be signed in to change notification settings - Fork 39
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
Adding serialize and resume to guardianJs transactions #24
Conversation
204e4b1
to
8dab8ad
Compare
README.md
Outdated
```js | ||
var serializedTransaction = secureStorage.get('guardiantx'); | ||
|
||
auth0GuardianJS.start({ transport: 'pooling' }, serializedTransaction, function(err, transaction) { |
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.
resume
README.md
Outdated
@@ -292,6 +292,35 @@ auth0GuardianJS.start(function(err, transaction) { | |||
//... | |||
}); | |||
``` | |||
### auth0GuardianJS.resume(options, transactionState, callback) | |||
This continues a transaction saved by `transaction.serialize()`. The option parameter provides | |||
the final user the opportunity to specify which kind of `client` to use. That been: |
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.
client
?? what's client? later it's used as transport: { transport: 'pooling' }
Something like this might sound better:
The option parameter provides the final user the opportunity to specify which kind of
transport
to use, the options being:
README.md
Outdated
@@ -389,6 +418,12 @@ recovery code is the new recovery code you must show to the user from him to sav | |||
transaction.recover({ recoveryCode: recoveryCode }); | |||
``` | |||
|
|||
#### transaction.serialize() | |||
The .serialize() method creates a regular javascript Object that should remind opaque |
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.
a "plain" object, or something better? A javascript object might have functions and other things in it. Maybe a plain JSON Object?
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 like plain
lib/index.js
Outdated
self.socketClient = socketClient(self.serviceUrl); | ||
} | ||
} | ||
self.socketClient = clientFactory({ |
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.
clientFactory.create
will look better, just like transactionFactory.fromXX
otherwise the require should have a better name, like:
var createClient = require('./utils/client_factory');
so the function call is more understandable
return; | ||
} | ||
|
||
callback(null, tx); |
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.
try {
const tx = transactionFactory.fromTransactionState(transactionState, {
transactionEventsReceiver: self.socketClient,
httpClient: self.httpClient
});
callback(null, tx);
} catch (transactionBuildingErr) {
callback(transactionBuildingErr);
}
lib/transaction/index.js
Outdated
@@ -24,7 +24,7 @@ var eventSequencer = require('../utils/event_sequencer'); | |||
var eventListenerHub = require('../utils/event_listener_hub'); | |||
|
|||
/** | |||
* @public | |||
* @public|| |
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.
?
lib/transaction/index.js
Outdated
@@ -74,6 +74,7 @@ function transaction(data, options) { | |||
self.txId = data.transactionToken.getDecoded().txid; | |||
self.transactionToken = data.transactionToken; | |||
self.transactionEventsReceiver = options.transactionEventsReceiver; | |||
|
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.
?
lib/transaction/index.js
Outdated
@@ -136,8 +137,34 @@ function transaction(data, options) { | |||
return self; | |||
} | |||
|
|||
|
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.
?
lib/utils/client_factory.js
Outdated
var pooling = require('./polling_client'); | ||
var socketio = require('./socket_client'); | ||
|
||
module.exports = function factory(options) { |
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.
export an object with a function create
or something like that instead of the function directly. otherwise client_factory is not a good name
1d42675
to
81aa89f
Compare
@nikolaseu addressed most of your comments; i realized that we needed a new test for |
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.
Posting a partial review. Will continue soon.
@@ -48,4 +48,11 @@ enrollment.prototype.getPhoneNumber = function getPhoneNumber() { | |||
return this.data.phoneNumber; | |||
}; | |||
|
|||
/** | |||
* @returns @see constructor. |
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 only @see
is enough here :)
README.md
Outdated
the final user the opportunity to specify which kind of `transport` to use. That been: | ||
|
||
- `socket`: a socket.io transport | ||
- `pooling`: a pooling transport. |
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.
"polling". "pooling" refers to a "pool" with several connections to pick from, "polling" refers to "poll" to see if something is done...
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 option parameter" -> "The options parameter"
"That been:" -> "Options include:"
README.md
Outdated
@@ -389,6 +418,12 @@ recovery code is the new recovery code you must show to the user from him to sav | |||
transaction.recover({ recoveryCode: recoveryCode }); | |||
``` | |||
|
|||
#### transaction.serialize() | |||
The .serialize() method creates a plain javascript Object that should remind opaque |
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.
s/remind/remain/
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'm not sure what is meant here, with the object being opaque to the end user. In all examples, the object is not sent to the end user.
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.
That's a good point; to 'library user' or 'library client' i meant.
81aa89f
to
6d9cdb5
Compare
lib/index.js
Outdated
|
||
/** | ||
* @public | ||
* | ||
* Post result to url using an standard form |
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.
"Post result to url using a standard form"
lib/transaction/factory.js
Outdated
* @param {object} transactionState.availableAuthenticationMethods | ||
* | ||
* @param {EventEmitter} options.transactionEventsReceiver | ||
* Receiver for transaction events; it will receive backend related transaction events |
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.
Extra space
lib/index.js
Outdated
@@ -128,6 +122,70 @@ auth0GuardianJS.prototype.start = function start(callback) { | |||
/** | |||
* @public | |||
* | |||
* This takes a parameter what transaction.serialize returns to | |||
* resume the transaction with auth0-mfa-api |
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.
"Takes a parameter returned from transaction.serialize to resume the transaction with auth0-mfa-api"
Correct me if I'm not interpreting it correctly, though
README.md
Outdated
- `socket`: a socket.io transport | ||
- `pooling`: a pooling transport. | ||
|
||
The default one is `socket`. |
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.
"If not set, the socket
transport is used as default"
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.
And polling
again :)
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.
Looks good, but it's a lot of changes... We really should have a test coverage setup (like istanbul) to not miss adding tests for any added/changed function.
lib/utils/client_factory.js
Outdated
@@ -0,0 +1,20 @@ | |||
var pooling = require('./polling_client'); |
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.
polling!
10ee80e
to
40821ba
Compare
client
(websocket/pooling)transaction
(fromStartFlow/fromTransactionState).serialize
method on Transaction.resume
method in guardianJS to continue from a seralized transaction.