@mattrglobal/verifier-sdk-web 2.0.0-preview-digital-credential-api.5 → 2.0.0-preview-digital-credential-api.6

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.
@@ -7,8 +7,8 @@
7
7
  * Do Not Translate or Localize
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
- * Generated: 2025-04-28
11
- * Version: 2.0.0-preview-digital-credential-api.5
10
+ * Generated: 2025-06-13
11
+ * Version: 2.0.0-preview-digital-credential-api.6
12
12
  * Dependencies:
13
13
  *
14
14
  * neverthrow -- 4.3.0
@@ -33,5 +33,5 @@
33
33
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34
34
  PERFORMANCE OF THIS SOFTWARE.
35
35
  ***************************************************************************** */
36
- function r(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))}function n(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function i(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}var o,a={withStackTrace:!1},s=function(e,t,r){return void 0===r&&(r=a),{data:t.isOk()?{type:"Ok",value:t.value}:{type:"Err",value:t.error},message:e,stack:r.withStackTrace?(new Error).stack:void 0}};!function(e){e.fromThrowable=function(e,t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{var o=e.apply(void 0,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(i(arguments[t]));return e}(r));return l(o)}catch(e){return u(t?t(e):e)}}}}(o||(o={}));var l=function(e){return new c(e)},u=function(e){return new d(e)},c=function(){function e(e){this.value=e}return e.prototype.isOk=function(){return!0},e.prototype.isErr=function(){return!this.isOk()},e.prototype.map=function(e){return l(e(this.value))},e.prototype.mapErr=function(e){return l(this.value)},e.prototype.andThen=function(e){return e(this.value)},e.prototype.orElse=function(e){return l(this.value)},e.prototype.asyncAndThen=function(e){return e(this.value)},e.prototype.asyncMap=function(e){return p.fromSafePromise(e(this.value))},e.prototype.unwrapOr=function(e){return this.value},e.prototype.match=function(e,t){return e(this.value)},e.prototype._unsafeUnwrap=function(e){return this.value},e.prototype._unsafeUnwrapErr=function(e){throw s("Called `_unsafeUnwrapErr` on an Ok",this,e)},e}(),d=function(){function e(e){this.error=e}return e.prototype.isOk=function(){return!1},e.prototype.isErr=function(){return!this.isOk()},e.prototype.map=function(e){return u(this.error)},e.prototype.mapErr=function(e){return u(e(this.error))},e.prototype.andThen=function(e){return u(this.error)},e.prototype.orElse=function(e){return e(this.error)},e.prototype.asyncAndThen=function(e){return f(this.error)},e.prototype.asyncMap=function(e){return f(this.error)},e.prototype.unwrapOr=function(e){return e},e.prototype.match=function(e,t){return t(this.error)},e.prototype._unsafeUnwrap=function(e){throw s("Called `_unsafeUnwrap` on an Err",this,e)},e.prototype._unsafeUnwrapErr=function(e){return this.error},e}();o.fromThrowable;var p=function(){function e(e){this._promise=e}return e.fromSafePromise=function(t){return new e(t.then((function(e){return new c(e)})))},e.fromPromise=function(t,r){return new e(t.then((function(e){return new c(e)})).catch((function(e){return new d(r(e))})))},e.prototype.map=function(t){var i=this;return new e(this._promise.then((function(e){return r(i,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return e.isErr()?[2,new d(e.error)]:(r=c.bind,[4,t(e.value)]);case 1:return[2,new(r.apply(c,[void 0,n.sent()]))]}}))}))})))},e.prototype.mapErr=function(t){var i=this;return new e(this._promise.then((function(e){return r(i,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return e.isOk()?[2,new c(e.value)]:(r=d.bind,[4,t(e.error)]);case 1:return[2,new(r.apply(d,[void 0,n.sent()]))]}}))}))})))},e.prototype.andThen=function(t){return new e(this._promise.then((function(r){if(r.isErr())return new d(r.error);var n=t(r.value);return n instanceof e?n._promise:n})))},e.prototype.orElse=function(t){var i=this;return new e(this._promise.then((function(e){return r(i,void 0,void 0,(function(){return n(this,(function(r){return e.isErr()?[2,t(e.error)]:[2,new c(e.value)]}))}))})))},e.prototype.match=function(e,t){return this._promise.then((function(r){return r.match(e,t)}))},e.prototype.unwrapOr=function(e){return this._promise.then((function(t){return t.unwrapOr(e)}))},e.prototype.then=function(e,t){return this._promise.then(e,t)},e}(),f=function(e){return new p(Promise.resolve(new d(e)))};function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=C(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function h(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||C(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(e)}function C(e,t){if(e){if("string"==typeof e)return y(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(e,t):void 0}}function k(e){var t,r,n=w(e);return"string"===n?'"'.concat(e,'"'):"number"===n||"bigint"===n||"boolean"===n?"".concat(e):"object"===n||"function"===n?null!==(t=e&&(null===(r=Object.getPrototypeOf(e))||void 0===r||null===(r=r.constructor)||void 0===r?void 0:r.name))&&void 0!==t?t:"null":n}function E(e,t,r,n,i){var o,a,s,l,u,c,d,p,f,y,v,h=i&&"input"in i?i.input:r.value,m=null!==(o=null!==(a=null==i?void 0:i.expected)&&void 0!==a?a:e.expects)&&void 0!==o?o:null,g=null!==(s=null==i?void 0:i.received)&&void 0!==s?s:k(h),b={kind:e.kind,type:e.type,input:h,expected:m,received:g,message:"Invalid ".concat(t,": ").concat(m?"Expected ".concat(m," but r"):"R","eceived ").concat(g),requirement:e.requirement,path:null==i?void 0:i.path,issues:null==i?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},w="schema"===e.kind,C=null!==(l=null!==(u=null!==(c=null!==(d=null!==(p=null==i?void 0:i.message)&&void 0!==p?p:e.message)&&void 0!==d?d:(f=e.reference,y=b.lang,null===(v=void 0)||void 0===v||null===(v=v.get(f))||void 0===v?void 0:v.get(y)))&&void 0!==c?c:w?function(e){var t;return null===(t=void 0)||void 0===t?void 0:t.get(e)}(b.lang):null)&&void 0!==u?u:n.message)&&void 0!==l?l:function(e){var t;return null===(t=void 0)||void 0===t?void 0:t.get(e)}(b.lang);C&&(b.message="function"==typeof C?C(b):C),w&&(r.typed=!1),r.issues?r.issues.push(b):r.issues=[b]}function T(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function S(e,t){var r,n=b(new Set(e));return n.length>1?"(".concat(n.join(" ".concat(t," ")),")"):null!==(r=n[0])&&void 0!==r?r:"never"}function O(e){return{kind:"validation",type:"non_empty",reference:O,async:!1,expects:"!0",message:e,_run:function(e,t){return e.typed&&0===e.value.length&&E(this,"length",e,t,{received:"0"}),e}}}function I(e,t){return{kind:"schema",type:"array",reference:I,expects:"Array",async:!1,item:e,message:t,_run:function(e,t){var r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(var n=0;n<r.length;n++){var i=r[n],o=this.item._run({typed:!1,value:i},t);if(o.issues){var a,s={type:"array",origin:"value",input:r,key:n,value:i},l=v(o.issues);try{for(l.s();!(a=l.n()).done;){var u,c=a.value;c.path?c.path.unshift(s):c.path=[s],null===(u=e.issues)||void 0===u||u.push(c)}}catch(e){l.e(e)}finally{l.f()}if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value.push(o.value)}}else E(this,"type",e,t);return e}}}function P(e){return{kind:"schema",type:"boolean",reference:P,expects:"boolean",async:!1,message:e,_run:function(e,t){return"boolean"==typeof e.value?e.typed=!0:E(this,"type",e,t),e}}}function F(e){return{kind:"schema",type:"function",reference:F,expects:"Function",async:!1,message:e,_run:function(e,t){return"function"==typeof e.value?e.typed=!0:E(this,"type",e,t),e}}}function R(e,t){return{kind:"schema",type:"object",reference:R,expects:"Object",async:!1,entries:e,message:t,_run:function(e,t){var r=e.value;if(r&&"object"===w(r))for(var n in e.typed=!0,e.value={},this.entries){var i=r[n],o=this.entries[n]._run({typed:!1,value:i},t);if(o.issues){var a,s={type:"object",origin:"value",input:r,key:n,value:i},l=v(o.issues);try{for(l.s();!(a=l.n()).done;){var u,c=a.value;c.path?c.path.unshift(s):c.path=[s],null===(u=e.issues)||void 0===u||u.push(c)}}catch(e){l.e(e)}finally{l.f()}if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||n in r)&&(e.value[n]=o.value)}else E(this,"type",e,t);return e}}}function j(e){for(var t={kind:"schema",type:"optional",reference:j,expects:"(".concat(e.expects," | undefined)"),async:!1,wrapped:e,_run:function(e,t){return void 0===e.value&&("default"in this&&(e.value=function(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}},r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return 0 in n&&(t.default=n[0]),t}function D(e,t){return{kind:"schema",type:"picklist",reference:D,expects:S(e.map(k),"|"),async:!1,options:e,message:t,_run:function(e,t){return this.options.includes(e.value)?e.typed=!0:E(this,"type",e,t),e}}}function U(e,t,r){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:t,message:r,_run:function(e,t){var r=e.value;if(r&&"object"===w(r)){for(var n in e.typed=!0,e.value={},r)if(T(r,n)){var i=r[n],o=this.key._run({typed:!1,value:n},t);if(o.issues){var a,s={type:"object",origin:"key",input:r,key:n,value:i},l=v(o.issues);try{for(l.s();!(a=l.n()).done;){var u,c=a.value;c.path=[s],null===(u=e.issues)||void 0===u||u.push(c)}}catch(e){l.e(e)}finally{l.f()}if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}var d=this.value._run({typed:!1,value:i},t);if(d.issues){var p,f={type:"object",origin:"value",input:r,key:n,value:i},y=v(d.issues);try{for(y.s();!(p=y.n()).done;){var h,m=p.value;m.path?m.path.unshift(f):m.path=[f],null===(h=e.issues)||void 0===h||h.push(m)}}catch(e){y.e(e)}finally{y.f()}if(e.issues||(e.issues=d.issues),t.abortEarly){e.typed=!1;break}}o.typed&&d.typed||(e.typed=!1),o.typed&&(e.value[o.value]=d.value)}}else E(this,"type",e,t);return e}}}function _(e){return{kind:"schema",type:"string",reference:_,expects:"string",async:!1,message:e,_run:function(e,t){return"string"==typeof e.value?e.typed=!0:E(this,"type",e,t),e}}}function A(e){var t;if(e){var r,n=v(e);try{for(n.s();!(r=n.n()).done;){var i,o=r.value;if(t)(i=t).push.apply(i,b(o.issues));else t=o.issues}}catch(e){n.e(e)}finally{n.f()}}return t}function x(e,t){return{kind:"schema",type:"union",reference:x,expects:S(e.map((function(e){return e.expects})),"|"),async:!1,options:e,message:t,_run:function(e,t){var r,n,i,o,a,s=v(this.options);try{for(s.s();!(a=s.n()).done;){var l=a.value._run({typed:!1,value:e.value},t);if(l.typed){if(!l.issues){n=l;break}i?i.push(l):i=[l]}else o?o.push(l):o=[l]}}catch(e){s.e(e)}finally{s.f()}if(n)return n;if(i){if(1===i.length)return i[0];E(this,"type",e,t,{issues:A(i)}),e.typed=!0}else{if(1===(null===(r=o)||void 0===r?void 0:r.length))return o[0];E(this,"type",e,t,{issues:A(o)})}return e}}}function q(){return{kind:"schema",type:"unknown",reference:q,expects:"unknown",async:!1,_run:function(e){return e.typed=!0,e}}}function M(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return g(g({},t[0]),{},{pipe:t,_run:function(e,r){for(var n=0,i=t;n<i.length;n++){var o=i[n];if("metadata"!==o.kind){if(e.issues&&("schema"===o.kind||"transformation"===o.kind)){e.typed=!1;break}e.issues&&(r.abortEarly||r.abortPipeEarly)||(e=o._run(e,r))}}return e}})}function B(e,t,r){var n=e._run({typed:!1,value:t},function(e){var t,r,n;return{lang:null!==(t=null==e?void 0:e.lang)&&void 0!==t?t:void 0,message:null==e?void 0:e.message,abortEarly:null!==(r=null==e?void 0:e.abortEarly)&&void 0!==r?r:void 0,abortPipeEarly:null!==(n=null==e?void 0:e.abortPipeEarly)&&void 0!==n?n:void 0}}(r));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}p.fromPromise,p.fromSafePromise;const H=e=>t=>B(e,t).success,Q=(e,r)=>n=>{const i=((e,t)=>{const r=B(t,e);return r.success?l(r.output):u(r.issues.map((({message:e,path:t})=>({message:e,path:null==t?void 0:t.map((e=>e.key))}))))})(n,e);if(i.isErr())throw new t(r,{data:n,errors:i.error})};var N,V;!function(e){e.UnexpectedRespond="UnexpectedRespond"}(N||(N={})),function(e){e.HttpError="HttpError",e.UnknownError="UnknownError"}(V||(V={}));const $=async(e,t)=>{try{const r=await fetch(e,t);return r.status>299||r.status<200?u({type:V.HttpError,message:`HTTP error, status = ${r.status}`,status:r.status}):l(r)}catch(e){return u({type:V.UnknownError,message:"Unknown error",cause:e})}};var L,G,J;e.MobileCredentialVerificationReasonType=void 0,(L=e.MobileCredentialVerificationReasonType||(e.MobileCredentialVerificationReasonType={})).Expired="expired",L.Inactive="inactive",L.StatusRevoked="invalid",L.StatusSuspended="suspended",L.StatusUnknown="unknown",e.ClaimType=void 0,(G=e.ClaimType||(e.ClaimType={})).Boolean="boolean",G.Number="number",G.String="string",G.Binary="binary",G.Date="date",G.DateTime="dateTime",G.Array="array",G.Object="object",e.CredentialBrandingImageFormat=void 0,(J=e.CredentialBrandingImageFormat||(e.CredentialBrandingImageFormat={})).svg="svg",J.png="png",e.MobileCredentialResponseErrorCode=void 0,(e.MobileCredentialResponseErrorCode||(e.MobileCredentialResponseErrorCode={})).NotReturned="notReturned",e.OpenidPresentationCredentialProfileSupported=void 0,(e.OpenidPresentationCredentialProfileSupported||(e.OpenidPresentationCredentialProfileSupported={})).MOBILE="mobile";const z=R({profile:D([e.OpenidPresentationCredentialProfileSupported.MOBILE]),docType:_(),nameSpaces:U(_(),U(_(),function e(t,r){return{kind:"schema",type:"strict_object",reference:e,expects:"Object",async:!1,entries:t,message:r,_run:function(e,t){var r=e.value;if(r&&"object"===w(r)){for(var n in e.typed=!0,e.value={},this.entries){var i=r[n],o=this.entries[n]._run({typed:!1,value:i},t);if(o.issues){var a,s={type:"object",origin:"value",input:r,key:n,value:i},l=v(o.issues);try{for(l.s();!(a=l.n()).done;){var u,c=a.value;c.path?c.path.unshift(s):c.path=[s],null===(u=e.issues)||void 0===u||u.push(c)}}catch(e){l.e(e)}finally{l.f()}if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||n in r)&&(e.value[n]=o.value)}if(!e.issues||!t.abortEarly)for(var d in r)if(!(d in this.entries)){var p=r[d];E(this,"type",e,t,{input:p,expected:"never",path:[{type:"object",origin:"value",input:r,key:d,value:p}]});break}}else E(this,"type",e,t);return e}}}({intentToRetain:j(P())})))}),K=R({credentials:I(R({id:_(),format:_(),meta:j(q()),claims:I(R({path:I(_())}))})),credential_sets:j(I(R({options:I(I(_())),required:j(P()),purpose:j(q())})))});var W;!function(e){e.SessionAborted="SessionAborted",e.VerificationError="VerificationError",e.ResponseError="ResponseError",e.WalletUnavailable="WalletUnavailable",e.Unknown="Unknown"}(W||(W={}));const X=R({sessionId:_(),challenge:j(_()),credentialQuery:j(q()),credentials:j(q()),credentialErrors:j(q()),error:j(q())});R({credentialQuery:x([I(z),K]),challenge:_(),redirectUri:j(_()),walletProviderId:j(_())});const Y=R({sessionId:_(),sessionUrl:_()}),Z=R({sessionId:_(),request:R({})});var ee,te,re;!function(e){e.challenge="mattr_chg",e.sessionId="mattr_sid"}(ee||(ee={})),e.Mode=void 0,(te=e.Mode||(e.Mode={})).sameDevice="sameDevice",te.crossDevice="crossDevice",function(e){e.PresentationCompleted="PresentationCompleted",e.PresentationTimeout="PresentationTimeout",e.PresentationAbort="PresentationAbort"}(re||(re={}));const ne=R({credentialQuery:x([M(I(z),O()),K]),redirectUri:_(),challenge:j(_()),walletProviderId:j(_()),mode:D([e.Mode.sameDevice])}),ie=R({credentialQuery:x([M(I(z),O()),K]),crossDeviceCallback:R({onComplete:F(),onFailure:F()}),challenge:j(_()),walletProviderId:j(_()),mode:D([e.Mode.crossDevice])}),oe=R({credentialQuery:x([M(I(z),O()),K]),crossDeviceCallback:R({onComplete:F(),onFailure:F()}),redirectUri:_(),challenge:j(_()),walletProviderId:j(_()),mode:j(D([e.Mode.crossDevice,e.Mode.sameDevice]))}),ae=x([ne,ie,oe]);e.RequestCredentialsErrorType=void 0,(e.RequestCredentialsErrorType||(e.RequestCredentialsErrorType={})).RequestCredentialsFailed="RequestCredentialsFailed";const se=R({apiBaseUrl:_(),applicationId:j(_()),enableDigitalCredentialsApiSameDeviceFlow:j(P()),enableDigitalCredentialsApiCrossDeviceFlow:j(P())});let le;var ue;!function(e){e.SdkNotInitialised="SDK not initialised"}(ue||(ue={}));const ce=()=>le;var de=me,pe=me,fe=me,ye=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,ve=/CrOS/,he=/android|ipad|playbook|silk/i;function me(e){e||(e={});var t=e.ua;if(t||"undefined"==typeof navigator||(t=navigator.userAgent),t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]),"string"!=typeof t)return!1;var r=ye.test(t)&&!ve.test(t)||!!e.tablet&&he.test(t);return!r&&e.tablet&&e.featureDetect&&navigator&&navigator.maxTouchPoints>1&&-1!==t.indexOf("Macintosh")&&-1!==t.indexOf("Safari")&&(r=!0),r}de.isMobile=pe,de.default=fe;const ge=e=>1e3*Math.pow(2,e),be=2,we=async(e,t)=>{const{retries:r=be,retryDelay:n=ge,attempt:i=0,retryHttpStatus:o}=t,a=await e();if(a.isErr()&&a.error.status===o&&r>0){const o="function"==typeof n?n(i):n;return await new Promise((e=>setTimeout(e,o))),await we(e,Object.assign(Object.assign({},t),{retries:r-1,retryDelay:n,attempt:i+1}))}return a},Ce=()=>{const e=window.crypto.getRandomValues(new Uint8Array(32)),t=String.fromCharCode(...Array.from(e));return window.btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},ke=async({credentialQuery:e,challenge:t,redirectUri:r,apiBaseUrl:n,applicationId:i,walletProviderId:o})=>{const a=Object.assign(Object.assign(Object.assign({credentialQuery:e,challenge:t},r?{redirectUri:r}:{}),i?{applicationId:i}:{}),o?{walletProviderId:o}:{}),s=await $(`${n}/v2/presentations/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(s.isErr())return u(s.error);const c=await s.value.json();return H(Y)(c)?l(c):u({type:N.UnexpectedRespond,message:"Create session return unsupported response"})},Ee=async({challenge:e,responseCode:t,sessionId:r,apiBaseUrl:n})=>{const i={challenge:e,responseCode:t},o=await we((async()=>await $(`${n}/v2/presentations/sessions/${r}/result`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})),{retries:2,retryHttpStatus:404});if(o.isErr())return u(o.error);const a=await o.value.json();return H(X)(a)?l(a):u({type:N.UnexpectedRespond,message:"Exchange session result return unsupported response",details:{data:a}})},Te=()=>{var e;try{return"function"==typeof(null===(e=null===navigator||void 0===navigator?void 0:navigator.identity)||void 0===e?void 0:e.get)}catch(e){return!1}};var Se,Oe,Ie;let Pe;e.CrossDeviceCallbackErrorType=void 0,(Se=e.CrossDeviceCallbackErrorType||(e.CrossDeviceCallbackErrorType={})).Timeout="Timeout",Se.Abort="Abort",Se.RequestCredentialsFailed="RequestCredentialsFailed",function(e){e.FailedToGetSessionResult="Failed to get session result",e.FailedToCreateSession="Failed to create session",e.Abort="User aborted the session",e.Timeout="User session timeout"}(Oe||(Oe={})),function(e){e.message="message"}(Ie||(Ie={}));const Fe=e=>{const{container:t}=e;document.body.contains(t)&&document.body.removeChild(t),window.removeEventListener(Ie.message,Pe,!1)},Re=async t=>{const{challenge:r,walletProviderId:n,credentialQuery:i,crossDeviceCallback:o,initialiseOptions:a}=t,{apiBaseUrl:s,applicationId:c}=a,d=await ke({credentialQuery:i,challenge:r,apiBaseUrl:s,applicationId:c,walletProviderId:n});if(d.isErr())return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:Oe.FailedToCreateSession,cause:d.error});const{sessionUrl:p,sessionId:f}=d.value,y=(e=>{const{sessionUrl:t}=e,r=document.createElement("div"),n=document.createElement("iframe");n.src=t,n.setAttribute("style","border: none !important; width: 100% !important; height: 100% !important; position: absolute !important; top: 0 !important; left: 0 !important; animation: openOnlinePresentationModal 0.4s 0s linear forwards;");const i=document.createElement("style");return i.innerHTML="@keyframes openOnlinePresentationModal {\n 0% {\n opacity: 0;\n transform: scale(0.95)\n }\n 100% {\n opacity: 100%;\n transform: scale(1)\n }\n }",r.appendChild(i),r.appendChild(n),document.body.appendChild(r),r.setAttribute("style","background: rgba(0, 0, 0, 0.5) !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; z-index: 999;"),r.setAttribute("class","mattr-verifier-modal-container"),r})({sessionUrl:p,crossDeviceCallback:o});return Pe=(t=>async r=>{const{crossDeviceCallback:n,container:i,sessionId:o,apiBaseUrl:a,challenge:s}=t,{onComplete:l,onFailure:u}=n;if(r.origin===a){if(r.data.type===re.PresentationCompleted&&r.data.responseCode&&r.data.sessionId){const t=r.data.responseCode,n=await Ee({challenge:s,responseCode:t,sessionId:o,apiBaseUrl:a});return n.isErr()?(u({type:e.CrossDeviceCallbackErrorType.RequestCredentialsFailed,message:Oe.FailedToGetSessionResult}),void Fe({container:i})):(l({result:n.value,sessionId:n.value.sessionId}),void Fe({container:i}))}return r.data.type===re.PresentationTimeout?(u({type:e.CrossDeviceCallbackErrorType.Timeout,message:Oe.Timeout}),void Fe({container:i})):r.data.type===re.PresentationAbort?(u({type:e.CrossDeviceCallbackErrorType.Abort,message:Oe.Abort}),void Fe({container:i})):void 0}})({crossDeviceCallback:o,container:y,sessionId:f,apiBaseUrl:s,challenge:r}),window.addEventListener(Ie.message,Pe,!1),l({sessionId:f})};var je;!function(e){e.FailedToStoreChallenge="Failed to store challenge",e.FailedToCreateSession="Failed to create session"}(je||(je={}));var De;!function(e){e.FailedToStoreChallenge="Failed to store challenge",e.FailedToCreateSession="Failed to create session"}(De||(De={}));const Ue=async t=>{const{challenge:r,credentialQuery:n,initialiseOptions:i}=t,{apiBaseUrl:o,digitalCredentialsApiProtocol:a}=i;window.localStorage.setItem(ee.challenge,r);const s=window.localStorage.getItem(ee.challenge);if(!s)return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:De.FailedToStoreChallenge});const c=await(async({credentialQuery:e,challenge:t,apiBaseUrl:r,protocol:n})=>{const i=Object.assign({credentialQuery:e,challenge:t},n&&{protocol:n}),o=await $(`${r}/v2/presentations/sessions/web/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(o.isErr())return u(o.error);const a=await o.value.json();return H(Z)(a)?l(a):u({type:N.UnexpectedRespond,message:"Create digital credentials api session return unsupported response"})})({credentialQuery:n,challenge:s,apiBaseUrl:o,protocol:a});if(c.isErr())return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:De.FailedToCreateSession,cause:c.error});const{request:d,sessionId:p}=c.value;let f,y;window.localStorage.setItem(ee.sessionId,p);try{f=await navigator.identity.get(d)}catch(t){return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:"Failed call to digital credentials api"})}try{y=JSON.parse(f.data)}catch(e){y=f.data}const v=await(async({challenge:e,sessionId:t,response:r,apiBaseUrl:n,protocol:i})=>{const o={challenge:e,sessionId:t,response:r,protocol:i},a=await we((async()=>await $(`${n}/v2/presentations/sessions/web/response`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})),{retries:2,retryHttpStatus:404});if(a.isErr())return u(a.error);const s=await a.value.json();return l(s)})({challenge:r,sessionId:p,response:y,apiBaseUrl:o,protocol:null!=a?a:"preview"});return v.isOk()?l({sessionId:p,result:v.value}):u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:"Invalid response from digital credentials api"})};var _e;e.HandleRedirectCallbackErrorType=void 0,(e.HandleRedirectCallbackErrorType||(e.HandleRedirectCallbackErrorType={})).HandleRedirectCallbackFailed="HandleRedirectCallbackFailed",function(e){e.FailedToFindResponseCode="Failed to find response code",e.FailedToFindChallenge="Failed to find challenge",e.FailedToFindSessionId="Failed to find sessionId",e.FailedToGetSessionResult="Failed to get session result"}(_e||(_e={}));const Ae={generateChallenge:Ce,unwrap:(e,r)=>{if(e.isOk())return e.value;throw new t(null!=r?r:"Error unwrapping result",e.error)},isDigitalCredentialsApiSupported:Te};e.handleRedirectCallback=async()=>{const r=ce();if(!r)throw new t(ue.SdkNotInitialised);const{apiBaseUrl:n}=r,i=(o=window.location.hash,a="response_code",new URLSearchParams(o.split("#")[1]).get(a));var o,a;if(!i)return u({type:e.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,message:_e.FailedToFindResponseCode});const s=window.localStorage.getItem(ee.challenge);if(!s)return u({type:e.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,message:_e.FailedToFindChallenge});const c=window.localStorage.getItem(ee.sessionId);if(!c)return u({type:e.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,message:_e.FailedToFindSessionId});const d=await Ee({challenge:s,responseCode:i,sessionId:c,apiBaseUrl:n});return d.isErr()?u({type:e.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,message:_e.FailedToGetSessionResult,cause:d.error}):l({result:d.value,sessionId:d.value.sessionId})},e.initialise=e=>{Q(se,"Invalid initialise options")(e),le=e},e.requestCredentials=async r=>{var n;const i=ce();if(!i)throw new t(ue.SdkNotInitialised);Q(ae,"Invalid request credential options")(r);const{challenge:o=Ce()}=r,a=null!==(n=r.mode)&&void 0!==n?n:(s=navigator.userAgent,pe({ua:s,tablet:!1})?e.Mode.sameDevice:e.Mode.crossDevice);var s;if(i.enableDigitalCredentialsApiCrossDeviceFlow&&Te()&&a===e.Mode.crossDevice)return console.log("Digital Credentials API support found, proceeding with request using API in cross device flow"),await Ue(Object.assign(Object.assign({},r),{initialiseOptions:i,challenge:o}));if(i.enableDigitalCredentialsApiCrossDeviceFlow&&console.log("Digital Credentials API support not found, falling back to OpenID4VP"),i.enableDigitalCredentialsApiSameDeviceFlow&&Te()&&a===e.Mode.sameDevice)return console.log("Digital Credentials API support found, proceeding with request using API in same device flow"),await Ue(Object.assign(Object.assign({},r),{initialiseOptions:i,challenge:o}));if(i.enableDigitalCredentialsApiSameDeviceFlow&&console.log("Digital Credentials API support not found, falling back to OpenID4VP"),a===e.Mode.sameDevice&&"redirectUri"in r)return await(async t=>{const{challenge:r,credentialQuery:n,redirectUri:i,walletProviderId:o,initialiseOptions:a}=t,{apiBaseUrl:s,applicationId:c}=a;window.localStorage.setItem(ee.challenge,r);const d=window.localStorage.getItem(ee.challenge);if(!d)return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:je.FailedToStoreChallenge});const p=await ke({credentialQuery:n,challenge:d,redirectUri:i,apiBaseUrl:s,applicationId:c,walletProviderId:o});if(p.isErr())return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:je.FailedToCreateSession,cause:p.error});const{sessionUrl:f,sessionId:y}=p.value;return window.localStorage.setItem(ee.sessionId,y),window.location.assign(f),l({sessionId:y})})(Object.assign(Object.assign({},r),{initialiseOptions:i,challenge:o,mode:a}));if(a===e.Mode.crossDevice&&"crossDeviceCallback"in r)return await Re(Object.assign(Object.assign({},r),{initialiseOptions:i,challenge:o,mode:a}));throw new t("Invalid request credential options",{data:r})},e.utils=Ae,Object.defineProperty(e,"__esModule",{value:!0})}));
36
+ function r(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))}function n(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function i(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}var o,a={withStackTrace:!1},s=function(e,t,r){return void 0===r&&(r=a),{data:t.isOk()?{type:"Ok",value:t.value}:{type:"Err",value:t.error},message:e,stack:r.withStackTrace?(new Error).stack:void 0}};!function(e){e.fromThrowable=function(e,t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{var o=e.apply(void 0,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(i(arguments[t]));return e}(r));return l(o)}catch(e){return u(t?t(e):e)}}}}(o||(o={}));var l=function(e){return new c(e)},u=function(e){return new d(e)},c=function(){function e(e){this.value=e}return e.prototype.isOk=function(){return!0},e.prototype.isErr=function(){return!this.isOk()},e.prototype.map=function(e){return l(e(this.value))},e.prototype.mapErr=function(e){return l(this.value)},e.prototype.andThen=function(e){return e(this.value)},e.prototype.orElse=function(e){return l(this.value)},e.prototype.asyncAndThen=function(e){return e(this.value)},e.prototype.asyncMap=function(e){return p.fromSafePromise(e(this.value))},e.prototype.unwrapOr=function(e){return this.value},e.prototype.match=function(e,t){return e(this.value)},e.prototype._unsafeUnwrap=function(e){return this.value},e.prototype._unsafeUnwrapErr=function(e){throw s("Called `_unsafeUnwrapErr` on an Ok",this,e)},e}(),d=function(){function e(e){this.error=e}return e.prototype.isOk=function(){return!1},e.prototype.isErr=function(){return!this.isOk()},e.prototype.map=function(e){return u(this.error)},e.prototype.mapErr=function(e){return u(e(this.error))},e.prototype.andThen=function(e){return u(this.error)},e.prototype.orElse=function(e){return e(this.error)},e.prototype.asyncAndThen=function(e){return f(this.error)},e.prototype.asyncMap=function(e){return f(this.error)},e.prototype.unwrapOr=function(e){return e},e.prototype.match=function(e,t){return t(this.error)},e.prototype._unsafeUnwrap=function(e){throw s("Called `_unsafeUnwrap` on an Err",this,e)},e.prototype._unsafeUnwrapErr=function(e){return this.error},e}();o.fromThrowable;var p=function(){function e(e){this._promise=e}return e.fromSafePromise=function(t){return new e(t.then((function(e){return new c(e)})))},e.fromPromise=function(t,r){return new e(t.then((function(e){return new c(e)})).catch((function(e){return new d(r(e))})))},e.prototype.map=function(t){var i=this;return new e(this._promise.then((function(e){return r(i,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return e.isErr()?[2,new d(e.error)]:(r=c.bind,[4,t(e.value)]);case 1:return[2,new(r.apply(c,[void 0,n.sent()]))]}}))}))})))},e.prototype.mapErr=function(t){var i=this;return new e(this._promise.then((function(e){return r(i,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return e.isOk()?[2,new c(e.value)]:(r=d.bind,[4,t(e.error)]);case 1:return[2,new(r.apply(d,[void 0,n.sent()]))]}}))}))})))},e.prototype.andThen=function(t){return new e(this._promise.then((function(r){if(r.isErr())return new d(r.error);var n=t(r.value);return n instanceof e?n._promise:n})))},e.prototype.orElse=function(t){var i=this;return new e(this._promise.then((function(e){return r(i,void 0,void 0,(function(){return n(this,(function(r){return e.isErr()?[2,t(e.error)]:[2,new c(e.value)]}))}))})))},e.prototype.match=function(e,t){return this._promise.then((function(r){return r.match(e,t)}))},e.prototype.unwrapOr=function(e){return this._promise.then((function(t){return t.unwrapOr(e)}))},e.prototype.then=function(e,t){return this._promise.then(e,t)},e}(),f=function(e){return new p(Promise.resolve(new d(e)))};function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=C(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function h(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||C(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(e)}function C(e,t){if(e){if("string"==typeof e)return y(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(e,t):void 0}}function k(e){var t,r,n=w(e);return"string"===n?'"'.concat(e,'"'):"number"===n||"bigint"===n||"boolean"===n?"".concat(e):"object"===n||"function"===n?null!==(t=e&&(null===(r=Object.getPrototypeOf(e))||void 0===r||null===(r=r.constructor)||void 0===r?void 0:r.name))&&void 0!==t?t:"null":n}function E(e,t,r,n,i){var o,a,s,l,u,c,d,p,f,y,v,h=i&&"input"in i?i.input:r.value,m=null!==(o=null!==(a=null==i?void 0:i.expected)&&void 0!==a?a:e.expects)&&void 0!==o?o:null,g=null!==(s=null==i?void 0:i.received)&&void 0!==s?s:k(h),b={kind:e.kind,type:e.type,input:h,expected:m,received:g,message:"Invalid ".concat(t,": ").concat(m?"Expected ".concat(m," but r"):"R","eceived ").concat(g),requirement:e.requirement,path:null==i?void 0:i.path,issues:null==i?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},w="schema"===e.kind,C=null!==(l=null!==(u=null!==(c=null!==(d=null!==(p=null==i?void 0:i.message)&&void 0!==p?p:e.message)&&void 0!==d?d:(f=e.reference,y=b.lang,null===(v=void 0)||void 0===v||null===(v=v.get(f))||void 0===v?void 0:v.get(y)))&&void 0!==c?c:w?function(e){var t;return null===(t=void 0)||void 0===t?void 0:t.get(e)}(b.lang):null)&&void 0!==u?u:n.message)&&void 0!==l?l:function(e){var t;return null===(t=void 0)||void 0===t?void 0:t.get(e)}(b.lang);C&&(b.message="function"==typeof C?C(b):C),w&&(r.typed=!1),r.issues?r.issues.push(b):r.issues=[b]}function T(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function O(e,t){var r,n=b(new Set(e));return n.length>1?"(".concat(n.join(" ".concat(t," ")),")"):null!==(r=n[0])&&void 0!==r?r:"never"}function S(e){return{kind:"validation",type:"non_empty",reference:S,async:!1,expects:"!0",message:e,_run:function(e,t){return e.typed&&0===e.value.length&&E(this,"length",e,t,{received:"0"}),e}}}function I(e,t){return{kind:"schema",type:"array",reference:I,expects:"Array",async:!1,item:e,message:t,_run:function(e,t){var r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(var n=0;n<r.length;n++){var i=r[n],o=this.item._run({typed:!1,value:i},t);if(o.issues){var a,s={type:"array",origin:"value",input:r,key:n,value:i},l=v(o.issues);try{for(l.s();!(a=l.n()).done;){var u,c=a.value;c.path?c.path.unshift(s):c.path=[s],null===(u=e.issues)||void 0===u||u.push(c)}}catch(e){l.e(e)}finally{l.f()}if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value.push(o.value)}}else E(this,"type",e,t);return e}}}function P(e){return{kind:"schema",type:"boolean",reference:P,expects:"boolean",async:!1,message:e,_run:function(e,t){return"boolean"==typeof e.value?e.typed=!0:E(this,"type",e,t),e}}}function F(e){return{kind:"schema",type:"function",reference:F,expects:"Function",async:!1,message:e,_run:function(e,t){return"function"==typeof e.value?e.typed=!0:E(this,"type",e,t),e}}}function R(e,t){return{kind:"schema",type:"object",reference:R,expects:"Object",async:!1,entries:e,message:t,_run:function(e,t){var r=e.value;if(r&&"object"===w(r))for(var n in e.typed=!0,e.value={},this.entries){var i=r[n],o=this.entries[n]._run({typed:!1,value:i},t);if(o.issues){var a,s={type:"object",origin:"value",input:r,key:n,value:i},l=v(o.issues);try{for(l.s();!(a=l.n()).done;){var u,c=a.value;c.path?c.path.unshift(s):c.path=[s],null===(u=e.issues)||void 0===u||u.push(c)}}catch(e){l.e(e)}finally{l.f()}if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||n in r)&&(e.value[n]=o.value)}else E(this,"type",e,t);return e}}}function j(e){for(var t={kind:"schema",type:"optional",reference:j,expects:"(".concat(e.expects," | undefined)"),async:!1,wrapped:e,_run:function(e,t){return void 0===e.value&&("default"in this&&(e.value=function(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}},r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return 0 in n&&(t.default=n[0]),t}function D(e,t){return{kind:"schema",type:"picklist",reference:D,expects:O(e.map(k),"|"),async:!1,options:e,message:t,_run:function(e,t){return this.options.includes(e.value)?e.typed=!0:E(this,"type",e,t),e}}}function U(e,t,r){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:t,message:r,_run:function(e,t){var r=e.value;if(r&&"object"===w(r)){for(var n in e.typed=!0,e.value={},r)if(T(r,n)){var i=r[n],o=this.key._run({typed:!1,value:n},t);if(o.issues){var a,s={type:"object",origin:"key",input:r,key:n,value:i},l=v(o.issues);try{for(l.s();!(a=l.n()).done;){var u,c=a.value;c.path=[s],null===(u=e.issues)||void 0===u||u.push(c)}}catch(e){l.e(e)}finally{l.f()}if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}var d=this.value._run({typed:!1,value:i},t);if(d.issues){var p,f={type:"object",origin:"value",input:r,key:n,value:i},y=v(d.issues);try{for(y.s();!(p=y.n()).done;){var h,m=p.value;m.path?m.path.unshift(f):m.path=[f],null===(h=e.issues)||void 0===h||h.push(m)}}catch(e){y.e(e)}finally{y.f()}if(e.issues||(e.issues=d.issues),t.abortEarly){e.typed=!1;break}}o.typed&&d.typed||(e.typed=!1),o.typed&&(e.value[o.value]=d.value)}}else E(this,"type",e,t);return e}}}function A(e){return{kind:"schema",type:"string",reference:A,expects:"string",async:!1,message:e,_run:function(e,t){return"string"==typeof e.value?e.typed=!0:E(this,"type",e,t),e}}}function _(e){var t;if(e){var r,n=v(e);try{for(n.s();!(r=n.n()).done;){var i,o=r.value;if(t)(i=t).push.apply(i,b(o.issues));else t=o.issues}}catch(e){n.e(e)}finally{n.f()}}return t}function x(e,t){return{kind:"schema",type:"union",reference:x,expects:O(e.map((function(e){return e.expects})),"|"),async:!1,options:e,message:t,_run:function(e,t){var r,n,i,o,a,s=v(this.options);try{for(s.s();!(a=s.n()).done;){var l=a.value._run({typed:!1,value:e.value},t);if(l.typed){if(!l.issues){n=l;break}i?i.push(l):i=[l]}else o?o.push(l):o=[l]}}catch(e){s.e(e)}finally{s.f()}if(n)return n;if(i){if(1===i.length)return i[0];E(this,"type",e,t,{issues:_(i)}),e.typed=!0}else{if(1===(null===(r=o)||void 0===r?void 0:r.length))return o[0];E(this,"type",e,t,{issues:_(o)})}return e}}}function q(){return{kind:"schema",type:"unknown",reference:q,expects:"unknown",async:!1,_run:function(e){return e.typed=!0,e}}}function M(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return g(g({},t[0]),{},{pipe:t,_run:function(e,r){for(var n=0,i=t;n<i.length;n++){var o=i[n];if("metadata"!==o.kind){if(e.issues&&("schema"===o.kind||"transformation"===o.kind)){e.typed=!1;break}e.issues&&(r.abortEarly||r.abortPipeEarly)||(e=o._run(e,r))}}return e}})}function B(e,t,r){var n=e._run({typed:!1,value:t},function(e){var t,r,n;return{lang:null!==(t=null==e?void 0:e.lang)&&void 0!==t?t:void 0,message:null==e?void 0:e.message,abortEarly:null!==(r=null==e?void 0:e.abortEarly)&&void 0!==r?r:void 0,abortPipeEarly:null!==(n=null==e?void 0:e.abortPipeEarly)&&void 0!==n?n:void 0}}(r));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}p.fromPromise,p.fromSafePromise;const H=e=>t=>B(e,t).success,Q=(e,r)=>n=>{const i=((e,t)=>{const r=B(t,e);return r.success?l(r.output):u(r.issues.map((({message:e,path:t})=>({message:e,path:null==t?void 0:t.map((e=>e.key))}))))})(n,e);if(i.isErr())throw new t(r,{data:n,errors:i.error})};var N,V;!function(e){e.UnexpectedRespond="UnexpectedRespond"}(N||(N={})),function(e){e.HttpError="HttpError",e.UnknownError="UnknownError"}(V||(V={}));const $=async(e,t)=>{try{const r=await fetch(e,t);return r.status>299||r.status<200?u({type:V.HttpError,message:`HTTP error, status = ${r.status}`,status:r.status}):l(r)}catch(e){return u({type:V.UnknownError,message:"Unknown error",cause:e})}};var J,L,G;e.MobileCredentialVerificationReasonType=void 0,(J=e.MobileCredentialVerificationReasonType||(e.MobileCredentialVerificationReasonType={})).Expired="expired",J.Inactive="inactive",J.StatusRevoked="invalid",J.StatusSuspended="suspended",J.StatusUnknown="unknown",e.ClaimType=void 0,(L=e.ClaimType||(e.ClaimType={})).Boolean="boolean",L.Number="number",L.String="string",L.Binary="binary",L.Date="date",L.DateTime="dateTime",L.Array="array",L.Object="object",e.CredentialBrandingImageFormat=void 0,(G=e.CredentialBrandingImageFormat||(e.CredentialBrandingImageFormat={})).svg="svg",G.png="png",e.MobileCredentialResponseErrorCode=void 0,(e.MobileCredentialResponseErrorCode||(e.MobileCredentialResponseErrorCode={})).NotReturned="notReturned",e.OpenidPresentationCredentialProfileSupported=void 0,(e.OpenidPresentationCredentialProfileSupported||(e.OpenidPresentationCredentialProfileSupported={})).MOBILE="mobile";const z=R({profile:D([e.OpenidPresentationCredentialProfileSupported.MOBILE]),docType:A(),nameSpaces:U(A(),U(A(),function e(t,r){return{kind:"schema",type:"strict_object",reference:e,expects:"Object",async:!1,entries:t,message:r,_run:function(e,t){var r=e.value;if(r&&"object"===w(r)){for(var n in e.typed=!0,e.value={},this.entries){var i=r[n],o=this.entries[n]._run({typed:!1,value:i},t);if(o.issues){var a,s={type:"object",origin:"value",input:r,key:n,value:i},l=v(o.issues);try{for(l.s();!(a=l.n()).done;){var u,c=a.value;c.path?c.path.unshift(s):c.path=[s],null===(u=e.issues)||void 0===u||u.push(c)}}catch(e){l.e(e)}finally{l.f()}if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||n in r)&&(e.value[n]=o.value)}if(!e.issues||!t.abortEarly)for(var d in r)if(!(d in this.entries)){var p=r[d];E(this,"type",e,t,{input:p,expected:"never",path:[{type:"object",origin:"value",input:r,key:d,value:p}]});break}}else E(this,"type",e,t);return e}}}({intentToRetain:j(P())})))}),K=R({credentials:I(R({id:A(),format:A(),meta:j(q()),claims:I(R({path:I(A())}))})),credential_sets:j(I(R({options:I(I(A())),required:j(P()),purpose:j(q())})))});var W;!function(e){e.SessionAborted="SessionAborted",e.VerificationError="VerificationError",e.ResponseError="ResponseError",e.WalletUnavailable="WalletUnavailable",e.Unknown="Unknown"}(W||(W={}));const X=R({sessionId:A(),challenge:j(A()),credentialQuery:j(q()),credentials:j(q()),credentialErrors:j(q()),error:j(q())});R({credentialQuery:x([I(z),K]),challenge:A(),redirectUri:j(A()),walletProviderId:j(A())});const Y=R({sessionId:A(),sessionUrl:A()}),Z=R({sessionId:A(),request:R({})});var ee,te,re;!function(e){e.challenge="mattr_chg",e.sessionId="mattr_sid"}(ee||(ee={})),e.Mode=void 0,(te=e.Mode||(e.Mode={})).sameDevice="sameDevice",te.crossDevice="crossDevice",function(e){e.PresentationCompleted="PresentationCompleted",e.PresentationTimeout="PresentationTimeout",e.PresentationAbort="PresentationAbort"}(re||(re={}));const ne=R({credentialQuery:x([M(I(z),S()),K]),redirectUri:A(),challenge:j(A()),walletProviderId:j(A()),mode:D([e.Mode.sameDevice])}),ie=R({credentialQuery:x([M(I(z),S()),K]),crossDeviceCallback:R({onComplete:F(),onFailure:F()}),challenge:j(A()),walletProviderId:j(A()),mode:D([e.Mode.crossDevice])}),oe=R({credentialQuery:x([M(I(z),S()),K]),crossDeviceCallback:R({onComplete:F(),onFailure:F()}),redirectUri:A(),challenge:j(A()),walletProviderId:j(A()),mode:j(D([e.Mode.crossDevice,e.Mode.sameDevice]))}),ae=x([ne,ie,oe]);e.RequestCredentialsErrorType=void 0,(e.RequestCredentialsErrorType||(e.RequestCredentialsErrorType={})).RequestCredentialsFailed="RequestCredentialsFailed";const se=R({apiBaseUrl:A(),applicationId:j(A()),enableDigitalCredentialsApiSameDeviceFlow:j(P()),enableDigitalCredentialsApiCrossDeviceFlow:j(P())});let le;var ue;!function(e){e.SdkNotInitialised="SDK not initialised"}(ue||(ue={}));const ce=()=>le;var de=me,pe=me,fe=me,ye=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,ve=/CrOS/,he=/android|ipad|playbook|silk/i;function me(e){e||(e={});var t=e.ua;if(t||"undefined"==typeof navigator||(t=navigator.userAgent),t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]),"string"!=typeof t)return!1;var r=ye.test(t)&&!ve.test(t)||!!e.tablet&&he.test(t);return!r&&e.tablet&&e.featureDetect&&navigator&&navigator.maxTouchPoints>1&&-1!==t.indexOf("Macintosh")&&-1!==t.indexOf("Safari")&&(r=!0),r}de.isMobile=pe,de.default=fe;const ge=e=>1e3*Math.pow(2,e),be=2,we=async(e,t)=>{const{retries:r=be,retryDelay:n=ge,attempt:i=0,retryHttpStatus:o}=t,a=await e();if(a.isErr()&&a.error.status===o&&r>0){const o="function"==typeof n?n(i):n;return await new Promise((e=>setTimeout(e,o))),await we(e,Object.assign(Object.assign({},t),{retries:r-1,retryDelay:n,attempt:i+1}))}return a},Ce=()=>{const e=window.crypto.getRandomValues(new Uint8Array(32)),t=String.fromCharCode(...Array.from(e));return window.btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},ke=async({credentialQuery:e,challenge:t,redirectUri:r,apiBaseUrl:n,applicationId:i,walletProviderId:o})=>{const a=Object.assign(Object.assign(Object.assign({credentialQuery:e,challenge:t},r?{redirectUri:r}:{}),i?{applicationId:i}:{}),o?{walletProviderId:o}:{}),s=await $(`${n}/v2/presentations/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(s.isErr())return u(s.error);const c=await s.value.json();return H(Y)(c)?l(c):u({type:N.UnexpectedRespond,message:"Create session return unsupported response"})},Ee=async({challenge:e,responseCode:t,sessionId:r,apiBaseUrl:n})=>{const i={challenge:e,responseCode:t},o=await we((async()=>await $(`${n}/v2/presentations/sessions/${r}/result`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})),{retries:2,retryHttpStatus:404});if(o.isErr())return u(o.error);const a=await o.value.json();return H(X)(a)?l(a):u({type:N.UnexpectedRespond,message:"Exchange session result return unsupported response",details:{data:a}})};var Te,Oe,Se;let Ie;e.CrossDeviceCallbackErrorType=void 0,(Te=e.CrossDeviceCallbackErrorType||(e.CrossDeviceCallbackErrorType={})).Timeout="Timeout",Te.Abort="Abort",Te.RequestCredentialsFailed="RequestCredentialsFailed",function(e){e.FailedToGetSessionResult="Failed to get session result",e.FailedToCreateSession="Failed to create session",e.Abort="User aborted the session",e.Timeout="User session timeout"}(Oe||(Oe={})),function(e){e.message="message"}(Se||(Se={}));const Pe=e=>{const{container:t}=e;document.body.contains(t)&&document.body.removeChild(t),window.removeEventListener(Se.message,Ie,!1)},Fe=async t=>{const{challenge:r,walletProviderId:n,credentialQuery:i,crossDeviceCallback:o,initialiseOptions:a}=t,{apiBaseUrl:s,applicationId:c}=a,d=await ke({credentialQuery:i,challenge:r,apiBaseUrl:s,applicationId:c,walletProviderId:n});if(d.isErr())return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:Oe.FailedToCreateSession,cause:d.error});const{sessionUrl:p,sessionId:f}=d.value,y=(e=>{const{sessionUrl:t}=e,r=document.createElement("div"),n=document.createElement("iframe");n.src=t,n.setAttribute("style","border: none !important; width: 100% !important; height: 100% !important; position: absolute !important; top: 0 !important; left: 0 !important; animation: openOnlinePresentationModal 0.4s 0s linear forwards;");const i=document.createElement("style");return i.innerHTML="@keyframes openOnlinePresentationModal {\n 0% {\n opacity: 0;\n transform: scale(0.95)\n }\n 100% {\n opacity: 100%;\n transform: scale(1)\n }\n }",r.appendChild(i),r.appendChild(n),document.body.appendChild(r),r.setAttribute("style","background: rgba(0, 0, 0, 0.5) !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; z-index: 999;"),r.setAttribute("class","mattr-verifier-modal-container"),r})({sessionUrl:p,crossDeviceCallback:o});return Ie=(t=>async r=>{const{crossDeviceCallback:n,container:i,sessionId:o,apiBaseUrl:a,challenge:s}=t,{onComplete:l,onFailure:u}=n;if(r.origin===a){if(r.data.type===re.PresentationCompleted&&r.data.responseCode&&r.data.sessionId){const t=r.data.responseCode,n=await Ee({challenge:s,responseCode:t,sessionId:o,apiBaseUrl:a});return n.isErr()?(u({type:e.CrossDeviceCallbackErrorType.RequestCredentialsFailed,message:Oe.FailedToGetSessionResult}),void Pe({container:i})):(l({result:n.value,sessionId:n.value.sessionId}),void Pe({container:i}))}return r.data.type===re.PresentationTimeout?(u({type:e.CrossDeviceCallbackErrorType.Timeout,message:Oe.Timeout}),void Pe({container:i})):r.data.type===re.PresentationAbort?(u({type:e.CrossDeviceCallbackErrorType.Abort,message:Oe.Abort}),void Pe({container:i})):void 0}})({crossDeviceCallback:o,container:y,sessionId:f,apiBaseUrl:s,challenge:r}),window.addEventListener(Se.message,Ie,!1),l({sessionId:f})};var Re;!function(e){e.FailedToStoreChallenge="Failed to store challenge",e.FailedToCreateSession="Failed to create session"}(Re||(Re={}));var je;!function(e){e.FailedToStoreChallenge="Failed to store challenge",e.FailedToCreateSession="Failed to create session"}(je||(je={}));const De=async t=>{const{challenge:r,credentialQuery:n,initialiseOptions:i}=t,{apiBaseUrl:o,digitalCredentialsApiProtocol:a}=i;window.localStorage.setItem(ee.challenge,r);const s=window.localStorage.getItem(ee.challenge);if(!s)return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:je.FailedToStoreChallenge});const c=await(async({credentialQuery:e,challenge:t,apiBaseUrl:r,protocol:n})=>{const i=Object.assign({credentialQuery:e,challenge:t},n&&{protocol:n}),o=await $(`${r}/v2/presentations/sessions/web/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(o.isErr())return u(o.error);const a=await o.value.json();return H(Z)(a)?l(a):u({type:N.UnexpectedRespond,message:"Create digital credentials api session return unsupported response"})})({credentialQuery:n,challenge:s,apiBaseUrl:o,protocol:a});if(c.isErr())return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:je.FailedToCreateSession,cause:c.error});const{request:d,sessionId:p}=c.value;let f;window.localStorage.setItem(ee.sessionId,p);try{if("providers"in d.digital){let e;const t=d.digital.providers[0];if("preview"===t.protocol){console.log(`DC API Preview Request: ${JSON.stringify(d)}`);f=(await navigator.identity.get(d)).data}else{e={protocol:t.protocol,data:JSON.parse(t.request)};const r=Object.assign(Object.assign({},"org-iso-mdoc"===e.protocol&&{mediation:"required"}),{digital:{requests:[e]}});console.log(`DC API Request: ${JSON.stringify(r)}`);f=(await navigator.credentials.get(r)).data}}else{f=(await navigator.credentials.get(d)).data}}catch(t){return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:"Failed call to digital credentials api"})}const y=await(async({challenge:e,sessionId:t,response:r,apiBaseUrl:n,protocol:i})=>{const o={challenge:e,sessionId:t,response:r,protocol:i},a=await we((async()=>await $(`${n}/v2/presentations/sessions/web/response`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})),{retries:2,retryHttpStatus:404});if(a.isErr())return u(a.error);const s=await a.value.json();return l(s)})({challenge:r,sessionId:p,response:f,apiBaseUrl:o,protocol:null!=a?a:"preview"});return y.isOk()?l({sessionId:p,result:y.value}):u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:"Invalid response from digital credentials api"})};var Ue;e.HandleRedirectCallbackErrorType=void 0,(e.HandleRedirectCallbackErrorType||(e.HandleRedirectCallbackErrorType={})).HandleRedirectCallbackFailed="HandleRedirectCallbackFailed",function(e){e.FailedToFindResponseCode="Failed to find response code",e.FailedToFindChallenge="Failed to find challenge",e.FailedToFindSessionId="Failed to find sessionId",e.FailedToGetSessionResult="Failed to get session result"}(Ue||(Ue={}));const Ae={generateChallenge:Ce,unwrap:(e,r)=>{if(e.isOk())return e.value;throw new t(null!=r?r:"Error unwrapping result",e.error)}};e.handleRedirectCallback=async()=>{const r=ce();if(!r)throw new t(ue.SdkNotInitialised);const{apiBaseUrl:n}=r,i=(o=window.location.hash,a="response_code",new URLSearchParams(o.split("#")[1]).get(a));var o,a;if(!i)return u({type:e.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,message:Ue.FailedToFindResponseCode});const s=window.localStorage.getItem(ee.challenge);if(!s)return u({type:e.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,message:Ue.FailedToFindChallenge});const c=window.localStorage.getItem(ee.sessionId);if(!c)return u({type:e.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,message:Ue.FailedToFindSessionId});const d=await Ee({challenge:s,responseCode:i,sessionId:c,apiBaseUrl:n});return d.isErr()?u({type:e.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,message:Ue.FailedToGetSessionResult,cause:d.error}):l({result:d.value,sessionId:d.value.sessionId})},e.initialise=e=>{Q(se,"Invalid initialise options")(e),le=e},e.requestCredentials=async r=>{var n;const i=ce();if(!i)throw new t(ue.SdkNotInitialised);Q(ae,"Invalid request credential options")(r);const{challenge:o=Ce()}=r,a=null!==(n=r.mode)&&void 0!==n?n:(s=navigator.userAgent,pe({ua:s,tablet:!1})?e.Mode.sameDevice:e.Mode.crossDevice);var s;if(i.enableDigitalCredentialsApiCrossDeviceFlow&&a===e.Mode.crossDevice)return console.log("Digital Credentials API support found, proceeding with request using API in cross device flow"),await De(Object.assign(Object.assign({},r),{initialiseOptions:i,challenge:o}));if(i.enableDigitalCredentialsApiCrossDeviceFlow&&console.log("Digital Credentials API support not found, falling back to OpenID4VP"),i.enableDigitalCredentialsApiSameDeviceFlow&&a===e.Mode.sameDevice)return console.log("Digital Credentials API support found, proceeding with request using API in same device flow"),await De(Object.assign(Object.assign({},r),{initialiseOptions:i,challenge:o}));if(i.enableDigitalCredentialsApiSameDeviceFlow&&console.log("Digital Credentials API support not found, falling back to OpenID4VP"),a===e.Mode.sameDevice&&"redirectUri"in r)return await(async t=>{const{challenge:r,credentialQuery:n,redirectUri:i,walletProviderId:o,initialiseOptions:a}=t,{apiBaseUrl:s,applicationId:c}=a;window.localStorage.setItem(ee.challenge,r);const d=window.localStorage.getItem(ee.challenge);if(!d)return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:Re.FailedToStoreChallenge});const p=await ke({credentialQuery:n,challenge:d,redirectUri:i,apiBaseUrl:s,applicationId:c,walletProviderId:o});if(p.isErr())return u({type:e.RequestCredentialsErrorType.RequestCredentialsFailed,message:Re.FailedToCreateSession,cause:p.error});const{sessionUrl:f,sessionId:y}=p.value;return window.localStorage.setItem(ee.sessionId,y),window.location.assign(f),l({sessionId:y})})(Object.assign(Object.assign({},r),{initialiseOptions:i,challenge:o,mode:a}));if(a===e.Mode.crossDevice&&"crossDeviceCallback"in r)return await Fe(Object.assign(Object.assign({},r),{initialiseOptions:i,challenge:o,mode:a}));throw new t("Invalid request credential options",{data:r})},e.utils=Ae,Object.defineProperty(e,"__esModule",{value:!0})}));
37
37
  //# sourceMappingURL=verifier-js.production.js.map