@oauth2-cli/sky-api 0.1.1 → 0.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.
- package/CHANGELOG.md +21 -0
- package/README.md +3 -3
- package/dist/index.d.ts +5 -9
- package/dist/index.js +8 -11
- package/package.json +3 -3
- package/src/index.ts +13 -17
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
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.2.0](https://github.com/battis/oauth2-cli/compare/sky-api/0.1.2...sky-api/0.2.0) (2025-03-09)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **oauth2-cli:** detect and warn about reused localhost ports ([3431d84](https://github.com/battis/oauth2-cli/commit/3431d84d47251dd9fba47b23bbfd3dcf653fc7d3))
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- **sky-api:** limit excess subscription key copying ([e8a76c8](https://github.com/battis/oauth2-cli/commit/e8a76c814fe9bcbfb7de0ce3b40f7373b3e9787d))
|
|
14
|
+
- **oauth2-configure:** remove redundant caching ([7294e6a](https://github.com/battis/oauth2-cli/commit/7294e6a7aec373f72abc7c9e7c2ce4c659e3cba5))
|
|
15
|
+
|
|
16
|
+
## [0.1.2](https://github.com/battis/oauth2-cli/compare/sky-api/0.1.1...sky-api/0.1.2) (2025-03-08)
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- **oauth2-cli:** export Credentials type for convenience ([f000b56](https://github.com/battis/oauth2-cli/commit/f000b56a587c021d64a294ff33d42fa3966afd38))
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- **sky-api:** update from deprecated TokenManager to Client ([3685ede](https://github.com/battis/oauth2-cli/commit/3685edeacd7d5d2b05e4259dcd6f2ae15babb74a))
|
|
25
|
+
|
|
5
26
|
## [0.1.1](https://github.com/battis/oauth2-cli/compare/sky-api/0.1.0...sky-api/0.1.1) (2025-03-06)
|
|
6
27
|
|
|
7
28
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @oauth2-cli/sky-api
|
|
2
2
|
|
|
3
3
|
Acquire SKY API access tokens via OAuth 2.0 within CLI tools
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm i
|
|
8
|
+
npm i @oauth2-cli/sky-api
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -14,7 +14,7 @@ Configure your SKY API app credentials somewhere relatively secure (e.g. your en
|
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import dotenv from 'dotenv';
|
|
17
|
-
import { SkyAPI } from '
|
|
17
|
+
import { SkyAPI } from '@oauth2-cli/sky-api';
|
|
18
18
|
|
|
19
19
|
(async () => {
|
|
20
20
|
dotenv.config();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { RequestInfo, RequestInit } from 'node-fetch';
|
|
2
|
-
import * as
|
|
3
|
-
export type
|
|
4
|
-
client_id: string;
|
|
5
|
-
client_secret: string;
|
|
2
|
+
import * as OAuth2 from 'oauth2-cli';
|
|
3
|
+
export type Credentials = Omit<OAuth2.Credentials, 'authorization_endpoint' | 'token_endpoint'> & {
|
|
6
4
|
subscription_key: string;
|
|
7
|
-
redirect_uri: string;
|
|
8
|
-
store?: oauth.TokenStorage | string;
|
|
9
5
|
};
|
|
10
6
|
export declare class SkyAPI {
|
|
11
|
-
private
|
|
7
|
+
private client;
|
|
12
8
|
private token?;
|
|
13
9
|
private subscription_key;
|
|
14
|
-
constructor(credentials:
|
|
15
|
-
getToken(): Promise<
|
|
10
|
+
constructor({ subscription_key, ...credentials }: Credentials);
|
|
11
|
+
getToken(): Promise<OAuth2.Token | undefined>;
|
|
16
12
|
fetch(endpoint: URL | RequestInfo, init?: RequestInit): Promise<unknown>;
|
|
17
13
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
// TODO replace node-fetch dependency with native fetch when bumping to node@>=21
|
|
2
2
|
import nodeFetch from 'node-fetch';
|
|
3
|
-
import * as
|
|
3
|
+
import * as OAuth2 from 'oauth2-cli';
|
|
4
4
|
const SUBSCRIPTION_HEADER = 'Bb-Api-Subscription-Key';
|
|
5
5
|
export class SkyAPI {
|
|
6
|
-
|
|
6
|
+
client;
|
|
7
7
|
token;
|
|
8
8
|
subscription_key;
|
|
9
|
-
constructor(credentials) {
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
redirect_uri: credentials.redirect_uri,
|
|
9
|
+
constructor({ subscription_key, ...credentials }) {
|
|
10
|
+
this.subscription_key = subscription_key;
|
|
11
|
+
this.client = new OAuth2.Client({
|
|
12
|
+
...credentials,
|
|
14
13
|
authorization_endpoint: 'https://app.blackbaud.com/oauth/authorize',
|
|
15
14
|
token_endpoint: 'https://oauth2.sky.blackbaud.com/token',
|
|
16
|
-
headers: { [SUBSCRIPTION_HEADER]:
|
|
17
|
-
store: credentials.store
|
|
15
|
+
headers: { [SUBSCRIPTION_HEADER]: this.subscription_key }
|
|
18
16
|
});
|
|
19
|
-
this.subscription_key = credentials.subscription_key;
|
|
20
17
|
}
|
|
21
18
|
async getToken() {
|
|
22
|
-
this.token = await this.
|
|
19
|
+
this.token = await this.client.getToken();
|
|
23
20
|
return this.token;
|
|
24
21
|
}
|
|
25
22
|
async fetch(endpoint, init) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oauth2-cli/sky-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"blackbaud",
|
|
6
6
|
"sky",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"node-fetch": "^3.3.2",
|
|
26
|
-
"oauth2-cli": "0.
|
|
26
|
+
"oauth2-cli": "0.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@tsconfig/node20": "^20.1.4",
|
|
30
30
|
"commit-and-tag-version": "^12.5.0",
|
|
31
31
|
"del-cli": "^6.0.0",
|
|
32
32
|
"npm-run-all": "^4.1.5",
|
|
33
|
-
"typescript": "^5.
|
|
33
|
+
"typescript": "^5.8.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"clean": "del ./dist",
|
package/src/index.ts
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
// TODO replace node-fetch dependency with native fetch when bumping to node@>=21
|
|
2
2
|
import nodeFetch, { RequestInfo, RequestInit } from 'node-fetch';
|
|
3
|
-
import * as
|
|
3
|
+
import * as OAuth2 from 'oauth2-cli';
|
|
4
4
|
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export type Credentials = Omit<
|
|
6
|
+
OAuth2.Credentials,
|
|
7
|
+
'authorization_endpoint' | 'token_endpoint'
|
|
8
|
+
> & {
|
|
8
9
|
subscription_key: string;
|
|
9
|
-
redirect_uri: string;
|
|
10
|
-
store?: oauth.TokenStorage | string;
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
const SUBSCRIPTION_HEADER = 'Bb-Api-Subscription-Key';
|
|
14
13
|
|
|
15
14
|
export class SkyAPI {
|
|
16
|
-
private
|
|
17
|
-
private token?:
|
|
15
|
+
private client: OAuth2.Client;
|
|
16
|
+
private token?: OAuth2.Token;
|
|
18
17
|
private subscription_key: string;
|
|
19
18
|
|
|
20
|
-
public constructor(credentials:
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
redirect_uri: credentials.redirect_uri,
|
|
19
|
+
public constructor({ subscription_key, ...credentials }: Credentials) {
|
|
20
|
+
this.subscription_key = subscription_key;
|
|
21
|
+
this.client = new OAuth2.Client({
|
|
22
|
+
...credentials,
|
|
25
23
|
authorization_endpoint: 'https://app.blackbaud.com/oauth/authorize',
|
|
26
24
|
token_endpoint: 'https://oauth2.sky.blackbaud.com/token',
|
|
27
|
-
headers: { [SUBSCRIPTION_HEADER]:
|
|
28
|
-
store: credentials.store
|
|
25
|
+
headers: { [SUBSCRIPTION_HEADER]: this.subscription_key }
|
|
29
26
|
});
|
|
30
|
-
this.subscription_key = credentials.subscription_key;
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
public async getToken() {
|
|
34
|
-
this.token = await this.
|
|
30
|
+
this.token = await this.client.getToken();
|
|
35
31
|
return this.token;
|
|
36
32
|
}
|
|
37
33
|
|