@grabjs/superapp-sdk 2.0.0-beta.23 → 2.0.0-beta.29
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 +14 -155
- package/api-reference/api.json +43962 -0
- package/dist/index.d.ts +2140 -2608
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +14 -9
- package/skills/SKILL.md +405 -0
- package/api-reference/json/api.json +0 -27688
- package/api-reference/markdown/README.md +0 -194
- package/api-reference/markdown/classes/BaseModule.md +0 -123
- package/api-reference/markdown/classes/CameraModule.md +0 -177
- package/api-reference/markdown/classes/CheckoutModule.md +0 -181
- package/api-reference/markdown/classes/ContainerModule.md +0 -751
- package/api-reference/markdown/classes/DeviceCapabilityModule.md +0 -161
- package/api-reference/markdown/classes/FileModule.md +0 -178
- package/api-reference/markdown/classes/IdentityModule.md +0 -299
- package/api-reference/markdown/classes/LocaleModule.md +0 -161
- package/api-reference/markdown/classes/LocationModule.md +0 -239
- package/api-reference/markdown/classes/MediaModule.md +0 -219
- package/api-reference/markdown/classes/PlatformModule.md +0 -162
- package/api-reference/markdown/classes/ProfileModule.md +0 -224
- package/api-reference/markdown/classes/ScopeModule.md +0 -219
- package/api-reference/markdown/classes/StorageModule.md +0 -608
- package/api-reference/markdown/classes/SystemWebViewKitModule.md +0 -177
- package/api-reference/markdown/classes/UserAttributesModule.md +0 -164
- package/api-reference/markdown/functions/isClientError.md +0 -37
- package/api-reference/markdown/functions/isErrorResponse.md +0 -40
- package/api-reference/markdown/functions/isRedirection.md +0 -37
- package/api-reference/markdown/functions/isServerError.md +0 -37
- package/api-reference/markdown/functions/isSuccess.md +0 -39
- package/api-reference/markdown/globals.md +0 -176
- package/api-reference/markdown/interfaces/GrabAppInfo.md +0 -23
- package/api-reference/markdown/interfaces/InvokeOptions.md +0 -63
- package/api-reference/markdown/interfaces/Version.md +0 -23
- package/api-reference/markdown/interfaces/WrappedModule.md +0 -51
- package/api-reference/markdown/type-aliases/AuthorizeRequest.md +0 -79
- package/api-reference/markdown/type-aliases/AuthorizeResponse.md +0 -58
- package/api-reference/markdown/type-aliases/AuthorizeResult.md +0 -33
- package/api-reference/markdown/type-aliases/BackResponse.md +0 -37
- package/api-reference/markdown/type-aliases/BackResult.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeClientError.md +0 -9
- package/api-reference/markdown/type-aliases/BridgeError.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeRedirection.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeResponse.md +0 -40
- package/api-reference/markdown/type-aliases/BridgeServerError.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeStatusCode.md +0 -7
- package/api-reference/markdown/type-aliases/BridgeStream.md +0 -29
- package/api-reference/markdown/type-aliases/BridgeStreamHandlers.md +0 -25
- package/api-reference/markdown/type-aliases/BridgeSuccessResponse.md +0 -14
- package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResponse.md +0 -18
- package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResult.md +0 -8
- package/api-reference/markdown/type-aliases/CloseResponse.md +0 -37
- package/api-reference/markdown/type-aliases/CloseResult.md +0 -8
- package/api-reference/markdown/type-aliases/DRMContentConfig.md +0 -34
- package/api-reference/markdown/type-aliases/DRMPlaybackEvent.md +0 -43
- package/api-reference/markdown/type-aliases/DownloadFileRequest.md +0 -32
- package/api-reference/markdown/type-aliases/DownloadFileResponse.md +0 -48
- package/api-reference/markdown/type-aliases/DownloadFileResult.md +0 -11
- package/api-reference/markdown/type-aliases/ErrorResponse.md +0 -32
- package/api-reference/markdown/type-aliases/FetchEmailResponse.md +0 -58
- package/api-reference/markdown/type-aliases/FetchEmailResult.md +0 -21
- package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResponse.md +0 -42
- package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResult.md +0 -57
- package/api-reference/markdown/type-aliases/GetBooleanRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetBooleanResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetBooleanResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetCoordinateResponse.md +0 -49
- package/api-reference/markdown/type-aliases/GetCoordinateResult.md +0 -29
- package/api-reference/markdown/type-aliases/GetCountryCodeResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetCountryCodeResult.md +0 -25
- package/api-reference/markdown/type-aliases/GetDoubleRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetDoubleResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetDoubleResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetIntRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetIntResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetIntResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResponse.md +0 -48
- package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResult.md +0 -31
- package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResponse.md +0 -48
- package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResult.md +0 -17
- package/api-reference/markdown/type-aliases/GetSessionParamsResponse.md +0 -40
- package/api-reference/markdown/type-aliases/GetSessionParamsResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetStringRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetStringResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetStringResult.md +0 -27
- package/api-reference/markdown/type-aliases/HasAccessToResponse.md +0 -66
- package/api-reference/markdown/type-aliases/HasAccessToResult.md +0 -27
- package/api-reference/markdown/type-aliases/HideBackButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideBackButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/HideLoaderResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideLoaderResult.md +0 -8
- package/api-reference/markdown/type-aliases/HideRefreshButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideRefreshButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/IsConnectedResponse.md +0 -31
- package/api-reference/markdown/type-aliases/IsConnectedResult.md +0 -27
- package/api-reference/markdown/type-aliases/IsEsimSupportedResponse.md +0 -48
- package/api-reference/markdown/type-aliases/IsEsimSupportedResult.md +0 -17
- package/api-reference/markdown/type-aliases/ObserveDRMPlaybackResponse.md +0 -15
- package/api-reference/markdown/type-aliases/ObserveLocationChangeResponse.md +0 -15
- package/api-reference/markdown/type-aliases/OnContentLoadedResponse.md +0 -37
- package/api-reference/markdown/type-aliases/OnContentLoadedResult.md +0 -8
- package/api-reference/markdown/type-aliases/OnCtaTapRequest.md +0 -13
- package/api-reference/markdown/type-aliases/OnCtaTapResponse.md +0 -37
- package/api-reference/markdown/type-aliases/OnCtaTapResult.md +0 -8
- package/api-reference/markdown/type-aliases/OpenExternalLinkRequest.md +0 -13
- package/api-reference/markdown/type-aliases/OpenExternalLinkResponse.md +0 -46
- package/api-reference/markdown/type-aliases/OpenExternalLinkResult.md +0 -8
- package/api-reference/markdown/type-aliases/Platform.md +0 -7
- package/api-reference/markdown/type-aliases/PlayDRMContentResponse.md +0 -43
- package/api-reference/markdown/type-aliases/PlayDRMContentResult.md +0 -8
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewRequest.md +0 -23
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResponse.md +0 -55
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResult.md +0 -8
- package/api-reference/markdown/type-aliases/ReloadScopesResponse.md +0 -46
- package/api-reference/markdown/type-aliases/ReloadScopesResult.md +0 -8
- package/api-reference/markdown/type-aliases/RemoveAllResponse.md +0 -37
- package/api-reference/markdown/type-aliases/RemoveAllResult.md +0 -8
- package/api-reference/markdown/type-aliases/RemoveResponse.md +0 -46
- package/api-reference/markdown/type-aliases/RemoveResult.md +0 -8
- package/api-reference/markdown/type-aliases/ResponseStatusCode200.md +0 -34
- package/api-reference/markdown/type-aliases/ResponseStatusCode204.md +0 -20
- package/api-reference/markdown/type-aliases/ResponseStatusCode302.md +0 -20
- package/api-reference/markdown/type-aliases/ResponseStatusCode400.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode401.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode403.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode404.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode424.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode426.md +0 -12
- package/api-reference/markdown/type-aliases/ResponseStatusCode500.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode501.md +0 -12
- package/api-reference/markdown/type-aliases/ScanQRCodeRequest.md +0 -27
- package/api-reference/markdown/type-aliases/ScanQRCodeResponse.md +0 -64
- package/api-reference/markdown/type-aliases/ScanQRCodeResult.md +0 -21
- package/api-reference/markdown/type-aliases/SendAnalyticsEventRequest.md +0 -56
- package/api-reference/markdown/type-aliases/SendAnalyticsEventResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SendAnalyticsEventResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetBackgroundColorRequest.md +0 -13
- package/api-reference/markdown/type-aliases/SetBackgroundColorResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetBackgroundColorResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetBooleanResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetBooleanResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetDoubleResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetDoubleResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetIntResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetIntResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetStringResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetStringResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetTitleRequest.md +0 -13
- package/api-reference/markdown/type-aliases/SetTitleResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetTitleResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowBackButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowBackButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowLoaderResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowLoaderResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowRefreshButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowRefreshButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/StatusCodeMap.md +0 -80
- package/api-reference/markdown/type-aliases/Subscription.md +0 -12
- package/api-reference/markdown/type-aliases/TriggerCheckoutRequest.md +0 -26
- package/api-reference/markdown/type-aliases/TriggerCheckoutResponse.md +0 -76
- package/api-reference/markdown/type-aliases/TriggerCheckoutResult.md +0 -75
- package/api-reference/markdown/type-aliases/VerifyEmailRequest.md +0 -32
- package/api-reference/markdown/type-aliases/VerifyEmailResponse.md +0 -55
- package/api-reference/markdown/type-aliases/VerifyEmailResult.md +0 -8
- package/api-reference/markdown/variables/ContainerAnalyticsEventData.md +0 -21
- package/api-reference/markdown/variables/ContainerAnalyticsEventName.md +0 -13
- package/api-reference/markdown/variables/ContainerAnalyticsEventState.md +0 -25
package/dist/index.esm.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the LICENSE file in the root
|
|
5
5
|
* directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
var e,t={exports:{}},r=(e||(e=1,function(e){function t(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function r(e){return{subscribe:e,then:function(t,r){return new Promise(function(n,o){try{var a=null,i=!1;a=e({next:function(e){n(null==t?void 0:t(e)),a&&a.unsubscribe(),i=!0}}),i&&a&&a.unsubscribe()}catch(e){null==r?o(e):n(r(e))}})}}}function n(n,o){return o.funcNameToWrap,function(n,o){var a=o.callbackNameFunc,i=o.funcToWrap;return r(function(r){var o,s=a();return n[s]=function(t){if(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(!e)return!1;var n=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=n.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&o.unsubscribe();else{var n=t.result,a=t.error,i=t.status_code;r&&r.next&&r.next({result:null===n?void 0:n,error:null===a?void 0:a,status_code:null===i?void 0:i})}},i(s),o=t(function(){n[s]=void 0,r&&r.complete&&r.complete()})})}(n,function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r}(o,["funcNameToWrap"]))}(e.StreamEvent||(e.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",e.createDataStream=r,e.createSubscription=t,e.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},e.wrapModule=function(e,t){var r;e[(r=t,"Wrapped"+r)]=function(e,t,r){return{invoke:function(o,a){return n(e,{funcNameToWrap:o,callbackNameFunc:function(){return function(e,t){var r=t.moduleName,n=t.funcName,o=0;return function(){for(var t,a,i="";(i=(t={moduleName:r,funcName:n,requestID:o}).moduleName+"_"+t.funcName+"Callback"+(null!==(a=t.requestID)?"_"+a:""))in e;)o+=1;return o+=1,i}()}(e,{moduleName:t,funcName:o})},funcToWrap:function(e){return r({callback:e,method:o,module:t,parameters:null!=a?a:{}})}})}}}(e,t,function(r){if(e[t]&&e[t][r.method]instanceof Function)e[t][r.method](JSON.stringify(r));else{if(!(e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]))throw new Error("Unexpected method '"+r.method+"' for module '"+t+"'");e.webkit.messageHandlers[t].postMessage(r)}})},Object.defineProperty(e,"__esModule",{value:!0})}(t.exports)),t.exports);function n(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}function o(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class a{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,!this.wrappedModule)try{r.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${n(e)&&`: ${e.message}`}`,{cause:e})}}async invoke(e){const{method:t,params:r,isSupported:n,transformResponse:a}=e;try{const e=o();if(!e)return{status_code:501,error:"Not implemented: This method requires the Grab app environment"};if(n&&!n(e))return{status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"};const i=await this.wrappedModule.invoke(t,r);return a?a(i):i}catch{return{status_code:500,error:"Failed to invoke method"}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:r,isSupported:n,transformResponse:a}=e;try{const e=o();if(!e)return this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"});if(n&&!n(e))return this.createErrorStream({status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"});const i=this.wrappedModule.invoke(t,r);return a?{subscribe:e=>i.subscribe({next:t=>e?.next?.(a(t)),complete:e?.complete}),then:e=>i.then(t=>e?e(a(t)):a(t))}:i}catch{return this.createErrorStream({status_code:500,error:"Failed to invoke method"})}}}function i(e){return 200===e.status_code||204===e.status_code}function s(e){return 302===e.status_code}function c(e){return 400===e.status_code||401===e.status_code||403===e.status_code||404===e.status_code||424===e.status_code||426===e.status_code}function u(e){return 500===e.status_code||501===e.status_code}function d(e){return c(e)||u(e)}class l extends a{constructor(){super("CameraModule")}async scanQRCode(e){return await this.invoke({method:"scanQRCode",params:e})}}class h extends a{constructor(){super("CheckoutModule")}async triggerCheckout(e){return await this.invoke({method:"triggerCheckout",params:e})}}const m={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},p={DEFAULT:"DEFAULT"},g={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"};class f extends a{constructor(){super("ContainerModule")}async setBackgroundColor(e){return await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}})}async setTitle(e){return await this.invoke({method:"setTitle",params:{title:e}})}async hideBackButton(){return await this.invoke({method:"hideBackButton"})}async showBackButton(){return await this.invoke({method:"showBackButton"})}async hideRefreshButton(){return await this.invoke({method:"hideRefreshButton"})}async showRefreshButton(){return await this.invoke({method:"showRefreshButton"})}async close(){return await this.invoke({method:"close"})}async onContentLoaded(){return await this.invoke({method:"onContentLoaded"})}async showLoader(){return await this.invoke({method:"showLoader"})}async hideLoader(){return await this.invoke({method:"hideLoader"})}async openExternalLink(e){return await this.invoke({method:"openExternalLink",params:{url:e}})}async onCtaTap(e){return await this.invoke({method:"onCtaTap",params:{action:e}})}async sendAnalyticsEvent(e){const t=this.validateAnalyticsEvent(e);return t?{status_code:400,error:t}:await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}})}async isConnected(){return null!==o()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){return await this.invoke({method:"getSessionParams"})}validateAnalyticsEvent(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"!=typeof e.data?"data must be undefined or an object":null}}class v extends a{constructor(){super("DeviceCapabilityModule")}async isEsimSupported(){return await this.invoke({method:"isEsimSupported"})}}class w extends a{constructor(){super("FileModule")}async downloadFile(e){return await this.invoke({method:"downloadFile",params:e})}}function y(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let r="";for(let n=0;n<e;n+=1)r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[n]%62);return r}async function b(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let r="";for(let e=0;e<t.byteLength;e+=1)r+=String.fromCharCode(t[e]);return btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}function k(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const S="grabid",_={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"};class C extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}class M extends a{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=_[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new C("Failed to fetch authorization configuration");const r=await e.json();if(!r.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new C("Invalid authorization configuration");return r.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof C)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=y(16),t=y(7),r=(n=y(64),btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var n;return{nonce:e,state:t,codeVerifier:r,codeChallenge:await b(r),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),r=this.getStorageItem("nonce"),n=this.getStorageItem("redirect_uri"),o=[e,t,r,n].filter(e=>null!==e).length;return 4===o?{status_code:200,result:{state:e,codeVerifier:t,nonce:r,redirectUri:n}}:0===o?{status_code:204}:{status_code:400,error:"Inconsistent authorization artifacts in storage"}}async clearAuthorizationArtifacts(){return window.localStorage.removeItem(`${S}:nonce`),window.localStorage.removeItem(`${S}:state`),window.localStorage.removeItem(`${S}:code_verifier`),window.localStorage.removeItem(`${S}:redirect_uri`),window.localStorage.removeItem(`${S}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${S}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${S}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=o();return!t||"staging"!==e.environment&&!k(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:n(e)?e.message:"Could not fetch authorization endpoint"}}const r={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},o=M.buildAuthorizeUrl(t,r);return window.location.assign(o),{status_code:302}}async performNativeAuthorization(e){return await this.invoke({method:"authorize",params:{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode}})}async authorize(e){const t=M.validateAuthorizeRequest(e);if(t)return{status_code:400,error:t};const r=await this.generatePKCEArtifacts(),n=e.responseMode||"redirect",o="in_place"===n?M.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...r,redirectUri:o});const a={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:r.nonce,state:r.state,codeChallenge:r.codeChallenge,codeChallengeMethod:r.codeChallengeMethod};if(M.shouldUseWebConsent(e))return this.performWebAuthorization({...a,environment:e.environment});try{const t=await this.performNativeAuthorization({...a,actualRedirectUri:o,responseMode:n});return 400===t.status_code||401===t.status_code||403===t.status_code||500===t.status_code||501===t.status_code?(console.error(`Native authorization returned ${t.status_code}, falling back to web flow:`,t.error),this.performWebAuthorization({...a,environment:e.environment})):t}catch(t){return console.error("Native authorization failed, falling back to web flow:",t),this.performWebAuthorization({...a,environment:e.environment})}}static validateRequiredString(e,t){return e&&"string"==typeof e&&""!==e.trim()?null:`${t} is required and must be a non-empty string`}static validateAuthorizeRequest(e){if(null==e)return"request is required";const t=M.validateRequiredString(e.scope,"scope");if(t)return t;const r=M.validateRequiredString(e.clientId,"clientId");if(r)return r;const n=M.validateRequiredString(e.redirectUri,"redirectUri");if(n)return n;try{if(!new URL(e.redirectUri))return"redirectUri must be a valid URL"}catch{return"redirectUri must be a valid URL"}return M.validateRequiredString(e.environment,"environment")||("staging"!==e.environment&&"production"!==e.environment?"environment must be either 'staging' or 'production'":null)}}class E extends a{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){return await this.invoke({method:"getLanguageLocaleIdentifier"})}}class I extends a{constructor(){super("LocationModule")}async getCoordinate(){return await this.invoke({method:"getCoordinate"})}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){return await this.invoke({method:"getCountryCode"})}}class A extends a{constructor(){super("MediaModule")}async playDRMContent(e){return await this.invoke({method:"playDRMContent",params:{data:e}})}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}}class U extends a{constructor(){super("PlatformModule")}async back(){return await this.invoke({method:"back"})}}class N extends a{constructor(){super("ProfileModule")}async fetchEmail(){return await this.invoke({method:"fetchEmail",isSupported:e=>k(e.version,N.MINIMUM_VERSION)})}async verifyEmail(e){return await this.invoke({method:"verifyEmail",params:e,isSupported:e=>k(e.version,N.MINIMUM_VERSION)})}}N.MINIMUM_VERSION={major:5,minor:399,patch:0};class T extends a{constructor(){super("ScopeModule")}async hasAccessTo(e,t){return await this.invoke({method:"hasAccessTo",params:{module:e,method:t}})}async reloadScopes(){return await this.invoke({method:"reloadScopes"})}}class R extends a{constructor(){super("StorageModule")}async setBoolean(e,t){return await this.invoke({method:"setBoolean",params:{key:e,value:t}})}async getBoolean(e){return await this.invoke({method:"getBoolean",params:{key:e}})}async setInt(e,t){return await this.invoke({method:"setInt",params:{key:e,value:t}})}async getInt(e){return await this.invoke({method:"getInt",params:{key:e}})}async setString(e,t){return await this.invoke({method:"setString",params:{key:e,value:t}})}async getString(e){return await this.invoke({method:"getString",params:{key:e}})}async setDouble(e,t){return await this.invoke({method:"setDouble",params:{key:e,value:t}})}async getDouble(e){return await this.invoke({method:"getDouble",params:{key:e}})}async remove(e){return await this.invoke({method:"remove",params:{key:e}})}async removeAll(){return await this.invoke({method:"removeAll"})}}class O extends a{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){return await this.invoke({method:"redirectToSystemWebView",params:e})}}class x extends a{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){return await this.invoke({method:"getSelectedTravelDestination"})}}export{a as BaseModule,l as CameraModule,h as CheckoutModule,g as ContainerAnalyticsEventData,p as ContainerAnalyticsEventName,m as ContainerAnalyticsEventState,f as ContainerModule,v as DeviceCapabilityModule,w as FileModule,M as IdentityModule,E as LocaleModule,I as LocationModule,A as MediaModule,U as PlatformModule,N as ProfileModule,T as ScopeModule,R as StorageModule,O as SystemWebViewKitModule,x as UserAttributesModule,c as isClientError,d as isErrorResponse,s as isRedirection,u as isServerError,i as isSuccess};
|
|
7
|
+
var e,t={exports:{}},n=(e||(e=1,function(e){function t(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function n(e){return{subscribe:e,then:function(t,n){return new Promise(function(r,s){try{var o=null,a=!1;o=e({next:function(e){r(null==t?void 0:t(e)),o&&o.unsubscribe(),a=!0}}),a&&o&&o.unsubscribe()}catch(e){null==n?s(e):r(n(e))}})}}}function r(r,s){return s.funcNameToWrap,function(r,s){var o=s.callbackNameFunc,a=s.funcToWrap;return n(function(n){var s,i=o();return r[i]=function(t){if(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(!e)return!1;var r=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=r.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&s.unsubscribe();else{var r=t.result,o=t.error,a=t.status_code;n&&n.next&&n.next({result:null===r?void 0:r,error:null===o?void 0:o,status_code:null===a?void 0:a})}},a(i),s=t(function(){r[i]=void 0,n&&n.complete&&n.complete()})})}(r,function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&(n[r[s]]=e[r[s]])}return n}(s,["funcNameToWrap"]))}(e.StreamEvent||(e.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",e.createDataStream=n,e.createSubscription=t,e.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},e.wrapModule=function(e,t){var n;e[(n=t,"Wrapped"+n)]=function(e,t,n){return{invoke:function(s,o){return r(e,{funcNameToWrap:s,callbackNameFunc:function(){return function(e,t){var n=t.moduleName,r=t.funcName,s=0;return function(){for(var t,o,a="";(a=(t={moduleName:n,funcName:r,requestID:s}).moduleName+"_"+t.funcName+"Callback"+(null!==(o=t.requestID)?"_"+o:""))in e;)s+=1;return s+=1,a}()}(e,{moduleName:t,funcName:s})},funcToWrap:function(e){return n({callback:e,method:s,module:t,parameters:null!=o?o:{}})}})}}}(e,t,function(n){if(e[t]&&e[t][n.method]instanceof Function)e[t][n.method](JSON.stringify(n));else{if(!(e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]))throw new Error("Unexpected method '"+n.method+"' for module '"+t+"'");e.webkit.messageHandlers[t].postMessage(n)}})},Object.defineProperty(e,"__esModule",{value:!0})}(t.exports)),t.exports);function r(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function s(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function o(e,t,n,r,o){const a=o&&"input"in o?o.input:n.value,i=o?.expected??e.expects??null,c=o?.received??s(a),u={kind:e.kind,type:e.type,input:a,expected:i,received:c,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:o?.path,issues:o?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},d="schema"===e.kind,l=o?.message??e.message??(e.reference,void u.lang)??(d?void u.lang:null)??r.message??void u.lang;void 0!==l&&(u.message="function"==typeof l?l(u):l),d&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function a(e){return{version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},r())}}function i(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function c(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}function u(e,t){return{kind:"validation",type:"min_length",reference:u,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&o(this,"length",e,t,{received:`${e.value.length}`}),e}}}function d(e){return{kind:"validation",type:"url",reference:d,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&o(this,"URL",e,t),e}}}function l(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function p(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function h(e){return{kind:"schema",type:"boolean",reference:h,expects:"boolean",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"boolean"==typeof e.value?e.typed=!0:o(this,"type",e,t),e}}}function m(e,t){return{kind:"schema",type:"literal",reference:m,expects:s(e),async:!1,literal:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:o(this,"type",e,t),e}}}function f(e,t){return{kind:"schema",type:"nullable",reference:f,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return a(this)},"~run"(e,t){return null===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function v(e){return{kind:"schema",type:"number",reference:v,expects:"number",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"number"!=typeof e.value||isNaN(e.value)?o(this,"type",e,t):e.typed=!0,e}}}function y(e,t){return{kind:"schema",type:"object",reference:y,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const r in this.entries){const s=this.entries[r];if(r in n||("exact_optional"===s.type||"optional"===s.type||"nullish"===s.type)&&void 0!==s.default){const o=r in n?n[r]:p(s),a=s["~run"]({value:o},t);if(a.issues){const s={type:"object",origin:"value",input:n,key:r,value:o};for(const t of a.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value[r]=a.value}else if(void 0!==s.fallback)e.value[r]=l(s);else if("exact_optional"!==s.type&&"optional"!==s.type&&"nullish"!==s.type&&(o(this,"key",e,t,{input:void 0,expected:`"${r}"`,path:[{type:"object",origin:"key",input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else o(this,"type",e,t);return e}}}function g(e,t){return{kind:"schema",type:"optional",reference:g,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return a(this)},"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function w(e,t){return{kind:"schema",type:"picklist",reference:w,expects:c(e.map(s),"|"),async:!1,options:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:o(this,"type",e,t),e}}}function k(e,t,n){return{kind:"schema",type:"record",reference:k,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const r in n)if(i(n,r)){const s=n[r],o=this.key["~run"]({value:r},t);if(o.issues){const a={type:"object",origin:"key",input:n,key:r,value:s};for(const t of o.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}const a=this.value["~run"]({value:s},t);if(a.issues){const o={type:"object",origin:"value",input:n,key:r,value:s};for(const t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}o.typed&&a.typed||(e.typed=!1),o.typed&&(e.value[o.value]=a.value)}}else o(this,"type",e,t);return e}}}function b(e){return{kind:"schema",type:"string",reference:b,expects:"string",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"string"==typeof e.value?e.typed=!0:o(this,"type",e,t),e}}}function S(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function x(e,t){return{kind:"schema",type:"union",reference:x,expects:c(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){let n,r,s;for(const o of this.options){const a=o["~run"]({value:e.value},t);if(a.typed){if(!a.issues){n=a;break}r?r.push(a):r=[a]}else s?s.push(a):s=[a]}if(n)return n;if(r){if(1===r.length)return r[0];o(this,"type",e,t,{issues:S(r)}),e.typed=!0}else{if(1===s?.length)return s[0];o(this,"type",e,t,{issues:S(s)})}return e}}}function _(){return{kind:"schema",type:"unknown",reference:_,expects:"unknown",async:!1,get"~standard"(){return a(this)},"~run":e=>(e.typed=!0,e)}}function U(...e){return{...e[0],pipe:e,get"~standard"(){return a(this)},"~run"(t,n){for(const r of e)if("metadata"!==r.kind){if(t.issues&&("schema"===r.kind||"transformation"===r.kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=r["~run"](t,n))}return t}}}function $(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}function C(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class E{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${$(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},r(void 0));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}(e,t);return n.success?null:n.issues.map(e=>{const t=e.path?.map(e=>String(e.key)).join(".");return t?`${t}: ${e.message}`:e.message}).join(", ")}checkSupport(e){const t=C();return t?e(t)?null:{status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"}:{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}async invoke(e){const{method:t,params:n}=e;try{return C()?await this.wrappedModule.invoke(t,n):{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}catch(e){return{status_code:500,error:`Failed to invoke method: ${$(e)?e.message:"Unknown error"}`}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:n}=e;try{return C()?this.wrappedModule.invoke(t,n):this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"})}catch(e){return this.createErrorStream({status_code:500,error:`Failed to invoke method: ${$(e)?e.message:"Unknown error"}`})}}}function D(e){return 200===e.status_code||204===e.status_code}function M(e){return 200===e.status_code}function I(e){return 204===e.status_code}function A(e){return 302===e.status_code}function K(e){return 302===e.status_code}function N(e){const t=e.status_code;return 400===t||401===t||403===t||404===t||424===t||426===t}function T(e){return 500===e.status_code||501===e.status_code}function O(e){return"error"in e}const R=e=>y({status_code:m(e),error:b()}),j=e=>y({status_code:m(200),result:e}),P=y({status_code:m(204)}),B=y({status_code:m(200)}),z=y({status_code:m(302)}),L=y({title:g(b())}),G=y({qrCode:b()}),W=x([j(G),P,R(400),R(403),R(500),R(501)]);class q extends E{constructor(){super("CameraModule")}async scanQRCode(e){const t=this.validate(L,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),r=this.validate(W,n);return r&&console.warn(`[SDK:scanQRCode] Unexpected response shape: ${r}`),n}}const F=k(b(),_()),V=y({transactionID:b(),status:w(["success","failure","pending","userInitiatedCancel"]),errorMessage:g(b()),errorCode:g(b())}),H=x([j(V),R(400),R(500),R(501)]);class Q extends E{constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(F,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"triggerCheckout",params:e}),r=this.validate(H,n);return r&&console.warn(`[SDK:triggerCheckout] Unexpected response shape: ${r}`),n}}const J={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},Y={DEFAULT:"DEFAULT"},X={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},Z=x([P,R(400),R(500),R(501)]),ee=x([B,R(400),R(500),R(501)]),te=x([B,R(500),R(501)]),ne=te,re=te,se=te,oe=te,ae=te,ie=te,ce=te,ue=x([B,R(400),R(500),R(501)]),de=x([B,R(500),R(501)]),le=y({state:U(b(),u(1)),name:U(b(),u(1)),data:g(k(b(),_()))}),pe=x([B,R(400),R(500),R(501)]),he=y({connected:h()}),me=x([j(he),R(404)]),fe=y({result:b()}),ve=x([j(fe),R(500),R(501)]);class ye extends E{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(Z,t);return n&&console.warn(`[SDK:setBackgroundColor] Unexpected response shape: ${n}`),t}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(ee,t);return n&&console.warn(`[SDK:setTitle] Unexpected response shape: ${n}`),t}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(te,e);return t&&console.warn(`[SDK:hideBackButton] Unexpected response shape: ${t}`),e}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(ne,e);return t&&console.warn(`[SDK:showBackButton] Unexpected response shape: ${t}`),e}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(re,e);return t&&console.warn(`[SDK:hideRefreshButton] Unexpected response shape: ${t}`),e}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(se,e);return t&&console.warn(`[SDK:showRefreshButton] Unexpected response shape: ${t}`),e}async close(){const e=await this.invoke({method:"close"}),t=this.validate(oe,e);return t&&console.warn(`[SDK:close] Unexpected response shape: ${t}`),e}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(ae,e);return t&&console.warn(`[SDK:onContentLoaded] Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(ie,e);return t&&console.warn(`[SDK:showLoader] Unexpected response shape: ${t}`),e}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ce,e);return t&&console.warn(`[SDK:hideLoader] Unexpected response shape: ${t}`),e}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(ue,t);return n&&console.warn(`[SDK:openExternalLink] Unexpected response shape: ${n}`),t}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(de,t);return n&&console.warn(`[SDK:onCtaTap] Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(le,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}}),r=this.validate(pe,n);return r&&console.warn(`[SDK:sendAnalyticsEvent] Unexpected response shape: ${r}`),n}async isConnected(){return null!==C()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){const e=await this.invoke({method:"getSessionParams"}),t=this.validate(ve,e);return t&&console.warn(`[SDK:getSessionParams] Unexpected response shape: ${t}`),e}}const ge=h(),we=x([j(ge),R(500),R(501)]);class ke extends E{constructor(){super("DeviceCapabilityModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(we,e);return t&&console.warn(`[SDK:isEsimSupported] Unexpected response shape: ${t}`),e}}const be=y({fileUrl:U(b(),d()),fileName:U(b(),u(1))}),Se=x([P,R(400),R(500),R(501)]);class xe extends E{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(be,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),r=this.validate(Se,n);return r&&console.warn(`[SDK:downloadFile] Unexpected response shape: ${r}`),n}}function _e(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let n="";for(let r=0;r<e;r+=1)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[r]%62);return n}async function Ue(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let n="";for(let e=0;e<t.byteLength;e+=1)n+=String.fromCharCode(t[e]);return btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}function $e(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const Ce="grabid",Ee={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"};class De extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const Me=y({clientId:U(b(),u(1)),redirectUri:U(b(),d()),scope:U(b(),u(1)),environment:w(["staging","production"]),responseMode:g(w(["redirect","in_place"]))}),Ie=y({code:b(),state:b()}),Ae=x([j(Ie),P,z,R(400),R(401),R(403),R(500),R(501)]),Ke=y({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Ne=x([j(Ke),P,R(400)]),Te=P;class Oe extends E{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=Ee[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new De("Failed to fetch authorization configuration");const n=await e.json();if(!n.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new De("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof De)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=_e(16),t=_e(32),n=(r=_e(64),btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var r;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await Ue(n),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),n=this.getStorageItem("nonce"),r=this.getStorageItem("redirect_uri");return null===e&&null===t&&null===n&&null===r?{status_code:204}:null!==e&&null!==t&&null!==n&&null!==r?{status_code:200,result:{state:e,codeVerifier:t,nonce:n,redirectUri:r}}:{status_code:400,error:"Inconsistent authorization artifacts in storage"}}async clearAuthorizationArtifacts(){return window.localStorage.removeItem(`${Ce}:nonce`),window.localStorage.removeItem(`${Ce}:state`),window.localStorage.removeItem(`${Ce}:code_verifier`),window.localStorage.removeItem(`${Ce}:redirect_uri`),window.localStorage.removeItem(`${Ce}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${Ce}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${Ce}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=C();return!t||"staging"!==e.environment&&!$e(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:$(e)?e.message:"Could not fetch authorization endpoint"}}const n={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},r=Oe.buildAuthorizeUrl(t,n);return window.location.assign(r),{status_code:302}}async performNativeAuthorization(e){const t=await this.invoke({method:"authorize",params:{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode}}),n=this.validate(Ae,t);return n&&console.warn(`[SDK:authorize] Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(Me,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),r=e.responseMode||"redirect",s="in_place"===r?Oe.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...n,redirectUri:s});const o={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:n.nonce,state:n.state,codeChallenge:n.codeChallenge,codeChallengeMethod:n.codeChallengeMethod};if(Oe.shouldUseWebConsent(e))return this.performWebAuthorization({...o,environment:e.environment});try{const t=await this.performNativeAuthorization({...o,actualRedirectUri:s,responseMode:r});return 400===t.status_code||401===t.status_code||403===t.status_code||500===t.status_code||501===t.status_code?(console.error(`Native authorization returned ${t.status_code}, falling back to web flow:`,t.error),this.performWebAuthorization({...o,environment:e.environment})):t}catch(t){return console.error("Native authorization failed, falling back to web flow:",t),this.performWebAuthorization({...o,environment:e.environment})}}}const Re=b(),je=x([j(Re),R(500),R(501)]);class Pe extends E{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(je,e);return t&&console.warn(`[SDK:getLanguageLocaleIdentifier] Unexpected response shape: ${t}`),e}}const Be=y({lat:v(),lng:v()}),ze=x([j(Be),R(403),R(424),R(500),R(501)]),Le=y({countryCode:b()}),Ge=x([j(Le),R(403),R(424),R(500),R(501)]);class We extends E{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(ze,e);return t&&console.warn(`[SDK:getCoordinate] Unexpected response shape: ${t}`),e}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){const e=await this.invoke({method:"getCountryCode"}),t=this.validate(Ge,e);return t&&console.warn(`[SDK:getCountryCode] Unexpected response shape: ${t}`),e}}const qe=x([B,P,R(500),R(501)]),Fe=y({eventType:w(["started","paused","ended","error"]),data:g(k(b(),_()))}),Ve=x([j(Fe),R(500),R(501)]);class He extends E{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate(qe,t);return n&&console.warn(`[SDK:playDRMContent] Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}}const Qe=x([P,R(500),R(501)]);class Je extends E{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(Qe,e);return t&&console.warn(`[SDK:back] Unexpected response shape: ${t}`),e}}const Ye=y({email:b()}),Xe=x([j(Ye),R(400),R(403),R(426),R(500),R(501)]),Ze=y({email:U(b(),u(1)),otp:U(b(),u(1))}),et=x([B,R(400),R(403),R(426),R(500),R(501)]);class tt extends E{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>$e(e.version,tt.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(Xe,t);return n&&console.warn(`[SDK:fetchEmail] Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>$e(e.version,tt.MINIMUM_VERSION));if(t)return t;const n=this.validate(Ze,e);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"verifyEmail",params:e}),s=this.validate(et,r);return s&&console.warn(`[SDK:verifyEmail] Unexpected response shape: ${s}`),r}}tt.MINIMUM_VERSION={major:5,minor:399,patch:0};const nt=y({module:U(b(),u(1)),method:U(b(),u(1))}),rt=y({hasAccess:h()}),st=x([j(rt),R(400),R(424),R(500),R(501)]),ot=x([B,R(424),R(500),R(501)]);class at extends E{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},r=this.validate(nt,n);if(r)return{status_code:400,error:r};const s=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(st,s);return o&&console.warn(`[SDK:hasAccessTo] Unexpected response shape: ${o}`),s}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(ot,e);return t&&console.warn(`[SDK:reloadScopes] Unexpected response shape: ${t}`),e}}const it=x([P,R(400),R(403),R(500),R(501)]);class ct extends E{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(it,e);return t&&console.warn(`[SDK:dismiss] Unexpected response shape: ${t}`),e}}const ut=x([P,R(400),R(500),R(501)]),dt=y({key:U(b(),u(1))}),lt=ut,pt=dt,ht=y({value:f(h())}),mt=x([j(ht),R(400),R(500),R(501)]),ft=ut,vt=dt,yt=y({value:f(v())}),gt=x([j(yt),R(400),R(500),R(501)]),wt=ut,kt=dt,bt=y({value:f(b())}),St=x([j(bt),R(400),R(500),R(501)]),xt=ut,_t=dt,Ut=y({value:f(v())}),$t=x([j(Ut),R(400),R(500),R(501)]),Ct=dt,Et=ut,Dt=x([P,R(500),R(501)]);class Mt extends E{constructor(){super("StorageModule")}async setBoolean(e,t){const n=await this.invoke({method:"setBoolean",params:{key:e,value:t}}),r=this.validate(lt,n);return r&&console.warn(`[SDK:setBoolean] Unexpected response shape: ${r}`),n}async getBoolean(e){const t={key:e},n=this.validate(pt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getBoolean",params:t}),s=this.validate(mt,r);return s&&console.warn(`[SDK:getBoolean] Unexpected response shape: ${s}`),r}async setInt(e,t){const n=await this.invoke({method:"setInt",params:{key:e,value:t}}),r=this.validate(ft,n);return r&&console.warn(`[SDK:setInt] Unexpected response shape: ${r}`),n}async getInt(e){const t={key:e},n=this.validate(vt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getInt",params:t}),s=this.validate(gt,r);return s&&console.warn(`[SDK:getInt] Unexpected response shape: ${s}`),r}async setString(e,t){const n=await this.invoke({method:"setString",params:{key:e,value:t}}),r=this.validate(wt,n);return r&&console.warn(`[SDK:setString] Unexpected response shape: ${r}`),n}async getString(e){const t={key:e},n=this.validate(kt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getString",params:t}),s=this.validate(St,r);return s&&console.warn(`[SDK:getString] Unexpected response shape: ${s}`),r}async setDouble(e,t){const n=await this.invoke({method:"setDouble",params:{key:e,value:t}}),r=this.validate(xt,n);return r&&console.warn(`[SDK:setDouble] Unexpected response shape: ${r}`),n}async getDouble(e){const t={key:e},n=this.validate(_t,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getDouble",params:t}),s=this.validate($t,r);return s&&console.warn(`[SDK:getDouble] Unexpected response shape: ${s}`),r}async remove(e){const t={key:e},n=this.validate(Ct,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"remove",params:t}),s=this.validate(Et,r);return s&&console.warn(`[SDK:remove] Unexpected response shape: ${s}`),r}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(Dt,e);return t&&console.warn(`[SDK:removeAll] Unexpected response shape: ${t}`),e}}const It=y({url:U(b(),d())}),At=x([B,R(400),R(424),R(500),R(501)]);class Kt extends E{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(It,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),r=this.validate(At,n);return r&&console.warn(`[SDK:redirectToSystemWebView] Unexpected response shape: ${r}`),n}}const Nt=b(),Tt=x([j(Nt),P,R(500),R(501)]);class Ot extends E{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(Tt,e);return t&&console.warn(`[SDK:getSelectedTravelDestination] Unexpected response shape: ${t}`),e}}export{Me as AuthorizeRequestSchema,Ae as AuthorizeResponseSchema,Ie as AuthorizeResultSchema,Qe as BackResponseSchema,E as BaseModule,q as CameraModule,Q as CheckoutModule,Te as ClearAuthorizationArtifactsResponseSchema,oe as CloseResponseSchema,X as ContainerAnalyticsEventData,Y as ContainerAnalyticsEventName,J as ContainerAnalyticsEventState,ye as ContainerModule,Fe as DRMPlaybackEventSchema,ke as DeviceCapabilityModule,it as DismissSplashScreenResponseSchema,be as DownloadFileRequestSchema,Se as DownloadFileResponseSchema,Xe as FetchEmailResponseSchema,Ye as FetchEmailResultSchema,xe as FileModule,Ne as GetAuthorizationArtifactsResponseSchema,Ke as GetAuthorizationArtifactsResultSchema,pt as GetBooleanRequestSchema,mt as GetBooleanResponseSchema,ht as GetBooleanResultSchema,ze as GetCoordinateResponseSchema,Be as GetCoordinateResultSchema,Ge as GetCountryCodeResponseSchema,Le as GetCountryCodeResultSchema,_t as GetDoubleRequestSchema,$t as GetDoubleResponseSchema,Ut as GetDoubleResultSchema,vt as GetIntRequestSchema,gt as GetIntResponseSchema,yt as GetIntResultSchema,je as GetLanguageLocaleIdentifierResponseSchema,Re as GetLanguageLocaleIdentifierResultSchema,Tt as GetSelectedTravelDestinationResponseSchema,Nt as GetSelectedTravelDestinationResultSchema,ve as GetSessionParamsResponseSchema,fe as GetSessionParamsResultSchema,kt as GetStringRequestSchema,St as GetStringResponseSchema,bt as GetStringResultSchema,nt as HasAccessToRequestSchema,st as HasAccessToResponseSchema,rt as HasAccessToResultSchema,te as HideBackButtonResponseSchema,ce as HideLoaderResponseSchema,re as HideRefreshButtonResponseSchema,Oe as IdentityModule,me as IsConnectedResponseSchema,he as IsConnectedResultSchema,we as IsEsimSupportedResponseSchema,ge as IsEsimSupportedResultSchema,Pe as LocaleModule,We as LocationModule,He as MediaModule,Ve as ObserveDRMPlaybackResponseSchema,ae as OnContentLoadedResponseSchema,de as OnCtaTapResponseSchema,ue as OpenExternalLinkResponseSchema,Je as PlatformModule,qe as PlayDRMContentResponseSchema,tt as ProfileModule,It as RedirectToSystemWebViewRequestSchema,At as RedirectToSystemWebViewResponseSchema,ot as ReloadScopesResponseSchema,Dt as RemoveAllResponseSchema,Et as RemoveResponseSchema,L as ScanQRCodeRequestSchema,W as ScanQRCodeResponseSchema,G as ScanQRCodeResultSchema,at as ScopeModule,le as SendAnalyticsEventRequestSchema,pe as SendAnalyticsEventResponseSchema,Z as SetBackgroundColorResponseSchema,lt as SetBooleanResponseSchema,xt as SetDoubleResponseSchema,ft as SetIntResponseSchema,wt as SetStringResponseSchema,ee as SetTitleResponseSchema,ne as ShowBackButtonResponseSchema,ie as ShowLoaderResponseSchema,se as ShowRefreshButtonResponseSchema,ct as SplashScreenModule,Mt as StorageModule,Kt as SystemWebViewKitModule,F as TriggerCheckoutRequestSchema,H as TriggerCheckoutResponseSchema,V as TriggerCheckoutResultSchema,Ot as UserAttributesModule,Ze as VerifyEmailRequestSchema,et as VerifyEmailResponseSchema,N as isClientError,O as isError,K as isFound,I as isNoContent,M as isOk,A as isRedirection,T as isServerError,D as isSuccess};
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the LICENSE file in the root
|
|
5
5
|
* directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SuperAppSDK={})}(this,function(e){"use strict";var t,r={exports:{}},n=(t||(t=1,function(e){function t(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function r(e){return{subscribe:e,then:function(t,r){return new Promise(function(n,o){try{var a=null,i=!1;a=e({next:function(e){n(null==t?void 0:t(e)),a&&a.unsubscribe(),i=!0}}),i&&a&&a.unsubscribe()}catch(e){null==r?o(e):n(r(e))}})}}}function n(n,o){return o.funcNameToWrap,function(n,o){var a=o.callbackNameFunc,i=o.funcToWrap;return r(function(r){var o,s=a();return n[s]=function(t){if(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(!e)return!1;var n=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=n.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&o.unsubscribe();else{var n=t.result,a=t.error,i=t.status_code;r&&r.next&&r.next({result:null===n?void 0:n,error:null===a?void 0:a,status_code:null===i?void 0:i})}},i(s),o=t(function(){n[s]=void 0,r&&r.complete&&r.complete()})})}(n,function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r}(o,["funcNameToWrap"]))}(e.StreamEvent||(e.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",e.createDataStream=r,e.createSubscription=t,e.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},e.wrapModule=function(e,t){var r;e[(r=t,"Wrapped"+r)]=function(e,t,r){return{invoke:function(o,a){return n(e,{funcNameToWrap:o,callbackNameFunc:function(){return function(e,t){var r=t.moduleName,n=t.funcName,o=0;return function(){for(var t,a,i="";(i=(t={moduleName:r,funcName:n,requestID:o}).moduleName+"_"+t.funcName+"Callback"+(null!==(a=t.requestID)?"_"+a:""))in e;)o+=1;return o+=1,i}()}(e,{moduleName:t,funcName:o})},funcToWrap:function(e){return r({callback:e,method:o,module:t,parameters:null!=a?a:{}})}})}}}(e,t,function(r){if(e[t]&&e[t][r.method]instanceof Function)e[t][r.method](JSON.stringify(r));else{if(!(e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]))throw new Error("Unexpected method '"+r.method+"' for module '"+t+"'");e.webkit.messageHandlers[t].postMessage(r)}})},Object.defineProperty(e,"__esModule",{value:!0})}(r.exports)),r.exports);function o(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}function a(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class i{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${o(e)&&`: ${e.message}`}`,{cause:e})}}async invoke(e){const{method:t,params:r,isSupported:n,transformResponse:o}=e;try{const e=a();if(!e)return{status_code:501,error:"Not implemented: This method requires the Grab app environment"};if(n&&!n(e))return{status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"};const i=await this.wrappedModule.invoke(t,r);return o?o(i):i}catch{return{status_code:500,error:"Failed to invoke method"}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:r,isSupported:n,transformResponse:o}=e;try{const e=a();if(!e)return this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"});if(n&&!n(e))return this.createErrorStream({status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"});const i=this.wrappedModule.invoke(t,r);return o?{subscribe:e=>i.subscribe({next:t=>e?.next?.(o(t)),complete:e?.complete}),then:e=>i.then(t=>e?e(o(t)):o(t))}:i}catch{return this.createErrorStream({status_code:500,error:"Failed to invoke method"})}}}function s(e){return 400===e.status_code||401===e.status_code||403===e.status_code||404===e.status_code||424===e.status_code||426===e.status_code}function c(e){return 500===e.status_code||501===e.status_code}function u(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let r="";for(let n=0;n<e;n+=1)r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[n]%62);return r}async function d(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let r="";for(let e=0;e<t.byteLength;e+=1)r+=String.fromCharCode(t[e]);return btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}function l(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const h="grabid",m={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"};class p extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}class f extends i{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=m[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new p("Failed to fetch authorization configuration");const r=await e.json();if(!r.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new p("Invalid authorization configuration");return r.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof p)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=u(16),t=u(7),r=(n=u(64),btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var n;return{nonce:e,state:t,codeVerifier:r,codeChallenge:await d(r),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),r=this.getStorageItem("nonce"),n=this.getStorageItem("redirect_uri"),o=[e,t,r,n].filter(e=>null!==e).length;return 4===o?{status_code:200,result:{state:e,codeVerifier:t,nonce:r,redirectUri:n}}:0===o?{status_code:204}:{status_code:400,error:"Inconsistent authorization artifacts in storage"}}async clearAuthorizationArtifacts(){return window.localStorage.removeItem(`${h}:nonce`),window.localStorage.removeItem(`${h}:state`),window.localStorage.removeItem(`${h}:code_verifier`),window.localStorage.removeItem(`${h}:redirect_uri`),window.localStorage.removeItem(`${h}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${h}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${h}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=a();return!t||"staging"!==e.environment&&!l(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:o(e)?e.message:"Could not fetch authorization endpoint"}}const r={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},n=f.buildAuthorizeUrl(t,r);return window.location.assign(n),{status_code:302}}async performNativeAuthorization(e){return await this.invoke({method:"authorize",params:{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode}})}async authorize(e){const t=f.validateAuthorizeRequest(e);if(t)return{status_code:400,error:t};const r=await this.generatePKCEArtifacts(),n=e.responseMode||"redirect",o="in_place"===n?f.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...r,redirectUri:o});const a={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:r.nonce,state:r.state,codeChallenge:r.codeChallenge,codeChallengeMethod:r.codeChallengeMethod};if(f.shouldUseWebConsent(e))return this.performWebAuthorization({...a,environment:e.environment});try{const t=await this.performNativeAuthorization({...a,actualRedirectUri:o,responseMode:n});return 400===t.status_code||401===t.status_code||403===t.status_code||500===t.status_code||501===t.status_code?(console.error(`Native authorization returned ${t.status_code}, falling back to web flow:`,t.error),this.performWebAuthorization({...a,environment:e.environment})):t}catch(t){return console.error("Native authorization failed, falling back to web flow:",t),this.performWebAuthorization({...a,environment:e.environment})}}static validateRequiredString(e,t){return e&&"string"==typeof e&&""!==e.trim()?null:`${t} is required and must be a non-empty string`}static validateAuthorizeRequest(e){if(null==e)return"request is required";const t=f.validateRequiredString(e.scope,"scope");if(t)return t;const r=f.validateRequiredString(e.clientId,"clientId");if(r)return r;const n=f.validateRequiredString(e.redirectUri,"redirectUri");if(n)return n;try{if(!new URL(e.redirectUri))return"redirectUri must be a valid URL"}catch{return"redirectUri must be a valid URL"}return f.validateRequiredString(e.environment,"environment")||("staging"!==e.environment&&"production"!==e.environment?"environment must be either 'staging' or 'production'":null)}}class g extends i{constructor(){super("ProfileModule")}async fetchEmail(){return await this.invoke({method:"fetchEmail",isSupported:e=>l(e.version,g.MINIMUM_VERSION)})}async verifyEmail(e){return await this.invoke({method:"verifyEmail",params:e,isSupported:e=>l(e.version,g.MINIMUM_VERSION)})}}g.MINIMUM_VERSION={major:5,minor:399,patch:0},e.BaseModule=i,e.CameraModule=class extends i{constructor(){super("CameraModule")}async scanQRCode(e){return await this.invoke({method:"scanQRCode",params:e})}},e.CheckoutModule=class extends i{constructor(){super("CheckoutModule")}async triggerCheckout(e){return await this.invoke({method:"triggerCheckout",params:e})}},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=class extends i{constructor(){super("ContainerModule")}async setBackgroundColor(e){return await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}})}async setTitle(e){return await this.invoke({method:"setTitle",params:{title:e}})}async hideBackButton(){return await this.invoke({method:"hideBackButton"})}async showBackButton(){return await this.invoke({method:"showBackButton"})}async hideRefreshButton(){return await this.invoke({method:"hideRefreshButton"})}async showRefreshButton(){return await this.invoke({method:"showRefreshButton"})}async close(){return await this.invoke({method:"close"})}async onContentLoaded(){return await this.invoke({method:"onContentLoaded"})}async showLoader(){return await this.invoke({method:"showLoader"})}async hideLoader(){return await this.invoke({method:"hideLoader"})}async openExternalLink(e){return await this.invoke({method:"openExternalLink",params:{url:e}})}async onCtaTap(e){return await this.invoke({method:"onCtaTap",params:{action:e}})}async sendAnalyticsEvent(e){const t=this.validateAnalyticsEvent(e);return t?{status_code:400,error:t}:await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}})}async isConnected(){return null!==a()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){return await this.invoke({method:"getSessionParams"})}validateAnalyticsEvent(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"!=typeof e.data?"data must be undefined or an object":null}},e.DeviceCapabilityModule=class extends i{constructor(){super("DeviceCapabilityModule")}async isEsimSupported(){return await this.invoke({method:"isEsimSupported"})}},e.FileModule=class extends i{constructor(){super("FileModule")}async downloadFile(e){return await this.invoke({method:"downloadFile",params:e})}},e.IdentityModule=f,e.LocaleModule=class extends i{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){return await this.invoke({method:"getLanguageLocaleIdentifier"})}},e.LocationModule=class extends i{constructor(){super("LocationModule")}async getCoordinate(){return await this.invoke({method:"getCoordinate"})}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){return await this.invoke({method:"getCountryCode"})}},e.MediaModule=class extends i{constructor(){super("MediaModule")}async playDRMContent(e){return await this.invoke({method:"playDRMContent",params:{data:e}})}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}},e.PlatformModule=class extends i{constructor(){super("PlatformModule")}async back(){return await this.invoke({method:"back"})}},e.ProfileModule=g,e.ScopeModule=class extends i{constructor(){super("ScopeModule")}async hasAccessTo(e,t){return await this.invoke({method:"hasAccessTo",params:{module:e,method:t}})}async reloadScopes(){return await this.invoke({method:"reloadScopes"})}},e.StorageModule=class extends i{constructor(){super("StorageModule")}async setBoolean(e,t){return await this.invoke({method:"setBoolean",params:{key:e,value:t}})}async getBoolean(e){return await this.invoke({method:"getBoolean",params:{key:e}})}async setInt(e,t){return await this.invoke({method:"setInt",params:{key:e,value:t}})}async getInt(e){return await this.invoke({method:"getInt",params:{key:e}})}async setString(e,t){return await this.invoke({method:"setString",params:{key:e,value:t}})}async getString(e){return await this.invoke({method:"getString",params:{key:e}})}async setDouble(e,t){return await this.invoke({method:"setDouble",params:{key:e,value:t}})}async getDouble(e){return await this.invoke({method:"getDouble",params:{key:e}})}async remove(e){return await this.invoke({method:"remove",params:{key:e}})}async removeAll(){return await this.invoke({method:"removeAll"})}},e.SystemWebViewKitModule=class extends i{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){return await this.invoke({method:"redirectToSystemWebView",params:e})}},e.UserAttributesModule=class extends i{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){return await this.invoke({method:"getSelectedTravelDestination"})}},e.isClientError=s,e.isErrorResponse=function(e){return s(e)||c(e)},e.isRedirection=function(e){return 302===e.status_code},e.isServerError=c,e.isSuccess=function(e){return 200===e.status_code||204===e.status_code}});
|
|
7
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SuperAppSDK={})}(this,function(e){"use strict";var t,n={exports:{}},s=(t||(t=1,function(e){function t(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function n(e){return{subscribe:e,then:function(t,n){return new Promise(function(s,o){try{var r=null,a=!1;r=e({next:function(e){s(null==t?void 0:t(e)),r&&r.unsubscribe(),a=!0}}),a&&r&&r.unsubscribe()}catch(e){null==n?o(e):s(n(e))}})}}}function s(s,o){return o.funcNameToWrap,function(s,o){var r=o.callbackNameFunc,a=o.funcToWrap;return n(function(n){var o,i=r();return s[i]=function(t){if(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(!e)return!1;var s=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=s.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&o.unsubscribe();else{var s=t.result,r=t.error,a=t.status_code;n&&n.next&&n.next({result:null===s?void 0:s,error:null===r?void 0:r,status_code:null===a?void 0:a})}},a(i),o=t(function(){s[i]=void 0,n&&n.complete&&n.complete()})})}(s,function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&(n[s[o]]=e[s[o]])}return n}(o,["funcNameToWrap"]))}(e.StreamEvent||(e.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",e.createDataStream=n,e.createSubscription=t,e.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},e.wrapModule=function(e,t){var n;e[(n=t,"Wrapped"+n)]=function(e,t,n){return{invoke:function(o,r){return s(e,{funcNameToWrap:o,callbackNameFunc:function(){return function(e,t){var n=t.moduleName,s=t.funcName,o=0;return function(){for(var t,r,a="";(a=(t={moduleName:n,funcName:s,requestID:o}).moduleName+"_"+t.funcName+"Callback"+(null!==(r=t.requestID)?"_"+r:""))in e;)o+=1;return o+=1,a}()}(e,{moduleName:t,funcName:o})},funcToWrap:function(e){return n({callback:e,method:o,module:t,parameters:null!=r?r:{}})}})}}}(e,t,function(n){if(e[t]&&e[t][n.method]instanceof Function)e[t][n.method](JSON.stringify(n));else{if(!(e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]))throw new Error("Unexpected method '"+n.method+"' for module '"+t+"'");e.webkit.messageHandlers[t].postMessage(n)}})},Object.defineProperty(e,"__esModule",{value:!0})}(n.exports)),n.exports);function o(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function r(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function a(e,t,n,s,o){const a=o&&"input"in o?o.input:n.value,i=o?.expected??e.expects??null,c=o?.received??r(a),u={kind:e.kind,type:e.type,input:a,expected:i,received:c,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:o?.path,issues:o?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},d="schema"===e.kind,l=o?.message??e.message??(e.reference,void u.lang)??(d?void u.lang:null)??s.message??void u.lang;void 0!==l&&(u.message="function"==typeof l?l(u):l),d&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function i(e){return{version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},o())}}function c(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function u(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}function d(e,t){return{kind:"validation",type:"min_length",reference:d,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&a(this,"length",e,t,{received:`${e.value.length}`}),e}}}function l(e){return{kind:"validation",type:"url",reference:l,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&a(this,"URL",e,t),e}}}function h(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function p(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function m(e){return{kind:"schema",type:"boolean",reference:m,expects:"boolean",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"boolean"==typeof e.value?e.typed=!0:a(this,"type",e,t),e}}}function f(e,t){return{kind:"schema",type:"literal",reference:f,expects:r(e),async:!1,literal:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:a(this,"type",e,t),e}}}function v(e,t){return{kind:"schema",type:"nullable",reference:v,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return null===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function y(e){return{kind:"schema",type:"number",reference:y,expects:"number",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"number"!=typeof e.value||isNaN(e.value)?a(this,"type",e,t):e.typed=!0,e}}}function g(e,t){return{kind:"schema",type:"object",reference:g,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const s in this.entries){const o=this.entries[s];if(s in n||("exact_optional"===o.type||"optional"===o.type||"nullish"===o.type)&&void 0!==o.default){const r=s in n?n[s]:p(o),a=o["~run"]({value:r},t);if(a.issues){const o={type:"object",origin:"value",input:n,key:s,value:r};for(const t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value[s]=a.value}else if(void 0!==o.fallback)e.value[s]=h(o);else if("exact_optional"!==o.type&&"optional"!==o.type&&"nullish"!==o.type&&(a(this,"key",e,t,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:n,key:s,value:n[s]}]}),t.abortEarly))break}}else a(this,"type",e,t);return e}}}function S(e,t){return{kind:"schema",type:"optional",reference:S,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function w(e,t){return{kind:"schema",type:"picklist",reference:w,expects:u(e.map(r),"|"),async:!1,options:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:a(this,"type",e,t),e}}}function b(e,t,n){return{kind:"schema",type:"record",reference:b,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return i(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const s in n)if(c(n,s)){const o=n[s],r=this.key["~run"]({value:s},t);if(r.issues){const a={type:"object",origin:"key",input:n,key:s,value:o};for(const t of r.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=r.issues),t.abortEarly){e.typed=!1;break}}const a=this.value["~run"]({value:o},t);if(a.issues){const r={type:"object",origin:"value",input:n,key:s,value:o};for(const t of a.issues)t.path?t.path.unshift(r):t.path=[r],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}r.typed&&a.typed||(e.typed=!1),r.typed&&(e.value[r.value]=a.value)}}else a(this,"type",e,t);return e}}}function k(e){return{kind:"schema",type:"string",reference:k,expects:"string",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"string"==typeof e.value?e.typed=!0:a(this,"type",e,t),e}}}function R(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function C(e,t){return{kind:"schema",type:"union",reference:C,expects:u(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){let n,s,o;for(const r of this.options){const a=r["~run"]({value:e.value},t);if(a.typed){if(!a.issues){n=a;break}s?s.push(a):s=[a]}else o?o.push(a):o=[a]}if(n)return n;if(s){if(1===s.length)return s[0];a(this,"type",e,t,{issues:R(s)}),e.typed=!0}else{if(1===o?.length)return o[0];a(this,"type",e,t,{issues:R(o)})}return e}}}function x(){return{kind:"schema",type:"unknown",reference:x,expects:"unknown",async:!1,get"~standard"(){return i(this)},"~run":e=>(e.typed=!0,e)}}function _(...e){return{...e[0],pipe:e,get"~standard"(){return i(this)},"~run"(t,n){for(const s of e)if("metadata"!==s.kind){if(t.issues&&("schema"===s.kind||"transformation"===s.kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=s["~run"](t,n))}return t}}}function E(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}function M(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class U{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,!this.wrappedModule)try{s.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${E(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},o(void 0));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}(e,t);return n.success?null:n.issues.map(e=>{const t=e.path?.map(e=>String(e.key)).join(".");return t?`${t}: ${e.message}`:e.message}).join(", ")}checkSupport(e){const t=M();return t?e(t)?null:{status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"}:{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}async invoke(e){const{method:t,params:n}=e;try{return M()?await this.wrappedModule.invoke(t,n):{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}catch(e){return{status_code:500,error:`Failed to invoke method: ${E(e)?e.message:"Unknown error"}`}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:n}=e;try{return M()?this.wrappedModule.invoke(t,n):this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"})}catch(e){return this.createErrorStream({status_code:500,error:`Failed to invoke method: ${E(e)?e.message:"Unknown error"}`})}}}const D=e=>g({status_code:f(e),error:k()}),$=e=>g({status_code:f(200),result:e}),I=g({status_code:f(204)}),A=g({status_code:f(200)}),T=g({status_code:f(302)}),K=g({title:S(k())}),N=g({qrCode:k()}),O=C([$(N),I,D(400),D(403),D(500),D(501)]),B=b(k(),x()),G=g({transactionID:k(),status:w(["success","failure","pending","userInitiatedCancel"]),errorMessage:S(k()),errorCode:S(k())}),L=C([$(G),D(400),D(500),D(501)]),P=C([I,D(400),D(500),D(501)]),z=C([A,D(400),D(500),D(501)]),j=C([A,D(500),D(501)]),q=j,F=j,W=j,V=j,H=j,Q=j,J=j,Y=C([A,D(400),D(500),D(501)]),X=C([A,D(500),D(501)]),Z=g({state:_(k(),d(1)),name:_(k(),d(1)),data:S(b(k(),x()))}),ee=C([A,D(400),D(500),D(501)]),te=g({connected:m()}),ne=C([$(te),D(404)]),se=g({result:k()}),oe=C([$(se),D(500),D(501)]),re=m(),ae=C([$(re),D(500),D(501)]),ie=g({fileUrl:_(k(),l()),fileName:_(k(),d(1))}),ce=C([I,D(400),D(500),D(501)]);function ue(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let n="";for(let s=0;s<e;s+=1)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[s]%62);return n}async function de(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let n="";for(let e=0;e<t.byteLength;e+=1)n+=String.fromCharCode(t[e]);return btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}function le(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const he="grabid",pe={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"};class me extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const fe=g({clientId:_(k(),d(1)),redirectUri:_(k(),l()),scope:_(k(),d(1)),environment:w(["staging","production"]),responseMode:S(w(["redirect","in_place"]))}),ve=g({code:k(),state:k()}),ye=C([$(ve),I,T,D(400),D(401),D(403),D(500),D(501)]),ge=g({state:k(),codeVerifier:k(),nonce:k(),redirectUri:k()}),Se=C([$(ge),I,D(400)]),we=I;class be extends U{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=pe[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new me("Failed to fetch authorization configuration");const n=await e.json();if(!n.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new me("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof me)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=ue(16),t=ue(32),n=(s=ue(64),btoa(s).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var s;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await de(n),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),n=this.getStorageItem("nonce"),s=this.getStorageItem("redirect_uri");return null===e&&null===t&&null===n&&null===s?{status_code:204}:null!==e&&null!==t&&null!==n&&null!==s?{status_code:200,result:{state:e,codeVerifier:t,nonce:n,redirectUri:s}}:{status_code:400,error:"Inconsistent authorization artifacts in storage"}}async clearAuthorizationArtifacts(){return window.localStorage.removeItem(`${he}:nonce`),window.localStorage.removeItem(`${he}:state`),window.localStorage.removeItem(`${he}:code_verifier`),window.localStorage.removeItem(`${he}:redirect_uri`),window.localStorage.removeItem(`${he}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${he}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${he}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=M();return!t||"staging"!==e.environment&&!le(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:E(e)?e.message:"Could not fetch authorization endpoint"}}const n={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},s=be.buildAuthorizeUrl(t,n);return window.location.assign(s),{status_code:302}}async performNativeAuthorization(e){const t=await this.invoke({method:"authorize",params:{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode}}),n=this.validate(ye,t);return n&&console.warn(`[SDK:authorize] Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(fe,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),s=e.responseMode||"redirect",o="in_place"===s?be.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...n,redirectUri:o});const r={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:n.nonce,state:n.state,codeChallenge:n.codeChallenge,codeChallengeMethod:n.codeChallengeMethod};if(be.shouldUseWebConsent(e))return this.performWebAuthorization({...r,environment:e.environment});try{const t=await this.performNativeAuthorization({...r,actualRedirectUri:o,responseMode:s});return 400===t.status_code||401===t.status_code||403===t.status_code||500===t.status_code||501===t.status_code?(console.error(`Native authorization returned ${t.status_code}, falling back to web flow:`,t.error),this.performWebAuthorization({...r,environment:e.environment})):t}catch(t){return console.error("Native authorization failed, falling back to web flow:",t),this.performWebAuthorization({...r,environment:e.environment})}}}const ke=k(),Re=C([$(ke),D(500),D(501)]),Ce=g({lat:y(),lng:y()}),xe=C([$(Ce),D(403),D(424),D(500),D(501)]),_e=g({countryCode:k()}),Ee=C([$(_e),D(403),D(424),D(500),D(501)]),Me=C([A,I,D(500),D(501)]),Ue=g({eventType:w(["started","paused","ended","error"]),data:S(b(k(),x()))}),De=C([$(Ue),D(500),D(501)]),$e=C([I,D(500),D(501)]),Ie=g({email:k()}),Ae=C([$(Ie),D(400),D(403),D(426),D(500),D(501)]),Te=g({email:_(k(),d(1)),otp:_(k(),d(1))}),Ke=C([A,D(400),D(403),D(426),D(500),D(501)]);class Ne extends U{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>le(e.version,Ne.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(Ae,t);return n&&console.warn(`[SDK:fetchEmail] Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>le(e.version,Ne.MINIMUM_VERSION));if(t)return t;const n=this.validate(Te,e);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"verifyEmail",params:e}),o=this.validate(Ke,s);return o&&console.warn(`[SDK:verifyEmail] Unexpected response shape: ${o}`),s}}Ne.MINIMUM_VERSION={major:5,minor:399,patch:0};const Oe=g({module:_(k(),d(1)),method:_(k(),d(1))}),Be=g({hasAccess:m()}),Ge=C([$(Be),D(400),D(424),D(500),D(501)]),Le=C([A,D(424),D(500),D(501)]),Pe=C([I,D(400),D(403),D(500),D(501)]),ze=C([I,D(400),D(500),D(501)]),je=g({key:_(k(),d(1))}),qe=ze,Fe=je,We=g({value:v(m())}),Ve=C([$(We),D(400),D(500),D(501)]),He=ze,Qe=je,Je=g({value:v(y())}),Ye=C([$(Je),D(400),D(500),D(501)]),Xe=ze,Ze=je,et=g({value:v(k())}),tt=C([$(et),D(400),D(500),D(501)]),nt=ze,st=je,ot=g({value:v(y())}),rt=C([$(ot),D(400),D(500),D(501)]),at=je,it=ze,ct=C([I,D(500),D(501)]),ut=g({url:_(k(),l())}),dt=C([A,D(400),D(424),D(500),D(501)]),lt=k(),ht=C([$(lt),I,D(500),D(501)]);e.AuthorizeRequestSchema=fe,e.AuthorizeResponseSchema=ye,e.AuthorizeResultSchema=ve,e.BackResponseSchema=$e,e.BaseModule=U,e.CameraModule=class extends U{constructor(){super("CameraModule")}async scanQRCode(e){const t=this.validate(K,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),s=this.validate(O,n);return s&&console.warn(`[SDK:scanQRCode] Unexpected response shape: ${s}`),n}},e.CheckoutModule=class extends U{constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(B,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"triggerCheckout",params:e}),s=this.validate(L,n);return s&&console.warn(`[SDK:triggerCheckout] Unexpected response shape: ${s}`),n}},e.ClearAuthorizationArtifactsResponseSchema=we,e.CloseResponseSchema=V,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=class extends U{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(P,t);return n&&console.warn(`[SDK:setBackgroundColor] Unexpected response shape: ${n}`),t}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(z,t);return n&&console.warn(`[SDK:setTitle] Unexpected response shape: ${n}`),t}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(j,e);return t&&console.warn(`[SDK:hideBackButton] Unexpected response shape: ${t}`),e}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(q,e);return t&&console.warn(`[SDK:showBackButton] Unexpected response shape: ${t}`),e}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(F,e);return t&&console.warn(`[SDK:hideRefreshButton] Unexpected response shape: ${t}`),e}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(W,e);return t&&console.warn(`[SDK:showRefreshButton] Unexpected response shape: ${t}`),e}async close(){const e=await this.invoke({method:"close"}),t=this.validate(V,e);return t&&console.warn(`[SDK:close] Unexpected response shape: ${t}`),e}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(H,e);return t&&console.warn(`[SDK:onContentLoaded] Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(Q,e);return t&&console.warn(`[SDK:showLoader] Unexpected response shape: ${t}`),e}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(J,e);return t&&console.warn(`[SDK:hideLoader] Unexpected response shape: ${t}`),e}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(Y,t);return n&&console.warn(`[SDK:openExternalLink] Unexpected response shape: ${n}`),t}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(X,t);return n&&console.warn(`[SDK:onCtaTap] Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(Z,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}}),s=this.validate(ee,n);return s&&console.warn(`[SDK:sendAnalyticsEvent] Unexpected response shape: ${s}`),n}async isConnected(){return null!==M()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){const e=await this.invoke({method:"getSessionParams"}),t=this.validate(oe,e);return t&&console.warn(`[SDK:getSessionParams] Unexpected response shape: ${t}`),e}},e.DRMPlaybackEventSchema=Ue,e.DeviceCapabilityModule=class extends U{constructor(){super("DeviceCapabilityModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(ae,e);return t&&console.warn(`[SDK:isEsimSupported] Unexpected response shape: ${t}`),e}},e.DismissSplashScreenResponseSchema=Pe,e.DownloadFileRequestSchema=ie,e.DownloadFileResponseSchema=ce,e.FetchEmailResponseSchema=Ae,e.FetchEmailResultSchema=Ie,e.FileModule=class extends U{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(ie,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),s=this.validate(ce,n);return s&&console.warn(`[SDK:downloadFile] Unexpected response shape: ${s}`),n}},e.GetAuthorizationArtifactsResponseSchema=Se,e.GetAuthorizationArtifactsResultSchema=ge,e.GetBooleanRequestSchema=Fe,e.GetBooleanResponseSchema=Ve,e.GetBooleanResultSchema=We,e.GetCoordinateResponseSchema=xe,e.GetCoordinateResultSchema=Ce,e.GetCountryCodeResponseSchema=Ee,e.GetCountryCodeResultSchema=_e,e.GetDoubleRequestSchema=st,e.GetDoubleResponseSchema=rt,e.GetDoubleResultSchema=ot,e.GetIntRequestSchema=Qe,e.GetIntResponseSchema=Ye,e.GetIntResultSchema=Je,e.GetLanguageLocaleIdentifierResponseSchema=Re,e.GetLanguageLocaleIdentifierResultSchema=ke,e.GetSelectedTravelDestinationResponseSchema=ht,e.GetSelectedTravelDestinationResultSchema=lt,e.GetSessionParamsResponseSchema=oe,e.GetSessionParamsResultSchema=se,e.GetStringRequestSchema=Ze,e.GetStringResponseSchema=tt,e.GetStringResultSchema=et,e.HasAccessToRequestSchema=Oe,e.HasAccessToResponseSchema=Ge,e.HasAccessToResultSchema=Be,e.HideBackButtonResponseSchema=j,e.HideLoaderResponseSchema=J,e.HideRefreshButtonResponseSchema=F,e.IdentityModule=be,e.IsConnectedResponseSchema=ne,e.IsConnectedResultSchema=te,e.IsEsimSupportedResponseSchema=ae,e.IsEsimSupportedResultSchema=re,e.LocaleModule=class extends U{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Re,e);return t&&console.warn(`[SDK:getLanguageLocaleIdentifier] Unexpected response shape: ${t}`),e}},e.LocationModule=class extends U{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(xe,e);return t&&console.warn(`[SDK:getCoordinate] Unexpected response shape: ${t}`),e}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){const e=await this.invoke({method:"getCountryCode"}),t=this.validate(Ee,e);return t&&console.warn(`[SDK:getCountryCode] Unexpected response shape: ${t}`),e}},e.MediaModule=class extends U{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate(Me,t);return n&&console.warn(`[SDK:playDRMContent] Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}},e.ObserveDRMPlaybackResponseSchema=De,e.OnContentLoadedResponseSchema=H,e.OnCtaTapResponseSchema=X,e.OpenExternalLinkResponseSchema=Y,e.PlatformModule=class extends U{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate($e,e);return t&&console.warn(`[SDK:back] Unexpected response shape: ${t}`),e}},e.PlayDRMContentResponseSchema=Me,e.ProfileModule=Ne,e.RedirectToSystemWebViewRequestSchema=ut,e.RedirectToSystemWebViewResponseSchema=dt,e.ReloadScopesResponseSchema=Le,e.RemoveAllResponseSchema=ct,e.RemoveResponseSchema=it,e.ScanQRCodeRequestSchema=K,e.ScanQRCodeResponseSchema=O,e.ScanQRCodeResultSchema=N,e.ScopeModule=class extends U{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},s=this.validate(Oe,n);if(s)return{status_code:400,error:s};const o=await this.invoke({method:"hasAccessTo",params:n}),r=this.validate(Ge,o);return r&&console.warn(`[SDK:hasAccessTo] Unexpected response shape: ${r}`),o}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(Le,e);return t&&console.warn(`[SDK:reloadScopes] Unexpected response shape: ${t}`),e}},e.SendAnalyticsEventRequestSchema=Z,e.SendAnalyticsEventResponseSchema=ee,e.SetBackgroundColorResponseSchema=P,e.SetBooleanResponseSchema=qe,e.SetDoubleResponseSchema=nt,e.SetIntResponseSchema=He,e.SetStringResponseSchema=Xe,e.SetTitleResponseSchema=z,e.ShowBackButtonResponseSchema=q,e.ShowLoaderResponseSchema=Q,e.ShowRefreshButtonResponseSchema=W,e.SplashScreenModule=class extends U{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(Pe,e);return t&&console.warn(`[SDK:dismiss] Unexpected response shape: ${t}`),e}},e.StorageModule=class extends U{constructor(){super("StorageModule")}async setBoolean(e,t){const n=await this.invoke({method:"setBoolean",params:{key:e,value:t}}),s=this.validate(qe,n);return s&&console.warn(`[SDK:setBoolean] Unexpected response shape: ${s}`),n}async getBoolean(e){const t={key:e},n=this.validate(Fe,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getBoolean",params:t}),o=this.validate(Ve,s);return o&&console.warn(`[SDK:getBoolean] Unexpected response shape: ${o}`),s}async setInt(e,t){const n=await this.invoke({method:"setInt",params:{key:e,value:t}}),s=this.validate(He,n);return s&&console.warn(`[SDK:setInt] Unexpected response shape: ${s}`),n}async getInt(e){const t={key:e},n=this.validate(Qe,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getInt",params:t}),o=this.validate(Ye,s);return o&&console.warn(`[SDK:getInt] Unexpected response shape: ${o}`),s}async setString(e,t){const n=await this.invoke({method:"setString",params:{key:e,value:t}}),s=this.validate(Xe,n);return s&&console.warn(`[SDK:setString] Unexpected response shape: ${s}`),n}async getString(e){const t={key:e},n=this.validate(Ze,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getString",params:t}),o=this.validate(tt,s);return o&&console.warn(`[SDK:getString] Unexpected response shape: ${o}`),s}async setDouble(e,t){const n=await this.invoke({method:"setDouble",params:{key:e,value:t}}),s=this.validate(nt,n);return s&&console.warn(`[SDK:setDouble] Unexpected response shape: ${s}`),n}async getDouble(e){const t={key:e},n=this.validate(st,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getDouble",params:t}),o=this.validate(rt,s);return o&&console.warn(`[SDK:getDouble] Unexpected response shape: ${o}`),s}async remove(e){const t={key:e},n=this.validate(at,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"remove",params:t}),o=this.validate(it,s);return o&&console.warn(`[SDK:remove] Unexpected response shape: ${o}`),s}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(ct,e);return t&&console.warn(`[SDK:removeAll] Unexpected response shape: ${t}`),e}},e.SystemWebViewKitModule=class extends U{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(ut,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),s=this.validate(dt,n);return s&&console.warn(`[SDK:redirectToSystemWebView] Unexpected response shape: ${s}`),n}},e.TriggerCheckoutRequestSchema=B,e.TriggerCheckoutResponseSchema=L,e.TriggerCheckoutResultSchema=G,e.UserAttributesModule=class extends U{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(ht,e);return t&&console.warn(`[SDK:getSelectedTravelDestination] Unexpected response shape: ${t}`),e}},e.VerifyEmailRequestSchema=Te,e.VerifyEmailResponseSchema=Ke,e.isClientError=function(e){const t=e.status_code;return 400===t||401===t||403===t||404===t||424===t||426===t},e.isError=function(e){return"error"in e},e.isFound=function(e){return 302===e.status_code},e.isNoContent=function(e){return 204===e.status_code},e.isOk=function(e){return 200===e.status_code},e.isRedirection=function(e){return 302===e.status_code},e.isServerError=function(e){return 500===e.status_code||501===e.status_code},e.isSuccess=function(e){return 200===e.status_code||204===e.status_code}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grabjs/superapp-sdk",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.29",
|
|
4
4
|
"description": "SDK for Grab SuperApp WebView.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -21,14 +21,18 @@
|
|
|
21
21
|
"node": "24"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "npm run build:dist && npm run build:docs",
|
|
25
|
-
"build:dist": "node scripts/build.mjs",
|
|
26
|
-
"build:docs": "
|
|
24
|
+
"build": "npm run clean && npm run build:dist && npm run build:docs && npm run build:skills",
|
|
25
|
+
"build:dist": "node scripts/build-dist.mjs",
|
|
26
|
+
"build:docs": "npm run build:docs:api && npm run build:docs:html",
|
|
27
|
+
"build:docs:api": "npx typedoc --options typedoc.api.json",
|
|
28
|
+
"build:docs:html": "npx typedoc --options typedoc.html.json",
|
|
29
|
+
"build:docs:md": "npx typedoc --options typedoc.md.json",
|
|
30
|
+
"build:skills": "node scripts/build-skills.mjs",
|
|
27
31
|
"build:watch": "rollup -cw",
|
|
28
32
|
"check": "npm run check:format && npm run check:lint && npm run test:check",
|
|
29
33
|
"check:format": "prettier --check .",
|
|
30
34
|
"check:lint": "eslint .",
|
|
31
|
-
"clean": "rimraf dist build",
|
|
35
|
+
"clean": "rimraf md dist build api-reference skills",
|
|
32
36
|
"fix": "npm run fix:format && npm run fix:lint",
|
|
33
37
|
"fix:format": "prettier --write .",
|
|
34
38
|
"fix:lint": "eslint . --fix",
|
|
@@ -50,7 +54,8 @@
|
|
|
50
54
|
],
|
|
51
55
|
"files": [
|
|
52
56
|
"dist",
|
|
53
|
-
"api-reference"
|
|
57
|
+
"api-reference",
|
|
58
|
+
"skills"
|
|
54
59
|
],
|
|
55
60
|
"keywords": [
|
|
56
61
|
"superapp",
|
|
@@ -68,6 +73,7 @@
|
|
|
68
73
|
"@eslint/js": "^10.0.1",
|
|
69
74
|
"@eslint/json": "^1.0.1",
|
|
70
75
|
"@eslint/markdown": "^7.5.1",
|
|
76
|
+
"@grabjs/mobile-kit-bridge-sdk": "^2.2.2",
|
|
71
77
|
"@microsoft/api-extractor": "^7.57.6",
|
|
72
78
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
73
79
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
@@ -91,13 +97,12 @@
|
|
|
91
97
|
"typedoc": "^0.28.17",
|
|
92
98
|
"typedoc-plugin-markdown": "^4.10.0",
|
|
93
99
|
"typedoc-plugin-no-inherit": "^1.6.1",
|
|
100
|
+
"typedoc-plugin-valibot": "^1.0.2",
|
|
94
101
|
"typescript": "^5.9.3",
|
|
95
102
|
"typescript-eslint": "^8.56.1",
|
|
103
|
+
"valibot": "^1.3.1",
|
|
96
104
|
"vitest": "^4.0.18"
|
|
97
105
|
},
|
|
98
|
-
"peerDependencies": {
|
|
99
|
-
"@grabjs/mobile-kit-bridge-sdk": "^2.2.2"
|
|
100
|
-
},
|
|
101
106
|
"lint-staged": {
|
|
102
107
|
"**/*": "prettier --write --ignore-unknown",
|
|
103
108
|
"*.{js,ts,mjs}": "eslint --fix"
|