oauth2-cli 0.7.2 → 0.8.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 CHANGED
@@ -2,108 +2,125 @@
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.7.2](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.7.1...oauth2-cli/0.7.2) (2026-02-16)
5
+ ## [0.8.0](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.7.3...oauth2-cli/0.8.0) (2026-02-17)
6
+
7
+ ### ⚠ BREAKING CHANGES
8
+
9
+ - clarify subclass groupings and extensibility
10
+ - simplify credentials structure
11
+ - rename Token.TokenStorage to less redundant Token.Storage
12
+ - simplify namespacing of Injection and Scope
13
+ - improved clarity of errors and causes
14
+
15
+ ### Features
6
16
 
17
+ - base_url for API requests preempts issuer, if present ([972496a](https://github.com/battis/oauth2-cli/commit/972496a663751c12dce7271b33134c8055d84191))
18
+ - clarify subclass groupings and extensibility ([4fec372](https://github.com/battis/oauth2-cli/commit/4fec372019603c4bfada0e26d1813b3c196db536))
19
+ - rename Token.TokenStorage to less redundant Token.Storage ([149d65a](https://github.com/battis/oauth2-cli/commit/149d65ac218a2c230ed8bca76963e44a5a6ff441))
20
+ - simplify credentials structure ([0e95439](https://github.com/battis/oauth2-cli/commit/0e95439a30f78268ddf7363dc4feeb0b1ff0edba))
21
+ - simplify namespacing of Injection and Scope ([b5db750](https://github.com/battis/oauth2-cli/commit/b5db7503f557a0c2092d327742b1bdd82be0edbb))
7
22
 
8
23
  ### Bug Fixes
9
24
 
10
- * resolve remaining requestish requests correctly ([2be680c](https://github.com/battis/oauth2-cli/commit/2be680c9575bcfe9e816e450c85b94ccf5c8f950))
25
+ - export Scope without accidentally registering plugin ([3816537](https://github.com/battis/oauth2-cli/commit/38165376d6581b323cbb141a4923cd5613edeb63))
26
+ - improved clarity of errors and causes ([9f1ddce](https://github.com/battis/oauth2-cli/commit/9f1ddcec82c3295e39fc8857784634da072e7570))
27
+ - treat base_url as true base URL ([8a4b76c](https://github.com/battis/oauth2-cli/commit/8a4b76cb48041e31c7d0a72adb0312febad3ff28))
11
28
 
12
- ## [0.7.1](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.7.0...oauth2-cli/0.7.1) (2026-02-16)
29
+ ## [0.7.3](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.7.2...oauth2-cli/0.7.3) (2026-02-17)
13
30
 
14
- ## [0.7.0](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.6.0...oauth2-cli/0.7.0) (2026-02-16)
31
+ ### Bug Fixes
32
+
33
+ - push past failed well-known URL ([48eca87](https://github.com/battis/oauth2-cli/commit/48eca875e9fffe30adc88ad1b5fdf0202722bb12))
34
+
35
+ ## [0.7.2](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.7.1...oauth2-cli/0.7.2) (2026-02-16)
36
+
37
+ ### Bug Fixes
38
+
39
+ - resolve remaining requestish requests correctly ([2be680c](https://github.com/battis/oauth2-cli/commit/2be680c9575bcfe9e816e450c85b94ccf5c8f950))
15
40
 
41
+ ## [0.7.0](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.6.0...oauth2-cli/0.7.0) (2026-02-16)
16
42
 
17
43
  ### ⚠ BREAKING CHANGES
18
44
 
19
- * make more properties of Client accessible to subclasses
45
+ - make more properties of Client accessible to subclasses
20
46
 
21
47
  ### Features
22
48
 
23
- * make more properties of Client accessible to subclasses ([74ef874](https://github.com/battis/oauth2-cli/commit/74ef874804323a9c3c496ddf7b0e24bac9e671e1))
49
+ - make more properties of Client accessible to subclasses ([74ef874](https://github.com/battis/oauth2-cli/commit/74ef874804323a9c3c496ddf7b0e24bac9e671e1))
24
50
 
25
51
  ## [0.6.0](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.5.1...oauth2-cli/0.6.0) (2026-02-15)
26
52
 
27
-
28
53
  ### ⚠ BREAKING CHANGES
29
54
 
30
- * limit TokenStorage to storing _only_ refresh_tokens
31
- * improve express shutdown, refactor entire package
55
+ - limit TokenStorage to storing _only_ refresh_tokens
56
+ - improve express shutdown, refactor entire package
32
57
 
33
58
  ### Features
34
59
 
35
- * compatible with @battis/google-cloud-run-to-localhost ([3e449b1](https://github.com/battis/oauth2-cli/commit/3e449b14d546759f7e6543c86350ea83b60a80a7))
36
- * display authorization starting URL on command line as well as opening browser ([fb72bcf](https://github.com/battis/oauth2-cli/commit/fb72bcffafaf66453f8f8f0f8af4b27ef11827c6))
37
- * externalize path/port identification to gcrtl ([0f6c28b](https://github.com/battis/oauth2-cli/commit/0f6c28b31a7888eac524b28bcdc9c8eabbf57d91))
38
- * fallback to package templates if ejs present but no alternative template providedd ([6b05454](https://github.com/battis/oauth2-cli/commit/6b05454976b1fb4144f91ba51fc1c9331f1c0f34))
39
- * limit TokenStorage to storing _only_ refresh_tokens ([3de9c96](https://github.com/battis/oauth2-cli/commit/3de9c96510d15eebd51a0be7d8df278614541f95))
40
-
60
+ - compatible with @battis/google-cloud-run-to-localhost ([3e449b1](https://github.com/battis/oauth2-cli/commit/3e449b14d546759f7e6543c86350ea83b60a80a7))
61
+ - display authorization starting URL on command line as well as opening browser ([fb72bcf](https://github.com/battis/oauth2-cli/commit/fb72bcffafaf66453f8f8f0f8af4b27ef11827c6))
62
+ - externalize path/port identification to gcrtl ([0f6c28b](https://github.com/battis/oauth2-cli/commit/0f6c28b31a7888eac524b28bcdc9c8eabbf57d91))
63
+ - fallback to package templates if ejs present but no alternative template providedd ([6b05454](https://github.com/battis/oauth2-cli/commit/6b05454976b1fb4144f91ba51fc1c9331f1c0f34))
64
+ - limit TokenStorage to storing _only_ refresh_tokens ([3de9c96](https://github.com/battis/oauth2-cli/commit/3de9c96510d15eebd51a0be7d8df278614541f95))
41
65
 
42
66
  ### Bug Fixes
43
67
 
44
- * attempt to authorize and retry when encountering 401 error ([bc75fed](https://github.com/battis/oauth2-cli/commit/bc75fed052b548e41411287f7d98fa78c3f27ee5))
45
- * improve express shutdown, refactor entire package ([a740313](https://github.com/battis/oauth2-cli/commit/a740313c33d26f07ebab5b282607d8828cf3c3a7))
68
+ - attempt to authorize and retry when encountering 401 error ([bc75fed](https://github.com/battis/oauth2-cli/commit/bc75fed052b548e41411287f7d98fa78c3f27ee5))
69
+ - improve express shutdown, refactor entire package ([a740313](https://github.com/battis/oauth2-cli/commit/a740313c33d26f07ebab5b282607d8828cf3c3a7))
46
70
 
47
71
  ## [0.5.1](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.5.0...oauth2-cli/0.5.1) (2026-01-20)
48
72
 
49
-
50
73
  ### Bug Fixes
51
74
 
52
- * allow extending private methods for debugging ([ea9957f](https://github.com/battis/oauth2-cli/commit/ea9957f71629c4a177ebdf6acf0aecaa299a5260))
75
+ - allow extending private methods for debugging ([ea9957f](https://github.com/battis/oauth2-cli/commit/ea9957f71629c4a177ebdf6acf0aecaa299a5260))
53
76
 
54
77
  ## [0.5.0](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.4.0...oauth2-cli/0.5.0) (2026-01-14)
55
78
 
56
-
57
79
  ### ⚠ BREAKING CHANGES
58
80
 
59
- * move to Node.js v24 support
81
+ - move to Node.js v24 support
60
82
 
61
83
  ### Features
62
84
 
63
- * move to Node.js v24 support ([03d5cf4](https://github.com/battis/oauth2-cli/commit/03d5cf455e38f7beb2fbf93f1612acb906c5f5a0))
85
+ - move to Node.js v24 support ([03d5cf4](https://github.com/battis/oauth2-cli/commit/03d5cf455e38f7beb2fbf93f1612acb906c5f5a0))
64
86
 
65
87
  ## [0.4.0](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.3.0...oauth2-cli/0.4.0) (2026-01-04)
66
88
 
67
-
68
89
  ### ⚠ BREAKING CHANGES
69
90
 
70
- * remove deprecated TokenManager
91
+ - remove deprecated TokenManager
71
92
 
72
93
  ### Features
73
94
 
74
- * provide fetch() and fetchJSON() methods to translate to openid-client requests ([3fe454f](https://github.com/battis/oauth2-cli/commit/3fe454f28497d704041ea4e599a4ad5b2b08b469))
75
-
95
+ - provide fetch() and fetchJSON() methods to translate to openid-client requests ([3fe454f](https://github.com/battis/oauth2-cli/commit/3fe454f28497d704041ea4e599a4ad5b2b08b469))
76
96
 
77
97
  ### Bug Fixes
78
98
 
79
- * remove deprecated TokenManager ([2dde67e](https://github.com/battis/oauth2-cli/commit/2dde67edd70b151bd1bab6de3845839a06957e65))
99
+ - remove deprecated TokenManager ([2dde67e](https://github.com/battis/oauth2-cli/commit/2dde67edd70b151bd1bab6de3845839a06957e65))
80
100
 
81
101
  ## [0.3.0](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.2.3...oauth2-cli/0.3.0) (2025-12-24)
82
102
 
83
-
84
103
  ### ⚠ BREAKING CHANGES
85
104
 
86
- * resolve 1Password secret references successfully
105
+ - resolve 1Password secret references successfully
87
106
 
88
107
  ### Bug Fixes
89
108
 
90
- * resolve 1Password secret references successfully ([c4446e1](https://github.com/battis/oauth2-cli/commit/c4446e197a66271dac3ea8d58ff44725cc6be1db))
109
+ - resolve 1Password secret references successfully ([c4446e1](https://github.com/battis/oauth2-cli/commit/c4446e197a66271dac3ea8d58ff44725cc6be1db))
91
110
 
92
111
  ## [0.2.3](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.2.2...oauth2-cli/0.2.3) (2025-12-23)
93
112
 
94
-
95
113
  ### Bug Fixes
96
114
 
97
- * add wildcard param name ([97b2e58](https://github.com/battis/oauth2-cli/commit/97b2e58835941797fce564c736d8c4bd6e3ce97f))
115
+ - add wildcard param name ([97b2e58](https://github.com/battis/oauth2-cli/commit/97b2e58835941797fce564c736d8c4bd6e3ce97f))
98
116
 
99
117
  ## [0.2.2](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.2.1...oauth2-cli/0.2.2) (2025-12-23)
100
118
 
101
119
  ## [0.2.1](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.2.0...oauth2-cli/0.2.1) (2025-09-11)
102
120
 
103
-
104
121
  ### Bug Fixes
105
122
 
106
- * update dependencies to address transient openid-client config error ([f0ca9a8](https://github.com/battis/oauth2-cli/commit/f0ca9a8d2bb4551b80a49e48aa43df5ba66a5a9b))
123
+ - update dependencies to address transient openid-client config error ([f0ca9a8](https://github.com/battis/oauth2-cli/commit/f0ca9a8d2bb4551b80a49e48aa43df5ba66a5a9b))
107
124
 
108
125
  ## [0.2.0](https://github.com/battis/oauth2-cli/compare/oauth2-cli/0.1.6...oauth2-cli/0.2.0) (2025-03-09)
109
126
 
package/README.md CHANGED
@@ -39,7 +39,7 @@ Broadly speaking, having provided the configuration, the client is immediately r
39
39
 
40
40
  A `Client` requires some minimal information in order to interact with an OAuth 2.0 authorized API. The OAuth 2.0 base set is a `client_id`, `client_secret`, `authorization_endpoint`, `token_endpoint`, and a `redirect_uri`. For an OpenID-authenticated API, you could provide a `client_id`, `client_secret`, `issuer`, and `redirect_uri` and the Client will query the issuer for further details regarding required connection parameters (it is built on to of [openid-client](https://www.npmjs.com/package/openid-client)).
41
41
 
42
- In both cases, the token can be persisted by passing an implementation of [`TokenStorage`](https://github.com/battis/oauth2-cli/blob/main/packages/oauth2-cli/src/Token/TokenStorage.ts), such as [`FileStorage`](https://github.com/battis/oauth2-cli/blob/main/packages/oauth2-cli/src/Token/FileStorage.ts) which expects a path to a location to store a JSON file of access token data. _There are more secure ways to store your tokens, such as [@oauth2-cli/qui-cli](https://www.npmjs.com/package/@oauth2-cli/qui-cli)'s [`EnvironmentStorage`](https://github.com/battis/oauth2-cli/blob/main/packages/qui-cli/src/EnvironmentStorage.ts) which can be linked to a [1Password vault](https://github.com/battis/qui-cli/tree/main/packages/env#1password-integration)._
42
+ In both cases, the token can be persisted by passing an implementation of [`Token.Storage`](https://github.com/battis/oauth2-cli/blob/main/packages/oauth2-cli/src/Token/TokenStorage.ts), such as [`FileStorage`](https://github.com/battis/oauth2-cli/blob/main/packages/oauth2-cli/src/Token/FileStorage.ts) which expects a path to a location to store a JSON file of access token data. _There are more secure ways to store your tokens, such as [@oauth2-cli/qui-cli](https://www.npmjs.com/package/@oauth2-cli/qui-cli)'s [`EnvironmentStorage`](https://github.com/battis/oauth2-cli/blob/main/packages/qui-cli/src/EnvironmentStorage.ts) which can be linked to a [1Password vault](https://github.com/battis/qui-cli/tree/main/packages/env#1password-integration)._
43
43
 
44
44
  #### `redirect_uri` to Localhost
45
45
 
package/dist/Client.d.ts CHANGED
@@ -3,8 +3,8 @@ import { Request } from 'express';
3
3
  import { EventEmitter } from 'node:events';
4
4
  import * as OpenIDClient from 'openid-client';
5
5
  import * as requestish from 'requestish';
6
- import * as Credentials from './Credentials.js';
7
- import * as Req from './Request/index.js';
6
+ import { Credentials } from './Credentials.js';
7
+ import { Injection } from './Injection.js';
8
8
  import { Session, SessionOptions } from './Session.js';
9
9
  import * as Token from './Token/index.js';
10
10
  /**
@@ -14,20 +14,22 @@ import * as Token from './Token/index.js';
14
14
  export declare const DEFAULT_REDIRECT_URI = "http://localhost:3000/oauth2-cli/redirect";
15
15
  export type ClientOptions = {
16
16
  /** Credentials for server access */
17
- credentials: Credentials.Combined;
17
+ credentials: Credentials;
18
18
  /** Optional request components to inject */
19
19
  inject?: {
20
20
  search?: requestish.URLSearchParams.ish;
21
21
  headers?: requestish.Headers.ish;
22
22
  body?: requestish.Body.ish;
23
23
  };
24
+ /** Base URL for all non-absolute requests */
25
+ base_url?: requestish.URL.ish;
24
26
  /**
25
27
  * Optional absolute path to EJS view templates directory, see
26
28
  * [WebServer.setViews()](./Webserver.ts)
27
29
  */
28
30
  views?: PathString;
29
31
  /** Optional {@link TokenStorage} implementation to manage tokens */
30
- storage?: Token.TokenStorage;
32
+ storage?: Token.Storage;
31
33
  };
32
34
  type RefreshOptions = {
33
35
  /**
@@ -38,7 +40,7 @@ type RefreshOptions = {
38
40
  */
39
41
  refresh_token?: string;
40
42
  /** Additional request injection for refresh grant flow */
41
- inject?: Req.Injection;
43
+ inject?: Injection;
42
44
  };
43
45
  type GetTokenOptions = {
44
46
  /**
@@ -52,7 +54,7 @@ type GetTokenOptions = {
52
54
  * Additional request injection for authorization code grant and/or refresh
53
55
  * grant flows
54
56
  */
55
- inject?: Req.Injection;
57
+ inject?: Injection;
56
58
  };
57
59
  /**
58
60
  * Wrap {@link https://www.npmjs.com/package/openid-client openid-client} in a
@@ -63,14 +65,15 @@ type GetTokenOptions = {
63
65
  */
64
66
  export declare class Client extends EventEmitter {
65
67
  static readonly TokenEvent = "token";
66
- protected credentials: Credentials.Combined;
68
+ protected credentials: Credentials;
69
+ protected base_url?: requestish.URL.ish;
67
70
  protected config?: OpenIDClient.Configuration;
71
+ protected inject?: Injection;
68
72
  protected views?: PathString;
69
- protected inject?: Req.Injection;
70
73
  private token?;
71
74
  private tokenLock;
72
75
  private storage?;
73
- constructor({ credentials, views, inject, storage }: ClientOptions);
76
+ constructor({ credentials, base_url, views, inject, storage }: ClientOptions);
74
77
  get redirect_uri(): requestish.URL.ish;
75
78
  /**
76
79
  * @throws IndeterminateConfiguration if provided credentials combined with
package/dist/Client.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Mutex } from 'async-mutex';
2
2
  import { EventEmitter } from 'node:events';
3
+ import path from 'node:path';
3
4
  import * as OpenIDClient from 'openid-client';
4
5
  import * as requestish from 'requestish';
5
- import * as Errors from './Errors/index.js';
6
- import * as Req from './Request/index.js';
6
+ import * as Scope from './Scope.js';
7
7
  import { Session } from './Session.js';
8
8
  /**
9
9
  * A generic `redirect_uri` to use if the server does not require pre-registered
@@ -20,15 +20,17 @@ export const DEFAULT_REDIRECT_URI = 'http://localhost:3000/oauth2-cli/redirect';
20
20
  export class Client extends EventEmitter {
21
21
  static TokenEvent = 'token';
22
22
  credentials;
23
+ base_url;
23
24
  config;
24
- views;
25
25
  inject;
26
+ views;
26
27
  token;
27
28
  tokenLock = new Mutex();
28
29
  storage;
29
- constructor({ credentials, views, inject, storage }) {
30
+ constructor({ credentials, base_url, views, inject, storage }) {
30
31
  super();
31
32
  this.credentials = credentials;
33
+ this.base_url = base_url;
32
34
  this.views = views;
33
35
  this.inject = inject;
34
36
  this.storage = storage;
@@ -41,8 +43,14 @@ export class Client extends EventEmitter {
41
43
  * OpenID discovery fail to generate a complete configuration
42
44
  */
43
45
  async getConfiguration() {
46
+ let error = undefined;
44
47
  if (!this.config && this.credentials.issuer) {
45
- this.config = await OpenIDClient.discovery(requestish.URL.from(this.credentials.issuer), this.credentials.client_id, { client_secret: this.credentials.client_secret });
48
+ try {
49
+ this.config = await OpenIDClient.discovery(requestish.URL.from(this.credentials.issuer), this.credentials.client_id, { client_secret: this.credentials.client_secret });
50
+ }
51
+ catch (e) {
52
+ error = e;
53
+ }
46
54
  }
47
55
  if (!this.config && this.credentials?.authorization_endpoint) {
48
56
  this.config = new OpenIDClient.Configuration({
@@ -53,7 +61,12 @@ export class Client extends EventEmitter {
53
61
  }, this.credentials.client_id, { client_secret: this.credentials.client_secret });
54
62
  }
55
63
  if (!this.config) {
56
- throw new Errors.IndeterminateConfiguration();
64
+ throw new Error('The client configuration could not be constructed from provided credentials.', {
65
+ cause: {
66
+ credentials: this.credentials,
67
+ 'OpenID configuration result': error
68
+ }
69
+ });
57
70
  }
58
71
  return this.config;
59
72
  }
@@ -64,7 +77,7 @@ export class Client extends EventEmitter {
64
77
  params.set('code_challenge_method', 'S256');
65
78
  params.set('state', session.state);
66
79
  if (this.credentials.scope) {
67
- params.set('scope', Req.Scope.toString(this.credentials.scope));
80
+ params.set('scope', Scope.toString(this.credentials.scope));
68
81
  }
69
82
  return params;
70
83
  }
@@ -134,7 +147,9 @@ export class Client extends EventEmitter {
134
147
  async save(token) {
135
148
  this.token = token;
136
149
  if (!token.access_token) {
137
- throw new Errors.MissingAccessToken();
150
+ throw new Error('No access_token in response.', {
151
+ cause: token
152
+ });
138
153
  }
139
154
  if (this.storage && this.token.refresh_token) {
140
155
  await this.storage.save(this.token.refresh_token);
@@ -155,11 +170,19 @@ export class Client extends EventEmitter {
155
170
  url = requestish.URL.from(url);
156
171
  }
157
172
  catch (error) {
158
- if (this.credentials.issuer) {
159
- url = new URL(url, this.credentials.issuer);
173
+ if (this.base_url || this.credentials.issuer) {
174
+ url = path.join(
175
+ // @ts-expect-error 2345 TS, I _just_ tested this!
176
+ requestish.URL.toString(this.base_url || this.credentials.issuer), requestish.URL.toString(url).replace(/^\/?/, ''));
160
177
  }
161
178
  else {
162
- throw error;
179
+ throw new Error(`Invalid request URL "${url}"`, {
180
+ cause: {
181
+ base_url: this.base_url,
182
+ issuer: this.credentials.issuer,
183
+ error
184
+ }
185
+ });
163
186
  }
164
187
  }
165
188
  const request = async () => await OpenIDClient.fetchProtectedResource(await this.getConfiguration(), (await this.getToken()).access_token, requestish.URL.from(requestish.URLSearchParams.appendTo(url, this.inject?.search || {})), method, body, requestish.Headers.merge(this.inject?.headers, headers), dPoPOptions);
@@ -184,7 +207,9 @@ export class Client extends EventEmitter {
184
207
  return (await response.json());
185
208
  }
186
209
  else {
187
- throw new Errors.BadResponse(response);
210
+ throw new Error('The response could not be parsed as JSON.', {
211
+ cause: response
212
+ });
188
213
  }
189
214
  }
190
215
  /**
@@ -1,24 +1,10 @@
1
1
  import * as requestish from 'requestish';
2
- import * as Req from './Request/index.js';
3
- export type OAuth2 = {
2
+ import * as Scope from './Scope.js';
3
+ export type Credentials = {
4
4
  client_id: string;
5
5
  client_secret: string;
6
6
  redirect_uri: requestish.URL.ish;
7
- authorization_endpoint: requestish.URL.ish;
8
- token_endpoint: requestish.URL.ish;
9
- scope?: Req.Scope.ish;
10
- };
11
- export type OpenID = {
12
- issuer: requestish.URL.ish;
13
- client_id: string;
14
- client_secret: string;
15
- redirect_uri: requestish.URL.ish;
16
- };
17
- export type Combined = {
18
- client_id: string;
19
- client_secret: string;
20
- redirect_uri: requestish.URL.ish;
21
- scope?: Req.Scope.ish;
7
+ scope?: Scope.ish;
22
8
  } & ({
23
9
  issuer?: requestish.URL.ish;
24
10
  authorization_endpoint: requestish.URL.ish;
@@ -1,2 +1,4 @@
1
+ export * from './Credentials.js';
1
2
  export * from './Injection.js';
2
3
  export * as Scope from './Scope.js';
4
+ export * from './WebServer.js';
@@ -1,2 +1,4 @@
1
+ export * from './Credentials.js';
1
2
  export * from './Injection.js';
2
3
  export * as Scope from './Scope.js';
4
+ export * from './WebServer.js';
@@ -0,0 +1,2 @@
1
+ export * from './Client.js';
2
+ export * as Token from './Token/index.js';
package/dist/Extend.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './Client.js';
2
+ export * as Token from './Token/index.js';
package/dist/Session.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PathString } from '@battis/descriptive-types';
2
2
  import { Request } from 'express';
3
3
  import { Client } from './Client.js';
4
- import * as Req from './Request/index.js';
4
+ import { Injection } from './Injection.js';
5
5
  import * as Token from './Token/index.js';
6
6
  import * as WebServer from './WebServer.js';
7
7
  export type SessionOptions = {
@@ -9,7 +9,7 @@ export type SessionOptions = {
9
9
  /** See {@link WebServer.setViews Webserver.setViews()} */
10
10
  views?: PathString;
11
11
  /** Additional request injection for authorization code grant flow */
12
- inject?: Req.Injection;
12
+ inject?: Injection;
13
13
  };
14
14
  export type Resolver = (response?: Token.Response, error?: Error) => void | Promise<void>;
15
15
  export declare class Session {
@@ -20,7 +20,7 @@ export declare class Session {
20
20
  /** OAuth 2.0 state (if PKCE is not supported) */
21
21
  readonly state: string;
22
22
  /** Additional request injection for Authorization Code Grant request */
23
- readonly inject?: Req.Injection;
23
+ readonly inject?: Injection;
24
24
  private _resolve?;
25
25
  private spinner?;
26
26
  /**
package/dist/Session.js CHANGED
@@ -3,7 +3,6 @@ import * as gcrtl from 'gcrtl';
3
3
  import open from 'open';
4
4
  import * as OpenIDClient from 'openid-client';
5
5
  import ora from 'ora';
6
- import * as Errors from './Errors/index.js';
7
6
  import * as WebServer from './WebServer.js';
8
7
  export class Session {
9
8
  client;
@@ -49,7 +48,7 @@ export class Session {
49
48
  resolve(response);
50
49
  }
51
50
  else {
52
- reject(new Errors.MissingAccessToken());
51
+ reject(new Error('Authorization Code Grant response undefined.'));
53
52
  }
54
53
  };
55
54
  const url = gcrtl
@@ -1,5 +1,5 @@
1
- import { TokenStorage } from './TokenStorage.js';
2
- export declare class FileStorage implements TokenStorage {
1
+ import { Storage } from './Storage.js';
2
+ export declare class FileStorage implements Storage {
3
3
  private fileLock;
4
4
  private readonly filePath;
5
5
  constructor(filePath: string);
@@ -1,4 +1,4 @@
1
- export interface TokenStorage {
1
+ export interface Storage {
2
2
  load(): Promise<string | undefined>;
3
3
  save(refresh_token: string): Promise<void>;
4
4
  }
@@ -1,3 +1,3 @@
1
1
  export * from './FileStorage.js';
2
2
  export * from './Response.js';
3
- export * from './TokenStorage.js';
3
+ export * from './Storage.js';
@@ -1,3 +1,3 @@
1
1
  export * from './FileStorage.js';
2
2
  export * from './Response.js';
3
- export * from './TokenStorage.js';
3
+ export * from './Storage.js';
package/dist/WebServer.js CHANGED
@@ -3,7 +3,6 @@ import * as gcrtl from 'gcrtl';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import * as requestish from 'requestish';
6
- import * as Errors from './Errors/index.js';
7
6
  let ejs = undefined;
8
7
  try {
9
8
  ejs = (await import('ejs')).default;
@@ -31,7 +30,7 @@ export class WebServer {
31
30
  const url = requestish.URL.from(this.session.redirect_uri);
32
31
  this.port = url.port;
33
32
  if (WebServer.activePorts.includes(this.port)) {
34
- throw new Errors.PortCollision(url.port);
33
+ throw new Error(`Another process is already running at http://localhost:${url.port}.`, { cause: { activePorts: WebServer.activePorts } });
35
34
  }
36
35
  WebServer.activePorts.push(this.port);
37
36
  const app = express();
package/dist/index.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- export * from './Client.js';
2
- export * as Credentials from './Credentials.js';
3
- export * as Errors from './Errors/index.js';
4
- export * as Request from './Request/index.js';
5
- export * as Token from './Token/index.js';
6
- export * from './WebServer.js';
1
+ export * from './Export.js';
2
+ export * from './Extend.js';
package/dist/index.js CHANGED
@@ -1,6 +1,2 @@
1
- export * from './Client.js';
2
- export * as Credentials from './Credentials.js';
3
- export * as Errors from './Errors/index.js';
4
- export * as Request from './Request/index.js';
5
- export * as Token from './Token/index.js';
6
- export * from './WebServer.js';
1
+ export * from './Export.js';
2
+ export * from './Extend.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oauth2-cli",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Acquire API access tokens via OAuth 2.0 within CLI tools",
5
5
  "homepage": "https://github.com/battis/oauth2-cli/tree/main/packages/oauth2-cli#readme",
6
6
  "repository": {
@@ -1,3 +0,0 @@
1
- export declare class BadResponse extends Error {
2
- constructor(response: Response);
3
- }
@@ -1,7 +0,0 @@
1
- export class BadResponse extends Error {
2
- constructor(response) {
3
- super(`Response error ${response.status}: ${response.statusText}`, {
4
- cause: response
5
- });
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- export declare class IndeterminateConfiguration extends Error {
2
- constructor();
3
- }
@@ -1,5 +0,0 @@
1
- export class IndeterminateConfiguration extends Error {
2
- constructor() {
3
- super('A configuration could not be determined from the provided credentials.');
4
- }
5
- }
@@ -1,3 +0,0 @@
1
- export declare class MissingAccessToken extends Error {
2
- constructor();
3
- }
@@ -1,5 +0,0 @@
1
- export class MissingAccessToken extends Error {
2
- constructor() {
3
- super('No access token available.');
4
- }
5
- }
@@ -1,3 +0,0 @@
1
- export declare class PortCollision extends Error {
2
- constructor(port: string);
3
- }
@@ -1,5 +0,0 @@
1
- export class PortCollision extends Error {
2
- constructor(port) {
3
- super(`Cannot start authorization: another process is already running at http://localhost:${port}.`);
4
- }
5
- }
@@ -1,4 +0,0 @@
1
- export * from './BadResponse.js';
2
- export * from './IndeterminateConfiguration.js';
3
- export * from './MissingAccessToken.js';
4
- export * from './PortCollision.js';
@@ -1,4 +0,0 @@
1
- export * from './BadResponse.js';
2
- export * from './IndeterminateConfiguration.js';
3
- export * from './MissingAccessToken.js';
4
- export * from './PortCollision.js';
File without changes
File without changes
File without changes
File without changes
File without changes