@dropsh/plugin-oauth2 0.5.3 → 0.5.6

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.
@@ -0,0 +1,35 @@
1
+ import type { DropSHPlugin } from "dropsh/plugin";
2
+ /**
3
+ * Fields common to every oauth2 profile. `id` decouples the profile identity
4
+ * from `type` (the grant-flow selector), so two profiles of the same grant flow
5
+ * (e.g. two `client_credentials` with different scopes) can coexist. `default`
6
+ * marks the fallback profile when none is active/selected.
7
+ */
8
+ interface OAuth2Common {
9
+ /** Profile id (defaults to `type` for backward compatibility). */
10
+ id?: string;
11
+ /** Fallback profile when none is active or explicitly selected. */
12
+ default?: boolean;
13
+ }
14
+ export type OAuth2Config = OAuth2Common & ({
15
+ type: "oauth2_password";
16
+ client_id: string;
17
+ username: string;
18
+ token_url: string;
19
+ scope?: string;
20
+ client_secret?: string;
21
+ } | {
22
+ type: "oauth2_client_credentials";
23
+ client_id: string;
24
+ token_url: string;
25
+ scope?: string;
26
+ client_secret?: string;
27
+ } | {
28
+ type: "oauth2_authcode";
29
+ client_id: string;
30
+ token_url: string;
31
+ scope?: string;
32
+ redirect_port?: number;
33
+ });
34
+ export declare function oauth2Plugin(config: OAuth2Config): DropSHPlugin;
35
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { AuthSession, HttpClient } from "dropsh/plugin";
2
+ export declare function generatePkce(): {
3
+ verifier: string;
4
+ challenge: string;
5
+ };
6
+ export declare function generateState(): string;
7
+ export interface AcquireAuthCodeDeps {
8
+ baseUrl: string;
9
+ clientId: string;
10
+ tokenUrl: string;
11
+ scope?: string;
12
+ redirectPort?: number;
13
+ http: HttpClient;
14
+ openBrowser: (url: string) => Promise<void>;
15
+ stdout: (s: string) => void;
16
+ now: () => number;
17
+ timeoutMs?: number;
18
+ _generatePkce?: () => {
19
+ verifier: string;
20
+ challenge: string;
21
+ };
22
+ _generateState?: () => string;
23
+ }
24
+ /** Runs the PKCE browser flow and returns an AuthSession (no persistence). */
25
+ export declare function acquireAuthCodeSession(deps: AcquireAuthCodeDeps): Promise<AuthSession>;
@@ -0,0 +1,3 @@
1
+ import type { AuthProvider } from "dropsh/plugin";
2
+ import type { OAuth2Config } from "./index.js";
3
+ export declare function oauth2Provider(cfg: OAuth2Config): AuthProvider;
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@dropsh/plugin-oauth2",
3
- "version": "0.5.3",
3
+ "version": "0.5.6",
4
4
  "type": "module",
5
5
  "main": "./dist/plugins/oauth2/src/index.js",
6
+ "types": "./dist/plugins/oauth2/src/index.d.ts",
6
7
  "exports": {
7
- ".": "./dist/plugins/oauth2/src/index.js"
8
+ ".": {
9
+ "types": "./dist/plugins/oauth2/src/index.d.ts",
10
+ "default": "./dist/plugins/oauth2/src/index.js"
11
+ }
8
12
  },
9
13
  "files": [
10
14
  "dist/plugins/oauth2/src",
@@ -19,7 +23,7 @@
19
23
  "devDependencies": {
20
24
  "typescript": "^5.6.0",
21
25
  "vitest": "^4.1.8",
22
- "dropsh": "0.5.3"
26
+ "dropsh": "0.5.6"
23
27
  },
24
28
  "scripts": {
25
29
  "build": "tsc",