@webority/mobile-core 0.183.0 → 0.185.0
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 +6 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/push/push.js +1 -1
- package/lib/commonjs/versionCheck/index.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/push/push.js +1 -1
- package/lib/module/versionCheck/index.js +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -2
- package/lib/typescript/commonjs/push/push.d.ts +5 -5
- package/lib/typescript/commonjs/versionCheck/index.d.ts +1 -1
- package/lib/typescript/module/index.d.ts +2 -2
- package/lib/typescript/module/push/push.d.ts +5 -5
- package/lib/typescript/module/versionCheck/index.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -103,6 +103,8 @@ tapped notification's data as strings, including the tap that launched the app.
|
|
|
103
103
|
settings switch its `status` and `enabled`. The library does not remember the switch: an app that
|
|
104
104
|
keeps push on calls `enablePush` at each start. `setBadgeCount(count)` sets the app icon badge. `dismissAllNotifications()` clears every notification from the notification tray; it never throws, and logs a failure at warn.
|
|
105
105
|
|
|
106
|
+
`showInForeground` and `playSoundInForeground` receive the notification's data, so an app can hide a push for a screen already open: `showInForeground: (data) => !(data.targetKind === 'chat' && data.targetId === openChatId())`. On Android, an app that draws data-only pushes in its own native messaging service makes the same decision in that service, because those pushes never reach this handler.
|
|
107
|
+
|
|
106
108
|
- `enablePush({ prompt: false })` never shows the permission prompt: a phone already granted
|
|
107
109
|
registers silently, and any other resolves with its status (`undetermined` when the person has not
|
|
108
110
|
been asked yet, `denied` when refused and the prompt can still show, `blocked` when only
|
|
@@ -371,7 +373,10 @@ It is the app's store identifier, so the API can tell apps of the same client ki
|
|
|
371
373
|
The version floor comes only from the `Min-App-Version` response header. When a reply carries it,
|
|
372
374
|
`useVersionCheck` turns `isUpdateRequired` on for a build below it. A 426 `client_update_required`
|
|
373
375
|
does not move the floor, so a 426 without that header leaves the floor where it is. A 426 is never
|
|
374
|
-
retried.
|
|
376
|
+
retried. `useVersionCheck` runs on Staging and Production builds, never on Development.
|
|
377
|
+
|
|
378
|
+
An app with its own axios clients calls `applyClientHeaders(client)` and `readMinAppVersion(client)`
|
|
379
|
+
on each of them, after `setConfig({ appId, appBuild })`, and gets the same headers and update check.
|
|
375
380
|
|
|
376
381
|
An app moves to this contract by hand. It renames the old `X-` header
|
|
377
382
|
strings to the plain names, `ApiError.detail` to `diagnostic` and `detail.signOutReason` to
|
package/lib/commonjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ACCESS_TOKEN_KEY",{enumerable:!0,get:function(){return _authStore.ACCESS_TOKEN_KEY}}),Object.defineProperty(exports,"ACCOUNT_ID_HEADER",{enumerable:!0,get:function(){return _clientHeaders.ACCOUNT_ID_HEADER}}),Object.defineProperty(exports,"AsYouType",{enumerable:!0,get:function(){return _index4.AsYouType}}),Object.defineProperty(exports,"CLIENT_BUILD_HEADER",{enumerable:!0,get:function(){return _clientHeaders.CLIENT_BUILD_HEADER}}),Object.defineProperty(exports,"CLIENT_KIND",{enumerable:!0,get:function(){return _clientHeaders.CLIENT_KIND}}),Object.defineProperty(exports,"CLIENT_KIND_HEADER",{enumerable:!0,get:function(){return _clientHeaders.CLIENT_KIND_HEADER}}),Object.defineProperty(exports,"CONTRACT_ERROR_CODE",{enumerable:!0,get:function(){return _index3.CONTRACT_ERROR_CODE}}),Object.defineProperty(exports,"DeepLink",{enumerable:!0,get:function(){return _index2.DeepLink}}),Object.defineProperty(exports,"ENVIRONMENT_APP_ID_SUFFIX",{enumerable:!0,get:function(){return _appIdentity.ENVIRONMENT_APP_ID_SUFFIX}}),Object.defineProperty(exports,"FIELD_RULE_MESSAGES",{enumerable:!0,get:function(){return _index9.FIELD_RULE_MESSAGES}}),Object.defineProperty(exports,"IDEMPOTENCY_KEY_HEADER",{enumerable:!0,get:function(){return _retry.IDEMPOTENCY_KEY_HEADER}}),Object.defineProperty(exports,"IDLE_LAST_ACTIVITY_KEY",{enumerable:!0,get:function(){return _index5.IDLE_LAST_ACTIVITY_KEY}}),Object.defineProperty(exports,"Logger",{enumerable:!0,get:function(){return _index6.Logger}}),Object.defineProperty(exports,"MIN_APP_VERSION_HEADER",{enumerable:!0,get:function(){return _minAppVersion.MIN_APP_VERSION_HEADER}}),Object.defineProperty(exports,"NETWORK_CHECK_CODE",{enumerable:!0,get:function(){return _index3.NETWORK_CHECK_CODE}}),Object.defineProperty(exports,"NETWORK_CHECK_MESSAGE",{enumerable:!0,get:function(){return _index3.NETWORK_CHECK_MESSAGE}}),Object.defineProperty(exports,"NETWORK_CODE",{enumerable:!0,get:function(){return _index3.NETWORK_CODE}}),Object.defineProperty(exports,"OFFLINE_CODE",{enumerable:!0,get:function(){return _index3.OFFLINE_CODE}}),Object.defineProperty(exports,"OFFLINE_MESSAGE",{enumerable:!0,get:function(){return _index3.OFFLINE_MESSAGE}}),Object.defineProperty(exports,"PUSH_STATUS",{enumerable:!0,get:function(){return _status.PUSH_STATUS}}),Object.defineProperty(exports,"REFRESH_TOKEN_KEY",{enumerable:!0,get:function(){return _authStore.REFRESH_TOKEN_KEY}}),Object.defineProperty(exports,"REQUEST_CANCELED_CODE",{enumerable:!0,get:function(){return _index3.REQUEST_CANCELED_CODE}}),Object.defineProperty(exports,"RequestOfflineError",{enumerable:!0,get:function(){return _userClient.RequestOfflineError}}),Object.defineProperty(exports,"SERVER_FAILURE_MESSAGE",{enumerable:!0,get:function(){return _index3.SERVER_FAILURE_MESSAGE}}),Object.defineProperty(exports,"SESSION_EXPIRED_CODE",{enumerable:!0,get:function(){return _userClient.SESSION_EXPIRED_CODE}}),Object.defineProperty(exports,"SESSION_REVOKED_CODE",{enumerable:!0,get:function(){return _userClient.SESSION_REVOKED_CODE}}),Object.defineProperty(exports,"SESSION_USER_KEY",{enumerable:!0,get:function(){return _authStore.SESSION_USER_KEY}}),Object.defineProperty(exports,"Storage",{enumerable:!0,get:function(){return _index8.Storage}}),Object.defineProperty(exports,"TIMEOUT_CODE",{enumerable:!0,get:function(){return _index3.TIMEOUT_CODE}}),Object.defineProperty(exports,"TIMEOUT_MESSAGE",{enumerable:!0,get:function(){return _index3.TIMEOUT_MESSAGE}}),Object.defineProperty(exports,"TRACEPARENT_HEADER",{enumerable:!0,get:function(){return _requestDefaults.TRACEPARENT_HEADER}}),Object.defineProperty(exports,"UNEXPECTED_MESSAGE",{enumerable:!0,get:function(){return _index3.UNEXPECTED_MESSAGE}}),Object.defineProperty(exports,"UNREACHABLE_MESSAGE",{enumerable:!0,get:function(){return _index3.UNREACHABLE_MESSAGE}}),Object.defineProperty(exports,"VersionCheck",{enumerable:!0,get:function(){return _index0.VersionCheck}}),Object.defineProperty(exports,"WORKSPACE_CHANGED_CODE",{enumerable:!0,get:function(){return _workspace.WORKSPACE_CHANGED_CODE}}),Object.defineProperty(exports,"WorkspaceChangedError",{enumerable:!0,get:function(){return _workspace.WorkspaceChangedError}}),Object.defineProperty(exports,"addDays",{enumerable:!0,get:function(){return _index4.addDays}}),Object.defineProperty(exports,"addMinAppVersionListener",{enumerable:!0,get:function(){return _minAppVersion.addMinAppVersionListener}}),Object.defineProperty(exports,"addNetworkStatusListener",{enumerable:!0,get:function(){return _index7.addNetworkStatusListener}}),Object.defineProperty(exports,"addSessionEndedListener",{enumerable:!0,get:function(){return _authStore.addSessionEndedListener}}),Object.defineProperty(exports,"apiErrorMessage",{enumerable:!0,get:function(){return _index3.apiErrorMessage}}),Object.defineProperty(exports,"applyRequestDefaults",{enumerable:!0,get:function(){return _requestDefaults.applyRequestDefaults}}),Object.defineProperty(exports,"attachRetry",{enumerable:!0,get:function(){return _retry.attachRetry}}),Object.defineProperty(exports,"buildCurl",{enumerable:!0,get:function(){return _curl.buildCurl}}),Object.defineProperty(exports,"checkFields",{enumerable:!0,get:function(){return _index9.checkFields}}),Object.defineProperty(exports,"clampNationalNumber",{enumerable:!0,get:function(){return _index4.clampNationalNumber}}),Object.defineProperty(exports,"clearSession",{enumerable:!0,get:function(){return _authStore.clearSession}}),Object.defineProperty(exports,"clientRequestHeaders",{enumerable:!0,get:function(){return _clientHeaders.clientRequestHeaders}}),Object.defineProperty(exports,"configureFormatters",{enumerable:!0,get:function(){return _index4.configureFormatters}}),Object.defineProperty(exports,"configureLogger",{enumerable:!0,get:function(){return _index6.configureLogger}}),Object.defineProperty(exports,"countryFlagEmoji",{enumerable:!0,get:function(){return _index4.countryFlagEmoji}}),Object.defineProperty(exports,"crashlyticsRemoteLogger",{enumerable:!0,get:function(){return _crashlytics.crashlyticsRemoteLogger}}),Object.defineProperty(exports,"createContractCaller",{enumerable:!0,get:function(){return _contractCaller.createContractCaller}}),Object.defineProperty(exports,"decodeJWT",{enumerable:!0,get:function(){return _jwt.decodeJWT}}),Object.defineProperty(exports,"detectPhoneCountry",{enumerable:!0,get:function(){return _index4.detectPhoneCountry}}),Object.defineProperty(exports,"diffMs",{enumerable:!0,get:function(){return _index4.diffMs}}),Object.defineProperty(exports,"encodeBase64",{enumerable:!0,get:function(){return _base.encodeBase64}}),Object.defineProperty(exports,"extractApiError",{enumerable:!0,get:function(){return _index3.extractApiError}}),Object.defineProperty(exports,"fetchWithRetry",{enumerable:!0,get:function(){return _fetchRetry.fetchWithRetry}}),Object.defineProperty(exports,"fieldRules",{enumerable:!0,get:function(){return _index9.fieldRules}}),Object.defineProperty(exports,"formatCompactNumber",{enumerable:!0,get:function(){return _index4.formatCompactNumber}}),Object.defineProperty(exports,"formatCurrency",{enumerable:!0,get:function(){return _index4.formatCurrency}}),Object.defineProperty(exports,"formatDate",{enumerable:!0,get:function(){return _index4.formatDate}}),Object.defineProperty(exports,"formatDateISO",{enumerable:!0,get:function(){return _index4.formatDateISO}}),Object.defineProperty(exports,"formatDatePattern",{enumerable:!0,get:function(){return _index4.formatDatePattern}}),Object.defineProperty(exports,"formatDateTime",{enumerable:!0,get:function(){return _index4.formatDateTime}}),Object.defineProperty(exports,"formatMinor",{enumerable:!0,get:function(){return _index4.formatMinor}}),Object.defineProperty(exports,"formatNumber",{enumerable:!0,get:function(){return _index4.formatNumber}}),Object.defineProperty(exports,"formatPercent",{enumerable:!0,get:function(){return _index4.formatPercent}}),Object.defineProperty(exports,"formatPhone",{enumerable:!0,get:function(){return _index4.formatPhone}}),Object.defineProperty(exports,"formatPhoneAsTyped",{enumerable:!0,get:function(){return _index4.formatPhoneAsTyped}}),Object.defineProperty(exports,"formatRelative",{enumerable:!0,get:function(){return _index4.formatRelative}}),Object.defineProperty(exports,"formatRelativeTime",{enumerable:!0,get:function(){return _index4.formatRelativeTime}}),Object.defineProperty(exports,"formatTime",{enumerable:!0,get:function(){return _index4.formatTime}}),Object.defineProperty(exports,"formatTime12h",{enumerable:!0,get:function(){return _index4.formatTime12h}}),Object.defineProperty(exports,"formatTimeInWindowsZone",{enumerable:!0,get:function(){return _index4.formatTimeInWindowsZone}}),Object.defineProperty(exports,"formatTimeInZone",{enumerable:!0,get:function(){return _index4.formatTimeInZone}}),Object.defineProperty(exports,"getClientBuild",{enumerable:!0,get:function(){return _clientHeaders.getClientBuild}}),Object.defineProperty(exports,"getConfig",{enumerable:!0,get:function(){return _index.getConfig}}),Object.defineProperty(exports,"getConfigValue",{enumerable:!0,get:function(){return _index.getConfigValue}}),Object.defineProperty(exports,"getCountries",{enumerable:!0,get:function(){return _index4.getCountries}}),Object.defineProperty(exports,"getCountryCallingCode",{enumerable:!0,get:function(){return _index4.getCountryCallingCode}}),Object.defineProperty(exports,"getDeviceContext",{enumerable:!0,get:function(){return _index6.getDeviceContext}}),Object.defineProperty(exports,"getFormatterConfig",{enumerable:!0,get:function(){return _index4.getFormatterConfig}}),Object.defineProperty(exports,"getInitials",{enumerable:!0,get:function(){return _index4.getInitials}}),Object.defineProperty(exports,"getJWTExpiry",{enumerable:!0,get:function(){return _jwt.getJWTExpiry}}),Object.defineProperty(exports,"getMinAppVersion",{enumerable:!0,get:function(){return _minAppVersion.getMinAppVersion}}),Object.defineProperty(exports,"getNetworkStatus",{enumerable:!0,get:function(){return _index7.getNetworkStatus}}),Object.defineProperty(exports,"getPhoneCountries",{enumerable:!0,get:function(){return _index4.getPhoneCountries}}),Object.defineProperty(exports,"getSessionUser",{enumerable:!0,get:function(){return _authStore.getSessionUser}}),Object.defineProperty(exports,"getToken",{enumerable:!0,get:function(){return _authStore.getToken}}),Object.defineProperty(exports,"groupingForLocale",{enumerable:!0,get:function(){return _index4.groupingForLocale}}),Object.defineProperty(exports,"initUserAuth",{enumerable:!0,get:function(){return _initUserAuth.initUserAuth}}),Object.defineProperty(exports,"initWebority",{enumerable:!0,get:function(){return _initSDK.initWebority}}),Object.defineProperty(exports,"injectStore",{enumerable:!0,get:function(){return _userClient.injectStore}}),Object.defineProperty(exports,"injectUserAuth",{enumerable:!0,get:function(){return _userClient.injectUserAuth}}),Object.defineProperty(exports,"installedAppId",{enumerable:!0,get:function(){return _appIdentity.installedAppId}}),Object.defineProperty(exports,"isAlphanumeric",{enumerable:!0,get:function(){return _index9.isAlphanumeric}}),Object.defineProperty(exports,"isApiError",{enumerable:!0,get:function(){return _index3.isApiError}}),Object.defineProperty(exports,"isBetween",{enumerable:!0,get:function(){return _index9.isBetween}}),Object.defineProperty(exports,"isBuildBelowMinimum",{enumerable:!0,get:function(){return _index0.isBuildBelowMinimum}}),Object.defineProperty(exports,"isDateAfter",{enumerable:!0,get:function(){return _index4.isDateAfter}}),Object.defineProperty(exports,"isDateBefore",{enumerable:!0,get:function(){return _index4.isDateBefore}}),Object.defineProperty(exports,"isEmail",{enumerable:!0,get:function(){return _index9.isEmail}}),Object.defineProperty(exports,"isHexColor",{enumerable:!0,get:function(){return _index9.isHexColor}}),Object.defineProperty(exports,"isInteger",{enumerable:!0,get:function(){return _index9.isInteger}}),Object.defineProperty(exports,"isJWTExpired",{enumerable:!0,get:function(){return _jwt.isJWTExpired}}),Object.defineProperty(exports,"isNeverSentError",{enumerable:!0,get:function(){return _retry.isNeverSentError}}),Object.defineProperty(exports,"isNoResponse",{enumerable:!0,get:function(){return _index3.isNoResponse}}),Object.defineProperty(exports,"isNonEmpty",{enumerable:!0,get:function(){return _index9.isNonEmpty}}),Object.defineProperty(exports,"isNumeric",{enumerable:!0,get:function(){return _index9.isNumeric}}),Object.defineProperty(exports,"isPhone",{enumerable:!0,get:function(){return _index9.isPhone}}),Object.defineProperty(exports,"isRetryableFailure",{enumerable:!0,get:function(){return _retry.isRetryableFailure}}),Object.defineProperty(exports,"isRetryableStatus",{enumerable:!0,get:function(){return _retry.isRetryableStatus}}),Object.defineProperty(exports,"isSameDay",{enumerable:!0,get:function(){return _index4.isSameDay}}),Object.defineProperty(exports,"isStrongPassword",{enumerable:!0,get:function(){return _index9.isStrongPassword}}),Object.defineProperty(exports,"isSupportedCountry",{enumerable:!0,get:function(){return _index4.isSupportedCountry}}),Object.defineProperty(exports,"isUrl",{enumerable:!0,get:function(){return _index9.isUrl}}),Object.defineProperty(exports,"isValidNationalNumber",{enumerable:!0,get:function(){return _index4.isValidNationalNumber}}),Object.defineProperty(exports,"isValidPhoneNumber",{enumerable:!0,get:function(){return _index4.isValidPhoneNumber}}),Object.defineProperty(exports,"isWorkspaceChangedError",{enumerable:!0,get:function(){return _workspace.isWorkspaceChangedError}}),Object.defineProperty(exports,"listQuery",{enumerable:!0,get:function(){return _call.listQuery}}),Object.defineProperty(exports,"logCurl",{enumerable:!0,get:function(){return _curl.logCurl}}),Object.defineProperty(exports,"maxLength",{enumerable:!0,get:function(){return _index9.maxLength}}),Object.defineProperty(exports,"maxNationalNumberLength",{enumerable:!0,get:function(){return _index4.maxNationalNumberLength}}),Object.defineProperty(exports,"mergeContracts",{enumerable:!0,get:function(){return _call.mergeContracts}}),Object.defineProperty(exports,"minLength",{enumerable:!0,get:function(){return _index9.minLength}}),Object.defineProperty(exports,"newIdempotencyKey",{enumerable:!0,get:function(){return _idempotencyKey.newIdempotencyKey}}),Object.defineProperty(exports,"newTraceparent",{enumerable:!0,get:function(){return _requestDefaults.newTraceparent}}),Object.defineProperty(exports,"normalizePhone",{enumerable:!0,get:function(){return _index4.normalizePhone}}),Object.defineProperty(exports,"parseBuildNumber",{enumerable:!0,get:function(){return _index0.parseBuildNumber}}),Object.defineProperty(exports,"parseDeepLink",{enumerable:!0,get:function(){return _index2.parseDeepLink}}),Object.defineProperty(exports,"parsePhoneNumber",{enumerable:!0,get:function(){return _index4.parsePhoneNumber}}),Object.defineProperty(exports,"parsePhoneNumberFromString",{enumerable:!0,get:function(){return _index4.parsePhoneNumberFromString}}),Object.defineProperty(exports,"parseResponse",{enumerable:!0,get:function(){return _index3.parseResponse}}),Object.defineProperty(exports,"publicClient",{enumerable:!0,get:function(){return _publicClient.default}}),Object.defineProperty(exports,"refineWith",{enumerable:!0,get:function(){return _index9.refineWith}}),Object.defineProperty(exports,"refreshAccessToken",{enumerable:!0,get:function(){return _tokenRefresh.refreshAccessToken}}),Object.defineProperty(exports,"removeSessionUser",{enumerable:!0,get:function(){return _authStore.removeSessionUser}}),Object.defineProperty(exports,"removeToken",{enumerable:!0,get:function(){return _authStore.removeToken}}),Object.defineProperty(exports,"reportIdleActivity",{enumerable:!0,get:function(){return _index5.reportIdleActivity}}),Object.defineProperty(exports,"resendWhenUnanswered",{enumerable:!0,get:function(){return _retry.resendWhenUnanswered}}),Object.defineProperty(exports,"resetConfig",{enumerable:!0,get:function(){return _index.resetConfig}}),Object.defineProperty(exports,"resetRefreshState",{enumerable:!0,get:function(){return _userClient.resetRefreshState}}),Object.defineProperty(exports,"retryAfterMs",{enumerable:!0,get:function(){return _retry.retryAfterMs}}),Object.defineProperty(exports,"setConfig",{enumerable:!0,get:function(){return _index.setConfig}}),Object.defineProperty(exports,"setDeviceContext",{enumerable:!0,get:function(){return _index6.setDeviceContext}}),Object.defineProperty(exports,"setKeychainImplementation",{enumerable:!0,get:function(){return _authStore.setKeychainImplementation}}),Object.defineProperty(exports,"setNetworkStatusImplementation",{enumerable:!0,get:function(){return _index7.setNetworkStatusImplementation}}),Object.defineProperty(exports,"setStorageImplementation",{enumerable:!0,get:function(){return _index8.setStorageImplementation}}),Object.defineProperty(exports,"splitPhoneNumber",{enumerable:!0,get:function(){return _index4.splitPhoneNumber}}),Object.defineProperty(exports,"startOfDay",{enumerable:!0,get:function(){return _index4.startOfDay}}),Object.defineProperty(exports,"storeSessionUser",{enumerable:!0,get:function(){return _authStore.storeSessionUser}}),Object.defineProperty(exports,"storeToken",{enumerable:!0,get:function(){return _authStore.storeToken}}),Object.defineProperty(exports,"toFieldPath",{enumerable:!0,get:function(){return _index3.toFieldPath}}),Object.defineProperty(exports,"useDeepLink",{enumerable:!0,get:function(){return _index2.useDeepLink}}),Object.defineProperty(exports,"useIdleTimeout",{enumerable:!0,get:function(){return _index5.useIdleTimeout}}),Object.defineProperty(exports,"useNetworkStatus",{enumerable:!0,get:function(){return _index7.useNetworkStatus}}),Object.defineProperty(exports,"useVersionCheck",{enumerable:!0,get:function(){return _index0.useVersionCheck}}),Object.defineProperty(exports,"userClient",{enumerable:!0,get:function(){return _userClient.default}}),Object.defineProperty(exports,"validatePhoneNumberLength",{enumerable:!0,get:function(){return _index4.validatePhoneNumberLength}}),Object.defineProperty(exports,"withBaseUrl",{enumerable:!0,get:function(){return _call.withBaseUrl}});var cache,_call=require("@webority/api-contract/call"),_clientHeaders=require("./api/clientHeaders.js"),_contractCaller=require("./api/contractCaller.js"),_curl=require("./api/curl.js"),_fetchRetry=require("./api/fetchRetry.js"),_idempotencyKey=require("./api/idempotencyKey.js"),_minAppVersion=require("./api/minAppVersion.js"),_publicClient=_interopRequireDefault(require("./api/publicClient.js")),_requestDefaults=require("./api/requestDefaults.js"),_retry=require("./api/retry.js"),_tokenRefresh=require("./api/tokenRefresh.js"),_userClient=_interopRequireWildcard(require("./api/userClient.js")),_workspace=require("./api/workspace.js"),_authStore=require("./auth/authStore.js"),_jwt=require("./auth/jwt.js"),_index=require("./config/index.js"),_appIdentity=require("./config/appIdentity.js"),_index2=require("./deepLink/index.js"),_index3=require("./errors/index.js"),_index4=require("./formatters/index.js"),_index5=require("./idle/index.js"),_initSDK=require("./initSDK.js"),_initUserAuth=require("./initUserAuth.js"),_index6=require("./logger/index.js"),_crashlytics=require("./logger/crashlytics.js"),_index7=require("./network/index.js"),_status=require("./push/status.js"),_index8=require("./storage/index.js"),_base=require("./utils/base64.js"),_index9=require("./validators/index.js"),_index0=require("./versionCheck/index.js");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,n,i=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((t=i&&Object.getOwnPropertyDescriptor(e,n))&&(t.get||t.set)?i(o,n,t):o[n]=e[n]);return o}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ACCESS_TOKEN_KEY",{enumerable:!0,get:function(){return _authStore.ACCESS_TOKEN_KEY}}),Object.defineProperty(exports,"ACCOUNT_ID_HEADER",{enumerable:!0,get:function(){return _clientHeaders.ACCOUNT_ID_HEADER}}),Object.defineProperty(exports,"AsYouType",{enumerable:!0,get:function(){return _index4.AsYouType}}),Object.defineProperty(exports,"CLIENT_BUILD_HEADER",{enumerable:!0,get:function(){return _clientHeaders.CLIENT_BUILD_HEADER}}),Object.defineProperty(exports,"CLIENT_KIND",{enumerable:!0,get:function(){return _clientHeaders.CLIENT_KIND}}),Object.defineProperty(exports,"CLIENT_KIND_HEADER",{enumerable:!0,get:function(){return _clientHeaders.CLIENT_KIND_HEADER}}),Object.defineProperty(exports,"CONTRACT_ERROR_CODE",{enumerable:!0,get:function(){return _index3.CONTRACT_ERROR_CODE}}),Object.defineProperty(exports,"DeepLink",{enumerable:!0,get:function(){return _index2.DeepLink}}),Object.defineProperty(exports,"ENVIRONMENT_APP_ID_SUFFIX",{enumerable:!0,get:function(){return _appIdentity.ENVIRONMENT_APP_ID_SUFFIX}}),Object.defineProperty(exports,"FIELD_RULE_MESSAGES",{enumerable:!0,get:function(){return _index9.FIELD_RULE_MESSAGES}}),Object.defineProperty(exports,"IDEMPOTENCY_KEY_HEADER",{enumerable:!0,get:function(){return _retry.IDEMPOTENCY_KEY_HEADER}}),Object.defineProperty(exports,"IDLE_LAST_ACTIVITY_KEY",{enumerable:!0,get:function(){return _index5.IDLE_LAST_ACTIVITY_KEY}}),Object.defineProperty(exports,"Logger",{enumerable:!0,get:function(){return _index6.Logger}}),Object.defineProperty(exports,"MIN_APP_VERSION_HEADER",{enumerable:!0,get:function(){return _minAppVersion.MIN_APP_VERSION_HEADER}}),Object.defineProperty(exports,"NETWORK_CHECK_CODE",{enumerable:!0,get:function(){return _index3.NETWORK_CHECK_CODE}}),Object.defineProperty(exports,"NETWORK_CHECK_MESSAGE",{enumerable:!0,get:function(){return _index3.NETWORK_CHECK_MESSAGE}}),Object.defineProperty(exports,"NETWORK_CODE",{enumerable:!0,get:function(){return _index3.NETWORK_CODE}}),Object.defineProperty(exports,"OFFLINE_CODE",{enumerable:!0,get:function(){return _index3.OFFLINE_CODE}}),Object.defineProperty(exports,"OFFLINE_MESSAGE",{enumerable:!0,get:function(){return _index3.OFFLINE_MESSAGE}}),Object.defineProperty(exports,"PUSH_STATUS",{enumerable:!0,get:function(){return _status.PUSH_STATUS}}),Object.defineProperty(exports,"REFRESH_TOKEN_KEY",{enumerable:!0,get:function(){return _authStore.REFRESH_TOKEN_KEY}}),Object.defineProperty(exports,"REQUEST_CANCELED_CODE",{enumerable:!0,get:function(){return _index3.REQUEST_CANCELED_CODE}}),Object.defineProperty(exports,"RequestOfflineError",{enumerable:!0,get:function(){return _userClient.RequestOfflineError}}),Object.defineProperty(exports,"SERVER_FAILURE_MESSAGE",{enumerable:!0,get:function(){return _index3.SERVER_FAILURE_MESSAGE}}),Object.defineProperty(exports,"SESSION_EXPIRED_CODE",{enumerable:!0,get:function(){return _userClient.SESSION_EXPIRED_CODE}}),Object.defineProperty(exports,"SESSION_REVOKED_CODE",{enumerable:!0,get:function(){return _userClient.SESSION_REVOKED_CODE}}),Object.defineProperty(exports,"SESSION_USER_KEY",{enumerable:!0,get:function(){return _authStore.SESSION_USER_KEY}}),Object.defineProperty(exports,"Storage",{enumerable:!0,get:function(){return _index8.Storage}}),Object.defineProperty(exports,"TIMEOUT_CODE",{enumerable:!0,get:function(){return _index3.TIMEOUT_CODE}}),Object.defineProperty(exports,"TIMEOUT_MESSAGE",{enumerable:!0,get:function(){return _index3.TIMEOUT_MESSAGE}}),Object.defineProperty(exports,"TRACEPARENT_HEADER",{enumerable:!0,get:function(){return _requestDefaults.TRACEPARENT_HEADER}}),Object.defineProperty(exports,"UNEXPECTED_MESSAGE",{enumerable:!0,get:function(){return _index3.UNEXPECTED_MESSAGE}}),Object.defineProperty(exports,"UNREACHABLE_MESSAGE",{enumerable:!0,get:function(){return _index3.UNREACHABLE_MESSAGE}}),Object.defineProperty(exports,"VersionCheck",{enumerable:!0,get:function(){return _index0.VersionCheck}}),Object.defineProperty(exports,"WORKSPACE_CHANGED_CODE",{enumerable:!0,get:function(){return _workspace.WORKSPACE_CHANGED_CODE}}),Object.defineProperty(exports,"WorkspaceChangedError",{enumerable:!0,get:function(){return _workspace.WorkspaceChangedError}}),Object.defineProperty(exports,"addDays",{enumerable:!0,get:function(){return _index4.addDays}}),Object.defineProperty(exports,"addMinAppVersionListener",{enumerable:!0,get:function(){return _minAppVersion.addMinAppVersionListener}}),Object.defineProperty(exports,"addNetworkStatusListener",{enumerable:!0,get:function(){return _index7.addNetworkStatusListener}}),Object.defineProperty(exports,"addSessionEndedListener",{enumerable:!0,get:function(){return _authStore.addSessionEndedListener}}),Object.defineProperty(exports,"apiErrorMessage",{enumerable:!0,get:function(){return _index3.apiErrorMessage}}),Object.defineProperty(exports,"applyClientHeaders",{enumerable:!0,get:function(){return _clientHeaders.applyClientHeaders}}),Object.defineProperty(exports,"applyRequestDefaults",{enumerable:!0,get:function(){return _requestDefaults.applyRequestDefaults}}),Object.defineProperty(exports,"attachRetry",{enumerable:!0,get:function(){return _retry.attachRetry}}),Object.defineProperty(exports,"buildCurl",{enumerable:!0,get:function(){return _curl.buildCurl}}),Object.defineProperty(exports,"checkFields",{enumerable:!0,get:function(){return _index9.checkFields}}),Object.defineProperty(exports,"clampNationalNumber",{enumerable:!0,get:function(){return _index4.clampNationalNumber}}),Object.defineProperty(exports,"clearSession",{enumerable:!0,get:function(){return _authStore.clearSession}}),Object.defineProperty(exports,"clientRequestHeaders",{enumerable:!0,get:function(){return _clientHeaders.clientRequestHeaders}}),Object.defineProperty(exports,"configureFormatters",{enumerable:!0,get:function(){return _index4.configureFormatters}}),Object.defineProperty(exports,"configureLogger",{enumerable:!0,get:function(){return _index6.configureLogger}}),Object.defineProperty(exports,"countryFlagEmoji",{enumerable:!0,get:function(){return _index4.countryFlagEmoji}}),Object.defineProperty(exports,"crashlyticsRemoteLogger",{enumerable:!0,get:function(){return _crashlytics.crashlyticsRemoteLogger}}),Object.defineProperty(exports,"createContractCaller",{enumerable:!0,get:function(){return _contractCaller.createContractCaller}}),Object.defineProperty(exports,"decodeJWT",{enumerable:!0,get:function(){return _jwt.decodeJWT}}),Object.defineProperty(exports,"detectPhoneCountry",{enumerable:!0,get:function(){return _index4.detectPhoneCountry}}),Object.defineProperty(exports,"diffMs",{enumerable:!0,get:function(){return _index4.diffMs}}),Object.defineProperty(exports,"encodeBase64",{enumerable:!0,get:function(){return _base.encodeBase64}}),Object.defineProperty(exports,"extractApiError",{enumerable:!0,get:function(){return _index3.extractApiError}}),Object.defineProperty(exports,"fetchWithRetry",{enumerable:!0,get:function(){return _fetchRetry.fetchWithRetry}}),Object.defineProperty(exports,"fieldRules",{enumerable:!0,get:function(){return _index9.fieldRules}}),Object.defineProperty(exports,"formatCompactNumber",{enumerable:!0,get:function(){return _index4.formatCompactNumber}}),Object.defineProperty(exports,"formatCurrency",{enumerable:!0,get:function(){return _index4.formatCurrency}}),Object.defineProperty(exports,"formatDate",{enumerable:!0,get:function(){return _index4.formatDate}}),Object.defineProperty(exports,"formatDateISO",{enumerable:!0,get:function(){return _index4.formatDateISO}}),Object.defineProperty(exports,"formatDatePattern",{enumerable:!0,get:function(){return _index4.formatDatePattern}}),Object.defineProperty(exports,"formatDateTime",{enumerable:!0,get:function(){return _index4.formatDateTime}}),Object.defineProperty(exports,"formatMinor",{enumerable:!0,get:function(){return _index4.formatMinor}}),Object.defineProperty(exports,"formatNumber",{enumerable:!0,get:function(){return _index4.formatNumber}}),Object.defineProperty(exports,"formatPercent",{enumerable:!0,get:function(){return _index4.formatPercent}}),Object.defineProperty(exports,"formatPhone",{enumerable:!0,get:function(){return _index4.formatPhone}}),Object.defineProperty(exports,"formatPhoneAsTyped",{enumerable:!0,get:function(){return _index4.formatPhoneAsTyped}}),Object.defineProperty(exports,"formatRelative",{enumerable:!0,get:function(){return _index4.formatRelative}}),Object.defineProperty(exports,"formatRelativeTime",{enumerable:!0,get:function(){return _index4.formatRelativeTime}}),Object.defineProperty(exports,"formatTime",{enumerable:!0,get:function(){return _index4.formatTime}}),Object.defineProperty(exports,"formatTime12h",{enumerable:!0,get:function(){return _index4.formatTime12h}}),Object.defineProperty(exports,"formatTimeInWindowsZone",{enumerable:!0,get:function(){return _index4.formatTimeInWindowsZone}}),Object.defineProperty(exports,"formatTimeInZone",{enumerable:!0,get:function(){return _index4.formatTimeInZone}}),Object.defineProperty(exports,"getClientBuild",{enumerable:!0,get:function(){return _clientHeaders.getClientBuild}}),Object.defineProperty(exports,"getConfig",{enumerable:!0,get:function(){return _index.getConfig}}),Object.defineProperty(exports,"getConfigValue",{enumerable:!0,get:function(){return _index.getConfigValue}}),Object.defineProperty(exports,"getCountries",{enumerable:!0,get:function(){return _index4.getCountries}}),Object.defineProperty(exports,"getCountryCallingCode",{enumerable:!0,get:function(){return _index4.getCountryCallingCode}}),Object.defineProperty(exports,"getDeviceContext",{enumerable:!0,get:function(){return _index6.getDeviceContext}}),Object.defineProperty(exports,"getFormatterConfig",{enumerable:!0,get:function(){return _index4.getFormatterConfig}}),Object.defineProperty(exports,"getInitials",{enumerable:!0,get:function(){return _index4.getInitials}}),Object.defineProperty(exports,"getJWTExpiry",{enumerable:!0,get:function(){return _jwt.getJWTExpiry}}),Object.defineProperty(exports,"getMinAppVersion",{enumerable:!0,get:function(){return _minAppVersion.getMinAppVersion}}),Object.defineProperty(exports,"getNetworkStatus",{enumerable:!0,get:function(){return _index7.getNetworkStatus}}),Object.defineProperty(exports,"getPhoneCountries",{enumerable:!0,get:function(){return _index4.getPhoneCountries}}),Object.defineProperty(exports,"getSessionUser",{enumerable:!0,get:function(){return _authStore.getSessionUser}}),Object.defineProperty(exports,"getToken",{enumerable:!0,get:function(){return _authStore.getToken}}),Object.defineProperty(exports,"groupingForLocale",{enumerable:!0,get:function(){return _index4.groupingForLocale}}),Object.defineProperty(exports,"initUserAuth",{enumerable:!0,get:function(){return _initUserAuth.initUserAuth}}),Object.defineProperty(exports,"initWebority",{enumerable:!0,get:function(){return _initSDK.initWebority}}),Object.defineProperty(exports,"injectStore",{enumerable:!0,get:function(){return _userClient.injectStore}}),Object.defineProperty(exports,"injectUserAuth",{enumerable:!0,get:function(){return _userClient.injectUserAuth}}),Object.defineProperty(exports,"installedAppId",{enumerable:!0,get:function(){return _appIdentity.installedAppId}}),Object.defineProperty(exports,"isAlphanumeric",{enumerable:!0,get:function(){return _index9.isAlphanumeric}}),Object.defineProperty(exports,"isApiError",{enumerable:!0,get:function(){return _index3.isApiError}}),Object.defineProperty(exports,"isBetween",{enumerable:!0,get:function(){return _index9.isBetween}}),Object.defineProperty(exports,"isBuildBelowMinimum",{enumerable:!0,get:function(){return _index0.isBuildBelowMinimum}}),Object.defineProperty(exports,"isDateAfter",{enumerable:!0,get:function(){return _index4.isDateAfter}}),Object.defineProperty(exports,"isDateBefore",{enumerable:!0,get:function(){return _index4.isDateBefore}}),Object.defineProperty(exports,"isEmail",{enumerable:!0,get:function(){return _index9.isEmail}}),Object.defineProperty(exports,"isHexColor",{enumerable:!0,get:function(){return _index9.isHexColor}}),Object.defineProperty(exports,"isInteger",{enumerable:!0,get:function(){return _index9.isInteger}}),Object.defineProperty(exports,"isJWTExpired",{enumerable:!0,get:function(){return _jwt.isJWTExpired}}),Object.defineProperty(exports,"isNeverSentError",{enumerable:!0,get:function(){return _retry.isNeverSentError}}),Object.defineProperty(exports,"isNoResponse",{enumerable:!0,get:function(){return _index3.isNoResponse}}),Object.defineProperty(exports,"isNonEmpty",{enumerable:!0,get:function(){return _index9.isNonEmpty}}),Object.defineProperty(exports,"isNumeric",{enumerable:!0,get:function(){return _index9.isNumeric}}),Object.defineProperty(exports,"isPhone",{enumerable:!0,get:function(){return _index9.isPhone}}),Object.defineProperty(exports,"isRetryableFailure",{enumerable:!0,get:function(){return _retry.isRetryableFailure}}),Object.defineProperty(exports,"isRetryableStatus",{enumerable:!0,get:function(){return _retry.isRetryableStatus}}),Object.defineProperty(exports,"isSameDay",{enumerable:!0,get:function(){return _index4.isSameDay}}),Object.defineProperty(exports,"isStrongPassword",{enumerable:!0,get:function(){return _index9.isStrongPassword}}),Object.defineProperty(exports,"isSupportedCountry",{enumerable:!0,get:function(){return _index4.isSupportedCountry}}),Object.defineProperty(exports,"isUrl",{enumerable:!0,get:function(){return _index9.isUrl}}),Object.defineProperty(exports,"isValidNationalNumber",{enumerable:!0,get:function(){return _index4.isValidNationalNumber}}),Object.defineProperty(exports,"isValidPhoneNumber",{enumerable:!0,get:function(){return _index4.isValidPhoneNumber}}),Object.defineProperty(exports,"isWorkspaceChangedError",{enumerable:!0,get:function(){return _workspace.isWorkspaceChangedError}}),Object.defineProperty(exports,"listQuery",{enumerable:!0,get:function(){return _call.listQuery}}),Object.defineProperty(exports,"logCurl",{enumerable:!0,get:function(){return _curl.logCurl}}),Object.defineProperty(exports,"maxLength",{enumerable:!0,get:function(){return _index9.maxLength}}),Object.defineProperty(exports,"maxNationalNumberLength",{enumerable:!0,get:function(){return _index4.maxNationalNumberLength}}),Object.defineProperty(exports,"mergeContracts",{enumerable:!0,get:function(){return _call.mergeContracts}}),Object.defineProperty(exports,"minLength",{enumerable:!0,get:function(){return _index9.minLength}}),Object.defineProperty(exports,"newIdempotencyKey",{enumerable:!0,get:function(){return _idempotencyKey.newIdempotencyKey}}),Object.defineProperty(exports,"newTraceparent",{enumerable:!0,get:function(){return _requestDefaults.newTraceparent}}),Object.defineProperty(exports,"normalizePhone",{enumerable:!0,get:function(){return _index4.normalizePhone}}),Object.defineProperty(exports,"parseBuildNumber",{enumerable:!0,get:function(){return _index0.parseBuildNumber}}),Object.defineProperty(exports,"parseDeepLink",{enumerable:!0,get:function(){return _index2.parseDeepLink}}),Object.defineProperty(exports,"parsePhoneNumber",{enumerable:!0,get:function(){return _index4.parsePhoneNumber}}),Object.defineProperty(exports,"parsePhoneNumberFromString",{enumerable:!0,get:function(){return _index4.parsePhoneNumberFromString}}),Object.defineProperty(exports,"parseResponse",{enumerable:!0,get:function(){return _index3.parseResponse}}),Object.defineProperty(exports,"publicClient",{enumerable:!0,get:function(){return _publicClient.default}}),Object.defineProperty(exports,"readMinAppVersion",{enumerable:!0,get:function(){return _minAppVersion.readMinAppVersion}}),Object.defineProperty(exports,"refineWith",{enumerable:!0,get:function(){return _index9.refineWith}}),Object.defineProperty(exports,"refreshAccessToken",{enumerable:!0,get:function(){return _tokenRefresh.refreshAccessToken}}),Object.defineProperty(exports,"removeSessionUser",{enumerable:!0,get:function(){return _authStore.removeSessionUser}}),Object.defineProperty(exports,"removeToken",{enumerable:!0,get:function(){return _authStore.removeToken}}),Object.defineProperty(exports,"reportIdleActivity",{enumerable:!0,get:function(){return _index5.reportIdleActivity}}),Object.defineProperty(exports,"resendWhenUnanswered",{enumerable:!0,get:function(){return _retry.resendWhenUnanswered}}),Object.defineProperty(exports,"resetConfig",{enumerable:!0,get:function(){return _index.resetConfig}}),Object.defineProperty(exports,"resetRefreshState",{enumerable:!0,get:function(){return _userClient.resetRefreshState}}),Object.defineProperty(exports,"retryAfterMs",{enumerable:!0,get:function(){return _retry.retryAfterMs}}),Object.defineProperty(exports,"setConfig",{enumerable:!0,get:function(){return _index.setConfig}}),Object.defineProperty(exports,"setDeviceContext",{enumerable:!0,get:function(){return _index6.setDeviceContext}}),Object.defineProperty(exports,"setKeychainImplementation",{enumerable:!0,get:function(){return _authStore.setKeychainImplementation}}),Object.defineProperty(exports,"setNetworkStatusImplementation",{enumerable:!0,get:function(){return _index7.setNetworkStatusImplementation}}),Object.defineProperty(exports,"setStorageImplementation",{enumerable:!0,get:function(){return _index8.setStorageImplementation}}),Object.defineProperty(exports,"splitPhoneNumber",{enumerable:!0,get:function(){return _index4.splitPhoneNumber}}),Object.defineProperty(exports,"startOfDay",{enumerable:!0,get:function(){return _index4.startOfDay}}),Object.defineProperty(exports,"storeSessionUser",{enumerable:!0,get:function(){return _authStore.storeSessionUser}}),Object.defineProperty(exports,"storeToken",{enumerable:!0,get:function(){return _authStore.storeToken}}),Object.defineProperty(exports,"toFieldPath",{enumerable:!0,get:function(){return _index3.toFieldPath}}),Object.defineProperty(exports,"useDeepLink",{enumerable:!0,get:function(){return _index2.useDeepLink}}),Object.defineProperty(exports,"useIdleTimeout",{enumerable:!0,get:function(){return _index5.useIdleTimeout}}),Object.defineProperty(exports,"useNetworkStatus",{enumerable:!0,get:function(){return _index7.useNetworkStatus}}),Object.defineProperty(exports,"useVersionCheck",{enumerable:!0,get:function(){return _index0.useVersionCheck}}),Object.defineProperty(exports,"userClient",{enumerable:!0,get:function(){return _userClient.default}}),Object.defineProperty(exports,"validatePhoneNumberLength",{enumerable:!0,get:function(){return _index4.validatePhoneNumberLength}}),Object.defineProperty(exports,"withBaseUrl",{enumerable:!0,get:function(){return _call.withBaseUrl}});var cache,_call=require("@webority/api-contract/call"),_clientHeaders=require("./api/clientHeaders.js"),_contractCaller=require("./api/contractCaller.js"),_curl=require("./api/curl.js"),_fetchRetry=require("./api/fetchRetry.js"),_idempotencyKey=require("./api/idempotencyKey.js"),_minAppVersion=require("./api/minAppVersion.js"),_publicClient=_interopRequireDefault(require("./api/publicClient.js")),_requestDefaults=require("./api/requestDefaults.js"),_retry=require("./api/retry.js"),_tokenRefresh=require("./api/tokenRefresh.js"),_userClient=_interopRequireWildcard(require("./api/userClient.js")),_workspace=require("./api/workspace.js"),_authStore=require("./auth/authStore.js"),_jwt=require("./auth/jwt.js"),_index=require("./config/index.js"),_appIdentity=require("./config/appIdentity.js"),_index2=require("./deepLink/index.js"),_index3=require("./errors/index.js"),_index4=require("./formatters/index.js"),_index5=require("./idle/index.js"),_initSDK=require("./initSDK.js"),_initUserAuth=require("./initUserAuth.js"),_index6=require("./logger/index.js"),_crashlytics=require("./logger/crashlytics.js"),_index7=require("./network/index.js"),_status=require("./push/status.js"),_index8=require("./storage/index.js"),_base=require("./utils/base64.js"),_index9=require("./validators/index.js"),_index0=require("./versionCheck/index.js");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,n,i=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((t=i&&Object.getOwnPropertyDescriptor(e,n))&&(t.get||t.set)?i(o,n,t):o[n]=e[n]);return o}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.usePush=exports.toPushReceived=exports.toPushAction=exports.toNotificationActions=exports.setPushImplementation=exports.setCategories=exports.setBadgeCount=exports.routeTaskPayload=exports.resolveModules=exports.resetPush=exports.readDevicePushToken=exports.onReceive=exports.onAction=exports.notifyLocal=exports.initPush=exports.enablePush=exports.dismissAllNotifications=exports.disablePush=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../logger/index.js"),_guards=require("../utils/guards.js");let resolved,override=null;const setPushImplementation=e=>{override=e};exports.setPushImplementation=setPushImplementation;const resolveModules=()=>{if(override)return override;if(void 0!==resolved)return resolved;try{if(require("expo").isRunningInExpoGo())return resolved=null,resolved;const e=require("expo-notifications"),t=require("expo-application");resolved={notifications:e,applicationId:t.applicationId,getApnsEnvironment:()=>t.getIosPushNotificationServiceEnvironmentAsync()}}catch(e){_index.Logger.warn("[push] expo-notifications is not available; push is off",e),resolved=null}return resolved};exports.resolveModules=resolveModules;let state={status:"unknown",enabled:!1,registrationError:null};const subscribers=new Set,setState=e=>{state={...state,...e};for(const e of subscribers)e()};let config=null,channelsReady=Promise.resolve(),tokenSubscription=null,actionHandler=null;const receiveHandlers=new Set;let listening=!1,listeningForReceived=!1;const pendingResponses=[],routedAt=new Map,REPEAT_WINDOW_MS=1e4,requireConfig=()=>{if(!config)throw new Error("[@webority/mobile-core] call initPush before enablePush or disablePush.");return config},toPermissionStatus=e=>e.granted?"granted":"denied"===e.status?e.canAskAgain?"denied":"blocked":"undetermined",toStringData=e=>{const t={};for(const[n,i]of Object.entries(e??{}))null!=i&&(t[n]="object"==typeof i?JSON.stringify(i):String(i));return t},contentData=e=>{const t=e.request.content;if(t.data)return toStringData(t.data);if("string"==typeof t.dataString)try{const e=JSON.parse(t.dataString);if(!(0,_guards.isRecord)(e))throw new Error("the notification data is not a JSON object");return toStringData(e)}catch(e){_index.Logger.error("[push] notification data is not JSON",e)}return{}},triggerData=e=>{const t=e.request.trigger,n={...t?.remoteMessage?.data??{}};for(const[e,i]of Object.entries(t?.payload??{}))"aps"===e||"body"===e&&"object"==typeof i||(n[e]=i);return toStringData(n)},notificationData=e=>({...triggerData(e),...contentData(e)}),responseData=e=>notificationData(e.notification),toPushReceived=e=>({notificationId:e.request.identifier,title:e.request.content.title??null,body:e.request.content.body??null,data:notificationData(e)});exports.toPushReceived=toPushReceived;const toPushAction=e=>({actionId:e.actionIdentifier,...e.userText?{userText:e.userText}:{},data:responseData(e),notificationId:e.notification.request.identifier});exports.toPushAction=toPushAction;const toNotificationActions=e=>e.map(e=>({identifier:e.id,buttonTitle:e.title,...e.textInput?{textInput:{submitButtonTitle:e.textInput.submitTitle,placeholder:e.textInput.placeholder}}:{},options:{opensAppToForeground:e.opensApp??!0,isDestructive:e.destructive??!1,isAuthenticationRequired:e.authenticationRequired??!1}}));exports.toNotificationActions=toNotificationActions;const routeResponse=async(e,t)=>{const n=`${t.notification.request.identifier}:${t.actionIdentifier}`,i=routedAt.get(n);if(void 0!==i&&Date.now()-i<1e4)return;if(t.actionIdentifier!==e.DEFAULT_ACTION_IDENTIFIER&&actionHandler){routedAt.set(n,Date.now());try{await actionHandler(toPushAction(t))}catch(e){_index.Logger.error("[push] onAction threw",e)}}else if(config){routedAt.set(n,Date.now());try{config.onOpen(responseData(t))}catch(e){_index.Logger.error("[push] onOpen threw",e)}}else pendingResponses.push(t)},drainPending=async e=>{const t=pendingResponses.splice(0);for(const n of t)await routeResponse(e,n)},listenForResponses=e=>{listening||(listening=!0,e.addNotificationResponseReceivedListener(t=>{routeResponse(e,t)}),e.getLastNotificationResponseAsync().then(async t=>(t&&await routeResponse(e,t),e.clearLastNotificationResponseAsync?.())).catch(e=>_index.Logger.error("[push] reading the launch notification failed",e)))},isString=e=>"string"==typeof e,isStringOrNull=e=>null===e||"string"==typeof e,isRecordOrNull=e=>null===e||(0,_guards.isRecord)(e),optionalOf=(e,t)=>t(e)?e:void 0,remoteMessageOf=e=>(0,_guards.isRecord)(e)?{data:optionalOf(e.data,isRecordOrNull)}:void 0,toNotificationResponse=e=>{if(!(0,_guards.isRecord)(e))return null;const{actionIdentifier:t,userText:n,notification:i}=e;if(!isString(t)||!(0,_guards.isRecord)(i))return null;const{request:o}=i;if(!(0,_guards.isRecord)(o))return null;const{identifier:s,content:r,trigger:a}=o;return isString(s)&&(0,_guards.isRecord)(r)?{actionIdentifier:t,userText:optionalOf(n,isString),notification:{request:{identifier:s,content:{title:optionalOf(r.title,isStringOrNull),body:optionalOf(r.body,isStringOrNull),data:optionalOf(r.data,isRecordOrNull),dataString:optionalOf(r.dataString,isString)},trigger:(0,_guards.isRecord)(a)?{type:optionalOf(a.type,isString),payload:optionalOf(a.payload,isRecordOrNull),remoteMessage:remoteMessageOf(a.remoteMessage)}:void 0}}}:null},routeTaskPayload=async e=>{const t=resolveModules();if(!t)return;const n=toNotificationResponse(e);n&&await routeResponse(t.notifications,n)};exports.routeTaskPayload=routeTaskPayload;const createChannels=async(e,t)=>{for(const n of t)try{await e.setNotificationChannelAsync(n.id,{name:n.name,importance:"high"===n.importance?e.AndroidImportance.HIGH:e.AndroidImportance.DEFAULT})}catch(e){_index.Logger.error(`[push] creating channel ${n.id} failed`,e)}},APNS_ENVIRONMENTS={development:"Development",production:"Production"},readApnsEnvironment=async e=>{try{return APNS_ENVIRONMENTS[await e.getApnsEnvironment()??""]??null}catch(e){return _index.Logger.warn("[push] reading the APNs environment failed",e),null}},deviceTimeZone=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||null,toDevice=async(e,t)=>{const n="android"===e.type?"Fcm":"ios"===e.type?"Apns":null;if(!n||"string"!=typeof e.data)return null;if(!t.applicationId)throw new Error("[@webority/mobile-core] push needs the app bundle id from expo-application.");return{installationId:await requireConfig().getInstallationId(),platform:n,token:e.data,appId:t.applicationId,apnsEnvironment:"Apns"===n?await readApnsEnvironment(t):null,timeZone:deviceTimeZone()}},initPush=e=>{const t=null===config;if(config=e,!t)return;const n=resolveModules();if(!n)return void setState({status:"unavailable"});const i=n.notifications;i.setNotificationHandler({handleNotification:async()=>{const e=config?.showInForeground?.()??!0;return{shouldShowBanner:e,shouldShowList:e,shouldPlaySound:e&&(config?.playSoundInForeground?.()??!0),shouldSetBadge:!0}}}),"android"===_reactNative.Platform.OS&&e.androidChannels?.length&&(channelsReady=createChannels(i,e.androidChannels)),listenForResponses(i),drainPending(i),i.getPermissionsAsync().then(e=>setState({status:toPermissionStatus(e)})).catch(e=>_index.Logger.error("[push] permission check failed",e))};exports.initPush=initPush;let registering=null,registeredKey=null,unregistering=null,tokenDrop=Promise.resolve();const registerOnce=e=>{const t=JSON.stringify(e);if(registering?.key===t)return registering.promise;const n=requireConfig().register(e).then(()=>{registeredKey=t,state.registrationError&&setState({registrationError:null})}).finally(()=>{registering?.promise===n&&(registering=null)});return registering={key:t,promise:n},n},enablePush=async({prompt:e=!0}={})=>{requireConfig();const t=resolveModules();if(!t)return setState({status:"unavailable"}),"unavailable";const n=t.notifications;await channelsReady,await tokenDrop;let i=await n.getPermissionsAsync();if(!i.granted&&e&&(i=await n.requestPermissionsAsync()),!i.granted){const e=toPermissionStatus(i);return setState({status:e}),e}const o=await toDevice(await n.getDevicePushTokenAsync(),t);return o?(await registerOnce(o),tokenSubscription?.remove(),tokenSubscription=n.addPushTokenListener(e=>{(unregistering??Promise.resolve()).then(()=>state.enabled?toDevice(e,t):null).then(e=>e&&JSON.stringify(e)!==registeredKey?registerOnce(e):void 0).catch(e=>{_index.Logger.error("[push] re-registering a new token failed",e),setState({registrationError:e instanceof Error?e:new Error(String(e))})})}),setState({status:"granted",enabled:!0}),"granted"):(setState({status:"unavailable"}),"unavailable")};exports.enablePush=enablePush;const readDevicePushToken=async()=>{const e=resolveModules();if(!e)return null;await tokenDrop;if(!(await e.notifications.getPermissionsAsync()).granted)return null;const t=await e.notifications.getDevicePushTokenAsync(),n="android"===t.type?"android":"ios"===t.type?"ios":null;return n&&"string"==typeof t.data?{platform:n,token:t.data}:null};exports.readDevicePushToken=readDevicePushToken;const stopFollowingToken=()=>{tokenSubscription?.remove(),tokenSubscription=null,registeredKey=null,setState({enabled:!1,registrationError:null})},disablePush=async()=>{const e=requireConfig(),t=await e.getInstallationId();await Promise.allSettled([registering?.promise]);let settle=()=>{};const n=new Promise(e=>{settle=e});unregistering=n;try{await e.unregister(t),stopFollowingToken()}finally{unregistering===n&&(unregistering=null),settle()}};exports.disablePush=disablePush;const resetPush=async()=>{stopFollowingToken();const e=resolveModules();if(!e)return;const t=e.notifications.unregisterForNotificationsAsync();tokenDrop=Promise.allSettled([t]),await t};exports.resetPush=resetPush;const setBadgeCount=async e=>{const t=resolveModules();t&&await t.notifications.setBadgeCountAsync(e)};exports.setBadgeCount=setBadgeCount;const dismissAllNotifications=async()=>{const e=resolveModules();if(e)try{await e.notifications.dismissAllNotificationsAsync()}catch(e){_index.Logger.warn("[push] dismissing the notifications failed",e)}};exports.dismissAllNotifications=dismissAllNotifications;const setCategories=async e=>{const t=resolveModules();if(t)for(const n of e)await t.notifications.setNotificationCategoryAsync(n.id,toNotificationActions(n.actions))};exports.setCategories=setCategories;const onAction=e=>{actionHandler=e;const t=resolveModules();return t&&(listenForResponses(t.notifications),drainPending(t.notifications)),()=>{actionHandler===e&&(actionHandler=null)}};exports.onAction=onAction;const onReceive=e=>{receiveHandlers.add(e);const t=resolveModules();return t&&!listeningForReceived&&(listeningForReceived=!0,t.notifications.addNotificationReceivedListener(e=>{const t=toPushReceived(e);for(const e of[...receiveHandlers])try{e(t)}catch(e){_index.Logger.error("[push] onReceive threw",e)}})),()=>{receiveHandlers.delete(e)}};exports.onReceive=onReceive;const notifyLocal=async({title:e,body:t,data:n})=>{const i=resolveModules();i&&await i.notifications.scheduleNotificationAsync({content:{title:e,body:t,data:n??{}},trigger:null})};exports.notifyLocal=notifyLocal;const subscribe=e=>(subscribers.add(e),()=>{subscribers.delete(e)}),getSnapshot=()=>state,enable=async()=>{await enablePush()},usePush=()=>({...(0,_react.useSyncExternalStore)(subscribe,getSnapshot,getSnapshot),enable:enable,disable:disablePush});exports.usePush=usePush;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.usePush=exports.toPushReceived=exports.toPushAction=exports.toNotificationActions=exports.setPushImplementation=exports.setCategories=exports.setBadgeCount=exports.routeTaskPayload=exports.resolveModules=exports.resetPush=exports.readDevicePushToken=exports.onReceive=exports.onAction=exports.notifyLocal=exports.initPush=exports.enablePush=exports.dismissAllNotifications=exports.disablePush=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../logger/index.js"),_guards=require("../utils/guards.js");let resolved,override=null;const setPushImplementation=e=>{override=e};exports.setPushImplementation=setPushImplementation;const resolveModules=()=>{if(override)return override;if(void 0!==resolved)return resolved;try{if(require("expo").isRunningInExpoGo())return resolved=null,resolved;const e=require("expo-notifications"),t=require("expo-application");resolved={notifications:e,applicationId:t.applicationId,getApnsEnvironment:()=>t.getIosPushNotificationServiceEnvironmentAsync()}}catch(e){_index.Logger.warn("[push] expo-notifications is not available; push is off",e),resolved=null}return resolved};exports.resolveModules=resolveModules;let state={status:"unknown",enabled:!1,registrationError:null};const subscribers=new Set,setState=e=>{state={...state,...e};for(const e of subscribers)e()};let config=null,channelsReady=Promise.resolve(),tokenSubscription=null,actionHandler=null;const receiveHandlers=new Set;let listening=!1,listeningForReceived=!1;const pendingResponses=[],routedAt=new Map,REPEAT_WINDOW_MS=1e4,requireConfig=()=>{if(!config)throw new Error("[@webority/mobile-core] call initPush before enablePush or disablePush.");return config},toPermissionStatus=e=>e.granted?"granted":"denied"===e.status?e.canAskAgain?"denied":"blocked":"undetermined",toStringData=e=>{const t={};for(const[n,i]of Object.entries(e??{}))null!=i&&(t[n]="object"==typeof i?JSON.stringify(i):String(i));return t},contentData=e=>{const t=e.request.content;if(t.data)return toStringData(t.data);if("string"==typeof t.dataString)try{const e=JSON.parse(t.dataString);if(!(0,_guards.isRecord)(e))throw new Error("the notification data is not a JSON object");return toStringData(e)}catch(e){_index.Logger.error("[push] notification data is not JSON",e)}return{}},triggerData=e=>{const t=e.request.trigger,n={...t?.remoteMessage?.data??{}};for(const[e,i]of Object.entries(t?.payload??{}))"aps"===e||"body"===e&&"object"==typeof i||(n[e]=i);return toStringData(n)},notificationData=e=>({...triggerData(e),...contentData(e)}),responseData=e=>notificationData(e.notification),toPushReceived=e=>({notificationId:e.request.identifier,title:e.request.content.title??null,body:e.request.content.body??null,data:notificationData(e)});exports.toPushReceived=toPushReceived;const toPushAction=e=>({actionId:e.actionIdentifier,...e.userText?{userText:e.userText}:{},data:responseData(e),notificationId:e.notification.request.identifier});exports.toPushAction=toPushAction;const toNotificationActions=e=>e.map(e=>({identifier:e.id,buttonTitle:e.title,...e.textInput?{textInput:{submitButtonTitle:e.textInput.submitTitle,placeholder:e.textInput.placeholder}}:{},options:{opensAppToForeground:e.opensApp??!0,isDestructive:e.destructive??!1,isAuthenticationRequired:e.authenticationRequired??!1}}));exports.toNotificationActions=toNotificationActions;const routeResponse=async(e,t)=>{const n=`${t.notification.request.identifier}:${t.actionIdentifier}`,i=routedAt.get(n);if(void 0!==i&&Date.now()-i<1e4)return;if(t.actionIdentifier!==e.DEFAULT_ACTION_IDENTIFIER&&actionHandler){routedAt.set(n,Date.now());try{await actionHandler(toPushAction(t))}catch(e){_index.Logger.error("[push] onAction threw",e)}}else if(config){routedAt.set(n,Date.now());try{config.onOpen(responseData(t))}catch(e){_index.Logger.error("[push] onOpen threw",e)}}else pendingResponses.push(t)},drainPending=async e=>{const t=pendingResponses.splice(0);for(const n of t)await routeResponse(e,n)},listenForResponses=e=>{listening||(listening=!0,e.addNotificationResponseReceivedListener(t=>{routeResponse(e,t)}),e.getLastNotificationResponseAsync().then(async t=>(t&&await routeResponse(e,t),e.clearLastNotificationResponseAsync?.())).catch(e=>_index.Logger.error("[push] reading the launch notification failed",e)))},isString=e=>"string"==typeof e,isStringOrNull=e=>null===e||"string"==typeof e,isRecordOrNull=e=>null===e||(0,_guards.isRecord)(e),optionalOf=(e,t)=>t(e)?e:void 0,remoteMessageOf=e=>(0,_guards.isRecord)(e)?{data:optionalOf(e.data,isRecordOrNull)}:void 0,toNotificationResponse=e=>{if(!(0,_guards.isRecord)(e))return null;const{actionIdentifier:t,userText:n,notification:i}=e;if(!isString(t)||!(0,_guards.isRecord)(i))return null;const{request:o}=i;if(!(0,_guards.isRecord)(o))return null;const{identifier:s,content:r,trigger:a}=o;return isString(s)&&(0,_guards.isRecord)(r)?{actionIdentifier:t,userText:optionalOf(n,isString),notification:{request:{identifier:s,content:{title:optionalOf(r.title,isStringOrNull),body:optionalOf(r.body,isStringOrNull),data:optionalOf(r.data,isRecordOrNull),dataString:optionalOf(r.dataString,isString)},trigger:(0,_guards.isRecord)(a)?{type:optionalOf(a.type,isString),payload:optionalOf(a.payload,isRecordOrNull),remoteMessage:remoteMessageOf(a.remoteMessage)}:void 0}}}:null},routeTaskPayload=async e=>{const t=resolveModules();if(!t)return;const n=toNotificationResponse(e);n&&await routeResponse(t.notifications,n)};exports.routeTaskPayload=routeTaskPayload;const createChannels=async(e,t)=>{for(const n of t)try{await e.setNotificationChannelAsync(n.id,{name:n.name,importance:"high"===n.importance?e.AndroidImportance.HIGH:e.AndroidImportance.DEFAULT})}catch(e){_index.Logger.error(`[push] creating channel ${n.id} failed`,e)}},APNS_ENVIRONMENTS={development:"Development",production:"Production"},readApnsEnvironment=async e=>{try{return APNS_ENVIRONMENTS[await e.getApnsEnvironment()??""]??null}catch(e){return _index.Logger.warn("[push] reading the APNs environment failed",e),null}},deviceTimeZone=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||null,toDevice=async(e,t)=>{const n="android"===e.type?"Fcm":"ios"===e.type?"Apns":null;if(!n||"string"!=typeof e.data)return null;if(!t.applicationId)throw new Error("[@webority/mobile-core] push needs the app bundle id from expo-application.");return{installationId:await requireConfig().getInstallationId(),platform:n,token:e.data,appId:t.applicationId,apnsEnvironment:"Apns"===n?await readApnsEnvironment(t):null,timeZone:deviceTimeZone()}},initPush=e=>{const t=null===config;if(config=e,!t)return;const n=resolveModules();if(!n)return void setState({status:"unavailable"});const i=n.notifications;i.setNotificationHandler({handleNotification:async e=>{const t=notificationData(e),n=config?.showInForeground?.(t)??!0;return{shouldShowBanner:n,shouldShowList:n,shouldPlaySound:n&&(config?.playSoundInForeground?.(t)??!0),shouldSetBadge:!0}}}),"android"===_reactNative.Platform.OS&&e.androidChannels?.length&&(channelsReady=createChannels(i,e.androidChannels)),listenForResponses(i),drainPending(i),i.getPermissionsAsync().then(e=>setState({status:toPermissionStatus(e)})).catch(e=>_index.Logger.error("[push] permission check failed",e))};exports.initPush=initPush;let registering=null,registeredKey=null,unregistering=null,tokenDrop=Promise.resolve();const registerOnce=e=>{const t=JSON.stringify(e);if(registering?.key===t)return registering.promise;const n=requireConfig().register(e).then(()=>{registeredKey=t,state.registrationError&&setState({registrationError:null})}).finally(()=>{registering?.promise===n&&(registering=null)});return registering={key:t,promise:n},n},enablePush=async({prompt:e=!0}={})=>{requireConfig();const t=resolveModules();if(!t)return setState({status:"unavailable"}),"unavailable";const n=t.notifications;await channelsReady,await tokenDrop;let i=await n.getPermissionsAsync();if(!i.granted&&e&&(i=await n.requestPermissionsAsync()),!i.granted){const e=toPermissionStatus(i);return setState({status:e}),e}const o=await toDevice(await n.getDevicePushTokenAsync(),t);return o?(await registerOnce(o),tokenSubscription?.remove(),tokenSubscription=n.addPushTokenListener(e=>{(unregistering??Promise.resolve()).then(()=>state.enabled?toDevice(e,t):null).then(e=>e&&JSON.stringify(e)!==registeredKey?registerOnce(e):void 0).catch(e=>{_index.Logger.error("[push] re-registering a new token failed",e),setState({registrationError:e instanceof Error?e:new Error(String(e))})})}),setState({status:"granted",enabled:!0}),"granted"):(setState({status:"unavailable"}),"unavailable")};exports.enablePush=enablePush;const readDevicePushToken=async()=>{const e=resolveModules();if(!e)return null;await tokenDrop;if(!(await e.notifications.getPermissionsAsync()).granted)return null;const t=await e.notifications.getDevicePushTokenAsync(),n="android"===t.type?"android":"ios"===t.type?"ios":null;return n&&"string"==typeof t.data?{platform:n,token:t.data}:null};exports.readDevicePushToken=readDevicePushToken;const stopFollowingToken=()=>{tokenSubscription?.remove(),tokenSubscription=null,registeredKey=null,setState({enabled:!1,registrationError:null})},disablePush=async()=>{const e=requireConfig(),t=await e.getInstallationId();await Promise.allSettled([registering?.promise]);let settle=()=>{};const n=new Promise(e=>{settle=e});unregistering=n;try{await e.unregister(t),stopFollowingToken()}finally{unregistering===n&&(unregistering=null),settle()}};exports.disablePush=disablePush;const resetPush=async()=>{stopFollowingToken();const e=resolveModules();if(!e)return;const t=e.notifications.unregisterForNotificationsAsync();tokenDrop=Promise.allSettled([t]),await t};exports.resetPush=resetPush;const setBadgeCount=async e=>{const t=resolveModules();t&&await t.notifications.setBadgeCountAsync(e)};exports.setBadgeCount=setBadgeCount;const dismissAllNotifications=async()=>{const e=resolveModules();if(e)try{await e.notifications.dismissAllNotificationsAsync()}catch(e){_index.Logger.warn("[push] dismissing the notifications failed",e)}};exports.dismissAllNotifications=dismissAllNotifications;const setCategories=async e=>{const t=resolveModules();if(t)for(const n of e)await t.notifications.setNotificationCategoryAsync(n.id,toNotificationActions(n.actions))};exports.setCategories=setCategories;const onAction=e=>{actionHandler=e;const t=resolveModules();return t&&(listenForResponses(t.notifications),drainPending(t.notifications)),()=>{actionHandler===e&&(actionHandler=null)}};exports.onAction=onAction;const onReceive=e=>{receiveHandlers.add(e);const t=resolveModules();return t&&!listeningForReceived&&(listeningForReceived=!0,t.notifications.addNotificationReceivedListener(e=>{const t=toPushReceived(e);for(const e of[...receiveHandlers])try{e(t)}catch(e){_index.Logger.error("[push] onReceive threw",e)}})),()=>{receiveHandlers.delete(e)}};exports.onReceive=onReceive;const notifyLocal=async({title:e,body:t,data:n})=>{const i=resolveModules();i&&await i.notifications.scheduleNotificationAsync({content:{title:e,body:t,data:n??{}},trigger:null})};exports.notifyLocal=notifyLocal;const subscribe=e=>(subscribers.add(e),()=>{subscribers.delete(e)}),getSnapshot=()=>state,enable=async()=>{await enablePush()},usePush=()=>({...(0,_react.useSyncExternalStore)(subscribe,getSnapshot,getSnapshot),enable:enable,disable:disablePush});exports.usePush=usePush;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VersionCheck=void 0,Object.defineProperty(exports,"isBuildBelowMinimum",{enumerable:!0,get:function(){return _buildNumber.isBuildBelowMinimum}}),Object.defineProperty(exports,"parseBuildNumber",{enumerable:!0,get:function(){return _buildNumber.parseBuildNumber}}),Object.defineProperty(exports,"readAppBuild",{enumerable:!0,get:function(){return _appBuild.readAppBuild}}),exports.useVersionCheck=void 0;var _react=require("react"),_minAppVersion=require("../api/minAppVersion.js"),_index=require("../config/index.js"),_index2=require("../logger/index.js"),_appBuild=require("./appBuild.js"),_buildNumber=require("./buildNumber.js");const missing=(e,r)=>{const i=new Error(`[VersionCheck] the app's ${e} is not available. Call setConfig({ ${r}: ... }). Every Webority app already has this value in appsettings.Compiled.json.`);return _index2.Logger.error(i.message),i},getSystemName=()=>{const{Platform:e}=require("react-native");return e.OS},getBundleId=()=>{const e=(0,_index.getConfigValue)("appId");if(e)return e;const r=((0,_appBuild.getDeviceInfo)()??_appBuild.expoApplicationBackend).getBundleId();if(r)return r;throw missing("store identifier","appId")},getBuildNumber=()=>{const e=(0,_appBuild.readAppBuild)();if(null!==e)return e;throw missing("build number","appBuild")},getCountry=()=>(0,_index.getConfigValue)("country","in").toLowerCase(),subscribeMinimum=e=>(0,_minAppVersion.addMinAppVersionListener)(()=>e()),getFallbackStoreUrl=()=>{const e=getSystemName().toLowerCase(),r=getCountry();if("ios"===e){const e=(0,_index.getConfigValue)("appStoreId");return e?`https://apps.apple.com/${r}/app/id${e}`:`https://apps.apple.com/${r}/app/${getBundleId()}`}return`https://play.google.com/store/apps/details?id=${getBundleId()}&hl=${r}`},storeUrlOrNull=()=>{try{return getFallbackStoreUrl()}catch{return null}},checkForUpdates=()=>{const e=(0,_buildNumber.isBuildBelowMinimum)(getBuildNumber(),(0,_minAppVersion.getMinAppVersion)());return{isNewVersionAvailable:e,updateType:e?"major":null,url:e?storeUrlOrNull():null}},VersionCheck=exports.VersionCheck={isNewVersionAvailable:async()=>checkForUpdates(),openUpdateUrl:async e=>{const{Linking:r}=require("react-native");try{if(e)_index2.Logger.info(`Opening app store URL: ${e}`),await r.openURL(e);else{const e=getFallbackStoreUrl();_index2.Logger.info(`Opening fallback store URL: ${e}`),await r.openURL(e)}return!0}catch(i){const n=i instanceof Error?i.message:String(i);_index2.Logger.error(`Failed to open store URL: ${n}`);try{if(e){const e=getFallbackStoreUrl();return _index2.Logger.info(`Trying fallback store URL: ${e}`),await r.openURL(e),!0}}catch(e){const r=e instanceof Error?e.message:String(e);_index2.Logger.error(`Failed to open fallback URL: ${r}`)}return!1}},getFallbackStoreUrl:getFallbackStoreUrl},NOT_REQUIRED={isUpdateRequired:!1,updateUrl:null},useVersionCheck=(e,r=(0,_index.getConfigValue)("environment","Development"))=>{const i=(0,_react.useSyncExternalStore)(subscribeMinimum,_minAppVersion.getMinAppVersion,_minAppVersion.getMinAppVersion);return(0,_react.useMemo)(()=>{if(!e||"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VersionCheck=void 0,Object.defineProperty(exports,"isBuildBelowMinimum",{enumerable:!0,get:function(){return _buildNumber.isBuildBelowMinimum}}),Object.defineProperty(exports,"parseBuildNumber",{enumerable:!0,get:function(){return _buildNumber.parseBuildNumber}}),Object.defineProperty(exports,"readAppBuild",{enumerable:!0,get:function(){return _appBuild.readAppBuild}}),exports.useVersionCheck=void 0;var _react=require("react"),_minAppVersion=require("../api/minAppVersion.js"),_index=require("../config/index.js"),_index2=require("../logger/index.js"),_appBuild=require("./appBuild.js"),_buildNumber=require("./buildNumber.js");const missing=(e,r)=>{const i=new Error(`[VersionCheck] the app's ${e} is not available. Call setConfig({ ${r}: ... }). Every Webority app already has this value in appsettings.Compiled.json.`);return _index2.Logger.error(i.message),i},getSystemName=()=>{const{Platform:e}=require("react-native");return e.OS},getBundleId=()=>{const e=(0,_index.getConfigValue)("appId");if(e)return e;const r=((0,_appBuild.getDeviceInfo)()??_appBuild.expoApplicationBackend).getBundleId();if(r)return r;throw missing("store identifier","appId")},getBuildNumber=()=>{const e=(0,_appBuild.readAppBuild)();if(null!==e)return e;throw missing("build number","appBuild")},getCountry=()=>(0,_index.getConfigValue)("country","in").toLowerCase(),subscribeMinimum=e=>(0,_minAppVersion.addMinAppVersionListener)(()=>e()),getFallbackStoreUrl=()=>{const e=getSystemName().toLowerCase(),r=getCountry();if("ios"===e){const e=(0,_index.getConfigValue)("appStoreId");return e?`https://apps.apple.com/${r}/app/id${e}`:`https://apps.apple.com/${r}/app/${getBundleId()}`}return`https://play.google.com/store/apps/details?id=${getBundleId()}&hl=${r}`},storeUrlOrNull=()=>{try{return getFallbackStoreUrl()}catch{return null}},checkForUpdates=()=>{const e=(0,_buildNumber.isBuildBelowMinimum)(getBuildNumber(),(0,_minAppVersion.getMinAppVersion)());return{isNewVersionAvailable:e,updateType:e?"major":null,url:e?storeUrlOrNull():null}},VersionCheck=exports.VersionCheck={isNewVersionAvailable:async()=>checkForUpdates(),openUpdateUrl:async e=>{const{Linking:r}=require("react-native");try{if(e)_index2.Logger.info(`Opening app store URL: ${e}`),await r.openURL(e);else{const e=getFallbackStoreUrl();_index2.Logger.info(`Opening fallback store URL: ${e}`),await r.openURL(e)}return!0}catch(i){const n=i instanceof Error?i.message:String(i);_index2.Logger.error(`Failed to open store URL: ${n}`);try{if(e){const e=getFallbackStoreUrl();return _index2.Logger.info(`Trying fallback store URL: ${e}`),await r.openURL(e),!0}}catch(e){const r=e instanceof Error?e.message:String(e);_index2.Logger.error(`Failed to open fallback URL: ${r}`)}return!1}},getFallbackStoreUrl:getFallbackStoreUrl},NOT_REQUIRED={isUpdateRequired:!1,updateUrl:null},useVersionCheck=(e,r=(0,_index.getConfigValue)("environment","Development"))=>{const i=(0,_react.useSyncExternalStore)(subscribeMinimum,_minAppVersion.getMinAppVersion,_minAppVersion.getMinAppVersion);return(0,_react.useMemo)(()=>{if(!e||"Development"===r||null===i)return NOT_REQUIRED;try{if(!(0,_buildNumber.isBuildBelowMinimum)(getBuildNumber(),i))return NOT_REQUIRED}catch{return NOT_REQUIRED}return{isUpdateRequired:!0,updateUrl:storeUrlOrNull()}},[e,r,i])};exports.useVersionCheck=useVersionCheck;
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{listQuery,mergeContracts,withBaseUrl}from"@webority/api-contract/call";export{ACCOUNT_ID_HEADER,CLIENT_BUILD_HEADER,CLIENT_KIND,CLIENT_KIND_HEADER,clientRequestHeaders,getClientBuild}from"./api/clientHeaders.js";export{createContractCaller}from"./api/contractCaller.js";export{buildCurl,logCurl}from"./api/curl.js";export{fetchWithRetry}from"./api/fetchRetry.js";export{newIdempotencyKey}from"./api/idempotencyKey.js";export{addMinAppVersionListener,getMinAppVersion,MIN_APP_VERSION_HEADER}from"./api/minAppVersion.js";export{default as publicClient}from"./api/publicClient.js";export{applyRequestDefaults,newTraceparent,TRACEPARENT_HEADER}from"./api/requestDefaults.js";export{attachRetry,IDEMPOTENCY_KEY_HEADER,isNeverSentError,isRetryableFailure,isRetryableStatus,resendWhenUnanswered,retryAfterMs}from"./api/retry.js";export{refreshAccessToken}from"./api/tokenRefresh.js";export{default as userClient,injectStore,injectUserAuth,RequestOfflineError,resetRefreshState,SESSION_EXPIRED_CODE,SESSION_REVOKED_CODE}from"./api/userClient.js";export{isWorkspaceChangedError,WORKSPACE_CHANGED_CODE,WorkspaceChangedError}from"./api/workspace.js";export{ACCESS_TOKEN_KEY,addSessionEndedListener,clearSession,getSessionUser,getToken,REFRESH_TOKEN_KEY,removeSessionUser,removeToken,SESSION_USER_KEY,setKeychainImplementation,storeSessionUser,storeToken}from"./auth/authStore.js";export{decodeJWT,getJWTExpiry,isJWTExpired}from"./auth/jwt.js";export{getConfig,getConfigValue,resetConfig,setConfig}from"./config/index.js";export{ENVIRONMENT_APP_ID_SUFFIX,installedAppId}from"./config/appIdentity.js";export{DeepLink,parseDeepLink,useDeepLink}from"./deepLink/index.js";export{apiErrorMessage,CONTRACT_ERROR_CODE,extractApiError,isApiError,isNoResponse,NETWORK_CHECK_CODE,NETWORK_CHECK_MESSAGE,NETWORK_CODE,OFFLINE_CODE,OFFLINE_MESSAGE,parseResponse,REQUEST_CANCELED_CODE,SERVER_FAILURE_MESSAGE,TIMEOUT_CODE,TIMEOUT_MESSAGE,toFieldPath,UNEXPECTED_MESSAGE,UNREACHABLE_MESSAGE}from"./errors/index.js";export{AsYouType,addDays,clampNationalNumber,configureFormatters,countryFlagEmoji,detectPhoneCountry,diffMs,formatCompactNumber,formatCurrency,formatDate,formatDateISO,formatDatePattern,formatDateTime,formatMinor,formatNumber,formatPercent,formatPhone,formatPhoneAsTyped,formatRelative,formatRelativeTime,formatTime,formatTime12h,formatTimeInWindowsZone,formatTimeInZone,getCountries,getCountryCallingCode,getFormatterConfig,getInitials,getPhoneCountries,groupingForLocale,isDateAfter,isDateBefore,isSameDay,isSupportedCountry,isValidNationalNumber,isValidPhoneNumber,maxNationalNumberLength,normalizePhone,parsePhoneNumber,parsePhoneNumberFromString,splitPhoneNumber,startOfDay,validatePhoneNumberLength}from"./formatters/index.js";export{IDLE_LAST_ACTIVITY_KEY,reportIdleActivity,useIdleTimeout}from"./idle/index.js";export{initWebority}from"./initSDK.js";export{initUserAuth}from"./initUserAuth.js";export{configureLogger,getDeviceContext,Logger,setDeviceContext}from"./logger/index.js";export{crashlyticsRemoteLogger}from"./logger/crashlytics.js";export{addNetworkStatusListener,getNetworkStatus,setNetworkStatusImplementation,useNetworkStatus}from"./network/index.js";export{PUSH_STATUS}from"./push/status.js";export{Storage,setStorageImplementation}from"./storage/index.js";export{encodeBase64}from"./utils/base64.js";export{checkFields,FIELD_RULE_MESSAGES,fieldRules,isAlphanumeric,isBetween,isEmail,isHexColor,isInteger,isNonEmpty,isNumeric,isPhone,isStrongPassword,isUrl,maxLength,minLength,refineWith}from"./validators/index.js";export{isBuildBelowMinimum,parseBuildNumber,useVersionCheck,VersionCheck}from"./versionCheck/index.js";
|
|
1
|
+
"use strict";export{listQuery,mergeContracts,withBaseUrl}from"@webority/api-contract/call";export{ACCOUNT_ID_HEADER,applyClientHeaders,CLIENT_BUILD_HEADER,CLIENT_KIND,CLIENT_KIND_HEADER,clientRequestHeaders,getClientBuild}from"./api/clientHeaders.js";export{createContractCaller}from"./api/contractCaller.js";export{buildCurl,logCurl}from"./api/curl.js";export{fetchWithRetry}from"./api/fetchRetry.js";export{newIdempotencyKey}from"./api/idempotencyKey.js";export{addMinAppVersionListener,getMinAppVersion,MIN_APP_VERSION_HEADER,readMinAppVersion}from"./api/minAppVersion.js";export{default as publicClient}from"./api/publicClient.js";export{applyRequestDefaults,newTraceparent,TRACEPARENT_HEADER}from"./api/requestDefaults.js";export{attachRetry,IDEMPOTENCY_KEY_HEADER,isNeverSentError,isRetryableFailure,isRetryableStatus,resendWhenUnanswered,retryAfterMs}from"./api/retry.js";export{refreshAccessToken}from"./api/tokenRefresh.js";export{default as userClient,injectStore,injectUserAuth,RequestOfflineError,resetRefreshState,SESSION_EXPIRED_CODE,SESSION_REVOKED_CODE}from"./api/userClient.js";export{isWorkspaceChangedError,WORKSPACE_CHANGED_CODE,WorkspaceChangedError}from"./api/workspace.js";export{ACCESS_TOKEN_KEY,addSessionEndedListener,clearSession,getSessionUser,getToken,REFRESH_TOKEN_KEY,removeSessionUser,removeToken,SESSION_USER_KEY,setKeychainImplementation,storeSessionUser,storeToken}from"./auth/authStore.js";export{decodeJWT,getJWTExpiry,isJWTExpired}from"./auth/jwt.js";export{getConfig,getConfigValue,resetConfig,setConfig}from"./config/index.js";export{ENVIRONMENT_APP_ID_SUFFIX,installedAppId}from"./config/appIdentity.js";export{DeepLink,parseDeepLink,useDeepLink}from"./deepLink/index.js";export{apiErrorMessage,CONTRACT_ERROR_CODE,extractApiError,isApiError,isNoResponse,NETWORK_CHECK_CODE,NETWORK_CHECK_MESSAGE,NETWORK_CODE,OFFLINE_CODE,OFFLINE_MESSAGE,parseResponse,REQUEST_CANCELED_CODE,SERVER_FAILURE_MESSAGE,TIMEOUT_CODE,TIMEOUT_MESSAGE,toFieldPath,UNEXPECTED_MESSAGE,UNREACHABLE_MESSAGE}from"./errors/index.js";export{AsYouType,addDays,clampNationalNumber,configureFormatters,countryFlagEmoji,detectPhoneCountry,diffMs,formatCompactNumber,formatCurrency,formatDate,formatDateISO,formatDatePattern,formatDateTime,formatMinor,formatNumber,formatPercent,formatPhone,formatPhoneAsTyped,formatRelative,formatRelativeTime,formatTime,formatTime12h,formatTimeInWindowsZone,formatTimeInZone,getCountries,getCountryCallingCode,getFormatterConfig,getInitials,getPhoneCountries,groupingForLocale,isDateAfter,isDateBefore,isSameDay,isSupportedCountry,isValidNationalNumber,isValidPhoneNumber,maxNationalNumberLength,normalizePhone,parsePhoneNumber,parsePhoneNumberFromString,splitPhoneNumber,startOfDay,validatePhoneNumberLength}from"./formatters/index.js";export{IDLE_LAST_ACTIVITY_KEY,reportIdleActivity,useIdleTimeout}from"./idle/index.js";export{initWebority}from"./initSDK.js";export{initUserAuth}from"./initUserAuth.js";export{configureLogger,getDeviceContext,Logger,setDeviceContext}from"./logger/index.js";export{crashlyticsRemoteLogger}from"./logger/crashlytics.js";export{addNetworkStatusListener,getNetworkStatus,setNetworkStatusImplementation,useNetworkStatus}from"./network/index.js";export{PUSH_STATUS}from"./push/status.js";export{Storage,setStorageImplementation}from"./storage/index.js";export{encodeBase64}from"./utils/base64.js";export{checkFields,FIELD_RULE_MESSAGES,fieldRules,isAlphanumeric,isBetween,isEmail,isHexColor,isInteger,isNonEmpty,isNumeric,isPhone,isStrongPassword,isUrl,maxLength,minLength,refineWith}from"./validators/index.js";export{isBuildBelowMinimum,parseBuildNumber,useVersionCheck,VersionCheck}from"./versionCheck/index.js";
|
package/lib/module/push/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useSyncExternalStore}from"react";import{Platform}from"react-native";import{Logger}from"../logger/index.js";import{isRecord}from"../utils/guards.js";let resolved,override=null;export const setPushImplementation=e=>{override=e};export const resolveModules=()=>{if(override)return override;if(void 0!==resolved)return resolved;try{if(require("expo").isRunningInExpoGo())return resolved=null,resolved;const e=require("expo-notifications"),t=require("expo-application");resolved={notifications:e,applicationId:t.applicationId,getApnsEnvironment:()=>t.getIosPushNotificationServiceEnvironmentAsync()}}catch(e){Logger.warn("[push] expo-notifications is not available; push is off",e),resolved=null}return resolved};let state={status:"unknown",enabled:!1,registrationError:null};const subscribers=new Set,setState=e=>{state={...state,...e};for(const e of subscribers)e()};let config=null,channelsReady=Promise.resolve(),tokenSubscription=null,actionHandler=null;const receiveHandlers=new Set;let listening=!1,listeningForReceived=!1;const pendingResponses=[],routedAt=new Map,REPEAT_WINDOW_MS=1e4,requireConfig=()=>{if(!config)throw new Error("[@webority/mobile-core] call initPush before enablePush or disablePush.");return config},toPermissionStatus=e=>e.granted?"granted":"denied"===e.status?e.canAskAgain?"denied":"blocked":"undetermined",toStringData=e=>{const t={};for(const[n,o]of Object.entries(e??{}))null!=o&&(t[n]="object"==typeof o?JSON.stringify(o):String(o));return t},contentData=e=>{const t=e.request.content;if(t.data)return toStringData(t.data);if("string"==typeof t.dataString)try{const e=JSON.parse(t.dataString);if(!isRecord(e))throw new Error("the notification data is not a JSON object");return toStringData(e)}catch(e){Logger.error("[push] notification data is not JSON",e)}return{}},triggerData=e=>{const t=e.request.trigger,n={...t?.remoteMessage?.data??{}};for(const[e,o]of Object.entries(t?.payload??{}))"aps"===e||"body"===e&&"object"==typeof o||(n[e]=o);return toStringData(n)},notificationData=e=>({...triggerData(e),...contentData(e)}),responseData=e=>notificationData(e.notification);export const toPushReceived=e=>({notificationId:e.request.identifier,title:e.request.content.title??null,body:e.request.content.body??null,data:notificationData(e)});export const toPushAction=e=>({actionId:e.actionIdentifier,...e.userText?{userText:e.userText}:{},data:responseData(e),notificationId:e.notification.request.identifier});export const toNotificationActions=e=>e.map(e=>({identifier:e.id,buttonTitle:e.title,...e.textInput?{textInput:{submitButtonTitle:e.textInput.submitTitle,placeholder:e.textInput.placeholder}}:{},options:{opensAppToForeground:e.opensApp??!0,isDestructive:e.destructive??!1,isAuthenticationRequired:e.authenticationRequired??!1}}));const routeResponse=async(e,t)=>{const n=`${t.notification.request.identifier}:${t.actionIdentifier}`,o=routedAt.get(n);if(void 0!==o&&Date.now()-o<1e4)return;if(t.actionIdentifier!==e.DEFAULT_ACTION_IDENTIFIER&&actionHandler){routedAt.set(n,Date.now());try{await actionHandler(toPushAction(t))}catch(e){Logger.error("[push] onAction threw",e)}}else if(config){routedAt.set(n,Date.now());try{config.onOpen(responseData(t))}catch(e){Logger.error("[push] onOpen threw",e)}}else pendingResponses.push(t)},drainPending=async e=>{const t=pendingResponses.splice(0);for(const n of t)await routeResponse(e,n)},listenForResponses=e=>{listening||(listening=!0,e.addNotificationResponseReceivedListener(t=>{routeResponse(e,t)}),e.getLastNotificationResponseAsync().then(async t=>(t&&await routeResponse(e,t),e.clearLastNotificationResponseAsync?.())).catch(e=>Logger.error("[push] reading the launch notification failed",e)))},isString=e=>"string"==typeof e,isStringOrNull=e=>null===e||"string"==typeof e,isRecordOrNull=e=>null===e||isRecord(e),optionalOf=(e,t)=>t(e)?e:void 0,remoteMessageOf=e=>isRecord(e)?{data:optionalOf(e.data,isRecordOrNull)}:void 0,toNotificationResponse=e=>{if(!isRecord(e))return null;const{actionIdentifier:t,userText:n,notification:o}=e;if(!isString(t)||!isRecord(o))return null;const{request:i}=o;if(!isRecord(i))return null;const{identifier:r,content:s,trigger:a}=i;return isString(r)&&isRecord(s)?{actionIdentifier:t,userText:optionalOf(n,isString),notification:{request:{identifier:r,content:{title:optionalOf(s.title,isStringOrNull),body:optionalOf(s.body,isStringOrNull),data:optionalOf(s.data,isRecordOrNull),dataString:optionalOf(s.dataString,isString)},trigger:isRecord(a)?{type:optionalOf(a.type,isString),payload:optionalOf(a.payload,isRecordOrNull),remoteMessage:remoteMessageOf(a.remoteMessage)}:void 0}}}:null};export const routeTaskPayload=async e=>{const t=resolveModules();if(!t)return;const n=toNotificationResponse(e);n&&await routeResponse(t.notifications,n)};const createChannels=async(e,t)=>{for(const n of t)try{await e.setNotificationChannelAsync(n.id,{name:n.name,importance:"high"===n.importance?e.AndroidImportance.HIGH:e.AndroidImportance.DEFAULT})}catch(e){Logger.error(`[push] creating channel ${n.id} failed`,e)}},APNS_ENVIRONMENTS={development:"Development",production:"Production"},readApnsEnvironment=async e=>{try{return APNS_ENVIRONMENTS[await e.getApnsEnvironment()??""]??null}catch(e){return Logger.warn("[push] reading the APNs environment failed",e),null}},deviceTimeZone=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||null,toDevice=async(e,t)=>{const n="android"===e.type?"Fcm":"ios"===e.type?"Apns":null;if(!n||"string"!=typeof e.data)return null;if(!t.applicationId)throw new Error("[@webority/mobile-core] push needs the app bundle id from expo-application.");return{installationId:await requireConfig().getInstallationId(),platform:n,token:e.data,appId:t.applicationId,apnsEnvironment:"Apns"===n?await readApnsEnvironment(t):null,timeZone:deviceTimeZone()}};export const initPush=e=>{const t=null===config;if(config=e,!t)return;const n=resolveModules();if(!n)return void setState({status:"unavailable"});const o=n.notifications;o.setNotificationHandler({handleNotification:async()=>{const e=config?.showInForeground?.()??!0;return{shouldShowBanner:e,shouldShowList:e,shouldPlaySound:e&&(config?.playSoundInForeground?.()??!0),shouldSetBadge:!0}}}),"android"===Platform.OS&&e.androidChannels?.length&&(channelsReady=createChannels(o,e.androidChannels)),listenForResponses(o),drainPending(o),o.getPermissionsAsync().then(e=>setState({status:toPermissionStatus(e)})).catch(e=>Logger.error("[push] permission check failed",e))};let registering=null,registeredKey=null,unregistering=null,tokenDrop=Promise.resolve();const registerOnce=e=>{const t=JSON.stringify(e);if(registering?.key===t)return registering.promise;const n=requireConfig().register(e).then(()=>{registeredKey=t,state.registrationError&&setState({registrationError:null})}).finally(()=>{registering?.promise===n&&(registering=null)});return registering={key:t,promise:n},n};export const enablePush=async({prompt:e=!0}={})=>{requireConfig();const t=resolveModules();if(!t)return setState({status:"unavailable"}),"unavailable";const n=t.notifications;await channelsReady,await tokenDrop;let o=await n.getPermissionsAsync();if(!o.granted&&e&&(o=await n.requestPermissionsAsync()),!o.granted){const e=toPermissionStatus(o);return setState({status:e}),e}const i=await toDevice(await n.getDevicePushTokenAsync(),t);return i?(await registerOnce(i),tokenSubscription?.remove(),tokenSubscription=n.addPushTokenListener(e=>{(unregistering??Promise.resolve()).then(()=>state.enabled?toDevice(e,t):null).then(e=>e&&JSON.stringify(e)!==registeredKey?registerOnce(e):void 0).catch(e=>{Logger.error("[push] re-registering a new token failed",e),setState({registrationError:e instanceof Error?e:new Error(String(e))})})}),setState({status:"granted",enabled:!0}),"granted"):(setState({status:"unavailable"}),"unavailable")};export const readDevicePushToken=async()=>{const e=resolveModules();if(!e)return null;await tokenDrop;if(!(await e.notifications.getPermissionsAsync()).granted)return null;const t=await e.notifications.getDevicePushTokenAsync(),n="android"===t.type?"android":"ios"===t.type?"ios":null;return n&&"string"==typeof t.data?{platform:n,token:t.data}:null};const stopFollowingToken=()=>{tokenSubscription?.remove(),tokenSubscription=null,registeredKey=null,setState({enabled:!1,registrationError:null})};export const disablePush=async()=>{const e=requireConfig(),t=await e.getInstallationId();await Promise.allSettled([registering?.promise]);let settle=()=>{};const n=new Promise(e=>{settle=e});unregistering=n;try{await e.unregister(t),stopFollowingToken()}finally{unregistering===n&&(unregistering=null),settle()}};export const resetPush=async()=>{stopFollowingToken();const e=resolveModules();if(!e)return;const t=e.notifications.unregisterForNotificationsAsync();tokenDrop=Promise.allSettled([t]),await t};export const setBadgeCount=async e=>{const t=resolveModules();t&&await t.notifications.setBadgeCountAsync(e)};export const dismissAllNotifications=async()=>{const e=resolveModules();if(e)try{await e.notifications.dismissAllNotificationsAsync()}catch(e){Logger.warn("[push] dismissing the notifications failed",e)}};export const setCategories=async e=>{const t=resolveModules();if(t)for(const n of e)await t.notifications.setNotificationCategoryAsync(n.id,toNotificationActions(n.actions))};export const onAction=e=>{actionHandler=e;const t=resolveModules();return t&&(listenForResponses(t.notifications),drainPending(t.notifications)),()=>{actionHandler===e&&(actionHandler=null)}};export const onReceive=e=>{receiveHandlers.add(e);const t=resolveModules();return t&&!listeningForReceived&&(listeningForReceived=!0,t.notifications.addNotificationReceivedListener(e=>{const t=toPushReceived(e);for(const e of[...receiveHandlers])try{e(t)}catch(e){Logger.error("[push] onReceive threw",e)}})),()=>{receiveHandlers.delete(e)}};export const notifyLocal=async({title:e,body:t,data:n})=>{const o=resolveModules();o&&await o.notifications.scheduleNotificationAsync({content:{title:e,body:t,data:n??{}},trigger:null})};const subscribe=e=>(subscribers.add(e),()=>{subscribers.delete(e)}),getSnapshot=()=>state,enable=async()=>{await enablePush()};export const usePush=()=>({...useSyncExternalStore(subscribe,getSnapshot,getSnapshot),enable:enable,disable:disablePush});
|
|
1
|
+
"use strict";import{useSyncExternalStore}from"react";import{Platform}from"react-native";import{Logger}from"../logger/index.js";import{isRecord}from"../utils/guards.js";let resolved,override=null;export const setPushImplementation=e=>{override=e};export const resolveModules=()=>{if(override)return override;if(void 0!==resolved)return resolved;try{if(require("expo").isRunningInExpoGo())return resolved=null,resolved;const e=require("expo-notifications"),t=require("expo-application");resolved={notifications:e,applicationId:t.applicationId,getApnsEnvironment:()=>t.getIosPushNotificationServiceEnvironmentAsync()}}catch(e){Logger.warn("[push] expo-notifications is not available; push is off",e),resolved=null}return resolved};let state={status:"unknown",enabled:!1,registrationError:null};const subscribers=new Set,setState=e=>{state={...state,...e};for(const e of subscribers)e()};let config=null,channelsReady=Promise.resolve(),tokenSubscription=null,actionHandler=null;const receiveHandlers=new Set;let listening=!1,listeningForReceived=!1;const pendingResponses=[],routedAt=new Map,REPEAT_WINDOW_MS=1e4,requireConfig=()=>{if(!config)throw new Error("[@webority/mobile-core] call initPush before enablePush or disablePush.");return config},toPermissionStatus=e=>e.granted?"granted":"denied"===e.status?e.canAskAgain?"denied":"blocked":"undetermined",toStringData=e=>{const t={};for(const[n,i]of Object.entries(e??{}))null!=i&&(t[n]="object"==typeof i?JSON.stringify(i):String(i));return t},contentData=e=>{const t=e.request.content;if(t.data)return toStringData(t.data);if("string"==typeof t.dataString)try{const e=JSON.parse(t.dataString);if(!isRecord(e))throw new Error("the notification data is not a JSON object");return toStringData(e)}catch(e){Logger.error("[push] notification data is not JSON",e)}return{}},triggerData=e=>{const t=e.request.trigger,n={...t?.remoteMessage?.data??{}};for(const[e,i]of Object.entries(t?.payload??{}))"aps"===e||"body"===e&&"object"==typeof i||(n[e]=i);return toStringData(n)},notificationData=e=>({...triggerData(e),...contentData(e)}),responseData=e=>notificationData(e.notification);export const toPushReceived=e=>({notificationId:e.request.identifier,title:e.request.content.title??null,body:e.request.content.body??null,data:notificationData(e)});export const toPushAction=e=>({actionId:e.actionIdentifier,...e.userText?{userText:e.userText}:{},data:responseData(e),notificationId:e.notification.request.identifier});export const toNotificationActions=e=>e.map(e=>({identifier:e.id,buttonTitle:e.title,...e.textInput?{textInput:{submitButtonTitle:e.textInput.submitTitle,placeholder:e.textInput.placeholder}}:{},options:{opensAppToForeground:e.opensApp??!0,isDestructive:e.destructive??!1,isAuthenticationRequired:e.authenticationRequired??!1}}));const routeResponse=async(e,t)=>{const n=`${t.notification.request.identifier}:${t.actionIdentifier}`,i=routedAt.get(n);if(void 0!==i&&Date.now()-i<1e4)return;if(t.actionIdentifier!==e.DEFAULT_ACTION_IDENTIFIER&&actionHandler){routedAt.set(n,Date.now());try{await actionHandler(toPushAction(t))}catch(e){Logger.error("[push] onAction threw",e)}}else if(config){routedAt.set(n,Date.now());try{config.onOpen(responseData(t))}catch(e){Logger.error("[push] onOpen threw",e)}}else pendingResponses.push(t)},drainPending=async e=>{const t=pendingResponses.splice(0);for(const n of t)await routeResponse(e,n)},listenForResponses=e=>{listening||(listening=!0,e.addNotificationResponseReceivedListener(t=>{routeResponse(e,t)}),e.getLastNotificationResponseAsync().then(async t=>(t&&await routeResponse(e,t),e.clearLastNotificationResponseAsync?.())).catch(e=>Logger.error("[push] reading the launch notification failed",e)))},isString=e=>"string"==typeof e,isStringOrNull=e=>null===e||"string"==typeof e,isRecordOrNull=e=>null===e||isRecord(e),optionalOf=(e,t)=>t(e)?e:void 0,remoteMessageOf=e=>isRecord(e)?{data:optionalOf(e.data,isRecordOrNull)}:void 0,toNotificationResponse=e=>{if(!isRecord(e))return null;const{actionIdentifier:t,userText:n,notification:i}=e;if(!isString(t)||!isRecord(i))return null;const{request:o}=i;if(!isRecord(o))return null;const{identifier:r,content:s,trigger:a}=o;return isString(r)&&isRecord(s)?{actionIdentifier:t,userText:optionalOf(n,isString),notification:{request:{identifier:r,content:{title:optionalOf(s.title,isStringOrNull),body:optionalOf(s.body,isStringOrNull),data:optionalOf(s.data,isRecordOrNull),dataString:optionalOf(s.dataString,isString)},trigger:isRecord(a)?{type:optionalOf(a.type,isString),payload:optionalOf(a.payload,isRecordOrNull),remoteMessage:remoteMessageOf(a.remoteMessage)}:void 0}}}:null};export const routeTaskPayload=async e=>{const t=resolveModules();if(!t)return;const n=toNotificationResponse(e);n&&await routeResponse(t.notifications,n)};const createChannels=async(e,t)=>{for(const n of t)try{await e.setNotificationChannelAsync(n.id,{name:n.name,importance:"high"===n.importance?e.AndroidImportance.HIGH:e.AndroidImportance.DEFAULT})}catch(e){Logger.error(`[push] creating channel ${n.id} failed`,e)}},APNS_ENVIRONMENTS={development:"Development",production:"Production"},readApnsEnvironment=async e=>{try{return APNS_ENVIRONMENTS[await e.getApnsEnvironment()??""]??null}catch(e){return Logger.warn("[push] reading the APNs environment failed",e),null}},deviceTimeZone=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||null,toDevice=async(e,t)=>{const n="android"===e.type?"Fcm":"ios"===e.type?"Apns":null;if(!n||"string"!=typeof e.data)return null;if(!t.applicationId)throw new Error("[@webority/mobile-core] push needs the app bundle id from expo-application.");return{installationId:await requireConfig().getInstallationId(),platform:n,token:e.data,appId:t.applicationId,apnsEnvironment:"Apns"===n?await readApnsEnvironment(t):null,timeZone:deviceTimeZone()}};export const initPush=e=>{const t=null===config;if(config=e,!t)return;const n=resolveModules();if(!n)return void setState({status:"unavailable"});const i=n.notifications;i.setNotificationHandler({handleNotification:async e=>{const t=notificationData(e),n=config?.showInForeground?.(t)??!0;return{shouldShowBanner:n,shouldShowList:n,shouldPlaySound:n&&(config?.playSoundInForeground?.(t)??!0),shouldSetBadge:!0}}}),"android"===Platform.OS&&e.androidChannels?.length&&(channelsReady=createChannels(i,e.androidChannels)),listenForResponses(i),drainPending(i),i.getPermissionsAsync().then(e=>setState({status:toPermissionStatus(e)})).catch(e=>Logger.error("[push] permission check failed",e))};let registering=null,registeredKey=null,unregistering=null,tokenDrop=Promise.resolve();const registerOnce=e=>{const t=JSON.stringify(e);if(registering?.key===t)return registering.promise;const n=requireConfig().register(e).then(()=>{registeredKey=t,state.registrationError&&setState({registrationError:null})}).finally(()=>{registering?.promise===n&&(registering=null)});return registering={key:t,promise:n},n};export const enablePush=async({prompt:e=!0}={})=>{requireConfig();const t=resolveModules();if(!t)return setState({status:"unavailable"}),"unavailable";const n=t.notifications;await channelsReady,await tokenDrop;let i=await n.getPermissionsAsync();if(!i.granted&&e&&(i=await n.requestPermissionsAsync()),!i.granted){const e=toPermissionStatus(i);return setState({status:e}),e}const o=await toDevice(await n.getDevicePushTokenAsync(),t);return o?(await registerOnce(o),tokenSubscription?.remove(),tokenSubscription=n.addPushTokenListener(e=>{(unregistering??Promise.resolve()).then(()=>state.enabled?toDevice(e,t):null).then(e=>e&&JSON.stringify(e)!==registeredKey?registerOnce(e):void 0).catch(e=>{Logger.error("[push] re-registering a new token failed",e),setState({registrationError:e instanceof Error?e:new Error(String(e))})})}),setState({status:"granted",enabled:!0}),"granted"):(setState({status:"unavailable"}),"unavailable")};export const readDevicePushToken=async()=>{const e=resolveModules();if(!e)return null;await tokenDrop;if(!(await e.notifications.getPermissionsAsync()).granted)return null;const t=await e.notifications.getDevicePushTokenAsync(),n="android"===t.type?"android":"ios"===t.type?"ios":null;return n&&"string"==typeof t.data?{platform:n,token:t.data}:null};const stopFollowingToken=()=>{tokenSubscription?.remove(),tokenSubscription=null,registeredKey=null,setState({enabled:!1,registrationError:null})};export const disablePush=async()=>{const e=requireConfig(),t=await e.getInstallationId();await Promise.allSettled([registering?.promise]);let settle=()=>{};const n=new Promise(e=>{settle=e});unregistering=n;try{await e.unregister(t),stopFollowingToken()}finally{unregistering===n&&(unregistering=null),settle()}};export const resetPush=async()=>{stopFollowingToken();const e=resolveModules();if(!e)return;const t=e.notifications.unregisterForNotificationsAsync();tokenDrop=Promise.allSettled([t]),await t};export const setBadgeCount=async e=>{const t=resolveModules();t&&await t.notifications.setBadgeCountAsync(e)};export const dismissAllNotifications=async()=>{const e=resolveModules();if(e)try{await e.notifications.dismissAllNotificationsAsync()}catch(e){Logger.warn("[push] dismissing the notifications failed",e)}};export const setCategories=async e=>{const t=resolveModules();if(t)for(const n of e)await t.notifications.setNotificationCategoryAsync(n.id,toNotificationActions(n.actions))};export const onAction=e=>{actionHandler=e;const t=resolveModules();return t&&(listenForResponses(t.notifications),drainPending(t.notifications)),()=>{actionHandler===e&&(actionHandler=null)}};export const onReceive=e=>{receiveHandlers.add(e);const t=resolveModules();return t&&!listeningForReceived&&(listeningForReceived=!0,t.notifications.addNotificationReceivedListener(e=>{const t=toPushReceived(e);for(const e of[...receiveHandlers])try{e(t)}catch(e){Logger.error("[push] onReceive threw",e)}})),()=>{receiveHandlers.delete(e)}};export const notifyLocal=async({title:e,body:t,data:n})=>{const i=resolveModules();i&&await i.notifications.scheduleNotificationAsync({content:{title:e,body:t,data:n??{}},trigger:null})};const subscribe=e=>(subscribers.add(e),()=>{subscribers.delete(e)}),getSnapshot=()=>state,enable=async()=>{await enablePush()};export const usePush=()=>({...useSyncExternalStore(subscribe,getSnapshot,getSnapshot),enable:enable,disable:disablePush});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo,useSyncExternalStore}from"react";import{addMinAppVersionListener,getMinAppVersion}from"../api/minAppVersion.js";import{getConfigValue}from"../config/index.js";import{Logger}from"../logger/index.js";import{expoApplicationBackend,getDeviceInfo,readAppBuild}from"./appBuild.js";import{isBuildBelowMinimum}from"./buildNumber.js";const missing=(e,r)=>{const t=new Error(`[VersionCheck] the app's ${e} is not available. Call setConfig({ ${r}: ... }). Every Webority app already has this value in appsettings.Compiled.json.`);return Logger.error(t.message),t},getSystemName=()=>{const{Platform:e}=require("react-native");return e.OS},getBundleId=()=>{const e=getConfigValue("appId");if(e)return e;const r=(getDeviceInfo()??expoApplicationBackend).getBundleId();if(r)return r;throw missing("store identifier","appId")},getBuildNumber=()=>{const e=readAppBuild();if(null!==e)return e;throw missing("build number","appBuild")},getCountry=()=>getConfigValue("country","in").toLowerCase(),subscribeMinimum=e=>addMinAppVersionListener(()=>e()),getFallbackStoreUrl=()=>{const e=getSystemName().toLowerCase(),r=getCountry();if("ios"===e){const e=getConfigValue("appStoreId");return e?`https://apps.apple.com/${r}/app/id${e}`:`https://apps.apple.com/${r}/app/${getBundleId()}`}return`https://play.google.com/store/apps/details?id=${getBundleId()}&hl=${r}`},storeUrlOrNull=()=>{try{return getFallbackStoreUrl()}catch{return null}},checkForUpdates=()=>{const e=isBuildBelowMinimum(getBuildNumber(),getMinAppVersion());return{isNewVersionAvailable:e,updateType:e?"major":null,url:e?storeUrlOrNull():null}};export const VersionCheck={isNewVersionAvailable:async()=>checkForUpdates(),openUpdateUrl:async e=>{const{Linking:r}=require("react-native");try{if(e)Logger.info(`Opening app store URL: ${e}`),await r.openURL(e);else{const e=getFallbackStoreUrl();Logger.info(`Opening fallback store URL: ${e}`),await r.openURL(e)}return!0}catch(t){const i=t instanceof Error?t.message:String(t);Logger.error(`Failed to open store URL: ${i}`);try{if(e){const e=getFallbackStoreUrl();return Logger.info(`Trying fallback store URL: ${e}`),await r.openURL(e),!0}}catch(e){const r=e instanceof Error?e.message:String(e);Logger.error(`Failed to open fallback URL: ${r}`)}return!1}},getFallbackStoreUrl:getFallbackStoreUrl};const NOT_REQUIRED={isUpdateRequired:!1,updateUrl:null};export const useVersionCheck=(e,r=getConfigValue("environment","Development"))=>{const t=useSyncExternalStore(subscribeMinimum,getMinAppVersion,getMinAppVersion);return useMemo(()=>{if(!e||"
|
|
1
|
+
"use strict";import{useMemo,useSyncExternalStore}from"react";import{addMinAppVersionListener,getMinAppVersion}from"../api/minAppVersion.js";import{getConfigValue}from"../config/index.js";import{Logger}from"../logger/index.js";import{expoApplicationBackend,getDeviceInfo,readAppBuild}from"./appBuild.js";import{isBuildBelowMinimum}from"./buildNumber.js";const missing=(e,r)=>{const t=new Error(`[VersionCheck] the app's ${e} is not available. Call setConfig({ ${r}: ... }). Every Webority app already has this value in appsettings.Compiled.json.`);return Logger.error(t.message),t},getSystemName=()=>{const{Platform:e}=require("react-native");return e.OS},getBundleId=()=>{const e=getConfigValue("appId");if(e)return e;const r=(getDeviceInfo()??expoApplicationBackend).getBundleId();if(r)return r;throw missing("store identifier","appId")},getBuildNumber=()=>{const e=readAppBuild();if(null!==e)return e;throw missing("build number","appBuild")},getCountry=()=>getConfigValue("country","in").toLowerCase(),subscribeMinimum=e=>addMinAppVersionListener(()=>e()),getFallbackStoreUrl=()=>{const e=getSystemName().toLowerCase(),r=getCountry();if("ios"===e){const e=getConfigValue("appStoreId");return e?`https://apps.apple.com/${r}/app/id${e}`:`https://apps.apple.com/${r}/app/${getBundleId()}`}return`https://play.google.com/store/apps/details?id=${getBundleId()}&hl=${r}`},storeUrlOrNull=()=>{try{return getFallbackStoreUrl()}catch{return null}},checkForUpdates=()=>{const e=isBuildBelowMinimum(getBuildNumber(),getMinAppVersion());return{isNewVersionAvailable:e,updateType:e?"major":null,url:e?storeUrlOrNull():null}};export const VersionCheck={isNewVersionAvailable:async()=>checkForUpdates(),openUpdateUrl:async e=>{const{Linking:r}=require("react-native");try{if(e)Logger.info(`Opening app store URL: ${e}`),await r.openURL(e);else{const e=getFallbackStoreUrl();Logger.info(`Opening fallback store URL: ${e}`),await r.openURL(e)}return!0}catch(t){const i=t instanceof Error?t.message:String(t);Logger.error(`Failed to open store URL: ${i}`);try{if(e){const e=getFallbackStoreUrl();return Logger.info(`Trying fallback store URL: ${e}`),await r.openURL(e),!0}}catch(e){const r=e instanceof Error?e.message:String(e);Logger.error(`Failed to open fallback URL: ${r}`)}return!1}},getFallbackStoreUrl:getFallbackStoreUrl};const NOT_REQUIRED={isUpdateRequired:!1,updateUrl:null};export const useVersionCheck=(e,r=getConfigValue("environment","Development"))=>{const t=useSyncExternalStore(subscribeMinimum,getMinAppVersion,getMinAppVersion);return useMemo(()=>{if(!e||"Development"===r||null===t)return NOT_REQUIRED;try{if(!isBuildBelowMinimum(getBuildNumber(),t))return NOT_REQUIRED}catch{return NOT_REQUIRED}return{isUpdateRequired:!0,updateUrl:storeUrlOrNull()}},[e,r,t])};export{readAppBuild}from"./appBuild.js";export{isBuildBelowMinimum,parseBuildNumber}from"./buildNumber.js";
|
|
@@ -40,7 +40,7 @@ export type { ContractFullReply, ContractListQueryInput, OperationTable } from "
|
|
|
40
40
|
export { listQuery, mergeContracts, withBaseUrl } from "@webority/api-contract/call";
|
|
41
41
|
export type { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
|
|
42
42
|
export type { AccountIdProvider, ClientKind } from "./api/clientHeaders";
|
|
43
|
-
export { ACCOUNT_ID_HEADER, CLIENT_BUILD_HEADER, CLIENT_KIND, CLIENT_KIND_HEADER, clientRequestHeaders, getClientBuild, } from "./api/clientHeaders";
|
|
43
|
+
export { ACCOUNT_ID_HEADER, applyClientHeaders, CLIENT_BUILD_HEADER, CLIENT_KIND, CLIENT_KIND_HEADER, clientRequestHeaders, getClientBuild, } from "./api/clientHeaders";
|
|
44
44
|
export type { ContractBodyCallConfig, ContractCallConfig, ContractCaller } from "./api/contractCaller";
|
|
45
45
|
export { createContractCaller } from "./api/contractCaller";
|
|
46
46
|
export { buildCurl, logCurl } from "./api/curl";
|
|
@@ -48,7 +48,7 @@ export type { FetchRetryPolicy } from "./api/fetchRetry";
|
|
|
48
48
|
export { fetchWithRetry } from "./api/fetchRetry";
|
|
49
49
|
export { newIdempotencyKey } from "./api/idempotencyKey";
|
|
50
50
|
export type { MinAppVersionListener } from "./api/minAppVersion";
|
|
51
|
-
export { addMinAppVersionListener, getMinAppVersion, MIN_APP_VERSION_HEADER, } from "./api/minAppVersion";
|
|
51
|
+
export { addMinAppVersionListener, getMinAppVersion, MIN_APP_VERSION_HEADER, readMinAppVersion, } from "./api/minAppVersion";
|
|
52
52
|
export { default as publicClient } from "./api/publicClient";
|
|
53
53
|
export { applyRequestDefaults, newTraceparent, TRACEPARENT_HEADER } from "./api/requestDefaults";
|
|
54
54
|
export type { RetryPolicy } from "./api/retry";
|
|
@@ -50,10 +50,10 @@ export interface PushConfig {
|
|
|
50
50
|
onOpen: (data: Record<string, string>) => void;
|
|
51
51
|
/** Only for channels the app does not create natively. */
|
|
52
52
|
androidChannels?: PushAndroidChannel[] | undefined;
|
|
53
|
-
/** Whether a notification arriving while the app is open is shown. Defaults to true. */
|
|
54
|
-
showInForeground?: (() => boolean) | undefined;
|
|
55
|
-
/** Whether a notification shown while the app is open plays its sound. Defaults to true. */
|
|
56
|
-
playSoundInForeground?: (() => boolean) | undefined;
|
|
53
|
+
/** Whether a notification arriving while the app is open is shown, given that notification's data. Defaults to true. */
|
|
54
|
+
showInForeground?: ((data: Record<string, string>) => boolean) | undefined;
|
|
55
|
+
/** Whether a notification shown while the app is open plays its sound, given that notification's data. Defaults to true. */
|
|
56
|
+
playSoundInForeground?: ((data: Record<string, string>) => boolean) | undefined;
|
|
57
57
|
}
|
|
58
58
|
/** A button on a notification category. */
|
|
59
59
|
export interface PushCategoryAction {
|
|
@@ -160,7 +160,7 @@ export interface PushNotificationsLike {
|
|
|
160
160
|
getLastNotificationResponseAsync: () => Promise<NotificationResponseLike | null>;
|
|
161
161
|
clearLastNotificationResponseAsync?: (() => Promise<void>) | undefined;
|
|
162
162
|
setNotificationHandler: (handler: {
|
|
163
|
-
handleNotification: () => Promise<{
|
|
163
|
+
handleNotification: (notification: NotificationLike) => Promise<{
|
|
164
164
|
shouldShowBanner: boolean;
|
|
165
165
|
shouldShowList: boolean;
|
|
166
166
|
shouldPlaySound: boolean;
|
|
@@ -39,7 +39,7 @@ export declare const VersionCheck: VersionCheckType;
|
|
|
39
39
|
*
|
|
40
40
|
* @param isAppReady - Whether the app is ready to show the prompt
|
|
41
41
|
* @param environment - The app environment (defaults to the one in config); the
|
|
42
|
-
* check runs in `'Production'`
|
|
42
|
+
* check runs in `'Staging'` and `'Production'`, never in `'Development'`
|
|
43
43
|
*/
|
|
44
44
|
export declare const useVersionCheck: (isAppReady: boolean, environment?: Environment) => UpdateInfo;
|
|
45
45
|
export { readAppBuild } from "./appBuild";
|
|
@@ -40,7 +40,7 @@ export type { ContractFullReply, ContractListQueryInput, OperationTable } from "
|
|
|
40
40
|
export { listQuery, mergeContracts, withBaseUrl } from "@webority/api-contract/call";
|
|
41
41
|
export type { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
|
|
42
42
|
export type { AccountIdProvider, ClientKind } from "./api/clientHeaders.js";
|
|
43
|
-
export { ACCOUNT_ID_HEADER, CLIENT_BUILD_HEADER, CLIENT_KIND, CLIENT_KIND_HEADER, clientRequestHeaders, getClientBuild, } from "./api/clientHeaders.js";
|
|
43
|
+
export { ACCOUNT_ID_HEADER, applyClientHeaders, CLIENT_BUILD_HEADER, CLIENT_KIND, CLIENT_KIND_HEADER, clientRequestHeaders, getClientBuild, } from "./api/clientHeaders.js";
|
|
44
44
|
export type { ContractBodyCallConfig, ContractCallConfig, ContractCaller } from "./api/contractCaller.js";
|
|
45
45
|
export { createContractCaller } from "./api/contractCaller.js";
|
|
46
46
|
export { buildCurl, logCurl } from "./api/curl.js";
|
|
@@ -48,7 +48,7 @@ export type { FetchRetryPolicy } from "./api/fetchRetry.js";
|
|
|
48
48
|
export { fetchWithRetry } from "./api/fetchRetry.js";
|
|
49
49
|
export { newIdempotencyKey } from "./api/idempotencyKey.js";
|
|
50
50
|
export type { MinAppVersionListener } from "./api/minAppVersion.js";
|
|
51
|
-
export { addMinAppVersionListener, getMinAppVersion, MIN_APP_VERSION_HEADER, } from "./api/minAppVersion.js";
|
|
51
|
+
export { addMinAppVersionListener, getMinAppVersion, MIN_APP_VERSION_HEADER, readMinAppVersion, } from "./api/minAppVersion.js";
|
|
52
52
|
export { default as publicClient } from "./api/publicClient.js";
|
|
53
53
|
export { applyRequestDefaults, newTraceparent, TRACEPARENT_HEADER } from "./api/requestDefaults.js";
|
|
54
54
|
export type { RetryPolicy } from "./api/retry.js";
|
|
@@ -50,10 +50,10 @@ export interface PushConfig {
|
|
|
50
50
|
onOpen: (data: Record<string, string>) => void;
|
|
51
51
|
/** Only for channels the app does not create natively. */
|
|
52
52
|
androidChannels?: PushAndroidChannel[] | undefined;
|
|
53
|
-
/** Whether a notification arriving while the app is open is shown. Defaults to true. */
|
|
54
|
-
showInForeground?: (() => boolean) | undefined;
|
|
55
|
-
/** Whether a notification shown while the app is open plays its sound. Defaults to true. */
|
|
56
|
-
playSoundInForeground?: (() => boolean) | undefined;
|
|
53
|
+
/** Whether a notification arriving while the app is open is shown, given that notification's data. Defaults to true. */
|
|
54
|
+
showInForeground?: ((data: Record<string, string>) => boolean) | undefined;
|
|
55
|
+
/** Whether a notification shown while the app is open plays its sound, given that notification's data. Defaults to true. */
|
|
56
|
+
playSoundInForeground?: ((data: Record<string, string>) => boolean) | undefined;
|
|
57
57
|
}
|
|
58
58
|
/** A button on a notification category. */
|
|
59
59
|
export interface PushCategoryAction {
|
|
@@ -160,7 +160,7 @@ export interface PushNotificationsLike {
|
|
|
160
160
|
getLastNotificationResponseAsync: () => Promise<NotificationResponseLike | null>;
|
|
161
161
|
clearLastNotificationResponseAsync?: (() => Promise<void>) | undefined;
|
|
162
162
|
setNotificationHandler: (handler: {
|
|
163
|
-
handleNotification: () => Promise<{
|
|
163
|
+
handleNotification: (notification: NotificationLike) => Promise<{
|
|
164
164
|
shouldShowBanner: boolean;
|
|
165
165
|
shouldShowList: boolean;
|
|
166
166
|
shouldPlaySound: boolean;
|
|
@@ -39,7 +39,7 @@ export declare const VersionCheck: VersionCheckType;
|
|
|
39
39
|
*
|
|
40
40
|
* @param isAppReady - Whether the app is ready to show the prompt
|
|
41
41
|
* @param environment - The app environment (defaults to the one in config); the
|
|
42
|
-
* check runs in `'Production'`
|
|
42
|
+
* check runs in `'Staging'` and `'Production'`, never in `'Development'`
|
|
43
43
|
*/
|
|
44
44
|
export declare const useVersionCheck: (isAppReady: boolean, environment?: Environment) => UpdateInfo;
|
|
45
45
|
export { readAppBuild } from "./appBuild.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.185.0",
|
|
4
4
|
"description": "Platform layer for Webority React Native apps: HTTP clients, auth/token storage, config, logging, formatters, validators, network status, permissions, storage, version checks and over-the-air updates. No UI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -404,7 +404,7 @@
|
|
|
404
404
|
}
|
|
405
405
|
},
|
|
406
406
|
"dependencies": {
|
|
407
|
-
"@webority/api-contract": "0.
|
|
407
|
+
"@webority/api-contract": "0.185.0",
|
|
408
408
|
"axios": "^1.19.0",
|
|
409
409
|
"libphonenumber-js": "^1.12.41"
|
|
410
410
|
},
|