@mcp-abap-adt/auth-broker 4.0.0 → 5.0.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.
- package/CHANGELOG.md +273 -1
- package/README.md +1028 -908
- package/dist/AuthBroker.d.ts +353 -99
- package/dist/AuthBroker.d.ts.map +1 -1
- package/dist/AuthBroker.js +806 -258
- package/dist/DestinationConfigError.d.ts +35 -6
- package/dist/DestinationConfigError.d.ts.map +1 -1
- package/dist/DestinationConfigError.js +51 -9
- package/dist/SessionWriter.d.ts +70 -33
- package/dist/SessionWriter.d.ts.map +1 -1
- package/dist/SessionWriter.js +118 -94
- package/dist/binding.d.ts +137 -64
- package/dist/binding.d.ts.map +1 -1
- package/dist/binding.js +330 -131
- package/dist/bindingOf.d.ts +33 -14
- package/dist/bindingOf.d.ts.map +1 -1
- package/dist/bindingOf.js +50 -20
- package/dist/buildIdentity.d.ts +137 -0
- package/dist/buildIdentity.d.ts.map +1 -0
- package/dist/buildIdentity.js +393 -0
- package/dist/clientAuthentication.d.ts +124 -0
- package/dist/clientAuthentication.d.ts.map +1 -0
- package/dist/clientAuthentication.js +218 -0
- package/dist/contractShape.d.ts +24 -0
- package/dist/contractShape.d.ts.map +1 -0
- package/dist/contractShape.js +24 -0
- package/dist/destinations.d.ts +174 -53
- package/dist/destinations.d.ts.map +1 -1
- package/dist/destinations.js +460 -150
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/quietLogger.d.ts +24 -0
- package/dist/quietLogger.d.ts.map +1 -0
- package/dist/quietLogger.js +63 -0
- package/package.json +9 -7
package/dist/binding.d.ts
CHANGED
|
@@ -1,95 +1,168 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A secret is bound to the resource it was obtained for and to
|
|
2
|
+
* A secret is bound to the resource it was obtained for and to everything that
|
|
3
|
+
* decides where it goes and whose it is.
|
|
3
4
|
*
|
|
4
|
-
* The session store keeps two strings beside the secret
|
|
5
|
-
*
|
|
6
|
-
* stored secret only when both equal what this destination's means give. The
|
|
7
|
-
* store keeps them as given; the broker canonicalises **both sides** before it
|
|
8
|
-
* compares, with the one function here (the broker's only, decided), so a store
|
|
9
|
-
* need not canonicalise and a legacy file's composed URI compares equal.
|
|
5
|
+
* The session store keeps two strings beside the secret, and the broker uses a
|
|
6
|
+
* stored secret only when both equal what this destination's means give:
|
|
10
7
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* -
|
|
16
|
-
*
|
|
17
|
-
* `client_id=<id>` for an issuer, none for a SAML ACS — parsed and
|
|
18
|
-
* re-encoded with `URLSearchParams`, so a value percent-encoded on one side
|
|
19
|
-
* and plain on the other compares equal;
|
|
20
|
-
* - no user info, no other parameter, no fragment.
|
|
8
|
+
* - **`issuedFor`**, the resource: `serviceUrl` with the SAP client, in the
|
|
9
|
+
* canonical form 4.x wrote (`resourceUri`). Both sides are canonicalised
|
|
10
|
+
* before they are compared, so a stored value written by any 4.x-era
|
|
11
|
+
* consumer compares equal.
|
|
12
|
+
* - **`issuedBy`**, a versioned record only the broker produces
|
|
13
|
+
* (`bindingRecord`):
|
|
21
14
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
15
|
+
* ```
|
|
16
|
+
* mcp-abap-adt-binding/2;<row>;<eleven address fields>;<trust>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* `row` is `authType/grantType` (or `provider/…` for the token API's
|
|
20
|
+
* consumer provider); each address field is the exact string the row hands
|
|
21
|
+
* its provider — `encodeURIComponent`-encoded, `""` when it hands none, never
|
|
22
|
+
* canonicalised — in the fixed order of `RECORD_FIELDS`; `trust` is the
|
|
23
|
+
* SHA-256 of the row's non-secret trust input (`trustDigest`), or `""`.
|
|
24
|
+
* The record is compared by exact equality and never parsed, split or
|
|
25
|
+
* matched; no regular expression touches it.
|
|
26
|
+
*
|
|
27
|
+
* No secret takes part in either string, nor a hash of one: a hash in a
|
|
28
|
+
* session file can be checked offline against guesses.
|
|
24
29
|
*/
|
|
25
30
|
import type { IConfig, IConnectionConfig } from '@mcp-abap-adt/interfaces-auth-broker';
|
|
26
31
|
import type { IAuthorizationConfig } from '@mcp-abap-adt/interfaces-auth-sap';
|
|
32
|
+
/** What a binding reads of a client: who it is, never its secret. */
|
|
33
|
+
export type BoundClient = Pick<IAuthorizationConfig, 'uaaUrl' | 'uaaClientId'>;
|
|
27
34
|
/**
|
|
28
|
-
* The
|
|
29
|
-
*
|
|
30
|
-
*
|
|
35
|
+
* The certificate client a build read for the `clientAuthentication`
|
|
36
|
+
* strategy, as the store answered it: where its token endpoint is, and its
|
|
37
|
+
* public certificate — never its key.
|
|
31
38
|
*/
|
|
32
|
-
export
|
|
39
|
+
export interface BoundCertificate {
|
|
40
|
+
readonly certUrl: unknown;
|
|
41
|
+
readonly certificate: unknown;
|
|
42
|
+
}
|
|
43
|
+
/** The eleven address fields of the record, in their fixed order. */
|
|
44
|
+
export declare const RECORD_FIELDS: readonly ["clientId", "uaaUrl", "oidcIssuerUrl", "oidcTokenEndpoint", "oidcAuthorizationEndpoint", "oidcDeviceAuthorizationEndpoint", "oidcAudience", "samlIdpSsoUrl", "samlAcsUrl", "samlTokenUrl", "certUrl"];
|
|
45
|
+
/** The address values a row hands its provider; any one may be absent. */
|
|
46
|
+
export type RecordFields = Partial<Record<(typeof RECORD_FIELDS)[number], unknown>>;
|
|
47
|
+
/**
|
|
48
|
+
* The `issuedBy` record: the version, the row, the eleven address fields in
|
|
49
|
+
* their fixed order — each the exact string, encoded, `""` when absent or
|
|
50
|
+
* `''` — and the trust digest. Every field is always present, and none holds
|
|
51
|
+
* `;`, so the string is unambiguous without being parsed.
|
|
52
|
+
*/
|
|
53
|
+
export declare function bindingRecord(row: string, fields: RecordFields, trust: string): string;
|
|
33
54
|
/**
|
|
34
|
-
* The
|
|
35
|
-
* `
|
|
55
|
+
* The trust digest: lower-case hex SHA-256 of the UTF-8 bytes of
|
|
56
|
+
* `"mcp-abap-adt-binding/2/trust\n"` and the JSON of the `[name, value]` pairs
|
|
57
|
+
* in the row's fixed order — no trimming, no canonicalisation. JSON of arrays
|
|
58
|
+
* and primitives has one output (lone surrogates escaped), so equal inputs
|
|
59
|
+
* give equal bytes.
|
|
36
60
|
*/
|
|
37
|
-
export declare function
|
|
38
|
-
/**
|
|
39
|
-
export declare function acsUri(acsUrl: unknown): string | undefined;
|
|
40
|
-
/** How a stored `issuedBy` is read: as an issuer with its client, or as an ACS. */
|
|
41
|
-
export type IssuerKind = 'issuer' | 'acs';
|
|
42
|
-
/** What this destination's means bind a secret to, canonical; absent where they cannot say. */
|
|
61
|
+
export declare function trustDigest(pairs: readonly (readonly [string, unknown])[]): string;
|
|
62
|
+
/** What this destination's means bind a secret to. */
|
|
43
63
|
export interface Binding {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
|
|
64
|
+
/** The canonical resource; absent when the means state none. */
|
|
65
|
+
issuedFor?: string | undefined;
|
|
66
|
+
/** The record: always present — at least the row. */
|
|
67
|
+
issuedBy: string;
|
|
68
|
+
/**
|
|
69
|
+
* The record holds the client the row authenticates and every server
|
|
70
|
+
* address its provider sends a credential to. Only such a
|
|
71
|
+
* binding is seeded from a stored session, or carries its refresh token.
|
|
72
|
+
*/
|
|
73
|
+
fullyStated: boolean;
|
|
48
74
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
75
|
+
* Set on the `clientAuthentication` strategy path only: a resource neither
|
|
76
|
+
* side states — no `issuedFor` computed and none stored — matches, so the
|
|
77
|
+
* record alone decides. A resource stated on one side only never matches.
|
|
52
78
|
*/
|
|
53
|
-
|
|
79
|
+
unstatedResourceMatches?: true;
|
|
54
80
|
}
|
|
55
81
|
/**
|
|
56
|
-
* The
|
|
57
|
-
* `
|
|
82
|
+
* The canonical resource URI, as 4.x wrote it: scheme and host lower-cased
|
|
83
|
+
* (by `URL`, for http and https); the port explicit (`443` / `80` by
|
|
84
|
+
* default); the path without a trailing `/`, its case kept; one query
|
|
85
|
+
* parameter, `sap-client=<n>` — `sapClient` when given, else the one the URL
|
|
86
|
+
* carries — re-encoded with `URLSearchParams`; no user info, no other
|
|
87
|
+
* parameter, no fragment. A URL that does not parse, or has no host, has no
|
|
88
|
+
* canonical form: `undefined`, never guessed. For a stored value, call it
|
|
89
|
+
* without `sapClient`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function resourceUri(serviceUrl: unknown, sapClient?: string): string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The UAA grants (`authorization_code`, `client_credentials`, `passcode`):
|
|
94
|
+
* the client id and `uaaUrl` as the provider receives them, and `certUrl`
|
|
95
|
+
* when the build read the certificate client; trust is the client
|
|
96
|
+
* certificate. Fully stated with the client, `uaaUrl` and — when read —
|
|
97
|
+
* `certUrl`.
|
|
58
98
|
*/
|
|
59
|
-
export declare function uaaBinding(means: IConnectionConfig, client:
|
|
99
|
+
export declare function uaaBinding(grant: string, means: IConnectionConfig, client: BoundClient | null, certificate: BoundCertificate | null): Binding;
|
|
60
100
|
/**
|
|
61
|
-
* The OIDC grants: the
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
101
|
+
* The OIDC grants: the client id, `oidcIssuerUrl`, `oidcTokenEndpoint`, and
|
|
102
|
+
* the grant's own endpoint (`oidcAuthorizationEndpoint`,
|
|
103
|
+
* `oidcDeviceAuthorizationEndpoint`) or audience (`oidcAudience`), and
|
|
104
|
+
* `certUrl` when read; trust is the scopes, the `password` grant's
|
|
105
|
+
* `username`, the token-exchange token types, and the client certificate.
|
|
106
|
+
*
|
|
107
|
+
* Fully stated with the client, each endpoint the grant sends to — explicit,
|
|
108
|
+
* or the issuer it is discovered from — and `certUrl` when read;
|
|
109
|
+
* `token_exchange` never: its subject token, a secret, decides whose
|
|
110
|
+
* credential it obtains.
|
|
65
111
|
*/
|
|
66
|
-
export declare function oidcBinding(means: IConnectionConfig, client:
|
|
112
|
+
export declare function oidcBinding(grant: string, means: IConnectionConfig, client: BoundClient | null, certificate: BoundCertificate | null): Binding;
|
|
67
113
|
/**
|
|
68
|
-
* `saml2_pure`: the
|
|
69
|
-
* cookies
|
|
114
|
+
* `saml2_pure`: the IdP's SSO URL and the ACS of the system that sets the
|
|
115
|
+
* cookies; trust is the SAML trust. Fully stated with both.
|
|
70
116
|
*/
|
|
71
117
|
export declare function samlPureBinding(means: IConnectionConfig): Binding;
|
|
72
118
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
|
|
119
|
+
* `saml2_bearer`: the client id, `uaaUrl`, the IdP's SSO URL, the ACS,
|
|
120
|
+
* `samlTokenUrl`, and `certUrl` when read; trust is the SAML trust and the
|
|
121
|
+
* client certificate. Fully stated with the client, the IdP, the token
|
|
122
|
+
* endpoint (`samlTokenUrl`, or `uaaUrl`) and — when read — `certUrl`.
|
|
123
|
+
*/
|
|
124
|
+
export declare function samlBearerBinding(means: IConnectionConfig, client: BoundClient | null, certificate: BoundCertificate | null): Binding;
|
|
125
|
+
/**
|
|
126
|
+
* A `none` row: the resource, and the record — for `jwt` the client id,
|
|
127
|
+
* `uaaUrl` and `oidcIssuerUrl` as the means state them, for `saml` the ACS;
|
|
128
|
+
* no trust. A handed-over credential is compared by exact equality of the
|
|
129
|
+
* whole record; it is never seeded into a renewal, so it is not
|
|
130
|
+
* "fully stated".
|
|
131
|
+
*/
|
|
132
|
+
export declare function handedOverBinding(authType: 'jwt' | 'saml', means: IConnectionConfig, client: BoundClient | null): Binding;
|
|
133
|
+
/**
|
|
134
|
+
* The token API with a consumer's provider: the `serviceUrl` it resolved,
|
|
135
|
+
* with the SAP client, and the record `provider/<row>` — for a factory the
|
|
136
|
+
* client id and `uaaUrl` of the client it was handed, for an instance (handed
|
|
137
|
+
* no client) none; no trust. Never fully stated: the broker cannot know what
|
|
138
|
+
* the factory composes, and an instance is handed no client.
|
|
139
|
+
*/
|
|
140
|
+
export declare function consumerBinding(row: string, serviceUrl: string, sapClient: string | undefined, client: BoundClient | null): Binding;
|
|
141
|
+
/**
|
|
142
|
+
* A binding on the `clientAuthentication` strategy path: a resource that
|
|
143
|
+
* neither the means nor the stored session state matches
|
|
144
|
+
* (`Binding.unstatedResourceMatches`).
|
|
78
145
|
*/
|
|
79
|
-
export declare function
|
|
146
|
+
export declare function strategyBinding(binding: Binding): Binding;
|
|
80
147
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* and `uaaClientId`) for `jwt`, `samlAcsUrl` for `saml`.
|
|
148
|
+
* The stored `issuedFor`, canonicalised, equals the destination's — or, with
|
|
149
|
+
* `unstatedResourceMatches`, neither states one.
|
|
84
150
|
*/
|
|
85
|
-
export declare function handedOverBinding(authType: 'jwt' | 'saml', means: IConnectionConfig, client: IAuthorizationConfig | null): Binding;
|
|
86
|
-
/** The stored `issuedFor`, canonicalised, equals the destination's. */
|
|
87
151
|
export declare function sameResource(stored: IConfig | null, binding: Binding): boolean;
|
|
88
|
-
/** The stored `issuedBy
|
|
89
|
-
export declare function
|
|
152
|
+
/** The stored `issuedBy` is exactly this binding's record. */
|
|
153
|
+
export declare function sameRecord(stored: IConfig | null, binding: Binding): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Whether any stored secret could ever seed this binding's provider: the
|
|
156
|
+
* binding is fully stated and its resource can match — stated, or matching
|
|
157
|
+
* when neither side states one (`unstatedResourceMatches`). The condition
|
|
158
|
+
* `boundHere` needs beside the stored values.
|
|
159
|
+
*/
|
|
160
|
+
export declare function couldBeSeeded(binding: Binding): boolean;
|
|
90
161
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
162
|
+
* A stored secret may seed this binding's provider — or have its refresh
|
|
163
|
+
* token carried — only when the binding is fully stated, the resource
|
|
164
|
+
* matches, and the stored `issuedBy` is exactly the record. A session with no
|
|
165
|
+
* `issuedBy`, or a 4.x one, never matches.
|
|
93
166
|
*/
|
|
94
167
|
export declare function boundHere(stored: IConfig | null, binding: Binding): boolean;
|
|
95
168
|
//# sourceMappingURL=binding.d.ts.map
|
package/dist/binding.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EAClB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,aAAa,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAQD,qEAAqE;AACrE,eAAO,MAAM,aAAa,iNAYhB,CAAC;AAEX,0EAA0E;AAC1E,MAAM,MAAM,YAAY,GAAG,OAAO,CAChC,MAAM,CAAC,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAChD,CAAC;AA0CF;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,GACZ,MAAM,CAQR;AA2BD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,GAC7C,MAAM,CAOR;AAED,sDAAsD;AACtD,MAAM,WAAW,OAAO;IACtB,gEAAgE;IAChE,SA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