keycloak-mock
Advanced tools
Comparing version 0.0.4 to 0.0.5
import { JWK } from "node-jose"; | ||
import { MockUserProfile } from "./database"; | ||
export interface CreateTokenOptions { | ||
sub: string; | ||
user: MockUserProfile; | ||
expiresIn: number; | ||
@@ -5,0 +6,0 @@ key: JWK.Key; |
@@ -17,5 +17,12 @@ "use strict"; | ||
typ: "Bearer", | ||
sub: options.sub, | ||
sub: options.user.sub, | ||
azp: options.clientID, | ||
session_state: uuid_1.v4(), | ||
gender: options.user.gender, | ||
preferred_username: options.user.preferred_username, | ||
given_name: options.user.given_name, | ||
family_name: options.user.family_name, | ||
email_verified: options.user.email_verified, | ||
name: options.user.name, | ||
email: options.user.email, | ||
}, options.key.toPEM(true), { | ||
@@ -22,0 +29,0 @@ algorithm: "RS256", |
@@ -43,4 +43,4 @@ "use strict"; | ||
var node_jose_1 = require("node-jose"); | ||
var createBearerToken_1 = __importDefault(require("./createBearerToken")); | ||
var database_1 = __importDefault(require("./database")); | ||
var createBearerToken_1 = __importDefault(require("./createBearerToken")); | ||
var MockInstance = /** @class */ (function () { | ||
@@ -55,4 +55,8 @@ function MockInstance(store, defaultKey, database, params) { | ||
if (expiresIn === void 0) { expiresIn = 3600; } | ||
var user = this.database.findUserByID(sub); | ||
if (!user) { | ||
throw new Error("Cannot create bearer token for non-existen user"); | ||
} | ||
return createBearerToken_1.default({ | ||
sub: sub, | ||
user: user, | ||
key: this.defaultKey, | ||
@@ -59,0 +63,0 @@ expiresIn: expiresIn, |
@@ -6,4 +6,6 @@ import { v4 as uuidv4 } from "uuid"; | ||
import { MockUserProfile } from "./database"; | ||
export interface CreateTokenOptions { | ||
sub: string; | ||
user: MockUserProfile; | ||
expiresIn: number; | ||
@@ -27,5 +29,12 @@ key: JWK.Key; | ||
typ: "Bearer", | ||
sub: options.sub, | ||
sub: options.user.sub, | ||
azp: options.clientID, | ||
session_state: uuidv4(), | ||
gender: options.user.gender, | ||
preferred_username: options.user.preferred_username, | ||
given_name: options.user.given_name, | ||
family_name: options.user.family_name, | ||
email_verified: options.user.email_verified, | ||
name: options.user.name, | ||
email: options.user.email, | ||
}, | ||
@@ -32,0 +41,0 @@ options.key.toPEM(true), |
import { JWK } from "node-jose"; | ||
import MockDatabase from "./database"; | ||
import createBearerToken from "./createBearerToken"; | ||
import { MockUserProfile, CreateMockUserProfileOptions } from "./database"; | ||
import MockDatabase, { MockUserProfile, CreateMockUserProfileOptions } from "./database"; | ||
@@ -39,4 +37,9 @@ export interface CreateMockInstanceOptions { | ||
createBearerToken(sub: string, expiresIn: number = 3600): string { | ||
const user = this.database.findUserByID(sub); | ||
if (!user) { | ||
throw new Error("Cannot create bearer token for non-existen user"); | ||
} | ||
return createBearerToken({ | ||
sub, | ||
user, | ||
key: this.defaultKey, | ||
@@ -43,0 +46,0 @@ expiresIn, |
{ | ||
"name": "keycloak-mock", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Keycloak server mock for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38090
851