UNPKG

@digitalpersona/core

Version:
3 lines (2 loc) 8.59 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).dp=e.dp||{},e.dp.core=e.dp.core||{}))}(this,function(e){"use strict";class t{constructor(e,r,n){this.href=t.create(e,r,n)}static getSanitizedQuery(e){return Object.keys(e).map(t=>[t,e[t]].map(encodeURIComponent).join("=")).join("&")}static create(e,r,n){return e+(r?`/${encodeURI(r)}`:"")+(n?`?${t.getSanitizedQuery(n)}`:"")}}var r,n,o,s,i,a,m,c,l,f;(r=e.BioFactor||(e.BioFactor={}))[r.Multiple=1]="Multiple",r[r.FacialFeatures=2]="FacialFeatures",r[r.Voice=4]="Voice",r[r.Fingerprint=8]="Fingerprint",r[r.Iris=16]="Iris",r[r.Retina=32]="Retina",r[r.HandGeometry=64]="HandGeometry",r[r.SignatureDynamics=128]="SignatureDynamics",r[r.KeystrokeDynamics=256]="KeystrokeDynamics",r[r.LipMovement=512]="LipMovement",r[r.ThermalFaceImage=1024]="ThermalFaceImage",r[r.ThermalHandImage=2048]="ThermalHandImage",r[r.Gait=4096]="Gait",(n=e.BioSampleFormatOwner||(e.BioSampleFormatOwner={}))[n.None=0]="None",n[n.Neurotechnologija=49]="Neurotechnologija",n[n.DigitalPersona=51]="DigitalPersona",n[n.Cognitec=99]="Cognitec",n[n.Innovatrics=53]="Innovatrics";class u{constructor(e,t){this.FormatOwner=e,this.FormatID=t}}(o=e.BioSampleType||(e.BioSampleType={}))[o.Raw=1]="Raw",o[o.Intermediate=2]="Intermediate",o[o.Processed=4]="Processed",o[o.RawWSQCompressed=8]="RawWSQCompressed",o[o.Encrypted=16]="Encrypted",o[o.Signed=32]="Signed",(s=e.BioSamplePurpose||(e.BioSamplePurpose={}))[s.Any=0]="Any",s[s.Verify=1]="Verify",s[s.Identify=2]="Identify",s[s.Enroll=3]="Enroll",s[s.EnrollForVerificationOnly=4]="EnrollForVerificationOnly",s[s.EnrollForIdentificationOnly=5]="EnrollForIdentificationOnly",s[s.Audit=6]="Audit",(i=e.BioSampleEncryption||(e.BioSampleEncryption={}))[i.None=0]="None",i[i.XTEA=1]="XTEA";class p{constructor(e,t,r,n,o,s){this.Factor=e,this.Format=t,this.Type=r,this.Purpose=n,this.Quality=o,this.Encryption=s}}class y{constructor(e,t){this.Header=e,this.Data=t,this.Version=1}}class d{}d.fromUtf8=(e=>decodeURIComponent(escape(h.noBom(e)))),d.fromBase64=(e=>d.fromUtf8(h.fromBase64(e))),d.fromBase64Url=(e=>d.fromUtf8(h.fromBase64Url(e))),d.withBom=(e=>"\ufeff"+e),d.noBom=(e=>e.replace(/^\uFEFF/,""));class h{}h.fromUtf16=(e=>unescape(encodeURIComponent(d.noBom(e)))),h.fromBase64=(e=>atob(e)),h.fromBase64Url=(e=>h.fromBase64(g.fromBase64Url(e))),h.fromBytes=(e=>String.fromCharCode(...e)),h.withBom=(e=>""+e),h.noBom=(e=>e.replace(/^\xEF\xBB\xBF/,""));class g{}g.fromUtf8=(e=>btoa(e)),g.fromUtf16=(e=>g.fromUtf8(h.fromUtf16(e))),g.fromBase64Url=(e=>(e.length%4==2?e+"==":e.length%4==3?e+"=":e).replace(/-/g,"+").replace(/_/g,"/")),g.fromBytes=(e=>g.fromUtf8(h.fromBytes(e))),g.fromJSON=(e=>g.fromUtf16(JSON.stringify(e)));class B{}B.fromBase64=(e=>e.replace(/\=/g,"").replace(/\+/g,"-").replace(/\//g,"_")),B.fromUtf8=(e=>B.fromBase64(g.fromUtf8(e))),B.fromUtf16=(e=>B.fromBase64(g.fromUtf16(e))),B.fromBytes=(e=>B.fromUtf8(h.fromBytes(e))),B.fromJSON=(e=>B.fromUtf16(JSON.stringify(e)));(a=e.UserNameType||(e.UserNameType={}))[a.Unknown=0]="Unknown",a[a.NetBIOSDomain=1]="NetBIOSDomain",a[a.DNSDomain=2]="DNSDomain",a[a.SAM=3]="SAM",a[a.Simple=4]="Simple",a[a.UID=5]="UID",a[a.UPN=6]="UPN",a[a.Display=7]="Display",a[a.SID=8]="SID",a[a.DP=9]="DP";class F{constructor(t,r){this.name=t||"",this.type=r||(0===this.name.length?e.UserNameType.Unknown:"*"===this.name?e.UserNameType.Unknown:-1!==this.name.indexOf("@")?e.UserNameType.UPN:-1!==this.name.indexOf("\\")?e.UserNameType.SAM:/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(this.name)?e.UserNameType.UID:e.UserNameType.DP)}isAnonymous(){return!this.name||0===this.name.length}isEveryone(){return"*"===this.name}static Anonymous(){return new F("",e.UserNameType.Unknown)}static Everyone(){return new F("*",e.UserNameType.Unknown)}static fromJWT(t,r){const n=U.claims(t);return n.sub&&n.sub instanceof F?n.sub:n.wan?new F(n.wan,r):n.sub?new F(n.sub,r||e.UserNameType.DP):F.Anonymous()}}class A{constructor(e,t,r){this.typ=e,this.cty=r,this.alg=t}}class U{static claims(e){const t=e.split("."),r=JSON.parse(d.fromBase64Url(t[0]));if("JWT"===r.cty)return Object.assign(Object.assign({},r),new A);{const e=JSON.parse(d.fromBase64Url(t[1]));if("object"==typeof e.sub){const{name:t,type:r}=e.sub;e.sub=new F(t,r)}return e}}static errors(e){const t=[],r=U.claims(e),n=(new Date).getTime()/1e3;return r.iat&&r.nbf&&r.iat>r.nbf&&t.push(new Error("JWT.Error.IssueTimeLaterThanNotBefore")),r.nbf&&r.nbf>n&&t.push(new Error("JWT.Error.NotEffectiveYet")),r.exp&&r.exp<=n&&t.push(new Error("JWT.Error.Expired")),t.length>0?t:null}}(m=e.ClaimName||(e.ClaimName={})).TokensId="jti",m.IssuerName="iss",m.IssuedAt="iat",m.Audience="aud",m.NotBefore="nbf",m.ExpiresAfter="exp",m.SubjectName="sub",m.IssuerDomain="dom",m.SubjectUid="uid",m.ADGuid="ad_guid",m.CredentialsUsed="crd",m.Group="group",m.Role="role",m.WindowsAccountName="wan",m.T24Principal="t24";class C{constructor(e){this.jwt=e}static None(){return new C("")}}class E{constructor(e,t,r=!0){this.id=e,this.data=t?r?B.fromUtf16("string"!=typeof t?JSON.stringify(t):t):JSON.stringify(t):null}static None(){return new E("")}static Any(){return new E("*")}}E.Password="D1A1F561-E14A-4699-9138-2EB523E132CC",E.Fingerprints="AC184A13-60AB-40E5-A514-E10F777EC2F9",E.Face="85AEAA44-413B-4DC1-AF09-ADE15892730A",E.SmartCard="D66CC98D-4153-4987-8EBE-FB46E848EA98",E.ContactlessCard="F674862D-AC70-48CA-B73E-64A22F3BAC44",E.ProximityCard="1F31360C-81C0-4EE0-9ACD-5A4400F66CC2",E.PIN="8A6FCEC3-3C8A-40C2-8AC0-A039EC01BA05",E.SecurityQuestions="B49E99C6-6C94-42DE-ACD7-FD6B415DF503",E.Bluetooth="E750A180-577B-47F7-ACD9-F89A7E27FA49",E.OneTimePassword="324C38BD-0B51-4E4D-BD75-200DA0C8177F",E.U2F="5D5F73AF-BCE5-4161-9584-42A61AED0E48",E.IWA="AE922666-9667-49BC-97DA-1EB0E1EF73D2",E.Email="7845D71D-AB67-4EA7-913C-F81E75C3A087",E.Behavior="193C41F6-5CF6-4525-84CC-223603DAC9AB",E.Cards="FCFA704C-144B-42DB-8DF3-13F5CD20C525",(c=e.FingerPosition||(e.FingerPosition={}))[c.Unknown=0]="Unknown",c[c.RightThumb=1]="RightThumb",c[c.RightIndex=2]="RightIndex",c[c.RightMiddle=3]="RightMiddle",c[c.RightRing=4]="RightRing",c[c.RightLittle=5]="RightLittle",c[c.LeftThumb=6]="LeftThumb",c[c.LeftIndex=7]="LeftIndex",c[c.LeftMiddle=8]="LeftMiddle",c[c.LeftRing=9]="LeftRing",c[c.LeftLittle=10]="LeftLittle";class D{constructor(e){this.position=e}static fromJson(e){return new D(e.position)}}(l=e.FaceImageType||(e.FaceImageType={}))[l.Jpeg=1]="Jpeg";class w{constructor(t,r=e.FaceImageType.Jpeg){this.ImageData=t,this.ImageType=r,this.Version=1}static fromDataURL(e){return new w(e.replace("data:image/jpeg;base64,",""))}static fromCanvas(e,t=1){return w.fromDataURL(e.toDataURL("image/jpeg",t))}toBioSample(t=new u(e.BioSampleFormatOwner.None,0),r=e.BioSamplePurpose.Any,n=196864){return new y(new p(e.BioFactor.FacialFeatures,t,e.BioSampleType.Raw,r,-1,e.BioSampleEncryption.None),B.fromJSON(this))}}(f=e.QuestionType||(e.QuestionType={}))[f.Regular=0]="Regular",f[f.Custom=1]="Custom";class S{constructor(t,r,n,o,s){if(this.number=t,this.lang_id=r,this.sublang_id=n,this.keyboard_layout=o,this.text=s,this.version=1,this.type=t<=100?e.QuestionType.Regular:e.QuestionType.Custom,this.type===e.QuestionType.Custom&&!s)throw new Error("Question text is required for custom questions")}static fromJson(e){const t=e;return new S(t.number,t.lang_id,t.sublang_id,t.keyboard_layout,t.text)}}e.Answer=class{constructor(e,t){this.text=t,this.number=e instanceof S?e.number:e}},e.Base32=class{static fromBytes(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";let r=0,n=0,o=0,s=0,i=0,a="",m=e.length,c=0;const l=5*Math.floor(m/5);for(;c<l;)r=e[c++],n=e[c++],o=e[c++],s=e[c++],i=e[c++],a+=t[r>>>3]+t[31&(r<<2|n>>>6)]+t[n>>>1&31]+t[31&(n<<4|o>>>4)]+t[31&(o<<1|s>>>7)]+t[s>>>2&31]+t[31&(s<<3|i>>>5)]+t[31&i];const f=m-l;if(0===f)return a;switch(f){case 4:s=e[--m];case 3:o=e[--m];case 2:n=e[--m];case 1:r=e[--m]}switch(a+=t[r>>>3],f){case 1:return a+t[r<<2&31]+"======";case 2:return a+t[31&(r<<2|n>>>6)]+t[n>>>1&31]+t[n<<4&31]+"====";case 3:return a+t[31&(r<<2|n>>>6)]+t[n>>>1&31]+t[31&(n<<4|o>>>4)]+t[o<<1&31]+"===";case 4:return a+t[31&(r<<2|n>>>6)]+t[n>>>1&31]+t[31&(n<<4|o>>>4)]+t[31&(o<<1|s>>>7)]+t[s>>>2&31]+t[s<<3&31]+"="}return a}},e.Base64=g,e.Base64Url=B,e.BioSample=y,e.BioSampleFormat=u,e.BioSampleHeader=p,e.Credential=E,e.FaceImage=w,e.Finger=D,e.JWT=U,e.Question=S,e.Ticket=C,e.Url=t,e.User=F,e.Utf16=d,e.Utf8=h,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=index.umd.min.js.map