@redocly/redoc-revel 0.141.0-next.19 → 0.141.0-next.20
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/CHANGELOG.md +22 -0
- package/dist/client/app/hooks/products/useProducts.d.ts +2 -0
- package/dist/client/providers/post-message/PostMessageConnection.d.ts +1 -1
- package/dist/client/providers/post-message/PostMessageProvider.d.ts +1 -1
- package/dist/client/providers/post-message/use-post-message.d.ts +1 -1
- package/dist/compiled/@redocly/platform-utils/pii/index.mjs +1 -0
- package/dist/compiled/@redocly/platform-utils/pii/package.json +1 -0
- package/dist/markdoc/nodes/table.js +1 -1
- package/dist/server/plugins/default-theme/resolve-products-config.d.ts +1 -0
- package/dist/server/plugins/default-theme/resolve-products-config.js +1 -1
- package/dist/server/tools/notifiers/formatter.js +1 -1
- package/dist/server/utils/product.d.ts +1 -0
- package/package.json +9 -6
- package/dist/compiled/@redocly/pii/index.mjs +0 -1
- package/dist/compiled/@redocly/pii/package.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @redocly/redoc-revel
|
|
2
2
|
|
|
3
|
+
## 0.141.0-next.20
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8580b8c90fd: Added the `nameTranslationKey` option to `products` in `redocly.yaml` to translate product names in the product picker, mobile menu, and search.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 5b602a8e91c: Fixed an issue where a list at the start of a Markdoc `table` cell appeared lower than the content of the other cells in the row.
|
|
12
|
+
- e2aed09a734: Fixed an issue in the **Try it** console where query parameter, header and cookie names that contained runtime expressions were sent unresolved.
|
|
13
|
+
- Updated dependencies [c50a3e97b7c]
|
|
14
|
+
- Updated dependencies [9fb3b464348]
|
|
15
|
+
- Updated dependencies [f60348b619c]
|
|
16
|
+
- Updated dependencies [c156135717c]
|
|
17
|
+
- Updated dependencies [5b602a8e91c]
|
|
18
|
+
- Updated dependencies [8580b8c90fd]
|
|
19
|
+
- Updated dependencies [927801b2ca7]
|
|
20
|
+
- @redocly/api-docs@0.6.0-next.20
|
|
21
|
+
- @redocly/realm-asyncapi-sdk@0.18.0-next.3
|
|
22
|
+
- @redocly/theme@0.73.0-next.15
|
|
23
|
+
- @redocly/portal-plugin-mock-server@0.26.0-next.6
|
|
24
|
+
|
|
3
25
|
## 0.141.0-next.19
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -2,10 +2,12 @@ export declare const useProducts: () => ({
|
|
|
2
2
|
folder: string;
|
|
3
3
|
icon?: string | undefined;
|
|
4
4
|
name: string;
|
|
5
|
+
nameTranslationKey?: string | undefined;
|
|
5
6
|
} & {
|
|
6
7
|
folder: string;
|
|
7
8
|
icon?: string | undefined;
|
|
8
9
|
name: string;
|
|
10
|
+
nameTranslationKey?: string | undefined;
|
|
9
11
|
} & {
|
|
10
12
|
slug: string;
|
|
11
13
|
link: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PropsWithChildren } from 'react';
|
|
3
|
-
import type { PreviewMessage } from '@redocly/platform-utils';
|
|
3
|
+
import type { PreviewMessage } from '@redocly/platform-utils/post-message';
|
|
4
4
|
type PostMessageProviderValue = {
|
|
5
5
|
sendMessage: (message: PreviewMessage) => void;
|
|
6
6
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function usePostMessage(): {
|
|
2
|
-
sendMessage: (message: import("@redocly/platform-utils").PreviewMessage) => void;
|
|
2
|
+
sendMessage: (message: import("@redocly/platform-utils/post-message").PreviewMessage) => void;
|
|
3
3
|
};
|
|
4
4
|
//# sourceMappingURL=use-post-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=e=>{if(!e||typeof e!="string"||!e.includes("@"))return e;let[r="",t]=e.split("@");return`${r.length>2?r.slice(0,2)+"*".repeat(r.length-2):"*".repeat(r.length)}@${t}`},m=/[a-zA-Z0-9._%+-]/,b=/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/,v=e=>{let r="",t=0,a=0;for(;a<e.length;){let n=e.indexOf("@",a);if(n===-1)break;let d=n;for(;d>t&&m.test(e.charAt(d-1));)d--;let c=d<n?b.exec(e.slice(n+1))?.[0]:void 0;if(!c){a=n+1;continue}let l=n+1+c.length;r+=e.slice(t,d)+o(e.slice(d,l)),t=l,a=l}return r+e.slice(t)},_={email:{pattern:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,replacement:"[email_removed]"},phone:{pattern:/(?:\+?1[-.\s]?)?\(?([0-9]{3})\)?[-.\s]?([0-9]{3})[-.\s]?([0-9]{4})(?:\s?(?:ext|x|extension)\.?\s?(\d+))?/g,replacement:"[phone_removed]"},ssn:{pattern:/\b(?!000|666|9\d{2})\d{3}-?(?!00)\d{2}-?(?!0000)\d{4}\b/g,replacement:"[SSN_removed]"},creditCard:{pattern:/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,replacement:"[credit_card_removed]"},address:{pattern:/\b\d+\s[A-Za-z0-9\s,.-]+(?:Street|St|Avenue|Ave|Road|Rd|Boulevard|Blvd|Lane|Ln|Drive|Dr|Court|Ct|Circle|Cir|Way|Place|Pl|Parkway|Pkwy|Terrace|Ter)\b/gi,replacement:"[address_removed]"},passport:{pattern:/\b[A-Z]{2}[0-9]{7}\b/g,replacement:"[passport_number_removed]"},driversLicense:{pattern:/\b[A-Z]{1,2}[0-9]{6,9}\b/g,replacement:"[driver_license_removed]"},zipCode:{pattern:/(?<!\d-)\b\d{5}(?:-\d{4})?\b(?!-\d)/g,replacement:"[zip_code_removed]"},bankAccount:{pattern:/\b\d{8,17}\b/g,replacement:"[bank_account_removed]"},dateOfBirth:{pattern:/\b(?:0[1-9]|1[0-2])[-/](?:0[1-9]|[12][0-9]|3[01])[-/](?:19|20)\d{2}\b/g,replacement:"[date_removed]"}};function i(e){return typeof e=="string"}function u(e={}){let r={email:{enabled:!0,replacement:"[email_removed]"},phone:{enabled:!0,replacement:"[phone_removed]"},ssn:{enabled:!0,replacement:"[SSN_removed]"},creditCard:{enabled:!0,replacement:"[credit_card_removed]"},address:{enabled:!0,replacement:"[address_removed]"},passport:{enabled:!0,replacement:"[passport_number_removed]"},driversLicense:{enabled:!0,replacement:"[driver_license_removed]"},zipCode:{enabled:!0,replacement:"[zip_code_removed]"},bankAccount:{enabled:!0,replacement:"[bank_account_removed]"},dateOfBirth:{enabled:!0,replacement:"[date_removed]"}};for(let[t,a]of Object.entries(e))r[t]?r[t]={...r[t],...a}:r[t]=a;return r}function s(e,r={}){if(!i(e))return e;let t=u(r),a=e;for(let[n,d]of Object.entries(t)){if(!d.enabled)continue;let c=_[n],l=c?.pattern||d.pattern,p=d.replacement||c?.replacement||"[PII removed]";l&&(a=a.replace(l,p))}return a}function f(e){if(!i(e))return e;try{let r=new URL(e,"http://example.com");for(let[t,a]of r.searchParams.entries()){let n=String(s(a));r.searchParams.set(t,n)}return e.startsWith("http://")||e.startsWith("https://")?r.toString():r.pathname+r.search+r.hash}catch{return String(s(e))}}export{o as maskEmail,v as maskSubject,s as removePii,f as removePiiFromUrl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@redocly/platform-utils","main":"index.mjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from"@redocly/markdoc";import{MARKDOWN_CLASS_NAME as u}from"@redocly/theme/core/constants";import{isTag as i}from"../helpers/guards/is-tag.js";import{getInnerText as f}from"../helpers/get-inner-text.js";const T={transform(t,e){const{class:a,...s}=t.transformAttributes(e),n=t.transformChildren(e);return new r.Tag("div",{className:"md-table-wrapper"},[new r.Tag("table",{...s,className:[u,a].filter(Boolean).join(" ")},b(n))])}},m={type:String,matches:["top","middle","bottom"],render:"vAlign"},A={...r.nodes.td,attributes:{...r.nodes.td.attributes,valign:m},transform:o},C={...r.nodes.th,attributes:{...r.nodes.th.attributes,valign:m},transform:o};function o(t,e){const a=t.transformChildren(e);return new r.Tag(t.type,t.transformAttributes(e),a.some(p)?a.map(h):a)}function p(t){return i(t)&&(t.name==="ul"||t.name==="ol")}function h(t){return typeof t=="string"&&t.trim()?new r.Tag("span",{},[t]):t}function b(t){if(!t.length)return t;const[e,...a]=t;return!i(e)||e.name!=="thead"?t:[new r.Tag("thead",e.attributes,e.children.map(s=>!i(s)||s.name!=="tr"?s:new r.Tag("tr",s.attributes,s.children.map(n=>!i(n)||n.name!=="th"?n:new r.Tag("th",{...n.attributes,"data-label":f(n.children)},n.children))))),...a]}export{T as table,A as td,C as th};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import f from"path";import{productConfigOverrideSchema as A,REDOCLY_TEAMS_RBAC as O,REDOCLY_ROUTE_RBAC as S}from"@redocly/config";import{CONFIG_FILE_NAME as b}from"../../../constants/common.js";import{findDeepFirst as B}from"../../../utils/tree/find-deep-first.js";import{removeTrailingSlash as D}from"../../../utils/url/remove-trailing-slash.js";import{addTrailingSlash as E}from"../../../utils/url/add-trailing-slash.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{logger as F}from"../../tools/notifiers/logger.js";import{FileNotFoundError as I,resolveAssetPath as _}from"../../utils/index.js";import{safeParsePartial as j}from"../config-parser/safe-parse.js";import{resolveLinksFromConfig as v,resolveItems as $}from"../nav-utils.js";import{resolveLogoConfig as T}from"./resolve-logo.js";import{pickUiAccessibleConfig as z}from"./index.js";import{getExcludedFromLinkCheckerPatterns as N}from"../sidebars/utils.js";const ie=async(o,e,r)=>{if(!o)return;const n={};for(const t of Object.keys(o)){let c;const m=o[t].icon;if(m)try{c=await _(m,r.fs,{fromFileRelativePath:b,contentDir:e.contentDir,outdir:e.outdir})}catch(w){w instanceof I?await k.panicOnBuildContentError(`Could not resolve icon for product "${t}": file ${m} does not exist`):await k.panicOnBuild(`Could not resolve icon for product "${t}": ${w.message}`)}const{name:C,nameTranslationKey:a,folder:d}=o[t],s=f.posix.join(d,"redocly.yaml"),u=r.fs.exists(s)?await r.cache.load(s,"product-config"):void 0,p=u?.data&&j(A,u.data),l=await W(d,r,e);if(!l){await k.panicOnBuild(`Could not resolve first link for product "${t}"`);continue}const P=e.getRouteBySlug(l),g=f.join(e.contentDir,d),i=p&&z(p),y=Object.keys(i?.logo||{}).length>0?await T(i?.logo,s,e.outdir,r.fs):void 0,h=N(e.getConfig()),L={navFile:s,excludedFromLinkCheckerPatterns:h};n[t]={name:C,nameTranslationKey:a,folder:d,icon:c,slug:r.slugify(f.normalize(d)),link:l,configOverride:i&&{logo:Object.keys(y||{}).length>0?y:void 0,navbar:await v(i.navbar,g,e,r,L),footer:await v(i.footer,g,e,r,L),feedback:i.feedback,sidebar:i.sidebar,search:i.search&&{...i.search,suggestedPages:await v(i.search?.suggestedPages,g,e,r,{navFile:b,excludedFromLinkCheckerPatterns:h})},codeSnippet:i.codeSnippet,breadcrumbs:i.breadcrumbs&&{...i.breadcrumbs,prefixItems:await v(i.breadcrumbs?.prefixItems||[],g,e,r,{navFile:b,excludedFromLinkCheckerPatterns:h})},palette:i.palette,analytics:i.analytics,mockServer:i.mockServer},[O]:P?.[O],[S]:P?.[S]},F.verbose(`Resolved config for product "${t}"`)}return n};async function W(o,e,r){const n=E(f.posix.normalize(o)),t=D(e.slugify(f.normalize(o))),c=r.getRouteBySlug(t);if(c&&c.fsPath.startsWith(n))return c.slug;const m=e.fs.scan(/sidebars\.yaml$/).filter(u=>u.relativePath.startsWith(n)),a=U(m)[0]?.relativePath;if(a){const u=await e.cache.load(a,"yaml"),p=await $(u.data,f.dirname(a),r,e,{navFile:a}),l=R(p);if(l)return F.verbose(`Found product first link "${l}" in sidebar "${a}"`),l}const d=await $([{directory:`${n}`}],f.dirname("sidebars.yaml"),r,e,{navFile:"sidebars.yaml"}),s=R(d);return s&&F.verbose(`Found product first link "${s}" in product folder "${n}"`),s}function R(o){return(o?B(o,r=>!!r.link):void 0)?.link}function U(o){return o.sort((e,r)=>{const n=e.relativePath.split("/").length,t=r.relativePath.split("/").length;return n!==t?n-t:e.relativePath.localeCompare(r.relativePath,void 0,{numeric:!0})})}export{W as getProductFirstLink,ie as resolveProductsConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import*as E from"node:path";import{envConfig as R}from"../../config/env-config.js";import{maskEmail as T,maskSubject as C,removePii as w,removePiiFromUrl as $}from"../../../compiled/@redocly/pii/index.mjs";import{red as x,green as A,bold as F,blue as l,gray as r,yellow as b,cyan as v}from"./helpers/colors.js";function P(e,s){return s?e:w(e)}var n;(function(e){e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.SUCCESS="SUCCESS",e.VERBOSE="VERBOSE",e.HTTP="HTTP"})(n||(n={}));const I={[n.VERBOSE]:0,[n.HTTP]:1,[n.INFO]:2,[n.SUCCESS]:2,[n.WARN]:3,[n.ERROR]:4};function J(e,s){return I[e]>=I[s]}function W(e){if(!e)return;const s=e.toUpperCase();if(s in n)return s}const H={[n.INFO]:l,[n.SUCCESS]:A,[n.WARN]:b,[n.ERROR]:x,[n.HTTP]:v,[n.VERBOSE]:r},N={"%ap":e=>l(E.resolve(e)),"%rp":e=>l(E.relative(process.cwd(),e)),"%s":e=>e?.toString(),"%c":e=>l(e)},M={format(e){return R.REDOCLY_LOG_FORMAT==="JSON"?y(e):U(e)},interpolate(e,...s){const u=Object.keys(N).map(a=>`(${a})`).join("|"),o=new RegExp(u,"g");let i,c=e;for(;(i=o.exec(e))!==null;){i.index===o.lastIndex&&o.lastIndex++;const a=s.shift();if(a===void 0)break;const t=i[0];c=c.replace(t,N[t](a))}return c}};var z=M;const U=e=>{const{level:s,message:u,duration:o,context:i,preSanitized:c}=e,a=R.isRuntimeMode,t=[H[s](F(`[${s.toLowerCase()}]`))];if(a&&t.push(r(`time="${j()}"`)),i){const{email:m,ipAddress:f,subject:d,method:S,pathname:p,statusCode:h,teams:g,apiFunction:O}=i;O&&t.push(l(`fn="${O}"`)),h&&t.push(D(h)),e.level===n.HTTP&&(S&&t.push(r(`method="${S}"`)),p&&t.push(r(`path="${$(p)}"`))),f&&t.push(r(`ip="${f}"`)),m&&t.push(r(`email="${T(m)}"`)),d&&t.push(r(`sub="${C(d)}"`)),g?.length&&t.push(r(`teams="${g.join(", ")}"`))}if(u){const m=a?`msg="${String(P(u,c)).replaceAll?.('"','\\"')}"`:String(u);t.push(m)}return e.level===n.HTTP&&i?.userAgent&&t.push(r(`agent="${i.userAgent}"`)),o&&t.push(V(o)),t.join(" ")+`
|
|
1
|
+
import*as E from"node:path";import{envConfig as R}from"../../config/env-config.js";import{maskEmail as T,maskSubject as C,removePii as w,removePiiFromUrl as $}from"../../../compiled/@redocly/platform-utils/pii/index.mjs";import{red as x,green as A,bold as F,blue as l,gray as r,yellow as b,cyan as v}from"./helpers/colors.js";function P(e,s){return s?e:w(e)}var n;(function(e){e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.SUCCESS="SUCCESS",e.VERBOSE="VERBOSE",e.HTTP="HTTP"})(n||(n={}));const I={[n.VERBOSE]:0,[n.HTTP]:1,[n.INFO]:2,[n.SUCCESS]:2,[n.WARN]:3,[n.ERROR]:4};function J(e,s){return I[e]>=I[s]}function W(e){if(!e)return;const s=e.toUpperCase();if(s in n)return s}const H={[n.INFO]:l,[n.SUCCESS]:A,[n.WARN]:b,[n.ERROR]:x,[n.HTTP]:v,[n.VERBOSE]:r},N={"%ap":e=>l(E.resolve(e)),"%rp":e=>l(E.relative(process.cwd(),e)),"%s":e=>e?.toString(),"%c":e=>l(e)},M={format(e){return R.REDOCLY_LOG_FORMAT==="JSON"?y(e):U(e)},interpolate(e,...s){const u=Object.keys(N).map(a=>`(${a})`).join("|"),o=new RegExp(u,"g");let i,c=e;for(;(i=o.exec(e))!==null;){i.index===o.lastIndex&&o.lastIndex++;const a=s.shift();if(a===void 0)break;const t=i[0];c=c.replace(t,N[t](a))}return c}};var z=M;const U=e=>{const{level:s,message:u,duration:o,context:i,preSanitized:c}=e,a=R.isRuntimeMode,t=[H[s](F(`[${s.toLowerCase()}]`))];if(a&&t.push(r(`time="${j()}"`)),i){const{email:m,ipAddress:f,subject:d,method:S,pathname:p,statusCode:h,teams:g,apiFunction:O}=i;O&&t.push(l(`fn="${O}"`)),h&&t.push(D(h)),e.level===n.HTTP&&(S&&t.push(r(`method="${S}"`)),p&&t.push(r(`path="${$(p)}"`))),f&&t.push(r(`ip="${f}"`)),m&&t.push(r(`email="${T(m)}"`)),d&&t.push(r(`sub="${C(d)}"`)),g?.length&&t.push(r(`teams="${g.join(", ")}"`))}if(u){const m=a?`msg="${String(P(u,c)).replaceAll?.('"','\\"')}"`:String(u);t.push(m)}return e.level===n.HTTP&&i?.userAgent&&t.push(r(`agent="${i.userAgent}"`)),o&&t.push(V(o)),t.join(" ")+`
|
|
2
2
|
`},y=({context:e,message:s,preSanitized:u,...o})=>{const{method:i,pathname:c,statusCode:a,userAgent:t,subject:m,email:f,teams:d,apiFunction:S}=e||{},p={...o,email:f&&T(f),subject:m&&C(m),teams:d,apiFunction:S,...o.level===n.HTTP?{method:i,pathname:String($(c)),statusCode:a,userAgent:t}:{message:String(P(String(s??""),u))}};return R.isRuntimeMode&&(p.time=j()),JSON.stringify(p,["time","level","scope","message","duration","method","pathname","statusCode","userAgent","subject","ipAddress","email","apiFunction"])+`
|
|
3
3
|
`},D=e=>(e%500<100?x:e%400<100?b:A)(`status="${e}"`),j=()=>{const e=new Date().getTimezoneOffset()*6e4;return new Date(Date.now()-e).toISOString().slice(0,-1)},V=e=>r(`dur="${Math.round(e)}ms"`);export{n as LogLevel,z as default,W as parseLogLevel,J as shouldLog};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/redoc-revel",
|
|
3
|
-
"version": "0.141.0-next.
|
|
3
|
+
"version": "0.141.0-next.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"@opentelemetry/sdk-trace-web": "2.8.0",
|
|
34
34
|
"@opentelemetry/semantic-conventions": "1.40.0",
|
|
35
35
|
"@redocly/ajv": "8.18.0",
|
|
36
|
-
"@redocly/api-docs": "0.6.0-next.
|
|
37
|
-
"@redocly/config": "0.
|
|
36
|
+
"@redocly/api-docs": "0.6.0-next.20",
|
|
37
|
+
"@redocly/config": "0.77.0",
|
|
38
38
|
"@redocly/markdoc": "0.7.1",
|
|
39
39
|
"@redocly/openapi-core": "2.81.0",
|
|
40
40
|
"@redocly/portal-legacy-ui": "0.19.0",
|
|
41
|
-
"@redocly/portal-plugin-mock-server": "0.26.0-next.
|
|
42
|
-
"@redocly/realm-asyncapi-sdk": "0.18.0-next.
|
|
43
|
-
"@redocly/theme": "0.73.0-next.
|
|
41
|
+
"@redocly/portal-plugin-mock-server": "0.26.0-next.6",
|
|
42
|
+
"@redocly/realm-asyncapi-sdk": "0.18.0-next.3",
|
|
43
|
+
"@redocly/theme": "0.73.0-next.15",
|
|
44
44
|
"@shikijs/transformers": "3.21.0",
|
|
45
45
|
"@tanstack/react-query": "5.62.3",
|
|
46
46
|
"@tanstack/react-table": "8.21.3",
|
|
@@ -109,6 +109,9 @@
|
|
|
109
109
|
"@redocly/portal"
|
|
110
110
|
]
|
|
111
111
|
},
|
|
112
|
+
"testInterface": {
|
|
113
|
+
"exempt": "Product package assembled from packages/portal at build time; the source and its tests are in packages/portal."
|
|
114
|
+
},
|
|
112
115
|
"scripts": {
|
|
113
116
|
"clean": "rimraf \"dist\"",
|
|
114
117
|
"compile": "tsgo --build tsconfig.json && tsc-alias -p tsconfig.json",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o=e=>{if(!e||typeof e!="string"||!e.includes("@"))return e;let[r="",t]=e.split("@");return`${r.length>2?r.slice(0,2)+"*".repeat(r.length-2):"*".repeat(r.length)}@${t}`},m=/[a-zA-Z0-9._%+-]/,b=/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/,v=e=>{var r;let t="",a=0,l=0;for(;l<e.length;){let n=e.indexOf("@",l);if(n===-1)break;let d=n;for(;d>a&&m.test(e.charAt(d-1));)d--;let s=d<n?(r=b.exec(e.slice(n+1)))===null||r===void 0?void 0:r[0]:void 0;if(!s){l=n+1;continue}let c=n+1+s.length;t+=e.slice(a,d)+o(e.slice(d,c)),a=c,l=c}return t+e.slice(a)},_={email:{pattern:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,replacement:"[email_removed]"},phone:{pattern:/(?:\+?1[-.\s]?)?\(?([0-9]{3})\)?[-.\s]?([0-9]{3})[-.\s]?([0-9]{4})(?:\s?(?:ext|x|extension)\.?\s?(\d+))?/g,replacement:"[phone_removed]"},ssn:{pattern:/\b(?!000|666|9\d{2})\d{3}-?(?!00)\d{2}-?(?!0000)\d{4}\b/g,replacement:"[SSN_removed]"},creditCard:{pattern:/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,replacement:"[credit_card_removed]"},address:{pattern:/\b\d+\s[A-Za-z0-9\s,.-]+(?:Street|St|Avenue|Ave|Road|Rd|Boulevard|Blvd|Lane|Ln|Drive|Dr|Court|Ct|Circle|Cir|Way|Place|Pl|Parkway|Pkwy|Terrace|Ter)\b/gi,replacement:"[address_removed]"},passport:{pattern:/\b[A-Z]{2}[0-9]{7}\b/g,replacement:"[passport_number_removed]"},driversLicense:{pattern:/\b[A-Z]{1,2}[0-9]{6,9}\b/g,replacement:"[driver_license_removed]"},zipCode:{pattern:/(?<!\d-)\b\d{5}(?:-\d{4})?\b(?!-\d)/g,replacement:"[zip_code_removed]"},bankAccount:{pattern:/\b\d{8,17}\b/g,replacement:"[bank_account_removed]"},dateOfBirth:{pattern:/\b(?:0[1-9]|1[0-2])[-/](?:0[1-9]|[12][0-9]|3[01])[-/](?:19|20)\d{2}\b/g,replacement:"[date_removed]"}};function p(e){return typeof e=="string"}function u(e={}){let r={email:{enabled:!0,replacement:"[email_removed]"},phone:{enabled:!0,replacement:"[phone_removed]"},ssn:{enabled:!0,replacement:"[SSN_removed]"},creditCard:{enabled:!0,replacement:"[credit_card_removed]"},address:{enabled:!0,replacement:"[address_removed]"},passport:{enabled:!0,replacement:"[passport_number_removed]"},driversLicense:{enabled:!0,replacement:"[driver_license_removed]"},zipCode:{enabled:!0,replacement:"[zip_code_removed]"},bankAccount:{enabled:!0,replacement:"[bank_account_removed]"},dateOfBirth:{enabled:!0,replacement:"[date_removed]"}};for(let[t,a]of Object.entries(e))r[t]?r[t]=Object.assign(Object.assign({},r[t]),a):r[t]=a;return r}function i(e,r={}){if(!p(e))return e;let t=u(r),a=e;for(let[l,n]of Object.entries(t)){if(!n.enabled)continue;let d=_[l],s=d?.pattern||n.pattern,c=n.replacement||d?.replacement||"[PII removed]";s&&(a=a.replace(s,c))}return a}function f(e){if(!p(e))return e;try{let r=new URL(e,"http://example.com");for(let[t,a]of r.searchParams.entries()){let l=String(i(a));r.searchParams.set(t,l)}return e.startsWith("http://")||e.startsWith("https://")?r.toString():r.pathname+r.search+r.hash}catch{return String(i(e))}}export{o as maskEmail,v as maskSubject,i as removePii,f as removePiiFromUrl};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"@redocly/pii","main":"index.mjs"}
|