@hiofu/apply-sdk 0.1.1 → 0.1.4
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 +144 -80
- package/dist/{chunk-XEXQY3NM.js → chunk-MFY3F4OY.js} +210 -8
- package/dist/{client-BD0-Mbnq.d.cts → client-Ct5xyQMk.d.cts} +153 -5
- package/dist/{client-BD0-Mbnq.d.ts → client-Ct5xyQMk.d.ts} +153 -5
- package/dist/index.cjs +360 -19
- package/dist/index.d.cts +28 -5
- package/dist/index.d.ts +28 -5
- package/dist/index.global.js +1 -1
- package/dist/index.js +190 -29
- package/dist/react.cjs +358 -7
- package/dist/react.d.cts +307 -3
- package/dist/react.d.ts +307 -3
- package/dist/react.js +170 -2
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Hiofu=(()=>{var $=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Me=Object.prototype.hasOwnProperty;var ze=(e,t)=>{for(var o in t)$(e,o,{get:t[o],enumerable:!0})},De=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of je(t))!Me.call(e,n)&&n!==o&&$(e,n,{get:()=>t[n],enumerable:!(i=Fe(t,n))||i.enumerable});return e};var $e=e=>De($({},"__esModule",{value:!0}),e);var st={};ze(st,{DEFAULT_APPLY_SCOPES:()=>Q,DEFAULT_AUTHORIZE_SCOPES:()=>X,HIOFU_BRAND_COLOR:()=>ee,HIOFU_BRAND_SOFT:()=>He,HIOFU_BUTTON_LABEL:()=>Ie,HIOFU_FONT_FAMILY:()=>L,HIOFU_FONT_URL:()=>Ae,HIOFU_TAGLINE:()=>Se,HIOFU_WORDMARK:()=>ve,Hiofu:()=>rt,HiofuApiError:()=>b,HiofuApplyError:()=>w,HiofuClient:()=>h,HiofuConfigurationError:()=>g,autoBind:()=>O,bootstrapFromScriptTag:()=>j,createApplyClient:()=>xe,hiofuLogoSvg:()=>ke,isAutoBound:()=>Ee});var I="https://api.hiofu.com/api",b=class extends Error{constructor(o,i,n){super(o);this.status=i;this.body=n}};async function S(e,t={}){let o=new Headers(t.headers);o.set("Content-Type","application/json"),t.token&&o.set("Authorization",`Bearer ${t.token}`);let i=await fetch(e,{...t,headers:o}),n=await i.text(),a=n;try{a=n?JSON.parse(n):null}catch{}if(!i.ok){let r=a?.message?.toString()??`Request failed (${i.status})`;throw new b(r,i.status,a)}return a}async function K(e,t){let o=e.apiBase??I,i=await S(`${o}/oauth/token`,{method:"POST",body:JSON.stringify({grant_type:"authorization_code",client_id:e.clientId,code:t.code,code_verifier:t.verifier,redirect_uri:t.redirectUri})});return{accessToken:i.data.access_token,refreshToken:i.data.refresh_token??null,expiresAt:Date.now()+i.data.expires_in*1e3,scopes:i.data.scope.split(" ").filter(Boolean)}}async function ue(e,t){let o=e.apiBase??I,i=await S(`${o}/oauth/token`,{method:"POST",body:JSON.stringify({grant_type:"refresh_token",client_id:e.clientId,refresh_token:t})});return{accessToken:i.data.access_token,refreshToken:i.data.refresh_token??null,expiresAt:Date.now()+i.data.expires_in*1e3,scopes:i.data.scope.split(" ").filter(Boolean)}}async function le(e,t){let o=e.apiBase??I;await S(`${o}/oauth/revoke`,{method:"POST",body:JSON.stringify({token:t,client_id:e.clientId})})}async function ce(e,t){let o=e.apiBase??I;return S(`${o}/v1/partner/me`,{token:t})}async function pe(e,t){let o=e.apiBase??I;return S(`${o}/v1/partner/me/full`,{token:t})}async function de(e,t,o){let i=e.apiBase??I;return S(`${i}/v1/partner/applications`,{method:"POST",token:t,headers:o.idempotencyKey?{"Idempotency-Key":o.idempotencyKey}:void 0,body:JSON.stringify(o)})}var g=class extends Error{constructor(t,o,i){super(o),this.name="HiofuConfigurationError",this.code=t,this.details=i}},Ke=new Set(["https://hiofu.com","https://www.hiofu.com","https://api.hiofu.com"]),Je=new Set(["https://sandbox.hiofu.com","https://api.sandbox.hiofu.com"]);function Ve(e){if(e.startsWith("pk_test_"))return"test";if(e.startsWith("pk_live_"))return"live";throw new g("hiofu.configuration_error","Hiofu clientId must start with pk_test_ or pk_live_.",{clientIdPrefix:e.slice(0,8)})}function fe(e){let t;try{t=new URL(e)}catch{throw new g("hiofu.configuration_error","Hiofu origin and API URLs must be absolute URLs.",{value:e})}return["localhost","127.0.0.1","0.0.0.0"].includes(t.hostname)?"local":Je.has(t.origin)?"sandbox":Ke.has(t.origin)?"production":"unknown"}function me(e,t,o,i){if(!(t==="local"||t==="unknown")){if(e==="test"&&t==="production")throw new g("hiofu.environment_mismatch","pk_test_* client IDs must use sandbox Hiofu origins, not production.",{field:o,value:i,expected:"sandbox",received:"production"});if(e==="live"&&t==="sandbox")throw new g("hiofu.environment_mismatch","pk_live_* client IDs must use production Hiofu origins, not sandbox.",{field:o,value:i,expected:"production",received:"sandbox"})}}function ge(e){let t=Ve(e.clientId);me(t,fe(e.hiofuOrigin),"hiofuOrigin",e.hiofuOrigin),me(t,fe(e.apiBase),"apiBase",e.apiBase)}var he="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";function J(e=64){if(e<43||e>128)throw new Error("PKCE verifier length must be 43..128");let t=new Uint8Array(e);crypto.getRandomValues(t);let o="";for(let i=0;i<e;i++)o+=he[t[i]%he.length];return o}function qe(e){let t=new Uint8Array(e),o="";for(let i of t)o+=String.fromCharCode(i);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function ye(e){let t=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",t);return qe(o)}function Ce(e=43){return J(e)}var Ge="https://hiofu.com",We=5*6e4;function Ye(e,t){if(e.redirectUri)return e.redirectUri;let o=new URL(t).origin;return typeof window<"u"&&window.location.origin&&window.location.origin!==o?new URL("/oauth/callback.html",window.location.origin).toString():`${o}/oauth/callback-shim`}async function V(e,t,o,i){let n=e.hiofuOrigin??Ge,a=new URL(n).origin,r=Ye(e,n),c=e.authorizeTimeoutMs??We,l=J(),p=await ye(l),y=Ce(),u=new URL(`${n}/oauth/consent`);u.searchParams.set("client_id",e.clientId),u.searchParams.set("redirect_uri",r),u.searchParams.set("scope",t.join(" ")),u.searchParams.set("state",y),u.searchParams.set("code_challenge",p),u.searchParams.set("code_challenge_method","S256"),o?.jobId&&u.searchParams.set("job_id",o.jobId),o?.jobTitle&&u.searchParams.set("job_title",o.jobTitle),o?.employerId&&u.searchParams.set("employer_id",o.employerId),o?.employerName&&u.searchParams.set("employer_name",o.employerName),o?.variationId&&u.searchParams.set("variation_id",o.variationId);let m=480,d=720,f=window.screenX+(window.outerWidth-m)/2,M=window.screenY+(window.outerHeight-d)/2,Oe=`popup=yes,width=${m},height=${d},left=${f},top=${M},scrollbars=yes`,_=window.open(u.toString(),"hiofu_apply",Oe);if(!_)throw new Error("Popup blocked. Allow popups for this site to continue.");i?.onPopupOpened?.({redirectUri:r});try{localStorage.removeItem("hiofu_oauth_result")}catch{}return new Promise((Pe,z)=>{let C=!1,k=null,D=null,T=null,P=()=>{if(C=!0,window.removeEventListener("message",ne),window.removeEventListener("storage",re),window.removeEventListener("focus",se),window.clearInterval(Be),k&&clearTimeout(k),D&&clearTimeout(D),T)try{T.close()}catch{}try{localStorage.removeItem("hiofu_oauth_result")}catch{}},H=(s,v)=>{if(C||!s||s.type!=="hiofu_oauth")return;let E=s.state===y;if(i?.onPopupResultReceived?.({channel:v,hasCode:!!s.code,hasError:!!s.error,stateMatches:E,error:s.error??null,variationId:s.variationId??null}),!!E){if(s.error){P();try{_.close()}catch{}i?.onPopupClosed?.(s.error==="access_denied"?"denied":"completed"),z(new Error(s.error));return}if(s.code){P();try{_.close()}catch{}i?.onPopupClosed?.("completed"),Pe({code:s.code,state:y,verifier:l,redirectUri:r,variationId:s.variationId??null})}}},Re=new URL(r).origin,Ue=new Set([a,Re]),ne=s=>{C||Ue.has(s.origin)&&H(s.data,"message")},re=s=>{if(!C&&!(s.key!=="hiofu_oauth_result"||!s.newValue))try{H(JSON.parse(s.newValue),"storage")}catch{}};if(typeof BroadcastChannel<"u")try{T=new BroadcastChannel("hiofu_oauth"),T.onmessage=s=>{C||H(s.data,"broadcast")}}catch{T=null}let se=()=>{C||(k&&clearTimeout(k),k=setTimeout(()=>{try{let s=localStorage.getItem("hiofu_oauth_result");if(s){H(JSON.parse(s),"focus_storage");return}}catch{}},3e3))};window.addEventListener("message",ne),window.addEventListener("storage",re),window.addEventListener("focus",se);let Be=window.setInterval(()=>{if(!C){try{let s=_.location.href;if(s){let v=new URL(s),E=v.searchParams.get("code"),Ne=v.searchParams.get("state"),ae=v.searchParams.get("error"),Le=v.searchParams.get("variation_id");if(E||ae){H({type:"hiofu_oauth",code:E,state:Ne,error:ae,variationId:Le},"poll_url");return}}}catch{}try{let s=localStorage.getItem("hiofu_oauth_result");if(s){H(JSON.parse(s),"poll_storage");return}}catch{}_.closed&&(P(),i?.onPopupClosed?.("user_closed"),z(new Error("Authorization popup closed before completion.")))}},500);D=window.setTimeout(()=>{if(!C){P();try{_.close()}catch{}i?.onPopupClosed?.("timed_out"),z(new Error("Authorization timed out. Please try again."))}},c)})}var we=0;function R(e="hiofu"){let t=globalThis.crypto;if(typeof t?.randomUUID=="function")return`${e}_${t.randomUUID()}`;if(typeof t?.getRandomValues=="function"){let i=new Uint8Array(16);t.getRandomValues(i);let n=Array.from(i,a=>a.toString(16).padStart(2,"0")).join("");return`${e}_${Date.now()}_${n}`}we+=1;let o=typeof globalThis.performance?.now=="function"?Math.floor(globalThis.performance.now()*1e3):0;return`${e}_${Date.now()}_${o}_${we}`}var G=new Map;function W(e){return`hiofu:${e}:token`}function Ze(){return typeof window>"u"?"server":window.location?.origin||"unknown-origin"}function Y(e){return`hiofu:${Ze()}:${e}:token`}function be(e){try{return JSON.parse(e)}catch{return null}}function q(e){return{...e,refreshToken:null}}function U(e,t){if(t==="memory")return G.get(e)??null;if(typeof window>"u")return null;try{let o=Y(e),i=window.sessionStorage.getItem(o);if(i){let l=be(i);return l?q(l):null}let n=W(e),a=window.sessionStorage.getItem(n);if(!a)return null;let r=be(a);if(!r)return null;let c=q(r);return window.sessionStorage.setItem(o,JSON.stringify(c)),window.sessionStorage.removeItem(n),c}catch{return null}}function B(e,t,o){if(t==="memory"){G.set(e,o);return}if(!(typeof window>"u"))try{window.sessionStorage.setItem(Y(e),JSON.stringify(q(o))),window.sessionStorage.removeItem(W(e))}catch{}}function Z(e,t){if(t==="memory"){G.delete(e);return}if(!(typeof window>"u"))try{window.sessionStorage.removeItem(Y(e)),window.sessionStorage.removeItem(W(e))}catch{}}var X=["profile.basic"],Q=["applications.write","passport.snapshot"];function _e(e){return[...new Set(e)]}function Xe(e){let t=[...e];return t.includes("applications.write")||t.push("applications.write"),t.includes("passport.snapshot")||t.push("passport.snapshot"),_e(t)}function Qe(){return R()}function N(e){return{expiresAt:e.expiresAt,scopes:[...e.scopes]}}var h=class{constructor(t){this.listeners=new Set;if(!t.clientId)throw new Error("HiofuClient: clientId is required");this.config={...t,hiofuOrigin:t.hiofuOrigin??"https://hiofu.com",apiBase:t.apiBase??"https://api.hiofu.com/api",storage:t.storage??"memory",authorizeTimeoutMs:t.authorizeTimeoutMs??5*6e4},ge(this.config)}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}emit(t){try{this.config.onEvent?.(t)}catch{}for(let o of this.listeners)try{o(t)}catch{}}async getAccessToken(){let t=U(this.config.clientId,this.config.storage);if(!t)return null;if(t.expiresAt-3e4>Date.now())return t.accessToken;if(!t.refreshToken)return null;try{let o=await ue(this.config,t.refreshToken);return B(this.config.clientId,this.config.storage,o),this.emit({type:"token_issued",token:N(o)}),o.accessToken}catch{return Z(this.config.clientId,this.config.storage),null}}async authorize(t=this.config.scopes??X,o){let i=await V(this.config,_e(t),o,{onPopupOpened:({redirectUri:r})=>{this.emit({type:"popup_opened",redirectUri:r})},onPopupClosed:r=>{this.emit({type:"popup_closed",reason:r})},onPopupResultReceived:r=>{this.emit({type:"popup_result_received",...r})}}),n=await K(this.config,{code:i.code,verifier:i.verifier,redirectUri:i.redirectUri});B(this.config.clientId,this.config.storage,n);let a=N(n);return this.emit({type:"token_issued",token:a}),a}async apply(t){this.emit({type:"apply_started",input:{jobId:t.jobId,jobTitle:t.jobTitle,employerId:t.employerId,employerName:t.employerName,variationId:t.variationId??void 0}});try{let o=await this.getAccessToken(),i=U(this.config.clientId,this.config.storage),n=Xe(t.scopes??this.config.applyScopes??this.config.scopes??Q),a=i&&n.every(u=>i.scopes.includes(u)),r=!t.variationId,c=t.idempotencyKey?.trim()||Qe(),l=t.variationId??null;if(!o||!a||r){let u=await V(this.config,n,{jobId:t.jobId,jobTitle:t.jobTitle,employerId:t.employerId,employerName:t.employerName,variationId:t.variationId},{onPopupOpened:({redirectUri:d})=>{this.emit({type:"popup_opened",redirectUri:d})},onPopupClosed:d=>{this.emit({type:"popup_closed",reason:d})},onPopupResultReceived:d=>{this.emit({type:"popup_result_received",...d})}}),m=await K(this.config,{code:u.code,verifier:u.verifier,redirectUri:u.redirectUri});B(this.config.clientId,this.config.storage,m),this.emit({type:"token_issued",token:N(m)}),i=m,o=m.accessToken,l=u.variationId??t.variationId??null}this.emit({type:"apply_submitting",idempotencyKey:c,variationId:l});let p=await de(this.config,o,{jobId:t.jobId,jobTitle:t.jobTitle,employerId:t.employerId,employerName:t.employerName,role:t.role,variationId:l??void 0,idempotencyKey:c}),y={application:p.data.application,authorization:N(i),idempotencyKey:c,sharedView:p.data.sharedView??(l?{type:"variation",label:null}:{type:"full_passport",label:null}),versionNumber:p.data.versionNumber??null,profile:p.data.profile??null,evidence:p.data.evidence??null,snapshot:p.data.snapshot??null,delivery:p.data.delivery??null};return this.emit({type:"apply_success",result:y}),y}catch(o){let i=o instanceof Error?o:new Error(String(o));throw this.emit({type:"apply_error",error:i}),i}}async getProfile(t="basic"){let o=await this.getAccessToken();if(!o)throw new Error("Not authorised. Call authorize() or apply().");return t==="full"?pe(this.config,o):ce(this.config,o)}async logout(){let t=U(this.config.clientId,this.config.storage);if(t?.accessToken)try{await le(this.config,t.accessToken)}catch{}Z(this.config.clientId,this.config.storage)}};var ee="#667eea",He="#eaf4ff",ve="HIOFU",Ie="Apply with HSP1",Se="Skills Passport Platform",L="'Geist', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Ae="https://fonts.googleapis.com/css2?family=Geist:wght@400;600&display=swap";function ke({size:e=24,color:t=ee}={}){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4000 4000" width="${e}" height="${e}" fill="none" aria-hidden="true"><path fill="${t}" transform="translate(1034,1034)" d="M0 0 C212.85 0 425.7 0 645 0 C645 212.52 645 425.04 645 644 C856.89636356 643.96037473 856.89636356 643.96037473 1068.79272461 643.90991211 C1109.66711426 643.90539551 1109.66711426 643.90539551 1128.76930237 643.90455627 C1143.06830418 643.90355843 1157.3673013 643.89923459 1171.66630179 643.89332657 C1186.22879895 643.88739059 1200.79129313 643.88515942 1215.35379145 643.88655505 C1224.02511491 643.88727558 1232.69642734 643.8852541 1241.36774878 643.8791924 C1247.08119714 643.87546737 1252.79463809 643.87531229 1258.50808695 643.87816466 C1261.76999766 643.87968819 1265.03188252 643.87902557 1268.29379189 643.87511742 C1271.80233562 643.87115732 1275.31082282 643.87323457 1278.8193655 643.87695217 C1279.84998128 643.87432515 1280.88059705 643.87169812 1281.94244361 643.86899149 C1282.86776725 643.87123879 1283.7930909 643.8734861 1284.74645466 643.8758015 C1285.54991085 643.87564552 1286.35336705 643.87548954 1287.1811704 643.87532884 C1289 644 1289 644 1290 645 C1290.09699984 646.41513221 1290.12447387 647.83509264 1290.1241985 649.25354534 C1290.1264458 650.17886899 1290.12869311 651.10419264 1290.13100851 652.05755639 C1290.12706797 653.60348006 1290.12706797 653.60348006 1290.12304783 655.1806345 C1290.12477845 656.81393262 1290.12477845 656.81393262 1290.12654402 658.48022666 C1290.12921807 662.17649429 1290.12468308 665.87271951 1290.12025452 669.56898499 C1290.12069145 672.21977348 1290.12152514 674.87055912 1290.12284851 677.52134705 C1290.12493343 683.3176645 1290.12326705 689.11397171 1290.11921513 694.91028798 C1290.11313165 703.64128822 1290.11284368 712.37228222 1290.11368043 721.1032842 C1290.11492471 735.73246789 1290.11162001 750.36164711 1290.10557556 764.99082947 C1290.09741702 784.77151653 1290.09547353 804.55219592 1290.09460449 824.33288574 C1290.08934731 871.90942474 1290.07538629 919.48596246 1290.0625 967.0625 C1290.041875 1073.301875 1290.02125 1179.54125 1290 1289 C1502.52 1289 1715.04 1289 1934 1289 C1934 1501.85 1934 1714.7 1934 1934 C1721.15 1934 1508.3 1934 1289 1934 C1288.625 1772.5 1288.625 1772.5 1288.52197266 1721.65039062 C1288.48202947 1706.50774795 1288.48202947 1706.50774795 1288.43954468 1691.3651123 C1288.42080214 1684.66068632 1288.40721862 1677.95627536 1288.39730835 1671.25183105 C1288.38581716 1663.49036763 1288.36742107 1655.72895444 1288.34107121 1647.96752676 C1288.3278415 1644.01067253 1288.31732704 1640.05387476 1288.31574559 1636.09699726 C1288.30745247 1620.60432768 1288.04882577 1605.17510698 1287.08163452 1589.70935059 C1287.00124612 1588.42143317 1286.92085773 1587.13351575 1286.83803332 1585.80657053 C1282.06455978 1515.63263785 1252.40600162 1448.19883165 1205.11328125 1396.33203125 C1203.22623463 1394.24965264 1201.38941767 1392.13496936 1199.5625 1390 C1192.95235187 1382.42587194 1185.71742314 1375.4353351 1178 1369 C1177.46697266 1368.55317871 1176.93394531 1368.10635742 1176.38476562 1367.64599609 C1159.24283074 1353.32553103 1141.43739688 1341.01413992 1122 1330 C1121.33468262 1329.61505371 1120.66936523 1329.23010742 1119.98388672 1328.83349609 C1079.10735154 1305.20781221 1028.19860917 1291.13249309 980.95703125 1290.76171875 C979.92285568 1290.7519249 978.88868011 1290.74213104 977.82316589 1290.73204041 C954.89597459 1290.55972646 932.58691104 1290.71914018 910 1295 C908.85321777 1295.21430664 907.70643555 1295.42861328 906.52490234 1295.64941406 C850.7227533 1306.40136369 798.57630888 1331.24788422 756 1369 C755.03191406 1369.85722656 754.06382812 1370.71445313 753.06640625 1371.59765625 C741.20418581 1382.29413391 729.84647149 1393.39927075 720 1406 C719.04945705 1407.16357244 718.09615669 1408.32489584 717.140625 1409.484375 C710.17564591 1417.97433671 703.86187772 1426.7156136 698 1436 C697.63342285 1436.57621094 697.2668457 1437.15242188 696.88916016 1437.74609375 C667.61100204 1484.08675854 650.28720896 1537.03647257 646.91055298 1591.7442627 C646.86805293 1592.4281217 646.82555287 1593.11198071 646.78176494 1593.81656271 C645.83996196 1609.26927039 645.68958126 1624.69941296 645.68335578 1640.17642534 C645.67948705 1644.19779951 645.66412082 1648.21913577 645.6503849 1652.24048615 C645.62553662 1659.99201109 645.61033146 1667.74352268 645.59880099 1675.49507764 C645.58498323 1684.49056295 645.55865582 1693.48598508 645.5324707 1702.48144531 C645.46955608 1726.15427147 645.42326434 1749.82713944 645.375 1773.5 C645.25125 1826.465 645.1275 1879.43 645 1934 C432.15 1934 219.3 1934 0 1934 C0 1721.15 0 1508.3 0 1289 C160.5625 1288.625 160.5625 1288.625 211.12329102 1288.52197266 C226.17547199 1288.48203099 226.17547199 1288.48203099 241.22764587 1288.43954468 C247.89378247 1288.42079659 254.55990392 1288.407216 261.22605896 1288.39730835 C268.94216177 1288.38582173 276.65821399 1288.36743205 284.37428081 1288.34107121 C288.30848121 1288.32783468 292.24262471 1288.31732587 296.17684853 1288.31574559 C311.39652544 1288.3075441 326.56079366 1288.06692488 341.75254822 1287.08944702 C342.99136232 1287.01010599 344.23017642 1286.93076495 345.50653034 1286.84901965 C387.02631279 1283.93222903 427.79434077 1272.55595424 465 1254 C466.31967773 1253.35925537 466.31967773 1253.35925537 467.66601562 1252.70556641 C492.1979482 1240.77197411 514.44418239 1224.84575596 535 1207 C535.80695312 1206.30648437 536.61390625 1205.61296875 537.4453125 1204.8984375 C549.58245126 1194.2424411 561.09572755 1182.76471215 571 1170 C571.94755571 1168.83872009 572.89829595 1167.68003411 573.8515625 1166.5234375 C580.82061869 1158.03191742 587.13612786 1149.28754528 593 1140 C593.36657715 1139.42378906 593.7331543 1138.84757812 594.11083984 1138.25390625 C623.52719041 1091.69451424 642.93520462 1035.77851825 643.203125 980.33984375 C643.21018463 979.36022675 643.21724426 978.38060974 643.22451782 977.37130737 C643.46827251 947.05917734 643.46827251 947.05917734 640 917 C639.79600586 915.85160645 639.59201172 914.70321289 639.38183594 913.52001953 C624.33070602 831.13315773 579.21845208 754.47206937 510.04174805 705.98974609 C499.64395414 698.85804342 488.92923007 692.28184987 478 686 C477.31856934 685.60361328 476.63713867 685.20722656 475.93505859 684.79882812 C421.32602944 653.31303265 359.70138388 645.90857123 297.84687839 645.79942851 C293.78017846 645.79117312 289.71349636 645.77734735 285.64680958 645.76427555 C277.78419488 645.73981035 269.92157578 645.72012322 262.05894377 645.70219031 C252.94736361 645.6811969 243.83580796 645.65411741 234.72424316 645.6270752 C210.71200946 645.55876501 186.69975307 645.4986243 162.6875 645.4375 C109.000625 645.293125 55.31375 645.14875 0 645 C0 432.15 0 219.3 0 0 Z"/><path fill="${t}" opacity="0.55" transform="translate(2665.2273972332478,1033.88392727077)" d="M0 0 C4.13109652 0.00441336 8.26219201 0.00290235 12.39329025 0.00218208 C20.38739589 0.0016536 28.38149015 0.00623972 36.37559288 0.01268341 C45.6357789 0.01992215 54.89595822 0.02068027 64.15614769 0.02146824 C88.56996783 0.02670501 112.98378547 0.04066624 137.39760277 0.05357273 C191.97135277 0.07419773 246.54510277 0.09482273 302.77260277 0.11607273 C302.77260277 212.96607273 302.77260277 425.81607273 302.77260277 645.11607273 C245.88885277 645.17794773 189.00510277 645.23982273 130.39760277 645.30357273 C112.46625999 645.33088474 94.53491722 645.35819675 76.06020042 645.3863364 C54.08778831 645.39988621 54.08778831 645.39988621 43.78685448 645.40240391 C36.62463329 645.40518787 29.46248328 645.41613414 22.30028221 645.43279941 C14.01926219 645.45203915 5.73830981 645.46054737 -2.54273266 645.45640758 C-6.76923774 645.45461797 -10.99559212 645.457241 -15.22206882 645.47371812 C-38.9778459 645.56183254 -62.35832648 644.49213945 -85.66489723 639.42857273 C-86.85824684 639.17366062 -88.05159645 638.91874851 -89.28110817 638.65611179 C-116.04222495 632.75696648 -142.12677201 623.98604368 -166.36020973 611.0960532 C-168.27037284 610.09351728 -170.198279 609.13534185 -172.13364723 608.18247898 C-189.97415333 599.26222593 -206.80822277 587.75093662 -222.22739723 575.11607273 C-222.73706032 574.70115574 -223.24672341 574.28623874 -223.77183083 573.85874851 C-243.26481687 557.928418 -261.11849809 540.28009887 -276.22739723 520.11607273 C-277.12709111 518.93635037 -278.02683124 517.75666329 -278.92661598 516.57701023 C-286.30270586 506.80899554 -292.90835946 496.59425731 -299.22739723 486.11607273 C-299.65907204 485.40144871 -300.09074684 484.68682468 -300.5355027 483.95054539 C-326.42724396 440.54826299 -342.06636784 387.5809744 -342.46567848 336.97544773 C-342.48036926 335.4263068 -342.48036926 335.4263068 -342.49535683 333.84587009 C-342.66772841 310.94951731 -342.5024975 288.67259489 -338.22739723 266.11607273 C-337.90593727 264.39589939 -337.90593727 264.39589939 -337.57798317 262.64097507 C-332.85158743 238.11118756 -325.49772666 214.57345459 -315.38853005 191.7391196 C-314.36606186 189.42932183 -313.36859721 187.11059599 -312.37583473 184.78794773 C-297.62667222 151.13976141 -274.6137392 121.36945591 -249.22739723 95.11607273 C-248.74754372 94.61962253 -248.2676902 94.12317234 -247.77329567 93.6116782 C-242.48368784 88.16894019 -237.05255716 82.9797985 -231.22739723 78.11607273 C-230.70500466 77.67456882 -230.18261208 77.23306492 -229.64438942 76.7781821 C-213.69661083 63.34013123 -196.8285241 51.45493394 -178.5511277 41.3953696 C-177.02513958 40.55525847 -175.50316193 39.70781288 -173.98569801 38.85240085 C-120.15120122 8.53576352 -60.86821967 -0.08189714 0 0 Z"/></svg>`}var te=!1,x=null;function oe(e){if(!e)return;let t=e.split(/[\s,]+/).map(o=>o.trim()).filter(Boolean);return t.length?t:void 0}function Te(e){if(!e)return;let t=e.split(",").map(o=>o.trim()).filter(Boolean);return t.length?t:void 0}function F(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function O(e){if(typeof document>"u")return()=>{};x&&x();let t=async i=>{let n=i.target?.closest("[data-hiofu-apply]");if(!n)return;i.preventDefault();let a=n.getAttribute("data-job-id"),r=n.getAttribute("data-job-title"),c=n.getAttribute("data-employer-id"),l=n.getAttribute("data-employer-name"),p=n.getAttribute("data-external-role-id"),y=n.getAttribute("data-external-employer-id"),u=n.getAttribute("data-hiofu-variation-id")??void 0,m=n.getAttribute("data-hiofu-idempotency-key")??void 0,d=oe(n.getAttribute("data-hiofu-scopes"));if(!a||!r||!c||!l){let f=new Error("data-job-id, data-job-title, data-employer-id and data-employer-name are required");n.dispatchEvent(new CustomEvent("hiofu:apply:error",{bubbles:!0,detail:f}));return}n.setAttribute("data-hiofu-loading","1");try{let f={jobId:a,jobTitle:r,employerId:c,employerName:l};u&&(f.variationId=u),m&&(f.idempotencyKey=m),d&&(f.scopes=d),(p||y)&&(f.role={externalRoleId:p??a,externalEmployerId:y??c,title:n.getAttribute("data-role-title")??r,description:n.getAttribute("data-role-description")??void 0,department:n.getAttribute("data-role-department")??void 0,locations:Te(n.getAttribute("data-role-locations")),jobTypes:Te(n.getAttribute("data-role-job-types")),salaryMin:F(n.getAttribute("data-role-salary-min")),salaryMax:F(n.getAttribute("data-role-salary-max")),salaryCurrency:n.getAttribute("data-role-salary-currency")??void 0,experienceMin:F(n.getAttribute("data-role-experience-min")),experienceMax:F(n.getAttribute("data-role-experience-max"))});let M=await e.apply(f);n.dispatchEvent(new CustomEvent("hiofu:apply:success",{bubbles:!0,detail:M}))}catch(f){n.dispatchEvent(new CustomEvent("hiofu:apply:error",{bubbles:!0,detail:f}))}finally{n.removeAttribute("data-hiofu-loading")}};document.querySelectorAll("[data-hiofu-apply]").forEach(i=>{i.style.fontFamily=L}),document.addEventListener("click",t),te=!0;let o=()=>{document.removeEventListener("click",t),te=!1,x===o&&(x=null)};return x=o,o}function Ee(){return te}function j(){if(typeof document>"u")return null;let e=document.currentScript;if(!e)return null;let t=e.getAttribute("data-client-id");if(!t)return null;let o={clientId:t,hiofuOrigin:e.getAttribute("data-hiofu-origin")??void 0,apiBase:e.getAttribute("data-api-base")??void 0,redirectUri:e.getAttribute("data-redirect-uri")??void 0,scopes:oe(e.getAttribute("data-scopes")),applyScopes:oe(e.getAttribute("data-apply-scopes"))},i=new h(o);return O(i),i}var w=class extends Error{constructor(t){super(t.message),this.name="HiofuApplyError",this.code=t.code,this.correlationId=t.correlationId,this.retryable=t.retryable,this.cause=t.cause}},et={sandbox:{hiofuOrigin:"https://sandbox.hiofu.com",apiBase:"https://api.sandbox.hiofu.com/api"},production:{hiofuOrigin:"https://hiofu.com",apiBase:"https://api.hiofu.com/api"}};function ie(){return R()}function tt(e,t){if(e==="sandbox"&&!t.startsWith("pk_test_"))throw new w({code:"environment_mismatch",message:"Sandbox integrations must use a pk_test_* publishable key.",correlationId:ie(),retryable:!1});if(e==="production"&&!t.startsWith("pk_live_"))throw new w({code:"environment_mismatch",message:"Production integrations must use a pk_live_* publishable key.",correlationId:ie(),retryable:!1})}function ot(e){let t=e.role.locations??(e.role.location?[e.role.location]:void 0);return{jobId:e.externalJobId,jobTitle:e.jobTitle??e.role.title,employerId:e.externalEmployerId,employerName:e.employerName??e.externalEmployerId,scopes:e.scopes,variationId:e.variationId,idempotencyKey:e.idempotencyKey,role:{externalRoleId:e.externalJobId,externalEmployerId:e.externalEmployerId,title:e.role.title,description:e.role.description,locations:t,metadata:{...e.role.metadata??{},...e.role.skills?{skills:e.role.skills}:{},...e.role.salary?{salary:e.role.salary}:{},...e.role.dimensions?{dimensions:e.role.dimensions}:{},...e.callbackState?{callbackState:e.callbackState}:{},...e.partnerTags?{partnerTags:e.partnerTags}:{}}}}}function it(e,t,o){let i=e.application.submittedAt instanceof Date?e.application.submittedAt.toISOString():e.application.submittedAt??new Date().toISOString();return{applicationId:e.application.id,partnerApplicationId:o,hiofuRoleId:e.application.jobId??"",status:e.application.status,environment:t,submittedAt:String(i),raw:e}}function nt(e,t){if(e instanceof w)return e;let o=e instanceof Error?e.message:String(e),i="submit_failed",n=!1;if(e instanceof g)i=e.code==="hiofu.environment_mismatch"?"environment_mismatch":"configuration_error";else if(/popup blocked/i.test(o))i="popup_blocked",n=!0;else if(/timed out/i.test(o))i="timeout",n=!0;else if(/access_denied|consent/i.test(o))i="consent_required";else if(e instanceof b){let a=e.body,r=a?.code??a?.error?.code??"";e.status===401||e.status===403?i="auth_failed":/role/i.test(r)||/role/i.test(o)?i="role_mapping_failed":(i="submit_failed",n=e.status>=500)}return new w({code:i,message:o,correlationId:t,retryable:n,cause:e})}function xe(e){tt(e.environment,e.publicKey);let t=et[e.environment],o=new h({clientId:e.publicKey,hiofuOrigin:e.hiofuOrigin??t.hiofuOrigin,apiBase:e.apiBase??t.apiBase,redirectUri:e.redirectUri,scopes:e.scopes,applyScopes:e.applyScopes,storage:e.storage,authorizeTimeoutMs:e.popupOptions?.timeoutMs,onEvent:e.onEvent});return{rawClient:o,authorize(i){return o.authorize(i)},getAccessToken(){return o.getAccessToken()},logout(){return o.logout()},async apply(i){let n=ie();try{let a=await o.apply(ot(i)),r=it(a,e.environment,i.idempotencyKey);return e.onComplete?.(r),r}catch(a){let r=nt(a,n);throw r.code==="consent_required"?e.onCancel?.({reason:"user_cancelled",correlationId:n}):r.code==="timeout"?e.onCancel?.({reason:"timeout",correlationId:n}):/popup closed/i.test(r.message)&&e.onCancel?.({reason:"popup_closed",correlationId:n}),e.onError?.(r),r}}}}var A=null,rt={init(e){return A=new h(e),O(A),A},client(){if(!A)throw new Error("Hiofu.init({ clientId }) was not called");return A},apply(e){return this.client().apply(e)},authorize(e){return this.client().authorize(e)},getAccessToken(){return this.client().getAccessToken()},logout(){return this.client().logout()}};if(typeof document<"u"){let e=j();e&&(A=e)}return $e(st);})();
|
|
1
|
+
"use strict";var Hiofu=(()=>{var ee=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ge=Object.prototype.hasOwnProperty;var We=(e,t)=>{for(var o in t)ee(e,o,{get:t[o],enumerable:!0})},Ye=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ve(t))!Ge.call(e,n)&&n!==o&&ee(e,n,{get:()=>t[n],enumerable:!(i=Je(t,n))||i.enumerable});return e};var Ze=e=>Ye(ee({},"__esModule",{value:!0}),e);var yt={};We(yt,{DEFAULT_APPLY_SCOPES:()=>ce,DEFAULT_AUTHORIZE_SCOPES:()=>ue,HIOFU_BRAND_COLOR:()=>pe,HIOFU_BRAND_SOFT:()=>Oe,HIOFU_BUTTON_LABEL:()=>Ue,HIOFU_FONT_FAMILY:()=>Y,HIOFU_FONT_URL:()=>Ne,HIOFU_TAGLINE:()=>Be,HIOFU_WORDMARK:()=>Me,Hiofu:()=>ht,HiofuApiError:()=>M,HiofuApplyError:()=>T,HiofuClient:()=>S,HiofuConfigurationError:()=>v,HiofuManagementClient:()=>$,HiofuPopupError:()=>U,autoBind:()=>j,bootstrapFromScriptTag:()=>X,createApplyClient:()=>je,createManagementClient:()=>$e,hiofuLogoSvg:()=>Le,isAutoBound:()=>Fe});var A="https://api.hiofu.com/api",M=class extends Error{constructor(o,i,n){super(o);this.status=i;this.body=n}};async function k(e,t={}){let o=new Headers(t.headers);o.set("Content-Type","application/json"),t.token&&o.set("Authorization",`Bearer ${t.token}`);let i=await fetch(e,{...t,headers:o}),n=await i.text(),s=n;try{s=n?JSON.parse(n):null}catch{}if(!i.ok){let r=s?.message?.toString()??`Request failed (${i.status})`;throw new M(r,i.status,s)}return s}async function te(e,t){let o=e.apiBase??A,i=await k(`${o}/oauth/token`,{method:"POST",body:JSON.stringify({grant_type:"authorization_code",client_id:e.clientId,code:t.code,code_verifier:t.verifier,redirect_uri:t.redirectUri})});return{accessToken:i.data.access_token,refreshToken:i.data.refresh_token??null,expiresAt:Date.now()+i.data.expires_in*1e3,scopes:i.data.scope.split(" ").filter(Boolean)}}async function be(e,t){let o=e.apiBase??A,i=await k(`${o}/oauth/token`,{method:"POST",body:JSON.stringify({grant_type:"refresh_token",client_id:e.clientId,refresh_token:t})});return{accessToken:i.data.access_token,refreshToken:i.data.refresh_token??null,expiresAt:Date.now()+i.data.expires_in*1e3,scopes:i.data.scope.split(" ").filter(Boolean)}}async function He(e,t){let o=e.apiBase??A;await k(`${o}/oauth/revoke`,{method:"POST",body:JSON.stringify({token:t,client_id:e.clientId})})}async function we(e,t){let o=e.apiBase??A;return k(`${o}/v1/partner/me`,{token:t})}async function ve(e,t){let o=e.apiBase??A;return k(`${o}/v1/partner/me/full`,{token:t})}async function _e(e,t,o){let i=e.apiBase??A;return k(`${i}/v1/partner/applications`,{method:"POST",token:t,headers:o.idempotencyKey?{"Idempotency-Key":o.idempotencyKey}:void 0,body:JSON.stringify(o)})}var v=class extends Error{constructor(t,o,i){super(o),this.name="HiofuConfigurationError",this.code=t,this.details=i}},Xe=new Set(["https://hiofu.com","https://www.hiofu.com","https://api.hiofu.com"]),Qe=new Set(["https://sandbox.hiofu.com","https://api.sandbox.hiofu.com"]);function et(e){if(e.startsWith("pk_test_"))return"test";if(e.startsWith("pk_live_"))return"live";throw new v("hiofu.configuration_error","Hiofu clientId must start with pk_test_ or pk_live_.",{clientIdPrefix:e.slice(0,8)})}function Se(e){let t;try{t=new URL(e)}catch{throw new v("hiofu.configuration_error","Hiofu origin and API URLs must be absolute URLs.",{value:e})}return["localhost","127.0.0.1","0.0.0.0"].includes(t.hostname)?"local":Qe.has(t.origin)?"sandbox":Xe.has(t.origin)?"production":"unknown"}function xe(e,t,o,i){if(!(t==="local"||t==="unknown")){if(e==="test"&&t==="production")throw new v("hiofu.environment_mismatch","pk_test_* client IDs must use sandbox Hiofu origins, not production.",{field:o,value:i,expected:"sandbox",received:"production"});if(e==="live"&&t==="sandbox")throw new v("hiofu.environment_mismatch","pk_live_* client IDs must use production Hiofu origins, not sandbox.",{field:o,value:i,expected:"production",received:"sandbox"})}}function Ie(e){let t=et(e.clientId);xe(t,Se(e.hiofuOrigin),"hiofuOrigin",e.hiofuOrigin),xe(t,Se(e.apiBase),"apiBase",e.apiBase)}var Ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";function oe(e=64){if(e<43||e>128)throw new Error("PKCE verifier length must be 43..128");let t=globalThis.crypto;if(!t?.getRandomValues)throw new Error("Secure random generation is unavailable in this browser.");let o=new Uint8Array(e);t.getRandomValues(o);let i="";for(let n=0;n<e;n++)i+=Ae[o[n]%Ae.length];return i}function tt(e){let t=new Uint8Array(e),o="";for(let i of t)o+=String.fromCharCode(i);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var ot=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function _(e,t){return e>>>t|e<<32-t}function it(e){let t=e.length+1+8;for(;t%64!==0;)t++;let o=new Uint8Array(t);o.set(e),o[e.length]=128;let i=new DataView(o.buffer),n=e.length*8;i.setUint32(t-8,Math.floor(n/4294967296)),i.setUint32(t-4,n>>>0);let s=1779033703,r=3144134277,f=1013904242,p=2773480762,d=1359893119,y=2600822924,l=528734635,h=1541459225,c=new Uint32Array(64);for(let R=0;R<t;R+=64){for(let u=0;u<16;u++)c[u]=i.getUint32(R+u*4);for(let u=16;u<64;u++){let O=_(c[u-15],7)^_(c[u-15],18)^c[u-15]>>>3,H=_(c[u-2],17)^_(c[u-2],19)^c[u-2]>>>10;c[u]=c[u-16]+O+c[u-7]+H>>>0}let m=s,E=r,x=f,b=p,C=d,I=y,w=l,P=h;for(let u=0;u<64;u++){let O=_(C,6)^_(C,11)^_(C,25),H=C&I^~C&w,z=P+O+H+ot[u]+c[u]>>>0,Q=_(m,2)^_(m,13)^_(m,22),K=m&E^m&x^E&x,q=Q+K>>>0;P=w,w=I,I=C,C=b+z>>>0,b=x,x=E,E=m,m=z+q>>>0}s=s+m>>>0,r=r+E>>>0,f=f+x>>>0,p=p+b>>>0,d=d+C>>>0,y=y+I>>>0,l=l+w>>>0,h=h+P>>>0}let g=new ArrayBuffer(32),L=new DataView(g);return[s,r,f,p,d,y,l,h].forEach((R,m)=>{L.setUint32(m*4,R)}),g}async function ke(e){let t=new TextEncoder().encode(e),o=globalThis.crypto?.subtle?.digest?await globalThis.crypto.subtle.digest("SHA-256",t):it(t);return tt(o)}function Te(e=43){return oe(e)}var nt="https://hiofu.com",rt=5*6e4,U=class extends Error{constructor(t,o){super(o),this.name="HiofuPopupError",this.reason=t}};function st(e,t){if(e.redirectUri)return e.redirectUri;let o=new URL(t).origin;return typeof window<"u"&&window.location.origin&&window.location.origin!==o?new URL("/oauth/callback.html",window.location.origin).toString():`${o}/oauth/callback-shim`}async function ie(e,t,o,i){let n=e.hiofuOrigin??nt,s=new URL(n).origin,r=st(e,n),f=e.authorizeTimeoutMs??rt,p=oe(),d=await ke(p),y=Te(),l=new URL(`${n}/oauth/consent`);l.searchParams.set("client_id",e.clientId),l.searchParams.set("redirect_uri",r),l.searchParams.set("scope",t.join(" ")),l.searchParams.set("state",y),l.searchParams.set("code_challenge",d),l.searchParams.set("code_challenge_method","S256"),l.searchParams.set("popup","1"),l.searchParams.set("sdk","apply"),o?.jobId&&l.searchParams.set("job_id",o.jobId),o?.jobTitle&&l.searchParams.set("job_title",o.jobTitle),o?.employerId&&l.searchParams.set("employer_id",o.employerId),o?.employerName&&l.searchParams.set("employer_name",o.employerName),o?.variationId&&l.searchParams.set("variation_id",o.variationId);let h=480,c=720,g=window.screenX+(window.outerWidth-h)/2,L=window.screenY+(window.outerHeight-c)/2,R=`popup=yes,width=${h},height=${c},left=${g},top=${L},scrollbars=yes`,m=window.open(l.toString(),"hiofu_apply",R);if(!m)throw new Error("Popup blocked. Allow popups for this site to continue.");i?.onPopupOpened?.({redirectUri:r});try{localStorage.removeItem("hiofu_oauth_result")}catch{}return new Promise((E,x)=>{let b=!1,C=null,I=null,w=null,P=!1,u=!1,O=()=>{if(b=!0,window.removeEventListener("message",K),window.removeEventListener("storage",q),window.removeEventListener("blur",ge),window.removeEventListener("focus",ye),document.removeEventListener("visibilitychange",he),window.clearInterval(ze),C&&clearTimeout(C),I&&clearTimeout(I),w)try{w.close()}catch{}try{localStorage.removeItem("hiofu_oauth_result")}catch{}},H=(a,B)=>{if(b||!a||a.type!=="hiofu_oauth")return;let D=a.state===y;if(i?.onPopupResultReceived?.({channel:B,hasCode:!!a.code,hasError:!!a.error,stateMatches:D,error:a.error??null,variationId:a.variationId??null}),!!D){if(a.error){O();try{m.close()}catch{}i?.onPopupClosed?.(a.error==="access_denied"?"denied":"completed"),x(new Error(a.error));return}if(a.code){O();try{m.close()}catch{}i?.onPopupClosed?.("completed"),E({code:a.code,state:y,verifier:p,redirectUri:r,variationId:a.variationId??null})}}},z=new URL(r).origin,Q=new Set([s,z]),K=a=>{b||Q.has(a.origin)&&H(a.data,"message")},q=a=>{if(!b&&!(a.key!=="hiofu_oauth_result"||!a.newValue))try{H(JSON.parse(a.newValue),"storage")}catch{}},ge=()=>{P=!0},he=()=>{document.visibilityState==="hidden"&&(P=!0)};if(typeof BroadcastChannel<"u")try{w=new BroadcastChannel("hiofu_oauth"),w.onmessage=a=>{b||H(a.data,"broadcast")}}catch{w=null}let ye=()=>{b||(P&&(u=!0),C&&clearTimeout(C),C=setTimeout(()=>{try{let a=localStorage.getItem("hiofu_oauth_result");if(a){H(JSON.parse(a),"focus_storage");return}}catch{}},3e3))};window.addEventListener("message",K),window.addEventListener("storage",q),window.addEventListener("blur",ge),window.addEventListener("focus",ye),document.addEventListener("visibilitychange",he);let ze=window.setInterval(()=>{if(!b){try{let a=m.location.href;if(a){let B=new URL(a),D=B.searchParams.get("code"),Ke=B.searchParams.get("state"),Ce=B.searchParams.get("error"),qe=B.searchParams.get("variation_id");if(D||Ce){H({type:"hiofu_oauth",code:D,state:Ke,error:Ce,variationId:qe},"poll_url");return}}}catch{}try{let a=localStorage.getItem("hiofu_oauth_result");if(a){H(JSON.parse(a),"poll_storage");return}}catch{}if(m.closed&&u)try{let a=localStorage.getItem("hiofu_oauth_result");a&&H(JSON.parse(a),"close_check")}catch{}}},500);I=window.setTimeout(()=>{if(!b){O();try{m.close()}catch{}i?.onPopupClosed?.("timed_out"),x(new U("timed_out","Authorization timed out. Please try again."))}},f)})}var Re=0;function J(e="hiofu"){let t=globalThis.crypto;if(typeof t?.randomUUID=="function")return`${e}_${t.randomUUID()}`;if(typeof t?.getRandomValues=="function"){let i=new Uint8Array(16);t.getRandomValues(i);let n=Array.from(i,s=>s.toString(16).padStart(2,"0")).join("");return`${e}_${Date.now()}_${n}`}Re+=1;let o=typeof globalThis.performance?.now=="function"?Math.floor(globalThis.performance.now()*1e3):0;return`${e}_${Date.now()}_${o}_${Re}`}var re=new Map;function se(e){return`hiofu:${e}:token`}function at(){return typeof window>"u"?"server":window.location?.origin||"unknown-origin"}function ae(e){return`hiofu:${at()}:${e}:token`}function Ee(e){try{return JSON.parse(e)}catch{return null}}function ne(e){return{...e,refreshToken:null}}function V(e,t){if(t==="memory")return re.get(e)??null;if(typeof window>"u")return null;try{let o=ae(e),i=window.sessionStorage.getItem(o);if(i){let p=Ee(i);return p?ne(p):null}let n=se(e),s=window.sessionStorage.getItem(n);if(!s)return null;let r=Ee(s);if(!r)return null;let f=ne(r);return window.sessionStorage.setItem(o,JSON.stringify(f)),window.sessionStorage.removeItem(n),f}catch{return null}}function G(e,t,o){if(t==="memory"){re.set(e,o);return}if(!(typeof window>"u"))try{window.sessionStorage.setItem(ae(e),JSON.stringify(ne(o))),window.sessionStorage.removeItem(se(e))}catch{}}function le(e,t){if(t==="memory"){re.delete(e);return}if(!(typeof window>"u"))try{window.sessionStorage.removeItem(ae(e)),window.sessionStorage.removeItem(se(e))}catch{}}var ue=["profile.basic"],ce=["applications.write","passport.snapshot"];function Pe(e){return[...new Set(e)]}function lt(e){let t=[...e];return t.includes("applications.write")||t.push("applications.write"),t.includes("passport.snapshot")||t.push("passport.snapshot"),Pe(t)}function ut(){return J()}function W(e){return{expiresAt:e.expiresAt,scopes:[...e.scopes]}}var S=class{constructor(t){this.listeners=new Set;if(!t.clientId)throw new Error("HiofuClient: clientId is required");this.config={...t,hiofuOrigin:t.hiofuOrigin??"https://hiofu.com",apiBase:t.apiBase??"https://api.hiofu.com/api",storage:t.storage??"memory",authorizeTimeoutMs:t.authorizeTimeoutMs??5*6e4},Ie(this.config)}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}emit(t){try{this.config.onEvent?.(t)}catch{}for(let o of this.listeners)try{o(t)}catch{}}async getAccessToken(){let t=V(this.config.clientId,this.config.storage);if(!t)return null;if(t.expiresAt-3e4>Date.now())return t.accessToken;if(!t.refreshToken)return null;try{let o=await be(this.config,t.refreshToken);return G(this.config.clientId,this.config.storage,o),this.emit({type:"token_issued",token:W(o)}),o.accessToken}catch{return le(this.config.clientId,this.config.storage),null}}async authorize(t=this.config.scopes??ue,o){let i=await ie(this.config,Pe(t),o,{onPopupOpened:({redirectUri:r})=>{this.emit({type:"popup_opened",redirectUri:r})},onPopupClosed:r=>{this.emit({type:"popup_closed",reason:r})},onPopupResultReceived:r=>{this.emit({type:"popup_result_received",...r})}}),n=await te(this.config,{code:i.code,verifier:i.verifier,redirectUri:i.redirectUri});G(this.config.clientId,this.config.storage,n);let s=W(n);return this.emit({type:"token_issued",token:s}),s}async apply(t){this.emit({type:"apply_started",input:{jobId:t.jobId,jobTitle:t.jobTitle,employerId:t.employerId,employerName:t.employerName,variationId:t.variationId??void 0}});try{let o=await this.getAccessToken(),i=V(this.config.clientId,this.config.storage),n=lt(t.scopes??this.config.applyScopes??this.config.scopes??ce),s=i&&n.every(l=>i.scopes.includes(l)),r=!t.variationId,f=t.idempotencyKey?.trim()||ut(),p=t.variationId??null;if(!o||!s||r){let l=await ie(this.config,n,{jobId:t.jobId,jobTitle:t.jobTitle,employerId:t.employerId,employerName:t.employerName,variationId:t.variationId},{onPopupOpened:({redirectUri:c})=>{this.emit({type:"popup_opened",redirectUri:c})},onPopupClosed:c=>{this.emit({type:"popup_closed",reason:c})},onPopupResultReceived:c=>{this.emit({type:"popup_result_received",...c})}}),h=await te(this.config,{code:l.code,verifier:l.verifier,redirectUri:l.redirectUri});G(this.config.clientId,this.config.storage,h),this.emit({type:"token_issued",token:W(h)}),i=h,o=h.accessToken,p=l.variationId??t.variationId??null}this.emit({type:"apply_submitting",idempotencyKey:f,variationId:p});let d=await _e(this.config,o,{jobId:t.jobId,jobTitle:t.jobTitle,employerId:t.employerId,employerName:t.employerName,role:t.role,variationId:p??void 0,idempotencyKey:f}),y={application:d.data.application,authorization:W(i),idempotencyKey:f,sharedView:d.data.sharedView??(p?{type:"variation",label:null}:{type:"full_passport",label:null}),versionNumber:d.data.versionNumber??null,profile:d.data.profile??null,evidence:d.data.evidence??null,snapshot:d.data.snapshot??null,delivery:d.data.delivery??null};return this.emit({type:"apply_success",result:y}),y}catch(o){let i=o instanceof Error?o:new Error(String(o));throw this.emit({type:"apply_error",error:i}),i}}async getProfile(t="basic"){let o=await this.getAccessToken();if(!o)throw new Error("Not authorised. Call authorize() or apply().");return t==="full"?ve(this.config,o):we(this.config,o)}async logout(){let t=V(this.config.clientId,this.config.storage);if(t?.accessToken)try{await He(this.config,t.accessToken)}catch{}le(this.config.clientId,this.config.storage)}};var pe="#667eea",Oe="#eaf4ff",Me="HIOFU",Ue="Apply with HSP1",Be="Skills Passport Platform",Y="'Geist', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Ne="https://fonts.googleapis.com/css2?family=Geist:wght@400;600&display=swap";function Le({size:e=24,color:t=pe}={}){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4000 4000" width="${e}" height="${e}" fill="none" aria-hidden="true"><path fill="${t}" transform="translate(1034,1034)" d="M0 0 C212.85 0 425.7 0 645 0 C645 212.52 645 425.04 645 644 C856.89636356 643.96037473 856.89636356 643.96037473 1068.79272461 643.90991211 C1109.66711426 643.90539551 1109.66711426 643.90539551 1128.76930237 643.90455627 C1143.06830418 643.90355843 1157.3673013 643.89923459 1171.66630179 643.89332657 C1186.22879895 643.88739059 1200.79129313 643.88515942 1215.35379145 643.88655505 C1224.02511491 643.88727558 1232.69642734 643.8852541 1241.36774878 643.8791924 C1247.08119714 643.87546737 1252.79463809 643.87531229 1258.50808695 643.87816466 C1261.76999766 643.87968819 1265.03188252 643.87902557 1268.29379189 643.87511742 C1271.80233562 643.87115732 1275.31082282 643.87323457 1278.8193655 643.87695217 C1279.84998128 643.87432515 1280.88059705 643.87169812 1281.94244361 643.86899149 C1282.86776725 643.87123879 1283.7930909 643.8734861 1284.74645466 643.8758015 C1285.54991085 643.87564552 1286.35336705 643.87548954 1287.1811704 643.87532884 C1289 644 1289 644 1290 645 C1290.09699984 646.41513221 1290.12447387 647.83509264 1290.1241985 649.25354534 C1290.1264458 650.17886899 1290.12869311 651.10419264 1290.13100851 652.05755639 C1290.12706797 653.60348006 1290.12706797 653.60348006 1290.12304783 655.1806345 C1290.12477845 656.81393262 1290.12477845 656.81393262 1290.12654402 658.48022666 C1290.12921807 662.17649429 1290.12468308 665.87271951 1290.12025452 669.56898499 C1290.12069145 672.21977348 1290.12152514 674.87055912 1290.12284851 677.52134705 C1290.12493343 683.3176645 1290.12326705 689.11397171 1290.11921513 694.91028798 C1290.11313165 703.64128822 1290.11284368 712.37228222 1290.11368043 721.1032842 C1290.11492471 735.73246789 1290.11162001 750.36164711 1290.10557556 764.99082947 C1290.09741702 784.77151653 1290.09547353 804.55219592 1290.09460449 824.33288574 C1290.08934731 871.90942474 1290.07538629 919.48596246 1290.0625 967.0625 C1290.041875 1073.301875 1290.02125 1179.54125 1290 1289 C1502.52 1289 1715.04 1289 1934 1289 C1934 1501.85 1934 1714.7 1934 1934 C1721.15 1934 1508.3 1934 1289 1934 C1288.625 1772.5 1288.625 1772.5 1288.52197266 1721.65039062 C1288.48202947 1706.50774795 1288.48202947 1706.50774795 1288.43954468 1691.3651123 C1288.42080214 1684.66068632 1288.40721862 1677.95627536 1288.39730835 1671.25183105 C1288.38581716 1663.49036763 1288.36742107 1655.72895444 1288.34107121 1647.96752676 C1288.3278415 1644.01067253 1288.31732704 1640.05387476 1288.31574559 1636.09699726 C1288.30745247 1620.60432768 1288.04882577 1605.17510698 1287.08163452 1589.70935059 C1287.00124612 1588.42143317 1286.92085773 1587.13351575 1286.83803332 1585.80657053 C1282.06455978 1515.63263785 1252.40600162 1448.19883165 1205.11328125 1396.33203125 C1203.22623463 1394.24965264 1201.38941767 1392.13496936 1199.5625 1390 C1192.95235187 1382.42587194 1185.71742314 1375.4353351 1178 1369 C1177.46697266 1368.55317871 1176.93394531 1368.10635742 1176.38476562 1367.64599609 C1159.24283074 1353.32553103 1141.43739688 1341.01413992 1122 1330 C1121.33468262 1329.61505371 1120.66936523 1329.23010742 1119.98388672 1328.83349609 C1079.10735154 1305.20781221 1028.19860917 1291.13249309 980.95703125 1290.76171875 C979.92285568 1290.7519249 978.88868011 1290.74213104 977.82316589 1290.73204041 C954.89597459 1290.55972646 932.58691104 1290.71914018 910 1295 C908.85321777 1295.21430664 907.70643555 1295.42861328 906.52490234 1295.64941406 C850.7227533 1306.40136369 798.57630888 1331.24788422 756 1369 C755.03191406 1369.85722656 754.06382812 1370.71445313 753.06640625 1371.59765625 C741.20418581 1382.29413391 729.84647149 1393.39927075 720 1406 C719.04945705 1407.16357244 718.09615669 1408.32489584 717.140625 1409.484375 C710.17564591 1417.97433671 703.86187772 1426.7156136 698 1436 C697.63342285 1436.57621094 697.2668457 1437.15242188 696.88916016 1437.74609375 C667.61100204 1484.08675854 650.28720896 1537.03647257 646.91055298 1591.7442627 C646.86805293 1592.4281217 646.82555287 1593.11198071 646.78176494 1593.81656271 C645.83996196 1609.26927039 645.68958126 1624.69941296 645.68335578 1640.17642534 C645.67948705 1644.19779951 645.66412082 1648.21913577 645.6503849 1652.24048615 C645.62553662 1659.99201109 645.61033146 1667.74352268 645.59880099 1675.49507764 C645.58498323 1684.49056295 645.55865582 1693.48598508 645.5324707 1702.48144531 C645.46955608 1726.15427147 645.42326434 1749.82713944 645.375 1773.5 C645.25125 1826.465 645.1275 1879.43 645 1934 C432.15 1934 219.3 1934 0 1934 C0 1721.15 0 1508.3 0 1289 C160.5625 1288.625 160.5625 1288.625 211.12329102 1288.52197266 C226.17547199 1288.48203099 226.17547199 1288.48203099 241.22764587 1288.43954468 C247.89378247 1288.42079659 254.55990392 1288.407216 261.22605896 1288.39730835 C268.94216177 1288.38582173 276.65821399 1288.36743205 284.37428081 1288.34107121 C288.30848121 1288.32783468 292.24262471 1288.31732587 296.17684853 1288.31574559 C311.39652544 1288.3075441 326.56079366 1288.06692488 341.75254822 1287.08944702 C342.99136232 1287.01010599 344.23017642 1286.93076495 345.50653034 1286.84901965 C387.02631279 1283.93222903 427.79434077 1272.55595424 465 1254 C466.31967773 1253.35925537 466.31967773 1253.35925537 467.66601562 1252.70556641 C492.1979482 1240.77197411 514.44418239 1224.84575596 535 1207 C535.80695312 1206.30648437 536.61390625 1205.61296875 537.4453125 1204.8984375 C549.58245126 1194.2424411 561.09572755 1182.76471215 571 1170 C571.94755571 1168.83872009 572.89829595 1167.68003411 573.8515625 1166.5234375 C580.82061869 1158.03191742 587.13612786 1149.28754528 593 1140 C593.36657715 1139.42378906 593.7331543 1138.84757812 594.11083984 1138.25390625 C623.52719041 1091.69451424 642.93520462 1035.77851825 643.203125 980.33984375 C643.21018463 979.36022675 643.21724426 978.38060974 643.22451782 977.37130737 C643.46827251 947.05917734 643.46827251 947.05917734 640 917 C639.79600586 915.85160645 639.59201172 914.70321289 639.38183594 913.52001953 C624.33070602 831.13315773 579.21845208 754.47206937 510.04174805 705.98974609 C499.64395414 698.85804342 488.92923007 692.28184987 478 686 C477.31856934 685.60361328 476.63713867 685.20722656 475.93505859 684.79882812 C421.32602944 653.31303265 359.70138388 645.90857123 297.84687839 645.79942851 C293.78017846 645.79117312 289.71349636 645.77734735 285.64680958 645.76427555 C277.78419488 645.73981035 269.92157578 645.72012322 262.05894377 645.70219031 C252.94736361 645.6811969 243.83580796 645.65411741 234.72424316 645.6270752 C210.71200946 645.55876501 186.69975307 645.4986243 162.6875 645.4375 C109.000625 645.293125 55.31375 645.14875 0 645 C0 432.15 0 219.3 0 0 Z"/><path fill="${t}" opacity="0.55" transform="translate(2665.2273972332478,1033.88392727077)" d="M0 0 C4.13109652 0.00441336 8.26219201 0.00290235 12.39329025 0.00218208 C20.38739589 0.0016536 28.38149015 0.00623972 36.37559288 0.01268341 C45.6357789 0.01992215 54.89595822 0.02068027 64.15614769 0.02146824 C88.56996783 0.02670501 112.98378547 0.04066624 137.39760277 0.05357273 C191.97135277 0.07419773 246.54510277 0.09482273 302.77260277 0.11607273 C302.77260277 212.96607273 302.77260277 425.81607273 302.77260277 645.11607273 C245.88885277 645.17794773 189.00510277 645.23982273 130.39760277 645.30357273 C112.46625999 645.33088474 94.53491722 645.35819675 76.06020042 645.3863364 C54.08778831 645.39988621 54.08778831 645.39988621 43.78685448 645.40240391 C36.62463329 645.40518787 29.46248328 645.41613414 22.30028221 645.43279941 C14.01926219 645.45203915 5.73830981 645.46054737 -2.54273266 645.45640758 C-6.76923774 645.45461797 -10.99559212 645.457241 -15.22206882 645.47371812 C-38.9778459 645.56183254 -62.35832648 644.49213945 -85.66489723 639.42857273 C-86.85824684 639.17366062 -88.05159645 638.91874851 -89.28110817 638.65611179 C-116.04222495 632.75696648 -142.12677201 623.98604368 -166.36020973 611.0960532 C-168.27037284 610.09351728 -170.198279 609.13534185 -172.13364723 608.18247898 C-189.97415333 599.26222593 -206.80822277 587.75093662 -222.22739723 575.11607273 C-222.73706032 574.70115574 -223.24672341 574.28623874 -223.77183083 573.85874851 C-243.26481687 557.928418 -261.11849809 540.28009887 -276.22739723 520.11607273 C-277.12709111 518.93635037 -278.02683124 517.75666329 -278.92661598 516.57701023 C-286.30270586 506.80899554 -292.90835946 496.59425731 -299.22739723 486.11607273 C-299.65907204 485.40144871 -300.09074684 484.68682468 -300.5355027 483.95054539 C-326.42724396 440.54826299 -342.06636784 387.5809744 -342.46567848 336.97544773 C-342.48036926 335.4263068 -342.48036926 335.4263068 -342.49535683 333.84587009 C-342.66772841 310.94951731 -342.5024975 288.67259489 -338.22739723 266.11607273 C-337.90593727 264.39589939 -337.90593727 264.39589939 -337.57798317 262.64097507 C-332.85158743 238.11118756 -325.49772666 214.57345459 -315.38853005 191.7391196 C-314.36606186 189.42932183 -313.36859721 187.11059599 -312.37583473 184.78794773 C-297.62667222 151.13976141 -274.6137392 121.36945591 -249.22739723 95.11607273 C-248.74754372 94.61962253 -248.2676902 94.12317234 -247.77329567 93.6116782 C-242.48368784 88.16894019 -237.05255716 82.9797985 -231.22739723 78.11607273 C-230.70500466 77.67456882 -230.18261208 77.23306492 -229.64438942 76.7781821 C-213.69661083 63.34013123 -196.8285241 51.45493394 -178.5511277 41.3953696 C-177.02513958 40.55525847 -175.50316193 39.70781288 -173.98569801 38.85240085 C-120.15120122 8.53576352 -60.86821967 -0.08189714 0 0 Z"/></svg>`}var fe=!1,F=null;function de(e){if(!e)return;let t=e.split(/[\s,]+/).map(o=>o.trim()).filter(Boolean);return t.length?t:void 0}function De(e){if(!e)return;let t=e.split(",").map(o=>o.trim()).filter(Boolean);return t.length?t:void 0}function Z(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function j(e){if(typeof document>"u")return()=>{};F&&F();let t=async i=>{let n=i.target?.closest("[data-hiofu-apply]");if(!n)return;i.preventDefault();let s=n.getAttribute("data-job-id"),r=n.getAttribute("data-job-title"),f=n.getAttribute("data-employer-id"),p=n.getAttribute("data-employer-name"),d=n.getAttribute("data-external-role-id"),y=n.getAttribute("data-external-employer-id"),l=n.getAttribute("data-hiofu-variation-id")??void 0,h=n.getAttribute("data-hiofu-idempotency-key")??void 0,c=de(n.getAttribute("data-hiofu-scopes"));if(!s||!r){let g=new Error("data-job-id and data-job-title are required");n.dispatchEvent(new CustomEvent("hiofu:apply:error",{bubbles:!0,detail:g}));return}n.setAttribute("data-hiofu-loading","1");try{let g={jobId:s,jobTitle:r};f&&(g.employerId=f),p&&(g.employerName=p),l&&(g.variationId=l),h&&(g.idempotencyKey=h),c&&(g.scopes=c),(d||y)&&(g.role={externalRoleId:d??s,externalEmployerId:y??f??void 0,title:n.getAttribute("data-role-title")??r,description:n.getAttribute("data-role-description")??void 0,department:n.getAttribute("data-role-department")??void 0,locations:De(n.getAttribute("data-role-locations")),jobTypes:De(n.getAttribute("data-role-job-types")),salaryMin:Z(n.getAttribute("data-role-salary-min")),salaryMax:Z(n.getAttribute("data-role-salary-max")),salaryCurrency:n.getAttribute("data-role-salary-currency")??void 0,experienceMin:Z(n.getAttribute("data-role-experience-min")),experienceMax:Z(n.getAttribute("data-role-experience-max"))});let L=await e.apply(g);n.dispatchEvent(new CustomEvent("hiofu:apply:success",{bubbles:!0,detail:L}))}catch(g){n.dispatchEvent(new CustomEvent("hiofu:apply:error",{bubbles:!0,detail:g}))}finally{n.removeAttribute("data-hiofu-loading")}};document.querySelectorAll("[data-hiofu-apply]").forEach(i=>{i.style.fontFamily=Y}),document.addEventListener("click",t),fe=!0;let o=()=>{document.removeEventListener("click",t),fe=!1,F===o&&(F=null)};return F=o,o}function Fe(){return fe}function X(){if(typeof document>"u")return null;let e=document.currentScript;if(!e)return null;let t=e.getAttribute("data-client-id");if(!t)return null;let o={clientId:t,hiofuOrigin:e.getAttribute("data-hiofu-origin")??void 0,apiBase:e.getAttribute("data-api-base")??void 0,redirectUri:e.getAttribute("data-redirect-uri")??void 0,scopes:de(e.getAttribute("data-scopes")),applyScopes:de(e.getAttribute("data-apply-scopes"))},i=new S(o);return j(i),i}var T=class extends Error{constructor(t){super(t.message),this.name="HiofuApplyError",this.code=t.code,this.correlationId=t.correlationId,this.retryable=t.retryable,this.cause=t.cause}},ct={sandbox:{hiofuOrigin:"https://sandbox.hiofu.com",apiBase:"https://api.sandbox.hiofu.com/api"},production:{hiofuOrigin:"https://hiofu.com",apiBase:"https://api.hiofu.com/api"}};function me(){return J()}function pt(e,t){if(e==="sandbox"&&!t.startsWith("pk_test_"))throw new T({code:"environment_mismatch",message:"Sandbox integrations must use a pk_test_* publishable key.",correlationId:me(),retryable:!1});if(e==="production"&&!t.startsWith("pk_live_"))throw new T({code:"environment_mismatch",message:"Production integrations must use a pk_live_* publishable key.",correlationId:me(),retryable:!1})}function ft(e){let t=e.role.locations??(e.role.location?[e.role.location]:void 0),o={jobId:e.externalJobId,jobTitle:e.jobTitle??e.role.title,scopes:e.scopes,variationId:e.variationId,idempotencyKey:e.idempotencyKey,role:{externalRoleId:e.externalJobId,title:e.role.title,description:e.role.description,locations:t,metadata:{...e.role.metadata??{},...e.role.skills?{skills:e.role.skills}:{},...e.role.salary?{salary:e.role.salary}:{},...e.role.dimensions?{dimensions:e.role.dimensions}:{},...e.callbackState?{callbackState:e.callbackState}:{},...e.partnerTags?{partnerTags:e.partnerTags}:{}}}};return e.externalEmployerId&&(o.employerId=e.externalEmployerId,o.role.externalEmployerId=e.externalEmployerId),e.employerName&&(o.employerName=e.employerName),o}function dt(e,t,o){let i=e.application.submittedAt instanceof Date?e.application.submittedAt.toISOString():e.application.submittedAt??new Date().toISOString();return{applicationId:e.application.id,partnerApplicationId:o,hiofuRoleId:e.application.jobId??"",status:e.application.status,environment:t,submittedAt:String(i),raw:e}}function mt(e,t){if(e instanceof T)return e;let o=e instanceof Error?e.message:String(e),i="submit_failed",n=!1;if(e instanceof v)i=e.code==="hiofu.environment_mismatch"?"environment_mismatch":"configuration_error";else if(e instanceof U)e.reason==="timed_out"?i="timeout":i="popup_closed",n=!0;else if(/popup blocked/i.test(o))i="popup_blocked",n=!0;else if(/authorization popup closed|popup closed/i.test(o))i="popup_closed",n=!0;else if(/timed out/i.test(o))i="timeout",n=!0;else if(/unknown or inactive client|redirect_uri not registered|partner is not approved|must accept dpa|unknown scope|scope\(s\) not permitted|pkce/i.test(o))i="configuration_error";else if(/access_denied|consent/i.test(o))i="consent_required";else if(e instanceof M){let s=e.body,r=s?.code??s?.error?.code??"";e.status===401||e.status===403?i="auth_failed":/role/i.test(r)||/role/i.test(o)?i="role_mapping_failed":(i="submit_failed",n=e.status>=500)}return new T({code:i,message:o,correlationId:t,retryable:n,cause:e})}function je(e){pt(e.environment,e.publicKey);let t=ct[e.environment],o=new S({clientId:e.publicKey,hiofuOrigin:e.hiofuOrigin??t.hiofuOrigin,apiBase:e.apiBase??t.apiBase,redirectUri:e.redirectUri,scopes:e.scopes,applyScopes:e.applyScopes,storage:e.storage,authorizeTimeoutMs:e.popupOptions?.timeoutMs,onEvent:e.onEvent});return{rawClient:o,authorize(i){return o.authorize(i)},getAccessToken(){return o.getAccessToken()},logout(){return o.logout()},async apply(i){let n=me();try{let s=await o.apply(ft(i)),r=dt(s,e.environment,i.idempotencyKey);return e.onComplete?.(r),r}catch(s){let r=mt(s,n);throw r.code==="consent_required"?e.onCancel?.({reason:"user_cancelled",correlationId:n}):r.code==="popup_closed"?e.onCancel?.({reason:"popup_closed",correlationId:n}):r.code==="timeout"&&e.onCancel?.({reason:"timeout",correlationId:n}),e.onError?.(r),r}}}}function gt(e){if(!e)return"";let t=new URLSearchParams;typeof e.page=="number"&&t.set("page",String(e.page)),typeof e.limit=="number"&&t.set("limit",String(e.limit)),e.status&&t.set("status",e.status),e.search?.trim()&&t.set("search",e.search.trim());let o=t.toString();return o?`?${o}`:""}var $=class{constructor(t={}){this.config=t}async request(t,o={}){let i=this.config.apiBase??A,n=new Headers(this.config.headers);return o.headers&&new Headers(o.headers).forEach((s,r)=>{n.set(r,s)}),k(`${i}${t}`,{...o,headers:n,token:this.config.accessToken,credentials:this.config.credentials??(this.config.accessToken?void 0:"include")})}async listRoles(t){return this.request(`/employer-roles${gt(t)}`)}async getRole(t){return(await this.request(`/employer-roles/${t}`)).data}async createRole(t){return(await this.request("/employer-roles",{method:"POST",body:JSON.stringify(t)})).data}async updateRole(t,o){return(await this.request(`/employer-roles/${t}`,{method:"PATCH",body:JSON.stringify(o)})).data}async updateRoleStatus(t,o){return(await this.request(`/employer-roles/${t}/status`,{method:"PATCH",body:JSON.stringify({status:o})})).data}async getDeveloperSettings(){return(await this.request("/employers/developer/apply-sdk")).data}async issuePublishableKey(){return(await this.request("/employers/developer/apply-sdk",{method:"POST"})).data}async saveRoleMapping(t){let o=null;return(!t.title||!t.description||!t.locations)&&(o=await this.getRole(t.employerRoleId)),(await this.request("/employers/developer/apply-sdk/role-mappings",{method:"POST",body:JSON.stringify({mode:t.mode,externalRoleId:t.externalRoleId,externalEmployerId:t.externalEmployerId,employerRoleId:t.employerRoleId,title:t.title??o?.title,description:t.description??o?.description??void 0,locations:t.locations??o?.locations??void 0,metadata:t.metadata})})).data}async addRedirectUri(t){return(await this.request("/employers/developer/apply-sdk/redirect-uris",{method:"POST",body:JSON.stringify(t)})).data}async removeRedirectUri(t){return(await this.request(`/employers/developer/apply-sdk/redirect-uris/${t}`,{method:"DELETE"})).data}};function $e(e={}){return new $(e)}var N=null,ht={init(e){return N=new S(e),j(N),N},client(){if(!N)throw new Error("Hiofu.init({ clientId }) was not called");return N},apply(e){return this.client().apply(e)},authorize(e){return this.client().authorize(e)},getAccessToken(){return this.client().getAccessToken()},logout(){return this.client().logout()}};if(typeof document<"u"){let e=X();e&&(N=e)}return Ze(yt);})();
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_API_BASE,
|
|
2
3
|
DEFAULT_APPLY_SCOPES,
|
|
3
4
|
DEFAULT_AUTHORIZE_SCOPES,
|
|
5
|
+
HIOFU_BRAND_COLOR,
|
|
6
|
+
HIOFU_BRAND_SOFT,
|
|
7
|
+
HIOFU_BUTTON_LABEL,
|
|
8
|
+
HIOFU_FONT_FAMILY,
|
|
9
|
+
HIOFU_FONT_URL,
|
|
10
|
+
HIOFU_TAGLINE,
|
|
11
|
+
HIOFU_WORDMARK,
|
|
4
12
|
HiofuApiError,
|
|
5
13
|
HiofuClient,
|
|
6
14
|
HiofuConfigurationError,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var HIOFU_BRAND_SOFT = "#eaf4ff";
|
|
13
|
-
var HIOFU_WORDMARK = "HIOFU";
|
|
14
|
-
var HIOFU_BUTTON_LABEL = "Apply with HSP1";
|
|
15
|
-
var HIOFU_TAGLINE = "Skills Passport Platform";
|
|
16
|
-
var HIOFU_FONT_FAMILY = "'Geist', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif";
|
|
17
|
-
var HIOFU_FONT_URL = "https://fonts.googleapis.com/css2?family=Geist:wght@400;600&display=swap";
|
|
18
|
-
function hiofuLogoSvg({
|
|
19
|
-
size = 24,
|
|
20
|
-
color = HIOFU_BRAND_COLOR
|
|
21
|
-
} = {}) {
|
|
22
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4000 4000" width="${size}" height="${size}" fill="none" aria-hidden="true"><path fill="${color}" transform="translate(1034,1034)" d="M0 0 C212.85 0 425.7 0 645 0 C645 212.52 645 425.04 645 644 C856.89636356 643.96037473 856.89636356 643.96037473 1068.79272461 643.90991211 C1109.66711426 643.90539551 1109.66711426 643.90539551 1128.76930237 643.90455627 C1143.06830418 643.90355843 1157.3673013 643.89923459 1171.66630179 643.89332657 C1186.22879895 643.88739059 1200.79129313 643.88515942 1215.35379145 643.88655505 C1224.02511491 643.88727558 1232.69642734 643.8852541 1241.36774878 643.8791924 C1247.08119714 643.87546737 1252.79463809 643.87531229 1258.50808695 643.87816466 C1261.76999766 643.87968819 1265.03188252 643.87902557 1268.29379189 643.87511742 C1271.80233562 643.87115732 1275.31082282 643.87323457 1278.8193655 643.87695217 C1279.84998128 643.87432515 1280.88059705 643.87169812 1281.94244361 643.86899149 C1282.86776725 643.87123879 1283.7930909 643.8734861 1284.74645466 643.8758015 C1285.54991085 643.87564552 1286.35336705 643.87548954 1287.1811704 643.87532884 C1289 644 1289 644 1290 645 C1290.09699984 646.41513221 1290.12447387 647.83509264 1290.1241985 649.25354534 C1290.1264458 650.17886899 1290.12869311 651.10419264 1290.13100851 652.05755639 C1290.12706797 653.60348006 1290.12706797 653.60348006 1290.12304783 655.1806345 C1290.12477845 656.81393262 1290.12477845 656.81393262 1290.12654402 658.48022666 C1290.12921807 662.17649429 1290.12468308 665.87271951 1290.12025452 669.56898499 C1290.12069145 672.21977348 1290.12152514 674.87055912 1290.12284851 677.52134705 C1290.12493343 683.3176645 1290.12326705 689.11397171 1290.11921513 694.91028798 C1290.11313165 703.64128822 1290.11284368 712.37228222 1290.11368043 721.1032842 C1290.11492471 735.73246789 1290.11162001 750.36164711 1290.10557556 764.99082947 C1290.09741702 784.77151653 1290.09547353 804.55219592 1290.09460449 824.33288574 C1290.08934731 871.90942474 1290.07538629 919.48596246 1290.0625 967.0625 C1290.041875 1073.301875 1290.02125 1179.54125 1290 1289 C1502.52 1289 1715.04 1289 1934 1289 C1934 1501.85 1934 1714.7 1934 1934 C1721.15 1934 1508.3 1934 1289 1934 C1288.625 1772.5 1288.625 1772.5 1288.52197266 1721.65039062 C1288.48202947 1706.50774795 1288.48202947 1706.50774795 1288.43954468 1691.3651123 C1288.42080214 1684.66068632 1288.40721862 1677.95627536 1288.39730835 1671.25183105 C1288.38581716 1663.49036763 1288.36742107 1655.72895444 1288.34107121 1647.96752676 C1288.3278415 1644.01067253 1288.31732704 1640.05387476 1288.31574559 1636.09699726 C1288.30745247 1620.60432768 1288.04882577 1605.17510698 1287.08163452 1589.70935059 C1287.00124612 1588.42143317 1286.92085773 1587.13351575 1286.83803332 1585.80657053 C1282.06455978 1515.63263785 1252.40600162 1448.19883165 1205.11328125 1396.33203125 C1203.22623463 1394.24965264 1201.38941767 1392.13496936 1199.5625 1390 C1192.95235187 1382.42587194 1185.71742314 1375.4353351 1178 1369 C1177.46697266 1368.55317871 1176.93394531 1368.10635742 1176.38476562 1367.64599609 C1159.24283074 1353.32553103 1141.43739688 1341.01413992 1122 1330 C1121.33468262 1329.61505371 1120.66936523 1329.23010742 1119.98388672 1328.83349609 C1079.10735154 1305.20781221 1028.19860917 1291.13249309 980.95703125 1290.76171875 C979.92285568 1290.7519249 978.88868011 1290.74213104 977.82316589 1290.73204041 C954.89597459 1290.55972646 932.58691104 1290.71914018 910 1295 C908.85321777 1295.21430664 907.70643555 1295.42861328 906.52490234 1295.64941406 C850.7227533 1306.40136369 798.57630888 1331.24788422 756 1369 C755.03191406 1369.85722656 754.06382812 1370.71445313 753.06640625 1371.59765625 C741.20418581 1382.29413391 729.84647149 1393.39927075 720 1406 C719.04945705 1407.16357244 718.09615669 1408.32489584 717.140625 1409.484375 C710.17564591 1417.97433671 703.86187772 1426.7156136 698 1436 C697.63342285 1436.57621094 697.2668457 1437.15242188 696.88916016 1437.74609375 C667.61100204 1484.08675854 650.28720896 1537.03647257 646.91055298 1591.7442627 C646.86805293 1592.4281217 646.82555287 1593.11198071 646.78176494 1593.81656271 C645.83996196 1609.26927039 645.68958126 1624.69941296 645.68335578 1640.17642534 C645.67948705 1644.19779951 645.66412082 1648.21913577 645.6503849 1652.24048615 C645.62553662 1659.99201109 645.61033146 1667.74352268 645.59880099 1675.49507764 C645.58498323 1684.49056295 645.55865582 1693.48598508 645.5324707 1702.48144531 C645.46955608 1726.15427147 645.42326434 1749.82713944 645.375 1773.5 C645.25125 1826.465 645.1275 1879.43 645 1934 C432.15 1934 219.3 1934 0 1934 C0 1721.15 0 1508.3 0 1289 C160.5625 1288.625 160.5625 1288.625 211.12329102 1288.52197266 C226.17547199 1288.48203099 226.17547199 1288.48203099 241.22764587 1288.43954468 C247.89378247 1288.42079659 254.55990392 1288.407216 261.22605896 1288.39730835 C268.94216177 1288.38582173 276.65821399 1288.36743205 284.37428081 1288.34107121 C288.30848121 1288.32783468 292.24262471 1288.31732587 296.17684853 1288.31574559 C311.39652544 1288.3075441 326.56079366 1288.06692488 341.75254822 1287.08944702 C342.99136232 1287.01010599 344.23017642 1286.93076495 345.50653034 1286.84901965 C387.02631279 1283.93222903 427.79434077 1272.55595424 465 1254 C466.31967773 1253.35925537 466.31967773 1253.35925537 467.66601562 1252.70556641 C492.1979482 1240.77197411 514.44418239 1224.84575596 535 1207 C535.80695312 1206.30648437 536.61390625 1205.61296875 537.4453125 1204.8984375 C549.58245126 1194.2424411 561.09572755 1182.76471215 571 1170 C571.94755571 1168.83872009 572.89829595 1167.68003411 573.8515625 1166.5234375 C580.82061869 1158.03191742 587.13612786 1149.28754528 593 1140 C593.36657715 1139.42378906 593.7331543 1138.84757812 594.11083984 1138.25390625 C623.52719041 1091.69451424 642.93520462 1035.77851825 643.203125 980.33984375 C643.21018463 979.36022675 643.21724426 978.38060974 643.22451782 977.37130737 C643.46827251 947.05917734 643.46827251 947.05917734 640 917 C639.79600586 915.85160645 639.59201172 914.70321289 639.38183594 913.52001953 C624.33070602 831.13315773 579.21845208 754.47206937 510.04174805 705.98974609 C499.64395414 698.85804342 488.92923007 692.28184987 478 686 C477.31856934 685.60361328 476.63713867 685.20722656 475.93505859 684.79882812 C421.32602944 653.31303265 359.70138388 645.90857123 297.84687839 645.79942851 C293.78017846 645.79117312 289.71349636 645.77734735 285.64680958 645.76427555 C277.78419488 645.73981035 269.92157578 645.72012322 262.05894377 645.70219031 C252.94736361 645.6811969 243.83580796 645.65411741 234.72424316 645.6270752 C210.71200946 645.55876501 186.69975307 645.4986243 162.6875 645.4375 C109.000625 645.293125 55.31375 645.14875 0 645 C0 432.15 0 219.3 0 0 Z"/><path fill="${color}" opacity="0.55" transform="translate(2665.2273972332478,1033.88392727077)" d="M0 0 C4.13109652 0.00441336 8.26219201 0.00290235 12.39329025 0.00218208 C20.38739589 0.0016536 28.38149015 0.00623972 36.37559288 0.01268341 C45.6357789 0.01992215 54.89595822 0.02068027 64.15614769 0.02146824 C88.56996783 0.02670501 112.98378547 0.04066624 137.39760277 0.05357273 C191.97135277 0.07419773 246.54510277 0.09482273 302.77260277 0.11607273 C302.77260277 212.96607273 302.77260277 425.81607273 302.77260277 645.11607273 C245.88885277 645.17794773 189.00510277 645.23982273 130.39760277 645.30357273 C112.46625999 645.33088474 94.53491722 645.35819675 76.06020042 645.3863364 C54.08778831 645.39988621 54.08778831 645.39988621 43.78685448 645.40240391 C36.62463329 645.40518787 29.46248328 645.41613414 22.30028221 645.43279941 C14.01926219 645.45203915 5.73830981 645.46054737 -2.54273266 645.45640758 C-6.76923774 645.45461797 -10.99559212 645.457241 -15.22206882 645.47371812 C-38.9778459 645.56183254 -62.35832648 644.49213945 -85.66489723 639.42857273 C-86.85824684 639.17366062 -88.05159645 638.91874851 -89.28110817 638.65611179 C-116.04222495 632.75696648 -142.12677201 623.98604368 -166.36020973 611.0960532 C-168.27037284 610.09351728 -170.198279 609.13534185 -172.13364723 608.18247898 C-189.97415333 599.26222593 -206.80822277 587.75093662 -222.22739723 575.11607273 C-222.73706032 574.70115574 -223.24672341 574.28623874 -223.77183083 573.85874851 C-243.26481687 557.928418 -261.11849809 540.28009887 -276.22739723 520.11607273 C-277.12709111 518.93635037 -278.02683124 517.75666329 -278.92661598 516.57701023 C-286.30270586 506.80899554 -292.90835946 496.59425731 -299.22739723 486.11607273 C-299.65907204 485.40144871 -300.09074684 484.68682468 -300.5355027 483.95054539 C-326.42724396 440.54826299 -342.06636784 387.5809744 -342.46567848 336.97544773 C-342.48036926 335.4263068 -342.48036926 335.4263068 -342.49535683 333.84587009 C-342.66772841 310.94951731 -342.5024975 288.67259489 -338.22739723 266.11607273 C-337.90593727 264.39589939 -337.90593727 264.39589939 -337.57798317 262.64097507 C-332.85158743 238.11118756 -325.49772666 214.57345459 -315.38853005 191.7391196 C-314.36606186 189.42932183 -313.36859721 187.11059599 -312.37583473 184.78794773 C-297.62667222 151.13976141 -274.6137392 121.36945591 -249.22739723 95.11607273 C-248.74754372 94.61962253 -248.2676902 94.12317234 -247.77329567 93.6116782 C-242.48368784 88.16894019 -237.05255716 82.9797985 -231.22739723 78.11607273 C-230.70500466 77.67456882 -230.18261208 77.23306492 -229.64438942 76.7781821 C-213.69661083 63.34013123 -196.8285241 51.45493394 -178.5511277 41.3953696 C-177.02513958 40.55525847 -175.50316193 39.70781288 -173.98569801 38.85240085 C-120.15120122 8.53576352 -60.86821967 -0.08189714 0 0 Z"/></svg>`;
|
|
23
|
-
}
|
|
15
|
+
HiofuPopupError,
|
|
16
|
+
createRandomId,
|
|
17
|
+
hiofuLogoSvg,
|
|
18
|
+
jsonFetch
|
|
19
|
+
} from "./chunk-MFY3F4OY.js";
|
|
24
20
|
|
|
25
21
|
// src/auto-bind.ts
|
|
26
22
|
var bound = false;
|
|
@@ -60,9 +56,9 @@ function autoBind(client) {
|
|
|
60
56
|
const variationId = target.getAttribute("data-hiofu-variation-id") ?? void 0;
|
|
61
57
|
const idempotencyKey = target.getAttribute("data-hiofu-idempotency-key") ?? void 0;
|
|
62
58
|
const scopes = parseScopes(target.getAttribute("data-hiofu-scopes"));
|
|
63
|
-
if (!jobId || !jobTitle
|
|
59
|
+
if (!jobId || !jobTitle) {
|
|
64
60
|
const err = new Error(
|
|
65
|
-
"data-job-id
|
|
61
|
+
"data-job-id and data-job-title are required"
|
|
66
62
|
);
|
|
67
63
|
target.dispatchEvent(
|
|
68
64
|
new CustomEvent("hiofu:apply:error", {
|
|
@@ -76,17 +72,17 @@ function autoBind(client) {
|
|
|
76
72
|
try {
|
|
77
73
|
const applyOptions = {
|
|
78
74
|
jobId,
|
|
79
|
-
jobTitle
|
|
80
|
-
employerId,
|
|
81
|
-
employerName
|
|
75
|
+
jobTitle
|
|
82
76
|
};
|
|
77
|
+
if (employerId) applyOptions.employerId = employerId;
|
|
78
|
+
if (employerName) applyOptions.employerName = employerName;
|
|
83
79
|
if (variationId) applyOptions.variationId = variationId;
|
|
84
80
|
if (idempotencyKey) applyOptions.idempotencyKey = idempotencyKey;
|
|
85
81
|
if (scopes) applyOptions.scopes = scopes;
|
|
86
82
|
if (externalRoleId || externalEmployerId) {
|
|
87
83
|
applyOptions.role = {
|
|
88
84
|
externalRoleId: externalRoleId ?? jobId,
|
|
89
|
-
externalEmployerId: externalEmployerId ?? employerId,
|
|
85
|
+
externalEmployerId: externalEmployerId ?? employerId ?? void 0,
|
|
90
86
|
title: target.getAttribute("data-role-title") ?? jobTitle,
|
|
91
87
|
description: target.getAttribute("data-role-description") ?? void 0,
|
|
92
88
|
department: target.getAttribute("data-role-department") ?? void 0,
|
|
@@ -202,17 +198,14 @@ function assertPublicKey(environment, publicKey) {
|
|
|
202
198
|
}
|
|
203
199
|
function toApplyOptions(payload) {
|
|
204
200
|
const locations = payload.role.locations ?? (payload.role.location ? [payload.role.location] : void 0);
|
|
205
|
-
|
|
201
|
+
const options = {
|
|
206
202
|
jobId: payload.externalJobId,
|
|
207
203
|
jobTitle: payload.jobTitle ?? payload.role.title,
|
|
208
|
-
employerId: payload.externalEmployerId,
|
|
209
|
-
employerName: payload.employerName ?? payload.externalEmployerId,
|
|
210
204
|
scopes: payload.scopes,
|
|
211
205
|
variationId: payload.variationId,
|
|
212
206
|
idempotencyKey: payload.idempotencyKey,
|
|
213
207
|
role: {
|
|
214
208
|
externalRoleId: payload.externalJobId,
|
|
215
|
-
externalEmployerId: payload.externalEmployerId,
|
|
216
209
|
title: payload.role.title,
|
|
217
210
|
description: payload.role.description,
|
|
218
211
|
locations,
|
|
@@ -226,6 +219,14 @@ function toApplyOptions(payload) {
|
|
|
226
219
|
}
|
|
227
220
|
}
|
|
228
221
|
};
|
|
222
|
+
if (payload.externalEmployerId) {
|
|
223
|
+
options.employerId = payload.externalEmployerId;
|
|
224
|
+
options.role.externalEmployerId = payload.externalEmployerId;
|
|
225
|
+
}
|
|
226
|
+
if (payload.employerName) {
|
|
227
|
+
options.employerName = payload.employerName;
|
|
228
|
+
}
|
|
229
|
+
return options;
|
|
229
230
|
}
|
|
230
231
|
function toNormalizedResult(result, environment, partnerApplicationId) {
|
|
231
232
|
const submittedAt = result.application.submittedAt instanceof Date ? result.application.submittedAt.toISOString() : result.application.submittedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -246,12 +247,26 @@ function toApplyError(error, correlationId) {
|
|
|
246
247
|
let retryable = false;
|
|
247
248
|
if (error instanceof HiofuConfigurationError) {
|
|
248
249
|
code = error.code === "hiofu.environment_mismatch" ? "environment_mismatch" : "configuration_error";
|
|
250
|
+
} else if (error instanceof HiofuPopupError) {
|
|
251
|
+
if (error.reason === "timed_out") {
|
|
252
|
+
code = "timeout";
|
|
253
|
+
} else {
|
|
254
|
+
code = "popup_closed";
|
|
255
|
+
}
|
|
256
|
+
retryable = true;
|
|
249
257
|
} else if (/popup blocked/i.test(message)) {
|
|
250
258
|
code = "popup_blocked";
|
|
251
259
|
retryable = true;
|
|
260
|
+
} else if (/authorization popup closed|popup closed/i.test(message)) {
|
|
261
|
+
code = "popup_closed";
|
|
262
|
+
retryable = true;
|
|
252
263
|
} else if (/timed out/i.test(message)) {
|
|
253
264
|
code = "timeout";
|
|
254
265
|
retryable = true;
|
|
266
|
+
} else if (/unknown or inactive client|redirect_uri not registered|partner is not approved|must accept dpa|unknown scope|scope\(s\) not permitted|pkce/i.test(
|
|
267
|
+
message
|
|
268
|
+
)) {
|
|
269
|
+
code = "configuration_error";
|
|
255
270
|
} else if (/access_denied|consent/i.test(message)) {
|
|
256
271
|
code = "consent_required";
|
|
257
272
|
} else if (error instanceof HiofuApiError) {
|
|
@@ -314,10 +329,10 @@ function createApplyClient(config) {
|
|
|
314
329
|
const applyError = toApplyError(err, correlationId);
|
|
315
330
|
if (applyError.code === "consent_required") {
|
|
316
331
|
config.onCancel?.({ reason: "user_cancelled", correlationId });
|
|
332
|
+
} else if (applyError.code === "popup_closed") {
|
|
333
|
+
config.onCancel?.({ reason: "popup_closed", correlationId });
|
|
317
334
|
} else if (applyError.code === "timeout") {
|
|
318
335
|
config.onCancel?.({ reason: "timeout", correlationId });
|
|
319
|
-
} else if (/popup closed/i.test(applyError.message)) {
|
|
320
|
-
config.onCancel?.({ reason: "popup_closed", correlationId });
|
|
321
336
|
}
|
|
322
337
|
config.onError?.(applyError);
|
|
323
338
|
throw applyError;
|
|
@@ -326,6 +341,149 @@ function createApplyClient(config) {
|
|
|
326
341
|
};
|
|
327
342
|
}
|
|
328
343
|
|
|
344
|
+
// src/management.ts
|
|
345
|
+
function buildQuery(params) {
|
|
346
|
+
if (!params) {
|
|
347
|
+
return "";
|
|
348
|
+
}
|
|
349
|
+
const search = new URLSearchParams();
|
|
350
|
+
if (typeof params.page === "number") {
|
|
351
|
+
search.set("page", String(params.page));
|
|
352
|
+
}
|
|
353
|
+
if (typeof params.limit === "number") {
|
|
354
|
+
search.set("limit", String(params.limit));
|
|
355
|
+
}
|
|
356
|
+
if (params.status) {
|
|
357
|
+
search.set("status", params.status);
|
|
358
|
+
}
|
|
359
|
+
if (params.search?.trim()) {
|
|
360
|
+
search.set("search", params.search.trim());
|
|
361
|
+
}
|
|
362
|
+
const query = search.toString();
|
|
363
|
+
return query ? `?${query}` : "";
|
|
364
|
+
}
|
|
365
|
+
var HiofuManagementClient = class {
|
|
366
|
+
constructor(config = {}) {
|
|
367
|
+
this.config = config;
|
|
368
|
+
}
|
|
369
|
+
async request(path, init = {}) {
|
|
370
|
+
const apiBase = this.config.apiBase ?? DEFAULT_API_BASE;
|
|
371
|
+
const headers = new Headers(this.config.headers);
|
|
372
|
+
if (init.headers) {
|
|
373
|
+
new Headers(init.headers).forEach((value, key) => {
|
|
374
|
+
headers.set(key, value);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
return jsonFetch(`${apiBase}${path}`, {
|
|
378
|
+
...init,
|
|
379
|
+
headers,
|
|
380
|
+
token: this.config.accessToken,
|
|
381
|
+
credentials: this.config.credentials ?? (this.config.accessToken ? void 0 : "include")
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
async listRoles(params) {
|
|
385
|
+
return this.request(
|
|
386
|
+
`/employer-roles${buildQuery(params)}`
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
async getRole(roleId) {
|
|
390
|
+
const response = await this.request(
|
|
391
|
+
`/employer-roles/${roleId}`
|
|
392
|
+
);
|
|
393
|
+
return response.data;
|
|
394
|
+
}
|
|
395
|
+
async createRole(input) {
|
|
396
|
+
const response = await this.request(
|
|
397
|
+
"/employer-roles",
|
|
398
|
+
{
|
|
399
|
+
method: "POST",
|
|
400
|
+
body: JSON.stringify(input)
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
return response.data;
|
|
404
|
+
}
|
|
405
|
+
async updateRole(roleId, input) {
|
|
406
|
+
const response = await this.request(
|
|
407
|
+
`/employer-roles/${roleId}`,
|
|
408
|
+
{
|
|
409
|
+
method: "PATCH",
|
|
410
|
+
body: JSON.stringify(input)
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
return response.data;
|
|
414
|
+
}
|
|
415
|
+
async updateRoleStatus(roleId, status) {
|
|
416
|
+
const response = await this.request(
|
|
417
|
+
`/employer-roles/${roleId}/status`,
|
|
418
|
+
{
|
|
419
|
+
method: "PATCH",
|
|
420
|
+
body: JSON.stringify({ status })
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
return response.data;
|
|
424
|
+
}
|
|
425
|
+
async getDeveloperSettings() {
|
|
426
|
+
const response = await this.request(
|
|
427
|
+
"/employers/developer/apply-sdk"
|
|
428
|
+
);
|
|
429
|
+
return response.data;
|
|
430
|
+
}
|
|
431
|
+
async issuePublishableKey() {
|
|
432
|
+
const response = await this.request(
|
|
433
|
+
"/employers/developer/apply-sdk",
|
|
434
|
+
{
|
|
435
|
+
method: "POST"
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
return response.data;
|
|
439
|
+
}
|
|
440
|
+
async saveRoleMapping(input) {
|
|
441
|
+
let resolvedRole = null;
|
|
442
|
+
if (!input.title || !input.description || !input.locations) {
|
|
443
|
+
resolvedRole = await this.getRole(input.employerRoleId);
|
|
444
|
+
}
|
|
445
|
+
const response = await this.request(
|
|
446
|
+
"/employers/developer/apply-sdk/role-mappings",
|
|
447
|
+
{
|
|
448
|
+
method: "POST",
|
|
449
|
+
body: JSON.stringify({
|
|
450
|
+
mode: input.mode,
|
|
451
|
+
externalRoleId: input.externalRoleId,
|
|
452
|
+
externalEmployerId: input.externalEmployerId,
|
|
453
|
+
employerRoleId: input.employerRoleId,
|
|
454
|
+
title: input.title ?? resolvedRole?.title,
|
|
455
|
+
description: input.description ?? resolvedRole?.description ?? void 0,
|
|
456
|
+
locations: input.locations ?? resolvedRole?.locations ?? void 0,
|
|
457
|
+
metadata: input.metadata
|
|
458
|
+
})
|
|
459
|
+
}
|
|
460
|
+
);
|
|
461
|
+
return response.data;
|
|
462
|
+
}
|
|
463
|
+
async addRedirectUri(input) {
|
|
464
|
+
const response = await this.request(
|
|
465
|
+
"/employers/developer/apply-sdk/redirect-uris",
|
|
466
|
+
{
|
|
467
|
+
method: "POST",
|
|
468
|
+
body: JSON.stringify(input)
|
|
469
|
+
}
|
|
470
|
+
);
|
|
471
|
+
return response.data;
|
|
472
|
+
}
|
|
473
|
+
async removeRedirectUri(uriId) {
|
|
474
|
+
const response = await this.request(
|
|
475
|
+
`/employers/developer/apply-sdk/redirect-uris/${uriId}`,
|
|
476
|
+
{
|
|
477
|
+
method: "DELETE"
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
return response.data;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
function createManagementClient(config = {}) {
|
|
484
|
+
return new HiofuManagementClient(config);
|
|
485
|
+
}
|
|
486
|
+
|
|
329
487
|
// src/index.ts
|
|
330
488
|
var _instance = null;
|
|
331
489
|
var Hiofu = {
|
|
@@ -371,9 +529,12 @@ export {
|
|
|
371
529
|
HiofuApplyError,
|
|
372
530
|
HiofuClient,
|
|
373
531
|
HiofuConfigurationError,
|
|
532
|
+
HiofuManagementClient,
|
|
533
|
+
HiofuPopupError,
|
|
374
534
|
autoBind,
|
|
375
535
|
bootstrapFromScriptTag,
|
|
376
536
|
createApplyClient,
|
|
537
|
+
createManagementClient,
|
|
377
538
|
hiofuLogoSvg,
|
|
378
539
|
isAutoBound
|
|
379
540
|
};
|