-
Notifications
You must be signed in to change notification settings - Fork 2
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
SDK for QR Code Based Authentication Project. #3
base: main
Are you sure you want to change the base?
Conversation
authResponse: authResponse | ||
}; | ||
|
||
const authUrl = "https://192.168.1.3:9443/qr-auth/authenticate"; |
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 server URL should be configurable.
if (sessionDataKey) { | ||
authRequest = { | ||
sessionDataKey: sessionDataKey, | ||
tenantDomain: tenantDomain, | ||
}; | ||
} else { | ||
throw new Error("One or more required parameters (tenantDomain, sessionDataKey) was not found."); | ||
} |
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.
Let's fix the indentation here.
|
||
return result.then((res) => { | ||
let result; | ||
if (res.status === 202 && response == "SUCCESSFUL") { |
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.
Better if string literals like SUCCESSFUL
can be moved to enums.
date: | ||
current.getDate() + | ||
"-" + | ||
current.getMonth() + | ||
"-" + | ||
current.getFullYear(), |
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.
It's better to use the toLocaleDateString
method to do this.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
time: | ||
(current.getHours() < 12 | ||
? current.getHours() | ||
: current.getHours() - 12) + | ||
":" + | ||
current.getMinutes() + | ||
(current.getHours() < 12) | ||
? " a.m." | ||
: " p.m." |
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.
It's better to use the toLocaleDateString method to do this.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
Or you can try toISOString
.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
return response; | ||
}) | ||
.catch((err: any) => { | ||
console.log(`error: ${err.status}`); |
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.
Let's use the logger here.
body: body | ||
}) | ||
.then((response: any) => { | ||
|
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.
Remove this line
Co-authored-by: Theviyanthan Krishnamohan <[email protected]>
Co-authored-by: Theviyanthan Krishnamohan <[email protected]>
Co-authored-by: Theviyanthan Krishnamohan <[email protected]>
Co-authored-by: Theviyanthan Krishnamohan <[email protected]>
Purpose
Implement the SDK for the QR Code Based Authentication project.
Related Issue : wso2/product-is#12833