@digitalpersona/enrollment
Version:
DigitalPersona Enrollment API
3 lines (2 loc) • 9.84 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@digitalpersona/core"),require("u2f-api")):"function"==typeof define&&define.amd?define(["exports","@digitalpersona/core","u2f-api"],t):t(((e=e||self).dp=e.dp||{},e.dp.enrollment=e.dp.enrollment||{}),e.dp.core,e.u2fApi)}(this,function(e,t,n){"use strict";var r=function(){function e(e,n,r){if(this.enrollService=e,this.user=n,this.securityOfficer=r,!this.enrollService)throw new Error("enrollService");if(!this.user)throw new Error("user");this.securityOfficer||this.user instanceof t.User||(this.securityOfficer=this.user)}return e.prototype.isAuthenticated=function(){return!(this.user instanceof t.User)},e.prototype.getJWT=function(){return this.user instanceof t.User?"":this.user},e.prototype.getUser=function(){return this.user instanceof t.User?this.user:t.User.fromJWT(this.user)},e}(),o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function i(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var l,s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},c=function(){function e(e){if(this.context=e,!this.context)throw new Error("context")}return e.prototype._canEnroll=function(e){return this.context.enrollService.IsEnrollmentAllowed(new t.Ticket(this.context.securityOfficer||""),this.context.getUser(),e)},e.prototype._enroll=function(e){return this.context.user instanceof t.User?this.context.enrollService.EnrollAltusUserCredentials(new t.Ticket(this.context.securityOfficer||""),this.context.user,e):this.context.enrollService.EnrollUserCredentials(new t.Ticket(this.context.securityOfficer||""),new t.Ticket(this.context.user),e)},e.prototype._unenroll=function(e){return this.context.user instanceof t.User?this.context.enrollService.DeleteAltusUserCredentials(new t.Ticket(this.context.securityOfficer||""),this.context.user,e):this.context.enrollService.DeleteUserCredentials(new t.Ticket(this.context.securityOfficer||""),new t.Ticket(this.context.user),e)},e}(),u=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.getEnrolledCards=function(){return this.context.enrollService.GetEnrollmentData(this.context.getUser(),t.Credential.SmartCard).then(function(e){return JSON.parse(t.Utf8.fromBase64Url(e))})},n.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.SmartCard)},n.prototype.enroll=function(n){return e.prototype._enroll.call(this,new t.Credential(t.Credential.SmartCard,n))},n.prototype.unenroll=function(n){return e.prototype._unenroll.call(this,new t.Credential(t.Credential.SmartCard,n))},n}(c),a=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.ContactlessCard)},n.prototype.enroll=function(n){return e.prototype._enroll.call(this,new t.Credential(t.Credential.ContactlessCard,n))},n.prototype.unenroll=function(){return e.prototype._unenroll.call(this,new t.Credential(t.Credential.ContactlessCard))},n}(c),p=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.ProximityCard)},n.prototype.enroll=function(n){return e.prototype._enroll.call(this,new t.Credential(t.Credential.ProximityCard,n))},n.prototype.unenroll=function(){return e.prototype._unenroll.call(this,new t.Credential(t.Credential.ProximityCard))},n}(c),f=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.Face)},n.prototype.enroll=function(n){return e.prototype._enroll.call(this,new t.Credential(t.Credential.Face,n))},n.prototype.unenroll=function(){return e.prototype._unenroll.call(this,new t.Credential(t.Credential.Face))},n}(c),d=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.getEnrolledFingers=function(){return this.context.enrollService.GetEnrollmentData(this.context.getUser(),t.Credential.Fingerprints).then(function(e){return JSON.parse(t.Utf8.fromBase64Url(e)).map(function(e){return t.Finger.fromJson(e)})})},n.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.Fingerprints)},n.prototype.enroll=function(n,r){var o={position:n instanceof t.Finger?n.position:n,samples:r};return e.prototype._enroll.call(this,new t.Credential(t.Credential.Fingerprints,o))},n.prototype.unenroll=function(n){var r="number"==typeof n?[{position:n}]:n instanceof t.Finger?[n]:n instanceof Array?n.map(function(e){return e instanceof t.Finger?e.position:e}):null;return e.prototype._unenroll.call(this,new t.Credential(t.Credential.Fingerprints,r))},n}(c);!function(e){e[e.SendEmailVerificationRequest=16]="SendEmailVerificationRequest",e[e.SendSMSRequest=513]="SendSMSRequest",e[e.SendEmailRequest=514]="SendEmailRequest",e[e.UnlockActiveIdHardwareToken=515]="UnlockActiveIdHardwareToken"}(l||(l={}));var h,y=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.createKeyUri=function(e){var n=this.context.getJWT(),r=t.JWT.claims(n);if(!r)return Promise.reject(new Error("NoClaims"));var o=r.dom||r.iss;if(!o)return Promise.reject(new Error("NoIssuer"));var i=r.uid||r.ad_guid,l=this.context.getUser().name,s=t.Base32.fromBytes(e);return this.context.enrollService.GetEnrollmentData(t.User.Anonymous(),t.Credential.OneTimePassword).then(function(e){var n=JSON.parse(e);if(!n)return Promise.reject(new Error("NoEnrollmentData"));var r=i&&n.pn_tenant_id;return new t.Url("otpauth://totp",o+":"+l,{secret:s,issuer:o,apikey:n.pn_api_key,tenantid:r?n.pn_tenant_id:void 0,useruuid:r?i:void 0}).href})},n.prototype.sendVerificationCode=function(e,n){return this.context.enrollService.CustomAction(t.Ticket.None(),this.context.getUser(),new t.Credential(t.Credential.OneTimePassword,{key:t.Base64Url.fromBytes(e),phoneNumber:n}),l.SendSMSRequest).then()},n.prototype.enrollSoftwareOtp=function(n,r,o){return e.prototype._enroll.call(this,new t.Credential(t.Credential.OneTimePassword,{otp:n,key:t.Base64Url.fromBytes(r),phoneNumber:o}))},n.prototype.enrollHardwareOtp=function(n,r,o,i){return e.prototype._enroll.call(this,new t.Credential(t.Credential.OneTimePassword,{otp:n,serialNumber:r,counter:o,timer:i}))},n.prototype.unenroll=function(){return e.prototype._unenroll.call(this,new t.Credential(t.Credential.OneTimePassword))},n}(c);!function(e){e[e.PasswordRandomization=4]="PasswordRandomization",e[e.PasswordReset=13]="PasswordReset"}(h||(h={}));var C=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.Password)},n.prototype.enroll=function(n,r){return e.prototype._enroll.call(this,new t.Credential(t.Credential.Password,{oldPassword:r,newPassword:n}))},n.prototype.reset=function(n){return e.prototype._enroll.call(this,new t.Credential(t.Credential.Password,n))},n.prototype.randomize=function(){return this.context.enrollService.CustomAction(new t.Ticket(this.context.securityOfficer||""),this.context.getUser(),new t.Credential(t.Credential.Password),h.PasswordRandomization)},n}(c),w=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.PIN)},n.prototype.enroll=function(n){return e.prototype._enroll.call(this,new t.Credential(t.Credential.PIN,n))},n.prototype.unenroll=function(){return e.prototype._unenroll.call(this,new t.Credential(t.Credential.PIN))},n}(c),m=function(e){function n(t){return e.call(this,t)||this}return i(n,e),n.prototype.getEnrolledQuestions=function(){return this.context.enrollService.GetEnrollmentData(this.context.getUser(),t.Credential.SecurityQuestions).then(function(e){return JSON.parse(t.Utf8.fromBase64Url(e)).map(function(e){return t.Question.fromJson(e)})})},n.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.SecurityQuestions)},n.prototype.enroll=function(n){var r=n.filter(function(e){return e.question.number===e.answer.number}).filter(function(e,t,n){return n.findIndex(function(t){return n=e,t.question.number===n.question.number;var n})===t}).sort(function(e,t){return t.question.number-e.question.number});return e.prototype._enroll.call(this,new t.Credential(t.Credential.SecurityQuestions,r))},n.prototype.unenroll=function(){return e.prototype._unenroll.call(this,new t.Credential(t.Credential.SecurityQuestions))},n}(c),E=function(e){function r(t,n){var r=e.call(this,t)||this;if(!n)throw new Error("appId");return r.appId=n,r}return i(r,e),r.prototype.canEnroll=function(){return e.prototype._canEnroll.call(this,t.Credential.U2F)},r.prototype.enroll=function(){var o=this,i=this.appId,l=Math.round((new Date).getTime()/(1e3*r.TIME_WINDOW)),c=t.Base64Url.fromUtf16(l.toString()),u=[{version:"U2F_V2",appId:i,challenge:c}];return n.register(u,[],r.TIMEOUT).then(function(n){return e.prototype._enroll.call(o,new t.Credential(t.Credential.U2F,s({version:"U2F_V2",appId:i},n)))})},r.prototype.unenroll=function(){return e.prototype._unenroll.call(this,new t.Credential(t.Credential.U2F))},r.TIMEOUT=20,r.TIME_WINDOW=30,r}(c);e.ContactlessCardEnroll=a,e.EnrollmentContext=r,e.FaceEnroll=f,e.FingerprintsEnroll=d,e.PasswordEnroll=C,e.PinEnroll=w,e.ProximityCardEnroll=p,e.SecurityQuestionsEnroll=m,e.SmartCardEnroll=u,e.TimeOtpEnroll=y,e.U2FEnroll=E,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=index.umd.min.js.map