@grabjs/superapp-sdk 1.8.4 → 1.8.6-beta.1

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/README.md CHANGED
@@ -10,6 +10,7 @@ response object must have a structure defined in this document.
10
10
  - [Camera Module](https://github.com/grab/superapp-sdk/blob/master/docs/CameraModule.md)
11
11
  - [Checkout Module](https://github.com/grab/superapp-sdk/blob/master/docs/CheckoutModule.md).
12
12
  - [Container Module](https://github.com/grab/superapp-sdk/blob/master/docs/ContainerModule.md).
13
+ - [Identity Module](https://github.com/grab/superapp-sdk/blob/master/docs/IdentityModule.md).
13
14
  - [Location Module](https://github.com/grab/superapp-sdk/blob/master/docs/LocationModule.md).
14
15
  - [Media Module](https://github.com/grab/superapp-sdk/blob/master/docs/MediaModule.md).
15
16
  - [Scope Module](https://github.com/grab/superapp-sdk/blob/master/docs/ScopeModule.md).
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- ((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).SuperAppSDK={})})(this,function(e){function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function i(u){return function(){var e=this,a=arguments;return new Promise(function(t,n){var r=u.apply(e,a);function o(e){c(r,t,n,o,i,"next",e)}function i(e){c(r,t,n,o,i,"throw",e)}o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f(r.key),r)}}function u(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function t(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function s(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?t(Object(o),!0).forEach(function(e){var t,n;t=r,n=o[e=e],(e=f(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function l(){var h,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function r(e,t,n,r){var o,i,a,u,c,s,l,d,f,t=t&&t.prototype instanceof g?t:g,t=Object.create(t.prototype);return w(t,"_invoke",(o=e,i=n,l=r||[],d=!1,f={p:s=0,n:0,v:h,a:p,f:p.bind(h,4),d:function(e,t){return a=e,u=0,c=h,f.n=t,v}},function(e,t,n){if(1<s)throw TypeError("Generator is already running");for(d&&1===t&&p(t,n),u=t,c=n;(y=u<2?h:c)||!d;){a||(u?u<3?(1<u&&(f.n=-1),p(u,c)):f.n=c:f.v=c);try{if(s=2,a){if(y=a[e=u?e:"next"]){if(!(y=y.call(a,c)))throw TypeError("iterator result is not an object");if(!y.done)return y;c=y.value,u<2&&(u=0)}else 1===u&&(y=a.return)&&y.call(a),u<2&&(c=TypeError("The iterator does not provide a '"+e+"' method"),u=1);a=h}else if((y=(d=f.n<0)?c:o.call(i,f))!==v)break}catch(e){a=h,u=1,c=e}finally{s=1}}return{value:y,done:d}}),!0),t;function p(e,t){for(u=e,c=t,y=0;!d&&s&&!n&&y<l.length;y++){var n,r=l[y],o=f.p,i=r[2];3<e?(n=i===t)&&(c=r[(u=r[4])?5:u=3],r[4]=r[5]=h):r[0]<=o&&((n=e<2&&o<r[1])?(u=0,f.v=t,f.n=r[1]):o<i&&(n=e<3||r[0]>t||i<t)&&(r[4]=e,r[5]=t,f.n=i,u=0))}if(n||1<e)return v;throw d=!0,t}}var v={};function g(){}function o(){}function i(){}var y=Object.getPrototypeOf,e=[][t]?y(y([][t]())):(w(y={},t,function(){return this}),y),a=i.prototype=g.prototype=Object.create(e);function u(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,w(e,n,"GeneratorFunction")),e.prototype=Object.create(a),e}return w(a,"constructor",o.prototype=i),w(i,"constructor",o),w(i,n,o.displayName="GeneratorFunction"),w(a),w(a,n,"Generator"),w(a,t,function(){return this}),w(a,"toString",function(){return"[object Generator]"}),(l=function(){return{w:r,m:u}})()}function w(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}(w=function(e,t,n,r){function o(t,n){w(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))})(e,t,n,r)}function d(e,t){return(e=>{if(Array.isArray(e))return e})(e)||((e,t)=>{var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}})(e,t)||((e,t)=>{var n;if(e)return"string"==typeof e?r(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0})(e,t)||(()=>{throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")})()}function f(e){e=((e,t)=>{if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);if("object"!=typeof(n=n.call(e,t||"default")))return n;throw new TypeError("@@toPrimitive must return a primitive value.")})(e,"string");return"symbol"==typeof e?e:e+""}function n(e){return(n="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})(e)}var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function p(e,t){return e(t={exports:{}},t.exports),t.exports}var v=p(function(e,t){function f(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function p(e){return{subscribe:e,then:function(r,o){return new Promise(function(){try{var t=null,n=!1,t=e({next:function(e){r&&r(e),t&&t.unsubscribe(),n=!0}});n&&t&&t.unsubscribe()}catch(e){o&&o(e)}})}}}function h(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(e)return e=e,t=Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e))),n.every(function(e){return 0<=t.indexOf(e)})}var v;((v=t).StreamEvent||(v.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",v.createDataStream=p,v.createSubscription=f,v.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},v.wrapModule=function(u,c){var s,l,d;u["Wrapped"+c]=(s=u,l=c,d={},{invoke:function(t,n){return e=s,(r={funcNameToWrap:t,callbackNameFunc:function(){var e=d[t]||0;return d[t]=e+1,(e={moduleName:l,requestID:e,funcName:t}).moduleName+"_"+e.funcName+"Callback"+(null!==(e=e.requestID)?"_"+e:"")},funcToWrap:function(e){e={callback:e,method:t,module:l,parameters:null!=n?n:{}};if(u[c])u[c][e.method](JSON.stringify(e));else{if(!(u.webkit&&u.webkit.messageHandlers&&u.webkit.messageHandlers[c]))throw new Error("Unexpected method '"+e.method+"' for module '"+c+"'");u.webkit.messageHandlers[c].postMessage(e)}}}).funcNameToWrap,o=e,e=((e,t)=>{var n={};for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&(n[o[r]]=e[o[r]]);return n})(r,["funcNameToWrap"]),i=e.callbackNameFunc,a=e.funcToWrap,p(function(t){var n,e=i();return o[e]=function(e){h(e,"status_code")&&(h(e.result,"event")?e.result.event===v.StreamEvent.STREAM_TERMINATED&&n.unsubscribe():t&&t.next&&t.next(e))},a(e),n=f(function(){delete o[e],t&&t.complete&&t.complete()})});var e,r,o,i,a}})},Object.defineProperty(v,"__esModule",{value:!0})}),g=(v=v)&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v.default:v,v=(()=>u(function e(){a(this,e),g.wrapModule(window,"CameraModule")},[{key:"scanQRCode",value:function(){return window.WrappedCameraModule.invoke("scanQRCode",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}}]))(),y=(()=>u(function e(){a(this,e),g.wrapModule(window,"CheckoutModule")},[{key:"triggerCheckout",value:function(e){return window.WrappedCheckoutModule.invoke("triggerCheckout",e)}}]))(),m=(()=>u(function e(){a(this,e),g.wrapModule(window,"ContainerModule")},[{key:"setBackgroundColor",value:function(e){return window.WrappedContainerModule.invoke("setBackgroundColor",{backgroundColor:e})}},{key:"setTitle",value:function(e){return window.WrappedContainerModule.invoke("setTitle",{title:e})}},{key:"hideBackButton",value:function(){return window.WrappedContainerModule.invoke("hideBackButton")}},{key:"showBackButton",value:function(){return window.WrappedContainerModule.invoke("showBackButton")}},{key:"hideRefreshButton",value:function(){return window.WrappedContainerModule.invoke("hideRefreshButton")}},{key:"showRefreshButton",value:function(){return window.WrappedContainerModule.invoke("showRefreshButton")}},{key:"close",value:function(){return window.WrappedContainerModule.invoke("close")}},{key:"onContentLoaded",value:function(){return window.WrappedContainerModule.invoke("onContentLoaded")}},{key:"showLoader",value:function(){return window.WrappedContainerModule.invoke("showLoader")}},{key:"hideLoader",value:function(){return window.WrappedContainerModule.invoke("hideLoader")}},{key:"openExternalLink",value:function(e){return window.WrappedContainerModule.invoke("openExternalLink",{url:e})}},{key:"onCtaTap",value:function(e){return window.WrappedContainerModule.invoke("onCtaTap",{action:e})}},{key:"sendAnalyticsEvent",value:function(e){var t=this._validateAnalyticsEvent(e);return t?{then:function(e){return e({status_code:400,error:t})}}:window.WrappedContainerModule.invoke("sendAnalyticsEvent",{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null})}},{key:"isConnected",value:function(){var t,e=window.navigator&&window.navigator.userAgent;return e?(t=/grab[a-z]*\//i.test(e),{then:function(e){return e({status_code:t?200:404,error:t?null:"Not connected to Grab app"})}}):{then:function(e){return e({status_code:404,error:"User agent not available"})}}}},{key:"getSessionParams",value:function(){return window.WrappedContainerModule.invoke("getSessionParams")}},{key:"_validateAnalyticsEvent",value:function(e){return null==e.name?"name is required":"string"!=typeof e.name?"name must be a string":null==e.state?"state is required":"string"!=typeof e.state?"state must be a string":null!=e.data&&"object"!==n(e.data)?"data must be undefined or an object":null}}]))(),b={},k=p(function(e,t){e.exports=(e=(s=>{var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),!(r=!(r=!(r="undefined"!=typeof globalThis&&globalThis.crypto?globalThis.crypto:r)&&"undefined"!=typeof window&&window.msCrypto?window.msCrypto:r)&&void 0!==h&&h.crypto?h.crypto:r))try{r=b}catch(e){}var n=Object.create||function(e){return t.prototype=e,e=new t,t.prototype=null,e};function t(){}var e={},o=e.lib={},i=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),(t.init.prototype=t).$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},l=o.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var a=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=a<<24-(r+i)%4*8}else for(var u=0;u<o;u+=4)t[r+u>>>2]=n[u>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push((()=>{if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")})());return new l.init(t,e)}}),a=e.enc={},u=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new l.init(n,t/2)}},c=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new l.init(n,t)}},d=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new l.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t,n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),u=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,e=s.min(4*u,o);if(u){for(var c=0;c<u;c+=i)this._doProcessBlock(r,c);t=r.splice(0,u),n.sigBytes-=e}return new l.init(t,e)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),p=(o.Hasher=f.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(n){return function(e,t){return new n.init(t).finalize(e)}},_createHmacHelper:function(n){return function(e,t){return new p.HMAC.init(n,t).finalize(e)}}}),e.algo={});return e})(Math),e)}),S=p(function(e,t){e.exports=(e=>{var o=Math,t=e,n=t.lib,r=n.WordArray,i=n.Hasher,n=t.algo,a=[],h=[];function u(e){for(var t=o.sqrt(e),n=2;n<=t;n++)if(!(e%n))return;return 1}function c(e){return 4294967296*(e-(0|e))|0}for(var s=2,l=0;l<64;)u(s)&&(l<8&&(a[l]=c(o.pow(s,.5))),h[l]=c(o.pow(s,1/3)),l++),s++;var v=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],u=n[4],c=n[5],s=n[6],l=n[7],d=0;d<64;d++){v[d]=d<16?0|e[t+d]:(((f=v[d-15])<<25|f>>>7)^(f<<14|f>>>18)^f>>>3)+v[d-7]+(((f=v[d-2])<<15|f>>>17)^(f<<13|f>>>19)^f>>>10)+v[d-16];var f=r&o^r&i^o&i,p=l+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&s)+h[d]+v[d],l=s,s=c,c=u,u=a+p|0,a=i,i=o,o=r,r=p+(((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+f)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+s|0,n[7]=n[7]+l|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=o.floor(n/4294967296),t[15+(64+r>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});return t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n),e.SHA256})(k)}),M=p(function(e,t){function a(e,t,n){for(var r,o,i=[],a=0,u=0;u<t;u++)u%4&&(r=n[e.charCodeAt(u-1)]<<u%4*2,o=n[e.charCodeAt(u)]>>>6-u%4*2,i[a>>>2]|=(r|o)<<24-a%4*8,a++);return c.create(i,a)}var c;e.exports=(c=(e=k).lib.WordArray,e.enc.Base64={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=this._map,o=(e.clamp(),[]),i=0;i<n;i+=3)for(var a=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,u=0;u<4&&i+.75*u<n;u++)o.push(r.charAt(a>>>6*(3-u)&63));var c=r.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(e){var t=e.length,n=this._map;if(!(r=this._reverseMap))for(var r=this._reverseMap=[],o=0;o<n.length;o++)r[n.charCodeAt(o)]=o;var i=n.charAt(64);return i&&-1!==(i=e.indexOf(i))&&(t=i),a(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},e.enc.Base64)}),C=(()=>{function c(){a(this,c),window.WrappedIdentityModule||g.wrapModule(window,"IdentityModule")}return u(c,[{key:"NAMESPACE",get:function(){return"grabid"}},{key:"CODE_CHALLENGE_METHOD",get:function(){return"S256"}},{key:"NONCE_LENGTH",get:function(){return 16}},{key:"STATE_LENGTH",get:function(){return 7}},{key:"CODE_VERIFIER_LENGTH",get:function(){return 64}},{key:"OPENID_CONFIG_ENDPOINTS",get:function(){return{staging:"https://partner-api.stg-myteksi.com/grabid/v1/oauth2/.well-known/openid-configuration",production:"https://partner-api.grab.com/grabid/v1/oauth2/.well-known/openid-configuration"}}},{key:"fetchAuthorizationEndpoint",value:(o=i(l().m(function e(t){var n,r,o,i;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=this.OPENID_CONFIG_ENDPOINTS[t]){e.n=1;break}throw new Error("Invalid environment: ".concat(t,". Must be 'staging' or 'production'"));case 1:return e.p=1,e.n=2,fetch(n);case 2:if((r=e.v).ok){e.n=3;break}throw console.error("Failed to fetch OpenID configuration from ".concat(n,": ").concat(r.status," ").concat(r.statusText)),new Error("Failed to fetch authorization configuration");case 3:return e.n=4,r.json();case 4:if((o=e.v).authorization_endpoint){e.n=5;break}throw console.error("authorization_endpoint not found in OpenID configuration response"),new Error("Invalid authorization configuration");case 5:return e.a(2,o.authorization_endpoint);case 6:if(e.p=6,i=e.v,console.error("Error fetching authorization endpoint:",i),"Failed to fetch authorization configuration"===i.message||"Invalid authorization configuration"===i.message)throw i;e.n=7;break;case 7:throw new Error("Something wrong happened when fetching authorization configuration");case 8:return e.a(2)}},e,this,[[1,6]])})),function(e){return o.apply(this,arguments)})},{key:"generatePKCEArtifacts",value:function(){var e=c.generateRandomString(this.NONCE_LENGTH),t=c.generateRandomString(this.STATE_LENGTH),n=c.generateCodeVerifier(this.CODE_VERIFIER_LENGTH);return{nonce:e,state:t,codeVerifier:n,codeChallenge:c.generateCodeChallenge(n),codeChallengeMethod:this.CODE_CHALLENGE_METHOD}}},{key:"storePKCEArtifacts",value:function(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}},{key:"getAuthorizationArtifacts",value:(r=i(l().m(function e(){var t,n,r,o,i;return l().w(function(e){for(;;)switch(e.n){case 0:if(t=this.getStorageItem("state"),n=this.getStorageItem("code_verifier"),r=this.getStorageItem("nonce"),o=this.getStorageItem("redirect_uri"),4===(i=[t,n,r,o].filter(function(e){return null!==e}).length))return e.a(2,Promise.resolve({status_code:200,result:{state:t,codeVerifier:n,nonce:r,redirectUri:o},error:null}));e.n=1;break;case 1:if(0===i)return e.a(2,Promise.resolve({status_code:204,result:null,error:null}));e.n=2;break;case 2:return e.a(2,Promise.resolve({status_code:400,result:null,error:"Inconsistent authorization artifacts in storage"}))}},e,this)})),function(){return r.apply(this,arguments)})},{key:"clearAuthorizationArtifacts",value:(e=i(l().m(function e(){return l().w(function(e){for(;;)if(0===e.n)return window.localStorage.removeItem("".concat(this.NAMESPACE,":nonce")),window.localStorage.removeItem("".concat(this.NAMESPACE,":state")),window.localStorage.removeItem("".concat(this.NAMESPACE,":code_verifier")),window.localStorage.removeItem("".concat(this.NAMESPACE,":redirect_uri")),window.localStorage.removeItem("".concat(this.NAMESPACE,":login_return_uri")),e.a(2,Promise.resolve({status_code:204,result:null,error:null}))},e,this)})),function(){return e.apply(this,arguments)})},{key:"setStorageItem",value:function(e,t){window.localStorage.setItem("".concat(this.NAMESPACE,":").concat(e),t)}},{key:"getStorageItem",value:function(e){return window.localStorage.getItem("".concat(this.NAMESPACE,":").concat(e))}},{key:"performWebAuthorization",value:(n=i(l().m(function e(t){var n,r,o;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:return this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",t.redirectUri),e.p=1,e.n=2,this.fetchAuthorizationEndpoint(t.environment);case 2:n=e.v,e.n=4;break;case 3:return e.p=3,o=e.v,e.a(2,Promise.resolve({status_code:400,error:o.message}));case 4:return o={client_id:t.clientId,scope:t.scope,response_type:"code",redirect_uri:t.redirectUri,nonce:t.nonce,state:t.state,code_challenge_method:t.codeChallengeMethod,code_challenge:t.codeChallenge},r=c.buildAuthorizeUrl(n,o),window.location.assign(r),e.a(2,Promise.resolve({status_code:302,result:null}))}},e,this,[[1,3]])})),function(e){return n.apply(this,arguments)})},{key:"authorize",value:(t=i(l().m(function e(t){var n,r,o,i,a,u;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=c.validateAuthorizeRequest(t))return e.a(2,Promise.resolve({status_code:400,error:n}));e.n=1;break;case 1:if(n=this.generatePKCEArtifacts(),r=t.responseMode||"redirect",o="in_place"===r?c.normalizeUrl(window.location.href):t.redirectUri,this.storePKCEArtifacts(s(s({},n),{},{redirectUri:o})),i={clientId:t.clientId,redirectUri:t.redirectUri,scope:t.scope,nonce:n.nonce,state:n.state,codeChallenge:n.codeChallenge,codeChallengeMethod:n.codeChallengeMethod},c.shouldUseWebConsent(t))return e.a(2,this.performWebAuthorization(s(s({},i),{},{environment:t.environment})));e.n=2;break;case 2:return e.p=2,e.n=3,c.performNativeAuthorization(s(s({},i),{},{actualRedirectUri:o,responseMode:r}));case 3:if((a=e.v).error&&[400,401,403].includes(a.status_code))return console.error("Native authorization returned ".concat(a.status_code,", falling back to web flow:"),a.error),e.a(2,this.performWebAuthorization(s(s({},i),{},{environment:t.environment})));e.n=4;break;case 4:return e.a(2,a);case 5:return e.p=5,u=e.v,console.error("Native authorization failed, falling back to web flow:",u),e.a(2,this.performWebAuthorization(s(s({},i),{},{environment:t.environment})))}},e,this,[[2,5]])})),function(e){return t.apply(this,arguments)})}],[{key:"generateRandomString",value:function(e){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e),r=(crypto.getRandomValues(n),""),o=0;o<e;o+=1)r+=t.charAt(n[o]%t.length);return r}},{key:"base64URLEncode",value:function(e){return e.toString(M).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}},{key:"generateCodeVerifier",value:function(e){return c.base64URLEncode(c.generateRandomString(e))}},{key:"generateCodeChallenge",value:function(e){return c.base64URLEncode(S(e))}},{key:"normalizeUrl",value:function(e){e=new URL(e);return"".concat(e.origin).concat(e.pathname)}},{key:"buildAuthorizeUrl",value:function(e,t){t=Object.entries(t).filter(function(e){return null!=e[1]}).map(function(e){var e=d(e,2),t=e[0],e=e[1];return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e))}).join("&");return"".concat(e,"?").concat(t)}},{key:"parseGrabUserAgent",value:function(e){return e&&"string"==typeof e&&(e=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i))?{appName:e[1],major:Number(e[2]),minor:Number(e[3]),patch:Number(e[4]),platform:e[5]}:null}},{key:"isVersionBelow",value:function(e,t){return e.major!==t.major?e.major<t.major:e.minor!==t.minor?e.minor<t.minor:e.patch<t.patch}},{key:"shouldUseWebConsent",value:function(e){var t=c.parseGrabUserAgent(window.navigator.userAgent);return!t||"staging"!==e.environment&&c.isVersionBelow(t,{major:5,minor:396,patch:0})}},{key:"performNativeAuthorization",value:function(e){return window.WrappedIdentityModule.invoke("authorize",{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode})}},{key:"validateRequiredString",value:function(e,t){return e&&"string"==typeof e&&""!==e.trim()?null:"".concat(t," is required and must be a non-empty string")}},{key:"validateAuthorizeRequest",value:function(e){if(null==e)return"request is required";var t=c.validateRequiredString(e.scope,"scope");if(t)return t;t=c.validateRequiredString(e.clientId,"clientId");if(t)return t;t=c.validateRequiredString(e.redirectUri,"redirectUri");if(t)return t;try{if(!new URL(e.redirectUri))return"redirectUri must be a valid URL"}catch(e){return"redirectUri must be a valid URL"}t=c.validateRequiredString(e.environment,"environment");return t||("staging"!==e.environment&&"production"!==e.environment?"environment must be either 'staging' or 'production'":null)}}]);var t,n,e,r,o})(),_=(()=>u(function e(){a(this,e),g.wrapModule(window,"LocaleModule")},[{key:"getLanguageLocaleIdentifier",value:function(){return window.WrappedLocaleModule.invoke("getLanguageLocaleIdentifier")}}]))(),E=(()=>u(function e(){a(this,e),g.wrapModule(window,"LocationModule")},[{key:"getCoordinate",value:function(){return window.WrappedLocationModule.invoke("getCoordinate")}},{key:"observeLocationChange",value:function(){return window.WrappedLocationModule.invoke("observeLocationChange")}},{key:"getCountryCode",value:function(){return window.WrappedLocationModule.invoke("getCountryCode")}}]))(),A=(()=>u(function e(){a(this,e),g.wrapModule(window,"MediaModule")},[{key:"playDRMContent",value:function(e){return window.WrappedMediaModule.invoke("playDRMContent",{data:e})}}]))(),O=(()=>u(function e(){a(this,e),g.wrapModule(window,"PlatformModule")},[{key:"back",value:function(){return window.WrappedPlatformModule.invoke("back")}}]))(),I=(()=>u(function e(){a(this,e),g.wrapModule(window,"ScopeModule")},[{key:"hasAccessTo",value:function(e,t){return window.WrappedScopeModule.invoke("hasAccessTo",{module:e,method:t})}},{key:"reloadScopes",value:function(){return window.WrappedScopeModule.invoke("reloadScopes")}}]))(),P=(()=>u(function e(){a(this,e),g.wrapModule(window,"StorageModule")},[{key:"setBoolean",value:function(e,t){return window.WrappedStorageModule.invoke("setBoolean",{key:e,value:t})}},{key:"getBoolean",value:function(e){return window.WrappedStorageModule.invoke("getBoolean",{key:e})}},{key:"setInt",value:function(e,t){return window.WrappedStorageModule.invoke("setInt",{key:e,value:t})}},{key:"getInt",value:function(e){return window.WrappedStorageModule.invoke("getInt",{key:e})}},{key:"setString",value:function(e,t){return window.WrappedStorageModule.invoke("setString",{key:e,value:t})}},{key:"getString",value:function(e){return window.WrappedStorageModule.invoke("getString",{key:e})}},{key:"setDouble",value:function(e,t){return window.WrappedStorageModule.invoke("setDouble",{key:e,value:t})}},{key:"getDouble",value:function(e){return window.WrappedStorageModule.invoke("getDouble",{key:e})}},{key:"remove",value:function(e){return window.WrappedStorageModule.invoke("remove",{key:e})}},{key:"removeAll",value:function(){return window.WrappedStorageModule.invoke("removeAll")}}]))(),N=(()=>u(function e(){a(this,e),g.wrapModule(window,"SystemWebViewKitModule")},[{key:"redirectToSystemWebView",value:function(e){return window.WrappedSystemWebViewKitModule.invoke("redirectToSystemWebView",e)}}]))();e.CameraModule=v,e.CheckoutModule=y,e.ContainerAnalyticsEventData={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},e.ContainerAnalyticsEventName={DEFAULT:"DEFAULT"},e.ContainerAnalyticsEventState={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},e.ContainerModule=m,e.IdentityModule=C,e.LocaleModule=_,e.LocationModule=E,e.MediaModule=A,e.PlatformModule=O,e.ScopeModule=I,e.StorageModule=P,e.SystemWebViewKitModule=N,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ ((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).SuperAppSDK={})})(this,function(e){function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function i(u){return function(){var e=this,a=arguments;return new Promise(function(t,n){var r=u.apply(e,a);function o(e){c(r,t,n,o,i,"next",e)}function i(e){c(r,t,n,o,i,"throw",e)}o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f(r.key),r)}}function u(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function t(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function s(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?t(Object(o),!0).forEach(function(e){var t,n;t=r,n=o[e=e],(e=f(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function l(){var h,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function r(e,t,n,r){var o,i,a,u,c,s,l,d,f,t=t&&t.prototype instanceof y?t:y,t=Object.create(t.prototype);return g(t,"_invoke",(o=e,i=n,l=r||[],d=!1,f={p:s=0,n:0,v:h,a:p,f:p.bind(h,4),d:function(e,t){return a=e,u=0,c=h,f.n=t,v}},function(e,t,n){if(1<s)throw TypeError("Generator is already running");for(d&&1===t&&p(t,n),u=t,c=n;(w=u<2?h:c)||!d;){a||(u?u<3?(1<u&&(f.n=-1),p(u,c)):f.n=c:f.v=c);try{if(s=2,a){if(w=a[e=u?e:"next"]){if(!(w=w.call(a,c)))throw TypeError("iterator result is not an object");if(!w.done)return w;c=w.value,u<2&&(u=0)}else 1===u&&(w=a.return)&&w.call(a),u<2&&(c=TypeError("The iterator does not provide a '"+e+"' method"),u=1);a=h}else if((w=(d=f.n<0)?c:o.call(i,f))!==v)break}catch(e){a=h,u=1,c=e}finally{s=1}}return{value:w,done:d}}),!0),t;function p(e,t){for(u=e,c=t,w=0;!d&&s&&!n&&w<l.length;w++){var n,r=l[w],o=f.p,i=r[2];3<e?(n=i===t)&&(c=r[(u=r[4])?5:u=3],r[4]=r[5]=h):r[0]<=o&&((n=e<2&&o<r[1])?(u=0,f.v=t,f.n=r[1]):o<i&&(n=e<3||r[0]>t||i<t)&&(r[4]=e,r[5]=t,f.n=i,u=0))}if(n||1<e)return v;throw d=!0,t}}var v={};function y(){}function o(){}function i(){}var w=Object.getPrototypeOf,e=[][t]?w(w([][t]())):(g(w={},t,function(){return this}),w),a=i.prototype=y.prototype=Object.create(e);function u(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,g(e,n,"GeneratorFunction")),e.prototype=Object.create(a),e}return g(a,"constructor",o.prototype=i),g(i,"constructor",o),g(i,n,o.displayName="GeneratorFunction"),g(a),g(a,n,"Generator"),g(a,t,function(){return this}),g(a,"toString",function(){return"[object Generator]"}),(l=function(){return{w:r,m:u}})()}function g(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}(g=function(e,t,n,r){function o(t,n){g(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))})(e,t,n,r)}function d(e,t){return(e=>{if(Array.isArray(e))return e})(e)||((e,t)=>{var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}})(e,t)||((e,t)=>{var n;if(e)return"string"==typeof e?r(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0})(e,t)||(()=>{throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")})()}function f(e){e=((e,t)=>{if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);if("object"!=typeof(n=n.call(e,t||"default")))return n;throw new TypeError("@@toPrimitive must return a primitive value.")})(e,"string");return"symbol"==typeof e?e:e+""}function n(e){return(n="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})(e)}var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function p(e,t){return e(t={exports:{}},t.exports),t.exports}var v=p(function(e,t){function f(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function p(e){return{subscribe:e,then:function(r,o){return new Promise(function(){try{var t=null,n=!1,t=e({next:function(e){r&&r(e),t&&t.unsubscribe(),n=!0}});n&&t&&t.unsubscribe()}catch(e){o&&o(e)}})}}}function h(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(e)return e=e,t=Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e))),n.every(function(e){return 0<=t.indexOf(e)})}var v;((v=t).StreamEvent||(v.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",v.createDataStream=p,v.createSubscription=f,v.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},v.wrapModule=function(u,c){var s,l,d;u["Wrapped"+c]=(s=u,l=c,d={},{invoke:function(t,n){return e=s,(r={funcNameToWrap:t,callbackNameFunc:function(){var e=d[t]||0;return d[t]=e+1,(e={moduleName:l,requestID:e,funcName:t}).moduleName+"_"+e.funcName+"Callback"+(null!==(e=e.requestID)?"_"+e:"")},funcToWrap:function(e){e={callback:e,method:t,module:l,parameters:null!=n?n:{}};if(u[c])u[c][e.method](JSON.stringify(e));else{if(!(u.webkit&&u.webkit.messageHandlers&&u.webkit.messageHandlers[c]))throw new Error("Unexpected method '"+e.method+"' for module '"+c+"'");u.webkit.messageHandlers[c].postMessage(e)}}}).funcNameToWrap,o=e,e=((e,t)=>{var n={};for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&(n[o[r]]=e[o[r]]);return n})(r,["funcNameToWrap"]),i=e.callbackNameFunc,a=e.funcToWrap,p(function(t){var n,e=i();return o[e]=function(e){h(e,"status_code")&&(h(e.result,"event")?e.result.event===v.StreamEvent.STREAM_TERMINATED&&n.unsubscribe():t&&t.next&&t.next(e))},a(e),n=f(function(){delete o[e],t&&t.complete&&t.complete()})});var e,r,o,i,a}})},Object.defineProperty(v,"__esModule",{value:!0})}),y=(v=v)&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v.default:v,v=(()=>u(function e(){a(this,e),y.wrapModule(window,"CameraModule")},[{key:"scanQRCode",value:function(){return window.WrappedCameraModule.invoke("scanQRCode",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}}]))(),w=(()=>u(function e(){a(this,e),y.wrapModule(window,"CheckoutModule")},[{key:"triggerCheckout",value:function(e){return window.WrappedCheckoutModule.invoke("triggerCheckout",e)}}]))(),m=(()=>u(function e(){a(this,e),y.wrapModule(window,"ContainerModule")},[{key:"setBackgroundColor",value:function(e){return window.WrappedContainerModule.invoke("setBackgroundColor",{backgroundColor:e})}},{key:"setTitle",value:function(e){return window.WrappedContainerModule.invoke("setTitle",{title:e})}},{key:"hideBackButton",value:function(){return window.WrappedContainerModule.invoke("hideBackButton")}},{key:"showBackButton",value:function(){return window.WrappedContainerModule.invoke("showBackButton")}},{key:"hideRefreshButton",value:function(){return window.WrappedContainerModule.invoke("hideRefreshButton")}},{key:"showRefreshButton",value:function(){return window.WrappedContainerModule.invoke("showRefreshButton")}},{key:"close",value:function(){return window.WrappedContainerModule.invoke("close")}},{key:"onContentLoaded",value:function(){return window.WrappedContainerModule.invoke("onContentLoaded")}},{key:"showLoader",value:function(){return window.WrappedContainerModule.invoke("showLoader")}},{key:"hideLoader",value:function(){return window.WrappedContainerModule.invoke("hideLoader")}},{key:"openExternalLink",value:function(e){return window.WrappedContainerModule.invoke("openExternalLink",{url:e})}},{key:"onCtaTap",value:function(e){return window.WrappedContainerModule.invoke("onCtaTap",{action:e})}},{key:"sendAnalyticsEvent",value:function(e){var t=this._validateAnalyticsEvent(e);return t?{then:function(e){return e({status_code:400,error:t})}}:window.WrappedContainerModule.invoke("sendAnalyticsEvent",{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null})}},{key:"isConnected",value:function(){var t,e=window.navigator&&window.navigator.userAgent;return e?(t=/grab[a-z]*\//i.test(e),{then:function(e){return e({status_code:t?200:404,error:t?null:"Not connected to Grab app"})}}):{then:function(e){return e({status_code:404,error:"User agent not available"})}}}},{key:"getSessionParams",value:function(){return window.WrappedContainerModule.invoke("getSessionParams")}},{key:"_validateAnalyticsEvent",value:function(e){return null==e.name?"name is required":"string"!=typeof e.name?"name must be a string":null==e.state?"state is required":"string"!=typeof e.state?"state must be a string":null!=e.data&&"object"!==n(e.data)?"data must be undefined or an object":null}}]))(),b={},k=p(function(e,t){e.exports=(e=(s=>{var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),!(r=!(r=!(r="undefined"!=typeof globalThis&&globalThis.crypto?globalThis.crypto:r)&&"undefined"!=typeof window&&window.msCrypto?window.msCrypto:r)&&void 0!==h&&h.crypto?h.crypto:r))try{r=b}catch(e){}var n=Object.create||function(e){return t.prototype=e,e=new t,t.prototype=null,e};function t(){}var e={},o=e.lib={},i=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),(t.init.prototype=t).$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},l=o.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var a=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=a<<24-(r+i)%4*8}else for(var u=0;u<o;u+=4)t[r+u>>>2]=n[u>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push((()=>{if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")})());return new l.init(t,e)}}),a=e.enc={},u=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new l.init(n,t/2)}},c=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new l.init(n,t)}},d=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new l.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t,n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),u=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,e=s.min(4*u,o);if(u){for(var c=0;c<u;c+=i)this._doProcessBlock(r,c);t=r.splice(0,u),n.sigBytes-=e}return new l.init(t,e)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),p=(o.Hasher=f.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(n){return function(e,t){return new n.init(t).finalize(e)}},_createHmacHelper:function(n){return function(e,t){return new p.HMAC.init(n,t).finalize(e)}}}),e.algo={});return e})(Math),e)}),S=p(function(e,t){e.exports=(e=>{var o=Math,t=e,n=t.lib,r=n.WordArray,i=n.Hasher,n=t.algo,a=[],h=[];function u(e){for(var t=o.sqrt(e),n=2;n<=t;n++)if(!(e%n))return;return 1}function c(e){return 4294967296*(e-(0|e))|0}for(var s=2,l=0;l<64;)u(s)&&(l<8&&(a[l]=c(o.pow(s,.5))),h[l]=c(o.pow(s,1/3)),l++),s++;var v=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],u=n[4],c=n[5],s=n[6],l=n[7],d=0;d<64;d++){v[d]=d<16?0|e[t+d]:(((f=v[d-15])<<25|f>>>7)^(f<<14|f>>>18)^f>>>3)+v[d-7]+(((f=v[d-2])<<15|f>>>17)^(f<<13|f>>>19)^f>>>10)+v[d-16];var f=r&o^r&i^o&i,p=l+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&s)+h[d]+v[d],l=s,s=c,c=u,u=a+p|0,a=i,i=o,o=r,r=p+(((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+f)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+s|0,n[7]=n[7]+l|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=o.floor(n/4294967296),t[15+(64+r>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});return t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n),e.SHA256})(k)}),M=p(function(e,t){function a(e,t,n){for(var r,o,i=[],a=0,u=0;u<t;u++)u%4&&(r=n[e.charCodeAt(u-1)]<<u%4*2,o=n[e.charCodeAt(u)]>>>6-u%4*2,i[a>>>2]|=(r|o)<<24-a%4*8,a++);return c.create(i,a)}var c;e.exports=(c=(e=k).lib.WordArray,e.enc.Base64={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=this._map,o=(e.clamp(),[]),i=0;i<n;i+=3)for(var a=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,u=0;u<4&&i+.75*u<n;u++)o.push(r.charAt(a>>>6*(3-u)&63));var c=r.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(e){var t=e.length,n=this._map;if(!(r=this._reverseMap))for(var r=this._reverseMap=[],o=0;o<n.length;o++)r[n.charCodeAt(o)]=o;var i=n.charAt(64);return i&&-1!==(i=e.indexOf(i))&&(t=i),a(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},e.enc.Base64)}),C=(()=>{function c(){a(this,c),window.WrappedIdentityModule||y.wrapModule(window,"IdentityModule")}return u(c,[{key:"NAMESPACE",get:function(){return"grabid"}},{key:"CODE_CHALLENGE_METHOD",get:function(){return"S256"}},{key:"NONCE_LENGTH",get:function(){return 16}},{key:"STATE_LENGTH",get:function(){return 7}},{key:"CODE_VERIFIER_LENGTH",get:function(){return 64}},{key:"OPENID_CONFIG_ENDPOINTS",get:function(){return{staging:"https://partner-api.stg-myteksi.com/grabid/v1/oauth2/.well-known/openid-configuration",production:"https://partner-api.grab.com/grabid/v1/oauth2/.well-known/openid-configuration"}}},{key:"fetchAuthorizationEndpoint",value:(o=i(l().m(function e(t){var n,r,o,i;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=this.OPENID_CONFIG_ENDPOINTS[t]){e.n=1;break}throw new Error("Invalid environment: ".concat(t,". Must be 'staging' or 'production'"));case 1:return e.p=1,e.n=2,fetch(n);case 2:if((r=e.v).ok){e.n=3;break}throw console.error("Failed to fetch OpenID configuration from ".concat(n,": ").concat(r.status," ").concat(r.statusText)),new Error("Failed to fetch authorization configuration");case 3:return e.n=4,r.json();case 4:if((o=e.v).authorization_endpoint){e.n=5;break}throw console.error("authorization_endpoint not found in OpenID configuration response"),new Error("Invalid authorization configuration");case 5:return e.a(2,o.authorization_endpoint);case 6:if(e.p=6,i=e.v,console.error("Error fetching authorization endpoint:",i),"Failed to fetch authorization configuration"===i.message||"Invalid authorization configuration"===i.message)throw i;e.n=7;break;case 7:throw new Error("Something wrong happened when fetching authorization configuration");case 8:return e.a(2)}},e,this,[[1,6]])})),function(e){return o.apply(this,arguments)})},{key:"generatePKCEArtifacts",value:function(){var e=c.generateRandomString(this.NONCE_LENGTH),t=c.generateRandomString(this.STATE_LENGTH),n=c.generateCodeVerifier(this.CODE_VERIFIER_LENGTH);return{nonce:e,state:t,codeVerifier:n,codeChallenge:c.generateCodeChallenge(n),codeChallengeMethod:this.CODE_CHALLENGE_METHOD}}},{key:"storePKCEArtifacts",value:function(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}},{key:"getAuthorizationArtifacts",value:(r=i(l().m(function e(){var t,n,r,o,i;return l().w(function(e){for(;;)switch(e.n){case 0:if(t=this.getStorageItem("state"),n=this.getStorageItem("code_verifier"),r=this.getStorageItem("nonce"),o=this.getStorageItem("redirect_uri"),4===(i=[t,n,r,o].filter(function(e){return null!==e}).length))return e.a(2,Promise.resolve({status_code:200,result:{state:t,codeVerifier:n,nonce:r,redirectUri:o},error:null}));e.n=1;break;case 1:if(0===i)return e.a(2,Promise.resolve({status_code:204,result:null,error:null}));e.n=2;break;case 2:return e.a(2,Promise.resolve({status_code:400,result:null,error:"Inconsistent authorization artifacts in storage"}))}},e,this)})),function(){return r.apply(this,arguments)})},{key:"clearAuthorizationArtifacts",value:(e=i(l().m(function e(){return l().w(function(e){for(;;)if(0===e.n)return window.localStorage.removeItem("".concat(this.NAMESPACE,":nonce")),window.localStorage.removeItem("".concat(this.NAMESPACE,":state")),window.localStorage.removeItem("".concat(this.NAMESPACE,":code_verifier")),window.localStorage.removeItem("".concat(this.NAMESPACE,":redirect_uri")),window.localStorage.removeItem("".concat(this.NAMESPACE,":login_return_uri")),e.a(2,Promise.resolve({status_code:204,result:null,error:null}))},e,this)})),function(){return e.apply(this,arguments)})},{key:"setStorageItem",value:function(e,t){window.localStorage.setItem("".concat(this.NAMESPACE,":").concat(e),t)}},{key:"getStorageItem",value:function(e){return window.localStorage.getItem("".concat(this.NAMESPACE,":").concat(e))}},{key:"performWebAuthorization",value:(n=i(l().m(function e(t){var n,r,o;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:return this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",t.redirectUri),e.p=1,e.n=2,this.fetchAuthorizationEndpoint(t.environment);case 2:n=e.v,e.n=4;break;case 3:return e.p=3,o=e.v,e.a(2,Promise.resolve({status_code:400,error:o.message}));case 4:return o={client_id:t.clientId,scope:t.scope,response_type:"code",redirect_uri:t.redirectUri,nonce:t.nonce,state:t.state,code_challenge_method:t.codeChallengeMethod,code_challenge:t.codeChallenge},r=c.buildAuthorizeUrl(n,o),window.location.assign(r),e.a(2,Promise.resolve({status_code:302,result:null}))}},e,this,[[1,3]])})),function(e){return n.apply(this,arguments)})},{key:"authorize",value:(t=i(l().m(function e(t){var n,r,o,i,a,u;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=c.validateAuthorizeRequest(t))return e.a(2,Promise.resolve({status_code:400,error:n}));e.n=1;break;case 1:if(n=this.generatePKCEArtifacts(),r=t.responseMode||"redirect",o="in_place"===r?c.normalizeUrl(window.location.href):t.redirectUri,this.storePKCEArtifacts(s(s({},n),{},{redirectUri:o})),i={clientId:t.clientId,redirectUri:t.redirectUri,scope:t.scope,nonce:n.nonce,state:n.state,codeChallenge:n.codeChallenge,codeChallengeMethod:n.codeChallengeMethod},c.shouldUseWebConsent(t))return e.a(2,this.performWebAuthorization(s(s({},i),{},{environment:t.environment})));e.n=2;break;case 2:return e.p=2,e.n=3,c.performNativeAuthorization(s(s({},i),{},{actualRedirectUri:o,responseMode:r}));case 3:if((a=e.v).error&&[400,401,403].includes(a.status_code))return console.error("Native authorization returned ".concat(a.status_code,", falling back to web flow:"),a.error),e.a(2,this.performWebAuthorization(s(s({},i),{},{environment:t.environment})));e.n=4;break;case 4:return e.a(2,a);case 5:return e.p=5,u=e.v,console.error("Native authorization failed, falling back to web flow:",u),e.a(2,this.performWebAuthorization(s(s({},i),{},{environment:t.environment})))}},e,this,[[2,5]])})),function(e){return t.apply(this,arguments)})}],[{key:"generateRandomString",value:function(e){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e),r=(crypto.getRandomValues(n),""),o=0;o<e;o+=1)r+=t.charAt(n[o]%t.length);return r}},{key:"base64URLEncode",value:function(e){return e.toString(M).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}},{key:"generateCodeVerifier",value:function(e){return c.base64URLEncode(c.generateRandomString(e))}},{key:"generateCodeChallenge",value:function(e){return c.base64URLEncode(S(e))}},{key:"normalizeUrl",value:function(e){e=new URL(e);return"".concat(e.origin).concat(e.pathname)}},{key:"buildAuthorizeUrl",value:function(e,t){t=Object.entries(t).filter(function(e){return null!=e[1]}).map(function(e){var e=d(e,2),t=e[0],e=e[1];return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e))}).join("&");return"".concat(e,"?").concat(t)}},{key:"parseGrabUserAgent",value:function(e){return e&&"string"==typeof e&&(e=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i))?{appName:e[1],major:Number(e[2]),minor:Number(e[3]),patch:Number(e[4]),platform:e[5]}:null}},{key:"isVersionBelow",value:function(e,t){return e.major!==t.major?e.major<t.major:e.minor!==t.minor?e.minor<t.minor:e.patch<t.patch}},{key:"shouldUseWebConsent",value:function(e){var t=c.parseGrabUserAgent(window.navigator.userAgent);return!t||"staging"!==e.environment&&c.isVersionBelow(t,{major:5,minor:396,patch:0})}},{key:"performNativeAuthorization",value:function(e){return window.WrappedIdentityModule.invoke("authorize",{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode})}},{key:"validateRequiredString",value:function(e,t){return e&&"string"==typeof e&&""!==e.trim()?null:"".concat(t," is required and must be a non-empty string")}},{key:"validateAuthorizeRequest",value:function(e){if(null==e)return"request is required";var t=c.validateRequiredString(e.scope,"scope");if(t)return t;t=c.validateRequiredString(e.clientId,"clientId");if(t)return t;t=c.validateRequiredString(e.redirectUri,"redirectUri");if(t)return t;try{if(!new URL(e.redirectUri))return"redirectUri must be a valid URL"}catch(e){return"redirectUri must be a valid URL"}t=c.validateRequiredString(e.environment,"environment");return t||("staging"!==e.environment&&"production"!==e.environment?"environment must be either 'staging' or 'production'":null)}}]);var t,n,e,r,o})(),_=(()=>{function t(){a(this,t),window.WrappedProfileModule||y.wrapModule(window,"ProfileModule")}return u(t,[{key:"fetchEmail",value:function(){return t.isSupported()?window.WrappedProfileModule.invoke("fetchEmail"):Promise.resolve({status_code:403,error:"This feature requires Grab app version 5.399 or above."})}},{key:"verifyEmail",value:function(e){return t.isSupported()?window.WrappedProfileModule.invoke("verifyEmail",e):Promise.resolve({status_code:403,error:"This feature requires Grab app version 5.399 or above."})}}],[{key:"parseGrabUserAgent",value:function(e){return e&&"string"==typeof e&&(e=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i))?{appName:e[1],major:Number(e[2]),minor:Number(e[3]),patch:Number(e[4]),platform:e[5]}:null}},{key:"isVersionBelow",value:function(e,t){return e.major!==t.major?e.major<t.major:e.minor!==t.minor?e.minor<t.minor:e.patch<t.patch}},{key:"isSupported",value:function(){var e=t.parseGrabUserAgent(window.navigator.userAgent);return!!e&&!t.isVersionBelow(e,{major:5,minor:399,patch:0})}}])})(),E=(()=>u(function e(){a(this,e),y.wrapModule(window,"LocaleModule")},[{key:"getLanguageLocaleIdentifier",value:function(){return window.WrappedLocaleModule.invoke("getLanguageLocaleIdentifier")}}]))(),A=(()=>u(function e(){a(this,e),y.wrapModule(window,"LocationModule")},[{key:"getCoordinate",value:function(){return window.WrappedLocationModule.invoke("getCoordinate")}},{key:"observeLocationChange",value:function(){return window.WrappedLocationModule.invoke("observeLocationChange")}},{key:"getCountryCode",value:function(){return window.WrappedLocationModule.invoke("getCountryCode")}}]))(),O=(()=>u(function e(){a(this,e),y.wrapModule(window,"MediaModule")},[{key:"playDRMContent",value:function(e){return window.WrappedMediaModule.invoke("playDRMContent",{data:e})}}]))(),P=(()=>u(function e(){a(this,e),y.wrapModule(window,"PlatformModule")},[{key:"back",value:function(){return window.WrappedPlatformModule.invoke("back")}}]))(),I=(()=>u(function e(){a(this,e),y.wrapModule(window,"ScopeModule")},[{key:"hasAccessTo",value:function(e,t){return window.WrappedScopeModule.invoke("hasAccessTo",{module:e,method:t})}},{key:"reloadScopes",value:function(){return window.WrappedScopeModule.invoke("reloadScopes")}}]))(),N=(()=>u(function e(){a(this,e),y.wrapModule(window,"StorageModule")},[{key:"setBoolean",value:function(e,t){return window.WrappedStorageModule.invoke("setBoolean",{key:e,value:t})}},{key:"getBoolean",value:function(e){return window.WrappedStorageModule.invoke("getBoolean",{key:e})}},{key:"setInt",value:function(e,t){return window.WrappedStorageModule.invoke("setInt",{key:e,value:t})}},{key:"getInt",value:function(e){return window.WrappedStorageModule.invoke("getInt",{key:e})}},{key:"setString",value:function(e,t){return window.WrappedStorageModule.invoke("setString",{key:e,value:t})}},{key:"getString",value:function(e){return window.WrappedStorageModule.invoke("getString",{key:e})}},{key:"setDouble",value:function(e,t){return window.WrappedStorageModule.invoke("setDouble",{key:e,value:t})}},{key:"getDouble",value:function(e){return window.WrappedStorageModule.invoke("getDouble",{key:e})}},{key:"remove",value:function(e){return window.WrappedStorageModule.invoke("remove",{key:e})}},{key:"removeAll",value:function(){return window.WrappedStorageModule.invoke("removeAll")}}]))(),T=(()=>u(function e(){a(this,e),y.wrapModule(window,"SystemWebViewKitModule")},[{key:"redirectToSystemWebView",value:function(e){return window.WrappedSystemWebViewKitModule.invoke("redirectToSystemWebView",e)}}]))();e.CameraModule=v,e.CheckoutModule=w,e.ContainerAnalyticsEventData={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},e.ContainerAnalyticsEventName={DEFAULT:"DEFAULT"},e.ContainerAnalyticsEventState={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},e.ContainerModule=m,e.IdentityModule=C,e.LocaleModule=E,e.LocationModule=A,e.MediaModule=O,e.PlatformModule=P,e.ProfileModule=_,e.ScopeModule=I,e.StorageModule=N,e.SystemWebViewKitModule=T,Object.defineProperty(e,"__esModule",{value:!0})});
@@ -0,0 +1,136 @@
1
+ # ProfileModule
2
+
3
+ ## Description
4
+
5
+ The ProfileModule provides functionality related to user profile information.
6
+
7
+ ## Methods
8
+
9
+ ### 1. Fetch Email
10
+
11
+ **Method name**: `fetchEmail`
12
+
13
+ **Scopes to be requested**: `mobile.profile`
14
+
15
+ **Description**
16
+
17
+ This is used to fetch the verified email of the user. If the user does not have a verified email, the method will return a `status_code` of `204`.
18
+
19
+ **Arguments**
20
+
21
+ None
22
+
23
+ **Return type**
24
+
25
+ | Name | Type | Description |
26
+ | --- | --- | --- |
27
+ | result | Object \| null | Result of the fetch email operation. Returns `null` if no verified email is found (204). |
28
+ | error | String \| null | Error message if the operation fails |
29
+ | status_code | Number | HTTP status code for the operation |
30
+
31
+ **Result Object Properties**
32
+
33
+ When `status_code` is `200`, the result object contains:
34
+
35
+ | Property | Type | Description |
36
+ | --- | --- | --- |
37
+ | email | String | The verified email address of the user |
38
+
39
+ **Status Codes**
40
+
41
+ - **200**: Success, verified email found and returned in `result`
42
+ - **204**: No verified email found for the user
43
+ - **400**: Client error (e.g. invalid request)
44
+ - **500**: Internal server error
45
+
46
+ **Code example**
47
+
48
+ ```javascript
49
+ import { ProfileModule } from "@grabjs/superapp-sdk";
50
+
51
+ // Ideally, initialize this only once and reuse across app.
52
+ const profileModule = new ProfileModule();
53
+
54
+ const { result, error, status_code } = await profileModule.fetchEmail();
55
+
56
+ if (status_code === 200 && result) {
57
+ console.log("User email:", result.email);
58
+ } else if (status_code === 204) {
59
+ console.log("User does not have a verified email.");
60
+ } else if (error) {
61
+ console.error("Fetch email error:", error);
62
+ }
63
+ ```
64
+
65
+ ### 2. Verify Email
66
+
67
+ **Method name**: `verifyEmail`
68
+
69
+ **Scopes to be requested**: `mobile.profile`
70
+
71
+ **Description**
72
+
73
+ Trigger email capture bottom sheet and OTP verification. If the user closes the verify OTP bottom sheet, the method will return a `status_code` of `204`.
74
+
75
+ Successful verification will also update the email address for the user on Grab.
76
+
77
+ **Arguments**
78
+
79
+ | Name | Type | Required | Description |
80
+ | --- | --- | --- | --- |
81
+ | request | Object | Yes | Request parameters for email verification |
82
+
83
+ **Request Object Properties**
84
+
85
+ | Property | Type | Required | Description |
86
+ | --- | --- | --- | --- |
87
+ | email | String | No | Email address for verification. Native bottom sheet will be displayed with this email address if not empty (User can edit before proceeding) |
88
+ | skipUserInput | Boolean | No | If set to `true`, and email is not empty, trigger the verify OTP bottom sheet directly. |
89
+
90
+ **Return type**
91
+
92
+ | Name | Type | Description |
93
+ | --- | --- | --- |
94
+ | result | Object \| null | Result of the verify email operation. Returns `null` if the user cancels (204). |
95
+ | error | String \| null | Error message if the operation fails |
96
+ | status_code | Number | HTTP status code for the operation |
97
+
98
+ **Result Object Properties**
99
+
100
+ When `status_code` is `200`, the result object contains:
101
+
102
+ | Property | Type | Description |
103
+ | --- | --- | --- |
104
+ | email | String | The verified email address of the user |
105
+
106
+ **Status Codes**
107
+
108
+ - **200**: Success, email verified and returned in `result`
109
+ - **204**: User closed the native bottom sheet
110
+ - **400**: Client error (e.g. invalid email format)
111
+ - **403**: Unauthorised
112
+ - **500**: Internal server error
113
+
114
+ **Code example**
115
+
116
+ ```javascript
117
+ import { ProfileModule } from "@grabjs/superapp-sdk";
118
+
119
+ // Ideally, initialize this only once and reuse across app.
120
+ const profileModule = new ProfileModule();
121
+
122
+ const request = {
123
+ email: "test@example.com",
124
+ skipUserInput: false
125
+ };
126
+
127
+ const { result, error, status_code } = await profileModule.verifyEmail(request);
128
+
129
+ if (status_code === 200 && result) {
130
+ console.log("Verified email:", result.email);
131
+ } else if (status_code === 204) {
132
+ console.log("User closed the bottom sheet.");
133
+ } else if (error) {
134
+ console.error("Verify email error:", error);
135
+ }
136
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grabjs/superapp-sdk",
3
- "version": "1.8.4",
3
+ "version": "1.8.6-beta.1",
4
4
  "description": "SDK for Grab SuperApp WebView.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {