Skip to content

Commit 22eeddb

Browse files
committed
debug: just commit built files
1 parent 2f67bdf commit 22eeddb

32 files changed

+3169
-6
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
.nyc_output
22
node_modules
33
package-lock.json
4-
dist
54
coverage
6-
.esm-wrapper.mjs
7-
lib/
85
.deps
9-
index.d.ts
106
.DS_Store

dist/.esm-wrapper.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import mod from "./index.js";
2+
3+
export default mod;
4+
export const ALL_AUTH_FLOW_TYPES = mod.ALL_AUTH_FLOW_TYPES;
5+
export const createMongoDBOIDCPlugin = mod.createMongoDBOIDCPlugin;
6+
export const hookLoggerToMongoLogWriter = mod.hookLoggerToMongoLogWriter;

dist/api.d.ts

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
import type { IncomingMessage as HttpIncomingMessage, ServerResponse as HttpServerResponse } from 'http';
2+
import { MongoDBOIDCPluginImpl } from './plugin';
3+
import type { MongoDBOIDCLogEventsMap, OIDCAbortSignal, OIDCCallbackFunction, TypedEventEmitter } from './types';
4+
import type { RequestOptions } from 'https';
5+
/**
6+
* @public
7+
* @deprecated Use a custom `fetch` function instead
8+
*/
9+
export type HttpOptions = Partial<Pick<RequestOptions, 'agent' | 'ca' | 'cert' | 'crl' | 'headers' | 'key' | 'lookup' | 'passphrase' | 'pfx' | 'timeout'>>;
10+
/** @public */
11+
export type AuthFlowType = 'auth-code' | 'device-auth';
12+
/** @public */
13+
export declare const ALL_AUTH_FLOW_TYPES: readonly AuthFlowType[];
14+
/**
15+
* Information that the application needs to show to users when using the
16+
* Device Authorization flow.
17+
*
18+
* @public
19+
*/
20+
export interface DeviceFlowInformation {
21+
verificationUrl: string;
22+
userCode: string;
23+
}
24+
/** @public */
25+
export type OpenBrowserReturnType = void | undefined | (TypedEventEmitter<{
26+
exit(exitCode: number): void;
27+
error(err: unknown): void;
28+
}> & {
29+
spawnargs?: string[];
30+
});
31+
/** @public */
32+
export interface OpenBrowserOptions {
33+
/**
34+
* The URL to open the browser with.
35+
*/
36+
url: string;
37+
/**
38+
* A signal that is aborted when the user or the driver abort
39+
* an authentication attempt.
40+
*/
41+
signal: AbortSignal;
42+
}
43+
/** @public */
44+
export interface MongoDBOIDCPluginOptions {
45+
/**
46+
* A local URL to listen on. If this is not provided, a default URL
47+
* standardized for MongoDB applications is used.
48+
*
49+
* This is only used when the Authorization Code flow is enabled,
50+
* and when it is possible to open a browser.
51+
*/
52+
redirectURI?: string;
53+
/**
54+
* A function that opens an URL in a browser window. If this is `false`,
55+
* then all flows involving automatic browser operation (currently
56+
* Authorization Code flow) are disabled.
57+
*
58+
* If a `{ command: string }` object is provided, `command` will be spawned
59+
* inside a shell and receive the target URL as an argument. If `abortable`
60+
* is set, then a possible AbortSignal will be passed on and the child
61+
* process will be killed once that is reached. (This does not typically
62+
* make sense for GUI browsers, but can for command-line browsers.)
63+
*
64+
* If this option is missing or undefined, the default behavior is to use
65+
* `shell.openExternal()` if this is running inside of electron, and
66+
* the `open` package otherwise.
67+
*/
68+
openBrowser?: undefined | false | {
69+
command: string;
70+
abortable?: boolean;
71+
} | ((options: OpenBrowserOptions) => Promise<OpenBrowserReturnType>);
72+
/**
73+
* The maximum time that the plugin waits for an opened browser to access
74+
* the URL that was passed to it, in milliseconds. The default is 10 seconds.
75+
* Passing a value of zero will disable the timeout altogether.
76+
*/
77+
openBrowserTimeout?: number;
78+
/**
79+
* A callback to provide users with the information required to operate
80+
* the Device Authorization flow.
81+
*/
82+
notifyDeviceFlow?: (information: DeviceFlowInformation) => Promise<void> | void;
83+
/**
84+
* Restrict possible OIDC authorization flows to a subset.
85+
*
86+
* The default value is `['auth-code']`, i.e. the Device Authorization Grant
87+
* flow is not enabled by default and needs to be enabled explicitly.
88+
*
89+
* Order of the entries is not relevant. The Authorization Code Flow always
90+
* takes precedence over the Device Authorization Grant flow.
91+
*
92+
* This can either be a static list of supported flows or a function which
93+
* returns such a list. In the latter case, the function will be called
94+
* for each authentication attempt. The AbortSignal argument can be used
95+
* to get insight into when the auth attempt is being aborted, by the
96+
* driver or through some other means. (For example, this callback
97+
* could be used to inform a user about the fact that re-authentication
98+
* is required, and reject if they decline to do so.)
99+
*/
100+
allowedFlows?: AuthFlowType[] | ((options: {
101+
signal: AbortSignal;
102+
}) => Promise<AuthFlowType[]> | AuthFlowType[]);
103+
/**
104+
* An optional EventEmitter that can be used for recording log events.
105+
*/
106+
logger?: TypedEventEmitter<MongoDBOIDCLogEventsMap>;
107+
/**
108+
* An AbortSignal that can be used to explicitly cancel authentication
109+
* attempts, for example if a user intentionally aborts a connection
110+
* attempt.
111+
*
112+
* Note that the driver also registers its own AbortSignal with individual
113+
* authentication attempts in order to enforce a timeout, which has the
114+
* same effect for authentication attempts from that driver MongoClient
115+
* instance (but does not prevent other MongoClients from using this
116+
* plugin instance to authenticate).
117+
*/
118+
signal?: OIDCAbortSignal;
119+
/**
120+
* A custom handler for providing HTTP responses for requests to the
121+
* redirect HTTP server used in the Authorization Code Flow.
122+
*
123+
* The default handler serves simple text/plain messages.
124+
*/
125+
redirectServerRequestHandler?: RedirectServerRequestHandler;
126+
/**
127+
* A serialized representation of a previous plugin instance's state
128+
* as returned by `.serialize()`.
129+
*
130+
* This option should only be passed if it comes from a trusted source,
131+
* since it contains access tokens that will be sent to MongoDB servers.
132+
*/
133+
serializedState?: string;
134+
/**
135+
* If set to true, creating the plugin will throw an exception when
136+
* `serializedState` is provided but cannot be deserialized.
137+
* If set to false, invalid serialized state will result in a log
138+
* message being emitted but otherwise be ignored.
139+
*/
140+
throwOnIncompatibleSerializedState?: boolean;
141+
/**
142+
* Provide custom HTTP options for individual HTTP calls.
143+
*
144+
* @deprecated Use a custom `fetch` function instead.
145+
*/
146+
customHttpOptions?: HttpOptions | ((url: string, options: Readonly<HttpOptions>) => HttpOptions);
147+
/**
148+
* Provide a custom `fetch` function to be used for HTTP calls.
149+
*
150+
* Any API that is compatible with the web `fetch` API can be used here.
151+
*/
152+
customFetch?: (url: string, options: Readonly<unknown>) => Promise<Response>;
153+
/**
154+
* Pass ID tokens in place of access tokens. For debugging/working around
155+
* broken identity providers.
156+
*/
157+
passIdTokenAsAccessToken?: boolean;
158+
/**
159+
* Skip the nonce parameter in the Authorization Code request. This could
160+
* be used to work with providers that don't support the nonce parameter.
161+
*
162+
* Default is `false`.
163+
*/
164+
skipNonceInAuthCodeRequest?: boolean;
165+
}
166+
/** @public */
167+
export interface MongoDBOIDCPluginMongoClientOptions {
168+
readonly authMechanismProperties: {
169+
readonly OIDC_HUMAN_CALLBACK: OIDCCallbackFunction;
170+
};
171+
}
172+
/** @public */
173+
export interface MongoDBOIDCPlugin {
174+
/**
175+
* A subset of MongoClientOptions that need to be set in order
176+
* for the MongoClient to an instance of this plugin.
177+
*
178+
* This object should be deep-merged with other, pre-existing
179+
* MongoClient driver options.
180+
*
181+
* @public
182+
*/
183+
readonly mongoClientOptions: MongoDBOIDCPluginMongoClientOptions;
184+
/**
185+
* The logger instance passed in the options, or a default one otherwise.
186+
*/
187+
readonly logger: TypedEventEmitter<MongoDBOIDCLogEventsMap>;
188+
/**
189+
* Create a serialized representation of this plugin's state. The result
190+
* can be stored and be later passed to new plugin instances to make
191+
* that instance behave as a resumed version of this instance.
192+
*
193+
* Be aware that this string contains OIDC tokens in plaintext! Do not
194+
* store it without appropriate security mechanisms in place.
195+
*/
196+
serialize(): Promise<string>;
197+
/**
198+
* Destroy this plugin instance. Currently, this only clears timers
199+
* for automatic token refreshing.
200+
*/
201+
destroy(): Promise<void>;
202+
}
203+
/** @internal */
204+
export declare const publicPluginToInternalPluginMap_DoNotUseOutsideOfTests: WeakMap<MongoDBOIDCPlugin, MongoDBOIDCPluginImpl>;
205+
/**
206+
* Create a new OIDC plugin instance that can be passed to the Node.js MongoDB
207+
* driver's MongoClientOptions struct.
208+
*
209+
* This plugin instance can be passed to multiple MongoClient instances.
210+
* It caches credentials based on cluster OIDC metadata.
211+
* Do *not* pass the plugin instance to multiple MongoClient instances when the
212+
* MongoDB deployments they are connecting to do not share a trust relationship
213+
* since an untrusted server may be able to advertise malicious OIDC metadata
214+
* (this restriction may be lifted in a future version of this library).
215+
* Do *not* pass the plugin instance to multiple MongoClient instances when they
216+
* are being used with different usernames (user principals), in the connection
217+
* string or in the MongoClient options.
218+
*
219+
* @public
220+
*/
221+
export declare function createMongoDBOIDCPlugin(options: Readonly<MongoDBOIDCPluginOptions>): MongoDBOIDCPlugin;
222+
/** @internal */
223+
export declare const kDefaultOpenBrowserTimeout = 20000;
224+
/** @public */
225+
export type RedirectServerRequestInfo = {
226+
/** The incoming HTTP request. */
227+
req: HttpIncomingMessage;
228+
/** The outgoing HTTP response. */
229+
res: HttpServerResponse;
230+
/** The suggested HTTP status code. For unknown-url, this is 404. */
231+
status: number;
232+
} & ({
233+
result: 'redirecting';
234+
location: string;
235+
} | {
236+
result: 'rejected';
237+
/** Error information reported by the IdP as defined in RFC6749 section 4.1.2.1 */
238+
error?: string;
239+
/** Error information reported by the IdP as defined in RFC6749 section 4.1.2.1 */
240+
errorDescription?: string;
241+
/** Error information reported by the IdP as defined in RFC6749 section 4.1.2.1 */
242+
errorURI?: string;
243+
} | {
244+
result: 'accepted';
245+
} | {
246+
result: 'unknown-url';
247+
});
248+
/** @public */
249+
export type RedirectServerRequestHandler = (data: RedirectServerRequestInfo) => void;
250+
//# sourceMappingURL=api.d.ts.map

dist/api.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/api.js

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/api.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { createMongoDBOIDCPlugin, ALL_AUTH_FLOW_TYPES } from './api';
2+
export type { MongoDBOIDCPlugin, MongoDBOIDCPluginOptions, AuthFlowType, DeviceFlowInformation, OpenBrowserOptions, OpenBrowserReturnType, RedirectServerRequestHandler, RedirectServerRequestInfo, MongoDBOIDCPluginMongoClientOptions, HttpOptions, } from './api';
3+
export type { TypedEventEmitter, OIDCCallbackParams, OIDCCallbackFunction, IdPServerInfo, IdPServerResponse, OIDCAbortSignal, MongoDBOIDCError, MongoDBOIDCLogEventsMap, } from './types';
4+
export { hookLoggerToMongoLogWriter, MongoLogWriter } from './log-hook';
5+
//# sourceMappingURL=index.d.ts.map

dist/index.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)