@loginid/websdk3 3.0.3 → 3.0.5

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/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var J=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var ce=(t,e)=>{for(var r in e)J(t,r,{get:e[r],enumerable:!0})},Ue=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of De(e))!Ne.call(t,o)&&o!==r&&J(t,o,{get:()=>e[o],enumerable:!(s=we(e,o))||s.enumerable});return t};var Fe=t=>Ue(J({},"__esModule",{value:!0}),t);var Ze={};ce(Ze,{AbortError:()=>V,ApiError:()=>m,LoginIDAPI:()=>re,LoginIDWebSDK:()=>le,PasskeyError:()=>c,WebAuthnHelper:()=>z,createPasskeyCredential:()=>v,default:()=>Xe,doesDeviceSupportPasskeys:()=>Ie,getPasskeyCredential:()=>w,isConditionalUIAvailable:()=>Ae,isPlatformAuthenticatorAvailable:()=>Pe});module.exports=Fe(Ze);var M=class{config;constructor(e){this.config=e}getAppId(){if(this.config.appId)return this.config.appId;let e=/https:\/\/([0-9a-fA-F-]+)\.api.*\.loginid\.io/,r=this.config.baseUrl.match(e);if(r)return r[1];throw new Error("Invalid LoginID base URL. App ID not found.")}},L=M;var Le=t=>t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Ke=t=>{if(!t)return t;let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=[],s=0;for(;s<t.length;){let i=t.charCodeAt(s++),a=t.charCodeAt(s++),u=t.charCodeAt(s++),p=i<<16|a<<8|u;r.push(e[p>>18&63]+e[p>>12&63]+e[p>>6&63]+e[p&63])}let o=r.join(""),n=t.length%3;return n?o.slice(0,n-3)+"===".slice(n||3):o},He=t=>{let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={},s=String.fromCharCode;for(let a=0;a<64;a++)r[e.charAt(a)]=a;let o=0,n=0,i="";for(let a of t){let u=r[a];if(u!==void 0)for(o=(o<<6)+u,n+=6;n>=8;)i+=s(o>>(n-=8)&255)}return i},l=t=>{let e="",r=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)e+=String.fromCharCode(r[o]);let s=Ke(e);return Le(s)},R=t=>{t=t.replace(/-/g,"+").replace(/_/g,"/");let e=He(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r.buffer},de=()=>crypto.randomUUID?crypto.randomUUID():window.crypto.getRandomValues(new Uint32Array(4)).join("-"),me=(t,e)=>{e.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(s=>{Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(r.prototype,s)||Object.create(null))})})},D=t=>{try{let r=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(window.atob(r).split("").map(o=>"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(s)}catch(e){console.error(e)}},ye=t=>{let r=`; ${document.cookie}`.split(`; ${t}=`);if(r&&r.length===2)return r.pop().split(";").shift()},fe=t=>{document.cookie=t},he=t=>{document.cookie=`${t}=; expires=${new Date}`};var $=class{config;constructor(e){this.config=new L(e)}getToken(e){if(e.authzToken)return e.authzToken;{let r=this.getJwtCookie();return r||""}}getSessionInfo(){if(!this.isLoggedIn())return null;let e=D(this.getJwtCookie()||"{}");return{username:e.username,id:e.sub}}getJwtCookieName(){return`LoginID_${this.config.getAppId()}_token`}setJwtCookie(e){let r=D(e),s=new Date(r.exp*1e3).toUTCString(),o=`${this.getJwtCookieName()}=${e}; expires=${s}`;fe(o)}getJwtCookie(){return ye(this.getJwtCookieName())}isLoggedIn(){return!!this.getJwtCookie()}logout(){he(this.getJwtCookieName())}},Re=$;var g=class{constructor(e){this.config=e}};var m=class extends Error{url;status;statusText;body;request;constructor(e,r,s){super(s),this.name="ApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.body=r.body,this.request=e}};var N=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},b=class{#t;#r;#e;#o;#n;#i;#s;constructor(e){this.#t=!1,this.#r=!1,this.#e=!1,this.#o=[],this.#n=new Promise((r,s)=>{this.#i=r,this.#s=s;let o=a=>{this.#t||this.#r||this.#e||(this.#t=!0,this.#i&&this.#i(a))},n=a=>{this.#t||this.#r||this.#e||(this.#r=!0,this.#s&&this.#s(a))},i=a=>{this.#t||this.#r||this.#e||this.#o.push(a)};return Object.defineProperty(i,"isResolved",{get:()=>this.#t}),Object.defineProperty(i,"isRejected",{get:()=>this.#r}),Object.defineProperty(i,"isCancelled",{get:()=>this.#e}),e(o,n,i)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(e,r){return this.#n.then(e,r)}catch(e){return this.#n.catch(e)}finally(e){return this.#n.finally(e)}cancel(){if(!(this.#t||this.#r||this.#e)){if(this.#e=!0,this.#o.length)try{for(let e of this.#o)e()}catch(e){console.warn("Cancellation threw an error",e);return}this.#o.length=0,this.#s&&this.#s(new N("Request aborted"))}}get isCancelled(){return this.#e}};var Y=t=>t!=null,U=t=>typeof t=="string",G=t=>U(t)&&t!=="",Q=t=>typeof t=="object"&&typeof t.type=="string"&&typeof t.stream=="function"&&typeof t.arrayBuffer=="function"&&typeof t.constructor=="function"&&typeof t.constructor.name=="string"&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag]),ge=t=>t instanceof FormData,Ve=t=>{try{return btoa(t)}catch{return Buffer.from(t).toString("base64")}},_e=t=>{let e=[],r=(o,n)=>{e.push(`${encodeURIComponent(o)}=${encodeURIComponent(String(n))}`)},s=(o,n)=>{Y(n)&&(Array.isArray(n)?n.forEach(i=>{s(o,i)}):typeof n=="object"?Object.entries(n).forEach(([i,a])=>{s(`${o}[${i}]`,a)}):r(o,n))};return Object.entries(t).forEach(([o,n])=>{s(o,n)}),e.length>0?`?${e.join("&")}`:""},je=(t,e)=>{let r=t.ENCODE_PATH||encodeURI,s=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(n,i)=>e.path?.hasOwnProperty(i)?r(String(e.path[i])):n),o=`${t.BASE}${s}`;return e.query?`${o}${_e(e.query)}`:o},ze=t=>{if(t.formData){let e=new FormData,r=(s,o)=>{U(o)||Q(o)?e.append(s,o):e.append(s,JSON.stringify(o))};return Object.entries(t.formData).filter(([s,o])=>Y(o)).forEach(([s,o])=>{Array.isArray(o)?o.forEach(n=>r(s,n)):r(s,o)}),e}},K=async(t,e)=>typeof e=="function"?e(t):e,We=async(t,e)=>{let[r,s,o,n]=await Promise.all([K(e,t.TOKEN),K(e,t.USERNAME),K(e,t.PASSWORD),K(e,t.HEADERS)]),i=Object.entries({Accept:"application/json",...n,...e.headers}).filter(([a,u])=>Y(u)).reduce((a,[u,p])=>({...a,[u]:String(p)}),{});if(G(r)&&(i.Authorization=`Bearer ${r}`),G(s)&&G(o)){let a=Ve(`${s}:${o}`);i.Authorization=`Basic ${a}`}return e.body&&(e.mediaType?i["Content-Type"]=e.mediaType:Q(e.body)?i["Content-Type"]=e.body.type||"application/octet-stream":U(e.body)?i["Content-Type"]="text/plain":ge(e.body)||(i["Content-Type"]="application/json")),new Headers(i)},Je=t=>{if(t.body!==void 0)return t.mediaType?.includes("/json")?JSON.stringify(t.body):U(t.body)||Q(t.body)||ge(t.body)?t.body:JSON.stringify(t.body)},Me=async(t,e,r,s,o,n,i)=>{let a=new AbortController,u={headers:n,body:s??o,method:e.method,signal:a.signal};return t.WITH_CREDENTIALS&&(u.credentials=t.CREDENTIALS),i(()=>a.abort()),await fetch(r,u)},$e=(t,e)=>{if(e){let r=t.headers.get(e);if(U(r))return r}},Ge=async t=>{if(t.status!==204)try{let e=t.headers.get("Content-Type");if(e)return["application/json","application/problem+json"].some(o=>e.toLowerCase().startsWith(o))?await t.json():await t.text()}catch(e){console.error(e)}},Ye=(t,e)=>{let s={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...t.errors}[e.status];if(s)throw new m(t,e,s);if(!e.ok){let o=e.status??"unknown",n=e.statusText??"unknown",i=(()=>{try{return JSON.stringify(e.body,null,2)}catch{return}})();throw new m(t,e,`Generic Error: status: ${o}; status text: ${n}; body: ${i}`)}},be=(t,e)=>new b(async(r,s,o)=>{try{let n=je(t,e),i=ze(e),a=Je(e),u=await We(t,e);if(!o.isCancelled){let p=await Me(t,e,n,a,i,u,o),d=await Ge(p),h=$e(p,e.responseHeader),W={url:n,ok:p.ok,status:p.status,statusText:p.statusText,body:h??d};Ye(e,W),r(W.body)}}catch(n){s(n)}});var H=class extends g{constructor(e){super(e)}request(e){return be(this.config,e)}};var C=class{constructor(e){this.httpRequest=e}authAuthComplete({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/complete",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthInit({requestBody:e,userAgent:r}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/init",headers:{"User-Agent":r},body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthCodeRequest({authorization:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/otp",headers:{Authorization:e},errors:{401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthCodeRequestEmail({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/otp/email",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthCodeRequestSms({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/otp/sms",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthCodeVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/otp/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var q=class{constructor(e){this.httpRequest=e}mgmtGrantCreate({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/mgmt/grant",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",500:"InternalServerError: Internal Server Error response."}})}mgmtTokenVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/mgmt/token/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",500:"InternalServerError: Internal Server Error response."}})}};var P=class{constructor(e){this.httpRequest=e}passkeysPasskeysList({authorization:e}){return this.httpRequest.request({method:"GET",url:"/fido2/v2/passkeys",headers:{Authorization:e},errors:{401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}passkeysPasskeyDelete({id:e,authorization:r}){return this.httpRequest.request({method:"DELETE",url:"/fido2/v2/passkeys/{id}",path:{id:e},headers:{Authorization:r},errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}passkeysPasskeyRename({id:e,requestBody:r,authorization:s}){return this.httpRequest.request({method:"PUT",url:"/fido2/v2/passkeys/{id}",path:{id:e},headers:{Authorization:s},body:r,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var A=class{constructor(e){this.httpRequest=e}profileProfileDelete({id:e}){return this.httpRequest.request({method:"DELETE",url:"/fido2/v2/profile/{id}",path:{id:e},errors:{404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfileEmailUpdate({id:e,requestBody:r}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/profile/{id}/email",path:{id:e},body:r,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfilePhoneDelete({id:e}){return this.httpRequest.request({method:"DELETE",url:"/fido2/v2/profile/{id}/phone",path:{id:e},errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfilePhoneUpdate({id:e,requestBody:r}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/profile/{id}/phone",path:{id:e},body:r,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfileEmailVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/profile/email/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfilePhoneVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/profile/phone/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var I=class{constructor(e){this.httpRequest=e}regRegComplete({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/reg/complete",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",403:"Forbidden: Forbidden response.",500:"InternalServerError: Internal Server Error response."}})}regRegInit({requestBody:e,userAgent:r,authorization:s}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/reg/init",headers:{"User-Agent":r,Authorization:s},body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",500:"InternalServerError: Internal Server Error response."}})}};var O=class{constructor(e){this.httpRequest=e}txTxComplete({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/tx/complete",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",403:"Forbidden: Forbidden response.",500:"InternalServerError: Internal Server Error response."}})}txTxInit({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/tx/init",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",500:"InternalServerError: Internal Server Error response."}})}};var T=class{constructor(e){this.httpRequest=e}versionVersionShow(){return this.httpRequest.request({method:"GET",url:"/fido2/v2/version"})}};var x=class{constructor(e){this.httpRequest=e}wellKnownJwks(){return this.httpRequest.request({method:"GET",url:"/fido2/v2/.well-known/jwks.json",errors:{500:"InternalServerError: Internal Server Error response."}})}};var k=class{auth;mgmt;passkeys;profile;reg;tx;version;wellKnown;request;constructor(e,r=H){this.request=new r({BASE:e?.BASE??"https://api.loginid.io/fido2/v2",VERSION:e?.VERSION??"2.0",WITH_CREDENTIALS:e?.WITH_CREDENTIALS??!1,CREDENTIALS:e?.CREDENTIALS??"include",TOKEN:e?.TOKEN,USERNAME:e?.USERNAME,PASSWORD:e?.PASSWORD,HEADERS:e?.HEADERS,ENCODE_PATH:e?.ENCODE_PATH}),this.auth=new C(this.request),this.mgmt=new q(this.request),this.passkeys=new P(this.request),this.profile=new A(this.request),this.reg=new I(this.request),this.tx=new O(this.request),this.version=new T(this.request),this.wellKnown=new x(this.request)}};var X=class{config;service;session;constructor(e){this.config=new L(e),this.service=new k({BASE:e.baseUrl}),this.session=new Re(e)}},y=X;var Z=class extends Error{constructor(e){super(e),this.name="AbortError"}},V=Z;var ee=class t{static abortController=new AbortController;static renewWebAuthnAbortController=()=>{let e=new V("Cancelling current WebAuthn request");t.abortController.abort(e);let r=new AbortController;t.abortController=r}},S=ee;var f=(t,e,r)=>({...r,authzToken:e||r.authzToken||"",usernameType:r.usernameType||"email",displayName:r.displayName||t,callbacks:r.callbacks||{}}),Ce=(t,e)=>({...f(t,"",e),txType:e.txType||"raw",nonce:e.nonce||de()}),B=(t,e=!0,r=!1)=>({token:t,isAuthenticated:e,isFallback:r});var te=class extends y{constructor(e){super(e)}async validateOtp(e,r,s={}){let o=f(e,"",s),n={authCode:r,user:{username:e,usernameType:o.usernameType}},i=await this.service.auth.authAuthCodeVerify({requestBody:n}),a=B(i.jwtAccess);return S.renewWebAuthnAbortController(),this.session.setJwtCookie(a.token),a}async requestAndSendOtp(e,r="email",s={}){let o=f(e,"",s),n={user:{username:e,usernameType:o.usernameType}};switch(r){case"email":await this.service.auth.authAuthCodeRequestEmail({requestBody:n});break;case"sms":await this.service.auth.authAuthCodeRequestSms({requestBody:n});break;default:throw new Error("Invalid message method")}}},_=te;var qe=require("ua-parser-js"),F=t=>{let e={clientType:"browser",screenWidth:window.screen.width,screenHeight:window.screen.height,clientName:"",clientVersion:"",osName:"",osVersion:"",osArch:""};return t&&(e.deviceId=t),e},Qe=(t,e)=>{let r=t.split(".").map(Number),s=e.split(".").map(Number),o=Math.max(r.length,s.length);for(let n=0;n<o;n++){let i=n<r.length?r[n]:0,a=n<s.length?s[n]:0;if(i<a)return-1;if(i>a)return 1}return 0};async function Pe(){try{return!window.PublicKeyCredential||!window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?!1:await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return!1}}async function Ae(){try{return!window.PublicKeyCredential||!window.PublicKeyCredential.isConditionalMediationAvailable?!1:await window.PublicKeyCredential.isConditionalMediationAvailable()}catch{return!1}}async function Ie(){let t=new qe.UAParser(window.navigator.userAgent).getResult(),e={solution:"",deviceSupported:!1};if(!window.PublicKeyCredential)return e.solution="Your browser seems to be outdated. Please upgrade to the latest version.",e;if(!await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable())switch(t.os.name){case"Mac OS":{let s=t.browser.version||"";return t.browser.name==="Firefox"&&Qe(s,"122.0")<0?(e.solution="Please update your Firefox browser to the latest version.",e):(e.solution="Enable Touch ID on your device.",e)}case"iOS":return e.solution="Enable Face ID or Touch ID on your device.",e;case"Windows":return e.solution="Enable Windows Hello on your device. See here: https://support.microsoft.com/en-us/windows/learn-about-windows-hello-and-set-it-up-dae28983-8242-bb2a-d3d1-87c9d265a5f0.",e;case"Android":return t.browser.name==="Firefox"?(e.solution="Passkeys may not be supported on your Firefox browser. Please switch to a Chromium browser.",e):(e.solution="Enable device unlock via fingerprint, PIN, or facial recognition on your device.",e);default:return e.solution="Enable device unlock features such as fingerprint, PIN, or facial recognition.",e}return e.deviceSupported=!0,e}var re={};ce(re,{ApiError:()=>m,AuthService:()=>C,BaseHttpRequest:()=>g,CancelError:()=>N,CancelablePromise:()=>b,LoginIDService:()=>k,MgmtService:()=>q,OpenAPI:()=>Oe,PasskeysService:()=>P,ProfileService:()=>A,RegService:()=>I,TxService:()=>O,VersionService:()=>T,WellKnownService:()=>x});var Oe={BASE:"https://api.loginid.io/fido2/v2",VERSION:"2.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:void 0,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0};var oe=class extends y{constructor(e){super(e)}async verifyConfigSettings(){let e={isValid:!0};try{this.config.getAppId()}catch{return e.isValid=!1,e.solution="Please verify that your base URL is correct.",e.code="invalid_app_id",e.message="Invalid app ID",e}try{let r=f("","",{}),s={app:{id:this.config.getAppId()},deviceInfo:F(),user:{username:"",usernameType:r.usernameType}};await this.service.auth.authAuthInit({requestBody:s})}catch(r){return e.isValid=!1,e.solution="Verify that your application exists and the base URL is correct.",e.code="unknown_error",e.message="Unknown error.",r instanceof m&&(e.code=r.body.msgCode||"unknown_error",e.message=r.body.msg||r.body.message||"Unknown error."),e}return e}getSessionInfo(){return this.session.getSessionInfo()}logout(){this.session.logout()}},Te=oe;var xe=t=>`LoginID_${t}_device-id`,E=class{static persistDeviceId(e,r){r&&localStorage.setItem(xe(e),r)}static getDeviceId(e){return localStorage.getItem(xe(e))||""}};var ke=t=>[...t.crossAuthMethods,...t.fallbackMethods];var se=class extends Error{code;constructor(e,r,s){super(e),this.code=r,this.cause=s}},c=se;var ne=class extends Error{constructor(e){super(e),this.name="LoginIDError"}},ie=ne;var Se=(t,e)=>{let r=t.name,{publicKey:s}=e;if(r==="ConstraintError"){if(s?.authenticatorSelection?.requireResidentKey===!0)return new c("Your device does not support discoverable credentials","ERROR_DISCOVERABLE_CREDENTIALS_UNSUPPORTED",t);if(s?.authenticatorSelection?.userVerification==="required")return new c("Your device does not support user verification","ERROR_USER_VERIFICATION_UNSUPPORTED",t)}if(r==="InvalidStateError")return new c("A passkey already exists on your device","ERROR_PASSKEY_EXISTS",t);if(r==="NotAllowedError")return new c("Passkey creation has failed","ERROR_GENERAL_ERROR_SEE_CAUSE_FIELD",t);if(r==="NotSupportedError")return new c("Your device does not support the algorithms required for passkey creation","ERROR_ALGORITHMS_UNSUPPORTED",t);if(r==="SecurityError"){let o=s?.rp?.id;if(o!==window.location.hostname)return new c(`The domain of the relying party (${o}) is invalid for this domain`,"ERROR_DOMAIN_MISMATCH",t)}return r==="UnknownError"?new c("Your device could not process the requested options or could not create a new passkey","ERROR_AUTHENTICATOR_UNKNOWN_ERROR",t):t},Be=(t,e)=>{let r=t.name,{publicKey:s}=e;if(r==="AbortError"&&e.signal instanceof AbortSignal)return new c("Passkey authentication has been aborted","ERROR_PASSKEY_ABORTED",t);if(r==="NotAllowedError")return new c("Passkey authentication has failed","ERROR_GENERAL_ERROR_SEE_CAUSE_FIELD",t);if(r==="SecurityError"){let o=s?.rpId;if(o!==window.location.hostname)return new c(`The domain of the relying party (${o}) is invalid for this domain`,"ERROR_DOMAIN_MISMATCH",t)}return r==="UnknownError"?new c("Your device could not process the requested options or could not authenticate with a passkey","ERROR_AUTHENTICATOR_UNKNOWN_ERROR",t):t},br=new ie("User needs to be logged in to perform this operation."),ae=new ie("No login options available.");var v=async t=>{let e;if(t.excludeCredentials!==void 0){e=[];for(let o of t.excludeCredentials){let n={id:R(o.id),transports:o.transports,type:o.type};e.push(n)}}let r=t.pubKeyCredParams,s={publicKey:{attestation:t.attestation,authenticatorSelection:{...t.authenticatorSelection},challenge:R(t.challenge),excludeCredentials:e,extensions:t.extensions,pubKeyCredParams:r,rp:t.rp,timeout:t.timeout,user:{...t.user,id:R(t.user.id)}}};try{let o=await navigator.credentials.create(s);if(o===null)throw new Error("Failed to create the passkey credential.");return o}catch(o){throw o instanceof Error?Se(o,s):o}},w=async(t,e={})=>{let r;if(t.allowCredentials!==void 0){r=[];for(let o of t.allowCredentials){let n={id:R(o.id),transports:o.transports,type:o.type};r.push(n)}}let s={...e.autoFill&&{mediation:"conditional"},...e.abortSignal&&{signal:e.abortSignal},publicKey:{allowCredentials:r,challenge:R(t.challenge),extensions:t.extensions,rpId:t.rpId,timeout:t.timeout,userVerification:t.userVerification}};try{let o=await navigator.credentials.get(s);if(o===null)throw new Error("Failed to create the passkey credential.");return o}catch(o){throw o instanceof Error?Be(o,s):o}};var ue=class extends _{constructor(e){super(e)}async createNavigatorCredential(e){let{registrationRequestOptions:r,session:s}=e;S.renewWebAuthnAbortController();let o=await v(r),n=o.response,i=n.getPublicKey&&n.getPublicKey(),a=n.getPublicKeyAlgorithm&&n.getPublicKeyAlgorithm(),u=n.getAuthenticatorData&&n.getAuthenticatorData(),p=n.getTransports&&n.getTransports();return{creationResult:{attestationObject:l(n.attestationObject),clientDataJSON:l(n.clientDataJSON),credentialId:o.id,...i&&{publicKey:l(i)},...a&&{publicKeyAlgorithm:a},...u&&{authenticatorData:l(u)},...p&&{transports:p}},session:s}}async createPasskey(e,r="",s={}){let o=this.config.getAppId(),n=F(E.getDeviceId(o)),i=f(e,r,s);i.authzToken=this.session.getToken(i),i.authzToken&&D(i.authzToken).username!==e&&(i.authzToken="");let a={app:{id:o},deviceInfo:n,user:{username:e,usernameType:i.usernameType,displayName:i.displayName}},u=await this.service.reg.regRegInit({requestBody:a,...i.authzToken&&{authorization:i.authzToken}}),p=await this.createNavigatorCredential(u),d=await this.service.reg.regRegComplete({requestBody:p}),h=B(d.jwtAccess);return this.session.setJwtCookie(d.jwtAccess),E.persistDeviceId(o,d.deviceID),h}async getNavigatorCredential(e,r={}){let{assertionOptions:s,session:o}=e;r.abortSignal||(S.renewWebAuthnAbortController(),r.abortSignal=S.abortController.signal);let n=await w(s,r),i=n.response;return{assertionResult:{authenticatorData:l(i.authenticatorData),clientDataJSON:l(i.clientDataJSON),credentialId:n.id,signature:l(i.signature),...i.userHandle&&{userHandle:l(i.userHandle)}},session:o}}async authenticateWithPasskey(e="",r={}){let s=this.config.getAppId(),o=F(E.getDeviceId(s)),n=f(e,"",r),i={app:{id:s},deviceInfo:o,user:{username:e,usernameType:n.usernameType}},a=await this.service.auth.authAuthInit({requestBody:i});switch(a.action){case"proceed":{let u=await this.getNavigatorCredential(a,r),p=await this.service.auth.authAuthComplete({requestBody:u}),d=B(p.jwtAccess);return this.session.setJwtCookie(d.token),n?.callbacks?.onSuccess&&await n.callbacks.onSuccess(d),d}case"crossAuth":case"fallback":{if(n?.callbacks?.onFallback){let u=ke(a);return await n.callbacks.onFallback(e,u),B("",!1,!0)}throw ae}default:throw ae}}async authenticateWithPasskeyAutofill(e={}){return e.autoFill=!0,await this.authenticateWithPasskey("",e)}async requestOtp(e,r={}){if(r.authzToken=this.session.getToken(r),!r.authzToken){let o=await this.authenticateWithPasskey(e,r);r.authzToken=o.token}return await this.service.auth.authAuthCodeRequest({authorization:r.authzToken})}async confirmTransaction(e,r,s={}){let o=Ce(e,s),n={username:e,txPayload:r,nonce:o.nonce,txType:o.txType},{assertionOptions:i,session:a}=await this.service.tx.txTxInit({requestBody:n}),u={action:"proceed",crossAuthMethods:[],fallbackMethods:[],assertionOptions:i,session:a},{assertionResult:p}=await this.getNavigatorCredential(u),d={authenticatorData:p.authenticatorData,clientData:p.clientDataJSON,keyHandle:p.credentialId,session:a,signature:p.signature},h=await this.service.tx.txTxComplete({requestBody:d});return this.session.setJwtCookie(h.jwtAccess),h}},Ee=ue;var pe=class extends y{constructor(e){super(e)}async listPasskeys(e={}){let r=this.session.getToken(e);return await this.service.passkeys.passkeysPasskeysList({authorization:r})}async renamePasskey(e,r,s={}){let o=this.session.getToken(s),n={name:r};await this.service.passkeys.passkeysPasskeyRename({authorization:o,id:e,requestBody:n})}async deletePasskey(e,r={}){let s=this.session.getToken(r);await this.service.passkeys.passkeysPasskeyDelete({authorization:s,id:e})}},ve=pe;var j=class extends y{constructor(e){super(e)}};me(j,[y,Ee,_,ve,Te]);var le=j;var z=class{static async getNavigatorCredential(e,r={}){let{assertionOptions:s,session:o}=e,n=await w(s,r),i=n.response;return{assertionResult:{authenticatorData:l(i.authenticatorData),clientDataJSON:l(i.clientDataJSON),credentialId:n.id,signature:l(i.signature),...i.userHandle&&{userHandle:l(i.userHandle)}},session:o}}static async createNavigatorCredential(e){let{registrationRequestOptions:r,session:s}=e,o=await v(r),n=o.response,i=n.getPublicKey&&n.getPublicKey(),a=n.getPublicKeyAlgorithm&&n.getPublicKeyAlgorithm(),u=n.getAuthenticatorData&&n.getAuthenticatorData(),p=n.getTransports&&n.getTransports();return{creationResult:{attestationObject:l(n.attestationObject),clientDataJSON:l(n.clientDataJSON),credentialId:o.id,...i&&{publicKey:l(i)},...a&&{publicKeyAlgorithm:a},...u&&{authenticatorData:l(u)},...p&&{transports:p}},session:s}}};var Xe=le;0&&(module.exports={AbortError,ApiError,LoginIDAPI,LoginIDWebSDK,PasskeyError,WebAuthnHelper,createPasskeyCredential,doesDeviceSupportPasskeys,getPasskeyCredential,isConditionalUIAvailable,isPlatformAuthenticatorAvailable});
1
+ "use strict";var J=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Ue=Object.prototype.hasOwnProperty;var ce=(t,e)=>{for(var r in e)J(t,r,{get:e[r],enumerable:!0})},Fe=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ne(e))!Ue.call(t,o)&&o!==r&&J(t,o,{get:()=>e[o],enumerable:!(s=De(e,o))||s.enumerable});return t};var Ke=t=>Fe(J({},"__esModule",{value:!0}),t);var et={};ce(et,{AbortError:()=>V,ApiError:()=>m,LoginIDAPI:()=>se,LoginIDWebSDK:()=>de,PasskeyError:()=>d,WebAuthnHelper:()=>_,canCreatePasskey:()=>Ie,createPasskeyCredential:()=>S,default:()=>Ze,doesDeviceSupportPasskeys:()=>oe,getPasskeyCredential:()=>v,isConditionalUIAvailable:()=>Ae,isPlatformAuthenticatorAvailable:()=>re});module.exports=Ke(et);var M=class{config;constructor(e){this.config=e}getAppId(){if(this.config.appId)return this.config.appId;let e=/https:\/\/([0-9a-fA-F-]+)\.api.*\.loginid\.io/,r=this.config.baseUrl.match(e);if(r)return r[1];throw new Error("Invalid LoginID base URL. App ID not found.")}},K=M;var Le=t=>t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),He=t=>{if(!t)return t;let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=[],s=0;for(;s<t.length;){let i=t.charCodeAt(s++),a=t.charCodeAt(s++),u=t.charCodeAt(s++),p=i<<16|a<<8|u;r.push(e[p>>18&63]+e[p>>12&63]+e[p>>6&63]+e[p&63])}let o=r.join(""),n=t.length%3;return n?o.slice(0,n-3)+"===".slice(n||3):o},Ve=t=>{let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={},s=String.fromCharCode;for(let a=0;a<64;a++)r[e.charAt(a)]=a;let o=0,n=0,i="";for(let a of t){let u=r[a];if(u!==void 0)for(o=(o<<6)+u,n+=6;n>=8;)i+=s(o>>(n-=8)&255)}return i},l=t=>{let e="",r=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)e+=String.fromCharCode(r[o]);let s=He(e);return Le(s)},R=t=>{t=t.replace(/-/g,"+").replace(/_/g,"/");let e=Ve(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r.buffer},me=()=>crypto.randomUUID?crypto.randomUUID():window.crypto.getRandomValues(new Uint32Array(4)).join("-"),ye=(t,e)=>{e.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(s=>{Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(r.prototype,s)||Object.create(null))})})},w=t=>{try{let r=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(window.atob(r).split("").map(o=>"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(s)}catch(e){console.error(e)}},fe=t=>{let r=`; ${document.cookie}`.split(`; ${t}=`);if(r&&r.length===2)return r.pop().split(";").shift()},he=t=>{document.cookie=t},Re=t=>{document.cookie=`${t}=; expires=${new Date}`};var $=class{config;constructor(e){this.config=new K(e)}getToken(e){if(e.authzToken)return e.authzToken;{let r=this.getJwtCookie();return r||""}}getSessionInfo(){if(!this.isLoggedIn())return null;let e=w(this.getJwtCookie()||"{}");return{username:e.username,id:e.sub}}getJwtCookieName(){return`LoginID_${this.config.getAppId()}_token`}setJwtCookie(e){let r=w(e),s=new Date(r.exp*1e3).toUTCString(),o=`${this.getJwtCookieName()}=${e}; expires=${s}`;he(o)}getJwtCookie(){return fe(this.getJwtCookieName())}isLoggedIn(){return!!this.getJwtCookie()}logout(){Re(this.getJwtCookieName())}},ge=$;var g=class{constructor(e){this.config=e}};var m=class extends Error{url;status;statusText;body;request;constructor(e,r,s){super(s),this.name="ApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.body=r.body,this.request=e}};var D=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},b=class{#t;#r;#e;#o;#n;#i;#s;constructor(e){this.#t=!1,this.#r=!1,this.#e=!1,this.#o=[],this.#n=new Promise((r,s)=>{this.#i=r,this.#s=s;let o=a=>{this.#t||this.#r||this.#e||(this.#t=!0,this.#i&&this.#i(a))},n=a=>{this.#t||this.#r||this.#e||(this.#r=!0,this.#s&&this.#s(a))},i=a=>{this.#t||this.#r||this.#e||this.#o.push(a)};return Object.defineProperty(i,"isResolved",{get:()=>this.#t}),Object.defineProperty(i,"isRejected",{get:()=>this.#r}),Object.defineProperty(i,"isCancelled",{get:()=>this.#e}),e(o,n,i)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(e,r){return this.#n.then(e,r)}catch(e){return this.#n.catch(e)}finally(e){return this.#n.finally(e)}cancel(){if(!(this.#t||this.#r||this.#e)){if(this.#e=!0,this.#o.length)try{for(let e of this.#o)e()}catch(e){console.warn("Cancellation threw an error",e);return}this.#o.length=0,this.#s&&this.#s(new D("Request aborted"))}}get isCancelled(){return this.#e}};var Y=t=>t!=null,N=t=>typeof t=="string",G=t=>N(t)&&t!=="",Q=t=>typeof t=="object"&&typeof t.type=="string"&&typeof t.stream=="function"&&typeof t.arrayBuffer=="function"&&typeof t.constructor=="function"&&typeof t.constructor.name=="string"&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag]),be=t=>t instanceof FormData,We=t=>{try{return btoa(t)}catch{return Buffer.from(t).toString("base64")}},ze=t=>{let e=[],r=(o,n)=>{e.push(`${encodeURIComponent(o)}=${encodeURIComponent(String(n))}`)},s=(o,n)=>{Y(n)&&(Array.isArray(n)?n.forEach(i=>{s(o,i)}):typeof n=="object"?Object.entries(n).forEach(([i,a])=>{s(`${o}[${i}]`,a)}):r(o,n))};return Object.entries(t).forEach(([o,n])=>{s(o,n)}),e.length>0?`?${e.join("&")}`:""},_e=(t,e)=>{let r=t.ENCODE_PATH||encodeURI,s=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(n,i)=>e.path?.hasOwnProperty(i)?r(String(e.path[i])):n),o=`${t.BASE}${s}`;return e.query?`${o}${ze(e.query)}`:o},je=t=>{if(t.formData){let e=new FormData,r=(s,o)=>{N(o)||Q(o)?e.append(s,o):e.append(s,JSON.stringify(o))};return Object.entries(t.formData).filter(([s,o])=>Y(o)).forEach(([s,o])=>{Array.isArray(o)?o.forEach(n=>r(s,n)):r(s,o)}),e}},L=async(t,e)=>typeof e=="function"?e(t):e,Je=async(t,e)=>{let[r,s,o,n]=await Promise.all([L(e,t.TOKEN),L(e,t.USERNAME),L(e,t.PASSWORD),L(e,t.HEADERS)]),i=Object.entries({Accept:"application/json",...n,...e.headers}).filter(([a,u])=>Y(u)).reduce((a,[u,p])=>({...a,[u]:String(p)}),{});if(G(r)&&(i.Authorization=`Bearer ${r}`),G(s)&&G(o)){let a=We(`${s}:${o}`);i.Authorization=`Basic ${a}`}return e.body&&(e.mediaType?i["Content-Type"]=e.mediaType:Q(e.body)?i["Content-Type"]=e.body.type||"application/octet-stream":N(e.body)?i["Content-Type"]="text/plain":be(e.body)||(i["Content-Type"]="application/json")),new Headers(i)},Me=t=>{if(t.body!==void 0)return t.mediaType?.includes("/json")?JSON.stringify(t.body):N(t.body)||Q(t.body)||be(t.body)?t.body:JSON.stringify(t.body)},$e=async(t,e,r,s,o,n,i)=>{let a=new AbortController,u={headers:n,body:s??o,method:e.method,signal:a.signal};return t.WITH_CREDENTIALS&&(u.credentials=t.CREDENTIALS),i(()=>a.abort()),await fetch(r,u)},Ge=(t,e)=>{if(e){let r=t.headers.get(e);if(N(r))return r}},Ye=async t=>{if(t.status!==204)try{let e=t.headers.get("Content-Type");if(e)return["application/json","application/problem+json"].some(o=>e.toLowerCase().startsWith(o))?await t.json():await t.text()}catch(e){console.error(e)}},Qe=(t,e)=>{let s={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...t.errors}[e.status];if(s)throw new m(t,e,s);if(!e.ok){let o=e.status??"unknown",n=e.statusText??"unknown",i=(()=>{try{return JSON.stringify(e.body,null,2)}catch{return}})();throw new m(t,e,`Generic Error: status: ${o}; status text: ${n}; body: ${i}`)}},Ce=(t,e)=>new b(async(r,s,o)=>{try{let n=_e(t,e),i=je(e),a=Me(e),u=await Je(t,e);if(!o.isCancelled){let p=await $e(t,e,n,a,i,u,o),c=await Ye(p),F=Ge(p,e.responseHeader),j={url:n,ok:p.ok,status:p.status,statusText:p.statusText,body:F??c};Qe(e,j),r(j.body)}}catch(n){s(n)}});var H=class extends g{constructor(e){super(e)}request(e){return Ce(this.config,e)}};var C=class{constructor(e){this.httpRequest=e}authAuthComplete({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/complete",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthInit({requestBody:e,userAgent:r}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/init",headers:{"User-Agent":r},body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthCodeRequest({authorization:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/otp",headers:{Authorization:e},errors:{401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthCodeRequestEmail({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/otp/email",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthCodeRequestSms({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/otp/sms",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}authAuthCodeVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/auth/otp/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var P=class{constructor(e){this.httpRequest=e}mgmtGrantCreate({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/mgmt/grant",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",500:"InternalServerError: Internal Server Error response."}})}mgmtTokenVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/mgmt/token/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",500:"InternalServerError: Internal Server Error response."}})}};var q=class{constructor(e){this.httpRequest=e}passkeysPasskeysList({authorization:e}){return this.httpRequest.request({method:"GET",url:"/fido2/v2/passkeys",headers:{Authorization:e},errors:{401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}passkeysPasskeyDelete({id:e,authorization:r}){return this.httpRequest.request({method:"DELETE",url:"/fido2/v2/passkeys/{id}",path:{id:e},headers:{Authorization:r},errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}passkeysPasskeyRename({id:e,requestBody:r,authorization:s}){return this.httpRequest.request({method:"PUT",url:"/fido2/v2/passkeys/{id}",path:{id:e},headers:{Authorization:s},body:r,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var A=class{constructor(e){this.httpRequest=e}profileProfileDelete({id:e}){return this.httpRequest.request({method:"DELETE",url:"/fido2/v2/profile/{id}",path:{id:e},errors:{404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfileEmailUpdate({id:e,requestBody:r}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/profile/{id}/email",path:{id:e},body:r,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfilePhoneDelete({id:e}){return this.httpRequest.request({method:"DELETE",url:"/fido2/v2/profile/{id}/phone",path:{id:e},errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfilePhoneUpdate({id:e,requestBody:r}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/profile/{id}/phone",path:{id:e},body:r,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfileEmailVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/profile/email/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}profileProfilePhoneVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/profile/phone/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var I=class{constructor(e){this.httpRequest=e}regRegComplete({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/reg/complete",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",403:"Forbidden: Forbidden response.",500:"InternalServerError: Internal Server Error response."}})}regRegInit({requestBody:e,userAgent:r,authorization:s}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/reg/init",headers:{"User-Agent":r,Authorization:s},body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",500:"InternalServerError: Internal Server Error response."}})}};var T=class{constructor(e){this.httpRequest=e}txTxComplete({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/tx/complete",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",403:"Forbidden: Forbidden response.",500:"InternalServerError: Internal Server Error response."}})}txTxInit({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/tx/init",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var O=class{constructor(e){this.httpRequest=e}versionVersionShow(){return this.httpRequest.request({method:"GET",url:"/fido2/v2/version"})}};var x=class{constructor(e){this.httpRequest=e}wellKnownJwks(){return this.httpRequest.request({method:"GET",url:"/fido2/v2/.well-known/jwks.json",errors:{404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var E=class{auth;mgmt;passkeys;profile;reg;tx;version;wellKnown;request;constructor(e,r=H){this.request=new r({BASE:e?.BASE??"https://api.loginid.io/fido2/v2",VERSION:e?.VERSION??"2.0",WITH_CREDENTIALS:e?.WITH_CREDENTIALS??!1,CREDENTIALS:e?.CREDENTIALS??"include",TOKEN:e?.TOKEN,USERNAME:e?.USERNAME,PASSWORD:e?.PASSWORD,HEADERS:e?.HEADERS,ENCODE_PATH:e?.ENCODE_PATH}),this.auth=new C(this.request),this.mgmt=new P(this.request),this.passkeys=new q(this.request),this.profile=new A(this.request),this.reg=new I(this.request),this.tx=new T(this.request),this.version=new O(this.request),this.wellKnown=new x(this.request)}};var X=class{config;service;session;constructor(e){this.config=new K(e),this.service=new E({BASE:e.baseUrl}),this.session=new ge(e)}},y=X;var Z=class extends Error{constructor(e){super(e),this.name="AbortError"}},V=Z;var ee=class t{static abortController=new AbortController;static abortWebAuthnRequest=()=>{let e=new V("Cancelling current WebAuthn request");t.abortController.abort(e)};static renewWebAuthnAbortController=()=>{t.abortWebAuthnRequest();let e=new AbortController;t.abortController=e};static assignWebAuthnAbortController=e=>{t.abortWebAuthnRequest(),t.abortController=e}},h=ee;var f=(t,e,r)=>({...r,authzToken:e||r.authzToken||"",usernameType:r.usernameType||"other",displayName:r.displayName||t,callbacks:r.callbacks||{}}),Pe=(t,e)=>({...f(t,"",e),txType:e.txType||"raw",nonce:e.nonce||me()}),k=(t,e=!0,r=!1)=>({token:t,isAuthenticated:e,isFallback:r});var te=class extends y{constructor(e){super(e)}async validateOtp(e,r,s={}){let o=f(e,"",s),n={authCode:r,user:{username:e,usernameType:o.usernameType}},i=await this.service.auth.authAuthCodeVerify({requestBody:n}),a=k(i.jwtAccess);return h.renewWebAuthnAbortController(),this.session.setJwtCookie(a.token),a}async requestAndSendOtp(e,r="email",s={}){let o=f(e,"",s),n={user:{username:e,usernameType:o.usernameType}};switch(r){case"email":await this.service.auth.authAuthCodeRequestEmail({requestBody:n});break;case"sms":await this.service.auth.authAuthCodeRequestSms({requestBody:n});break;default:throw new Error("Invalid message method")}}},W=te;var qe=require("ua-parser-js"),U=t=>{let e={clientType:"browser",screenWidth:window.screen.width,screenHeight:window.screen.height,clientName:"",clientVersion:"",osName:"",osVersion:"",osArch:""};return t&&(e.deviceId=t),e},Xe=(t,e)=>{let r=t.split(".").map(Number),s=e.split(".").map(Number),o=Math.max(r.length,s.length);for(let n=0;n<o;n++){let i=n<r.length?r[n]:0,a=n<s.length?s[n]:0;if(i<a)return-1;if(i>a)return 1}return 0};async function re(){try{return!window.PublicKeyCredential||!window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?!1:await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return!1}}async function Ae(){try{return!window.PublicKeyCredential||!window.PublicKeyCredential.isConditionalMediationAvailable?!1:await window.PublicKeyCredential.isConditionalMediationAvailable()}catch{return!1}}async function oe(){let t=new qe.UAParser(window.navigator.userAgent).getResult(),e={solution:"",deviceSupported:!1};if(!window.PublicKeyCredential)return e.solution="Your browser seems to be outdated. Please upgrade to the latest version.",e;if(!await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable())switch(t.os.name){case"Mac OS":{let s=t.browser.version||"";return t.browser.name==="Firefox"&&Xe(s,"122.0")<0?(e.solution="Please update your Firefox browser to the latest version.",e):(e.solution="Enable Touch ID on your device.",e)}case"iOS":return e.solution="Enable Face ID or Touch ID on your device.",e;case"Windows":return e.solution="Enable Windows Hello on your device. See here: https://support.microsoft.com/en-us/windows/learn-about-windows-hello-and-set-it-up-dae28983-8242-bb2a-d3d1-87c9d265a5f0.",e;case"Android":return t.browser.name==="Firefox"?(e.solution="Passkeys may not be supported on your Firefox browser. Please switch to a Chromium browser.",e):(e.solution="Enable device unlock via fingerprint, PIN, or facial recognition on your device.",e);default:return e.solution="Enable device unlock features such as fingerprint, PIN, or facial recognition.",e}return e.deviceSupported=!0,e}async function Ie(){let t=await re(),e=await oe();return t&&e.deviceSupported}var se={};ce(se,{ApiError:()=>m,AuthService:()=>C,BaseHttpRequest:()=>g,CancelError:()=>D,CancelablePromise:()=>b,LoginIDService:()=>E,MgmtService:()=>P,OpenAPI:()=>Te,PasskeysService:()=>q,ProfileService:()=>A,RegService:()=>I,TxService:()=>T,VersionService:()=>O,WellKnownService:()=>x});var Te={BASE:"https://api.loginid.io/fido2/v2",VERSION:"2.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:void 0,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0};var ne=class extends y{constructor(e){super(e)}async verifyConfigSettings(){let e={isValid:!0};try{this.config.getAppId()}catch{return e.isValid=!1,e.solution="Please verify that your base URL is correct.",e.code="invalid_app_id",e.message="Invalid app ID",e}try{let r=f("","",{}),s={app:{id:this.config.getAppId()},deviceInfo:U(),user:{username:"",usernameType:r.usernameType}};await this.service.auth.authAuthInit({requestBody:s})}catch(r){return e.isValid=!1,e.solution="Verify that your application exists and the base URL is correct.",e.code="unknown_error",e.message="Unknown error.",r instanceof m&&(e.code=r.body.msgCode||"unknown_error",e.message=r.body.msg||r.body.message||"Unknown error."),e}return e}getSessionInfo(){return this.session.getSessionInfo()}logout(){this.session.logout()}},Oe=ne;var xe=t=>`LoginID_${t}_device-id`,B=class{static persistDeviceId(e,r){r&&localStorage.setItem(xe(e),r)}static getDeviceId(e){return localStorage.getItem(xe(e))||""}};var Ee=t=>[...t.crossAuthMethods,...t.fallbackMethods];var ie=class extends Error{code;constructor(e,r,s){super(e),this.code=r,this.cause=s}},d=ie;var ae=class extends Error{constructor(e){super(e),this.name="LoginIDError"}},ue=ae;var ke=(t,e)=>{let r=t.name,{publicKey:s}=e;if(r==="ConstraintError"){if(s?.authenticatorSelection?.requireResidentKey===!0)return new d("Your device does not support discoverable credentials","ERROR_DISCOVERABLE_CREDENTIALS_UNSUPPORTED",t);if(s?.authenticatorSelection?.userVerification==="required")return new d("Your device does not support user verification","ERROR_USER_VERIFICATION_UNSUPPORTED",t)}if(r==="InvalidStateError")return new d("A passkey already exists on your device","ERROR_PASSKEY_EXISTS",t);if(r==="NotAllowedError")return new d("Passkey creation has failed","ERROR_GENERAL_ERROR_SEE_CAUSE_FIELD",t);if(r==="NotSupportedError")return new d("Your device does not support the algorithms required for passkey creation","ERROR_ALGORITHMS_UNSUPPORTED",t);if(r==="SecurityError"){let o=s?.rp?.id;if(o!==window.location.hostname)return new d(`The domain of the relying party (${o}) is invalid for this domain`,"ERROR_DOMAIN_MISMATCH",t)}return r==="UnknownError"?new d("Your device could not process the requested options or could not create a new passkey","ERROR_AUTHENTICATOR_UNKNOWN_ERROR",t):t},Be=(t,e)=>{let r=t.name,{publicKey:s}=e;if(r==="AbortError"&&e.signal instanceof AbortSignal)return new d("Passkey authentication has been aborted","ERROR_PASSKEY_ABORTED",t);if(r==="NotAllowedError")return new d("Passkey authentication has failed","ERROR_GENERAL_ERROR_SEE_CAUSE_FIELD",t);if(r==="SecurityError"){let o=s?.rpId;if(o!==window.location.hostname)return new d(`The domain of the relying party (${o}) is invalid for this domain`,"ERROR_DOMAIN_MISMATCH",t)}return r==="UnknownError"?new d("Your device could not process the requested options or could not authenticate with a passkey","ERROR_AUTHENTICATOR_UNKNOWN_ERROR",t):t},Cr=new ue("User needs to be logged in to perform this operation."),Se=new ue("No login options available.");var S=async t=>{let e;if(t.excludeCredentials!==void 0){e=[];for(let o of t.excludeCredentials){let n={id:R(o.id),transports:o.transports,type:o.type};e.push(n)}}let r=t.pubKeyCredParams,s={publicKey:{attestation:t.attestation,authenticatorSelection:{...t.authenticatorSelection},challenge:R(t.challenge),excludeCredentials:e,extensions:t.extensions,pubKeyCredParams:r,rp:t.rp,timeout:t.timeout,user:{...t.user,id:R(t.user.id)}}};try{let o=await navigator.credentials.create(s);if(o===null)throw new Error("Failed to create the passkey credential.");return o}catch(o){throw o instanceof Error?ke(o,s):o}},v=async(t,e={})=>{let r;if(t.allowCredentials!==void 0){r=[];for(let o of t.allowCredentials){let n={id:R(o.id),transports:o.transports,type:o.type};r.push(n)}}let s={...e.autoFill&&{mediation:"conditional"},...e.abortController&&{signal:e.abortController.signal},publicKey:{allowCredentials:r,challenge:R(t.challenge),extensions:t.extensions,rpId:t.rpId,timeout:t.timeout,userVerification:t.userVerification}};try{let o=await navigator.credentials.get(s);if(o===null)throw new Error("Failed to create the passkey credential.");return o}catch(o){throw o instanceof Error?Be(o,s):o}};var pe=class extends W{constructor(e){super(e)}async createNavigatorCredential(e){let{registrationRequestOptions:r,session:s}=e;h.renewWebAuthnAbortController();let o=await S(r),n=o.response,i=n.getPublicKey&&n.getPublicKey(),a=n.getPublicKeyAlgorithm&&n.getPublicKeyAlgorithm(),u=n.getAuthenticatorData&&n.getAuthenticatorData(),p=n.getTransports&&n.getTransports();return{creationResult:{attestationObject:l(n.attestationObject),clientDataJSON:l(n.clientDataJSON),credentialId:o.id,...i&&{publicKey:l(i)},...a&&{publicKeyAlgorithm:a},...u&&{authenticatorData:l(u)},...p&&{transports:p}},session:s}}async createPasskey(e,r="",s={}){let o=this.config.getAppId(),n=U(B.getDeviceId(o)),i=f(e,r,s);i.authzToken=this.session.getToken(i),i.authzToken&&w(i.authzToken).username!==e&&(i.authzToken="");let a={app:{id:o},deviceInfo:n,user:{username:e,usernameType:i.usernameType,displayName:i.displayName}},u=await this.service.reg.regRegInit({requestBody:a,...i.authzToken&&{authorization:i.authzToken}}),p=await this.createNavigatorCredential(u),c=await this.service.reg.regRegComplete({requestBody:p}),F=k(c.jwtAccess);return this.session.setJwtCookie(c.jwtAccess),B.persistDeviceId(o,c.deviceID),F}async getNavigatorCredential(e,r={}){let{assertionOptions:s,session:o}=e;r.abortController?h.assignWebAuthnAbortController(r.abortController):(h.renewWebAuthnAbortController(),r.abortController=h.abortController);let n=await v(s,r),i=n.response;return{assertionResult:{authenticatorData:l(i.authenticatorData),clientDataJSON:l(i.clientDataJSON),credentialId:n.id,signature:l(i.signature),...i.userHandle&&{userHandle:l(i.userHandle)}},session:o}}async authenticateWithPasskey(e="",r={}){let s=this.config.getAppId(),o=U(B.getDeviceId(s)),n=f(e,"",r),i={app:{id:s},deviceInfo:o,user:{username:e,usernameType:n.usernameType}},a=await this.service.auth.authAuthInit({requestBody:i});switch(a.action){case"proceed":{let u=await this.getNavigatorCredential(a,r),p=await this.service.auth.authAuthComplete({requestBody:u}),c=k(p.jwtAccess);return this.session.setJwtCookie(c.token),n?.callbacks?.onSuccess&&await n.callbacks.onSuccess(c),c}case"crossAuth":case"fallback":{if(n?.callbacks?.onFallback){let u=Ee(a);await n.callbacks.onFallback(e,u)}return k("",!1,!0)}default:throw Se}}async authenticateWithPasskeyAutofill(e={}){return e.autoFill=!0,await this.authenticateWithPasskey("",e)}async requestOtp(e,r={}){if(r.authzToken=this.session.getToken(r),!r.authzToken){let o=await this.authenticateWithPasskey(e,r);r.authzToken=o.token}return await this.service.auth.authAuthCodeRequest({authorization:r.authzToken})}async confirmTransaction(e,r,s={}){let o=Pe(e,s),n={username:e,txPayload:r,nonce:o.nonce,txType:o.txType},{assertionOptions:i,session:a}=await this.service.tx.txTxInit({requestBody:n}),u={action:"proceed",crossAuthMethods:[],fallbackMethods:[],assertionOptions:i,session:a},{assertionResult:p}=await this.getNavigatorCredential(u),c={authenticatorData:p.authenticatorData,clientData:p.clientDataJSON,keyHandle:p.credentialId,session:a,signature:p.signature};return await this.service.tx.txTxComplete({requestBody:c})}},ve=pe;var le=class extends y{constructor(e){super(e)}async listPasskeys(e={}){let r=this.session.getToken(e);return await this.service.passkeys.passkeysPasskeysList({authorization:r})}async renamePasskey(e,r,s={}){let o=this.session.getToken(s),n={name:r};await this.service.passkeys.passkeysPasskeyRename({authorization:o,id:e,requestBody:n})}async deletePasskey(e,r={}){let s=this.session.getToken(r);await this.service.passkeys.passkeysPasskeyDelete({authorization:s,id:e})}},we=le;var z=class extends y{constructor(e){super(e)}};ye(z,[y,ve,W,we,Oe]);var de=z;var _=class{static async getNavigatorCredential(e,r={}){let{assertionOptions:s,session:o}=e,n=await v(s,r),i=n.response;return{assertionResult:{authenticatorData:l(i.authenticatorData),clientDataJSON:l(i.clientDataJSON),credentialId:n.id,signature:l(i.signature),...i.userHandle&&{userHandle:l(i.userHandle)}},session:o}}static async createNavigatorCredential(e){let{registrationRequestOptions:r,session:s}=e,o=await S(r),n=o.response,i=n.getPublicKey&&n.getPublicKey(),a=n.getPublicKeyAlgorithm&&n.getPublicKeyAlgorithm(),u=n.getAuthenticatorData&&n.getAuthenticatorData(),p=n.getTransports&&n.getTransports();return{creationResult:{attestationObject:l(n.attestationObject),clientDataJSON:l(n.clientDataJSON),credentialId:o.id,...i&&{publicKey:l(i)},...a&&{publicKeyAlgorithm:a},...u&&{authenticatorData:l(u)},...p&&{transports:p}},session:s}}};var Ze=de;0&&(module.exports={AbortError,ApiError,LoginIDAPI,LoginIDWebSDK,PasskeyError,WebAuthnHelper,canCreatePasskey,createPasskeyCredential,doesDeviceSupportPasskeys,getPasskeyCredential,isConditionalUIAvailable,isPlatformAuthenticatorAvailable});
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -54,6 +54,9 @@ declare abstract class BaseHttpRequest {
54
54
  abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
55
55
  }
56
56
 
57
+ /**
58
+ * Code generation result
59
+ */
57
60
  type AuthCode = {
58
61
  /**
59
62
  * Generated code
@@ -73,7 +76,7 @@ type UserLogin = {
73
76
  /**
74
77
  * Username type
75
78
  */
76
- usernameType: 'email' | 'phone';
79
+ usernameType?: 'email' | 'phone' | 'other';
77
80
  };
78
81
 
79
82
  type AuthCodeRequestSMSRequestBody = {
@@ -90,7 +93,8 @@ type AuthCodeVerifyRequestBody = {
90
93
 
91
94
  type AuthenticatorAssertionResponse = {
92
95
  /**
93
- * This attribute contains the authenticator data returned by the authenticator.
96
+ * A base64 encoded authenticator data structure encodes contextual bindings
97
+ * made by the authenticator.
94
98
  */
95
99
  authenticatorData: string;
96
100
  /**
@@ -129,6 +133,9 @@ type PubKeyCredentialDescriptor = {
129
133
  */
130
134
  id: string;
131
135
  transports?: Array<'usb' | 'nfc' | 'ble' | 'internal' | 'hybrid' | 'cable' | 'smart-card'>;
136
+ /**
137
+ * The valid credential types.
138
+ */
132
139
  type: 'public-key';
133
140
  };
134
141
 
@@ -151,7 +158,7 @@ type PublicKeyCredentialRequestOptions = {
151
158
  * authenticator. For example, if transaction confirmation is sought from the
152
159
  * user, then the prompt string might be included as an extension.
153
160
  */
154
- extensions?: Record<string, string>;
161
+ extensions?: Record<string, any>;
155
162
  /**
156
163
  * The relying party identifier claimed by the caller. If omitted, its value will
157
164
  * be the CredentialsContainer object’s relevant settings object's origin's
@@ -165,15 +172,14 @@ type PublicKeyCredentialRequestOptions = {
165
172
  */
166
173
  timeout?: number;
167
174
  /**
168
- * The Relying Party's requirements regarding user verification for the get()
169
- * operation. The value SHOULD be a member of UserVerificationRequirement but
170
- * client platforms MUST ignore unknown values, treating an unknown value as if
171
- * the member does not exist. Eligible authenticators are filtered to only those
172
- * capable of satisfying this requirement.
175
+ * User verification requirement
173
176
  */
174
177
  userVerification?: 'required' | 'preferred' | 'discouraged';
175
178
  };
176
179
 
180
+ /**
181
+ * FIDO2 authentication response
182
+ */
177
183
  type AuthInit = {
178
184
  /**
179
185
  * An action to be performed by the front-end to complete the authentication flow.
@@ -227,15 +233,15 @@ type DeviceInfo = {
227
233
  /**
228
234
  * Client name
229
235
  */
230
- clientName: string;
236
+ clientName?: string;
231
237
  /**
232
238
  * Client type.
233
239
  */
234
- clientType: 'browser' | 'other';
240
+ clientType?: 'browser' | 'other';
235
241
  /**
236
242
  * Client version
237
243
  */
238
- clientVersion: string;
244
+ clientVersion?: string;
239
245
  /**
240
246
  * An unique device identifier
241
247
  */
@@ -243,23 +249,23 @@ type DeviceInfo = {
243
249
  /**
244
250
  * OS architecture
245
251
  */
246
- osArch: string;
252
+ osArch?: string;
247
253
  /**
248
254
  * OS name
249
255
  */
250
- osName: string;
256
+ osName?: string;
251
257
  /**
252
258
  * OS version
253
259
  */
254
- osVersion: string;
260
+ osVersion?: string;
255
261
  /**
256
262
  * Screen height in pixels
257
263
  */
258
- screenHeight: number;
264
+ screenHeight?: number;
259
265
  /**
260
266
  * Screen width in pixels
261
267
  */
262
- screenWidth: number;
268
+ screenWidth?: number;
263
269
  };
264
270
 
265
271
  type AuthInitRequestBody = {
@@ -587,7 +593,8 @@ type CreationResult = {
587
593
  */
588
594
  attestationObject: string;
589
595
  /**
590
- * This attribute contains the authenticator data contained within attestationObject.
596
+ * A base64 encoded authenticator data structure encodes contextual bindings
597
+ * made by the authenticator.
591
598
  */
592
599
  authenticatorData?: string;
593
600
  /**
@@ -637,7 +644,7 @@ type AuthenticatorSelectionCriteria = {
637
644
  */
638
645
  residentKey?: 'discouraged' | 'preferred' | 'required';
639
646
  /**
640
- * Resident key requirement
647
+ * User verification requirement
641
648
  */
642
649
  userVerification?: 'required' | 'preferred' | 'discouraged';
643
650
  };
@@ -652,6 +659,9 @@ type PublicKeyCredentialParameters = {
652
659
  * e.g., RSA or Elliptic Curve.
653
660
  */
654
661
  alg?: -7 | -35 | -36 | -257 | -8;
662
+ /**
663
+ * The valid credential types.
664
+ */
655
665
  type?: 'public-key';
656
666
  };
657
667
 
@@ -679,9 +689,6 @@ type PublicKeyCredentialUserEntity = {
679
689
  };
680
690
 
681
691
  type PublicKeyCredentialCreationOptions = {
682
- /**
683
- * A preference for attestation conveyance.
684
- */
685
692
  attestation?: 'none' | 'indirect' | 'direct' | 'enterprise';
686
693
  authenticatorSelection?: AuthenticatorSelectionCriteria;
687
694
  /**
@@ -700,7 +707,7 @@ type PublicKeyCredentialCreationOptions = {
700
707
  /**
701
708
  * Additional parameters requesting processing by the client and authenticator.
702
709
  */
703
- extensions?: Record<string, string>;
710
+ extensions?: Record<string, any>;
704
711
  /**
705
712
  * This member contains information about the desired properties of the credential
706
713
  * to be created. The sequence is ordered from most preferred to least preferred.
@@ -718,6 +725,9 @@ type PublicKeyCredentialCreationOptions = {
718
725
  user: PublicKeyCredentialUserEntity;
719
726
  };
720
727
 
728
+ /**
729
+ * FIDO2 registration response
730
+ */
721
731
  type RegInit = {
722
732
  /**
723
733
  * An action to be performed by the front-end to complete the registration flow.
@@ -749,7 +759,7 @@ type User = {
749
759
  /**
750
760
  * Username type
751
761
  */
752
- usernameType: 'email' | 'phone';
762
+ usernameType: 'email' | 'phone' | 'other';
753
763
  };
754
764
 
755
765
  type RegInitRequestBody = {
@@ -796,6 +806,9 @@ declare class RegService {
796
806
  }): CancelablePromise<RegInit>;
797
807
  }
798
808
 
809
+ /**
810
+ * Transaction Confirmation Complete response
811
+ */
799
812
  type TxComplete = {
800
813
  authCred?: Passkey;
801
814
  /**
@@ -803,25 +816,9 @@ type TxComplete = {
803
816
  */
804
817
  credentialId: string;
805
818
  /**
806
- * JWT access token
807
- */
808
- jwtAccess: string;
809
- /**
810
- * Random string generated by LoginID.
811
- */
812
- lNonce: string;
813
- /**
814
- * Random string.
819
+ * Authorization token
815
820
  */
816
- nonce: string;
817
- /**
818
- * Computed hash value of the transaction.
819
- */
820
- txHash: string;
821
- /**
822
- * Internal transaction identifier
823
- */
824
- txId: string;
821
+ token: string;
825
822
  };
826
823
 
827
824
  type TxCompleteRequestBody = {
@@ -850,6 +847,9 @@ type TxCompleteRequestBody = {
850
847
  signature: string;
851
848
  };
852
849
 
850
+ /**
851
+ * Transaction Confirmation Init response
852
+ */
853
853
  type TxInit = {
854
854
  assertionOptions: PublicKeyCredentialRequestOptions;
855
855
  /**
@@ -902,7 +902,7 @@ declare class TxService {
902
902
  }): CancelablePromise<TxInit>;
903
903
  }
904
904
 
905
- type Version = {
905
+ type Version3 = {
906
906
  /**
907
907
  * Version hash
908
908
  */
@@ -918,14 +918,52 @@ declare class VersionService {
918
918
  constructor(httpRequest: BaseHttpRequest);
919
919
  /**
920
920
  * Show software version
921
- * @returns Version OK response.
921
+ * @returns Version3 OK response.
922
922
  * @throws ApiError
923
923
  */
924
- versionVersionShow(): CancelablePromise<Version>;
924
+ versionVersionShow(): CancelablePromise<Version3>;
925
925
  }
926
926
 
927
+ /**
928
+ * JWK
929
+ */
930
+ type ResultKey = {
931
+ /**
932
+ * Algorithm used
933
+ */
934
+ alg: string;
935
+ /**
936
+ * Curve used
937
+ */
938
+ crv?: string;
939
+ /**
940
+ * Key operations
941
+ */
942
+ key_ops: Array<string>;
943
+ /**
944
+ * Key Identifier
945
+ */
946
+ kid: string;
947
+ /**
948
+ * Key Type
949
+ */
950
+ kty: string;
951
+ /**
952
+ * Intended use of the key
953
+ */
954
+ use: string;
955
+ /**
956
+ * X coordinate of the elliptic curve public key
957
+ */
958
+ 'x'?: string;
959
+ /**
960
+ * Y coordinate of the elliptic curve public key
961
+ */
962
+ 'y'?: string;
963
+ };
964
+
927
965
  type WellKnownJwks = {
928
- keys?: Array<string>;
966
+ keys?: Array<ResultKey>;
929
967
  };
930
968
 
931
969
  declare class WellKnownService {
@@ -975,6 +1013,83 @@ type BadRequestError = {
975
1013
  msgCode: string;
976
1014
  };
977
1015
 
1016
+ type CodeResult = {
1017
+ /**
1018
+ * Generated code
1019
+ */
1020
+ code: string;
1021
+ /**
1022
+ * Expiration time of the code
1023
+ */
1024
+ expiresAt: string;
1025
+ };
1026
+
1027
+ type ForbiddenError = {
1028
+ msg: string;
1029
+ msgCode: string;
1030
+ };
1031
+
1032
+ type InternalServerError = {
1033
+ msg: string;
1034
+ msgCode: string;
1035
+ };
1036
+
1037
+ type NotFoundError = {
1038
+ msg: string;
1039
+ msgCode: string;
1040
+ };
1041
+
1042
+ type PublicKeyCredential$1 = {
1043
+ /**
1044
+ * This base64 encoded byte array contains the credential ID
1045
+ * of the public key credential the caller is referring to.
1046
+ */
1047
+ id: string;
1048
+ /**
1049
+ * This enumeration defines hints as to how clients might communicate with a
1050
+ * particular authenticator in order to obtain an assertion for a specific
1051
+ * credential.
1052
+ */
1053
+ transport?: 'usb' | 'nfc' | 'ble' | 'internal' | 'hybrid' | 'cable' | 'smart-card';
1054
+ /**
1055
+ * The type of the public key credential the caller is referring to.
1056
+ * The value SHOULD be a member of PublicKeyCredentialType but client
1057
+ * platforms MUST ignore any PublicKeyCredentialDescriptor with an unknown
1058
+ * type.
1059
+ */
1060
+ type?: 'public-key';
1061
+ };
1062
+
1063
+ type UnauthorizedError = {
1064
+ msg: string;
1065
+ msgCode: string;
1066
+ };
1067
+
1068
+ type Version = {
1069
+ /**
1070
+ * Version hash
1071
+ */
1072
+ hash?: string;
1073
+ /**
1074
+ * Software version
1075
+ */
1076
+ version: string;
1077
+ };
1078
+
1079
+ /**
1080
+ * Version
1081
+ */
1082
+ type Version2 = {
1083
+ /**
1084
+ * Version hash
1085
+ */
1086
+ hash?: string;
1087
+ /**
1088
+ * Software version
1089
+ */
1090
+ version: string;
1091
+ };
1092
+
978
1093
  type index_ApiError = ApiError;
979
1094
  declare const index_ApiError: typeof ApiError;
980
1095
  type index_Application = Application;
@@ -995,15 +1110,19 @@ type index_CancelError = CancelError;
995
1110
  declare const index_CancelError: typeof CancelError;
996
1111
  type index_CancelablePromise<T> = CancelablePromise<T>;
997
1112
  declare const index_CancelablePromise: typeof CancelablePromise;
1113
+ type index_CodeResult = CodeResult;
998
1114
  type index_CreationResult = CreationResult;
999
1115
  type index_DeviceInfo = DeviceInfo;
1116
+ type index_ForbiddenError = ForbiddenError;
1000
1117
  type index_GrantCreateRequestBody = GrantCreateRequestBody;
1001
1118
  type index_GrantCreateResponseBody = GrantCreateResponseBody;
1119
+ type index_InternalServerError = InternalServerError;
1002
1120
  type index_JWT = JWT;
1003
1121
  type index_LoginIDService = LoginIDService;
1004
1122
  declare const index_LoginIDService: typeof LoginIDService;
1005
1123
  type index_MgmtService = MgmtService;
1006
1124
  declare const index_MgmtService: typeof MgmtService;
1125
+ type index_NotFoundError = NotFoundError;
1007
1126
  declare const index_OpenAPI: typeof OpenAPI;
1008
1127
  type index_OpenAPIConfig = OpenAPIConfig;
1009
1128
  type index_Passkey = Passkey;
@@ -1027,6 +1146,7 @@ type index_RegInit = RegInit;
1027
1146
  type index_RegInitRequestBody = RegInitRequestBody;
1028
1147
  type index_RegService = RegService;
1029
1148
  declare const index_RegService: typeof RegService;
1149
+ type index_ResultKey = ResultKey;
1030
1150
  type index_TokenVerifyRequestBody = TokenVerifyRequestBody;
1031
1151
  type index_TxComplete = TxComplete;
1032
1152
  type index_TxCompleteRequestBody = TxCompleteRequestBody;
@@ -1034,16 +1154,19 @@ type index_TxInit = TxInit;
1034
1154
  type index_TxInitRequestBody = TxInitRequestBody;
1035
1155
  type index_TxService = TxService;
1036
1156
  declare const index_TxService: typeof TxService;
1157
+ type index_UnauthorizedError = UnauthorizedError;
1037
1158
  type index_User = User;
1038
1159
  type index_UserLogin = UserLogin;
1039
1160
  type index_Version = Version;
1161
+ type index_Version2 = Version2;
1162
+ type index_Version3 = Version3;
1040
1163
  type index_VersionService = VersionService;
1041
1164
  declare const index_VersionService: typeof VersionService;
1042
1165
  type index_WellKnownJwks = WellKnownJwks;
1043
1166
  type index_WellKnownService = WellKnownService;
1044
1167
  declare const index_WellKnownService: typeof WellKnownService;
1045
1168
  declare namespace index {
1046
- export { index_ApiError as ApiError, type index_Application as Application, type index_AuthCode as AuthCode, type index_AuthCodeRequestSMSRequestBody as AuthCodeRequestSMSRequestBody, type index_AuthCodeVerifyRequestBody as AuthCodeVerifyRequestBody, type index_AuthCompleteRequestBody as AuthCompleteRequestBody, type index_AuthInit as AuthInit, type index_AuthInitRequestBody as AuthInitRequestBody, index_AuthService as AuthService, type index_AuthenticatorAssertionResponse as AuthenticatorAssertionResponse, type index_AuthenticatorSelectionCriteria as AuthenticatorSelectionCriteria, type index_BadRequestError as BadRequestError, index_BaseHttpRequest as BaseHttpRequest, index_CancelError as CancelError, index_CancelablePromise as CancelablePromise, type index_CreationResult as CreationResult, type index_DeviceInfo as DeviceInfo, type index_GrantCreateRequestBody as GrantCreateRequestBody, type index_GrantCreateResponseBody as GrantCreateResponseBody, type index_JWT as JWT, index_LoginIDService as LoginIDService, index_MgmtService as MgmtService, index_OpenAPI as OpenAPI, type index_OpenAPIConfig as OpenAPIConfig, type index_Passkey as Passkey, type index_PasskeyCollection as PasskeyCollection, type PasskeyOptions$1 as PasskeyOptions, type index_PasskeyRenameRequestBody as PasskeyRenameRequestBody, index_PasskeysService as PasskeysService, type index_ProfileEmailUpdateRequestBody as ProfileEmailUpdateRequestBody, type index_ProfilePhoneUpdateRequestBody as ProfilePhoneUpdateRequestBody, type index_ProfilePhoneVerifyRequestBody as ProfilePhoneVerifyRequestBody, index_ProfileService as ProfileService, type index_PubKeyCredentialDescriptor as PubKeyCredentialDescriptor, type index_PublicKeyCredentialCreationOptions as PublicKeyCredentialCreationOptions, type index_PublicKeyCredentialParameters as PublicKeyCredentialParameters, type index_PublicKeyCredentialRequestOptions as PublicKeyCredentialRequestOptions, type index_PublicKeyCredentialRpEntity as PublicKeyCredentialRpEntity, type index_PublicKeyCredentialUserEntity as PublicKeyCredentialUserEntity, type index_RegCompleteRequestBody as RegCompleteRequestBody, type index_RegInit as RegInit, type index_RegInitRequestBody as RegInitRequestBody, index_RegService as RegService, type index_TokenVerifyRequestBody as TokenVerifyRequestBody, type index_TxComplete as TxComplete, type index_TxCompleteRequestBody as TxCompleteRequestBody, type index_TxInit as TxInit, type index_TxInitRequestBody as TxInitRequestBody, index_TxService as TxService, type index_User as User, type index_UserLogin as UserLogin, type index_Version as Version, index_VersionService as VersionService, type index_WellKnownJwks as WellKnownJwks, index_WellKnownService as WellKnownService };
1169
+ export { index_ApiError as ApiError, type index_Application as Application, type index_AuthCode as AuthCode, type index_AuthCodeRequestSMSRequestBody as AuthCodeRequestSMSRequestBody, type index_AuthCodeVerifyRequestBody as AuthCodeVerifyRequestBody, type index_AuthCompleteRequestBody as AuthCompleteRequestBody, type index_AuthInit as AuthInit, type index_AuthInitRequestBody as AuthInitRequestBody, index_AuthService as AuthService, type index_AuthenticatorAssertionResponse as AuthenticatorAssertionResponse, type index_AuthenticatorSelectionCriteria as AuthenticatorSelectionCriteria, type index_BadRequestError as BadRequestError, index_BaseHttpRequest as BaseHttpRequest, index_CancelError as CancelError, index_CancelablePromise as CancelablePromise, type index_CodeResult as CodeResult, type index_CreationResult as CreationResult, type index_DeviceInfo as DeviceInfo, type index_ForbiddenError as ForbiddenError, type index_GrantCreateRequestBody as GrantCreateRequestBody, type index_GrantCreateResponseBody as GrantCreateResponseBody, type index_InternalServerError as InternalServerError, type index_JWT as JWT, index_LoginIDService as LoginIDService, index_MgmtService as MgmtService, type index_NotFoundError as NotFoundError, index_OpenAPI as OpenAPI, type index_OpenAPIConfig as OpenAPIConfig, type index_Passkey as Passkey, type index_PasskeyCollection as PasskeyCollection, type PasskeyOptions$1 as PasskeyOptions, type index_PasskeyRenameRequestBody as PasskeyRenameRequestBody, index_PasskeysService as PasskeysService, type index_ProfileEmailUpdateRequestBody as ProfileEmailUpdateRequestBody, type index_ProfilePhoneUpdateRequestBody as ProfilePhoneUpdateRequestBody, type index_ProfilePhoneVerifyRequestBody as ProfilePhoneVerifyRequestBody, index_ProfileService as ProfileService, type index_PubKeyCredentialDescriptor as PubKeyCredentialDescriptor, type PublicKeyCredential$1 as PublicKeyCredential, type index_PublicKeyCredentialCreationOptions as PublicKeyCredentialCreationOptions, type index_PublicKeyCredentialParameters as PublicKeyCredentialParameters, type index_PublicKeyCredentialRequestOptions as PublicKeyCredentialRequestOptions, type index_PublicKeyCredentialRpEntity as PublicKeyCredentialRpEntity, type index_PublicKeyCredentialUserEntity as PublicKeyCredentialUserEntity, type index_RegCompleteRequestBody as RegCompleteRequestBody, type index_RegInit as RegInit, type index_RegInitRequestBody as RegInitRequestBody, index_RegService as RegService, type index_ResultKey as ResultKey, type index_TokenVerifyRequestBody as TokenVerifyRequestBody, type index_TxComplete as TxComplete, type index_TxCompleteRequestBody as TxCompleteRequestBody, type index_TxInit as TxInit, type index_TxInitRequestBody as TxInitRequestBody, index_TxService as TxService, type index_UnauthorizedError as UnauthorizedError, type index_User as User, type index_UserLogin as UserLogin, type index_Version as Version, type index_Version2 as Version2, type index_Version3 as Version3, index_VersionService as VersionService, type index_WellKnownJwks as WellKnownJwks, index_WellKnownService as WellKnownService };
1047
1170
  }
1048
1171
 
1049
1172
  type Complete<T> = {
@@ -1091,6 +1214,10 @@ interface PasskeyOptions {
1091
1214
  * Callback functions that can be triggered on various events during the authentication process.
1092
1215
  */
1093
1216
  callbacks?: Callbacks;
1217
+ /**
1218
+ * The type of username validation to be used. Defaults to **`other`**.
1219
+ */
1220
+ usernameType?: UsernameType;
1094
1221
  }
1095
1222
  /**
1096
1223
  * The base interface for passkey management options.
@@ -1128,7 +1255,7 @@ interface AuthenticateWithPasskeysOptions extends PasskeyOptions {
1128
1255
  * This should be used with the **`options.autoFill`** option to trigger the cancellation of the passkey conditional UI.
1129
1256
  * Pass this if additional passkeys API calls may be anticipated on the current context page.
1130
1257
  */
1131
- abortSignal?: AbortSignal;
1258
+ abortController?: AbortController;
1132
1259
  }
1133
1260
  /**
1134
1261
  * Authenticate with passkey autofill options.
@@ -1161,6 +1288,10 @@ interface ConfirmTransactionOptions extends PasskeyOptions {
1161
1288
  * Request and send OTP options.
1162
1289
  */
1163
1290
  interface RequestAndSendOtpOptions {
1291
+ /**
1292
+ * The type of username validation to be used. Defaults to **`other`**.
1293
+ */
1294
+ usernameType?: UsernameType;
1164
1295
  }
1165
1296
  /**
1166
1297
  * Request OTP options.
@@ -1701,7 +1832,7 @@ declare class Passkeys extends OTP {
1701
1832
  * return;
1702
1833
  * }
1703
1834
  *
1704
- * const result = await lid.authenticateWithPasskeyAutofill(options);
1835
+ * const result = await lid.authenticateWithPasskeyAutofill();
1705
1836
  * console.log("Authentication Result:", result);
1706
1837
  * } catch (error) {
1707
1838
  * // Handle errors
@@ -2039,5 +2170,13 @@ interface DoesDeviceSupportPasskeysResponse {
2039
2170
  * Attempts to provide a solution for missing platform authenticator
2040
2171
  */
2041
2172
  declare function doesDeviceSupportPasskeys(): Promise<DoesDeviceSupportPasskeysResponse>;
2173
+ /**
2174
+ * Determines whether a passkey can be created on the current device.
2175
+ *
2176
+ * @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether a passkey can be created.
2177
+ * - `true`: The device supports passkeys and a platform authenticator is available.
2178
+ * - `false`: Either the device does not support passkeys or a platform authenticator is not available.
2179
+ */
2180
+ declare function canCreatePasskey(): Promise<boolean>;
2042
2181
 
2043
- export { AbortError, type AllOptions, ApiError, type AuthResult, type AuthenticateWithPasskeyAutofillOptions, type AuthenticateWithPasskeysOptions, type Callbacks, type Complete, type ConfirmTransactionOptions, type CreatePasskeyOptions, type DeletePasskeyOptions, type DeviceInfoRequestBody, type DoesDeviceSupportPasskeysResponse, type FallbackCallback, type FallbackOptions, type ListPasskeysOptions, index as LoginIDAPI, type LoginIDConfig, LoginIDWebSDK, type Message, type Otp, PasskeyError, type PasskeyManagementOptions, type PasskeyOptions, type RenamePasskeyOptions, type RequestAndSendOtpOptions, type RequestOtpOptions, type SessionInfo, type SuccessCallback, type Transports, type UsernameType, type ValidateOtpOptions, type VerifyConfigResult, WebAuthnHelper, createPasskeyCredential, LoginIDWebSDK as default, doesDeviceSupportPasskeys, getPasskeyCredential, isConditionalUIAvailable, isPlatformAuthenticatorAvailable };
2182
+ export { AbortError, type AllOptions, ApiError, type AuthResult, type AuthenticateWithPasskeyAutofillOptions, type AuthenticateWithPasskeysOptions, type Callbacks, type Complete, type ConfirmTransactionOptions, type CreatePasskeyOptions, type DeletePasskeyOptions, type DeviceInfoRequestBody, type DoesDeviceSupportPasskeysResponse, type FallbackCallback, type FallbackOptions, type ListPasskeysOptions, index as LoginIDAPI, type LoginIDConfig, LoginIDWebSDK, type Message, type Otp, type Passkey, type PasskeyCollection, PasskeyError, type PasskeyManagementOptions, type PasskeyOptions, type RenamePasskeyOptions, type RequestAndSendOtpOptions, type RequestOtpOptions, type SessionInfo, type SuccessCallback, type Transports, type UsernameType, type ValidateOtpOptions, type VerifyConfigResult, WebAuthnHelper, canCreatePasskey, createPasskeyCredential, LoginIDWebSDK as default, doesDeviceSupportPasskeys, getPasskeyCredential, isConditionalUIAvailable, isPlatformAuthenticatorAvailable };