Skip to content
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 debug mode to uBox Camera API #4

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ If your PR requires multiple options, consider splitting it into multiple PRs to
-->

- [ ] Bugfix (non-breaking change that resolves an issue)
- [ ] New Game
- [ ] New Feature (which introduces functionality to an existing game or user interface)
- [ ] Breaking Change (fix or feature that disrupts existing functionality)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ To login to the API create a .env file and write the following
```
email=your_email
password=your_password
debug_mode=false
```
Once you have completed that run the following command
```
Expand Down
11 changes: 9 additions & 2 deletions login.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ require('dotenv').config();
var sha1 = require('js-sha1');
// HMAC SHA-1 with Base64 Encoding
function hmacSha1Base64(data) {

if (process.env.debug_mode == 'false') {
var hash = sha1.hmac.array('', data);
var base_hash = Buffer.from(hash).toString('base64');
// Replace the last character with a comma
const modifiedSignature = base_hash.replace(/.$/, ',');

return modifiedSignature;
} else {
return data
}
}
// Function to generate a random string for the device token
function generateRandomString(length) {
Expand All @@ -26,7 +29,11 @@ function generateRandomString(length) {
// Load email and password from environment variables
const email = process.env.email;
const password = hmacSha1Base64(process.env.password);
console.log(password)
if (process.env.debug_mode == 'true') {
console.log('email',process.env.email)
console.log('password',process.env.password)
console.log(password)
}
// Check if email and password are defined
if (!email || !password) {
console.error("Error: Email or password not found in environment variables.");
Expand Down