@redocly/replay 0.0.0-beta-20240215154132
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/LICENSE +1 -0
- package/README.md +1 -0
- package/dist/App-2bf73452.cjs +1139 -0
- package/dist/App-b015f359.js +9953 -0
- package/dist/index-7f707529.js +21433 -0
- package/dist/index-8311349a.cjs +189 -0
- package/dist/oauth2-redirect.cjs +4 -0
- package/dist/oauth2-redirect.d.ts +1 -0
- package/dist/oauth2-redirect.html +24 -0
- package/dist/oauth2-redirect.js +58 -0
- package/dist/replay.cjs +1 -0
- package/dist/replay.d.ts +231 -0
- package/dist/replay.js +7 -0
- package/package.json +57 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const c="Something went wrong, please, try again.";function t(o){return o&&o.replace(/=+$/,"")}function a(o,e){return!!o&&!!e&&t(o)===t(e)}function y(o){let e;if(/code|token|error/.test(window.location.hash)?e=window.location.hash.substring(1):e=location.search.substring(1),!e)throw console.error("No query string in OAuth 2 redirect URL"),new Error(c);const n=new URLSearchParams(e),r=n.get("access_token"),s=n.get("code"),i=n.get("token_type"),w=n.get("expires_in"),l=n.get("state"),u=n.get("error"),g=n.get("error_description")||c;if(u)throw new Error(g);if(!a(l,o==null?void 0:o.state))throw new Error("Outdated OAuth2 state");if((o==null?void 0:o.flow)==="implicit"){if(!r)throw new Error(`Your OAuth2 authentication service provider redirected you without an "access_token".
|
|
2
|
+
Please, try again or make sure your OAuth2 settings are correct.`);if(!i)throw new Error(`Your OAuth2 authentication service provider redirected you without a "token_type".
|
|
3
|
+
Please, try again or make sure your OAuth2 settings are correct.`);o==null||o.successCallback({access_token:r,token_type:i,expires_in:w,auth_code:""})}if((o==null?void 0:o.flow)==="authorizationCode"){if(!s)throw new Error(`Your OAuth2 authentication service provider redirected you without authorization "code".
|
|
4
|
+
Please, try again or make sure your OAuth2 settings are correct.`);o==null||o.successCallback({auth_code:s,access_token:"",token_type:"bearer"})}}function k(){var e;const o=(e=window.opener)==null?void 0:e.redirectOAuth2;try{y(o)}catch(n){o==null||o.errorCallback(n)}window.close()}window.onload=k;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
6
|
+
<title>Redocly Reference Docs: OAuth2 Redirect</title>
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
.user-info {
|
|
10
|
+
margin: 150px auto auto;
|
|
11
|
+
width: 50%;
|
|
12
|
+
background-color: whitesmoke;
|
|
13
|
+
padding: 20px;
|
|
14
|
+
text-align: center;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<script type="text/javascript" src="oauth2-redirect.js"></script>
|
|
21
|
+
|
|
22
|
+
<noscript> You need to enable JavaScript to run this app. </noscript>
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const c = "Something went wrong, please, try again.";
|
|
2
|
+
function t(o) {
|
|
3
|
+
return o && o.replace(/=+$/, "");
|
|
4
|
+
}
|
|
5
|
+
function a(o, e) {
|
|
6
|
+
return !!o && !!e && t(o) === t(e);
|
|
7
|
+
}
|
|
8
|
+
function y(o) {
|
|
9
|
+
let e;
|
|
10
|
+
if (/code|token|error/.test(window.location.hash) ? e = window.location.hash.substring(1) : e = location.search.substring(1), !e)
|
|
11
|
+
throw console.error("No query string in OAuth 2 redirect URL"), new Error(c);
|
|
12
|
+
const n = new URLSearchParams(e), r = n.get("access_token"), s = n.get("code"), i = n.get("token_type"), w = n.get("expires_in"), l = n.get("state"), g = n.get("error"), u = n.get("error_description") || c;
|
|
13
|
+
if (g)
|
|
14
|
+
throw new Error(u);
|
|
15
|
+
if (!a(l, o == null ? void 0 : o.state))
|
|
16
|
+
throw new Error("Outdated OAuth2 state");
|
|
17
|
+
if ((o == null ? void 0 : o.flow) === "implicit") {
|
|
18
|
+
if (!r)
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Your OAuth2 authentication service provider redirected you without an "access_token".
|
|
21
|
+
Please, try again or make sure your OAuth2 settings are correct.`
|
|
22
|
+
);
|
|
23
|
+
if (!i)
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Your OAuth2 authentication service provider redirected you without a "token_type".
|
|
26
|
+
Please, try again or make sure your OAuth2 settings are correct.`
|
|
27
|
+
);
|
|
28
|
+
o == null || o.successCallback({
|
|
29
|
+
access_token: r,
|
|
30
|
+
token_type: i,
|
|
31
|
+
expires_in: w,
|
|
32
|
+
auth_code: ""
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if ((o == null ? void 0 : o.flow) === "authorizationCode") {
|
|
36
|
+
if (!s)
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Your OAuth2 authentication service provider redirected you without authorization "code".
|
|
39
|
+
Please, try again or make sure your OAuth2 settings are correct.`
|
|
40
|
+
);
|
|
41
|
+
o == null || o.successCallback({
|
|
42
|
+
auth_code: s,
|
|
43
|
+
access_token: "",
|
|
44
|
+
token_type: "bearer"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function k() {
|
|
49
|
+
var e;
|
|
50
|
+
const o = (e = window.opener) == null ? void 0 : e.redirectOAuth2;
|
|
51
|
+
try {
|
|
52
|
+
y(o);
|
|
53
|
+
} catch (n) {
|
|
54
|
+
o == null || o.errorCallback(n);
|
|
55
|
+
}
|
|
56
|
+
window.close();
|
|
57
|
+
}
|
|
58
|
+
window.onload = k;
|
package/dist/replay.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-8311349a.cjs");require("react");require("@redocly/theme");exports.Replay=e.Replay;exports.ReplayOverlay=e.ReplayOverlay;
|
package/dist/replay.d.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
|
+
import { State } from '@hookstate/core';
|
|
3
|
+
|
|
4
|
+
declare enum ApiKeyLocation {
|
|
5
|
+
Query = "Query",
|
|
6
|
+
Header = "Headers"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare type Environment = {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
variables: EnvironmentVariable[];
|
|
13
|
+
state: EnvironmentState;
|
|
14
|
+
canBeRemoved: boolean;
|
|
15
|
+
canBeEdited: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare enum EnvironmentState {
|
|
19
|
+
Normal = "Normal",
|
|
20
|
+
Edit = "Edit",
|
|
21
|
+
Draft = "Draft"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare type EnvironmentVariable = {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
value: string;
|
|
28
|
+
canBeRemoved: boolean;
|
|
29
|
+
canBeEdited: boolean;
|
|
30
|
+
isSecret?: boolean;
|
|
31
|
+
readonlyName?: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
declare type FormDataParam = {
|
|
35
|
+
id: string;
|
|
36
|
+
active: boolean;
|
|
37
|
+
key: string;
|
|
38
|
+
value: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
declare const globalState: State<{
|
|
42
|
+
request: {
|
|
43
|
+
method: string;
|
|
44
|
+
url: string;
|
|
45
|
+
securityType: SecurityTypes;
|
|
46
|
+
security: {
|
|
47
|
+
"Basic Auth": {
|
|
48
|
+
username: string;
|
|
49
|
+
password: string;
|
|
50
|
+
};
|
|
51
|
+
JWT: {
|
|
52
|
+
token: string;
|
|
53
|
+
};
|
|
54
|
+
"API key": {
|
|
55
|
+
location: ApiKeyLocation;
|
|
56
|
+
name: string;
|
|
57
|
+
key: string;
|
|
58
|
+
};
|
|
59
|
+
"OAuth 2.0": {
|
|
60
|
+
grantType: SecurityFlows;
|
|
61
|
+
"Client Credentials": {
|
|
62
|
+
clientId: string;
|
|
63
|
+
clientSecret: string;
|
|
64
|
+
tokenUrl: string;
|
|
65
|
+
accessToken: string;
|
|
66
|
+
};
|
|
67
|
+
"Authorization Code": {
|
|
68
|
+
clientId: string;
|
|
69
|
+
clientSecret: string;
|
|
70
|
+
tokenUrl: string;
|
|
71
|
+
authorizationUrl: string;
|
|
72
|
+
callbackUrl: string;
|
|
73
|
+
scopes: string;
|
|
74
|
+
codeVerifier: string;
|
|
75
|
+
codeChallenge: string;
|
|
76
|
+
accessToken: string;
|
|
77
|
+
};
|
|
78
|
+
Implicit: {
|
|
79
|
+
clientId: string;
|
|
80
|
+
authorizationUrl: string;
|
|
81
|
+
callbackUrl: string;
|
|
82
|
+
scopes: string;
|
|
83
|
+
accessToken: string;
|
|
84
|
+
};
|
|
85
|
+
Password: {
|
|
86
|
+
username: string;
|
|
87
|
+
password: string;
|
|
88
|
+
clientId: string;
|
|
89
|
+
clientSecret: string;
|
|
90
|
+
tokenUrl: string;
|
|
91
|
+
accessToken: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
body: {
|
|
96
|
+
type: string;
|
|
97
|
+
content: string;
|
|
98
|
+
formData: FormDataParam[];
|
|
99
|
+
binary: File | null;
|
|
100
|
+
};
|
|
101
|
+
queryParameters: FormDataParam[];
|
|
102
|
+
headers: FormDataParam[];
|
|
103
|
+
cookies: FormDataParam[];
|
|
104
|
+
};
|
|
105
|
+
response: Response_2 | null;
|
|
106
|
+
history: HistoryItem[];
|
|
107
|
+
saved: SavedItem[];
|
|
108
|
+
operation: Operation | null;
|
|
109
|
+
operationUrl: string | undefined;
|
|
110
|
+
isLinked: boolean;
|
|
111
|
+
environments: Environment[];
|
|
112
|
+
selectedEnvironmentId: string | null;
|
|
113
|
+
corsProxyUrl: string;
|
|
114
|
+
}, {}>;
|
|
115
|
+
|
|
116
|
+
declare type HistoryItem = {
|
|
117
|
+
date: number;
|
|
118
|
+
request: Request_2;
|
|
119
|
+
response: Response | null;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
declare type Operation = {
|
|
123
|
+
name: string;
|
|
124
|
+
method: string;
|
|
125
|
+
path: string;
|
|
126
|
+
parameters: OperationParameter[];
|
|
127
|
+
body?: {
|
|
128
|
+
mediaTypes: {
|
|
129
|
+
[name: string]: {
|
|
130
|
+
name: string;
|
|
131
|
+
examples?: {
|
|
132
|
+
[name: string]: object;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
required?: boolean;
|
|
137
|
+
};
|
|
138
|
+
servers: Server[];
|
|
139
|
+
security?: {
|
|
140
|
+
id: string;
|
|
141
|
+
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
|
|
142
|
+
scopes: string[];
|
|
143
|
+
in?: 'query' | 'header' | 'cookie';
|
|
144
|
+
scheme?: string;
|
|
145
|
+
}[];
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
declare type OperationParameter = {
|
|
149
|
+
name: string;
|
|
150
|
+
in: 'query' | 'header' | 'path' | 'cookie';
|
|
151
|
+
required: boolean;
|
|
152
|
+
description?: string;
|
|
153
|
+
example?: string;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export declare function Replay(options: Partial<ReplayState>): JSX_2.Element;
|
|
157
|
+
|
|
158
|
+
export declare function ReplayOverlay({ onClose, value, corsProxyUrl: corsProxyUrlProp, operationUrl: operationUrlProp, }: {
|
|
159
|
+
onClose: () => void;
|
|
160
|
+
value: Operation;
|
|
161
|
+
operationUrl?: string;
|
|
162
|
+
corsProxyUrl?: string;
|
|
163
|
+
}): JSX_2.Element;
|
|
164
|
+
|
|
165
|
+
export declare type ReplayState = typeof globalState.value;
|
|
166
|
+
|
|
167
|
+
declare type Request_2 = typeof globalState.value.request;
|
|
168
|
+
|
|
169
|
+
declare type Response_2 = {
|
|
170
|
+
headers: [string, string][];
|
|
171
|
+
cookies: [string, string][];
|
|
172
|
+
body: string;
|
|
173
|
+
duration: number;
|
|
174
|
+
size: number;
|
|
175
|
+
status: number;
|
|
176
|
+
bodyUsed: boolean;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
declare type SavedFolder = {
|
|
180
|
+
id: string;
|
|
181
|
+
name: string;
|
|
182
|
+
items: SavedRequest[];
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
declare type SavedItem = {
|
|
186
|
+
type: SavedItemType;
|
|
187
|
+
item: SavedFolder | SavedRequest;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
declare enum SavedItemType {
|
|
191
|
+
Folder = "folder",
|
|
192
|
+
Request = "request"
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
declare type SavedRequest = {
|
|
196
|
+
id: string;
|
|
197
|
+
name: string;
|
|
198
|
+
request: Request;
|
|
199
|
+
response: Response | null;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
declare enum SecurityFlows {
|
|
203
|
+
ClientCredentials = "Client Credentials",
|
|
204
|
+
AuthorizationCode = "Authorization Code",
|
|
205
|
+
Implicit = "Implicit",
|
|
206
|
+
Password = "Password"
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
declare enum SecurityTypes {
|
|
210
|
+
NoAuth = "No Auth",
|
|
211
|
+
BasicAuth = "Basic Auth",
|
|
212
|
+
JWT = "JWT",
|
|
213
|
+
APIKey = "API key",
|
|
214
|
+
OAuth2 = "OAuth 2.0"
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
declare type Server = {
|
|
218
|
+
url: string;
|
|
219
|
+
description?: string;
|
|
220
|
+
variables?: {
|
|
221
|
+
[name: string]: ServerVariable;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
declare type ServerVariable = {
|
|
226
|
+
enum?: string[];
|
|
227
|
+
default: string;
|
|
228
|
+
description?: string;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export { }
|
package/dist/replay.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@redocly/replay",
|
|
3
|
+
"version": "0.0.0-beta-20240215154132",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/replay.cjs",
|
|
6
|
+
"module": "./dist/replay.js",
|
|
7
|
+
"types": "./dist/replay.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/replay.js",
|
|
14
|
+
"require": "./dist/replay.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@redocly/theme": "0.0.0-beta-20240215154132",
|
|
19
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
20
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
21
|
+
"react-router-dom": "^6.21.1",
|
|
22
|
+
"styled-components": "^5.3.11"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@codemirror/lang-html": "^6.4.7",
|
|
26
|
+
"@codemirror/lang-json": "^6.0.1",
|
|
27
|
+
"@codemirror/lang-xml": "^6.0.2",
|
|
28
|
+
"@hookstate/core": "^4.0.1",
|
|
29
|
+
"@lezer/highlight": "^1.1.6",
|
|
30
|
+
"@uiw/codemirror-theme-material": "^4.21.20",
|
|
31
|
+
"@uiw/react-codemirror": "^4.21.20",
|
|
32
|
+
"dayjs": "^1.11.7",
|
|
33
|
+
"rc-tooltip": "^6.1.3",
|
|
34
|
+
"react-resizable-panels": "^1.0.9",
|
|
35
|
+
"styled-components": "^5.3.11"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.9.0",
|
|
39
|
+
"@types/react": "^18.2.37",
|
|
40
|
+
"@types/react-dom": "^18.2.15",
|
|
41
|
+
"@types/styled-components": "5.1.34",
|
|
42
|
+
"@vitejs/plugin-react-swc": "^3.3.2",
|
|
43
|
+
"eslint-plugin-react-refresh": "^0.4.3",
|
|
44
|
+
"typescript": "^5.0.2",
|
|
45
|
+
"vite": "^4.4.5",
|
|
46
|
+
"vite-plugin-dts": "^3.6.3",
|
|
47
|
+
"vite-tsconfig-paths": "^4.2.1"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"start": "vite",
|
|
51
|
+
"build": "npm run clean && vite build && npm run copy-static",
|
|
52
|
+
"copy-static": "cp src/oauth2-redirect-page/oauth2-redirect.html dist",
|
|
53
|
+
"preview": "vite preview",
|
|
54
|
+
"watch": "tsc --build --watch",
|
|
55
|
+
"clean": "rm -rf dist"
|
|
56
|
+
}
|
|
57
|
+
}
|