@redocly/replay 0.19.0-next.6 → 0.19.0-next.8

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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./replay-index-CYED19ue.js");async function r(e,n){await o.invoke("plugin:opener|open_url",{url:e,with:n})}exports.openUrl=r;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./replay-index-CXcBKtqt.js");async function ho(r){const{descriptionPath:t,externalRefResolver:e,base:n}=r,a=await d.bundle({base:n,ref:t,config:r.config,dereference:!0,externalRefResolver:e});if(!a)throw new Error(`Could not find source description file '${t}'.`);return a.bundle.parsed}function Nt(r){if(typeof r!="object")return;const t=Object.keys(r)[0];return t?r[t]?.value:void 0}const go=r=>/\{.*?\}/.test(r);function oe({value:r,ctx:t,logger:e}){if(!r)return r;if(typeof r=="object"){for(const n in r)r[n]=oe({value:r[n],ctx:t,logger:e});return r}return typeof r=="number"||typeof r=="boolean"?r:r.toString().startsWith("$faker.")?De({pointer:r.slice(1),ctx:t,logger:e}):go(r)?$o(r,t,e):vo(r,t,e)}function mo(r,t,e){const n=r.indexOf("{");if(n!==-1){const c=r.substring(n+1).slice(0,-1),f=De({pointer:c.slice(1),ctx:t,logger:e});return f&&r.replace(/{(.*)}/,f)}else return r}function yo(r,t){const e=Object.keys(t),n=Object.values(t);return new Function(...e,`return ${r}`)(...n)}function $o(r,t,e){const n=/\{\$(\{[^{}]*\}|[^{}])*\}/g;let a=r;return a=a.replace(n,(c,f)=>wo(c,t,e)),a}function wo(r,t,e){if(!r.includes("$"))return r;if(r.includes("$faker."))return mo(r,t,e);const n=Fe(t)(Eo(r));return n!==void 0?n:""}const vo=(r,t,e)=>{if(!r)return r;const n=r.toString();if(!n.includes("$"))return r;if(n.startsWith("$file(")&&n.endsWith(")"))return n.slice(7,-2);if(n.startsWith("$sourceDescriptions.")&&n.includes(".workflows.")){const a=n.split("."),c=a[1],f=a[3];if(!c||!f)return;const l=Fe(t)("$sourceDescriptions");return l[c]?l[c].workflows.find(g=>g.workflowId===f):void 0}return n&&n.trim().startsWith("faker.")?De({pointer:n,ctx:t,logger:e}):n?Fe(t)(kt(n)):n.replace(/\$\{([^}]+)}/g,(a,c)=>Fe(t)(kt(c)))};function Eo(r){return r.replace(/\{(.*)\}/,"$1")}function kt(r){return r.replace(/\['(.*?)'\]/g,".$1")}const Fe=(r,t="")=>e=>{if(t||(t=e),!e)return r;const[n,...a]=e.split(".");if(!r)throw Error(`Cannot get ${d.red(n)} from ${d.red(t)}`);if(r?.[n]===void 0){const c=` Undefined ${d.red(n)} at ${d.red(t)}.`,f=Object.keys(r).length?`Did you mean to use another key? Available keys:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./replay-index-CYED19ue.js");async function ho(r){const{descriptionPath:t,externalRefResolver:e,base:n}=r,a=await d.bundle({base:n,ref:t,config:r.config,dereference:!0,externalRefResolver:e});if(!a)throw new Error(`Could not find source description file '${t}'.`);return a.bundle.parsed}function Nt(r){if(typeof r!="object")return;const t=Object.keys(r)[0];return t?r[t]?.value:void 0}const go=r=>/\{.*?\}/.test(r);function oe({value:r,ctx:t,logger:e}){if(!r)return r;if(typeof r=="object"){for(const n in r)r[n]=oe({value:r[n],ctx:t,logger:e});return r}return typeof r=="number"||typeof r=="boolean"?r:r.toString().startsWith("$faker.")?De({pointer:r.slice(1),ctx:t,logger:e}):go(r)?$o(r,t,e):vo(r,t,e)}function mo(r,t,e){const n=r.indexOf("{");if(n!==-1){const c=r.substring(n+1).slice(0,-1),f=De({pointer:c.slice(1),ctx:t,logger:e});return f&&r.replace(/{(.*)}/,f)}else return r}function yo(r,t){const e=Object.keys(t),n=Object.values(t);return new Function(...e,`return ${r}`)(...n)}function $o(r,t,e){const n=/\{\$(\{[^{}]*\}|[^{}])*\}/g;let a=r;return a=a.replace(n,(c,f)=>wo(c,t,e)),a}function wo(r,t,e){if(!r.includes("$"))return r;if(r.includes("$faker."))return mo(r,t,e);const n=Fe(t)(Eo(r));return n!==void 0?n:""}const vo=(r,t,e)=>{if(!r)return r;const n=r.toString();if(!n.includes("$"))return r;if(n.startsWith("$file(")&&n.endsWith(")"))return n.slice(7,-2);if(n.startsWith("$sourceDescriptions.")&&n.includes(".workflows.")){const a=n.split("."),c=a[1],f=a[3];if(!c||!f)return;const l=Fe(t)("$sourceDescriptions");return l[c]?l[c].workflows.find(g=>g.workflowId===f):void 0}return n&&n.trim().startsWith("faker.")?De({pointer:n,ctx:t,logger:e}):n?Fe(t)(kt(n)):n.replace(/\$\{([^}]+)}/g,(a,c)=>Fe(t)(kt(c)))};function Eo(r){return r.replace(/\{(.*)\}/,"$1")}function kt(r){return r.replace(/\['(.*?)'\]/g,".$1")}const Fe=(r,t="")=>e=>{if(t||(t=e),!e)return r;const[n,...a]=e.split(".");if(!r)throw Error(`Cannot get ${d.red(n)} from ${d.red(t)}`);if(r?.[n]===void 0){const c=` Undefined ${d.red(n)} at ${d.red(t)}.`,f=Object.keys(r).length?`Did you mean to use another key? Available keys:
2
2
  ${Object.keys(r).join(", ")}.
3
3
  `:"",l=`${c} ${f}`;throw Error(l)}return Fe(r[n],t)(a.join("."))};function De({pointer:r,ctx:t,logger:e}){const n=r.split("."),a={ctx:{faker:t.$faker}};try{const c=n.map(f=>f.trim()).map((f,l)=>f.endsWith(")")?`${l==0?"":"."}${f}`:`["${f}"]`).join("");return yo(`ctx${c}`,a)}catch(c){e.error(d.red(c.toString()));return}}function jt(r,t,e){if(typeof r=="string"&&r)return oe({value:r,ctx:t,logger:e});if(!(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r>"u"||r instanceof Blob||r===null))for(const n in r)typeof r[n]=="string"?r[n]&&(r[n]=oe({value:r[n],ctx:t,logger:e})):jt(r[n],t,e)}function St(r,t,e){return jt(r,t,e)||r}function Ct(r,t){if(!r)return;const e={};for(const n in t)e[`{${n}}`]=String(t[n]);return r.split(/(\{[a-zA-Z0-9_.-]+\}+)/g).map(n=>e[n]?e[n]:n).join("")}function ko(r){return typeof r=="object"&&r!==null&&"name"in r&&"value"in r&&!("in"in r)}function Ir(r){return typeof r=="object"&&r!==null&&"in"in r&&["header","query","path","cookie"].includes(r.in)}const So=/^image\/(png|jpeg|gif|bmp|webp|svg\+xml)|application\/pdf$/;function Wt(r){return r.startsWith("$file(")&&r.endsWith(")")?r.substring(7,r.length-2):r}const bt=async(r,t,e,n,a)=>{const c=d.pathBrowserifyExports.dirname(n),f=d.pathBrowserifyExports.resolve(c,Wt(e));r.append(t,await a.options.requestFileLoader.getFileBody(f))},qt=(r,t,e,n,a,c)=>{Object.entries(e).forEach(([f,l])=>{const g=c?`${c}[${f}]`:f;typeof l=="string"&&l.startsWith("$file(")&&l.endsWith(")")?r.push(bt(t,g,l,n,a)):Array.isArray(l)?l.forEach(h=>{typeof h=="string"&&h.startsWith("$file(")&&h.endsWith(")")?r.push(bt(t,g,h,n,a)):t.append(g,h.toString())}):typeof l=="object"&&l!==null?qt(r,t,l,n,a,g):(typeof l=="string"||typeof l=="number"||typeof l=="boolean")&&t.append(g,l.toString())})},Co=async(r,t,e,n)=>{if(r&&typeof r=="object"&&!Array.isArray(r)){const a=[];qt(a,t,r,e,n),await Promise.all(a)}},bo=async(r,t)=>{if(typeof r=="string"&&r.startsWith("$file(")&&r.endsWith(")")){const e=d.pathBrowserifyExports.resolve(d.pathBrowserifyExports.dirname(t.options.filePath),Wt(r));return t.options.requestFileLoader.getFileBody(e)}else return r};async function Ao(r,t){if(!r)return{payload:void 0,contentType:void 0,encoding:void 0,replacements:void 0};const{payload:e,contentType:n}=r;if(n==="multipart/form-data"){const a=new FormData,c=d.pathBrowserifyExports.resolve(t.options.filePath);return await Co(e,a,c,t),{...r,payload:a}}else{if(n==="application/octet-stream"||typeof n=="string"&&So.test(n))return{...r,payload:await bo(e,t),contentType:"application/octet-stream"};if(n==="application/x-www-form-urlencoded"&&typeof e=="string")return{...r,payload:Object.fromEntries(new URLSearchParams(e).entries()),contentType:"application/x-www-form-urlencoded"}}return r}function Ro(r){try{return d.parseRuntimeExpression(r)}catch{throw new Error(`Runtime expression is not valid: ${r}`)}}function Oo(r,t){const e=[{pattern:/\$response\.body#\/([\w/]+)/g,ctxFunction:(a,c)=>Te(t.$response?.body,c,a)},{pattern:/\$request\.body#\/([\w/]+)/g,ctxFunction:(a,c)=>Te(t.$request?.body,c,a)},{pattern:/\$outputs\.([\w-]+)#\/([\w/]+)/g,ctxFunction:(a,c,f)=>Te(t.$outputs?.[c],f,a)},{pattern:/\$workflows\.([\w-]+)\.outputs\.([\w-]+)#\/([\w/]+)/g,ctxFunction:(a,c,f,l)=>Te(t.$workflows?.[c]?.outputs?.[f],l,a)},{pattern:/\$steps\.([\w-]+)\.outputs\.([\w-]+)#\/([\w/]+)/g,ctxFunction:(a,c,f,l)=>Te(t.$steps?.[c]?.outputs?.[f],l,a)}];let n=r;for(const{pattern:a,ctxFunction:c}of e)n=n.replaceAll(a,c);return n}function Te(r,t,e){if(r)try{const n=d.pointer.get(r,`/${t}`);return typeof n=="string"||Array.isArray(n)||typeof n=="object"?JSON.stringify(n):n!==void 0?n:e}catch{return e}return e}function re({payload:r,context:t,contentType:e,logger:n}){if(e?.includes("application/octet-stream"))return St(r,t,n);if(e?.includes("multipart/form-data")){if(r instanceof FormData){const a=new FormData;for(const[c,f]of r.entries())if(f instanceof File)a.append(c,f);else{const l=re({payload:f,context:t,logger:n});a.append(c,l)}return a}return St(r,t,n)}return typeof r=="string"?No(r)?ye(r,t,n):Lo(r,t,n):d.isPlainObject(r)?Object.entries(r).reduce((a,[c,f])=>(a[c]=re({payload:f,context:t,logger:n}),a),{}):Array.isArray(r)?r.map(a=>re({payload:a,context:t,logger:n})):r}function ye(r,t,e){return typeof r=="string"?To(r,t,e):d.isPlainObject(r)?Object.entries(r).reduce((n,[a,c])=>(n[a]=c&&ye(c,t,e),n),{}):Array.isArray(r)?r.map(n=>ye(n,t,e)):r}function To(r,t,e){if(/^\$faker\.[a-zA-Z0-9._-]+(\([^\\)]*\))?$/.test(r))return De({pointer:r.slice(1),ctx:t,logger:e});if(r.includes("$faker.")){const c=/\$faker\.[a-zA-Z0-9._-]+(\([^\\)]*\))?/g;r=r.replace(c,f=>De({pointer:f.slice(1),ctx:t,logger:e})).replace(/{(.*?)}/g,"$1")}if(!r.includes("$")&&!/[=<>]/.test(r))return r;Ro(r);const n=_o(r,t),a=Fo(t);try{return new Function(...Object.keys(a),`return ${n};`)(...Object.values(a))}catch{throw new Error(`Error in resolving runtime expression '${r}'.
4
4
  This could be because the expression references a value from a previous failed step, or is trying to reference a variable that hasn't been set.`)}}function Po(r){return r.replace(/\$([a-zA-Z0-9._-]+)/g,(t,e)=>`$${e.replace(/-/g,"_")}`)}function _o(r,t){const e=Oo(r,t),a=Po(e).replace(/{(.*?)}/g,"$1"),c=Do(a),f=/\.header\.([a-zA-Z0-9._-]+)/g;return c.replace(f,(g,h)=>`.header.${h.toLowerCase()}`)}function Fo(r){const t={};for(const[e,n]of Object.entries(r)){const a=e.replace(/-/g,"_");t[a]=Ut(n)}return t}function Ut(r){return Array.isArray(r)?r:typeof r=="object"&&r!==null?Io(r):r}function Io(r){return Object.keys(r).reduce((t,e)=>{const n=e.replace(/-/g,"_");return t[n]=Ut(r[e]),t},{})}function Do(r){return r.replace(/\.(\d+)/g,(t,e,n,a)=>{const c=a[n-1];return/\d/.test(c)?t:`[${e}]`})}function Lo(r,t,e){const n=/\{(?:[^{}]|\{[^{}]*\})*\}|\$[^\s{}]+(?:\([^()]*\))*/g;return r.replace(n,a=>{const c=a.trim(),f=ye(c,t,e);return f!==void 0?f:a})}function No(r){return/^\$[^\s{}]+(\([^)]*\))?$|^\{[^{}]*\}$/.test(r.trim())}function jo({payload:r,replacements:t,expressionContext:e,logger:n}){for(const a of t){const{target:c,value:f}=a;if(typeof c!="string")throw new Error(`Invalid JSON Pointer: ${c}`);try{const l=d.pointer.get(r,c),g=re({payload:f,context:e,logger:n});l!==void 0&&d.pointer.set(r,c,g)}catch{throw new Error(`Invalid JSON Pointer: ${c}`)}}}const Wo=["parameters","failureActions","successActions"];function qo(r,t){const{reference:e,value:n}=r;if(!Wo.some(c=>e.includes(`$components.${c}`)))throw new Error("Invalid reference: available components are $components.parameters, $components.failureActions, or $components.successActions");const a=oe({value:e,ctx:t,logger:t.options.logger});return"value"in a&&n?{...a,value:n}:a}function _e(r,t){return"reference"in r?qo(r,t):r}function Uo(r,t){const e=r?.requestBody?.content||{},[n,a]=Object.entries(e)[0]||[],c=a?.example||Nt(a?.examples)||zt(a?.schema,t),f=zo(r);return{parameters:Bo([...At(r.pathParameters,t),...At(r.parameters,t)]).filter(({value:g})=>g),contentTypeParameters:[...n?[{name:"content-type",in:"header",value:n}]:[],...f?[{name:"accept",in:"header",value:f}]:[]],requestBody:c,contentType:n}}function zo(r){return r?.responses?Array.from(new Set(Object.values(r.responses).flatMap(t=>d.isPlainObject(t)&&"content"in t?Object.keys(t.content||{}):[]))).join(", "):void 0}function At(r,t){return(r||[]).filter(e=>e?.required===!0).map(e=>{if(Ir(e))return{name:e.name,in:e.in,value:Xo(e,t)}}).filter(e=>e!==void 0)}function Bo(r){const t={};for(const e of r)Ir(e)&&(t[(e.name+":"+e.in).toLowerCase()]=e);return Object.values(t)}function xo(r,t){let e,n;if(r.includes("$sourceDescriptions.")){const[,g,h]=r.split(".");e=g,n=h}else r.includes(".")?[e,n]=r.split("."):(n=r,e=Object.keys(t)[0]);const a=Object.keys(t);if(!t[e])throw new Error(`Unknown description name ${d.red(e)} at ${d.red(r)}. Available descriptions: ${a.join(", ")}.`);const c=t[e],f=c?.components?.securitySchemes,l=c.servers;for(const[g,h]of Object.entries(t[e].paths)){if(!h)return;for(const[y,w]of Object.entries(h))if(w.operationId===n)return{servers:h.servers||l,...w,pathParameters:w.parameters||[],path:g,method:y,descriptionName:e,securitySchemes:f}}throw new Error(`Unknown operationId ${d.red(n)} at ${d.red(r)}.`)}function Mo(r,t){const{$sourceDescriptions:e,sourceDescriptions:n}=t,[a,c]=r.split("#");if(!n)throw new Error("Missing described sourceDescriptions");const f=n.find(P=>{if(["openapi","arazzo"].includes(P.type)){if(a.includes("$sourceDescriptions.")){const[,N]=a.split(".");return P.name===N}return"url"in P&&P.url===a}return!1})?.name;if(!f)throw new Error(`Unknown operationPath ${d.red(r)}. API description ${d.red(a)} is not listed in 'sourceDescriptions' workflow section.`);const l=e[f]||{},g=l?.components?.securitySchemes,[h,y,w]=d.pointer.parse(c);if(h!=="paths")throw new Error(`Invalid fragment identifier: ${c} at operationPath ${d.red(r)}.`);const{servers:k}=l,C=d.pointer.get(l,c)||{},j=d.pointer.get(l,d.pointer.compile(["paths",y]))||{};return{servers:j.servers||k,...C,pathParameters:j.parameters||[],path:y,method:w,descriptionName:f,securitySchemes:g}}function Vo(r,t){if(!r.operationId&&!r.operationPath)return;const{$sourceDescriptions:e,sourceDescriptions:n}=t,{operationId:a,operationPath:c}=r;return a?xo(a,e):c?Mo(c,{$sourceDescriptions:e,sourceDescriptions:n}):void 0}function Ko({statusCode:r,contentType:t,descriptionResponses:e}){return e?(e[r]||e.default)?.content?.[t]?.schema:void 0}function Ho(r,t){if(!t)return;const n=t.requestBody?.content;return n&&n[r]?.schema||void 0}const Jo={title:"[REPLACE WITH API title]",version:"[REPLACE WITH API version]"};function zt(r,t){if(r)try{return d.sample(r,{skipReadOnly:!0,skipNonRequired:!1,quiet:!0})}catch(e){t.error(d.bgRed(" Error while generating test data from JSON Schema ")+`
@@ -1,4 +1,4 @@
1
- import { V as n } from "./replay-index-D-NcP33L.js";
1
+ import { V as n } from "./replay-index-CiAfmODL.js";
2
2
  async function r(e = {}) {
3
3
  return typeof e == "object" && Object.freeze(e), await n("plugin:dialog|open", { options: e });
4
4
  }
@@ -0,0 +1,4 @@
1
+ "use strict";const d="Something went wrong, please, try again.";function h(r){return r&&r.replace(/=+$/,"")}function m(r,e){return!!r&&!!e&&h(r)===h(e)}const w={invalid_request:"The request is missing a required parameter, includes an unsupported parameter value (other than grant type), repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.",invalid_client:"Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).",invalid_grant:"The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",unauthorized_client:"The authenticated client is not authorized to use this authorization grant type.",unsupported_grant_type:"The authorization grant type is not supported by the authorization server.",invalid_scope:"The requested scope is invalid, unknown, malformed, or exceeds the scope granted by the resource owner.",unsupported_response_type:"The requested response type is not supported by the authorization server.",access_denied:"The resource owner or authorization server denied the request.",server_error:"The authorization server encountered an unexpected condition.",temporarily_unavailable:"The authorization server is currently unable to handle the request due to a temporary overloading or maintenance."};class n extends Error{error;error_description;constructor({message:e,error:t,error_description:i}){const o=i||t&&w[t]||t||e||d;super(o),this.name="OAuth2Error",this.error=t,this.error_description=i}static fromJsonData(e){return e.error&&typeof e.error=="object"?new n({message:e.error.message}):new n({error:e.error,error_description:e.error_description})}static fromTextData(e){return new n({message:e})}static fromError(e){return new n({error:e.message})}}function y(r,e){let t;const i=e?new URL(e):window.location;if(/code|token|error/.test(i.hash)?t=i.hash.substring(1):t=i.search.substring(1),!t)throw console.error("No query string in OAuth 2 redirect URL"),new n({message:d});const o=new URLSearchParams(t),s=o.get("access_token"),a=o.get("code"),c=o.get("token_type"),l=o.get("expires_in"),p=o.get("state"),u=o.get("error"),g=o.get("error_description");if(u)throw new n({error:u,error_description:g??void 0});if(!m(p,r?.state))throw new Error("Outdated OAuth2 state");if(r?.flow==="implicit"){if(!s)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(!c)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.`);r?.successCallback({access_token:s,token_type:c,expires_in:l,auth_code:""})}if(r?.flow==="authorizationCode"){if(!a)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.`);r?.successCallback({auth_code:a,access_token:"",token_type:"bearer"})}}exports.OAuth2Error=n;exports.handleOAuth2Redirect=y;
@@ -0,0 +1,99 @@
1
+ const d = "Something went wrong, please, try again.";
2
+ function h(r) {
3
+ return r && r.replace(/=+$/, "");
4
+ }
5
+ function m(r, e) {
6
+ return !!r && !!e && h(r) === h(e);
7
+ }
8
+ const w = {
9
+ invalid_request: "The request is missing a required parameter, includes an unsupported parameter value (other than grant type), repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.",
10
+ invalid_client: "Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).",
11
+ invalid_grant: "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
12
+ unauthorized_client: "The authenticated client is not authorized to use this authorization grant type.",
13
+ unsupported_grant_type: "The authorization grant type is not supported by the authorization server.",
14
+ invalid_scope: "The requested scope is invalid, unknown, malformed, or exceeds the scope granted by the resource owner.",
15
+ // Authorization endpoint errors (from RFC 6749 Section 4.1.2.1)
16
+ unsupported_response_type: "The requested response type is not supported by the authorization server.",
17
+ access_denied: "The resource owner or authorization server denied the request.",
18
+ // Token endpoint errors (from RFC 6749 Section 5.2)
19
+ server_error: "The authorization server encountered an unexpected condition.",
20
+ temporarily_unavailable: "The authorization server is currently unable to handle the request due to a temporary overloading or maintenance."
21
+ };
22
+ class n extends Error {
23
+ error;
24
+ error_description;
25
+ constructor({
26
+ message: e,
27
+ error: t,
28
+ error_description: i
29
+ }) {
30
+ const o = i || t && w[t] || t || e || d;
31
+ super(o), this.name = "OAuth2Error", this.error = t, this.error_description = i;
32
+ }
33
+ static fromJsonData(e) {
34
+ return e.error && typeof e.error == "object" ? new n({
35
+ message: e.error.message
36
+ }) : new n({
37
+ error: e.error,
38
+ error_description: e.error_description
39
+ });
40
+ }
41
+ static fromTextData(e) {
42
+ return new n({
43
+ message: e
44
+ });
45
+ }
46
+ static fromError(e) {
47
+ return new n({
48
+ error: e.message
49
+ });
50
+ }
51
+ }
52
+ function y(r, e) {
53
+ let t;
54
+ const i = e ? new URL(e) : window.location;
55
+ if (/code|token|error/.test(i.hash) ? t = i.hash.substring(1) : t = i.search.substring(1), !t)
56
+ throw console.error("No query string in OAuth 2 redirect URL"), new n({ message: d });
57
+ const o = new URLSearchParams(t), s = o.get("access_token"), a = o.get("code"), c = o.get("token_type"), l = o.get("expires_in"), p = o.get("state"), u = o.get("error"), g = o.get("error_description");
58
+ if (u)
59
+ throw new n({
60
+ error: u,
61
+ error_description: g ?? void 0
62
+ });
63
+ if (!m(p, r?.state))
64
+ throw new Error("Outdated OAuth2 state");
65
+ if (r?.flow === "implicit") {
66
+ if (!s)
67
+ throw new Error(
68
+ `Your OAuth2 authentication service provider redirected you without an "access_token".
69
+ Please, try again or make sure your OAuth2 settings are correct.`
70
+ );
71
+ if (!c)
72
+ throw new Error(
73
+ `Your OAuth2 authentication service provider redirected you without a "token_type".
74
+ Please, try again or make sure your OAuth2 settings are correct.`
75
+ );
76
+ r?.successCallback({
77
+ access_token: s,
78
+ token_type: c,
79
+ expires_in: l,
80
+ auth_code: ""
81
+ });
82
+ }
83
+ if (r?.flow === "authorizationCode") {
84
+ if (!a)
85
+ throw new Error(
86
+ `Your OAuth2 authentication service provider redirected you without authorization "code".
87
+ Please, try again or make sure your OAuth2 settings are correct.`
88
+ );
89
+ r?.successCallback({
90
+ auth_code: a,
91
+ access_token: "",
92
+ token_type: "bearer"
93
+ });
94
+ }
95
+ }
96
+ export {
97
+ n as O,
98
+ y as h
99
+ };
@@ -1,5 +1,5 @@
1
- import { s as h, r as i, e as x } from "./replay-index-D-NcP33L.js";
2
- import { d as j, i as b, j as d } from "./replay-index-D-NcP33L.js";
1
+ import { s as h, r as i, e as x } from "./replay-index-CiAfmODL.js";
2
+ import { d as j, i as b, j as d } from "./replay-index-CiAfmODL.js";
3
3
  async function u(n, e) {
4
4
  const t = h(), l = await i(n), c = await i(e), o = l.replace(new RegExp(`^${t}+`), "").split(t).filter(Boolean), r = c.replace(new RegExp(`^${t}+`), "").split(t).filter(Boolean), m = Math.min(o.length, r.length);
5
5
  let s = 0;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./replay-index-CXcBKtqt.js");async function u(r,n){const t=e.sep(),l=await e.resolve(r),c=await e.resolve(n),a=l.replace(new RegExp(`^${t}+`),"").split(t).filter(Boolean),i=c.replace(new RegExp(`^${t}+`),"").split(t).filter(Boolean),m=Math.min(a.length,i.length);let s=0;for(let o=0;o<m&&a[o]===i[o];o++)s++;const p=a.slice(s).map(()=>".."),f=i.slice(s);return[...p,...f].join(t)}async function g(r){const n=await e.extname(r);return n?`.${n}`:""}exports.dirname=e.dirname;exports.isAbsolute=e.isAbsolute;exports.join=e.join;exports.resolve=e.resolve;exports.extname=g;exports.relative=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./replay-index-CYED19ue.js");async function u(r,n){const t=e.sep(),l=await e.resolve(r),c=await e.resolve(n),a=l.replace(new RegExp(`^${t}+`),"").split(t).filter(Boolean),i=c.replace(new RegExp(`^${t}+`),"").split(t).filter(Boolean),m=Math.min(a.length,i.length);let s=0;for(let o=0;o<m&&a[o]===i[o];o++)s++;const p=a.slice(s).map(()=>".."),f=i.slice(s);return[...p,...f].join(t)}async function g(r){const n=await e.extname(r);return n?`.${n}`:""}exports.dirname=e.dirname;exports.isAbsolute=e.isAbsolute;exports.join=e.join;exports.resolve=e.resolve;exports.extname=g;exports.relative=u;
package/dist/replay.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./replay-index-CXcBKtqt.js");exports.EmbeddedReplay=e.EmbeddedReplay;exports.Modal=e.Modal;exports.Replay=e.Replay;exports.ReplayOverlay=e.ReplayOverlay;Object.defineProperty(exports,"SpanStatusCode",{enumerable:!0,get:()=>e.SpanStatusCode});exports.TelemetryClient=e.TelemetryClient;exports.applyThemeToDOM=e.applyThemeToDOM;exports.getCurrentTheme=e.getCurrentTheme;exports.resolveTheme=e.resolveTheme;exports.useTelemetry=e.useTelemetry;exports.useTelemetryClient=e.useTelemetryClient;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./replay-index-CYED19ue.js"),t=require("./replay-oauth2-redirect-handler-Bqw5UUvl.js");exports.EmbeddedReplay=e.EmbeddedReplay;exports.Modal=e.Modal;exports.Replay=e.Replay;exports.ReplayOverlay=e.ReplayOverlay;Object.defineProperty(exports,"SpanStatusCode",{enumerable:!0,get:()=>e.SpanStatusCode});exports.TelemetryClient=e.TelemetryClient;exports.applyThemeToDOM=e.applyThemeToDOM;exports.getCurrentTheme=e.getCurrentTheme;exports.resolveTheme=e.resolveTheme;exports.useTelemetry=e.useTelemetry;exports.useTelemetryClient=e.useTelemetryClient;exports.OAuth2Error=t.OAuth2Error;exports.handleOAuth2Redirect=t.handleOAuth2Redirect;
package/dist/replay.d.ts CHANGED
@@ -62,6 +62,8 @@ export declare function getCurrentTheme(): ResolvedTheme;
62
62
 
63
63
  declare type GetOperationURLFunction = (operationId?: string) => string | undefined;
64
64
 
65
+ export declare function handleOAuth2Redirect(redirectOAuth2Data?: OAuth2RedirectData, urlString?: string): void;
66
+
65
67
  declare type ImplicitOAuthFlowsObject = {
66
68
  authorizationUrl?: string;
67
69
  scopes: Record<string, string>;
@@ -127,6 +129,54 @@ declare type ModalProps = {
127
129
  className?: string;
128
130
  };
129
131
 
132
+ export declare class OAuth2Error extends Error {
133
+ readonly error?: string;
134
+ readonly error_description?: string;
135
+ constructor({ message, error, error_description, }: {
136
+ message?: string;
137
+ error?: string;
138
+ error_description?: string;
139
+ });
140
+ static fromJsonData(data: {
141
+ error?: string | {
142
+ message: string;
143
+ };
144
+ error_description?: string;
145
+ }): OAuth2Error;
146
+ static fromTextData(data: string): OAuth2Error;
147
+ static fromError(error: Error): OAuth2Error;
148
+ }
149
+
150
+ declare interface OAuth2ErrorCallback_2 {
151
+ (error: OAuth2Error): void;
152
+ }
153
+ export { OAuth2ErrorCallback_2 as OAuth2ErrorCallback }
154
+
155
+ declare interface OAuth2RedirectData_2 {
156
+ flow: 'implicit' | 'authorizationCode';
157
+ data: {
158
+ authorizationUrl: string;
159
+ clientId: string;
160
+ scopes?: string[];
161
+ };
162
+ state: string;
163
+ successCallback: OAuth2SuccessCallback_2;
164
+ errorCallback: OAuth2ErrorCallback_2;
165
+ }
166
+ export { OAuth2RedirectData_2 as OAuth2RedirectData }
167
+
168
+ declare interface OAuth2SuccessCallback_2 {
169
+ ({ access_token, auth_code, token_type, expires_in, refresh_token, created_at, }: {
170
+ access_token: string;
171
+ auth_code: string;
172
+ token_type: string;
173
+ expires_in?: string | null;
174
+ refresh_token?: string;
175
+ created_at?: string;
176
+ }): void;
177
+ }
178
+ export { OAuth2SuccessCallback_2 as OAuth2SuccessCallback }
179
+
130
180
  declare type OAuthFlowsObject = {
131
181
  implicit?: ImplicitOAuthFlowsObject;
132
182
  password?: PasswordOAuthFlowsObject;
package/dist/replay.js CHANGED
@@ -1,14 +1,17 @@
1
- import { W as s, X as l, Y as t, Z as r, _ as m, a2 as y, a0 as p, a1 as T, $ as o, a3 as d, a4 as n } from "./replay-index-D-NcP33L.js";
1
+ import { W as s, X as r, Y as t, Z as l, _ as m, a2 as o, a0 as p, a1 as y, $ as d, a3 as h, a4 as T } from "./replay-index-CiAfmODL.js";
2
+ import { O as n, h as O } from "./replay-oauth2-redirect-handler-CqKZB3aV.js";
2
3
  export {
3
4
  s as EmbeddedReplay,
4
- l as Modal,
5
+ r as Modal,
6
+ n as OAuth2Error,
5
7
  t as Replay,
6
- r as ReplayOverlay,
8
+ l as ReplayOverlay,
7
9
  m as SpanStatusCode,
8
- y as TelemetryClient,
10
+ o as TelemetryClient,
9
11
  p as applyThemeToDOM,
10
- T as getCurrentTheme,
11
- o as resolveTheme,
12
- d as useTelemetry,
13
- n as useTelemetryClient
12
+ y as getCurrentTheme,
13
+ O as handleOAuth2Redirect,
14
+ d as resolveTheme,
15
+ h as useTelemetry,
16
+ T as useTelemetryClient
14
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/replay",
3
- "version": "0.19.0-next.6",
3
+ "version": "0.19.0-next.8",
4
4
  "type": "module",
5
5
  "main": "./dist/replay.cjs",
6
6
  "module": "./dist/replay.js",
@@ -19,7 +19,7 @@
19
19
  "react-dom": "^19.1.0",
20
20
  "react-router-dom": "^6.21.1",
21
21
  "styled-components": "^5.3.11",
22
- "@redocly/theme": "0.60.0-next.5"
22
+ "@redocly/theme": "0.60.0-next.6"
23
23
  },
24
24
  "dependencies": {
25
25
  "@codemirror/autocomplete": "^6.15.0",
@@ -42,12 +42,13 @@
42
42
  "@redocly/hookstate-core": "^4.2.1",
43
43
  "@redocly/hookstate-devtools": "^4.2.0",
44
44
  "@redocly/hookstate-localstored": "^4.0.2",
45
- "@redocly/openapi-core": "2.11.1",
46
- "@redocly/respect-core": "2.11.1",
45
+ "@redocly/openapi-core": "2.12.1",
46
+ "@redocly/respect-core": "2.12.1",
47
47
  "@redocly/vscode-json-languageservice": "^3.4.9",
48
48
  "@tauri-apps/api": "2.4.1",
49
49
  "@tauri-apps/plugin-dialog": "2.0.0-rc.1",
50
50
  "@tauri-apps/plugin-fs": "2.0.0-rc.2",
51
+ "@tauri-apps/plugin-opener": "^2.2.6",
51
52
  "@uiw/codemirror-theme-material": "^4.21.20",
52
53
  "@uiw/react-codemirror": "^4.21.20",
53
54
  "dayjs": "^1.11.7",
@@ -82,7 +83,7 @@
82
83
  "@types/react": "^19.1.4",
83
84
  "@types/react-dom": "^19.1.4",
84
85
  "@types/styled-components": "5.1.34",
85
- "@vitejs/plugin-react-swc": "^4.0.0",
86
+ "@vitejs/plugin-react-swc": "4.2.2",
86
87
  "babel-jest": "29.7.0",
87
88
  "identity-obj-proxy": "3.0.0",
88
89
  "jest": "^29.7.0",
@@ -91,7 +92,7 @@
91
92
  "ts-jest": "^29.1.2",
92
93
  "ts-node": "10.9.2",
93
94
  "typescript": "5.9.3",
94
- "vite": "7.1.9",
95
+ "vite": "7.2.6",
95
96
  "vite-plugin-dts": "4.5.4",
96
97
  "vite-tsconfig-paths": "4.3.2",
97
98
  "@redocly/replay-asyncapi-sdk": "0.0.1"