Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

keycloak-mock

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keycloak-mock - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

dist/views/getUser.d.ts

3

dist/database.d.ts

@@ -5,2 +5,3 @@ export interface CreateMockUserProfileOptions {

email: string;
attributes?: {};
}

@@ -16,2 +17,4 @@ export interface MockUserProfile {

email_verified: boolean;
created_at: number;
attributes: {};
}

@@ -18,0 +21,0 @@ declare class MockDatabase {

@@ -21,2 +21,3 @@ "use strict";

var email = options ? options.email : "henk@gmail.com";
var attributes = options ? options.attributes : {};
var _a = name.split(" "), givenName = _a[0], familyName = _a[1];

@@ -32,2 +33,4 @@ var profile = {

preferred_username: email,
created_at: new Date().getTime(),
attributes: attributes || {},
};

@@ -34,0 +37,0 @@ this.users.push(profile);

@@ -10,2 +10,3 @@ import { Scope } from "nock";

listCertificatesView?: ViewFn;
getUserView?: ViewFn;
getUserInfoView?: ViewFn;

@@ -12,0 +13,0 @@ }

@@ -24,2 +24,9 @@ "use strict";

})
.get(new RegExp("/admin/realms/" + realm + "/users/(.+)"))
.reply(function () {
if (options && options.getUserView) {
return options.getUserView(instance, this.req);
}
return views_1.getUser(instance, this.req);
})
.get("/realms/" + realm + "/protocol/openid-connect/userinfo")

@@ -26,0 +33,0 @@ .reply(function () {

3

dist/views/getUserInfo.js

@@ -44,2 +44,3 @@ "use strict";

var node_jose_1 = require("node-jose");
var head_1 = __importDefault(require("lodash/head"));
var getUserInfo = function (instance, request) { return __awaiter(void 0, void 0, void 0, function () {

@@ -50,3 +51,3 @@ var token, decodedToken, rawKey, key, user;

case 0:
token = (request.headers.authorization || "").split(" ")[1];
token = (head_1.default(request.headers.authorization) || "").split(" ")[1];
if (!token) {

@@ -53,0 +54,0 @@ return [2 /*return*/, [401, "Authorization required"]];

export { default as listCertificates } from "./listCertificates";
export { default as getUser } from "./getUser";
export { default as getUserInfo } from "./getUserInfo";
export { ViewFn } from "./types";

@@ -5,3 +5,5 @@ "use strict";

exports.listCertificates = listCertificates_1.default;
var getUser_1 = require("./getUser");
exports.getUser = getUser_1.default;
var getUserInfo_1 = require("./getUserInfo");
exports.getUserInfo = getUserInfo_1.default;

@@ -7,2 +7,3 @@ import { v4 as uuidv4 } from "uuid";

email: string;
attributes?: {};
}

@@ -19,2 +20,4 @@

email_verified: boolean;
created_at: number;
attributes: {};
}

@@ -44,2 +47,3 @@

const email = options ? options.email : "henk@gmail.com";
const attributes = options ? options.attributes : {};

@@ -57,2 +61,4 @@ const [givenName, familyName] = name.split(" ");

preferred_username: email,
created_at: new Date().getTime(),
attributes: attributes || {},
};

@@ -59,0 +65,0 @@

@@ -5,3 +5,3 @@ import nock, { Scope } from "nock";

import { ViewFn, listCertificates, getUserInfo } from "./views";
import { ViewFn, listCertificates, getUser, getUserInfo } from "./views";

@@ -17,2 +17,3 @@ let __activeMocks__: Map<string, Mock> = new Map<string, Mock>();

listCertificatesView?: ViewFn;
getUserView?: ViewFn;
getUserInfoView?: ViewFn;

@@ -39,2 +40,10 @@ }

})
.get(new RegExp(`/admin/realms/${realm}/users/(.+)`))
.reply(function() {
if (options && options.getUserView) {
return options.getUserView(instance, this.req);
}
return getUser(instance, this.req);
})
.get(`/realms/${realm}/protocol/openid-connect/userinfo`)

@@ -41,0 +50,0 @@ .reply(function() {

import jwt from "jsonwebtoken";
import { JWK } from "node-jose";
import head from "lodash/head";

@@ -9,3 +10,3 @@ import { MockInstance } from "../instance";

const getUserInfo: ViewFn = async (instance, request) => {
const token = (request.headers.authorization || "").split(" ")[1];
const token = (head(request.headers.authorization) || "").split(" ")[1];
if (!token) {

@@ -12,0 +13,0 @@ return [401, "Authorization required"];

export { default as listCertificates } from "./listCertificates";
export { default as getUser } from "./getUser";
export { default as getUserInfo } from "./getUserInfo";
export { ViewFn } from "./types";
{
"name": "keycloak-mock",
"version": "0.0.6",
"version": "0.0.7",
"description": "Keycloak server mock for Node.js",

@@ -23,3 +23,5 @@ "main": "dist/index.js",

"dependencies": {
"@types/lodash": "^4.14.149",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"nock": "^11.9.1",

@@ -26,0 +28,0 @@ "node-jose": "^1.1.3",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc