@mcp-abap-adt/auth-providers 1.2.0 → 2.2.0

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/COPYING +674 -0
  3. package/LICENSE +160 -17
  4. package/README.md +401 -66
  5. package/bin/auth-authorization-code.ts +5 -3
  6. package/dist/__tests__/helpers/netHelpers.d.ts +16 -0
  7. package/dist/__tests__/helpers/netHelpers.d.ts.map +1 -1
  8. package/dist/__tests__/helpers/netHelpers.js +29 -0
  9. package/dist/__tests__/helpers/testLogger.d.ts +1 -1
  10. package/dist/__tests__/helpers/testLogger.d.ts.map +1 -1
  11. package/dist/auth/announce.d.ts +11 -0
  12. package/dist/auth/announce.d.ts.map +1 -0
  13. package/dist/auth/announce.js +19 -0
  14. package/dist/auth/browserAuth.d.ts +23 -15
  15. package/dist/auth/browserAuth.d.ts.map +1 -1
  16. package/dist/auth/browserAuth.js +25 -111
  17. package/dist/auth/callbackServer.d.ts +7 -1
  18. package/dist/auth/callbackServer.d.ts.map +1 -1
  19. package/dist/auth/callbackServer.js +31 -21
  20. package/dist/auth/deviceFlowAuth.d.ts +1 -1
  21. package/dist/auth/deviceFlowAuth.d.ts.map +1 -1
  22. package/dist/auth/oidcBrowserAuth.d.ts +2 -9
  23. package/dist/auth/oidcBrowserAuth.d.ts.map +1 -1
  24. package/dist/auth/oidcBrowserAuth.js +16 -125
  25. package/dist/auth/oidcDiscovery.d.ts +1 -1
  26. package/dist/auth/oidcDiscovery.d.ts.map +1 -1
  27. package/dist/auth/oidcToken.d.ts +1 -1
  28. package/dist/auth/oidcToken.d.ts.map +1 -1
  29. package/dist/auth/saml2Auth.d.ts +2 -9
  30. package/dist/auth/saml2Auth.d.ts.map +1 -1
  31. package/dist/auth/saml2Auth.js +10 -130
  32. package/dist/auth/saml2TokenExchange.d.ts +1 -1
  33. package/dist/auth/saml2TokenExchange.d.ts.map +1 -1
  34. package/dist/errors/TokenProviderErrors.js +6 -6
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +21 -1
  38. package/dist/providers/AuthorizationCodeProvider.d.ts +8 -3
  39. package/dist/providers/AuthorizationCodeProvider.d.ts.map +1 -1
  40. package/dist/providers/AuthorizationCodeProvider.js +55 -44
  41. package/dist/providers/BaseTokenProvider.d.ts +2 -1
  42. package/dist/providers/BaseTokenProvider.d.ts.map +1 -1
  43. package/dist/providers/ClientCredentialsProvider.d.ts +1 -1
  44. package/dist/providers/ClientCredentialsProvider.d.ts.map +1 -1
  45. package/dist/providers/ClientCredentialsProvider.js +3 -3
  46. package/dist/providers/DeviceFlowProvider.d.ts +3 -1
  47. package/dist/providers/DeviceFlowProvider.d.ts.map +1 -1
  48. package/dist/providers/DeviceFlowProvider.js +17 -14
  49. package/dist/providers/OidcBrowserProvider.d.ts +5 -7
  50. package/dist/providers/OidcBrowserProvider.d.ts.map +1 -1
  51. package/dist/providers/OidcBrowserProvider.js +58 -61
  52. package/dist/providers/OidcDeviceFlowProvider.d.ts +2 -1
  53. package/dist/providers/OidcDeviceFlowProvider.d.ts.map +1 -1
  54. package/dist/providers/OidcDeviceFlowProvider.js +13 -11
  55. package/dist/providers/OidcPasswordProvider.d.ts +2 -1
  56. package/dist/providers/OidcPasswordProvider.d.ts.map +1 -1
  57. package/dist/providers/OidcPasswordProvider.js +4 -4
  58. package/dist/providers/OidcTokenExchangeProvider.d.ts +2 -1
  59. package/dist/providers/OidcTokenExchangeProvider.d.ts.map +1 -1
  60. package/dist/providers/OidcTokenExchangeProvider.js +3 -3
  61. package/dist/providers/Saml2BearerProvider.d.ts +4 -3
  62. package/dist/providers/Saml2BearerProvider.d.ts.map +1 -1
  63. package/dist/providers/Saml2BearerProvider.js +6 -3
  64. package/dist/providers/Saml2PureProvider.d.ts +4 -3
  65. package/dist/providers/Saml2PureProvider.d.ts.map +1 -1
  66. package/dist/providers/Saml2PureProvider.js +6 -3
  67. package/dist/providers/saml2Utils.d.ts +13 -12
  68. package/dist/providers/saml2Utils.d.ts.map +1 -1
  69. package/dist/providers/saml2Utils.js +46 -26
  70. package/dist/sso/SsoProviderFactory.d.ts +1 -1
  71. package/dist/sso/SsoProviderFactory.d.ts.map +1 -1
  72. package/dist/sso/types.d.ts +1 -1
  73. package/dist/sso/types.d.ts.map +1 -1
  74. package/dist/strategies/BrowserCallbackStrategy.d.ts +64 -0
  75. package/dist/strategies/BrowserCallbackStrategy.d.ts.map +1 -0
  76. package/dist/strategies/BrowserCallbackStrategy.js +210 -0
  77. package/dist/strategies/asOidcResult.d.ts +11 -0
  78. package/dist/strategies/asOidcResult.d.ts.map +1 -0
  79. package/dist/strategies/asOidcResult.js +30 -0
  80. package/dist/strategies/codeStrategies.d.ts +22 -0
  81. package/dist/strategies/codeStrategies.d.ts.map +1 -0
  82. package/dist/strategies/codeStrategies.js +39 -0
  83. package/dist/strategies/index.d.ts +8 -0
  84. package/dist/strategies/index.d.ts.map +1 -0
  85. package/dist/strategies/index.js +18 -0
  86. package/dist/strategies/manualStrategies.d.ts +20 -0
  87. package/dist/strategies/manualStrategies.d.ts.map +1 -0
  88. package/dist/strategies/manualStrategies.js +77 -0
  89. package/package.json +8 -5
  90. package/dist/auth/manualInput.d.ts +0 -5
  91. package/dist/auth/manualInput.d.ts.map +0 -1
  92. package/dist/auth/manualInput.js +0 -19
package/CHANGELOG.md CHANGED
@@ -7,6 +7,141 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.2.0] - 2026-09-24
11
+
12
+ ### Dependencies
13
+
14
+ - **`@mcp-abap-adt/interfaces` is replaced by the contract packages this
15
+ package actually uses.** The facade is deleted upstream; 51.0.0 is its last
16
+ version. The contracts now come from:
17
+ - `@mcp-abap-adt/interfaces-auth` `^1.2.0` — `ITokenProvider`, `ITokenResult`,
18
+ `IAuthorizationStrategy`, the callback server types, `AUTH_TYPE_*` and
19
+ `TOKEN_PROVIDER_ERROR_CODES`;
20
+ - `@mcp-abap-adt/interfaces-auth-sap` `^1.0.0` — `IAuthorizationConfig`;
21
+ - `@mcp-abap-adt/interfaces-utils` `^1.1.0` — `ILogger`.
22
+
23
+ No export of this package changed. A consumer that imports these types itself
24
+ should import them from the same packages, not from the facade.
25
+ - `@mcp-abap-adt/logger` (dev) `^0.4.0`, which is on `interfaces-utils` as well.
26
+
27
+ ## [2.1.0] - 2026-09-03
28
+
29
+ ### Licence
30
+
31
+ - **This package is now `LGPL-3.0-only`.** It was MIT up to and including 2.0.0, and
32
+ those versions stay MIT — a licence change is not retroactive, and anyone
33
+ already using 2.0.0 under MIT keeps that grant for 2.0.0.
34
+
35
+ The library licence of the GNU family, chosen for what it does *not* ask:
36
+ linking it into your own program — importing it, as every consumer of an npm
37
+ package does — does not put your program under the LGPL. What it asks is that
38
+ changes to this library stay free and that your users can substitute their own
39
+ build of it.
40
+
41
+ Both texts ship in the package: `LICENSE` is the LGPL, `COPYING` is the GPL it
42
+ is written on top of. The LGPL is a set of additional permissions over the GPL,
43
+ so it cannot be read without both.
44
+
45
+ Copyright © 2025–2026 Oleksii Kyslytsia.
46
+
47
+
48
+ ## [2.0.0] - 2026-07-31
49
+
50
+ Callback reception leaves the providers. How an interactive login is conducted —
51
+ reaching the authorization URL, receiving what comes back, the port, the timeout
52
+ — is now an `IAuthorizationStrategy` the consumer may replace wholesale; the
53
+ provider keeps only what it can compute, the URL and the token exchange. (#11)
54
+
55
+ ### Breaking
56
+
57
+ - **`browser` and `redirectPort` are removed from every provider config**, along
58
+ with `redirectUri`, `authorizationCode` and `authorizationCodeProvider`
59
+ (OIDC) and `assertionFlow`, `assertionProvider` and `manualInput` (SAML).
60
+ All are replaced by a single `authorization` strategy. See the migration
61
+ table in the README.
62
+ - **The default callback port is now 61001, was 3001** — for the UAA flow and
63
+ for SAML alike, the latter because `resolveAcsUrl` (which defaulted the ACS to
64
+ `http://localhost:3001/callback`) is gone and the ACS now comes from the
65
+ strategy. If you relied on the default and registered
66
+ `http://localhost:3001/callback` with your identity provider, the **IdP**
67
+ rejects the redirect and the error you see comes from it, not from this
68
+ package. Pass `port: 3001` explicitly to keep the old behaviour.
69
+ - **`acsUrl` is required when `authorizationUrl` is set** on `Saml2BearerProvider`
70
+ and `Saml2PureProvider`, and is rejected at construction. The ACS inside a
71
+ pre-built, deflated `SAMLRequest` cannot be read, so it cannot be checked
72
+ against what the strategy binds; 1.x accepted the combination and quietly used
73
+ a default ACS that was usually not where the IdP posted.
74
+ - **The terminal-paste channel is gone from the browser callback strategy.** In
75
+ 1.x a `none` / `headless` login could also be completed by pasting the code on
76
+ stdin, and that worked without the consumer choosing anything; it is the
77
+ channel headless and SSH users reached for most. `browserCallbackStrategy`
78
+ reads no stdin at all — under an MCP or LSP stdio transport that stream
79
+ carries the protocol, so an authorization library must not consume it. The
80
+ capability moved to `manualPasteStrategy({ redirectUri, read })`, which is now
81
+ an explicit choice; the paste form served on `/` remains the other fallback
82
+ for a browser on a different machine.
83
+ - **Device flow prompts no longer go to stdout.** `DeviceFlowProviderConfig`
84
+ accepts `logger?: ILogger`; the verification URI and user code go to that
85
+ logger, or to stderr when none is supplied. `OidcDeviceFlowProvider` likewise.
86
+ Anything capturing stdout to read the device code must now read stderr or
87
+ supply a logger. stdout carries protocol traffic under an MCP or LSP stdio
88
+ transport.
89
+ - `Saml2AssertionConfig` and `Saml2AssertionFlow` are removed from the types, and
90
+ `src/auth/manualInput.ts` is gone; `manualPasteStrategy` and
91
+ `manualSamlResponseStrategy` replace them.
92
+ - Requires `@mcp-abap-adt/interfaces` `^11.6.0` (was `^11.4.0`).
93
+
94
+ ### Added
95
+
96
+ - `IAuthorizationStrategy` support in all four interactive providers
97
+ (`AuthorizationCodeProvider`, `OidcBrowserProvider`, `Saml2BearerProvider`,
98
+ `Saml2PureProvider`), with shipped strategies: `browserCallbackStrategy`,
99
+ `oidcCallbackStrategy`, `samlCallbackStrategy`, `manualPasteStrategy`,
100
+ `manualSamlResponseStrategy`, `externalCodeStrategy`, `staticCodeStrategy`,
101
+ and the `asOidcResult` adapter. `BrowserCallbackStrategy`,
102
+ `DEFAULT_CALLBACK_PORT` and `DEFAULT_LOGIN_TIMEOUT_MS` are exported too.
103
+ - `asOidcResult` bridges the code-producing strategies, which yield a `string`,
104
+ to `OidcBrowserProvider`, which takes `IAuthorizationStrategy<OidcCallbackResult>`.
105
+ It delegates `dispose`, so wrapping costs nothing in lifecycle terms.
106
+ - The three `CallbackServerFactory` implementations are exported —
107
+ `withBrowserCallbackServer`, `withOidcCallbackServer`, `withSamlCallbackServer`
108
+ — so a consumer can reuse the transport while replacing everything around it,
109
+ or inject its own into a shipped strategy via `callbackServer`.
110
+ - Ephemeral callback ports (`port: 0`), where the identity provider accepts a
111
+ loopback redirect on any port. The bound port is reported back, so the token
112
+ exchange can send the redirect URI that actually received the callback.
113
+ - `OidcBrowserProvider` discovers lazily: a strategy that already holds a code
114
+ no longer drags in a discovery request, nor the `issuerUrl` requirement.
115
+
116
+ ### Fixed
117
+
118
+ - A `/callback` carrying neither a code nor an error no longer ends the login;
119
+ it is answered, counted, and reported in the timeout message.
120
+ - The OIDC callback route now distinguishes an IdP refusal from a stray
121
+ request — it previously had no `error=` branch at all.
122
+ - The SAML callback route no longer shows a success page before checking
123
+ whether an assertion arrived; a request with no assertion is answered 400.
124
+ - Manual input prompts go to stderr; they went to stdout, which corrupts an
125
+ MCP/LSP stdio transport.
126
+ - The token exchange sends the redirect URI that actually received the
127
+ callback, rather than one rebuilt from an assumed port.
128
+ - The PKCE challenge is pinned to the verifier that reaches the exchange.
129
+ - A strategy disposed while its port probe was still awaiting used to report
130
+ everything released and then bind a socket behind it.
131
+ - The remote paste hint named `http://localhost:<port>/` — an address that
132
+ cannot work for the one reader it addresses, someone whose browser is on
133
+ another machine. It now names `http://<this-host>:<port>/`, keeping the real
134
+ port and leaving the host to the reader, as the 1.x wording did.
135
+
136
+ ### Docs
137
+
138
+ - `README.md` documents strategies throughout, adds *Choosing an authorization
139
+ strategy* and *Migrating from 1.x to 2.0*, and corrects two claims that were
140
+ already wrong in 1.x: the default `browser` mode is `'none'`, not `'system'`,
141
+ and `extractCode` is internal, not exported.
142
+ - `docs/REFACTORING_PROPOSAL.md` is deleted; the `ITokenProvider` refactor it
143
+ proposed shipped in 1.0.0.
144
+
10
145
  ## [1.2.0] - 2026-07-28
11
146
 
12
147
  ### Fixed