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

@mongodb-js/oidc-plugin

Package Overview
Dependencies
Maintainers
33
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mongodb-js/oidc-plugin - npm Package Compare versions

Comparing version 0.4.0 to 1.0.0

5

dist/api.d.ts

@@ -6,3 +6,3 @@ /// <reference types="node" />

import { MongoDBOIDCPluginImpl } from './plugin';
import type { MongoDBOIDCLogEventsMap, OIDCAbortSignal, OIDCRefreshFunction, OIDCRequestFunction, TypedEventEmitter } from './types';
import type { MongoDBOIDCLogEventsMap, OIDCAbortSignal, OIDCCallbackFunction, TypedEventEmitter } from './types';
import type { RequestOptions } from 'https';

@@ -150,4 +150,3 @@ /** @public */

readonly authMechanismProperties: {
readonly REQUEST_TOKEN_CALLBACK: OIDCRequestFunction;
readonly REFRESH_TOKEN_CALLBACK: OIDCRefreshFunction;
readonly OIDC_HUMAN_CALLBACK: OIDCCallbackFunction;
};

@@ -154,0 +153,0 @@ }

2

dist/index.d.ts
export { createMongoDBOIDCPlugin, ALL_AUTH_FLOW_TYPES } from './api';
export type { MongoDBOIDCPlugin, MongoDBOIDCPluginOptions, AuthFlowType, DeviceFlowInformation, OpenBrowserOptions, OpenBrowserReturnType, RedirectServerRequestHandler, RedirectServerRequestInfo, MongoDBOIDCPluginMongoClientOptions, HttpOptions, } from './api';
export type { TypedEventEmitter, OIDCCallbackContext, OIDCRefreshFunction, OIDCRequestFunction, IdPServerInfo, IdPServerResponse, OIDCAbortSignal, MongoDBOIDCError, MongoDBOIDCLogEventsMap, } from './types';
export type { TypedEventEmitter, OIDCCallbackParams, OIDCCallbackFunction, IdPServerInfo, IdPServerResponse, OIDCAbortSignal, MongoDBOIDCError, MongoDBOIDCLogEventsMap, } from './types';
export { hookLoggerToMongoLogWriter, MongoLogWriter } from './log-hook';
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import type { MongoDBOIDCLogEventsMap, OIDCCallbackContext, IdPServerInfo, IdPServerResponse, TypedEventEmitter } from './types';
import type { MongoDBOIDCLogEventsMap, OIDCCallbackParams, IdPServerResponse, TypedEventEmitter } from './types';
import { TokenSet } from 'openid-client';

@@ -30,5 +30,5 @@ import type { MongoDBOIDCPlugin, MongoDBOIDCPluginOptions } from './api';

private initiateAuthAttempt;
requestToken(serverMetadata: IdPServerInfo, context: OIDCCallbackContext): Promise<IdPServerResponse>;
requestToken(params: OIDCCallbackParams): Promise<IdPServerResponse>;
destroy(): Promise<void>;
}
//# sourceMappingURL=plugin.d.ts.map

@@ -121,4 +121,3 @@ "use strict";

authMechanismProperties: {
REQUEST_TOKEN_CALLBACK: this.requestToken.bind(this),
REFRESH_TOKEN_CALLBACK: this.requestToken.bind(this),
OIDC_HUMAN_CALLBACK: this.requestToken.bind(this),
},

@@ -561,3 +560,3 @@ };

(0, util_1.throwIfAborted)(driverAbortSignal);
const combinedAbortController = new util_1.AbortController();
const combinedAbortController = new AbortController();
const optionsAbortCb = () => {

@@ -664,5 +663,7 @@ // @ts-expect-error TS doesn't understand .abort(reason)

}
async requestToken(serverMetadata, context) {
if (context.version !== 0) {
throw new types_1.MongoDBOIDCError(`OIDC MongoDB driver protocol mismatch: unknown version ${context.version}`);
async requestToken(params) {
if (params.version !== 1) {
throw new types_1.MongoDBOIDCError(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`OIDC MongoDB driver protocol mismatch: unknown version ${params.version}`);
}

@@ -672,15 +673,10 @@ if (this.destroyed) {

}
const state = this.getAuthState(serverMetadata);
if (!params.idpInfo) {
throw new types_1.MongoDBOIDCError('No IdP information provided');
}
const state = this.getAuthState(params.idpInfo);
if (state.currentAuthAttempt) {
return await state.currentAuthAttempt;
}
// The currently plan is for the 6.x driver (which may drop support
// for Node.js 14.x) to pass in an actual AbortSignal here. For
// compatibility with the 5.x driver/AbortSignal-less-Node.js, we accept
// a timeout in milliseconds as well.
const driverAbortSignal = context.timeoutContext ??
(context.timeoutSeconds
? (0, util_1.timeoutSignal)(context.timeoutSeconds * 1000)
: undefined);
const newAuthAttempt = this.initiateAuthAttempt(state, driverAbortSignal);
const newAuthAttempt = this.initiateAuthAttempt(state, params.timeoutContext);
try {

@@ -687,0 +683,0 @@ state.currentAuthAttempt = newAuthAttempt;

@@ -100,21 +100,17 @@ /** @public */

/**
* A copy of the Node.js driver's `OIDCCallbackContext`
* A copy of the Node.js driver's `OIDCCallbackParams` using `OIDCAbortSignal` instead of `AbortSignal`
* @public
*/
export interface OIDCCallbackContext {
export interface OIDCCallbackParams {
refreshToken?: string;
timeoutSeconds?: number;
timeoutContext?: OIDCAbortSignal;
version: number;
version: 1;
username?: string;
idpInfo?: IdPServerInfo;
}
/**
* A copy of the Node.js driver's `OIDCRequestFunction`
* @public
*/
export type OIDCRequestFunction = (info: IdPServerInfo, context: OIDCCallbackContext) => Promise<IdPServerResponse>;
/**
* A copy of the Node.js driver's `OIDCRefreshFunction`
* @public
*/
export type OIDCRefreshFunction = (info: IdPServerInfo, context: OIDCCallbackContext) => Promise<IdPServerResponse>;
export type OIDCCallbackFunction = (params: OIDCCallbackParams) => Promise<IdPServerResponse>;
/** @public */

@@ -121,0 +117,0 @@ export type OIDCAbortSignal = {

@@ -10,12 +10,2 @@ /// <reference types="node" />

export declare function errorString(err: unknown): string;
export declare const AbortController: {
new (): AbortController;
prototype: AbortController;
};
export declare const AbortSignal: {
new (): AbortSignal;
prototype: AbortSignal;
abort(reason?: any): AbortSignal;
timeout(milliseconds: number): AbortSignal;
};
export declare function timeoutSignal(ms: number): AbortSignal;

@@ -22,0 +12,0 @@ export declare function withLock<T extends (...args: any[]) => Promise<any>>(fn: T): (...args: Parameters<T>) => ReturnType<T>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.messageFromError = exports.validateSecureHTTPUrl = exports.normalizeObject = exports.withLock = exports.timeoutSignal = exports.AbortSignal = exports.AbortController = exports.errorString = exports.withAbortCheck = exports.throwIfAborted = void 0;
exports.messageFromError = exports.validateSecureHTTPUrl = exports.normalizeObject = exports.withLock = exports.timeoutSignal = exports.errorString = exports.withAbortCheck = exports.throwIfAborted = void 0;
class AbortError extends Error {

@@ -40,11 +40,5 @@ constructor() {

exports.errorString = errorString;
exports.AbortController =
// eslint-disable-next-line @typescript-eslint/no-var-requires
globalThis.AbortController ?? require('abort-controller').AbortController;
exports.AbortSignal =
// eslint-disable-next-line @typescript-eslint/no-var-requires
globalThis.AbortSignal ?? require('abort-controller').AbortSignal;
// AbortSignal.timeout, but consistently .unref()ed
function timeoutSignal(ms) {
const controller = new exports.AbortController();
const controller = new AbortController();
setTimeout(() => controller.abort(), ms).unref();

@@ -51,0 +45,0 @@ return controller.signal;

@@ -194,4 +194,3 @@ /// <reference types="node" />

readonly authMechanismProperties: {
readonly REQUEST_TOKEN_CALLBACK: OIDCRequestFunction;
readonly REFRESH_TOKEN_CALLBACK: OIDCRefreshFunction;
readonly OIDC_HUMAN_CALLBACK: OIDCCallbackFunction;
};

@@ -324,23 +323,18 @@ }

/**
* A copy of the Node.js driver's `OIDCCallbackContext`
* @public
*/
export declare interface OIDCCallbackContext {
refreshToken?: string;
timeoutSeconds?: number;
timeoutContext?: OIDCAbortSignal;
version: number;
}
/**
* A copy of the Node.js driver's `OIDCRefreshFunction`
* @public
*/
export declare type OIDCRefreshFunction = (info: IdPServerInfo, context: OIDCCallbackContext) => Promise<IdPServerResponse>;
export declare type OIDCCallbackFunction = (params: OIDCCallbackParams) => Promise<IdPServerResponse>;
/**
* A copy of the Node.js driver's `OIDCRequestFunction`
* A copy of the Node.js driver's `OIDCCallbackParams` using `OIDCAbortSignal` instead of `AbortSignal`
* @public
*/
export declare type OIDCRequestFunction = (info: IdPServerInfo, context: OIDCCallbackContext) => Promise<IdPServerResponse>;
export declare interface OIDCCallbackParams {
refreshToken?: string;
timeoutContext?: OIDCAbortSignal;
version: 1;
username?: string;
idpInfo?: IdPServerInfo;
}

@@ -347,0 +341,0 @@ /** @public */

@@ -16,3 +16,3 @@ {

"homepage": "https://github.com/mongodb-js/oidc-plugin",
"version": "0.4.0",
"version": "1.0.0",
"repository": {

@@ -34,3 +34,3 @@ "type": "git",

"engines": {
"node": ">= 14.18.0"
"node": ">= 16.20.1"
},

@@ -79,3 +79,3 @@ "types": "./index.d.ts",

"mocha": "^10.2.0",
"mongodb": "^5.4.0",
"mongodb": "^6.7.0",
"mongodb-log-writer": "^1.1.5",

@@ -94,3 +94,2 @@ "mongodb-runner": "^5.2.0",

"dependencies": {
"abort-controller": "^3.0.0",
"express": "^4.18.2",

@@ -97,0 +96,0 @@ "open": "^9.1.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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