oauth-callback 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,CAAC;AAEf;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,MAAM,CAOR;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,kBAAkB,GAAG,MAAM,GACjC,OAAO,CAAC,cAAc,CAAC,CAmDzB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAMlD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,CAAC;AAEf;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,MAAM,CAOR;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,kBAAkB,GAAG,MAAM,GACjC,OAAO,CAAC,cAAc,CAAC,CAsDzB"}
package/dist/index.js CHANGED
@@ -1269,11 +1269,14 @@ class BrowserOAuthProvider {
1269
1269
  }
1270
1270
  }
1271
1271
  // src/index.ts
1272
+ var DEFAULT_PORT = 3000;
1273
+ var DEFAULT_HOSTNAME = "localhost";
1274
+ var DEFAULT_CALLBACK_PATH = "/callback";
1272
1275
  function getRedirectUrl(options = {}) {
1273
1276
  const {
1274
- port = 3000,
1275
- hostname = "localhost",
1276
- callbackPath = "/callback"
1277
+ port = DEFAULT_PORT,
1278
+ hostname = DEFAULT_HOSTNAME,
1279
+ callbackPath = DEFAULT_CALLBACK_PATH
1277
1280
  } = options;
1278
1281
  return `http://${hostname}:${port}${callbackPath}`;
1279
1282
  }
@@ -1284,10 +1287,10 @@ async function authorizationUrlToOptions(input) {
1284
1287
  async function getAuthCode(input) {
1285
1288
  const options = typeof input === "string" ? await authorizationUrlToOptions(input) : input;
1286
1289
  const {
1287
- port = 3000,
1288
- hostname = "localhost",
1290
+ port = DEFAULT_PORT,
1291
+ hostname = DEFAULT_HOSTNAME,
1289
1292
  timeout = 30000,
1290
- callbackPath = "/callback",
1293
+ callbackPath = DEFAULT_CALLBACK_PATH,
1291
1294
  successHtml,
1292
1295
  errorHtml,
1293
1296
  signal,
@@ -1303,9 +1306,8 @@ async function getAuthCode(input) {
1303
1306
  signal,
1304
1307
  onRequest
1305
1308
  });
1306
- if ("authorizationUrl" in options && typeof options.launch === "function") {
1307
- const { authorizationUrl, launch } = options;
1308
- Promise.resolve(launch(authorizationUrl)).catch(() => {});
1309
+ if ("authorizationUrl" in options && options.authorizationUrl && "launch" in options && typeof options.launch === "function") {
1310
+ Promise.resolve(options.launch(options.authorizationUrl)).catch(() => {});
1309
1311
  }
1310
1312
  const result = await server.waitForCallback(callbackPath, timeout);
1311
1313
  if (result.error) {
package/dist/mcp.js CHANGED
@@ -1006,6 +1006,9 @@ function fileStore(filepath) {
1006
1006
  }
1007
1007
 
1008
1008
  // src/index.ts
1009
+ var DEFAULT_PORT = 3000;
1010
+ var DEFAULT_HOSTNAME = "localhost";
1011
+ var DEFAULT_CALLBACK_PATH = "/callback";
1009
1012
  async function authorizationUrlToOptions(input) {
1010
1013
  const open2 = await Promise.resolve().then(() => (init_open(), exports_open));
1011
1014
  return { authorizationUrl: input, launch: open2.default };
@@ -1013,10 +1016,10 @@ async function authorizationUrlToOptions(input) {
1013
1016
  async function getAuthCode(input) {
1014
1017
  const options = typeof input === "string" ? await authorizationUrlToOptions(input) : input;
1015
1018
  const {
1016
- port = 3000,
1017
- hostname = "localhost",
1019
+ port = DEFAULT_PORT,
1020
+ hostname = DEFAULT_HOSTNAME,
1018
1021
  timeout = 30000,
1019
- callbackPath = "/callback",
1022
+ callbackPath = DEFAULT_CALLBACK_PATH,
1020
1023
  successHtml,
1021
1024
  errorHtml,
1022
1025
  signal,
@@ -1032,9 +1035,8 @@ async function getAuthCode(input) {
1032
1035
  signal,
1033
1036
  onRequest
1034
1037
  });
1035
- if ("authorizationUrl" in options && typeof options.launch === "function") {
1036
- const { authorizationUrl, launch } = options;
1037
- Promise.resolve(launch(authorizationUrl)).catch(() => {});
1038
+ if ("authorizationUrl" in options && options.authorizationUrl && "launch" in options && typeof options.launch === "function") {
1039
+ Promise.resolve(options.launch(options.authorizationUrl)).catch(() => {});
1038
1040
  }
1039
1041
  const result = await server.waitForCallback(callbackPath, timeout);
1040
1042
  if (result.error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oauth-callback",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Lightweight OAuth 2.0 callback handler for Node.js, Deno, and Bun with built-in browser flow and MCP SDK integration",
5
5
  "keywords": [
6
6
  "oauth",
package/src/index.ts CHANGED
@@ -10,6 +10,10 @@ import { OAuthError } from "./errors";
10
10
  import { createCallbackServer, type CallbackResult } from "./server";
11
11
  import type { GetAuthCodeOptions } from "./types";
12
12
 
13
+ const DEFAULT_PORT = 3000;
14
+ const DEFAULT_HOSTNAME = "localhost";
15
+ const DEFAULT_CALLBACK_PATH = "/callback";
16
+
13
17
  export type { CallbackResult, CallbackServer, ServerOptions } from "./server";
14
18
  export { OAuthError, TimeoutError } from "./errors";
15
19
  export type { GetAuthCodeOptions } from "./types";
@@ -44,9 +48,9 @@ export function getRedirectUrl(
44
48
  } = {},
45
49
  ): string {
46
50
  const {
47
- port = 3000,
48
- hostname = "localhost",
49
- callbackPath = "/callback",
51
+ port = DEFAULT_PORT,
52
+ hostname = DEFAULT_HOSTNAME,
53
+ callbackPath = DEFAULT_CALLBACK_PATH,
50
54
  } = options;
51
55
  return `http://${hostname}:${port}${callbackPath}`;
52
56
  }
@@ -94,10 +98,10 @@ export async function getAuthCode(
94
98
  typeof input === "string" ? await authorizationUrlToOptions(input) : input;
95
99
 
96
100
  const {
97
- port = 3000,
98
- hostname = "localhost",
101
+ port = DEFAULT_PORT,
102
+ hostname = DEFAULT_HOSTNAME,
99
103
  timeout = 30000,
100
- callbackPath = "/callback",
104
+ callbackPath = DEFAULT_CALLBACK_PATH,
101
105
  successHtml,
102
106
  errorHtml,
103
107
  signal,
@@ -119,10 +123,13 @@ export async function getAuthCode(
119
123
  // Best-effort launch: fire-and-forget, swallow errors (managed mode only)
120
124
  if (
121
125
  "authorizationUrl" in options &&
122
- typeof (options as any).launch === "function"
126
+ options.authorizationUrl &&
127
+ "launch" in options &&
128
+ typeof options.launch === "function"
123
129
  ) {
124
- const { authorizationUrl, launch } = options as any;
125
- void Promise.resolve(launch(authorizationUrl)).catch(() => {});
130
+ void Promise.resolve(options.launch(options.authorizationUrl)).catch(
131
+ () => {},
132
+ );
126
133
  }
127
134
 
128
135
  const result = await server.waitForCallback(callbackPath, timeout);