physicalvalidation 0.1.0 → 0.2.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/README.md +9 -1
- package/dist/cli.js +52 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Search [Physical Validation](https://physicalvalidation.com) for providers and capabilities, or send a request for a person to review. Nothing is sent to a provider automatically. The CLI does not run a model.
|
|
4
4
|
|
|
5
|
-
The npm package name is `physicalvalidation`.
|
|
5
|
+
The npm package name is `physicalvalidation`. Publishing is a manual workflow.
|
|
6
6
|
|
|
7
7
|
Node.js 18 or newer is required.
|
|
8
8
|
|
|
@@ -47,6 +47,14 @@ npx physicalvalidation countries
|
|
|
47
47
|
|
|
48
48
|
`capabilities` is another name for `services`. Company ids come from search and look like `listed:org_example`. Pass `--cursor` with `next_cursor` from a previous `--json` page.
|
|
49
49
|
|
|
50
|
+
## Drafting a request
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx physicalvalidation draft
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Describe your request, or paste the review link from a previous curl draft. The terminal asks for each missing detail in turn. Press Enter to leave a question for later, or type `/done` to get the updated review link. The interview only prepares a draft. You decide whether to submit it on the review page.
|
|
57
|
+
|
|
50
58
|
## Sending a request
|
|
51
59
|
|
|
52
60
|
On a terminal the command shows the request, asks for an email, then beams it:
|
package/dist/cli.js
CHANGED
|
@@ -1,33 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createInterface as
|
|
3
|
-
`}function J(e){let t=y(e),r=b(t.data);if(r.length===0)return`No providers matched that search.
|
|
4
|
-
`;let n=[],i=Je(t);return i!==void 0&&n.push(`${i} ${i===1?"provider":"providers"}`,""),r.forEach((o,a)=>{n.push(`${a+1}. ${d(o.name)||"Provider"}`);let c=[d(o.providerType),d(o.level),Be(o)].filter(Te=>Te.length>0);c.length>0&&n.push(` ${c.join(" \xB7 ")}`);let u=d(o.id);u&&n.push(` ${u}`);let f=K(o.countries);f.length>0&&n.push(` ${f.join(", ")}`);let l=$(o.sites);l&&l!=="0"&&n.push(` ${l} ${l==="1"?"site":"sites"}`);let m=d(o.summary);m&&n.push(` ${m}`);let p=Fe(o.matched);p.length>0&&n.push(` ${p.join(", ")}`);let g=d(o.url);g&&n.push(` ${g}`),n.push("")}),Ve(n,t),typeof t.next_cursor=="string"&&t.next_cursor&&n.push("Another page is available. Run again with --json and pass next_cursor to --cursor."),`${n.join(`
|
|
5
|
-
`).replace(/\n+$/,"")}
|
|
6
|
-
`}function H(e){let t=y(y(e).data);return z(t,"company")}function W(e){let t=y(y(e).data);return z(t,"site")}function X(e,t){let r=b(y(e).data);if(r.length===0)return`Nothing is listed.
|
|
7
|
-
`;if(t==="countries"){let i=["code name sites"];for(let o of r){let a=d(o.code),c=d(o.name),u=$(o.count)||"0";(a||c)&&i.push(`${a.padEnd(5)}${c} ${u}`)}return`${i.join(`
|
|
8
|
-
`)}
|
|
9
|
-
`}return`${r.map(i=>{let o=d(i.slug),a=d(i.name);return o&&a?`${o} \u2014 ${a}`:o||a}).filter(i=>i.length>0).join(`
|
|
10
|
-
`)}
|
|
11
|
-
`}function z(e,t){let r=[];r.push(d(e.name)||(t==="company"?"Company":"Site"));let n=d(e.id);n&&r.push(n);let i=[d(e.providerType),d(e.level)].filter(f=>f.length>0);i.length>0&&r.push(i.join(" \xB7 "));let o=d(e.summary)||Ge(e.published);o&&r.push("",o);let a=K(e.websites);if(a.length>0&&r.push("",...a),t==="site"){let f=Ye(e.company);f&&r.push("",f);let l=F(e.location);l&&r.push(l)}else{let f=b(e.sites);if(f.length===0)r.push("","No sites are listed.");else{r.push("","Sites");for(let l of f.slice(0,20)){let m=d(l.name)||"Site",p=F(l.location);r.push(` ${p?`${p} \u2014 ${m}`:m}`)}f.length>20&&r.push(` ${f.length-20} more. Use --json for the full record.`)}}Ue(r,e.claims),De(r,e.unknowns);let c=d(e.url);c&&r.push("",c);let u=d(e.notice);return u&&r.push("",u),`${r.join(`
|
|
12
|
-
`)}
|
|
13
|
-
`}function Ue(e,t){let r=b(t);if(r.length!==0){e.push("","Claims");for(let n of r.slice(0,15)){let i=d(n.label);if(!i)continue;let o=d(n.scope);e.push(` ${o?`${i} (${o})`:i}`)}r.length>15&&e.push(` ${r.length-15} more. Use --json for the full record.`)}}function De(e,t){if(!Array.isArray(t)||t.length===0)return;let r=t.map(n=>typeof n=="string"?n.trim():h(n)?d(n.label)||d(n.name)||d(n.detail):"").filter(n=>n.length>0);r.length!==0&&e.push("","Unknown",...r.slice(0,10).map(n=>` ${n}`))}function Ve(e,t){let r=h(t.meta)?t.meta:void 0,n=r&&h(r.facets)?r.facets:void 0;if(!n)return;let i=[];for(let[o,a]of Object.entries(n)){let u=b(a).slice(0,8).map(f=>{let l=d(f.label)||d(f.value),m=$(f.count);return l?m?`${l} (${m})`:l:""}).filter(f=>f.length>0);u.length>0&&i.push(` ${o}: ${u.join(", ")}`)}i.length>0&&e.push("Filters",...i,"")}function Be(e){let t=d(e.match),r=d(e.matchedOn);return t&&r?`${t} match on ${r}`:t?`${t} match`:""}function Fe(e){let t=[];for(let r of b(e)){let n=d(r.label);if(n&&!t.includes(n)&&t.push(n),t.length===6)break}return t}function Ge(e){return h(e)?d(e.description):""}function Ye(e){return h(e)?d(e.name):""}function F(e){return h(e)?[d(e.city),d(e.region),d(e.country)||d(e.countryCode)].filter(t=>t.length>0).join(", "):""}function Je(e){if(!h(e.meta))return;let t=e.meta.total;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function y(e){return h(e)?e:{}}function b(e){return Array.isArray(e)?e.filter(h):[]}function K(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function d(e){if(typeof e!="string")return"";let t=e.trim();return!t||G.test(t)?"":t}function $(e){return typeof e=="number"&&Number.isFinite(e)?String(e):""}function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Q(e,t,r){let n=!!t.isTTY;return{color:n&&x(t,r),interactive:!!(e.isTTY&&t.isTTY),show:n,columns:t.columns&&t.columns>20?t.columns:80}}function x(e,t){return t.NO_COLOR||t.TERM==="dumb"?!1:!!e.isTTY}function He(e,t){let r=e%18,n="";for(let i=0;i<14;i+=1){let o=i<=r&&i>r-4;t?o?n+="\x1B[36m\u2501\x1B[0m":n+="\x1B[2m\xB7\x1B[0m":n+=o?"=":"."}return n}function T(e,t,r){if(!e.isTTY)return{stop(){}};let n=!1,i=0,o=()=>{e.write(`\r\x1B[2K${t} ${He(i,r)}`),i+=1};e.write("\x1B[?25l"),o();let a=setInterval(o,70);return a.unref(),{stop(c="clear"){n||(n=!0,clearInterval(a),c==="keep"?e.write(`\r\x1B[2K${t}
|
|
14
|
-
\x1B[?25h`):e.write("\r\x1B[2K\x1B[?25h"))}}}function Z(e,t){let r=We(e,Math.min(t.columns,78)-4);if(t.color){let n="\x1B[2m\u2502\x1B[0m",i=r.split(`
|
|
15
|
-
`).map(o=>`${n} ${o}`);return`
|
|
16
|
-
\x1B[1m\u250C Physical Validation\x1B[0m
|
|
17
|
-
${n}
|
|
18
|
-
${i.join(`
|
|
19
|
-
`)}
|
|
20
|
-
${n}
|
|
21
|
-
`}return`Physical Validation
|
|
22
|
-
|
|
23
|
-
Request:
|
|
24
|
-
${r}
|
|
25
|
-
|
|
26
|
-
`}function S(e,t){return t?`\x1B[31m${e}\x1B[0m
|
|
27
|
-
`:`${e}
|
|
28
|
-
`}function We(e,t){let r=Math.max(20,t),n=[];for(let i of e.split(`
|
|
29
|
-
`)){let o=i;if(o.length<=r){n.push(o);continue}for(;o.length>r;){let a=o.lastIndexOf(" ",r);a<=0&&(a=r),n.push(o.slice(0,a).trimEnd()),o=o.slice(a).trimStart()}n.push(o)}return n.join(`
|
|
30
|
-
`)}var Xe=/^(?:provider|archive|listed):[A-Za-z0-9_-]{1,120}$/;async function ee(e,t,r,n){e.command==="company"&&te(e.id),e.command==="site"&&ne(e.id);let i=e.command==="search"?"Searching Physical Validation...":"Loading from Physical Validation...",o=T(t.stdout,i,n.color);try{let a=await ze(e,r);return o.stop(),t.stdout.write(Ke(e,a)),0}catch(a){throw o.stop(),a}}async function ze(e,t){switch(e.command){case"search":return t.search({...e.query?{q:e.query}:{},service:e.service,type:e.type,country:e.country,region:e.region,modality:e.modality,quality:e.quality,equipment:e.equipment,...e.sort?{sort:e.sort}:{},...e.limit?{limit:e.limit}:{},...e.cursor?{cursor:e.cursor}:{},...e.facets?{facets:!0}:{}});case"company":return t.company(te(e.id));case"site":return t.site(ne(e.id));case"services":return t.services();case"techniques":return t.techniques();case"countries":return t.countries();default:throw new s("See --help for usage.",2,"usage")}}function Ke(e,t){if(e.json)return Y(t);if(e.command==="search")return J(t);if(e.command==="company")return H(t);if(e.command==="site")return W(t);if(e.command==="services"||e.command==="techniques"||e.command==="countries")return X(t,e.command);throw new s("See --help for usage.",2,"usage")}function te(e){if(!e||!Xe.test(e))throw new s("Pass a company id from search, such as listed:org_example.",2,"usage");return e}function ne(e){if(!e||e.length>200||e.includes("/")||e.includes("\\")||e.includes(".."))throw new s("Pass the site id from a company lookup.",2,"usage");if(e.includes("%")||e.includes("?")||e.includes("#")||/\s/.test(e))throw new s("Pass the site id from a company lookup.",2,"usage");return e}import{mkdirSync as Qe,readFileSync as Ze,writeFileSync as et}from"fs";import{tmpdir as tt}from"os";import{join as _}from"path";var C=3e4,re="cooldown.json";function N(e){let t=e.PHYSICALVALIDATION_COOLDOWN_MS;if(t===void 0||t.trim()===""||!/^\d+$/.test(t.trim()))return C;let r=Number(t.trim());return Number.isFinite(r)?r:C}function ie(e){let t=e.PHYSICALVALIDATION_STATE_DIR?.trim();return t||_(tt(),"physicalvalidation")}function oe(e,t=Date.now()){return Math.max(0,se(ie(e))-t)}function I(e,t,r=Date.now()){if(t>0)try{let n=ie(e),i=Math.max(se(n),r+t);Qe(n,{recursive:!0}),et(_(n,re),JSON.stringify({nextAt:i}),{mode:384})}catch{}}function se(e){try{let t=JSON.parse(Ze(_(e,re),"utf8"));return typeof t.nextAt=="number"&&Number.isFinite(t.nextAt)?t.nextAt:0}catch{return 0}}var q="https://physicalvalidation.com/api/v1",ae="Received. A person at Physical Validation will review it. Nothing else happens automatically.",ce="Beaming your request to Physical Validation...",ue="email: ",de="code: ";function L(e){return`physicalvalidation ${e}
|
|
2
|
+
import{createInterface as je}from"readline/promises";var a=class extends Error{exitCode;kind;retryAfterSeconds;constructor(t,r,n,i){super(t),this.name="CliError",this.exitCode=r,this.kind=n,i!==void 0&&(this.retryAfterSeconds=i)}};async function b(e,t){if(e.ask)return e.ask(t);let r=je({input:e.stdin,output:e.stdout});try{return await new Promise((n,i)=>{let o=!1,s=c=>{o||(o=!0,c())};r.once("SIGINT",()=>{s(()=>i(new a("Cancelled.",130,"cancelled")))}),r.once("close",()=>s(()=>i(new a("Interview closed.",130,"cancelled")))),r.question(t).then(c=>s(()=>n(c)),c=>s(()=>i(c)))})}finally{r.close()}}var O="https://physicalvalidation.com/api/v1",X="Received. A person at Physical Validation will review it. Nothing else happens automatically.",K="Beaming your request to Physical Validation...",Q="email: ",Z="code: ";function M(e){return`physicalvalidation ${e}
|
|
31
3
|
|
|
32
4
|
Search providers and capabilities, or send a request for a person to review.
|
|
33
5
|
Nothing is sent to a provider automatically.
|
|
@@ -39,6 +11,7 @@ Usage:
|
|
|
39
11
|
physicalvalidation services
|
|
40
12
|
physicalvalidation techniques
|
|
41
13
|
physicalvalidation countries
|
|
14
|
+
physicalvalidation draft [brief or review link]
|
|
42
15
|
physicalvalidation "<request>"
|
|
43
16
|
physicalvalidation --email <email> --code <digits> "<request>"
|
|
44
17
|
echo "<request>" | physicalvalidation --email <email> --code <digits>
|
|
@@ -62,7 +35,7 @@ Request options:
|
|
|
62
35
|
--code <digits> 6-digit code. Prompted on a terminal. Required otherwise.
|
|
63
36
|
|
|
64
37
|
Other:
|
|
65
|
-
--api <url> API base URL (default: ${
|
|
38
|
+
--api <url> API base URL (default: ${O})
|
|
66
39
|
-h, --help Show this help
|
|
67
40
|
-V, --version Show the version
|
|
68
41
|
|
|
@@ -78,16 +51,57 @@ Examples:
|
|
|
78
51
|
bunx physicalvalidation "Stability study for an mRNA-LNP, EU site"
|
|
79
52
|
pnpm dlx physicalvalidation "Peptide characterization, GMP, US"
|
|
80
53
|
|
|
81
|
-
|
|
54
|
+
Use draft to answer one question at a time and get a review link.
|
|
55
|
+
|
|
56
|
+
Without a subcommand, a request shows the text, asks for an email, then asks for the
|
|
82
57
|
6-digit code from that email. Up to five code attempts are allowed. The only
|
|
83
58
|
data sent is the request text, that email, and that code. The CLI does not
|
|
84
59
|
run a model. A person at Physical Validation reviews the request.
|
|
85
|
-
`}var
|
|
86
|
-
`)
|
|
60
|
+
`}var A="\x1B[?1049h",j="\x1B[?1049l",Ue=new RegExp(String.raw`^(?:[ Oo|/\\\r\n-]+|`+"\x1B"+String.raw`\[(?:H|K|(?:0|34|36|90|94|96)m))+`);async function ee(e,t){let r=!1,n=()=>{r&&e.stdout.write(j),r=!1},i;process.once("exit",n);try{let o=await e.fetch(t+"/dna",{headers:{accept:"text/plain"},redirect:"error",signal:AbortSignal.timeout(6e3)});if(!o.ok||!o.headers.get("content-type")?.startsWith("text/plain")||(i=o.body?.getReader(),!i))return;let s="",c=0;for(;;){let{value:u,done:d}=await i.read();if(d||(c+=u.length)>256e3)break;if(s+=Buffer.from(u).toString("latin1"),!r){if(A.startsWith(s)&&s!==A)continue;if(!s.startsWith(A))break;e.stdout.write(A),r=!0,s=s.slice(A.length)}let f=Ue.exec(s)?.[0]??"";if(f&&(e.stdout.write(f),s=s.slice(f.length)),s.startsWith(j)||s&&(!s.startsWith("\x1B")||s.length>=j.length))break}}catch{return}finally{n(),process.removeListener("exit",n),await i?.cancel().catch(()=>{})}}import{createHash as De}from"crypto";import{inflateRawSync as Be}from"zlib";function y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var te=14e5,ne=/^#prepared=1\.d\.([A-Za-z0-9_-]+)\.([a-f0-9]{16})$/;function U(e,t){if(typeof e!="string"||e.length>te+1024)return!1;let r=t+"/request?review=1";return e.startsWith(r)&&ne.test(e.slice(r.length))&&e.trim()===e}function re(e,t){let r=new a("Paste the complete Beacon review link, including its #prepared fragment.",2,"usage");if(!U(e,t))throw r;try{let n=ne.exec(new URL(e).hash),i=Buffer.from(n[1],"base64url");if(De("sha256").update(i).digest("hex").slice(0,16)!==n[2])throw r;let o=JSON.parse(Be(i,{maxOutputLength:te+1024}).toString("utf8"));if(!y(o)||typeof o.fragment!="string")throw r;let s=new URLSearchParams(o.fragment);if(s.get("v")!=="2")throw r;let c=JSON.parse(s.get("input")??"");if(!y(c)||o.estimate!==void 0&&!y(o.estimate))throw r;return{...c,...o.estimate?{estimate:o.estimate}:{}}}catch{throw r}}var Ve=new Set(["json","facets"]),oe=new Set(["service","type","country","region","modality","quality","equipment"]),Fe=new Set(["api","email","code","sort","limit","cursor"]),Ge=new Set(["draft","search","company","site","services","capabilities","techniques","countries"]),Ye=new Set(["relevance","name","completeness"]);function se(e){if(e.some(i=>i==="-h"||i==="--help"))return D({help:!0});if(e.some(i=>i==="-V"||i==="--version"))return D({version:!0});let t=D(),r=[],n=!1;for(let i=0;i<e.length;i+=1){let o=e[i];if(o===void 0)continue;if(o==="--"){r.length===0&&(n=!0),r.push(...e.slice(i+1));break}if(!o.startsWith("-")){r.push(o);continue}if(!o.startsWith("--"))throw new a(`Unknown option: ${o}. See --help for usage.`,2,"usage");let s=o.indexOf("="),c=s===-1?o:o.slice(0,s),u=c.slice(2),d=s===-1?void 0:o.slice(s+1);if(Ve.has(u)){if(d!==void 0)throw new a(`--${u} does not take a value.`,2,"usage");u==="json"&&(t.json=!0),u==="facets"&&(t.facets=!0);continue}if(!oe.has(u)&&!Fe.has(u))throw new a(`Unknown option: ${c}. See --help for usage.`,2,"usage");let f=d;if(f===void 0){let l=e[i+1];if(l===void 0||l.startsWith("-")&&l!=="-")throw new a(`Missing value for --${u}.`,2,"usage");f=l,i+=1}Je(t,u,f)}return He(t,r,n),ze(t),t}function ae(e){let t=(e??O).trim(),r;try{r=new URL(t)}catch{throw new a("Pass an http or https URL to --api.",2,"usage")}if(r.protocol!=="http:"&&r.protocol!=="https:")throw new a("Pass an http or https URL to --api.",2,"usage");if(r.username||r.password)throw new a("The API URL cannot include a username or password.",2,"usage");return r.hash="",r.search="",r.toString().replace(/\/$/,"")}function P(e){return e.length<=254&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function B(e){return/^\d{6}$/.test(e)}function v(e){let t="";for(let r=0;r<e.length;r+=1){let n=e.charCodeAt(r);if(n===27){r=Ke(e,r);continue}n<=8||n===11||n===12||n>=14&&n<=31||n===127||(t+=e[r])}return t.trim()}function D(e={}){return{help:!1,version:!1,json:!1,facets:!1,command:"intake",service:[],type:[],country:[],region:[],modality:[],quality:[],equipment:[],...e}}function Je(e,t,r){if(t==="api"&&(e.api=r),t==="email"&&(e.email=r),t==="code"&&(e.code=r),t==="sort"&&(e.sort=r),t==="limit"&&(e.limit=r),t==="cursor"&&(e.cursor=r),!oe.has(t))return;let n=t==="country"||t==="type"?r.split(","):[r],i=We(e,t);for(let o of n){let s=o.trim();s&&i.push(s)}}function We(e,t){return t==="service"?e.service:t==="type"?e.type:t==="country"?e.country:t==="region"?e.region:t==="modality"?e.modality:t==="quality"?e.quality:e.equipment}function He(e,t,r){let n=t[0];if(!r&&n&&Ge.has(n)){let i=t.slice(1),o=n==="capabilities"?"services":n;if(e.command=o,o==="draft"){i.length&&(e.text=i.join(" "));return}if(o==="search"){let s=i.join(" ").trim();s&&(e.query=s);return}if(o==="company"||o==="site"){if(i.length!==1)throw new a(o==="company"?"Pass one company id. See --help for usage.":"Pass one site id. See --help for usage.",2,"usage");e.id=i[0];return}if(i.length>0)throw new a(`${o} does not take extra text. See --help for usage.`,2,"usage");return}e.command="intake",t.length>0&&(e.text=t.join(" "))}function ze(e){if(e.help||e.version)return;let t=Xe(e);if((e.command==="intake"||e.command==="draft")&&e.json)throw new a("--json is for search and lookup. See --help for usage.",2,"usage");if(e.command!=="search"&&t)throw new a("Those options are for search. See --help for usage.",2,"usage");if(e.command!=="intake"&&(e.email!==void 0||e.code!==void 0))throw new a("--email and --code are only for sending a request. See --help for usage.",2,"usage");if(e.command!=="search")return;let r=e.query??"";if(r.length>500)throw new a(`Keep the search under ${500} characters.`,2,"usage");if(!r&&!t)throw new a("Pass the search text or a filter such as --country US. See --help for usage.",2,"usage");if(e.sort!==void 0){let n=e.sort.toLowerCase();if(!Ye.has(n))throw new a("Pass relevance, name, or completeness to --sort.",2,"usage");e.sort=n}if(e.limit!==void 0&&(!/^\d+$/.test(e.limit)||Number(e.limit)<1||Number(e.limit)>50))throw new a("Pass a page size from 1 to 50 to --limit.",2,"usage");if(e.cursor!==void 0&&(e.cursor.length>4e3||/\s/.test(e.cursor)))throw new a("That page cursor is not valid. Search again without --cursor.",2,"usage");e.country=e.country.map(n=>{if(!/^[A-Za-z]{2}$/.test(n))throw new a("Country codes are two letters, such as US.",2,"usage");return n.toUpperCase()});for(let n of[...e.service,...e.type,...e.region,...e.modality,...e.quality,...e.equipment])if(n.length>200)throw new a("That filter is too long.",2,"usage")}function Xe(e){return e.facets||e.sort!==void 0||e.limit!==void 0||e.cursor!==void 0||e.service.length>0||e.type.length>0||e.country.length>0||e.region.length>0||e.modality.length>0||e.quality.length>0||e.equipment.length>0}function Ke(e,t){if(e[t+1]!=="[")return t;let r=t+2;for(;r<e.length;){let n=e.charCodeAt(r);if(n>=64&&n<=126)return r;r+=1}return e.length-1}var ce=new Set(["need.title","need.description","need.services","pricing.min","pricing.max","pricing.currency","pricing.flexibility","contact.name","contact.email","contact.company","contact.role","estimate.customerType","estimate.region"]),de={"need.services":[["Other","other"],["Peptides","peptide-synthesis"],["Rabbits","rabbit-supply"],["Mice","mouse-supply"],["Genes & plasmids","gene-synthesis"],["Proteins & antibodies","protein-production"],["Sequencing","nucleic-acid-sequencing"]],"estimate.customerType":[["Industry","industry"],["Academic / nonprofit","academic_external"]],"estimate.region":[["United States","us"],["Europe","eu"],["United Kingdom","uk"],["China","cn"],["India","in"]],"pricing.flexibility":[["Firm","firm"],["Flexible","flexible"]]};async function ue(e,t,r){let{data:n}=await e.prepare(t);if(!y(n)||n.submitted!==!1||!y(n.draft)||!y(n.review)||typeof n.review.url!="string"||!U(n.review.url,r)||!Array.isArray(n.missing)||!n.missing.every(i=>y(i)&&typeof i.path=="string"&&typeof i.ask=="string"))throw new a("Beacon returned an unreadable draft.",1,"unexpected");return{url:n.review.url,draft:{...n.draft,...t.estimate?{estimate:t.estimate}:{}},missing:n.missing}}function Qe(e,t,r){let[n,i]=t.split("."),o=r,s=de[t];if(s){let u=s.find(([d,f],l)=>[d.toLowerCase(),f,String(l+1)].includes(r.toLowerCase()));if(u)o=u[1];else if(t!=="need.services")throw new a("Choose one of the listed options.",2,"usage")}if(t==="need.services")return{...e,services:[o]};if(n==="need")return{...e,[i]:o};if(t==="contact.email"&&!P(r))throw new a("Enter a valid email address.",2,"usage");if(t==="pricing.currency"){if(!/^[a-z]{3}$/i.test(r))throw new a("Enter a three-letter currency code, such as USD.",2,"usage");o=r.toUpperCase()}if(t==="pricing.min"||t==="pricing.max"){if(!/^\d+(?:\.\d+)?$/.test(r)||!Number.isFinite(Number(r)))throw new a("Enter a nonnegative amount.",2,"usage");o=Number(r)}let c=e[n];return{...e,[n]:{...y(c)?c:{},[i]:o}}}async function fe(e,t,r,n,i){if(!i.interactive)throw new a("Run physicalvalidation draft in a terminal to answer the questions.",2,"usage");let o=new URL(n).origin,s=(e??await b(t,`Describe your request or paste its Beacon review link
|
|
61
|
+
> `)).trim();for(;!s;)s=(await b(t,`Enter a brief description or paste the review link
|
|
62
|
+
> `)).trim();let c=/^https?:\/\/\S+$/i.test(s);if(!c&&s.length>4e3)throw new a("Keep the initial brief under 4,000 characters.",2,"usage");let u=c?re(s,o):{description:v(s)};!c&&i.color&&(t.stdout.columns??80)>=33&&(t.stdout.rows??24)>=20&&await ee(t,o);let d=await ue(r,u,o),f=new Set;try{for(d.missing.some(l=>ce.has(l.path))&&t.stdout.write(`Press Enter to skip a question, or type /done to review now.
|
|
63
|
+
`);;){let l=d.missing.find(p=>ce.has(p.path)&&!f.has(p.path));if(!l)break;let h=de[l.path]?.map(([p],L)=>`${L+1}) ${p}`).join(" "),w=v(l.ask).replace(/[\s\u0080-\u009f]+/g," "),E=v(await b(t,`${w}
|
|
64
|
+
${h?h+`
|
|
65
|
+
`:""}> `));if(E==="/done")break;if(!E){f.add(l.path);continue}try{let p=await ue(r,Qe(d.draft,l.path,E),o);p.missing.some(L=>L.path===l.path)?t.stderr.write(l.path==="need.services"?`Choose a listed service or enter its Beacon catalogue name.
|
|
66
|
+
`:`Beacon still needs this field. Try another answer or press Enter to skip.
|
|
67
|
+
`):d=p}catch(p){if(!(p instanceof a)||p.kind!=="usage")throw p;t.stderr.write(p.message+`
|
|
68
|
+
`)}}}finally{let l=d.missing.length;t.stdout.write(`
|
|
69
|
+
${l?`${l} unanswered ${l===1?"field":"fields"} to review. `:""}Draft only. Review your request here:
|
|
70
|
+
${d.url}
|
|
71
|
+
`)}return 0}var le=/^unv_[0-9a-f]{32}$/,Ze=1440*60,N=class{base;fetchImpl;version;timeoutMs;constructor(t){this.base=t.base.replace(/\/$/,""),this.fetchImpl=t.fetch,this.version=t.version,this.timeoutMs=t.timeoutMs??2e4}async create(t,r){let n=await this.send("POST","/unvetted-requests",{text:t,email:r},"create"),i=n.id,o=n.status;if(typeof i!="string"||!le.test(i)||o!=="code_sent")throw R();return{id:i,status:"code_sent"}}async verify(t,r){if(!le.test(t)||(await this.send("POST",`/unvetted-requests/${encodeURIComponent(t)}/verify`,{code:r},"verify")).status!=="received")throw R();return{status:"received"}}async search(t){return this.send("GET","/search",void 0,"read",et(t))}async company(t){return this.send("GET",`/companies/${encodeURIComponent(t)}`,void 0,"read")}async site(t){return this.send("GET",`/sites/${encodeURIComponent(t)}`,void 0,"read")}async prepare(t){return this.send("POST","/requests/prepare",t,"draft")}async services(){return this.send("GET","/services",void 0,"read")}async techniques(){return this.send("GET","/techniques",void 0,"read")}async countries(){return this.send("GET","/countries",void 0,"read")}async send(t,r,n,i,o){let s=o&&[...o.keys()].length>0?`${this.base}${r}?${o}`:`${this.base}${r}`,c;try{c=await this.fetchImpl(s,{method:t,redirect:"manual",credentials:"omit",headers:{accept:"application/json","user-agent":`physicalvalidation/${this.version}`,...n?{"content-type":"application/json"}:{}},body:n?JSON.stringify(n):void 0,signal:AbortSignal.timeout(this.timeoutMs)})}catch(d){throw ut(d)}if(c.status>=300&&c.status<400)throw new a("Physical Validation sent an unexpected redirect. Nothing else was sent.",1,"unexpected");let u=await ct(c);if(c.status===429||ot(c.status,u))throw tt(c,u);if(i==="draft"&&(c.status===400||c.status===422))throw new a(V(pe(u))??"Beacon could not use that value.",2,"usage");if(!c.ok)throw it(c.status,u,i);if(!I(u)||i==="read"&&!("data"in u))throw R();return u}};function et(e){let t=new URLSearchParams;return e.q&&t.set("q",e.q),x(t,"service",e.service),x(t,"type",e.type),x(t,"country",e.country),x(t,"region",e.region),x(t,"modality",e.modality),x(t,"quality",e.quality),x(t,"equipment",e.equipment),e.sort&&t.set("sort",e.sort),e.limit&&t.set("limit",e.limit),e.cursor&&t.set("cursor",e.cursor),e.facets&&t.set("facets","true"),t}function x(e,t,r){for(let n of r??[])e.append(t,n)}function R(){return new a("Physical Validation returned an unexpected response. Try again in a moment.",1,"unexpected")}function tt(e,t){let r=rt(e.headers.get("retry-after")),n=F(t),i=nt(r),o=n.toUpperCase()==="TOO_MANY_ATTEMPTS"?"Too many tries.":"Physical Validation is receiving too many requests right now.";return new a(`${o}${i}`,1,"rate_limit",r??60)}function nt(e){return e===void 0?" Wait a minute and try again.":e<1?" Try again in a moment.":e===1?" Try again in 1 second.":` Try again in ${e} seconds.`}function rt(e){let t=e?.trim()??"";if(!t)return;if(/^\d+$/.test(t))return me(Number(t));let r=Date.parse(t);if(!Number.isNaN(r))return me(Math.ceil((r-Date.now())/1e3))}function me(e){return Number.isFinite(e)?Math.min(Math.max(0,e),Ze):0}function it(e,t,r){let n=F(t),i=pe(t);if(e===410||n.toUpperCase()==="EXPIRED")return new a("That code has expired. Run the command again to request a new one.",1,"expired");if(e===409||n.toUpperCase()==="STALE_CURSOR")return new a("That page cursor is out of date. Search again without --cursor.",1,"rejected");if(e===503||n.toUpperCase()==="UNAVAILABLE")return new a("Physical Validation is not taking requests right now. Try again later.",1,"rejected");if(e===404){if(r==="read"){let c=V(i);return new a(c??"Nothing matched that id.",1,"rejected")}return new a(r==="verify"?"That code could not be matched. Run the command again to request a new one.":"Physical Validation is not ready to take that request yet. Try again later.",1,"rejected")}if(e===413)return new a("That request is too long.",2,"usage");if(r==="verify"&&(e===400||e===401||e===403||e===422||/code/i.test(n)))return new a("That code does not match.",1,"invalid_code");let o=V(i),s=e>=500?"Physical Validation had a problem on its side. Try again in a moment.":r==="read"?"Physical Validation did not accept that lookup.":"Physical Validation did not accept that request.";return new a(o?`${s} ${o}`:s,1,"rejected")}function ot(e,t){if(e===429)return!0;let r=F(t);return/^(rate_limited|too_many_requests|rate_limit|too_many_attempts)$/i.test(r)}function V(e){let t=e.replace(/\s+/g," ").trim();if(!(!t||t.length>180||t.includes("@")||at(t))&&!st(t))return t}function st(e){return!!(/price|pricing|\bcost\b|\bfees?\b|\$\s?\d|\b(?:usd|eur|gbp|aud|cad)\b/i.test(e)||/\.(?:ts|tsx|js|mjs|cjs):\d+/.test(e)||/\bat\s+\S+\s+\(/.test(e)||/\bstack\s*trace\b/i.test(e)||/node:internal/.test(e))}function F(e){let t=he(e);return typeof t?.code=="string"?t.code:""}function pe(e){let t=he(e);return typeof t?.message=="string"?t.message:I(e)&&typeof e.message=="string"?e.message:""}function he(e){if(I(e))return I(e.error)?e.error:e}function at(e){for(let t=0;t<e.length;t+=1)if(e.charCodeAt(t)<=31)return!0;return!1}async function ct(e){let t;try{t=await e.text()}catch{return null}if(!t)return null;try{return JSON.parse(t)}catch{return null}}function ut(e){return e instanceof a?e:dt(e)?new a("Physical Validation took too long to respond. Try again in a moment.",1,"network"):new a("Could not reach Physical Validation. Check your connection and try again.",1,"network")}function dt(e){let t=ft(e);if(t==="TimeoutError"||t==="AbortError")return!0;let r=lt(e);return r==="ETIMEDOUT"||r==="UND_ERR_CONNECT_TIMEOUT"||r==="ABORT_ERR"}function ft(e){return e&&typeof e=="object"&&"name"in e&&typeof e.name=="string"?e.name:""}function lt(e){let t=new Set,r=n=>{if(!(!n||typeof n!="object"||t.has(n))){if(t.add(n),"code"in n&&typeof n.code=="string")return n.code;if("errors"in n&&Array.isArray(n.errors))for(let i of n.errors){let o=r(i);if(o)return o}if("cause"in n)return r(n.cause)}};return r(e)}function I(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var mt=/^(?:price|prices|pricing|cost|costs|fee|fees|budget|budgets|quote|quotes|currency)$/i,we=/\$\s?\d|\b\d[\d,.]*\s*(?:usd|eur|gbp|aud|cad)\b/i;function G(e){if(Array.isArray(e))return e.map(G).filter(r=>r!==void 0);if(!g(e))return typeof e=="string"&&we.test(e)?void 0:e;let t={};for(let[r,n]of Object.entries(e)){if(mt.test(r))continue;let i=G(n);i!==void 0&&(t[r]=i)}return t}function ye(e){return`${JSON.stringify(G(e),null,2)}
|
|
72
|
+
`}function be(e){let t=S(e),r=k(t.data);if(r.length===0)return`No providers matched that search.
|
|
73
|
+
`;let n=[],i=vt(t);return i!==void 0&&n.push(`${i} ${i===1?"provider":"providers"}`,""),r.forEach((o,s)=>{n.push(`${s+1}. ${m(o.name)||"Provider"}`);let c=[m(o.providerType),m(o.level),wt(o)].filter(E=>E.length>0);c.length>0&&n.push(` ${c.join(" \xB7 ")}`);let u=m(o.id);u&&n.push(` ${u}`);let d=Te(o.countries);d.length>0&&n.push(` ${d.join(", ")}`);let f=Y(o.sites);f&&f!=="0"&&n.push(` ${f} ${f==="1"?"site":"sites"}`);let l=m(o.summary);l&&n.push(` ${l}`);let h=yt(o.matched);h.length>0&&n.push(` ${h.join(", ")}`);let w=m(o.url);w&&n.push(` ${w}`),n.push("")}),gt(n,t),typeof t.next_cursor=="string"&&t.next_cursor&&n.push("Another page is available. Run again with --json and pass next_cursor to --cursor."),`${n.join(`
|
|
74
|
+
`).replace(/\n+$/,"")}
|
|
75
|
+
`}function xe(e){let t=S(S(e).data);return ke(t,"company")}function ve(e){let t=S(S(e).data);return ke(t,"site")}function Se(e,t){let r=k(S(e).data);if(r.length===0)return`Nothing is listed.
|
|
76
|
+
`;if(t==="countries"){let i=["code name sites"];for(let o of r){let s=m(o.code),c=m(o.name),u=Y(o.count)||"0";(s||c)&&i.push(`${s.padEnd(5)}${c} ${u}`)}return`${i.join(`
|
|
77
|
+
`)}
|
|
78
|
+
`}return`${r.map(i=>{let o=m(i.slug),s=m(i.name);return o&&s?`${o} \u2014 ${s}`:o||s}).filter(i=>i.length>0).join(`
|
|
79
|
+
`)}
|
|
80
|
+
`}function ke(e,t){let r=[];r.push(m(e.name)||(t==="company"?"Company":"Site"));let n=m(e.id);n&&r.push(n);let i=[m(e.providerType),m(e.level)].filter(d=>d.length>0);i.length>0&&r.push(i.join(" \xB7 "));let o=m(e.summary)||bt(e.published);o&&r.push("",o);let s=Te(e.websites);if(s.length>0&&r.push("",...s),t==="site"){let d=xt(e.company);d&&r.push("",d);let f=ge(e.location);f&&r.push(f)}else{let d=k(e.sites);if(d.length===0)r.push("","No sites are listed.");else{r.push("","Sites");for(let f of d.slice(0,20)){let l=m(f.name)||"Site",h=ge(f.location);r.push(` ${h?`${h} \u2014 ${l}`:l}`)}d.length>20&&r.push(` ${d.length-20} more. Use --json for the full record.`)}}pt(r,e.claims),ht(r,e.unknowns);let c=m(e.url);c&&r.push("",c);let u=m(e.notice);return u&&r.push("",u),`${r.join(`
|
|
81
|
+
`)}
|
|
82
|
+
`}function pt(e,t){let r=k(t);if(r.length!==0){e.push("","Claims");for(let n of r.slice(0,15)){let i=m(n.label);if(!i)continue;let o=m(n.scope);e.push(` ${o?`${i} (${o})`:i}`)}r.length>15&&e.push(` ${r.length-15} more. Use --json for the full record.`)}}function ht(e,t){if(!Array.isArray(t)||t.length===0)return;let r=t.map(n=>typeof n=="string"?n.trim():g(n)?m(n.label)||m(n.name)||m(n.detail):"").filter(n=>n.length>0);r.length!==0&&e.push("","Unknown",...r.slice(0,10).map(n=>` ${n}`))}function gt(e,t){let r=g(t.meta)?t.meta:void 0,n=r&&g(r.facets)?r.facets:void 0;if(!n)return;let i=[];for(let[o,s]of Object.entries(n)){let u=k(s).slice(0,8).map(d=>{let f=m(d.label)||m(d.value),l=Y(d.count);return f?l?`${f} (${l})`:f:""}).filter(d=>d.length>0);u.length>0&&i.push(` ${o}: ${u.join(", ")}`)}i.length>0&&e.push("Filters",...i,"")}function wt(e){let t=m(e.match),r=m(e.matchedOn);return t&&r?`${t} match on ${r}`:t?`${t} match`:""}function yt(e){let t=[];for(let r of k(e)){let n=m(r.label);if(n&&!t.includes(n)&&t.push(n),t.length===6)break}return t}function bt(e){return g(e)?m(e.description):""}function xt(e){return g(e)?m(e.name):""}function ge(e){return g(e)?[m(e.city),m(e.region),m(e.country)||m(e.countryCode)].filter(t=>t.length>0).join(", "):""}function vt(e){if(!g(e.meta))return;let t=e.meta.total;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function S(e){return g(e)?e:{}}function k(e){return Array.isArray(e)?e.filter(g):[]}function Te(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function m(e){if(typeof e!="string")return"";let t=e.trim();return!t||we.test(t)?"":t}function Y(e){return typeof e=="number"&&Number.isFinite(e)?String(e):""}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ee(e,t,r){let n=!!t.isTTY;return{color:n&&T(t,r),interactive:!!(e.isTTY&&t.isTTY),show:n,columns:t.columns&&t.columns>20?t.columns:80}}function T(e,t){return t.NO_COLOR||t.TERM==="dumb"?!1:!!e.isTTY}function St(e,t){let r=e%18,n="";for(let i=0;i<14;i+=1){let o=i<=r&&i>r-4;t?o?n+="\x1B[36m\u2501\x1B[0m":n+="\x1B[2m\xB7\x1B[0m":n+=o?"=":"."}return n}function $(e,t,r){if(!e.isTTY)return{stop(){}};let n=!1,i=0,o=()=>{e.write(`\r\x1B[2K${t} ${St(i,r)}`),i+=1};e.write("\x1B[?25l"),o();let s=setInterval(o,70);return s.unref(),{stop(c="clear"){n||(n=!0,clearInterval(s),c==="keep"?e.write(`\r\x1B[2K${t}
|
|
83
|
+
\x1B[?25h`):e.write("\r\x1B[2K\x1B[?25h"))}}}function Ae(e,t){let r=kt(e,Math.min(t.columns,78)-4);if(t.color){let n="\x1B[2m\u2502\x1B[0m",i=r.split(`
|
|
84
|
+
`).map(o=>`${n} ${o}`);return`
|
|
85
|
+
\x1B[1m\u250C Physical Validation\x1B[0m
|
|
86
|
+
${n}
|
|
87
|
+
${i.join(`
|
|
88
|
+
`)}
|
|
89
|
+
${n}
|
|
90
|
+
`}return`Physical Validation
|
|
91
|
+
|
|
92
|
+
Request:
|
|
93
|
+
${r}
|
|
94
|
+
|
|
95
|
+
`}function C(e,t){return t?`\x1B[31m${e}\x1B[0m
|
|
96
|
+
`:`${e}
|
|
97
|
+
`}function kt(e,t){let r=Math.max(20,t),n=[];for(let i of e.split(`
|
|
98
|
+
`)){let o=i;if(o.length<=r){n.push(o);continue}for(;o.length>r;){let s=o.lastIndexOf(" ",r);s<=0&&(s=r),n.push(o.slice(0,s).trimEnd()),o=o.slice(s).trimStart()}n.push(o)}return n.join(`
|
|
99
|
+
`)}var Tt=/^(?:provider|archive|listed):[A-Za-z0-9_-]{1,120}$/;async function Pe(e,t,r,n){e.command==="company"&&Re(e.id),e.command==="site"&&$e(e.id);let i=e.command==="search"?"Searching Physical Validation...":"Loading from Physical Validation...",o=$(t.stdout,i,n.color);try{let s=await Et(e,r);return o.stop(),t.stdout.write(At(e,s)),0}catch(s){throw o.stop(),s}}async function Et(e,t){switch(e.command){case"search":return t.search({...e.query?{q:e.query}:{},service:e.service,type:e.type,country:e.country,region:e.region,modality:e.modality,quality:e.quality,equipment:e.equipment,...e.sort?{sort:e.sort}:{},...e.limit?{limit:e.limit}:{},...e.cursor?{cursor:e.cursor}:{},...e.facets?{facets:!0}:{}});case"company":return t.company(Re(e.id));case"site":return t.site($e(e.id));case"services":return t.services();case"techniques":return t.techniques();case"countries":return t.countries();default:throw new a("See --help for usage.",2,"usage")}}function At(e,t){if(e.json)return ye(t);if(e.command==="search")return be(t);if(e.command==="company")return xe(t);if(e.command==="site")return ve(t);if(e.command==="services"||e.command==="techniques"||e.command==="countries")return Se(t,e.command);throw new a("See --help for usage.",2,"usage")}function Re(e){if(!e||!Tt.test(e))throw new a("Pass a company id from search, such as listed:org_example.",2,"usage");return e}function $e(e){if(!e||e.length>200||e.includes("/")||e.includes("\\")||e.includes(".."))throw new a("Pass the site id from a company lookup.",2,"usage");if(e.includes("%")||e.includes("?")||e.includes("#")||/\s/.test(e))throw new a("Pass the site id from a company lookup.",2,"usage");return e}import{mkdirSync as Pt,readFileSync as Rt,writeFileSync as $t}from"fs";import{tmpdir as Ct}from"os";import{join as W}from"path";var J=3e4,Ce="cooldown.json";function H(e){let t=e.PHYSICALVALIDATION_COOLDOWN_MS;if(t===void 0||t.trim()===""||!/^\d+$/.test(t.trim()))return J;let r=Number(t.trim());return Number.isFinite(r)?r:J}function _e(e){let t=e.PHYSICALVALIDATION_STATE_DIR?.trim();return t||W(Ct(),"physicalvalidation")}function Ne(e,t=Date.now()){return Math.max(0,Ie(_e(e))-t)}function z(e,t,r=Date.now()){if(t>0)try{let n=_e(e),i=Math.max(Ie(n),r+t);Pt(n,{recursive:!0}),$t(W(n,Ce),JSON.stringify({nextAt:i}),{mode:384})}catch{}}function Ie(e){try{let t=JSON.parse(Rt(W(e,Ce),"utf8"));return typeof t.nextAt=="number"&&Number.isFinite(t.nextAt)?t.nextAt:0}catch{return 0}}var _t=350,Nt=64*1024;async function qe(e,t){let r="intake";try{if(e.length===0)return t.stdout.write(M(t.version)),0;let n=se(e);if(r=n.command,n.help)return t.stdout.write(M(t.version)),0;if(n.version)return t.stdout.write(`physicalvalidation ${t.version}
|
|
100
|
+
`),0;let i=Ee(t.stdin,t.stdout,t.env),o=ae(n.api??t.env.PHYSICALVALIDATION_API),s=new N({base:o,fetch:t.fetch,version:t.version});if(n.command==="draft")return await fe(n.text,t,s,o,i);if(n.command!=="intake")return await Pe(n,t,s,i);let c=await qt(n.text,t);It(t.env);let u=Ot(n.email,n.code,i.interactive);i.show&&t.stdout.write(Ae(c,i));let d=u.email??await Mt(t),f=Date.now(),l=$(t.stdout,K,i.color),h;try{h=await s.create(c,d)}catch(w){throw l.stop(),w}if(z(t.env,H(t.env)),i.show){let w=_t-(Date.now()-f);w>0&&await Ut(w)}return l.stop("keep"),i.show&&t.stdout.write(i.color?`\x1B[32mCode sent.\x1B[0m
|
|
87
101
|
`:`Code sent.
|
|
88
|
-
`),await
|
|
89
|
-
`),i.color&&t.stdout.write("\x1B[32m\u2713\x1B[0m "),t.stdout.write(`${
|
|
90
|
-
`),0}catch(n){r==="intake"&&n instanceof
|
|
102
|
+
`),await jt(s,h.id,u.code,t,i),i.show&&t.stdout.write(`
|
|
103
|
+
`),i.color&&t.stdout.write("\x1B[32m\u2713\x1B[0m "),t.stdout.write(`${X}
|
|
104
|
+
`),0}catch(n){r==="intake"&&n instanceof a&&n.kind==="rate_limit"&&n.retryAfterSeconds!==void 0&&z(t.env,Math.max(H(t.env),n.retryAfterSeconds*1e3));let i=n instanceof a?n:new a("Something went wrong. Try again in a moment.",1,"unexpected");return t.stderr.write(C(i.message,T(t.stderr,t.env))),i.exitCode}}function It(e){let t=Ne(e);if(t<=0)return;let r=Math.max(1,Math.ceil(t/1e3)),n=r===1?"second":"seconds";throw new a(`Wait ${r} ${n} before sending another request.`,1,"rate_limit")}async function qt(e,t){let r=e!==void 0?e:t.stdin.isTTY?void 0:await Lt(t.stdin);if(r===void 0)throw new a("Pass the request text, or pipe it on stdin. See --help for usage.",2,"usage");let n=v(r);if(!n)throw new a("The request text is empty.",2,"usage");if(n.length>4e3)throw new a(`The request is too long. Keep it under ${4e3} characters.`,2,"usage");return n}async function Lt(e){let t=[],r=0;for await(let n of e){let i=Buffer.isBuffer(n)?n:Buffer.from(n);if(r+=i.length,r>Nt)throw new a("The request is too long.",2,"usage");t.push(i)}return Buffer.concat(t).toString("utf8")}function Ot(e,t,r){let n=e?.trim(),i=t?.trim();if(e!==void 0&&!P(n??""))throw new a("Enter a valid email address.",2,"usage");if(t!==void 0&&!B(i??""))throw new a("Enter the 6-digit code from the email.",2,"usage");if(!r){if(!n)throw new a("Pass --email when this is not a terminal. See --help for usage.",2,"usage");if(!i)throw new a("Pass --code when this is not a terminal. See --help for usage.",2,"usage")}return{...n?{email:n}:{},...i?{code:i}:{}}}async function Mt(e){for(let t=0;t<5;t+=1){let r=(await b(e,Q)).trim();if(P(r))return r;e.stderr.write(C("Enter a valid email address.",T(e.stderr,e.env)))}throw new a("Enter a valid email address.",2,"usage")}async function jt(e,t,r,n,i){let o=r,s=0,c=0;for(;s<5;){let u=o;if(o=void 0,!u){if(!i.interactive)throw new a("Pass --code when this is not a terminal. See --help for usage.",2,"usage");u=(await b(n,Z)).trim()}if(!B(u)){c+=1;let f="Enter the 6-digit code from the email.";if(!i.interactive||c>=5)throw new a(f,2,"usage");n.stderr.write(C(f,T(n.stderr,n.env)));continue}s+=1;let d=$(n.stdout,"Checking code...",i.color);try{await e.verify(t,u);return}catch(f){if(!(f instanceof a)||f.kind!=="invalid_code")throw f;if(!i.interactive||s>=5)throw new a(s>=5?"That code does not match. Too many tries. Run the command again to request a new code.":"That code does not match.",1,"invalid_code");let l=5-s;n.stderr.write(C(`That code does not match. ${l} ${l===1?"try":"tries"} left.`,T(n.stderr,n.env)))}finally{d.stop()}}throw new a("That code does not match. Too many tries. Run the command again to request a new code.",1,"invalid_code")}function Ut(e){return new Promise(t=>{setTimeout(t,e)})}var Le=Number.parseInt(process.versions.node.split(".")[0]??"",10);(!Number.isFinite(Le)||Le<18)&&(process.stderr.write(`physicalvalidation needs Node.js 18 or newer.
|
|
91
105
|
`),process.exit(1));process.on("SIGINT",()=>{process.stdout.isTTY&&process.stdout.write(`\x1B[?25h
|
|
92
|
-
`),process.exit(130)});var
|
|
93
|
-
`),process.exit(1)};process.on("uncaughtException",
|
|
106
|
+
`),process.exit(130)});var Oe=()=>{process.stderr.write(`Something went wrong. Try again in a moment.
|
|
107
|
+
`),process.exit(1)};process.on("uncaughtException",Oe);process.on("unhandledRejection",Oe);var Me=await qe(process.argv.slice(2),{stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,env:process.env,fetch:globalThis.fetch,version:"0.2.0"});process.exitCode=Me;setImmediate(()=>{process.exit(Me)});
|