@mcp-abap-adt/auth-broker 0.1.2 → 0.1.3
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.
- package/CHANGELOG.md +24 -0
- package/dist/browserAuth.d.ts.map +1 -1
- package/dist/browserAuth.js +5 -1
- package/dist/logger.d.ts +11 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +72 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
Thank you to all contributors! See [CONTRIBUTORS.md](CONTRIBUTORS.md) for the complete list.
|
|
11
11
|
|
|
12
|
+
## [0.1.3] - 2025-12-01
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- **Configurable Log Levels** - Added log level control via environment variable `AUTH_LOG_LEVEL`
|
|
16
|
+
- `error` - only errors
|
|
17
|
+
- `warn` - errors and warnings
|
|
18
|
+
- `info` - errors, warnings, and info (default)
|
|
19
|
+
- `debug` - all messages
|
|
20
|
+
- Backward compatible: `DEBUG_AUTH_LOG=true` still works (sets level to debug)
|
|
21
|
+
- New `warn()` method in Logger interface for warning messages
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- **Error Handling for Consumer** - Improved error handling to ensure consumer can distinguish different error types
|
|
25
|
+
- Service key missing error: throws `Error` with message containing "No authentication found" or "Service key file not found"
|
|
26
|
+
- Browser opening failed error: throws `Error` with message containing "Browser opening failed"
|
|
27
|
+
- Both errors are now properly thrown and can be caught by consumer in `catch` blocks
|
|
28
|
+
- Errors are distinct and can be programmatically handled differently
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- **Logger Implementation** - Enhanced logger with log level filtering
|
|
32
|
+
- All log methods now respect the configured log level
|
|
33
|
+
- `info()`, `debug()`, `error()`, and new `warn()` methods filter output based on `AUTH_LOG_LEVEL`
|
|
34
|
+
- Default log level is `info` (shows errors, warnings, and info messages)
|
|
35
|
+
|
|
12
36
|
## [0.1.2] - 2025-11-30
|
|
13
37
|
|
|
14
38
|
### Added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserAuth.d.ts","sourceRoot":"","sources":["../src/browserAuth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,EAAiB,MAAM,UAAU,CAAC;AA4DjD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,MAAiB,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"browserAuth.d.ts","sourceRoot":"","sources":["../src/browserAuth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,EAAiB,MAAM,UAAU,CAAC;AA4DjD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,MAAiB,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAyMzD"}
|
package/dist/browserAuth.js
CHANGED
|
@@ -284,7 +284,11 @@ async function startBrowserAuth(serviceKey, browser = 'system', logger) {
|
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
catch (error) {
|
|
287
|
-
|
|
287
|
+
// If browser cannot be opened, show URL and throw error for consumer to catch
|
|
288
|
+
log.error(`❌ Failed to open browser: ${error?.message || String(error)}. Please open manually: ${authorizationUrl}`);
|
|
289
|
+
log.browserUrl(authorizationUrl);
|
|
290
|
+
// Throw error so consumer can distinguish this from "service key missing" error
|
|
291
|
+
reject(new Error(`Browser opening failed for destination authentication. Please open manually: ${authorizationUrl}`));
|
|
288
292
|
}
|
|
289
293
|
}
|
|
290
294
|
});
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Logger interface and implementations for auth-broker package
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Log levels
|
|
6
|
+
*/
|
|
7
|
+
export declare enum LogLevel {
|
|
8
|
+
ERROR = 0,
|
|
9
|
+
WARN = 1,
|
|
10
|
+
INFO = 2,
|
|
11
|
+
DEBUG = 3
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* Logger interface - defines logging methods
|
|
6
15
|
*/
|
|
@@ -8,6 +17,7 @@ export interface Logger {
|
|
|
8
17
|
info(message: string): void;
|
|
9
18
|
debug(message: string): void;
|
|
10
19
|
error(message: string): void;
|
|
20
|
+
warn(message: string): void;
|
|
11
21
|
browserAuth(message: string): void;
|
|
12
22
|
refresh(message: string): void;
|
|
13
23
|
success(message: string): void;
|
|
@@ -26,4 +36,5 @@ export declare function success(message: string): void;
|
|
|
26
36
|
export declare function browserUrl(url: string): void;
|
|
27
37
|
export declare function browserOpening(): void;
|
|
28
38
|
export declare function testSkip(message: string): void;
|
|
39
|
+
export declare function warn(message: string): void;
|
|
29
40
|
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,OAAO,EAA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AAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C"}
|
package/dist/logger.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Logger interface and implementations for auth-broker package
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.testLogger = exports.defaultLogger = void 0;
|
|
6
|
+
exports.testLogger = exports.defaultLogger = exports.LogLevel = void 0;
|
|
7
7
|
exports.info = info;
|
|
8
8
|
exports.debug = debug;
|
|
9
9
|
exports.error = error;
|
|
@@ -13,27 +13,70 @@ exports.success = success;
|
|
|
13
13
|
exports.browserUrl = browserUrl;
|
|
14
14
|
exports.browserOpening = browserOpening;
|
|
15
15
|
exports.testSkip = testSkip;
|
|
16
|
+
exports.warn = warn;
|
|
17
|
+
/**
|
|
18
|
+
* Log levels
|
|
19
|
+
*/
|
|
20
|
+
var LogLevel;
|
|
21
|
+
(function (LogLevel) {
|
|
22
|
+
LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
|
|
23
|
+
LogLevel[LogLevel["WARN"] = 1] = "WARN";
|
|
24
|
+
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
|
25
|
+
LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
|
|
26
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
27
|
+
/**
|
|
28
|
+
* Get log level from environment variable
|
|
29
|
+
* AUTH_LOG_LEVEL can be: error, warn, info, debug
|
|
30
|
+
* DEBUG_AUTH_LOG=true is also supported for backward compatibility (sets level to debug)
|
|
31
|
+
*/
|
|
32
|
+
function getLogLevel() {
|
|
33
|
+
const level = process.env.AUTH_LOG_LEVEL?.toLowerCase();
|
|
34
|
+
if (level === 'error')
|
|
35
|
+
return LogLevel.ERROR;
|
|
36
|
+
if (level === 'warn')
|
|
37
|
+
return LogLevel.WARN;
|
|
38
|
+
if (level === 'info')
|
|
39
|
+
return LogLevel.INFO;
|
|
40
|
+
if (level === 'debug')
|
|
41
|
+
return LogLevel.DEBUG;
|
|
42
|
+
// Backward compatibility
|
|
43
|
+
if (process.env.DEBUG_AUTH_LOG === 'true')
|
|
44
|
+
return LogLevel.DEBUG;
|
|
45
|
+
// Default: info level
|
|
46
|
+
return LogLevel.INFO;
|
|
47
|
+
}
|
|
16
48
|
/**
|
|
17
49
|
* Default logger implementation
|
|
18
|
-
* Controls output based on
|
|
19
|
-
* -
|
|
20
|
-
* -
|
|
50
|
+
* Controls output based on AUTH_LOG_LEVEL environment variable:
|
|
51
|
+
* - error: only errors
|
|
52
|
+
* - warn: errors and warnings
|
|
53
|
+
* - info: errors, warnings, and info (default)
|
|
54
|
+
* - debug: all messages
|
|
21
55
|
*/
|
|
22
56
|
class DefaultLogger {
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
this.
|
|
57
|
+
logLevel;
|
|
58
|
+
constructor(logLevel) {
|
|
59
|
+
this.logLevel = logLevel ?? getLogLevel();
|
|
26
60
|
}
|
|
27
61
|
info(message) {
|
|
28
|
-
|
|
62
|
+
if (this.logLevel >= LogLevel.INFO) {
|
|
63
|
+
console.info(message);
|
|
64
|
+
}
|
|
29
65
|
}
|
|
30
66
|
debug(message) {
|
|
31
|
-
if (this.
|
|
67
|
+
if (this.logLevel >= LogLevel.DEBUG) {
|
|
32
68
|
console.debug(`[DEBUG] ${message}`);
|
|
33
69
|
}
|
|
34
70
|
}
|
|
35
71
|
error(message) {
|
|
36
|
-
|
|
72
|
+
if (this.logLevel >= LogLevel.ERROR) {
|
|
73
|
+
console.error(message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
warn(message) {
|
|
77
|
+
if (this.logLevel >= LogLevel.WARN) {
|
|
78
|
+
console.warn(`[WARN] ${message}`);
|
|
79
|
+
}
|
|
37
80
|
}
|
|
38
81
|
browserAuth(message) {
|
|
39
82
|
this.info(`🌐 ${message}`);
|
|
@@ -58,23 +101,32 @@ class DefaultLogger {
|
|
|
58
101
|
}
|
|
59
102
|
/**
|
|
60
103
|
* Test logger implementation
|
|
61
|
-
*
|
|
104
|
+
* Uses same log levels as DefaultLogger
|
|
62
105
|
*/
|
|
63
106
|
class TestLogger {
|
|
64
|
-
|
|
65
|
-
constructor(
|
|
66
|
-
this.
|
|
107
|
+
logLevel;
|
|
108
|
+
constructor(logLevel) {
|
|
109
|
+
this.logLevel = logLevel ?? getLogLevel();
|
|
67
110
|
}
|
|
68
111
|
info(message) {
|
|
69
|
-
|
|
112
|
+
if (this.logLevel >= LogLevel.INFO) {
|
|
113
|
+
console.info(message);
|
|
114
|
+
}
|
|
70
115
|
}
|
|
71
116
|
debug(message) {
|
|
72
|
-
if (this.
|
|
117
|
+
if (this.logLevel >= LogLevel.DEBUG) {
|
|
73
118
|
console.info(`[DEBUG] ${message}`);
|
|
74
119
|
}
|
|
75
120
|
}
|
|
76
121
|
error(message) {
|
|
77
|
-
|
|
122
|
+
if (this.logLevel >= LogLevel.ERROR) {
|
|
123
|
+
console.error(message);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
warn(message) {
|
|
127
|
+
if (this.logLevel >= LogLevel.WARN) {
|
|
128
|
+
console.warn(`[WARN] ${message}`);
|
|
129
|
+
}
|
|
78
130
|
}
|
|
79
131
|
browserAuth(message) {
|
|
80
132
|
this.info(`🌐 ${message}`);
|
|
@@ -129,3 +181,6 @@ function browserOpening() {
|
|
|
129
181
|
function testSkip(message) {
|
|
130
182
|
exports.defaultLogger.testSkip(message);
|
|
131
183
|
}
|
|
184
|
+
function warn(message) {
|
|
185
|
+
exports.defaultLogger.warn(message);
|
|
186
|
+
}
|
package/package.json
CHANGED