Skip to content
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: 1 addition & 0 deletions js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class NeetoJWT {
const payload = {
email: this.email,
workspace: this.workspace,
scope: this.scope,
iat,
exp,
};
Expand Down
13 changes: 13 additions & 0 deletions js/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,23 @@ describe("NeetoJWT", () => {
const decoded = jwt.verify(token, publicKey, { algorithms: ["ES256"] });
expect(decoded.email).toBe(email);
expect(decoded.workspace).toBe(workspace);
expect(decoded.scope).toBe("user");
Comment thread
VarunSriram99 marked this conversation as resolved.
expect(decoded.iat).toBeDefined();
expect(decoded.exp).toBeDefined();
});

it("should embed scope in the JWT payload for consumer scope", () => {
const neetoJWT = new NeetoJWT({
email,
privateKey,
scope: "consumer",
});
const token = neetoJWT.generateJWT();
const decoded = jwt.verify(token, publicKey, { algorithms: ["ES256"] });
expect(decoded.scope).toBe("consumer");
expect(decoded.workspace).toBe("app");
Comment thread
VarunSriram99 marked this conversation as resolved.
});

it("should generate a login URL", () => {
const neetoJWT = new NeetoJWT({ email, workspace, privateKey });
const loginUrl = neetoJWT.generateLoginUrl(redirectUri);
Expand Down