@oauth2-cli/qui-cli 0.5.0 → 0.5.2
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 +15 -0
- package/dist/Module.d.ts +3 -2
- package/dist/Module.js +13 -12
- package/dist/OAuth2.d.ts +8 -7
- package/dist/OAuth2.js +28 -10
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
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.2](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.5.1...qui-cli-plugin/0.5.2) (2026-01-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* allow injection of custom oauth2-cli Client implementations via instantiateClient() ([cb1b94f](https://github.com/battis/oauth2-cli/commit/cb1b94fb1891343f00b5793fd6f7db33e6489c14))
|
|
11
|
+
* re-export all of oauth2-cli under the plugin module/class namespaces ([0cbdafc](https://github.com/battis/oauth2-cli/commit/0cbdafc84853f4a904e33640b65e4f0300f00b4a))
|
|
12
|
+
|
|
13
|
+
## [0.5.1](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.5.0...qui-cli-plugin/0.5.1) (2026-01-15)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* implement convenience methods as methods, not properties ([a3f67fe](https://github.com/battis/oauth2-cli/commit/a3f67fecde50ae19d8cf960fe6828623e745126b))
|
|
19
|
+
|
|
5
20
|
## [0.5.0](https://github.com/battis/oauth2-cli/compare/qui-cli-plugin/0.4.3...qui-cli-plugin/0.5.0) (2026-01-14)
|
|
6
21
|
|
|
7
22
|
|
package/dist/Module.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
export * from './EnvironmentStorage.js';
|
|
1
2
|
export * from './OAuth2.js';
|
|
2
3
|
export declare const name: string;
|
|
3
4
|
export declare const configure: (proposal?: import("./OAuth2.js").ConfigurationProposal) => void;
|
|
4
5
|
export declare const options: () => import("@qui-cli/plugin").Options;
|
|
5
6
|
export declare const init: ({ values }: import("@qui-cli/plugin").ExpectedArguments<typeof this.options>) => Promise<void>;
|
|
6
|
-
export declare const getToken: () => Promise<import("oauth2-cli").Token | undefined>;
|
|
7
|
-
export declare const getClient: () => import("oauth2-cli").Client;
|
|
7
|
+
export declare const getToken: () => Promise<import("oauth2-cli/dist/Token.js").Token | undefined>;
|
|
8
|
+
export declare const getClient: () => import("oauth2-cli/dist/Client.js").Client;
|
|
8
9
|
export declare const request: (url: string | URL, method?: string | undefined, body?: import("openid-client").FetchBody, headers?: Headers | undefined, dPoPOptions?: import("openid-client").DPoPOptions | undefined) => Promise<Response>;
|
|
9
10
|
export declare const requestJSON: <T extends import("@battis/typescript-tricks").JSONValue>(url: string | URL, method?: string | undefined, body?: import("openid-client").FetchBody, headers?: Headers | undefined, dPoPOptions?: import("openid-client").DPoPOptions | undefined) => Promise<T>;
|
|
10
11
|
export declare const fetch: (endpoint: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
package/dist/Module.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OAuth2Plugin } from './OAuth2.js';
|
|
2
|
+
export * from './EnvironmentStorage.js';
|
|
2
3
|
export * from './OAuth2.js';
|
|
3
|
-
const
|
|
4
|
-
export const name =
|
|
5
|
-
export const configure =
|
|
6
|
-
export const options =
|
|
7
|
-
export const init =
|
|
8
|
-
export const getToken =
|
|
9
|
-
export const getClient =
|
|
10
|
-
export const request =
|
|
11
|
-
export const requestJSON =
|
|
12
|
-
export const fetch =
|
|
13
|
-
export const fetchJSON =
|
|
4
|
+
const oauth2 = new OAuth2Plugin();
|
|
5
|
+
export const name = oauth2.name;
|
|
6
|
+
export const configure = oauth2.configure.bind(oauth2);
|
|
7
|
+
export const options = oauth2.options.bind(oauth2);
|
|
8
|
+
export const init = oauth2.init.bind(oauth2);
|
|
9
|
+
export const getToken = oauth2.getToken.bind(oauth2);
|
|
10
|
+
export const getClient = oauth2.getClient.bind(oauth2);
|
|
11
|
+
export const request = oauth2.request.bind(oauth2);
|
|
12
|
+
export const requestJSON = oauth2.requestJSON.bind(oauth2);
|
|
13
|
+
export const fetch = oauth2.fetch.bind(oauth2);
|
|
14
|
+
export const fetchJSON = oauth2.fetchJSON.bind(oauth2);
|
package/dist/OAuth2.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PathString, 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
|
-
export
|
|
5
|
+
export * from 'oauth2-cli';
|
|
6
6
|
type ParamNames = 'clientId' | 'clientSecret' | 'redirectUri' | 'authorizationEndpoint' | 'tokenEndpoint' | 'tokenPath' | 'accessToken';
|
|
7
7
|
type EnvironmentVars = Record<ParamNames, string>;
|
|
8
8
|
type SupportUrls = Record<ParamNames, URLString>;
|
|
@@ -34,7 +34,7 @@ export type ConfigurationProposal = Partial<Omit<Configuration, 'opt' | 'env' |
|
|
|
34
34
|
env?: Partial<EnvironmentVars>;
|
|
35
35
|
man?: Partial<Usage>;
|
|
36
36
|
};
|
|
37
|
-
export declare class
|
|
37
|
+
export declare class OAuth2Plugin {
|
|
38
38
|
readonly name: string;
|
|
39
39
|
[key: string]: unknown;
|
|
40
40
|
private static names;
|
|
@@ -45,10 +45,11 @@ export declare class OAuth2 {
|
|
|
45
45
|
configure(proposal?: ConfigurationProposal): void;
|
|
46
46
|
options(): Plugin.Options;
|
|
47
47
|
init({ values }: Plugin.ExpectedArguments<typeof this.options>): Promise<void>;
|
|
48
|
+
protected instantiateClient(...args: ConstructorParameters<typeof OAuth2CLI.Client>): void;
|
|
48
49
|
getClient(): OAuth2CLI.Client;
|
|
49
|
-
getToken
|
|
50
|
-
request
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
fetchJSON
|
|
50
|
+
getToken(): Promise<OAuth2CLI.Token | undefined>;
|
|
51
|
+
request(...args: Parameters<OAuth2CLI.Client['request']>): Promise<Response>;
|
|
52
|
+
requestJSON<T extends JSONValue>(...args: Parameters<OAuth2CLI.Client['requestJSON']>): Promise<T>;
|
|
53
|
+
fetch(...args: Parameters<OAuth2CLI.Client['fetch']>): Promise<Response>;
|
|
54
|
+
fetchJSON<T extends JSONValue>(...args: Parameters<OAuth2CLI.Client['fetchJSON']>): Promise<T>;
|
|
54
55
|
}
|
package/dist/OAuth2.js
CHANGED
|
@@ -5,13 +5,14 @@ import { Root } from '@qui-cli/root';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import * as OAuth2CLI from 'oauth2-cli';
|
|
7
7
|
import { EnvironmentStorage } from './EnvironmentStorage.js';
|
|
8
|
-
export
|
|
8
|
+
export * from 'oauth2-cli';
|
|
9
|
+
export class OAuth2Plugin {
|
|
9
10
|
name;
|
|
10
11
|
static names = [];
|
|
11
12
|
static ports = {};
|
|
12
13
|
constructor(name = '@oauth2-cli/qui-cli') {
|
|
13
14
|
this.name = name;
|
|
14
|
-
if (
|
|
15
|
+
if (OAuth2Plugin.names.includes(name)) {
|
|
15
16
|
throw new Error(`A @qui-cli/plugin named ${Colors.value(name)} has already been instantiated.`);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -69,9 +70,10 @@ export class OAuth2 {
|
|
|
69
70
|
Log.warning(`The ${Colors.url(url.protocol)} protocol may not work without additional configuration. The ` +
|
|
70
71
|
`server listening for the redirect will be running at ${Colors.url(`http://localhost:${url.port}`)}`);
|
|
71
72
|
}
|
|
72
|
-
if (
|
|
73
|
+
if (OAuth2Plugin.ports[url.port] &&
|
|
74
|
+
OAuth2Plugin.ports[url.port] !== this.name) {
|
|
73
75
|
Log.warning(`The port ${Colors.value(url.port)} has already been registered to another instance of this plugin ` +
|
|
74
|
-
`named ${Colors.value(
|
|
76
|
+
`named ${Colors.value(OAuth2Plugin.ports[url.port])}. This will likely cause a failure if both instances of the ` +
|
|
75
77
|
`plugin are listening for redirects at relatively proximate ` +
|
|
76
78
|
`moments in time.`);
|
|
77
79
|
}
|
|
@@ -139,6 +141,9 @@ export class OAuth2 {
|
|
|
139
141
|
}
|
|
140
142
|
this.configure(proposal);
|
|
141
143
|
}
|
|
144
|
+
instantiateClient(...args) {
|
|
145
|
+
this.client = new OAuth2CLI.Client(...args);
|
|
146
|
+
}
|
|
142
147
|
getClient() {
|
|
143
148
|
if (!this.client) {
|
|
144
149
|
const { clientId: client_id, clientSecret: client_secret, redirectUri: redirect_uri, authorizationEndpoint: authorization_endpoint, tokenEndpoint: token_endpoint, headers, store } = this.cliConfig;
|
|
@@ -154,7 +159,7 @@ export class OAuth2 {
|
|
|
154
159
|
if (!authorization_endpoint) {
|
|
155
160
|
throw new Error('OAuth 2.0 authorization endpoint not defined');
|
|
156
161
|
}
|
|
157
|
-
this.
|
|
162
|
+
this.instantiateClient({
|
|
158
163
|
client_id,
|
|
159
164
|
client_secret,
|
|
160
165
|
redirect_uri,
|
|
@@ -164,11 +169,24 @@ export class OAuth2 {
|
|
|
164
169
|
store
|
|
165
170
|
});
|
|
166
171
|
}
|
|
172
|
+
if (!this.client) {
|
|
173
|
+
throw new Error('Failed to instantiate oauth2-cli Client.');
|
|
174
|
+
}
|
|
167
175
|
return this.client;
|
|
168
176
|
}
|
|
169
|
-
getToken
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
getToken() {
|
|
178
|
+
return this.getClient().getToken();
|
|
179
|
+
}
|
|
180
|
+
request(...args) {
|
|
181
|
+
return this.getClient().request(...args);
|
|
182
|
+
}
|
|
183
|
+
requestJSON(...args) {
|
|
184
|
+
return this.getClient().requestJSON(...args);
|
|
185
|
+
}
|
|
186
|
+
fetch(...args) {
|
|
187
|
+
return this.getClient().fetch(...args);
|
|
188
|
+
}
|
|
189
|
+
fetchJSON(...args) {
|
|
190
|
+
return this.getClient().fetchJSON(...args);
|
|
191
|
+
}
|
|
174
192
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oauth2-cli/qui-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "@qui-cli/plugin wrapper for oauth2-cli",
|
|
5
5
|
"homepage": "https://github.com/battis/oauth2-cli/tree/main/packages/qui-cli#readme",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@qui-cli/root": "^3.0.6",
|
|
30
30
|
"@tsconfig/node24": "^24.0.3",
|
|
31
31
|
"commit-and-tag-version": "^12.6.1",
|
|
32
|
-
"del-cli": "^
|
|
32
|
+
"del-cli": "^7.0.0",
|
|
33
33
|
"npm-run-all": "^4.1.5",
|
|
34
34
|
"typescript": "^5.9.3"
|
|
35
35
|
},
|