@oauth2-cli/qui-cli 0.7.15 → 1.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 +24 -15
- package/README.md +33 -4
- package/dist/Client.d.ts +12 -2
- package/dist/Client.js +31 -21
- package/dist/OAuth2.d.ts +40 -0
- package/dist/OAuth2.js +41 -0
- package/dist/OAuth2Plugin.d.ts +96 -14
- package/dist/OAuth2Plugin.js +116 -42
- package/dist/Token/EnvironmentStorage.d.ts +14 -0
- package/dist/Token/EnvironmentStorage.js +14 -0
- package/dist/{Unregistered.d.ts → extendable.d.ts} +1 -1
- package/dist/{Unregistered.js → extendable.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/extendable/Client.d.ts +24 -0
- package/extendable/Client.js +71 -0
- package/extendable/OAuth2Plugin.d.ts +154 -0
- package/extendable/OAuth2Plugin.js +288 -0
- package/extendable/Token/EnvironmentStorage.d.ts +21 -0
- package/extendable/Token/EnvironmentStorage.js +27 -0
- package/extendable/Token/index.d.ts +2 -0
- package/extendable/Token/index.js +2 -0
- package/extendable/extendable.d.ts +4 -0
- package/extendable/extendable.js +4 -0
- package/extendable/index.d.ts +1 -0
- package/extendable/index.js +1 -0
- package/extendable/package.json +5 -0
- package/package.extendable.json +5 -0
- package/package.json +11 -6
- package/tsconfig.extendable.json +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,27 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
## [0.
|
|
5
|
+
## [1.0.0](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.7.16...qui-cli-plugin/1.0.0) (2026-02-20)
|
|
6
6
|
|
|
7
|
+
### ⚠ BREAKING CHANGES
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
- dist/Unregistered.js -> extendable
|
|
10
|
+
- rename WebServer -> Localhost, authorize.ejs -> launch.ejs
|
|
11
|
+
- simplify access to client name by making it (only) a read-only property
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
### Features
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
- dist/Unregistered.js -> extendable ([1734d05](https://github.com/battis/oauth2-cli/commit/1734d05845e2b5960a6636d591605973df38b696))
|
|
16
|
+
- human-readable reason for authorizing access ([0cce8c2](https://github.com/battis/oauth2-cli/commit/0cce8c2e13213e92befc4f58c81e6d7f9637ea63))
|
|
17
|
+
- rename WebServer -> Localhost, authorize.ejs -> launch.ejs ([09723a8](https://github.com/battis/oauth2-cli/commit/09723a81640cb8ad0e767584a81b9b56f5a617b2))
|
|
18
|
+
- simplify access to client name by making it (only) a read-only property ([401c870](https://github.com/battis/oauth2-cli/commit/401c870071c0e9ffc65282e8c42270dff6e897a2))
|
|
13
19
|
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- improve client debug logging ([f53575d](https://github.com/battis/oauth2-cli/commit/f53575d855665a868f8a803ff3fb197faff9543d))
|
|
23
|
+
|
|
24
|
+
## [0.7.16](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.7.15...qui-cli-plugin/0.7.16) (2026-02-19)
|
|
14
25
|
|
|
15
26
|
### Bug Fixes
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
- removing potential source of authorization failure ([15d7d89](https://github.com/battis/oauth2-cli/commit/15d7d8980337df3f66afa8398b3cccb1fc6b56b6))
|
|
18
29
|
|
|
19
|
-
## [0.7.
|
|
30
|
+
## [0.7.15](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.7.14...qui-cli-plugin/0.7.15) (2026-02-19)
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
- further debugging log refinement ([26bad46](https://github.com/battis/oauth2-cli/commit/26bad46741fc0b2075099054e7127e90a1a4a002))
|
|
35
|
+
|
|
36
|
+
## [0.7.14](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.7.13...qui-cli-plugin/0.7.14) (2026-02-19)
|
|
22
37
|
|
|
23
|
-
|
|
38
|
+
### Bug Fixes
|
|
24
39
|
|
|
25
|
-
|
|
40
|
+
- further refinement in debug logging ([568e563](https://github.com/battis/oauth2-cli/commit/568e563bc0a918cd9741951654db685488f10330))
|
|
26
41
|
|
|
27
42
|
## [0.7.7](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.7.6...qui-cli-plugin/0.7.7) (2026-02-19)
|
|
28
43
|
|
|
@@ -42,12 +57,6 @@ Incorporates oauth2-cli@0.8.5 updates
|
|
|
42
57
|
|
|
43
58
|
- improved debugging output ([a0e6cea](https://github.com/battis/oauth2-cli/commit/a0e6ceaf12dadd9b2bf1753c602165f7194cbf24))
|
|
44
59
|
|
|
45
|
-
## [0.7.4](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.7.3...qui-cli-plugin/0.7.4) (2026-02-18)
|
|
46
|
-
|
|
47
|
-
## [0.7.3](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.7.2...qui-cli-plugin/0.7.3) (2026-02-18)
|
|
48
|
-
|
|
49
|
-
Incorporate fixes from oauth2-cli@0.8.2
|
|
50
|
-
|
|
51
60
|
## [0.7.2](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.7.1...qui-cli-plugin/0.7.2) (2026-02-18)
|
|
52
61
|
|
|
53
62
|
### Features
|
package/README.md
CHANGED
|
@@ -19,16 +19,45 @@ npm install @qui-cli/core @oauth2-cli/qui-cli
|
|
|
19
19
|
import { OAuth2 } from '@oauth2-cli/qui-cli';
|
|
20
20
|
import { Core } from '@qui-cli/core';
|
|
21
21
|
|
|
22
|
-
//
|
|
22
|
+
// configure a client name and a reason for authorizing access (recommended)
|
|
23
|
+
OAuth2.configure({
|
|
24
|
+
name: 'Example',
|
|
25
|
+
reason: 'the README example'
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// initialize the `qui-cli` framework, loading credentials from the environment
|
|
23
29
|
await Core.run();
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
31
|
+
// request an endpoint, triggering interactive authorization if necessary
|
|
32
|
+
console.log(await OAuth2.requestJSON('https://example.com/api/endpoint'));
|
|
28
33
|
```
|
|
29
34
|
|
|
30
35
|
Without additional configuration, `OAuth2` will look for `ISSUER`, `CLIENT_ID`, `CLIENT_SECRET`, `REDIRECT_URI`, `AUTHORIZATION_ENDPOINT`, and `TOKEN_ENDPOINT` values in the environment and will attempt to configure the client using whichever subset of those values are present.
|
|
31
36
|
|
|
37
|
+
#### `name` and `reason`
|
|
38
|
+
|
|
39
|
+
It is strongly recommended that you provide a human-readable `name` for the client that will be used in user messages explaining _what_ is being accessed (e.g. the name of the API or service) and a human-readable `reason` for the user to provide this access (e.g. the name of your app or script). Messages are structured in the manner:
|
|
40
|
+
|
|
41
|
+
> ...to authorize access to `name` for `reason`, do this...
|
|
42
|
+
|
|
43
|
+
## Extending `OAuth2Plugin`
|
|
44
|
+
|
|
45
|
+
The default export of the package includes an instance of `OAuth2` which is self-registered within the [qui-cli](https://github.com/battis/qui-cli#readme) framework. This is convenient and normal, to facilitate rapidly agglomerating CLI apps out a a collection of plugins.
|
|
46
|
+
|
|
47
|
+
But if you are creating a custom extension of the plugin to pre-configure it to connect to a particular service, you may want to avoid that self-registration by importing from the `extendable` namespace:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { OAuth2Plugin } from '@oauth2-cli/qui-cli/extendable';
|
|
51
|
+
|
|
52
|
+
export class MyService extends OAuth2Plugin {
|
|
53
|
+
// ...
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
A detailed example of this strategy is found in the examples (see below): [api-plugin](https://github.com/battis/oauth2-cli/tree/main/examples/qui-cli/06%20api-plugin#readme).
|
|
58
|
+
|
|
59
|
+
## Examples
|
|
60
|
+
|
|
32
61
|
Refer to [`oauth2-cli`](https://www.npmjs.com/package/oauth2-cli) for more information about configuring that tool in more nuanced ways.
|
|
33
62
|
|
|
34
63
|
Refer to [`qui-cli`](https://github.com/battis/qui-cli#readme) for more information about using those tools to build command line apps.
|
package/dist/Client.d.ts
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { JSONValue } from '@battis/typescript-tricks';
|
|
2
2
|
import { Request } from 'express';
|
|
3
3
|
import * as OAuth2CLI from 'oauth2-cli';
|
|
4
|
-
import { Session } from 'oauth2-cli/dist/Session.js';
|
|
5
4
|
import type * as OpenIDClient from 'openid-client';
|
|
6
5
|
import * as requestish from 'requestish';
|
|
6
|
+
/**
|
|
7
|
+
* Wrap {@link https://www.npmjs.com/package/openid-client openid-client} in a
|
|
8
|
+
* class instance specific to a particular OAuth/OpenID server credential-set,
|
|
9
|
+
* abstracting away most flows into {@link getToken}
|
|
10
|
+
*
|
|
11
|
+
* Emits {@link Client.TokenEvent} whenever a new access token is received
|
|
12
|
+
*
|
|
13
|
+
* Provides optional debug logging output using
|
|
14
|
+
* {@link https://www.npmjs.com/package/@qui-cli/env @qui-cli/env}
|
|
15
|
+
*/
|
|
7
16
|
export declare class Client<C extends OAuth2CLI.Credentials = OAuth2CLI.Credentials> extends OAuth2CLI.Client<C> {
|
|
8
17
|
getConfiguration(): Promise<OpenIDClient.Configuration>;
|
|
9
18
|
authorize(): Promise<OAuth2CLI.Token.Response>;
|
|
10
|
-
handleAuthorizationCodeRedirect(request: Request, session:
|
|
19
|
+
handleAuthorizationCodeRedirect(request: Request, session: OAuth2CLI.Localhost.Server): Promise<OAuth2CLI.Token.Response>;
|
|
11
20
|
protected refreshTokenGrant(token: OAuth2CLI.Token.Response): Promise<OAuth2CLI.Token.Response | undefined>;
|
|
21
|
+
protected save(response: OAuth2CLI.Token.Response): Promise<OAuth2CLI.Token.Response>;
|
|
12
22
|
request(url: requestish.URL.ish, method?: string, body?: OpenIDClient.FetchBody, headers?: requestish.Headers.ish, dPoPOptions?: OpenIDClient.DPoPOptions): Promise<Response>;
|
|
13
23
|
requestJSON<J extends JSONValue = JSONValue>(url: requestish.URL.ish, method?: string, body?: OpenIDClient.FetchBody, headers?: requestish.Headers.ish, dPoPOptions?: OpenIDClient.DPoPOptions): Promise<J>;
|
|
14
24
|
}
|
package/dist/Client.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { Log } from '@qui-cli/log';
|
|
2
2
|
import * as OAuth2CLI from 'oauth2-cli';
|
|
3
|
+
/**
|
|
4
|
+
* Wrap {@link https://www.npmjs.com/package/openid-client openid-client} in a
|
|
5
|
+
* class instance specific to a particular OAuth/OpenID server credential-set,
|
|
6
|
+
* abstracting away most flows into {@link getToken}
|
|
7
|
+
*
|
|
8
|
+
* Emits {@link Client.TokenEvent} whenever a new access token is received
|
|
9
|
+
*
|
|
10
|
+
* Provides optional debug logging output using
|
|
11
|
+
* {@link https://www.npmjs.com/package/@qui-cli/env @qui-cli/env}
|
|
12
|
+
*/
|
|
3
13
|
export class Client extends OAuth2CLI.Client {
|
|
4
14
|
async getConfiguration() {
|
|
5
15
|
const creating = !this.config;
|
|
6
16
|
const config = await super.getConfiguration();
|
|
7
17
|
if (creating) {
|
|
8
|
-
Log.debug(`${this.
|
|
18
|
+
Log.debug(`${this.name} OAuth 2.0 configuration created`, {
|
|
9
19
|
credentials: this.credentials,
|
|
10
20
|
config: {
|
|
11
21
|
serverMetadata: config.serverMetadata(),
|
|
@@ -16,46 +26,46 @@ export class Client extends OAuth2CLI.Client {
|
|
|
16
26
|
return config;
|
|
17
27
|
}
|
|
18
28
|
async authorize() {
|
|
19
|
-
Log.debug(`Authorizing ${this.
|
|
29
|
+
Log.debug(`Authorizing ${this.name} new access token`);
|
|
20
30
|
const response = await super.authorize();
|
|
21
|
-
Log.debug(`Authorized ${this.
|
|
31
|
+
Log.debug(`Authorized ${this.name} new access token`, { response });
|
|
22
32
|
return response;
|
|
23
33
|
}
|
|
24
34
|
async handleAuthorizationCodeRedirect(request, session) {
|
|
25
|
-
Log.debug(`Handling ${this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
headers: request.headers,
|
|
30
|
-
body: request.body
|
|
31
|
-
},
|
|
32
|
-
session: {
|
|
33
|
-
code_verifier: session.code_verifier,
|
|
34
|
-
state: session.state,
|
|
35
|
-
inject: session.inject
|
|
36
|
-
}
|
|
35
|
+
Log.debug(`Handling ${this.name} authorization code redirect`, { request });
|
|
36
|
+
const response = await super.handleAuthorizationCodeRedirect(request, session);
|
|
37
|
+
Log.debug(`Received ${this.name} authorization code response`, {
|
|
38
|
+
response
|
|
37
39
|
});
|
|
38
|
-
return
|
|
40
|
+
return response;
|
|
39
41
|
}
|
|
40
42
|
async refreshTokenGrant(token) {
|
|
41
|
-
Log.debug(`Refreshing expired ${this.
|
|
43
|
+
Log.debug(`Refreshing expired ${this.name} access token`, {
|
|
42
44
|
token
|
|
43
45
|
});
|
|
44
46
|
const refreshed = await super.refreshTokenGrant(token);
|
|
45
|
-
Log.debug(`Received refreshed ${this.
|
|
47
|
+
Log.debug(`Received refreshed ${this.name} access token`, {
|
|
46
48
|
token: refreshed
|
|
47
49
|
});
|
|
48
50
|
return refreshed;
|
|
49
51
|
}
|
|
52
|
+
async save(response) {
|
|
53
|
+
Log.debug(`Persisting ${this.name} refresh token, if present and storage configured`, {
|
|
54
|
+
response
|
|
55
|
+
});
|
|
56
|
+
return await super.save(response);
|
|
57
|
+
}
|
|
50
58
|
async request(url, method, body, headers, dPoPOptions) {
|
|
51
|
-
Log.debug(
|
|
59
|
+
Log.debug(`Sending request to ${this.name}`, {
|
|
60
|
+
request: { method, url, headers, body, dPoPOptions }
|
|
61
|
+
});
|
|
52
62
|
const response = await super.request(url, method, body, headers, dPoPOptions);
|
|
53
|
-
Log.debug({ response });
|
|
63
|
+
Log.debug(`Received response from ${this.name}`, { response });
|
|
54
64
|
return response;
|
|
55
65
|
}
|
|
56
66
|
async requestJSON(url, method, body, headers, dPoPOptions) {
|
|
57
67
|
const json = await super.requestJSON(url, method, body, headers, dPoPOptions);
|
|
58
|
-
Log.debug({ json });
|
|
68
|
+
Log.debug(`Parsed JSON from ${this.name} response`, { json });
|
|
59
69
|
return json;
|
|
60
70
|
}
|
|
61
71
|
}
|
package/dist/OAuth2.d.ts
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience method
|
|
3
|
+
*
|
|
4
|
+
* @see {@link OAuth2Plugin.configure}
|
|
5
|
+
*/
|
|
1
6
|
export declare const configure: (proposal?: import("./OAuth2Plugin.js").Configuration<import("oauth2-cli").Credentials>) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Convenience method
|
|
9
|
+
*
|
|
10
|
+
* @see {@link OAuth2Plugin.options}
|
|
11
|
+
*/
|
|
2
12
|
export declare const options: () => import("@qui-cli/plugin").Options;
|
|
13
|
+
/**
|
|
14
|
+
* Convenience method
|
|
15
|
+
*
|
|
16
|
+
* @see {@link OAuth2Plugin.init}
|
|
17
|
+
*/
|
|
3
18
|
export declare const init: () => import("@qui-cli/plugin").Options;
|
|
19
|
+
/**
|
|
20
|
+
* Convenience method
|
|
21
|
+
*
|
|
22
|
+
* @see {@link OAuth2Plugin.client}
|
|
23
|
+
*/
|
|
4
24
|
export declare const client: () => import("./Client.js").Client<import("oauth2-cli").Credentials>;
|
|
25
|
+
/**
|
|
26
|
+
* Convenience method
|
|
27
|
+
*
|
|
28
|
+
* @see {@link OAuth2Plugin.request}
|
|
29
|
+
*/
|
|
5
30
|
export declare const request: (url: import("requestish/dist/URL.js").ish, method?: string | undefined, body?: import("openid-client").FetchBody, headers?: import("requestish/dist/Headers.js").ish | undefined, dPoPOptions?: import("openid-client").DPoPOptions | undefined) => Promise<Response>;
|
|
31
|
+
/**
|
|
32
|
+
* Convenience method
|
|
33
|
+
*
|
|
34
|
+
* @see {@link OAuth2Plugin.requestJSON}
|
|
35
|
+
*/
|
|
6
36
|
export declare const requestJSON: <T extends import("@battis/typescript-tricks").JSONValue>(url: import("requestish/dist/URL.js").ish, method?: string | undefined, body?: import("openid-client").FetchBody, headers?: import("requestish/dist/Headers.js").ish | undefined, dPoPOptions?: import("openid-client").DPoPOptions | undefined) => Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Convenience method
|
|
39
|
+
*
|
|
40
|
+
* @see {@link OAuth2Plugin.fetch}
|
|
41
|
+
*/
|
|
7
42
|
export declare const fetch: (input: import("requestish/dist/URL.js").ish, init?: RequestInit | undefined, dPoPOptions?: import("openid-client").DPoPOptions | undefined) => Promise<Response>;
|
|
43
|
+
/**
|
|
44
|
+
* Conveneince method
|
|
45
|
+
*
|
|
46
|
+
* @see {@link OAuth2Plugin.fetchJSON}
|
|
47
|
+
*/
|
|
8
48
|
export declare const fetchJSON: <T extends import("@battis/typescript-tricks").JSONValue>(input: import("requestish/dist/URL.js").ish, init?: RequestInit | undefined, dPoPOptions?: import("openid-client").DPoPOptions | undefined) => Promise<T>;
|
package/dist/OAuth2.js
CHANGED
|
@@ -1,14 +1,55 @@
|
|
|
1
1
|
import { register } from '@qui-cli/plugin';
|
|
2
2
|
import { OAuth2Plugin } from './OAuth2Plugin.js';
|
|
3
|
+
/** Auto-registered @oauth2-clu/qui-cli plugin */
|
|
3
4
|
const plugin = new OAuth2Plugin();
|
|
4
5
|
// @qui-cli/plugin convenience methods
|
|
6
|
+
/**
|
|
7
|
+
* Convenience method
|
|
8
|
+
*
|
|
9
|
+
* @see {@link OAuth2Plugin.configure}
|
|
10
|
+
*/
|
|
5
11
|
export const configure = plugin.configure.bind(plugin);
|
|
12
|
+
/**
|
|
13
|
+
* Convenience method
|
|
14
|
+
*
|
|
15
|
+
* @see {@link OAuth2Plugin.options}
|
|
16
|
+
*/
|
|
6
17
|
export const options = plugin.options.bind(plugin);
|
|
18
|
+
/**
|
|
19
|
+
* Convenience method
|
|
20
|
+
*
|
|
21
|
+
* @see {@link OAuth2Plugin.init}
|
|
22
|
+
*/
|
|
7
23
|
export const init = plugin.options.bind(plugin);
|
|
8
24
|
// oauth2-cli convenience methods
|
|
25
|
+
/**
|
|
26
|
+
* Convenience method
|
|
27
|
+
*
|
|
28
|
+
* @see {@link OAuth2Plugin.client}
|
|
29
|
+
*/
|
|
9
30
|
export const client = () => plugin.client;
|
|
31
|
+
/**
|
|
32
|
+
* Convenience method
|
|
33
|
+
*
|
|
34
|
+
* @see {@link OAuth2Plugin.request}
|
|
35
|
+
*/
|
|
10
36
|
export const request = plugin.request.bind(plugin);
|
|
37
|
+
/**
|
|
38
|
+
* Convenience method
|
|
39
|
+
*
|
|
40
|
+
* @see {@link OAuth2Plugin.requestJSON}
|
|
41
|
+
*/
|
|
11
42
|
export const requestJSON = plugin.requestJSON.bind(plugin);
|
|
43
|
+
/**
|
|
44
|
+
* Convenience method
|
|
45
|
+
*
|
|
46
|
+
* @see {@link OAuth2Plugin.fetch}
|
|
47
|
+
*/
|
|
12
48
|
export const fetch = plugin.fetch.bind(plugin);
|
|
49
|
+
/**
|
|
50
|
+
* Conveneince method
|
|
51
|
+
*
|
|
52
|
+
* @see {@link OAuth2Plugin.fetchJSON}
|
|
53
|
+
*/
|
|
13
54
|
export const fetchJSON = plugin.fetchJSON.bind(plugin);
|
|
14
55
|
await register(plugin);
|
package/dist/OAuth2Plugin.d.ts
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { URLString } from '@battis/descriptive-types';
|
|
2
2
|
import { JSONValue } from '@battis/typescript-tricks';
|
|
3
3
|
import * as Plugin from '@qui-cli/plugin';
|
|
4
4
|
import * as OAuth2CLI from 'oauth2-cli';
|
|
5
|
-
import
|
|
5
|
+
import { URL } from 'requestish';
|
|
6
6
|
import { Client } from './Client.js';
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
|
|
7
|
+
/** Key for value to be read from the local environment */
|
|
8
|
+
type EnvironmentKey = 'issuer' | 'client_id' | 'client_secret' | 'redirect_uri' | 'authorization_endpoint' | 'token_endpoint' | 'scope' | 'base_url';
|
|
9
|
+
/** Names of environment variables */
|
|
10
|
+
type EnvironmentVars = Record<EnvironmentKey, string>;
|
|
11
|
+
/** Reference URLs for environment variables */
|
|
12
|
+
type SupportUrls = Record<EnvironmentKey, URLString>;
|
|
13
|
+
/** Hint values for environment variables */
|
|
14
|
+
type Hints = Record<EnvironmentKey, string>;
|
|
15
|
+
/** Environment variables to ignore and supporess in usage documentation */
|
|
16
|
+
type EnvVarSuppression = Record<EnvironmentKey, boolean>;
|
|
17
|
+
/** Custom usage information to present to user */
|
|
12
18
|
type Usage = {
|
|
13
19
|
heading: string;
|
|
14
20
|
text?: string[];
|
|
15
21
|
};
|
|
22
|
+
/** Plugin configuration */
|
|
16
23
|
export type Configuration<C extends OAuth2CLI.Credentials = OAuth2CLI.Credentials> = Plugin.Configuration & {
|
|
17
|
-
/** Human-readable name for client in messages. */
|
|
24
|
+
/** Human-readable name for client in messages (e.g. the name of the API) */
|
|
18
25
|
name?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Human-readable for authorizing access in messages (e.g. the name of the
|
|
28
|
+
* app)
|
|
29
|
+
*/
|
|
30
|
+
reason?: string;
|
|
19
31
|
/** OAuth 2.0/OpenID Connect credential set */
|
|
20
32
|
credentials?: Partial<C>;
|
|
21
33
|
/** Base URL for all non-absolute requests */
|
|
22
|
-
base_url?:
|
|
34
|
+
base_url?: URL.ish;
|
|
23
35
|
/** Request components to inject into server requests */
|
|
24
36
|
inject?: OAuth2CLI.Injection;
|
|
25
37
|
/** Refresh token storage service */
|
|
@@ -34,8 +46,7 @@ export type Configuration<C extends OAuth2CLI.Credentials = OAuth2CLI.Credential
|
|
|
34
46
|
env?: Partial<EnvironmentVars>;
|
|
35
47
|
/** Should a particular credential value _not_ be loaded from the environment? */
|
|
36
48
|
suppress?: Partial<EnvVarSuppression>;
|
|
37
|
-
|
|
38
|
-
views?: PathString;
|
|
49
|
+
localhost?: OAuth2CLI.Options['localhost'];
|
|
39
50
|
};
|
|
40
51
|
export declare class OAuth2Plugin<C extends OAuth2CLI.Credentials = OAuth2CLI.Credentials, L extends Client<C> = Client<C>> {
|
|
41
52
|
readonly name: string;
|
|
@@ -43,30 +54,101 @@ export declare class OAuth2Plugin<C extends OAuth2CLI.Credentials = OAuth2CLI.Cr
|
|
|
43
54
|
private static names;
|
|
44
55
|
private static registeredPorts;
|
|
45
56
|
private overrideName?;
|
|
57
|
+
private reason?;
|
|
46
58
|
/**
|
|
47
59
|
* @param name Human-readable name for client in messages. Must also be a
|
|
48
60
|
* unique qui-cli plugin name.
|
|
49
61
|
*/
|
|
50
62
|
constructor(name?: string);
|
|
63
|
+
/** Configured client credentials */
|
|
51
64
|
private credentials?;
|
|
65
|
+
/** Configured client base_url */
|
|
52
66
|
private base_url?;
|
|
67
|
+
/** Configured usage information */
|
|
53
68
|
private man;
|
|
69
|
+
/** Configured reference URLs for credentials */
|
|
54
70
|
private url?;
|
|
71
|
+
/** Configured hint values for credentials */
|
|
55
72
|
private hint;
|
|
73
|
+
/** Configured environment variable names for credentials */
|
|
56
74
|
private env;
|
|
75
|
+
/** Configured credentials to suppress in usage and init */
|
|
57
76
|
private suppress?;
|
|
77
|
+
/** Configured request components for client to inject */
|
|
58
78
|
private inject?;
|
|
59
|
-
|
|
79
|
+
/** Configured {@link OAuth2CLI.Localhost.Options} to pass to client */
|
|
80
|
+
private localhost?;
|
|
81
|
+
/** Configured client refresh token storage strategy */
|
|
60
82
|
private storage?;
|
|
61
83
|
private _client?;
|
|
84
|
+
/**
|
|
85
|
+
* Configured oauth2-cli client
|
|
86
|
+
*
|
|
87
|
+
* Do _not_ access until intitialization is complete -- the client will be
|
|
88
|
+
* configured upon first access based on available configuration known at that
|
|
89
|
+
* time
|
|
90
|
+
*/
|
|
91
|
+
get client(): L;
|
|
92
|
+
/**
|
|
93
|
+
* Configure plugin for use
|
|
94
|
+
*
|
|
95
|
+
* May be called repeatedly, overlaying different options as they become
|
|
96
|
+
* available
|
|
97
|
+
*
|
|
98
|
+
* Invoked automatically by
|
|
99
|
+
* {@link https://github.com/battis/qui-cli#readme qui-cli} during
|
|
100
|
+
* initialization
|
|
101
|
+
*
|
|
102
|
+
* @see {@link Configuration}
|
|
103
|
+
*/
|
|
62
104
|
configure(proposal?: Configuration<C>): void;
|
|
105
|
+
/**
|
|
106
|
+
* Provide usage options to
|
|
107
|
+
* {@link https://github.com/battis/qui-cli#readme qui-cli} for display to user
|
|
108
|
+
* on command line
|
|
109
|
+
*
|
|
110
|
+
* Invoked automatically by
|
|
111
|
+
* {@link https://github.com/battis/qui-cli#readme qui-cli} during
|
|
112
|
+
* initialization
|
|
113
|
+
*/
|
|
63
114
|
options(): Plugin.Options;
|
|
115
|
+
/**
|
|
116
|
+
* Intialize plugin configuration from command line options and environment
|
|
117
|
+
*
|
|
118
|
+
* Invoked automatically by
|
|
119
|
+
* {@link https://github.com/battis/qui-cli#readme qui-cli} during
|
|
120
|
+
* initialization
|
|
121
|
+
*/
|
|
64
122
|
init(_: Plugin.ExpectedArguments<typeof this.options>): Promise<void>;
|
|
65
|
-
|
|
66
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Instantiate the `oauth2-cli` client
|
|
125
|
+
*
|
|
126
|
+
* Available hook for custom configurations in plugin development
|
|
127
|
+
*/
|
|
128
|
+
protected instantiateClient(options: OAuth2CLI.Options<C>): L;
|
|
129
|
+
/**
|
|
130
|
+
* Convenience method
|
|
131
|
+
*
|
|
132
|
+
* @see {@link OAuth2CLI.Client.request}
|
|
133
|
+
*/
|
|
67
134
|
request(...args: Parameters<OAuth2CLI.Client<C>['request']>): Promise<Response>;
|
|
135
|
+
/**
|
|
136
|
+
* Convenience method
|
|
137
|
+
*
|
|
138
|
+
* @see {@link OAuth2CLI.Client.requestJSON}
|
|
139
|
+
*/
|
|
68
140
|
requestJSON<T extends JSONValue>(...args: Parameters<OAuth2CLI.Client<C>['requestJSON']>): Promise<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Convenience method
|
|
143
|
+
*
|
|
144
|
+
* @see {@link OAuth2CLI.Client.fetch}
|
|
145
|
+
*/
|
|
69
146
|
fetch(...args: Parameters<OAuth2CLI.Client<C>['fetch']>): Promise<Response>;
|
|
147
|
+
/**
|
|
148
|
+
* Convenience method
|
|
149
|
+
*
|
|
150
|
+
* @see {@link OAuth2CLI.Client.fetchJSON}
|
|
151
|
+
*/
|
|
70
152
|
fetchJSON<T extends JSONValue>(...args: Parameters<OAuth2CLI.Client<C>['fetchJSON']>): Promise<T>;
|
|
71
153
|
}
|
|
72
154
|
export {};
|