@perspectask/sdk 0.0.6 → 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/README.md +1 -1
- package/dist/chunk-56FPFSE2.js +120 -0
- package/dist/chunk-56FPFSE2.js.map +1 -0
- package/dist/credentials.cjs +169 -0
- package/dist/credentials.cjs.map +1 -0
- package/dist/credentials.d.cts +32 -0
- package/dist/credentials.d.ts +32 -0
- package/dist/credentials.js +88 -0
- package/dist/credentials.js.map +1 -0
- package/dist/index.cjs +141 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/oauth-kp6GpoOV.d.cts +43 -0
- package/dist/oauth-kp6GpoOV.d.ts +43 -0
- package/package.json +6 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare const CLI_CLIENT_ID = "perspectask-cli";
|
|
2
|
+
declare const DEFAULT_BASE_URL = "https://api.perspectask.com/v1";
|
|
3
|
+
interface OAuthTokens {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
refreshToken: string;
|
|
6
|
+
/** Milliseconds since the epoch. */
|
|
7
|
+
expiresAt: number;
|
|
8
|
+
scope: string;
|
|
9
|
+
}
|
|
10
|
+
interface DeviceLogin {
|
|
11
|
+
deviceCode: string;
|
|
12
|
+
userCode: string;
|
|
13
|
+
verificationUri: string;
|
|
14
|
+
verificationUriComplete: string;
|
|
15
|
+
expiresIn: number;
|
|
16
|
+
interval: number;
|
|
17
|
+
}
|
|
18
|
+
interface OAuthRequestOptions {
|
|
19
|
+
/** The API base URL, e.g. `https://api.perspectask.com/v1`. OAuth endpoints live on the same origin. */
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
}
|
|
23
|
+
/** An OAuth error response. `code` is the RFC 6749 error, e.g. `invalid_grant`. */
|
|
24
|
+
declare class OAuthTokenError extends Error {
|
|
25
|
+
readonly code: string;
|
|
26
|
+
constructor(code: string, message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Start a browser login for a terminal. Show `verificationUriComplete` to the user, then call `waitForDeviceLogin`. */
|
|
29
|
+
declare function startDeviceLogin(options?: OAuthRequestOptions & {
|
|
30
|
+
scope?: string;
|
|
31
|
+
/** Shown on the approval page and under Connected apps, e.g. the machine's hostname. */
|
|
32
|
+
deviceName?: string;
|
|
33
|
+
}): Promise<DeviceLogin>;
|
|
34
|
+
/** Poll until the user approves (resolves with tokens) or denies or lets the code expire (rejects with an `OAuthTokenError`). */
|
|
35
|
+
declare function waitForDeviceLogin(login: DeviceLogin, options?: OAuthRequestOptions & {
|
|
36
|
+
sleep?: (ms: number) => Promise<void>;
|
|
37
|
+
}): Promise<OAuthTokens>;
|
|
38
|
+
/** Trade a refresh token for new tokens. The old refresh token stops working. */
|
|
39
|
+
declare function refreshTokens(refreshToken: string, options?: OAuthRequestOptions): Promise<OAuthTokens>;
|
|
40
|
+
/** Sign out: the access and refresh token both stop working. */
|
|
41
|
+
declare function revokeTokens(token: string, options?: OAuthRequestOptions): Promise<void>;
|
|
42
|
+
|
|
43
|
+
export { CLI_CLIENT_ID as C, type DeviceLogin as D, type OAuthTokens as O, DEFAULT_BASE_URL as a, type OAuthRequestOptions as b, OAuthTokenError as c, revokeTokens as d, refreshTokens as r, startDeviceLogin as s, waitForDeviceLogin as w };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare const CLI_CLIENT_ID = "perspectask-cli";
|
|
2
|
+
declare const DEFAULT_BASE_URL = "https://api.perspectask.com/v1";
|
|
3
|
+
interface OAuthTokens {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
refreshToken: string;
|
|
6
|
+
/** Milliseconds since the epoch. */
|
|
7
|
+
expiresAt: number;
|
|
8
|
+
scope: string;
|
|
9
|
+
}
|
|
10
|
+
interface DeviceLogin {
|
|
11
|
+
deviceCode: string;
|
|
12
|
+
userCode: string;
|
|
13
|
+
verificationUri: string;
|
|
14
|
+
verificationUriComplete: string;
|
|
15
|
+
expiresIn: number;
|
|
16
|
+
interval: number;
|
|
17
|
+
}
|
|
18
|
+
interface OAuthRequestOptions {
|
|
19
|
+
/** The API base URL, e.g. `https://api.perspectask.com/v1`. OAuth endpoints live on the same origin. */
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
}
|
|
23
|
+
/** An OAuth error response. `code` is the RFC 6749 error, e.g. `invalid_grant`. */
|
|
24
|
+
declare class OAuthTokenError extends Error {
|
|
25
|
+
readonly code: string;
|
|
26
|
+
constructor(code: string, message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Start a browser login for a terminal. Show `verificationUriComplete` to the user, then call `waitForDeviceLogin`. */
|
|
29
|
+
declare function startDeviceLogin(options?: OAuthRequestOptions & {
|
|
30
|
+
scope?: string;
|
|
31
|
+
/** Shown on the approval page and under Connected apps, e.g. the machine's hostname. */
|
|
32
|
+
deviceName?: string;
|
|
33
|
+
}): Promise<DeviceLogin>;
|
|
34
|
+
/** Poll until the user approves (resolves with tokens) or denies or lets the code expire (rejects with an `OAuthTokenError`). */
|
|
35
|
+
declare function waitForDeviceLogin(login: DeviceLogin, options?: OAuthRequestOptions & {
|
|
36
|
+
sleep?: (ms: number) => Promise<void>;
|
|
37
|
+
}): Promise<OAuthTokens>;
|
|
38
|
+
/** Trade a refresh token for new tokens. The old refresh token stops working. */
|
|
39
|
+
declare function refreshTokens(refreshToken: string, options?: OAuthRequestOptions): Promise<OAuthTokens>;
|
|
40
|
+
/** Sign out: the access and refresh token both stop working. */
|
|
41
|
+
declare function revokeTokens(token: string, options?: OAuthRequestOptions): Promise<void>;
|
|
42
|
+
|
|
43
|
+
export { CLI_CLIENT_ID as C, type DeviceLogin as D, type OAuthTokens as O, DEFAULT_BASE_URL as a, type OAuthRequestOptions as b, OAuthTokenError as c, revokeTokens as d, refreshTokens as r, startDeviceLogin as s, waitForDeviceLogin as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perspectask/sdk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Official TypeScript SDK for the PerspecTask API.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"import": "./dist/index.js",
|
|
30
30
|
"require": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./credentials": {
|
|
33
|
+
"types": "./dist/credentials.d.ts",
|
|
34
|
+
"import": "./dist/credentials.js",
|
|
35
|
+
"require": "./dist/credentials.cjs"
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"files": [
|