@loginid/websdk3 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +352 -62
- package/dist/index.d.ts +352 -62
- package/dist/index.js +1 -1
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ne=(t,e)=>{for(var r in e)w(t,r,{get:e[r],enumerable:!0})},ie=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of oe(e))!se.call(t,o)&&o!==r&&w(t,o,{get:()=>e[o],enumerable:!(s=re(e,o))||s.enumerable});return t};var ae=t=>ie(w({},"__esModule",{value:!0}),t);var qe={};ne(qe,{ApiError:()=>d,LoginIDWebSDK:()=>_,PasskeyError:()=>l,createPasskeyCredential:()=>S,default:()=>Ae,doesDeviceSupportPasskeys:()=>z,getPasskeyCredential:()=>v,isConditionalUIAvailable:()=>$,isPlatformAuthenticatorAvailable:()=>J});module.exports=ae(qe);var R=class{constructor(e){this.config=e}};var d=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 I=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},h=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 I("Request aborted"))}}get isCancelled(){return this.#e}};var D=t=>t!=null,g=t=>typeof t=="string",k=t=>g(t)&&t!=="",N=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]),W=t=>t instanceof FormData,pe=t=>{try{return btoa(t)}catch{return Buffer.from(t).toString("base64")}},ue=t=>{let e=[],r=(o,n)=>{e.push(`${encodeURIComponent(o)}=${encodeURIComponent(String(n))}`)},s=(o,n)=>{D(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("&")}`:""},le=(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}${ue(e.query)}`:o},ce=t=>{if(t.formData){let e=new FormData,r=(s,o)=>{g(o)||N(o)?e.append(s,o):e.append(s,JSON.stringify(o))};return Object.entries(t.formData).filter(([s,o])=>D(o)).forEach(([s,o])=>{Array.isArray(o)?o.forEach(n=>r(s,n)):r(s,o)}),e}},x=async(t,e)=>typeof e=="function"?e(t):e,de=async(t,e)=>{let[r,s,o,n]=await Promise.all([x(e,t.TOKEN),x(e,t.USERNAME),x(e,t.PASSWORD),x(e,t.HEADERS)]),i=Object.entries({Accept:"application/json",...n,...e.headers}).filter(([a,p])=>D(p)).reduce((a,[p,u])=>({...a,[p]:String(u)}),{});if(k(r)&&(i.Authorization=`Bearer ${r}`),k(s)&&k(o)){let a=pe(`${s}:${o}`);i.Authorization=`Basic ${a}`}return e.body&&(e.mediaType?i["Content-Type"]=e.mediaType:N(e.body)?i["Content-Type"]=e.body.type||"application/octet-stream":g(e.body)?i["Content-Type"]="text/plain":W(e.body)||(i["Content-Type"]="application/json")),new Headers(i)},ye=t=>{if(t.body!==void 0)return t.mediaType?.includes("/json")?JSON.stringify(t.body):g(t.body)||N(t.body)||W(t.body)?t.body:JSON.stringify(t.body)},me=async(t,e,r,s,o,n,i)=>{let a=new AbortController,p={headers:n,body:s??o,method:e.method,signal:a.signal};return t.WITH_CREDENTIALS&&(p.credentials=t.CREDENTIALS),i(()=>a.abort()),await fetch(r,p)},fe=(t,e)=>{if(e){let r=t.headers.get(e);if(g(r))return r}},Re=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)}},he=(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 d(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 d(t,e,`Generic Error: status: ${o}; status text: ${n}; body: ${i}`)}},V=(t,e)=>new h(async(r,s,o)=>{try{let n=le(t,e),i=ce(e),a=ye(e),p=await de(t,e);if(!o.isCancelled){let u=await me(t,e,n,a,i,p,o),f=await Re(u),te=fe(u,e.responseHeader),F={url:n,ok:u.ok,status:u.status,statusText:u.statusText,body:te??f};he(e,F),r(F.body)}}catch(n){s(n)}});var O=class extends R{constructor(e){super(e)}request(e){return V(this.config,e)}};var b=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.",403:"Forbidden: Forbidden 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.",500:"InternalServerError: Internal Server Error response."}})}};var C=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.",500:"InternalServerError: Internal Server Error response."}})}passkeysPasskeyDelete({id:e,authorization:r}){return this.httpRequest.request({method:"DELETE",url:"/fido2/v2/passkeys/{id}",headers:{Authorization:r},path:{id:e},errors:{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}",headers:{Authorization:s},path:{id:e},body:r,mediaType:"application/json",errors:{401:"Unauthorized: Unauthorized response.",403:"Forbidden: Forbidden response.",404:"NotFound: Not Found response.",500:"InternalServerError: Internal Server Error response."}})}};var P=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}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/reg/init",headers:{"User-Agent":r},body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",403:"Forbidden: Forbidden response.",500:"InternalServerError: Internal Server Error response."}})}};var A=class{constructor(e){this.httpRequest=e}tokenTokenVerify({requestBody:e}){return this.httpRequest.request({method:"POST",url:"/fido2/v2/token/verify",body:e,mediaType:"application/json",errors:{400:"BadRequest: Bad Request response.",500:"InternalServerError: Internal Server Error response."}})}};var q=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 E=class{auth;passkeys;reg;token;tx;version;request;constructor(e,r=O){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 b(this.request),this.passkeys=new C(this.request),this.reg=new P(this.request),this.token=new A(this.request),this.tx=new q(this.request),this.version=new T(this.request)}};var U=class{config;service;constructor(e){this.config=e,this.service=new E({BASE:e.baseUrl})}},y=U;var M=require("ua-parser-js"),H=()=>({clientType:"browser",screenWidth:window.screen.width,screenHeight:window.screen.height}),ge=(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 J(){try{return!window.PublicKeyCredential||!window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?!1:await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return!1}}async function $(){try{return!window.PublicKeyCredential||!window.PublicKeyCredential.isConditionalMediationAvailable?!1:await window.PublicKeyCredential.isConditionalMediationAvailable()}catch{return!1}}async function z(){let t=new M.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"&&ge(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 be=t=>t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Ce=t=>{if(!t)return t;let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=[],s=0;for(;s<t.length;){let i=t.charCodeAt(s++),a=t.charCodeAt(s++),p=t.charCodeAt(s++),u=i<<16|a<<8|p;r.push(e[u>>18&63]+e[u>>12&63]+e[u>>6&63]+e[u&63])}let o=r.join(""),n=t.length%3;return n?o.slice(0,n-3)+"===".slice(n||3):o},Pe=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 p=r[a];if(p!==void 0)for(o=(o<<6)+p,n+=6;n>=8;)i+=s(o>>(n-=8)&255)}return i},c=t=>{let e="",r=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)e+=String.fromCharCode(r[o]);let s=Ce(e);return be(s)},m=t=>{t=t.replace(/-/g,"+").replace(/_/g,"/");let e=Pe(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r.buffer},G=()=>crypto.randomUUID?crypto.randomUUID():window.crypto.getRandomValues(new Uint32Array(4)).join("-"),Y=(t,e)=>{e.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(s=>{Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(r.prototype,s)||Object.create(null))})})};var K=class extends Error{code;constructor(e,r,s){super(e),this.code=r,this.cause=s}},l=K;var Q=(t,e)=>{let r=t.name,{publicKey:s}=e;if(r==="ConstraintError"){if(s?.authenticatorSelection?.requireResidentKey===!0)return new l("Your device does not support discoverable credentials","ERROR_DISCOVERABLE_CREDENTIALS_UNSUPPORTED",t);if(s?.authenticatorSelection?.userVerification==="required")return new l("Your device does not support user verification","ERROR_USER_VERIFICATION_UNSUPPORTED",t)}if(r==="InvalidStateError")return new l("A passkey already exists on your device","ERROR_PASSKEY_EXISTS",t);if(r==="NotAllowedError")return new l("Passkey creation has failed","ERROR_GENERAL_ERROR_SEE_CAUSE_FIELD",t);if(r==="NotSupportedError")return new l("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 l(`The domain of the relying party (${o}) is invalid for this domain`,"ERROR_DOMAIN_MISMATCH",t)}return r==="UnknownError"?new l("Your device could not process the requested options or could not create a new passkey","ERROR_AUTHENTICATOR_UNKNOWN_ERROR",t):t},X=(t,e)=>{let r=t.name,{publicKey:s}=e;if(r==="AbortError"&&e.signal instanceof AbortSignal)return new l("Passkey authentication has been aborted","ERROR_PASSKEY_ABORTED",t);if(r==="NotAllowedError")return new l("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 l(`The domain of the relying party (${o}) is invalid for this domain`,"ERROR_DOMAIN_MISMATCH",t)}return r==="UnknownError"?new l("Your device could not process the requested options or could not authenticate with a passkey","ERROR_AUTHENTICATOR_UNKNOWN_ERROR",t):t};var S=async t=>{let e;if(t.excludeCredentials!==void 0){e=[];for(let o of t.excludeCredentials){let n={id:m(o.id),transports:o.transports,type:o.type};e.push(n)}}let r=t.pubKeyCredParams,s={publicKey:{attestation:t.attestation,authenticatorSelection:{...t.authenticatorSelection},challenge:m(t.challenge),excludeCredentials:e,extensions:t.extensions,pubKeyCredParams:r,rp:t.rp,timeout:t.timeout,user:{...t.user,id:m(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?Q(o,s):o}},v=async(t,e={})=>{let r;if(t.allowCredentials!==void 0){r=[];for(let o of t.allowCredentials){let n={id:m(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:m(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?X(o,s):o}};var j=class extends y{jwtAccess="";constructor(e){super(e)}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(),p=n.getAuthenticatorData&&n.getAuthenticatorData(),u=n.getTransports&&n.getTransports();return{creationResult:{attestationObject:c(n.attestationObject),clientDataJSON:c(n.clientDataJSON),credentialId:o.id,...i&&{publicKey:c(i)},...a&&{publicKeyAlgorithm:a},...p&&{authenticatorData:c(p)},...u&&{transports:u}},session:s}}async registerWithPasskey(e,r={}){let s=H();r.usernameType||(r.usernameType="email");let o={app:{id:this.config.appId,...r.token&&{token:r.token}},deviceInfo:s,user:{username:e,usernameType:r.usernameType,...r.displayName&&{displayName:r.displayName}},...r.mfa&&{mfa:r.mfa},...r.session&&{session:r.session}},n=await this.service.reg.regRegInit({requestBody:o}),i=await this.createNavigatorCredential(n),a=await this.service.reg.regRegComplete({requestBody:i});return this.jwtAccess=a.jwtAccess,a}async getNavigatorCredential(e,r={}){let{assertionOptions:s,session:o}=e,n=await v(s,r),i=n.response;return{assertionResult:{authenticatorData:c(i.authenticatorData),clientDataJSON:c(i.clientDataJSON),credentialId:n.id,signature:c(i.signature),...i.userHandle&&{userHandle:c(i.userHandle)}},session:o}}async authenticateWithPasskey(e="",r={}){let s=H();r.usernameType||(r.usernameType="email");let o={app:{id:this.config.appId,...r.token&&{token:r.token}},deviceInfo:s,...!r.autoFill&&{user:{username:e,usernameType:r.usernameType,...r.displayName&&{displayName:r.displayName}}}},n=await this.service.auth.authAuthInit({requestBody:o}),i=await this.getNavigatorCredential(n,r),a=await this.service.auth.authAuthComplete({requestBody:i});return this.jwtAccess=a.jwtAccess,a}async confirmTransaction(e,r,s={}){let o={username:e,txPayload:r,nonce:s.nonce||G(),txType:s.txType||"raw"},{assertionOptions:n,session:i}=await this.service.tx.txTxInit({requestBody:o}),a={assertionOptions:n,session:i},{assertionResult:p}=await this.getNavigatorCredential(a),u={authenticatorData:p.authenticatorData,clientData:p.clientDataJSON,keyHandle:p.credentialId,session:i,signature:p.signature},f=await this.service.tx.txTxComplete({requestBody:u});return this.jwtAccess=f.jwtAccess,f}getJWTAccess(){return this.jwtAccess}},Z=j;var L=class extends y{constructor(e){super(e)}async listPasskeys(e){return await this.service.passkeys.passkeysPasskeysList({authorization:e})}async renamePasskey(e,r,s){let o={name:s};return await this.service.passkeys.passkeysPasskeyRename({authorization:e,id:r,requestBody:o}),null}async deletePasskey(e,r){return await this.service.passkeys.passkeysPasskeyDelete({authorization:e,id:r}),null}},ee=L;var B=class extends y{constructor(e){super(e)}};Y(B,[y,Z,ee]);var _=B;var Ae=_;0&&(module.exports={ApiError,LoginIDWebSDK,PasskeyError,createPasskeyCredential,doesDeviceSupportPasskeys,getPasskeyCredential,isConditionalUIAvailable,isPlatformAuthenticatorAvailable});
|
|
1
|
+
"use strict";var D=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var le=(t,e)=>{for(var r in e)D(t,r,{get:e[r],enumerable:!0})},de=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ue(e))!pe.call(t,o)&&o!==r&&D(t,o,{get:()=>e[o],enumerable:!(s=ae(e,o))||s.enumerable});return t};var ce=t=>de(D({},"__esModule",{value:!0}),t);var Se={};le(Se,{ApiError:()=>c,LoginIDWebSDK:()=>_,PasskeyError:()=>l,createPasskeyCredential:()=>O,default:()=>Ie,doesDeviceSupportPasskeys:()=>te,getPasskeyCredential:()=>k,isConditionalUIAvailable:()=>ee,isPlatformAuthenticatorAvailable:()=>Z});module.exports=ce(Se);var h=class{constructor(e){this.config=e}};var c=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 I=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},R=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 I("Request aborted"))}}get isCancelled(){return this.#e}};var U=t=>t!=null,g=t=>typeof t=="string",N=t=>g(t)&&t!=="",F=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]),z=t=>t instanceof FormData,ye=t=>{try{return btoa(t)}catch{return Buffer.from(t).toString("base64")}},me=t=>{let e=[],r=(o,n)=>{e.push(`${encodeURIComponent(o)}=${encodeURIComponent(String(n))}`)},s=(o,n)=>{U(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("&")}`:""},fe=(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}${me(e.query)}`:o},he=t=>{if(t.formData){let e=new FormData,r=(s,o)=>{g(o)||F(o)?e.append(s,o):e.append(s,JSON.stringify(o))};return Object.entries(t.formData).filter(([s,o])=>U(o)).forEach(([s,o])=>{Array.isArray(o)?o.forEach(n=>r(s,n)):r(s,o)}),e}},S=async(t,e)=>typeof e=="function"?e(t):e,Re=async(t,e)=>{let[r,s,o,n]=await Promise.all([S(e,t.TOKEN),S(e,t.USERNAME),S(e,t.PASSWORD),S(e,t.HEADERS)]),i=Object.entries({Accept:"application/json",...n,...e.headers}).filter(([a,u])=>U(u)).reduce((a,[u,p])=>({...a,[u]:String(p)}),{});if(N(r)&&(i.Authorization=`Bearer ${r}`),N(s)&&N(o)){let a=ye(`${s}:${o}`);i.Authorization=`Basic ${a}`}return e.body&&(e.mediaType?i["Content-Type"]=e.mediaType:F(e.body)?i["Content-Type"]=e.body.type||"application/octet-stream":g(e.body)?i["Content-Type"]="text/plain":z(e.body)||(i["Content-Type"]="application/json")),new Headers(i)},ge=t=>{if(t.body!==void 0)return t.mediaType?.includes("/json")?JSON.stringify(t.body):g(t.body)||F(t.body)||z(t.body)?t.body:JSON.stringify(t.body)},Pe=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)},Ce=(t,e)=>{if(e){let r=t.headers.get(e);if(g(r))return r}},be=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 c(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 c(t,e,`Generic Error: status: ${o}; status text: ${n}; body: ${i}`)}},J=(t,e)=>new R(async(r,s,o)=>{try{let n=fe(t,e),i=he(e),a=ge(e),u=await Re(t,e);if(!o.isCancelled){let p=await Pe(t,e,n,a,i,u,o),f=await be(p),ie=Ce(p,e.responseHeader),W={url:n,ok:p.ok,status:p.status,statusText:p.statusText,body:ie??f};qe(e,W),r(W.body)}}catch(n){s(n)}});var x=class extends h{constructor(e){super(e)}request(e){return J(this.config,e)}};var P=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.",403:"Forbidden: Forbidden 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 C=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 b=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 q=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 A=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.",500:"InternalServerError: Internal Server Error response."}})}};var E=class{constructor(e){this.httpRequest=e}versionVersionShow(){return this.httpRequest.request({method:"GET",url:"/fido2/v2/version"})}};var B=class{auth;mgmt;passkeys;profile;reg;tx;version;request;constructor(e,r=x){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 P(this.request),this.mgmt=new C(this.request),this.passkeys=new b(this.request),this.profile=new q(this.request),this.reg=new A(this.request),this.tx=new T(this.request),this.version=new E(this.request)}};var Ae=t=>t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Te=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},Ee=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},d=t=>{let e="",r=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)e+=String.fromCharCode(r[o]);let s=Te(e);return Ae(s)},m=t=>{t=t.replace(/-/g,"+").replace(/_/g,"/");let e=Ee(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r.buffer},M=()=>crypto.randomUUID?crypto.randomUUID():window.crypto.getRandomValues(new Uint32Array(4)).join("-"),$=(t,e)=>{e.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(s=>{Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(r.prototype,s)||Object.create(null))})})},v=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)}},G=t=>{let r=`; ${document.cookie}`.split(`; ${t}=`);if(r&&r.length===2)return r.pop().split(";").shift()},Y=t=>{document.cookie=t},Q=t=>{document.cookie=`${t}=; expires=${new Date}`};var H=class{config;service;constructor(e){this.config=e,this.service=new B({BASE:e.baseUrl})}getToken(e){if(e.token)return e.token;{let r=this.getJwtCookie();return r||""}}getJwtCookieName(){return`LoginID_${this.config.appId}_token`}setJwtCookie(e){let r=v(e),s=new Date(r.exp*1e3).toUTCString(),o=`${this.getJwtCookieName()}=${e}; expires=${s}`;Y(o)}getJwtCookie(){return G(this.getJwtCookieName())}isLoggedIn(){return!!this.getJwtCookie()}signout(){Q(this.getJwtCookieName())}},y=H;var X=require("ua-parser-js"),K=()=>({clientType:"browser",screenWidth:window.screen.width,screenHeight:window.screen.height}),Be=(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 Z(){try{return!window.PublicKeyCredential||!window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?!1:await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return!1}}async function ee(){try{return!window.PublicKeyCredential||!window.PublicKeyCredential.isConditionalMediationAvailable?!1:await window.PublicKeyCredential.isConditionalMediationAvailable()}catch{return!1}}async function te(){let t=new X.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"&&Be(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 j=class extends Error{code;constructor(e,r,s){super(e),this.code=r,this.cause=s}},l=j;var re=(t,e)=>{let r=t.name,{publicKey:s}=e;if(r==="ConstraintError"){if(s?.authenticatorSelection?.requireResidentKey===!0)return new l("Your device does not support discoverable credentials","ERROR_DISCOVERABLE_CREDENTIALS_UNSUPPORTED",t);if(s?.authenticatorSelection?.userVerification==="required")return new l("Your device does not support user verification","ERROR_USER_VERIFICATION_UNSUPPORTED",t)}if(r==="InvalidStateError")return new l("A passkey already exists on your device","ERROR_PASSKEY_EXISTS",t);if(r==="NotAllowedError")return new l("Passkey creation has failed","ERROR_GENERAL_ERROR_SEE_CAUSE_FIELD",t);if(r==="NotSupportedError")return new l("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 l(`The domain of the relying party (${o}) is invalid for this domain`,"ERROR_DOMAIN_MISMATCH",t)}return r==="UnknownError"?new l("Your device could not process the requested options or could not create a new passkey","ERROR_AUTHENTICATOR_UNKNOWN_ERROR",t):t},oe=(t,e)=>{let r=t.name,{publicKey:s}=e;if(r==="AbortError"&&e.signal instanceof AbortSignal)return new l("Passkey authentication has been aborted","ERROR_PASSKEY_ABORTED",t);if(r==="NotAllowedError")return new l("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 l(`The domain of the relying party (${o}) is invalid for this domain`,"ERROR_DOMAIN_MISMATCH",t)}return r==="UnknownError"?new l("Your device could not process the requested options or could not authenticate with a passkey","ERROR_AUTHENTICATOR_UNKNOWN_ERROR",t):t};var O=async t=>{let e;if(t.excludeCredentials!==void 0){e=[];for(let o of t.excludeCredentials){let n={id:m(o.id),transports:o.transports,type:o.type};e.push(n)}}let r=t.pubKeyCredParams,s={publicKey:{attestation:t.attestation,authenticatorSelection:{...t.authenticatorSelection},challenge:m(t.challenge),excludeCredentials:e,extensions:t.extensions,pubKeyCredParams:r,rp:t.rp,timeout:t.timeout,user:{...t.user,id:m(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?re(o,s):o}},k=async(t,e={})=>{let r;if(t.allowCredentials!==void 0){r=[];for(let o of t.allowCredentials){let n={id:m(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:m(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?oe(o,s):o}};var L=class extends y{constructor(e){super(e)}async createNavigatorCredential(e){let{registrationRequestOptions:r,session:s}=e,o=await O(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:d(n.attestationObject),clientDataJSON:d(n.clientDataJSON),credentialId:o.id,...i&&{publicKey:d(i)},...a&&{publicKeyAlgorithm:a},...u&&{authenticatorData:d(u)},...p&&{transports:p}},session:s}}async registerWithPasskey(e,r={}){let s=K();r.usernameType||(r.usernameType="email"),r.token=this.getToken(r),r.token&&v(r.token).username!==e&&(r.token="");let o={app:{id:this.config.appId},deviceInfo:s,user:{username:e,usernameType:r.usernameType,...r.displayName&&{displayName:r.displayName}},...r.session&&{session:r.session}},n=await this.service.reg.regRegInit({requestBody:o,...r.token&&{authorization:r.token}}),i=await this.createNavigatorCredential(n),a=await this.service.reg.regRegComplete({requestBody:i});return this.setJwtCookie(a.jwtAccess),a}async getNavigatorCredential(e,r={}){let{assertionOptions:s,session:o}=e,n=await k(s,r),i=n.response;return{assertionResult:{authenticatorData:d(i.authenticatorData),clientDataJSON:d(i.clientDataJSON),credentialId:n.id,signature:d(i.signature),...i.userHandle&&{userHandle:d(i.userHandle)}},session:o}}async authenticateWithPasskey(e="",r={}){let s=K();r.usernameType||(r.usernameType="email");let o={app:{id:this.config.appId,...r.token&&{token:r.token}},deviceInfo:s,...!r.autoFill&&{user:{username:e,usernameType:r.usernameType,...r.displayName&&{displayName:r.displayName}}}},n=await this.service.auth.authAuthInit({requestBody:o}),i=await this.getNavigatorCredential(n,r),a=await this.service.auth.authAuthComplete({requestBody:i});return this.setJwtCookie(a.jwtAccess),a}async generateCodeWithPasskey(e,r={}){if(r.token=this.getToken(r),!r.token){let o=await this.authenticateWithPasskey(e,r);r.token=o.jwtAccess}return await this.service.auth.authAuthCodeRequest({authorization:r.token})}async authenticateWithCode(e,r,s={}){s.usernameType||(s.usernameType="email");let o={authCode:r,user:{username:e,usernameType:s.usernameType}},n=await this.service.auth.authAuthCodeVerify({requestBody:o});return this.setJwtCookie(n.jwtAccess),n}async addPasskey(e,r={}){let s=this.getToken(r);if(!s)throw new Error("User needs to be logged in to perform this operation.");return r.token=s,await this.registerWithPasskey(e,r)}async addPasskeyWithCode(e,r,s={}){return await this.authenticateWithCode(e,r,s),await this.registerWithPasskey(e,s)}async confirmTransaction(e,r,s={}){let o={username:e,txPayload:r,nonce:s.nonce||M(),txType:s.txType||"raw"},{assertionOptions:n,session:i}=await this.service.tx.txTxInit({requestBody:o}),a={assertionOptions:n,session:i},{assertionResult:u}=await this.getNavigatorCredential(a),p={authenticatorData:u.authenticatorData,clientData:u.clientDataJSON,keyHandle:u.credentialId,session:i,signature:u.signature},f=await this.service.tx.txTxComplete({requestBody:p});return this.setJwtCookie(f.jwtAccess),f}},se=L;var V=class extends y{constructor(e){super(e)}async listPasskeys(e={}){let r=this.getToken(e);return await this.service.passkeys.passkeysPasskeysList({authorization:r})}async renamePasskey(e,r,s={}){let o=this.getToken(s),n={name:r};return await this.service.passkeys.passkeysPasskeyRename({authorization:o,id:e,requestBody:n}),null}async deletePasskey(e,r={}){let s=this.getToken(r);return await this.service.passkeys.passkeysPasskeyDelete({authorization:s,id:e}),null}},ne=V;var w=class extends y{constructor(e){super(e)}};$(w,[y,se,ne]);var _=w;var Ie=_;0&&(module.exports={ApiError,LoginIDWebSDK,PasskeyError,createPasskeyCredential,doesDeviceSupportPasskeys,getPasskeyCredential,isConditionalUIAvailable,isPlatformAuthenticatorAvailable});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -49,6 +49,40 @@ declare abstract class BaseHttpRequest {
|
|
|
49
49
|
abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
type AuthCode = {
|
|
53
|
+
/**
|
|
54
|
+
* Generated code
|
|
55
|
+
*/
|
|
56
|
+
code: string;
|
|
57
|
+
/**
|
|
58
|
+
* Expiration time of the code
|
|
59
|
+
*/
|
|
60
|
+
expiresAt: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type UserLogin = {
|
|
64
|
+
/**
|
|
65
|
+
* Username
|
|
66
|
+
*/
|
|
67
|
+
username: string;
|
|
68
|
+
/**
|
|
69
|
+
* Username type
|
|
70
|
+
*/
|
|
71
|
+
usernameType: 'email' | 'phone';
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type AuthCodeRequestSMSRequestBody = {
|
|
75
|
+
user: UserLogin;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type AuthCodeVerifyRequestBody = {
|
|
79
|
+
/**
|
|
80
|
+
* Authentication code
|
|
81
|
+
*/
|
|
82
|
+
authCode: string;
|
|
83
|
+
user: UserLogin;
|
|
84
|
+
};
|
|
85
|
+
|
|
52
86
|
type AuthenticatorAssertionResponse = {
|
|
53
87
|
/**
|
|
54
88
|
* This attribute contains the authenticator data returned by the authenticator.
|
|
@@ -137,6 +171,10 @@ type PublicKeyCredentialRequestOptions = {
|
|
|
137
171
|
|
|
138
172
|
type AuthInit = {
|
|
139
173
|
assertionOptions: PublicKeyCredentialRequestOptions;
|
|
174
|
+
/**
|
|
175
|
+
* List of fallback methods (in priority order) available to this client.
|
|
176
|
+
*/
|
|
177
|
+
fallbackOptions?: Array<'otp:client' | 'otp:email' | 'otp:sms'>;
|
|
140
178
|
/**
|
|
141
179
|
* An opaque object containing session data.
|
|
142
180
|
*/
|
|
@@ -202,28 +240,25 @@ type DeviceInfo = {
|
|
|
202
240
|
screenWidth?: number;
|
|
203
241
|
};
|
|
204
242
|
|
|
205
|
-
type
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
243
|
+
type AuthInitRequestBody = {
|
|
244
|
+
app: Application;
|
|
245
|
+
deviceInfo: DeviceInfo;
|
|
246
|
+
user?: UserLogin;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
type CodeResult = {
|
|
210
250
|
/**
|
|
211
|
-
*
|
|
251
|
+
* Generated code
|
|
212
252
|
*/
|
|
213
|
-
|
|
253
|
+
code: string;
|
|
214
254
|
/**
|
|
215
|
-
*
|
|
255
|
+
* Expiration time of the code
|
|
216
256
|
*/
|
|
217
|
-
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
type AuthInitRequestBody = {
|
|
221
|
-
app: Application;
|
|
222
|
-
deviceInfo: DeviceInfo;
|
|
223
|
-
user?: User;
|
|
257
|
+
expiresAt: string;
|
|
224
258
|
};
|
|
225
259
|
|
|
226
260
|
type JWT = {
|
|
261
|
+
code?: CodeResult;
|
|
227
262
|
/**
|
|
228
263
|
* JWT access token
|
|
229
264
|
*/
|
|
@@ -253,6 +288,95 @@ declare class AuthService {
|
|
|
253
288
|
*/
|
|
254
289
|
userAgent?: string;
|
|
255
290
|
}): CancelablePromise<AuthInit>;
|
|
291
|
+
/**
|
|
292
|
+
* Request OTP code by an authenticated user
|
|
293
|
+
* An authenticated user can request an authentication code directly using this
|
|
294
|
+
* method. The code can be used for authentication from another device.
|
|
295
|
+
* @returns AuthCode OK response.
|
|
296
|
+
* @throws ApiError
|
|
297
|
+
*/
|
|
298
|
+
authAuthCodeRequest({ authorization, }: {
|
|
299
|
+
/**
|
|
300
|
+
* JWT Authorization header
|
|
301
|
+
*/
|
|
302
|
+
authorization?: string;
|
|
303
|
+
}): CancelablePromise<AuthCode>;
|
|
304
|
+
/**
|
|
305
|
+
* Request OTP code to be sent via email.
|
|
306
|
+
* Send authentication code to the provided email. The SMS will only be sent
|
|
307
|
+
* if the email address is known to the application, however, this method will
|
|
308
|
+
* return success regardless.
|
|
309
|
+
* @returns void
|
|
310
|
+
* @throws ApiError
|
|
311
|
+
*/
|
|
312
|
+
authAuthCodeRequestEmail({ requestBody, }: {
|
|
313
|
+
requestBody: AuthCodeRequestSMSRequestBody;
|
|
314
|
+
}): CancelablePromise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Request OTP code to be sent via SMS.
|
|
317
|
+
* Send authentication code to the provided phone number. The SMS will only be
|
|
318
|
+
* sent if the phone is registered with the application, however, it will return
|
|
319
|
+
* success regardless.
|
|
320
|
+
* @returns void
|
|
321
|
+
* @throws ApiError
|
|
322
|
+
*/
|
|
323
|
+
authAuthCodeRequestSms({ requestBody, }: {
|
|
324
|
+
requestBody: AuthCodeRequestSMSRequestBody;
|
|
325
|
+
}): CancelablePromise<void>;
|
|
326
|
+
/**
|
|
327
|
+
* Verify authentication code and return JWT access token with appropriate scopes
|
|
328
|
+
* @returns JWT OK response.
|
|
329
|
+
* @throws ApiError
|
|
330
|
+
*/
|
|
331
|
+
authAuthCodeVerify({ requestBody, }: {
|
|
332
|
+
requestBody: AuthCodeVerifyRequestBody;
|
|
333
|
+
}): CancelablePromise<JWT>;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
type GrantCreateRequestBody = {
|
|
337
|
+
/**
|
|
338
|
+
* List of requested grants
|
|
339
|
+
*/
|
|
340
|
+
grants: Array<'passkey:read' | 'passkey:write' | 'profile:read' | 'profile:write' | 'self:write'>;
|
|
341
|
+
/**
|
|
342
|
+
* User identifier
|
|
343
|
+
*/
|
|
344
|
+
username?: string;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
type GrantCreateResponseBody = {
|
|
348
|
+
/**
|
|
349
|
+
* Base64 encoded authorization token
|
|
350
|
+
*/
|
|
351
|
+
token: string;
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
type TokenVerifyRequestBody = {
|
|
355
|
+
/**
|
|
356
|
+
* JWT access token
|
|
357
|
+
*/
|
|
358
|
+
jwtAccess: string;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
declare class MgmtService {
|
|
362
|
+
readonly httpRequest: BaseHttpRequest;
|
|
363
|
+
constructor(httpRequest: BaseHttpRequest);
|
|
364
|
+
/**
|
|
365
|
+
* Create an authorization token with requested scopes
|
|
366
|
+
* @returns GrantCreateResponseBody OK response.
|
|
367
|
+
* @throws ApiError
|
|
368
|
+
*/
|
|
369
|
+
mgmtGrantCreate({ requestBody, }: {
|
|
370
|
+
requestBody: GrantCreateRequestBody;
|
|
371
|
+
}): CancelablePromise<GrantCreateResponseBody>;
|
|
372
|
+
/**
|
|
373
|
+
* Validate JWT Access Token
|
|
374
|
+
* @returns void
|
|
375
|
+
* @throws ApiError
|
|
376
|
+
*/
|
|
377
|
+
mgmtTokenVerify({ requestBody, }: {
|
|
378
|
+
requestBody: TokenVerifyRequestBody;
|
|
379
|
+
}): CancelablePromise<void>;
|
|
256
380
|
}
|
|
257
381
|
|
|
258
382
|
type Passkey = {
|
|
@@ -291,8 +415,11 @@ declare class PasskeysService {
|
|
|
291
415
|
* @returns PasskeyCollection OK response.
|
|
292
416
|
* @throws ApiError
|
|
293
417
|
*/
|
|
294
|
-
passkeysPasskeysList({ authorization }: {
|
|
295
|
-
|
|
418
|
+
passkeysPasskeysList({ authorization, }: {
|
|
419
|
+
/**
|
|
420
|
+
* JWT Authorization header
|
|
421
|
+
*/
|
|
422
|
+
authorization?: string;
|
|
296
423
|
}): CancelablePromise<PasskeyCollection>;
|
|
297
424
|
/**
|
|
298
425
|
* Delete passkey
|
|
@@ -304,20 +431,134 @@ declare class PasskeysService {
|
|
|
304
431
|
* Internal passkey identifier
|
|
305
432
|
*/
|
|
306
433
|
id: string;
|
|
307
|
-
|
|
434
|
+
/**
|
|
435
|
+
* JWT Authorization header
|
|
436
|
+
*/
|
|
437
|
+
authorization?: string;
|
|
308
438
|
}): CancelablePromise<void>;
|
|
309
439
|
/**
|
|
310
440
|
* Rename passkey
|
|
311
441
|
* @returns void
|
|
312
442
|
* @throws ApiError
|
|
313
443
|
*/
|
|
314
|
-
passkeysPasskeyRename({ id, requestBody, authorization }: {
|
|
444
|
+
passkeysPasskeyRename({ id, requestBody, authorization, }: {
|
|
315
445
|
/**
|
|
316
446
|
* Internal passkey identifier
|
|
317
447
|
*/
|
|
318
448
|
id: string;
|
|
319
449
|
requestBody: PasskeyRenameRequestBody;
|
|
320
|
-
|
|
450
|
+
/**
|
|
451
|
+
* JWT Authorization header
|
|
452
|
+
*/
|
|
453
|
+
authorization?: string;
|
|
454
|
+
}): CancelablePromise<void>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
type ProfileEmailUpdateRequestBody = {
|
|
458
|
+
/**
|
|
459
|
+
* Email address
|
|
460
|
+
*/
|
|
461
|
+
email: string;
|
|
462
|
+
/**
|
|
463
|
+
* Whether to update the email address immediately or send an authorization code
|
|
464
|
+
* to verify.
|
|
465
|
+
*/
|
|
466
|
+
requestVerification?: boolean;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
type ProfilePhoneUpdateRequestBody = {
|
|
470
|
+
/**
|
|
471
|
+
* Whether the user consents to receiving SMS messages on this number. The phone
|
|
472
|
+
* will not be used for sending messages if no consent is provided.
|
|
473
|
+
*/
|
|
474
|
+
messagingConsent?: boolean;
|
|
475
|
+
/**
|
|
476
|
+
* Phone number
|
|
477
|
+
*/
|
|
478
|
+
phoneNumber: string;
|
|
479
|
+
/**
|
|
480
|
+
* Whether to update the phone number immediately or send an authorization code
|
|
481
|
+
* to verify. This method will fail if verification is requested but no consent
|
|
482
|
+
* is provided.
|
|
483
|
+
*/
|
|
484
|
+
requestVerification?: boolean;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
type ProfilePhoneVerifyRequestBody = {
|
|
488
|
+
/**
|
|
489
|
+
* Verification code
|
|
490
|
+
*/
|
|
491
|
+
authCode: string;
|
|
492
|
+
/**
|
|
493
|
+
* Username associated with the code
|
|
494
|
+
*/
|
|
495
|
+
username: string;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
declare class ProfileService {
|
|
499
|
+
readonly httpRequest: BaseHttpRequest;
|
|
500
|
+
constructor(httpRequest: BaseHttpRequest);
|
|
501
|
+
/**
|
|
502
|
+
* Delete a user profile and all associated passkey
|
|
503
|
+
* @returns void
|
|
504
|
+
* @throws ApiError
|
|
505
|
+
*/
|
|
506
|
+
profileProfileDelete({ id, }: {
|
|
507
|
+
/**
|
|
508
|
+
* Internal user identifier
|
|
509
|
+
*/
|
|
510
|
+
id: string;
|
|
511
|
+
}): CancelablePromise<void>;
|
|
512
|
+
/**
|
|
513
|
+
* Update profile email address
|
|
514
|
+
* @returns void
|
|
515
|
+
* @throws ApiError
|
|
516
|
+
*/
|
|
517
|
+
profileProfileEmailUpdate({ id, requestBody, }: {
|
|
518
|
+
/**
|
|
519
|
+
* Internal user identifier
|
|
520
|
+
*/
|
|
521
|
+
id: string;
|
|
522
|
+
requestBody: ProfileEmailUpdateRequestBody;
|
|
523
|
+
}): CancelablePromise<void>;
|
|
524
|
+
/**
|
|
525
|
+
* Delete phone from the profile
|
|
526
|
+
* @returns void
|
|
527
|
+
* @throws ApiError
|
|
528
|
+
*/
|
|
529
|
+
profileProfilePhoneDelete({ id, }: {
|
|
530
|
+
/**
|
|
531
|
+
* Internal user identifier
|
|
532
|
+
*/
|
|
533
|
+
id: string;
|
|
534
|
+
}): CancelablePromise<void>;
|
|
535
|
+
/**
|
|
536
|
+
* Update the profile phone number
|
|
537
|
+
* @returns void
|
|
538
|
+
* @throws ApiError
|
|
539
|
+
*/
|
|
540
|
+
profileProfilePhoneUpdate({ id, requestBody, }: {
|
|
541
|
+
/**
|
|
542
|
+
* Internal user identifier
|
|
543
|
+
*/
|
|
544
|
+
id: string;
|
|
545
|
+
requestBody: ProfilePhoneUpdateRequestBody;
|
|
546
|
+
}): CancelablePromise<void>;
|
|
547
|
+
/**
|
|
548
|
+
* Verify phone number with received authorization code
|
|
549
|
+
* @returns void
|
|
550
|
+
* @throws ApiError
|
|
551
|
+
*/
|
|
552
|
+
profileProfileEmailVerify({ requestBody, }: {
|
|
553
|
+
requestBody: ProfilePhoneVerifyRequestBody;
|
|
554
|
+
}): CancelablePromise<void>;
|
|
555
|
+
/**
|
|
556
|
+
* Verify phone number with received authorization code
|
|
557
|
+
* @returns void
|
|
558
|
+
* @throws ApiError
|
|
559
|
+
*/
|
|
560
|
+
profileProfilePhoneVerify({ requestBody, }: {
|
|
561
|
+
requestBody: ProfilePhoneVerifyRequestBody;
|
|
321
562
|
}): CancelablePromise<void>;
|
|
322
563
|
}
|
|
323
564
|
|
|
@@ -467,17 +708,24 @@ type RegInit = {
|
|
|
467
708
|
session: string;
|
|
468
709
|
};
|
|
469
710
|
|
|
711
|
+
type User = {
|
|
712
|
+
/**
|
|
713
|
+
* Display Name
|
|
714
|
+
*/
|
|
715
|
+
displayName?: string;
|
|
716
|
+
/**
|
|
717
|
+
* Username
|
|
718
|
+
*/
|
|
719
|
+
username: string;
|
|
720
|
+
/**
|
|
721
|
+
* Username type
|
|
722
|
+
*/
|
|
723
|
+
usernameType: 'email' | 'phone';
|
|
724
|
+
};
|
|
725
|
+
|
|
470
726
|
type RegInitRequestBody = {
|
|
471
727
|
app: Application;
|
|
472
728
|
deviceInfo: DeviceInfo;
|
|
473
|
-
/**
|
|
474
|
-
* Set of authentication factors:
|
|
475
|
-
* - Single factor: Username (i.e. email or phone) + FIDO2 credential;
|
|
476
|
-
* - Two factor: Username + password + FIDO2 credential;
|
|
477
|
-
* - Passwordless: FIDO2 discoverable credentials;
|
|
478
|
-
* - Passwordless + MFA: FIDO2 discoverable credentials + PIN;
|
|
479
|
-
*/
|
|
480
|
-
mfa?: Array<'fido2' | 'email' | 'phone' | 'password' | 'pin'>;
|
|
481
729
|
/**
|
|
482
730
|
* An opaque object containing user data. It is used in place of "user" attribute
|
|
483
731
|
* for creating passkeys for pre-authorized users ("user" attribute is ignored if
|
|
@@ -505,35 +753,19 @@ declare class RegService {
|
|
|
505
753
|
* @returns RegInit OK response.
|
|
506
754
|
* @throws ApiError
|
|
507
755
|
*/
|
|
508
|
-
regRegInit({ requestBody, userAgent, }: {
|
|
756
|
+
regRegInit({ requestBody, userAgent, authorization, }: {
|
|
509
757
|
requestBody: RegInitRequestBody;
|
|
510
758
|
/**
|
|
511
759
|
* Raw user-agent header as set by a browser
|
|
512
760
|
*/
|
|
513
761
|
userAgent?: string;
|
|
762
|
+
/**
|
|
763
|
+
* JWT Authorization header
|
|
764
|
+
*/
|
|
765
|
+
authorization?: string;
|
|
514
766
|
}): CancelablePromise<RegInit>;
|
|
515
767
|
}
|
|
516
768
|
|
|
517
|
-
type TokenVerifyRequestBody = {
|
|
518
|
-
/**
|
|
519
|
-
* JWT access token
|
|
520
|
-
*/
|
|
521
|
-
jwtAccess: string;
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
declare class TokenService {
|
|
525
|
-
readonly httpRequest: BaseHttpRequest;
|
|
526
|
-
constructor(httpRequest: BaseHttpRequest);
|
|
527
|
-
/**
|
|
528
|
-
* Validate JWT Access Token
|
|
529
|
-
* @returns void
|
|
530
|
-
* @throws ApiError
|
|
531
|
-
*/
|
|
532
|
-
tokenTokenVerify({ requestBody, }: {
|
|
533
|
-
requestBody: TokenVerifyRequestBody;
|
|
534
|
-
}): CancelablePromise<void>;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
769
|
type TxComplete = {
|
|
538
770
|
authCred?: Passkey;
|
|
539
771
|
/**
|
|
@@ -665,9 +897,10 @@ declare class VersionService {
|
|
|
665
897
|
type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
|
|
666
898
|
declare class LoginIDService {
|
|
667
899
|
readonly auth: AuthService;
|
|
900
|
+
readonly mgmt: MgmtService;
|
|
668
901
|
readonly passkeys: PasskeysService;
|
|
902
|
+
readonly profile: ProfileService;
|
|
669
903
|
readonly reg: RegService;
|
|
670
|
-
readonly token: TokenService;
|
|
671
904
|
readonly tx: TxService;
|
|
672
905
|
readonly version: VersionService;
|
|
673
906
|
readonly request: BaseHttpRequest;
|
|
@@ -693,7 +926,6 @@ declare class ApiError extends Error {
|
|
|
693
926
|
|
|
694
927
|
type UsernameType = User['usernameType'];
|
|
695
928
|
type DeviceInfoRequestBody = DeviceInfo;
|
|
696
|
-
type MFA = RegInitRequestBody['mfa'];
|
|
697
929
|
type Transports = CreationResult['transports'];
|
|
698
930
|
interface LoginIDConfig {
|
|
699
931
|
baseUrl: string;
|
|
@@ -704,12 +936,20 @@ interface PasskeyOptions {
|
|
|
704
936
|
displayName?: string;
|
|
705
937
|
usernameType?: UsernameType;
|
|
706
938
|
}
|
|
939
|
+
interface PasskeyManagementOptions {
|
|
940
|
+
token?: string;
|
|
941
|
+
}
|
|
942
|
+
interface ListPasskeysOptions extends PasskeyManagementOptions {
|
|
943
|
+
}
|
|
944
|
+
interface RenamePasskeyOptions extends PasskeyManagementOptions {
|
|
945
|
+
}
|
|
946
|
+
interface DeletePasskeyOptions extends PasskeyManagementOptions {
|
|
947
|
+
}
|
|
707
948
|
interface AuthenticateWithPasskeysOptions extends PasskeyOptions {
|
|
708
949
|
autoFill?: boolean;
|
|
709
950
|
abortSignal?: AbortSignal;
|
|
710
951
|
}
|
|
711
952
|
interface RegisterWithPasskeyOptions extends PasskeyOptions {
|
|
712
|
-
mfa?: MFA;
|
|
713
953
|
session?: string;
|
|
714
954
|
}
|
|
715
955
|
interface ConfirmTransactionOptions extends PasskeyOptions {
|
|
@@ -738,13 +978,38 @@ declare class LoginIDBase {
|
|
|
738
978
|
* @param {LoginIDConfig} config Configuration object for LoginID API, including the base URL.
|
|
739
979
|
*/
|
|
740
980
|
constructor(config: LoginIDConfig);
|
|
981
|
+
getToken(options: PasskeyOptions): string;
|
|
982
|
+
/**
|
|
983
|
+
*
|
|
984
|
+
* @returns {string} The name of the cookie
|
|
985
|
+
*/
|
|
986
|
+
getJwtCookieName(): string;
|
|
987
|
+
/**
|
|
988
|
+
* Set jwt token to localstorage
|
|
989
|
+
* @param {string} jwt Configuration object for LoginID API, including the base URL.
|
|
990
|
+
*/
|
|
991
|
+
setJwtCookie(jwt: string): void;
|
|
992
|
+
/**
|
|
993
|
+
* Retrieves the JWT access token.
|
|
994
|
+
* @returns {string | undefined} The JWT access token.
|
|
995
|
+
*/
|
|
996
|
+
getJwtCookie(): string | undefined;
|
|
997
|
+
/**
|
|
998
|
+
* checks if the user is logged in.
|
|
999
|
+
* @returns {boolean}
|
|
1000
|
+
*/
|
|
1001
|
+
isLoggedIn(): boolean;
|
|
1002
|
+
/**
|
|
1003
|
+
* deletes the jwt cookie.
|
|
1004
|
+
* @returns {boolean}
|
|
1005
|
+
*/
|
|
1006
|
+
signout(): void;
|
|
741
1007
|
}
|
|
742
1008
|
|
|
743
1009
|
/**
|
|
744
1010
|
* Extends LoginIDBase to support creation, registration, and authentication of passkeys.
|
|
745
1011
|
*/
|
|
746
1012
|
declare class Passkeys extends LoginIDBase {
|
|
747
|
-
private jwtAccess;
|
|
748
1013
|
/**
|
|
749
1014
|
* Initializes a new Passkeys instance with the provided configuration.
|
|
750
1015
|
* @param {LoginIDConfig} config Configuration object for LoginID.
|
|
@@ -777,6 +1042,36 @@ declare class Passkeys extends LoginIDBase {
|
|
|
777
1042
|
* @returns {Promise<any>} Result of the authentication operation.
|
|
778
1043
|
*/
|
|
779
1044
|
authenticateWithPasskey(username?: string, options?: AuthenticateWithPasskeysOptions): Promise<PasskeyResult>;
|
|
1045
|
+
/**
|
|
1046
|
+
* Generates a code with passkey.
|
|
1047
|
+
* @param {string} username Username to authenticate.
|
|
1048
|
+
* @param {AuthenticateWithPasskeysOptions} options Additional authentication options.
|
|
1049
|
+
* @returns {Promise<AuthCode>} Code and expiry.
|
|
1050
|
+
*/
|
|
1051
|
+
generateCodeWithPasskey(username: string, options?: AuthenticateWithPasskeysOptions): Promise<AuthCode>;
|
|
1052
|
+
/**
|
|
1053
|
+
* Authenticate with a code.
|
|
1054
|
+
* @param {string} username Username to authenticate.
|
|
1055
|
+
* @param {string} code code to authenticate.
|
|
1056
|
+
* @param {AuthenticateWithPasskeysOptions} options Additional authentication options.
|
|
1057
|
+
* @returns {Promise<any>} Result of the authentication operation.
|
|
1058
|
+
*/
|
|
1059
|
+
authenticateWithCode(username: string, code: string, options?: AuthenticateWithPasskeysOptions): Promise<JWT>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Add passkey
|
|
1062
|
+
* @param username Username to authenticate.
|
|
1063
|
+
* @param options Additional authentication options.
|
|
1064
|
+
* @returns {Promise<PasskeyResult>} Result of the add passkey operation.
|
|
1065
|
+
*/
|
|
1066
|
+
addPasskey(username: string, options?: PasskeyOptions): Promise<PasskeyResult>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Add passkey with code
|
|
1069
|
+
* @param username Username to authenticate.
|
|
1070
|
+
* @param code Code to authenticate.
|
|
1071
|
+
* @param options Additional authentication options.
|
|
1072
|
+
* @returns @returns {Promise<PasskeyResult>} Result of the add passkey with code operation.
|
|
1073
|
+
*/
|
|
1074
|
+
addPasskeyWithCode(username: string, code: string, options?: PasskeyOptions): Promise<PasskeyResult>;
|
|
780
1075
|
/**
|
|
781
1076
|
* Confirms a transaction using a passkey.
|
|
782
1077
|
*
|
|
@@ -794,11 +1089,6 @@ declare class Passkeys extends LoginIDBase {
|
|
|
794
1089
|
* The result includes details about the transaction's details and includes a new JWT access token.
|
|
795
1090
|
*/
|
|
796
1091
|
confirmTransaction(username: string, txPayload: string, options?: ConfirmTransactionOptions): Promise<TxComplete>;
|
|
797
|
-
/**
|
|
798
|
-
* Retrieves the JWT access token.
|
|
799
|
-
* @returns {string} The JWT access token.
|
|
800
|
-
*/
|
|
801
|
-
getJWTAccess(): string;
|
|
802
1092
|
}
|
|
803
1093
|
|
|
804
1094
|
/**
|
|
@@ -815,7 +1105,7 @@ declare class PasskeyManager extends LoginIDBase {
|
|
|
815
1105
|
* @param {string} authToken Authorization token to authenticate the request.
|
|
816
1106
|
* @returns {Promise<PasskeysPasskeyResponseCollection>} A collection of passkeys.
|
|
817
1107
|
*/
|
|
818
|
-
listPasskeys(
|
|
1108
|
+
listPasskeys(options?: ListPasskeysOptions): Promise<PasskeyCollection>;
|
|
819
1109
|
/**
|
|
820
1110
|
* Renames a specified passkey.
|
|
821
1111
|
* @param {string} authToken Authorization token to authenticate the request.
|
|
@@ -823,14 +1113,14 @@ declare class PasskeyManager extends LoginIDBase {
|
|
|
823
1113
|
* @param {string} name The new name for the passkey.
|
|
824
1114
|
* @returns {Promise<null>} A promise that resolves to null upon successful completion.
|
|
825
1115
|
*/
|
|
826
|
-
renamePasskey(
|
|
1116
|
+
renamePasskey(id: string, name: string, options?: RenamePasskeyOptions): Promise<null>;
|
|
827
1117
|
/**
|
|
828
1118
|
* Deletes a specified passkey.
|
|
829
1119
|
* @param {string} authToken Authorization token to authenticate the request.
|
|
830
1120
|
* @param {string} id The ID of the passkey to delete.
|
|
831
1121
|
* @returns {Promise<null>} A promise that resolves to null upon successful deletion.
|
|
832
1122
|
*/
|
|
833
|
-
deletePasskey(
|
|
1123
|
+
deletePasskey(id: string, options?: DeletePasskeyOptions): Promise<null>;
|
|
834
1124
|
}
|
|
835
1125
|
|
|
836
1126
|
interface LoginIDWebSDK extends Passkeys, PasskeyManager {
|
|
@@ -889,4 +1179,4 @@ interface DoesDeviceSupportPasskeysResponse {
|
|
|
889
1179
|
*/
|
|
890
1180
|
declare function doesDeviceSupportPasskeys(): Promise<DoesDeviceSupportPasskeysResponse>;
|
|
891
1181
|
|
|
892
|
-
export { ApiError, type AuthenticateWithPasskeysOptions, type ConfirmTransactionOptions, type DeviceInfoRequestBody, type DoesDeviceSupportPasskeysResponse, type LoginIDConfig, LoginIDWebSDK, type
|
|
1182
|
+
export { ApiError, type AuthenticateWithPasskeysOptions, type ConfirmTransactionOptions, type DeletePasskeyOptions, type DeviceInfoRequestBody, type DoesDeviceSupportPasskeysResponse, type ListPasskeysOptions, type LoginIDConfig, LoginIDWebSDK, PasskeyError, type PasskeyManagementOptions, type PasskeyOptions, type PasskeyResult, type RegisterWithPasskeyOptions, type RenamePasskeyOptions, type Transports, type UsernameType, createPasskeyCredential, LoginIDWebSDK as default, doesDeviceSupportPasskeys, getPasskeyCredential, isConditionalUIAvailable, isPlatformAuthenticatorAvailable };
|