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

Message #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Message #20

wants to merge 2 commits into from

Conversation

anjuthomas
Copy link
Contributor

TODO: convert require statements to import. Need additional setting up to enable this.

*/
class Message {
constructor(claims) {
if (claims){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix spacing
if (claims) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

constructor(claims) {
if (claims){
this.claims = claims;
}else{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix spacing
} else {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

addOptionalClaims(optionalClaims) {
this.optionalClaims = optionalClaims;
this.optionalVerificationClaims = {};
for (var i = 0; i < optionalClaims.length; i++){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let i = 0;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also optionalClaims is defined as an object but you treat it like an array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


/** Check for missing required claims */
validateRequiredFields() {
for (var i = 0; i < this.optionsToPayload.length; i++){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let i = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

/** Fetch Required claims */
getRequiredClaims() {
this.requiredClaims = {};
for (var i = 0; i < this.optionsToPayload.length; i++){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let i = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1,265 @@
'use strict';
const jwtDecoder = require('../oicMsg/jose/jwt/decode');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use uppercase since this is a class name: JWTDecoder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1,265 @@
'use strict';
const jwtDecoder = require('../oicMsg/jose/jwt/decode');
const jwtSigner = require('../oicMsg/jose/jwt/sign');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this defined? I don't see it in https://github.com/GJWT/nodeOIDCMsg/tree/master/src/oicMsg/jose/jwt
If this is a class name, it should be capitalized too: JWTSigner

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has not been reviewed yet.. Most of the classes depend on each other.. I didn't post them as there is already three PRs open and thought it would better to close these ones before i open new ones.

Object.assign({}, this.getRequiredClaims(), this.getOptionalClaims());
}
const str = [];
for (const p in obj)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When traversing an object, you should check hasOwnProperty:
https://stackoverflow.com/questions/684672/how-do-i-loop-through-or-enumerate-a-javascript-object

for (const p in obj) {
  if (obj.hasOwnProperty(p)) {
  }
}

You can also use Object.keys(obj).forEach()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

validateRequiredFields() {
for (var i = 0; i < this.optionsToPayload.length; i++){
let key = this.optionsToPayload[i];
if (!this[key]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware that if this[key] evaluates to empty string, false or null, !this[key] will be false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


/**
* Deserialization of URL Encoded string
* @param {string} obj Url encoded string that needs to be deserialized
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called obj but in the function below, the parameter name is urlEncodedString

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants