@kong/spec-renderer 1.115.1 → 1.115.2-pr.1022.fd06bfc.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/dist/cli/index.js +0 -0
- package/dist/types/composables/useOAuthPkce.d.ts +15 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/oauth.d.ts +56 -0
- package/dist/types/utils/oauth-pkce.d.ts +14 -0
- package/dist/types/utils/oauth-popup.d.ts +19 -0
- package/package.json +29 -30
- package/dist/kongctl-ext-spec-preview-universal.tar.gz +0 -0
package/dist/cli/index.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthorizeOptions, Oauth2AuthStatus, Oauth2PkceTarget, OauthToken } from '../types/index.d.ts';
|
|
2
|
+
/** Treat tokens as expired a bit earlier, to account for network latency and to ensure in-flight requests don't 401 */
|
|
3
|
+
export declare const EXPIRY_SKEW_MS = 30000;
|
|
4
|
+
/** Give up on a token request the identity provider never answers. */
|
|
5
|
+
export declare const TOKEN_TIMEOUT_MS = 30000;
|
|
6
|
+
/** OAuth2 PKCE sign-in for Try It. Every caller shares the same module-level state. */
|
|
7
|
+
export default function useOAuthPkce(): {
|
|
8
|
+
statusFor: (target: Oauth2PkceTarget) => Oauth2AuthStatus;
|
|
9
|
+
aggregateStatus: (targets: Oauth2PkceTarget[]) => Oauth2AuthStatus;
|
|
10
|
+
tokenFor: (target: Oauth2PkceTarget) => OauthToken | undefined;
|
|
11
|
+
errorFor: (target: Oauth2PkceTarget) => string | undefined;
|
|
12
|
+
authorize: ({ target, clientId, scopes, redirectUri }: AuthorizeOptions) => Promise<void>;
|
|
13
|
+
clearCredentials: (target: Oauth2PkceTarget) => void;
|
|
14
|
+
reset: () => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Sign-in state of one authorizationCode (PKCE) security scheme. */
|
|
2
|
+
export type Oauth2AuthStatus = 'unauthenticated' | 'authorizing' | 'authenticated' | 'expired';
|
|
3
|
+
/** What the PKCE flow needs from one authorizationCode security scheme. */
|
|
4
|
+
export interface Oauth2PkceTarget {
|
|
5
|
+
schemeKey: string;
|
|
6
|
+
authorizationUrl: string;
|
|
7
|
+
tokenUrl: string;
|
|
8
|
+
scopes: Record<string, string>;
|
|
9
|
+
/** `authorizationUrl|tokenUrl|clientId`, so a token is never reused for another spec or client */
|
|
10
|
+
fingerprint: string;
|
|
11
|
+
}
|
|
12
|
+
/** An access token, held in memory only. */
|
|
13
|
+
export interface OauthToken {
|
|
14
|
+
accessToken: string;
|
|
15
|
+
tokenType: string;
|
|
16
|
+
/** epoch ms, undefined when the server sent no expires_in */
|
|
17
|
+
expiresAt?: number;
|
|
18
|
+
fingerprint: string;
|
|
19
|
+
}
|
|
20
|
+
/** What the callback page posts back from the identity provider. */
|
|
21
|
+
export interface AuthorizationResponseParams {
|
|
22
|
+
code?: string;
|
|
23
|
+
state?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
errorDescription?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface PkceChallenge {
|
|
28
|
+
verifier: string;
|
|
29
|
+
challenge: string;
|
|
30
|
+
state: string;
|
|
31
|
+
}
|
|
32
|
+
export interface BuildAuthorizeUrlParams {
|
|
33
|
+
authorizationUrl: string;
|
|
34
|
+
clientId: string;
|
|
35
|
+
redirectUri: string;
|
|
36
|
+
scope: string;
|
|
37
|
+
state: string;
|
|
38
|
+
codeChallenge: string;
|
|
39
|
+
}
|
|
40
|
+
export interface AwaitAuthorizationResponseResult {
|
|
41
|
+
promise: Promise<AuthorizationResponseParams>;
|
|
42
|
+
cancel: () => void;
|
|
43
|
+
}
|
|
44
|
+
/** What starting a sign-in needs: the scheme, the user's client id and scopes, and the callback page. */
|
|
45
|
+
export interface AuthorizeOptions {
|
|
46
|
+
target: Oauth2PkceTarget;
|
|
47
|
+
clientId: string;
|
|
48
|
+
scopes: string[];
|
|
49
|
+
redirectUri: string;
|
|
50
|
+
}
|
|
51
|
+
/** The parts of the token endpoint's JSON body (RFC 6749) this flow reads. */
|
|
52
|
+
export interface TokenResponseData {
|
|
53
|
+
access_token: string;
|
|
54
|
+
token_type?: string;
|
|
55
|
+
expires_in?: number;
|
|
56
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IOauth2SecurityScheme } from '@stoplight/types';
|
|
2
|
+
import type { BuildAuthorizeUrlParams, Oauth2PkceTarget, PkceChallenge } from '../types/index.d.ts';
|
|
3
|
+
/** True when the Web Crypto parts PKCE needs exist. Doesn't use window.isSecureContext, it's undefined in jsdom. */
|
|
4
|
+
export declare const canUsePkce: () => boolean;
|
|
5
|
+
/** True when raw is an absolute http(s) URL. Spec endpoints are untrusted, a javascript: URL would run in the popup. */
|
|
6
|
+
export declare const isAbsoluteHttpUrl: (raw: string) => boolean;
|
|
7
|
+
/** The S256 code_challenge for a verifier: its SHA-256, base64url encoded without padding. */
|
|
8
|
+
export declare const generateCodeChallenge: (verifier: string) => Promise<string>;
|
|
9
|
+
/** A fresh verifier, its challenge, and a state value, for one sign-in. */
|
|
10
|
+
export declare const createPkceChallenge: () => Promise<PkceChallenge>;
|
|
11
|
+
/** The authorization request URL for the PKCE (S256) flow. */
|
|
12
|
+
export declare const buildAuthorizeUrl: ({ authorizationUrl, clientId, redirectUri, scope, state, codeChallenge }: BuildAuthorizeUrlParams) => string;
|
|
13
|
+
/** The PKCE target for a scheme's authorizationCode flow, or undefined when it can't be used. */
|
|
14
|
+
export declare const buildPkceTarget: (schemeKey: string, scheme: IOauth2SecurityScheme, clientId: string) => Oauth2PkceTarget | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AwaitAuthorizationResponseResult } from '../types/index.d.ts';
|
|
2
|
+
export declare const OAUTH_MESSAGE_TYPE = "kong-spec-renderer:oauth-callback";
|
|
3
|
+
export declare const POPUP_NAME = "kong-spec-renderer-oauth";
|
|
4
|
+
export declare const POPUP_WIDTH = 600;
|
|
5
|
+
export declare const POPUP_HEIGHT = 760;
|
|
6
|
+
export declare const POPUP_POLL_MS = 500;
|
|
7
|
+
export declare const FLOW_TIMEOUT_MS: number;
|
|
8
|
+
/** Rejection message for a flow cancelled from code. It's not the user's error, so callers ignore it. */
|
|
9
|
+
export declare const FLOW_CANCELLED = "cancelled";
|
|
10
|
+
/**
|
|
11
|
+
* Open an empty popup centred on the window, or return null when the browser blocked it.
|
|
12
|
+
* Call it straight from the click, before any await, or the browser treats it as unrequested and blocks it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const openAuthorizationPopup: () => Window | null;
|
|
15
|
+
/**
|
|
16
|
+
* Wait for the callback page to post the identity provider's answer back.
|
|
17
|
+
* Rejects with a user-facing message when the popup closes or the sign-in times out.
|
|
18
|
+
*/
|
|
19
|
+
export declare const awaitAuthorizationResponse: (popup: Window, expectedOrigin: string) => AwaitAuthorizationResponseResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong/spec-renderer",
|
|
3
|
-
"version": "1.115.
|
|
3
|
+
"version": "1.115.2-pr.1022.fd06bfc.0",
|
|
4
4
|
"description": "Kong's open-source spec renderer",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -32,30 +32,6 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"dev": "cross-env USE_SANDBOX=true vite",
|
|
37
|
-
"build": "pnpm run typecheck && pnpm run build:package && pnpm run build:webcomponent && pnpm run build:types && pnpm run build:aliases && pnpm run build:cli",
|
|
38
|
-
"build:package": "vite build -m production",
|
|
39
|
-
"build:webcomponent": "cross-env VITE_AS_WEB_COMPONENT='true' vite build -m production",
|
|
40
|
-
"build:types": "vue-tsc -p './tsconfig.build.json' --emitDeclarationOnly",
|
|
41
|
-
"build:aliases": "tsc-alias -p './tsconfig.build.json'",
|
|
42
|
-
"build:cli": "tsc -p './tsconfig.cli.build.json' && node ./scripts/build-cli-assets.js && node ./scripts/generate-kongctl-manifest.mjs",
|
|
43
|
-
"generate:kongctl-manifest": "pnpm run build:cli",
|
|
44
|
-
"build:analyzer": "BUILD_VISUALIZER='true' vite build -m production",
|
|
45
|
-
"build:sandbox": "cross-env USE_SANDBOX=true vite build -m production",
|
|
46
|
-
"preview": "pnpm run build:sandbox && cross-env USE_SANDBOX=true vite preview",
|
|
47
|
-
"typecheck": "vue-tsc -p './tsconfig.build.json' --noEmit && pnpm run typecheck:cli && pnpm run typecheck:scripts",
|
|
48
|
-
"typecheck:cli": "tsc -p './tsconfig.cli.json' --noEmit",
|
|
49
|
-
"typecheck:scripts": "tsc -p './tsconfig.scripts.json' --noEmit",
|
|
50
|
-
"stylelint": "stylelint --allow-empty-input './src/**/*.{css,scss,vue}'",
|
|
51
|
-
"stylelint:fix": "stylelint --allow-empty-input './src/**/*.{css,scss,sass,vue}' --fix",
|
|
52
|
-
"lint": "eslint",
|
|
53
|
-
"lint:fix": "eslint --fix",
|
|
54
|
-
"test": "cross-env FORCE_COLOR=1 vitest run",
|
|
55
|
-
"test:open": "cross-env FORCE_COLOR=1 vitest --ui",
|
|
56
|
-
"semantic-release": "semantic-release",
|
|
57
|
-
"commit": "cz"
|
|
58
|
-
},
|
|
59
35
|
"peerDependencies": {
|
|
60
36
|
"vue": ">= 3.3.13 < 4"
|
|
61
37
|
},
|
|
@@ -104,14 +80,14 @@
|
|
|
104
80
|
"@types/jsdom": "^30.0.0",
|
|
105
81
|
"@types/json-schema": "^7.0.15",
|
|
106
82
|
"@types/markdown-it": "^14.2.0",
|
|
107
|
-
"@types/node": "^24.13.
|
|
83
|
+
"@types/node": "^24.13.5",
|
|
108
84
|
"@types/sanitize-html": "^2.16.1",
|
|
109
85
|
"@types/ws": "^8.18.1",
|
|
110
86
|
"@vitejs/plugin-vue": "^6.0.9",
|
|
111
87
|
"@vitest/ui": "^4.1.11",
|
|
112
88
|
"@vue/test-utils": "^2.5.0",
|
|
113
89
|
"@vue/tsconfig": "^0.9.1",
|
|
114
|
-
"autoprefixer": "^10.6.
|
|
90
|
+
"autoprefixer": "^10.6.1",
|
|
115
91
|
"c8": "^12.0.0",
|
|
116
92
|
"commitizen": "^4.3.2",
|
|
117
93
|
"cross-env": "^10.1.0",
|
|
@@ -215,7 +191,7 @@
|
|
|
215
191
|
},
|
|
216
192
|
"volta": {
|
|
217
193
|
"node": "24.21.0",
|
|
218
|
-
"pnpm": "11.
|
|
194
|
+
"pnpm": "11.27.0"
|
|
219
195
|
},
|
|
220
196
|
"config": {
|
|
221
197
|
"commitizen": {
|
|
@@ -227,5 +203,28 @@
|
|
|
227
203
|
"jiraAppend": "]"
|
|
228
204
|
}
|
|
229
205
|
},
|
|
230
|
-
"
|
|
231
|
-
|
|
206
|
+
"scripts": {
|
|
207
|
+
"dev": "cross-env USE_SANDBOX=true vite",
|
|
208
|
+
"build": "pnpm run typecheck && pnpm run build:package && pnpm run build:webcomponent && pnpm run build:types && pnpm run build:aliases && pnpm run build:cli",
|
|
209
|
+
"build:package": "vite build -m production",
|
|
210
|
+
"build:webcomponent": "cross-env VITE_AS_WEB_COMPONENT='true' vite build -m production",
|
|
211
|
+
"build:types": "vue-tsc -p './tsconfig.build.json' --emitDeclarationOnly",
|
|
212
|
+
"build:aliases": "tsc-alias -p './tsconfig.build.json'",
|
|
213
|
+
"build:cli": "tsc -p './tsconfig.cli.build.json' && node ./scripts/build-cli-assets.js && node ./scripts/generate-kongctl-manifest.mjs",
|
|
214
|
+
"generate:kongctl-manifest": "pnpm run build:cli",
|
|
215
|
+
"build:analyzer": "BUILD_VISUALIZER='true' vite build -m production",
|
|
216
|
+
"build:sandbox": "cross-env USE_SANDBOX=true vite build -m production",
|
|
217
|
+
"preview": "pnpm run build:sandbox && cross-env USE_SANDBOX=true vite preview",
|
|
218
|
+
"typecheck": "vue-tsc -p './tsconfig.build.json' --noEmit && pnpm run typecheck:cli && pnpm run typecheck:scripts",
|
|
219
|
+
"typecheck:cli": "tsc -p './tsconfig.cli.json' --noEmit",
|
|
220
|
+
"typecheck:scripts": "tsc -p './tsconfig.scripts.json' --noEmit",
|
|
221
|
+
"stylelint": "stylelint --allow-empty-input './src/**/*.{css,scss,vue}'",
|
|
222
|
+
"stylelint:fix": "stylelint --allow-empty-input './src/**/*.{css,scss,sass,vue}' --fix",
|
|
223
|
+
"lint": "eslint",
|
|
224
|
+
"lint:fix": "eslint --fix",
|
|
225
|
+
"test": "cross-env FORCE_COLOR=1 vitest run",
|
|
226
|
+
"test:open": "cross-env FORCE_COLOR=1 vitest --ui",
|
|
227
|
+
"semantic-release": "semantic-release",
|
|
228
|
+
"commit": "cz"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
Binary file
|