@terreno/syncdb 57.21.0 → 58.0.0-beta.2
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/CHANGELOG.md +89 -0
- package/README.md +8 -8
- package/dist/api/apiError.d.ts +43 -0
- package/dist/api/apiError.d.ts.map +1 -0
- package/dist/api/apiError.js +28 -0
- package/dist/api/apiError.js.map +1 -0
- package/dist/api/apiFetch.d.ts +44 -0
- package/dist/api/apiFetch.d.ts.map +1 -0
- package/dist/api/apiFetch.js +203 -0
- package/dist/api/apiFetch.js.map +1 -0
- package/dist/api/client.d.ts +70 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +240 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/client.test.d.ts +2 -0
- package/dist/api/client.test.d.ts.map +1 -0
- package/dist/api/client.test.js +588 -0
- package/dist/api/client.test.js.map +1 -0
- package/dist/app/app.d.ts +13 -0
- package/dist/app/app.d.ts.map +1 -0
- package/dist/app/app.js +13 -0
- package/dist/app/app.js.map +1 -0
- package/dist/app/devConsoleLogger.d.ts +18 -0
- package/dist/app/devConsoleLogger.d.ts.map +1 -0
- package/dist/app/devConsoleLogger.js +147 -0
- package/dist/app/devConsoleLogger.js.map +1 -0
- package/dist/app/devConsoleLogger.test.d.ts +2 -0
- package/dist/app/devConsoleLogger.test.d.ts.map +1 -0
- package/dist/app/devConsoleLogger.test.js +202 -0
- package/dist/app/devConsoleLogger.test.js.map +1 -0
- package/dist/app/mcpTools.d.ts +32 -0
- package/dist/app/mcpTools.d.ts.map +1 -0
- package/dist/app/mcpTools.js +61 -0
- package/dist/app/mcpTools.js.map +1 -0
- package/dist/app/permissions.d.ts +26 -0
- package/dist/app/permissions.d.ts.map +1 -0
- package/dist/app/permissions.js +37 -0
- package/dist/app/permissions.js.map +1 -0
- package/dist/app/permissions.test.d.ts +2 -0
- package/dist/app/permissions.test.d.ts.map +1 -0
- package/dist/app/permissions.test.js +36 -0
- package/dist/app/permissions.test.js.map +1 -0
- package/dist/app/upgradeCheck.d.ts +46 -0
- package/dist/app/upgradeCheck.d.ts.map +1 -0
- package/dist/app/upgradeCheck.js +121 -0
- package/dist/app/upgradeCheck.js.map +1 -0
- package/dist/auth/SessionProvider.d.ts +40 -0
- package/dist/auth/SessionProvider.d.ts.map +1 -0
- package/dist/auth/SessionProvider.js +44 -0
- package/dist/auth/SessionProvider.js.map +1 -0
- package/dist/auth/SessionProvider.test.d.ts +2 -0
- package/dist/auth/SessionProvider.test.d.ts.map +1 -0
- package/dist/auth/SessionProvider.test.js +240 -0
- package/dist/auth/SessionProvider.test.js.map +1 -0
- package/dist/auth/TerrenoAccountSecurityScreen.d.ts +25 -0
- package/dist/auth/TerrenoAccountSecurityScreen.d.ts.map +1 -0
- package/dist/auth/TerrenoAccountSecurityScreen.js +21 -0
- package/dist/auth/TerrenoAccountSecurityScreen.js.map +1 -0
- package/dist/auth/TerrenoLoginScreen.d.ts +62 -0
- package/dist/auth/TerrenoLoginScreen.d.ts.map +1 -0
- package/dist/auth/TerrenoLoginScreen.js +45 -0
- package/dist/auth/TerrenoLoginScreen.js.map +1 -0
- package/dist/auth/auth.d.ts +36 -0
- package/dist/auth/auth.d.ts.map +1 -0
- package/dist/auth/auth.js +35 -0
- package/dist/auth/auth.js.map +1 -0
- package/dist/auth/betterAuthAdapter.d.ts +1 -1
- package/dist/auth/betterAuthClient.d.ts +276 -0
- package/dist/auth/betterAuthClient.d.ts.map +1 -0
- package/dist/auth/betterAuthClient.js +744 -0
- package/dist/auth/betterAuthClient.js.map +1 -0
- package/dist/auth/betterAuthClient.types.test.d.ts +2 -0
- package/dist/auth/betterAuthClient.types.test.d.ts.map +1 -0
- package/dist/auth/betterAuthClient.types.test.js +151 -0
- package/dist/auth/betterAuthClient.types.test.js.map +1 -0
- package/dist/auth/betterAuthClientRegistry.d.ts +51 -0
- package/dist/auth/betterAuthClientRegistry.d.ts.map +1 -0
- package/dist/auth/betterAuthClientRegistry.js +69 -0
- package/dist/auth/betterAuthClientRegistry.js.map +1 -0
- package/dist/auth/betterAuthClientRegistry.test.d.ts +2 -0
- package/dist/auth/betterAuthClientRegistry.test.d.ts.map +1 -0
- package/dist/auth/betterAuthClientRegistry.test.js +91 -0
- package/dist/auth/betterAuthClientRegistry.test.js.map +1 -0
- package/dist/auth/betterAuthTypes.d.ts +172 -0
- package/dist/auth/betterAuthTypes.d.ts.map +1 -0
- package/dist/auth/betterAuthTypes.js +7 -0
- package/dist/auth/betterAuthTypes.js.map +1 -0
- package/dist/auth/jwtAuthAdapter.d.ts +102 -0
- package/dist/auth/jwtAuthAdapter.d.ts.map +1 -0
- package/dist/auth/jwtAuthAdapter.js +282 -0
- package/dist/auth/jwtAuthAdapter.js.map +1 -0
- package/dist/auth/jwtAuthAdapter.test.d.ts +2 -0
- package/dist/auth/jwtAuthAdapter.test.d.ts.map +1 -0
- package/dist/auth/jwtAuthAdapter.test.js +614 -0
- package/dist/auth/jwtAuthAdapter.test.js.map +1 -0
- package/dist/auth/loginErrors.d.ts +75 -0
- package/dist/auth/loginErrors.d.ts.map +1 -0
- package/dist/auth/loginErrors.js +154 -0
- package/dist/auth/loginErrors.js.map +1 -0
- package/dist/auth/loginErrors.test.d.ts +2 -0
- package/dist/auth/loginErrors.test.d.ts.map +1 -0
- package/dist/auth/loginErrors.test.js +70 -0
- package/dist/auth/loginErrors.test.js.map +1 -0
- package/dist/auth/ownEntry.d.ts +8 -0
- package/dist/auth/ownEntry.d.ts.map +1 -0
- package/dist/auth/ownEntry.js +13 -0
- package/dist/auth/ownEntry.js.map +1 -0
- package/dist/auth/ownEntry.test.d.ts +2 -0
- package/dist/auth/ownEntry.test.d.ts.map +1 -0
- package/dist/auth/ownEntry.test.js +18 -0
- package/dist/auth/ownEntry.test.js.map +1 -0
- package/dist/auth/platform.d.ts +3 -0
- package/dist/auth/platform.d.ts.map +1 -0
- package/dist/auth/platform.js +4 -0
- package/dist/auth/platform.js.map +1 -0
- package/dist/auth/rememberedAccounts.d.ts +126 -0
- package/dist/auth/rememberedAccounts.d.ts.map +1 -0
- package/dist/auth/rememberedAccounts.js +399 -0
- package/dist/auth/rememberedAccounts.js.map +1 -0
- package/dist/auth/rememberedAccounts.test.d.ts +2 -0
- package/dist/auth/rememberedAccounts.test.d.ts.map +1 -0
- package/dist/auth/rememberedAccounts.test.js +676 -0
- package/dist/auth/rememberedAccounts.test.js.map +1 -0
- package/dist/auth/session.d.ts +118 -0
- package/dist/auth/session.d.ts.map +1 -0
- package/dist/auth/session.js +370 -0
- package/dist/auth/session.js.map +1 -0
- package/dist/auth/session.test.d.ts +2 -0
- package/dist/auth/session.test.d.ts.map +1 -0
- package/dist/auth/session.test.js +825 -0
- package/dist/auth/session.test.js.map +1 -0
- package/dist/auth/tokenExpiry.d.ts +70 -0
- package/dist/auth/tokenExpiry.d.ts.map +1 -0
- package/dist/auth/tokenExpiry.js +123 -0
- package/dist/auth/tokenExpiry.js.map +1 -0
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.js +1 -1
- package/dist/auth/useAccountSecurity.d.ts +183 -0
- package/dist/auth/useAccountSecurity.d.ts.map +1 -0
- package/dist/auth/useAccountSecurity.js +399 -0
- package/dist/auth/useAccountSecurity.js.map +1 -0
- package/dist/auth/useAccountSecurity.types.test.d.ts +2 -0
- package/dist/auth/useAccountSecurity.types.test.d.ts.map +1 -0
- package/dist/auth/useAccountSecurity.types.test.js +21 -0
- package/dist/auth/useAccountSecurity.types.test.js.map +1 -0
- package/dist/auth/useAuthMethods.d.ts +67 -0
- package/dist/auth/useAuthMethods.d.ts.map +1 -0
- package/dist/auth/useAuthMethods.js +77 -0
- package/dist/auth/useAuthMethods.js.map +1 -0
- package/dist/auth/useAuthMethods.test.d.ts +2 -0
- package/dist/auth/useAuthMethods.test.d.ts.map +1 -0
- package/dist/auth/useAuthMethods.test.js +145 -0
- package/dist/auth/useAuthMethods.test.js.map +1 -0
- package/dist/auth/useJwtAuth.d.ts +31 -0
- package/dist/auth/useJwtAuth.d.ts.map +1 -0
- package/dist/auth/useJwtAuth.js +58 -0
- package/dist/auth/useJwtAuth.js.map +1 -0
- package/dist/auth/useJwtAuth.test.d.ts +2 -0
- package/dist/auth/useJwtAuth.test.d.ts.map +1 -0
- package/dist/auth/useJwtAuth.test.js +165 -0
- package/dist/auth/useJwtAuth.test.js.map +1 -0
- package/dist/auth/useLoginController.d.ts +248 -0
- package/dist/auth/useLoginController.d.ts.map +1 -0
- package/dist/auth/useLoginController.js +671 -0
- package/dist/auth/useLoginController.js.map +1 -0
- package/dist/auth/useLoginController.types.test.d.ts +2 -0
- package/dist/auth/useLoginController.types.test.d.ts.map +1 -0
- package/dist/auth/useLoginController.types.test.js +19 -0
- package/dist/auth/useLoginController.types.test.js.map +1 -0
- package/dist/buildNumber.d.ts +34 -0
- package/dist/buildNumber.d.ts.map +1 -0
- package/dist/buildNumber.js +62 -0
- package/dist/buildNumber.js.map +1 -0
- package/dist/buildNumber.test.d.ts +2 -0
- package/dist/buildNumber.test.d.ts.map +1 -0
- package/dist/buildNumber.test.js +114 -0
- package/dist/buildNumber.test.js.map +1 -0
- package/dist/client.d.ts +18 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +245 -185
- package/dist/client.js.map +1 -1
- package/dist/client.socketEvents.test.d.ts +2 -0
- package/dist/client.socketEvents.test.d.ts.map +1 -0
- package/dist/client.socketEvents.test.js +64 -0
- package/dist/client.socketEvents.test.js.map +1 -0
- package/dist/client.test.js +87 -1
- package/dist/client.test.js.map +1 -1
- package/dist/codegen/cli.js +23 -12
- package/dist/codegen/cli.js.map +1 -1
- package/dist/codegen/cli.test.js +57 -0
- package/dist/codegen/cli.test.js.map +1 -1
- package/dist/codegen/discoverCollections.d.ts.map +1 -1
- package/dist/codegen/discoverCollections.js +4 -0
- package/dist/codegen/discoverCollections.js.map +1 -1
- package/dist/codegen/discoverOperations.d.ts +11 -0
- package/dist/codegen/discoverOperations.d.ts.map +1 -0
- package/dist/codegen/discoverOperations.js +135 -0
- package/dist/codegen/discoverOperations.js.map +1 -0
- package/dist/codegen/emitApi.d.ts +8 -0
- package/dist/codegen/emitApi.d.ts.map +1 -0
- package/dist/codegen/emitApi.js +312 -0
- package/dist/codegen/emitApi.js.map +1 -0
- package/dist/codegen/emitApi.test.d.ts +2 -0
- package/dist/codegen/emitApi.test.d.ts.map +1 -0
- package/dist/codegen/emitApi.test.js +360 -0
- package/dist/codegen/emitApi.test.js.map +1 -0
- package/dist/codegen/emitSdk.js +2 -2
- package/dist/codegen/generate.d.ts +6 -1
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/codegen/generate.js +18 -0
- package/dist/codegen/generate.js.map +1 -1
- package/dist/codegen/generate.test.js +53 -1
- package/dist/codegen/generate.test.js.map +1 -1
- package/dist/codegen/hookNames.d.ts +11 -0
- package/dist/codegen/hookNames.d.ts.map +1 -1
- package/dist/codegen/hookNames.js +23 -0
- package/dist/codegen/hookNames.js.map +1 -1
- package/dist/codegen/safeIdentifiers.d.ts +5 -1
- package/dist/codegen/safeIdentifiers.d.ts.map +1 -1
- package/dist/codegen/safeIdentifiers.js +7 -2
- package/dist/codegen/safeIdentifiers.js.map +1 -1
- package/dist/codegen/safeIdentifiers.test.js +9 -0
- package/dist/codegen/safeIdentifiers.test.js.map +1 -1
- package/dist/codegen/types.d.ts +46 -1
- package/dist/codegen/types.d.ts.map +1 -1
- package/dist/config/baseUrl.d.ts +13 -0
- package/dist/config/baseUrl.d.ts.map +1 -0
- package/dist/config/baseUrl.js +49 -0
- package/dist/config/baseUrl.js.map +1 -0
- package/dist/config/baseUrl.test.d.ts +2 -0
- package/dist/config/baseUrl.test.d.ts.map +1 -0
- package/dist/config/baseUrl.test.js +42 -0
- package/dist/config/baseUrl.test.js.map +1 -0
- package/dist/config/resolveBaseUrls.d.ts +53 -0
- package/dist/config/resolveBaseUrls.d.ts.map +1 -0
- package/dist/config/resolveBaseUrls.js +80 -0
- package/dist/config/resolveBaseUrls.js.map +1 -0
- package/dist/config/resolveBaseUrls.test.d.ts +2 -0
- package/dist/config/resolveBaseUrls.test.d.ts.map +1 -0
- package/dist/config/resolveBaseUrls.test.js +265 -0
- package/dist/config/resolveBaseUrls.test.js.map +1 -0
- package/dist/crypto/keyProviders.d.ts +2 -2
- package/dist/crypto/keyProviders.d.ts.map +1 -1
- package/dist/crypto/keyProviders.js +15 -4
- package/dist/crypto/keyProviders.js.map +1 -1
- package/dist/crypto/keyProviders.test.js +19 -0
- package/dist/crypto/keyProviders.test.js.map +1 -1
- package/dist/crypto/types.d.ts +5 -0
- package/dist/crypto/types.d.ts.map +1 -1
- package/dist/flags/flagTestServer.d.ts +19 -0
- package/dist/flags/flagTestServer.d.ts.map +1 -0
- package/dist/flags/flagTestServer.js +58 -0
- package/dist/flags/flagTestServer.js.map +1 -0
- package/dist/flags/useFeatureFlags.d.ts +30 -0
- package/dist/flags/useFeatureFlags.d.ts.map +1 -0
- package/dist/flags/useFeatureFlags.js +83 -0
- package/dist/flags/useFeatureFlags.js.map +1 -0
- package/dist/flags/useFeatureFlags.test.d.ts +2 -0
- package/dist/flags/useFeatureFlags.test.d.ts.map +1 -0
- package/dist/flags/useFeatureFlags.test.js +116 -0
- package/dist/flags/useFeatureFlags.test.js.map +1 -0
- package/dist/flags/useTerrenoFeatureFlags.d.ts +50 -0
- package/dist/flags/useTerrenoFeatureFlags.d.ts.map +1 -0
- package/dist/flags/useTerrenoFeatureFlags.js +125 -0
- package/dist/flags/useTerrenoFeatureFlags.js.map +1 -0
- package/dist/flags/useTerrenoFeatureFlags.test.d.ts +2 -0
- package/dist/flags/useTerrenoFeatureFlags.test.d.ts.map +1 -0
- package/dist/flags/useTerrenoFeatureFlags.test.js +259 -0
- package/dist/flags/useTerrenoFeatureFlags.test.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/isolated/TerrenoAccountSecurityScreen.isolated.d.ts +2 -0
- package/dist/isolated/TerrenoAccountSecurityScreen.isolated.d.ts.map +1 -0
- package/dist/isolated/TerrenoAccountSecurityScreen.isolated.js +94 -0
- package/dist/isolated/TerrenoAccountSecurityScreen.isolated.js.map +1 -0
- package/dist/isolated/TerrenoLoginScreen.isolated.d.ts +2 -0
- package/dist/isolated/TerrenoLoginScreen.isolated.d.ts.map +1 -0
- package/dist/isolated/TerrenoLoginScreen.isolated.js +183 -0
- package/dist/isolated/TerrenoLoginScreen.isolated.js.map +1 -0
- package/dist/isolated/betterAuthClient.isolated.d.ts +2 -0
- package/dist/isolated/betterAuthClient.isolated.d.ts.map +1 -0
- package/dist/isolated/betterAuthClient.isolated.js +1734 -0
- package/dist/isolated/betterAuthClient.isolated.js.map +1 -0
- package/dist/isolated/betterAuthClient.native.isolated.d.ts +2 -0
- package/dist/isolated/betterAuthClient.native.isolated.d.ts.map +1 -0
- package/dist/isolated/betterAuthClient.native.isolated.js +153 -0
- package/dist/isolated/betterAuthClient.native.isolated.js.map +1 -0
- package/dist/isolated/mcpTools.isolated.d.ts +2 -0
- package/dist/isolated/mcpTools.isolated.d.ts.map +1 -0
- package/dist/isolated/mcpTools.isolated.js +197 -0
- package/dist/isolated/mcpTools.isolated.js.map +1 -0
- package/dist/isolated/rememberedAccounts.native.isolated.d.ts +2 -0
- package/dist/isolated/rememberedAccounts.native.isolated.d.ts.map +1 -0
- package/dist/isolated/rememberedAccounts.native.isolated.js +50 -0
- package/dist/isolated/rememberedAccounts.native.isolated.js.map +1 -0
- package/dist/isolated/sessionLogout.isolated.d.ts +2 -0
- package/dist/isolated/sessionLogout.isolated.d.ts.map +1 -0
- package/dist/isolated/sessionLogout.isolated.js +133 -0
- package/dist/isolated/sessionLogout.isolated.js.map +1 -0
- package/dist/isolated/tokenExpiry.isolated.d.ts +2 -0
- package/dist/isolated/tokenExpiry.isolated.d.ts.map +1 -0
- package/dist/isolated/tokenExpiry.isolated.js +232 -0
- package/dist/isolated/tokenExpiry.isolated.js.map +1 -0
- package/dist/isolated/upgradeCheck.isolated.d.ts +2 -0
- package/dist/isolated/upgradeCheck.isolated.d.ts.map +1 -0
- package/dist/isolated/upgradeCheck.isolated.js +241 -0
- package/dist/isolated/upgradeCheck.isolated.js.map +1 -0
- package/dist/isolated/useAccountSecurity.isolated.d.ts +2 -0
- package/dist/isolated/useAccountSecurity.isolated.d.ts.map +1 -0
- package/dist/isolated/useAccountSecurity.isolated.js +851 -0
- package/dist/isolated/useAccountSecurity.isolated.js.map +1 -0
- package/dist/isolated/useAccountSecurity.native.isolated.d.ts +2 -0
- package/dist/isolated/useAccountSecurity.native.isolated.d.ts.map +1 -0
- package/dist/isolated/useAccountSecurity.native.isolated.js +52 -0
- package/dist/isolated/useAccountSecurity.native.isolated.js.map +1 -0
- package/dist/isolated/useLoginController.isolated.d.ts +2 -0
- package/dist/isolated/useLoginController.isolated.d.ts.map +1 -0
- package/dist/isolated/useLoginController.isolated.js +1116 -0
- package/dist/isolated/useLoginController.isolated.js.map +1 -0
- package/dist/mutations/entityIds.d.ts +23 -0
- package/dist/mutations/entityIds.d.ts.map +1 -0
- package/dist/mutations/entityIds.js +31 -0
- package/dist/mutations/entityIds.js.map +1 -0
- package/dist/mutations/entityIds.test.d.ts +2 -0
- package/dist/mutations/entityIds.test.d.ts.map +1 -0
- package/dist/mutations/entityIds.test.js +48 -0
- package/dist/mutations/entityIds.test.js.map +1 -0
- package/dist/persisters/defaultPersisterFactory.native.d.ts.map +1 -1
- package/dist/persisters/defaultPersisterFactory.native.js +2 -0
- package/dist/persisters/defaultPersisterFactory.native.js.map +1 -1
- package/dist/persisters/encryptedIndexedDbPersister.d.ts.map +1 -1
- package/dist/persisters/encryptedIndexedDbPersister.js +3 -0
- package/dist/persisters/encryptedIndexedDbPersister.js.map +1 -1
- package/dist/persisters/types.d.ts +6 -0
- package/dist/persisters/types.d.ts.map +1 -1
- package/dist/query/queryWindows.js +2 -2
- package/dist/query/queryWindows.js.map +1 -1
- package/dist/react/apiHooks.d.ts +87 -0
- package/dist/react/apiHooks.d.ts.map +1 -0
- package/dist/react/apiHooks.js +195 -0
- package/dist/react/apiHooks.js.map +1 -0
- package/dist/react/apiHooks.test.d.ts +2 -0
- package/dist/react/apiHooks.test.d.ts.map +1 -0
- package/dist/react/apiHooks.test.js +366 -0
- package/dist/react/apiHooks.test.js.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/provider.d.ts +2 -0
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.js +2 -0
- package/dist/react/provider.js.map +1 -1
- package/dist/react/useSocketEvent.d.ts +27 -0
- package/dist/react/useSocketEvent.d.ts.map +1 -0
- package/dist/react/useSocketEvent.js +36 -0
- package/dist/react/useSocketEvent.js.map +1 -0
- package/dist/react/useSocketEvent.test.d.ts +2 -0
- package/dist/react/useSocketEvent.test.d.ts.map +1 -0
- package/dist/react/useSocketEvent.test.js +76 -0
- package/dist/react/useSocketEvent.test.js.map +1 -0
- package/dist/sync/replayCoordinator.d.ts.map +1 -1
- package/dist/sync/replayCoordinator.js +5 -4
- package/dist/sync/replayCoordinator.js.map +1 -1
- package/dist/sync/socketTransport.d.ts.map +1 -1
- package/dist/sync/socketTransport.js +14 -1
- package/dist/sync/socketTransport.js.map +1 -1
- package/dist/sync/socketTransport.test.js +42 -0
- package/dist/sync/socketTransport.test.js.map +1 -1
- package/dist/sync/transport.d.ts +9 -0
- package/dist/sync/transport.d.ts.map +1 -1
- package/dist/sync/transport.js +13 -0
- package/dist/sync/transport.js.map +1 -1
- package/dist/testing/fakeTransport.d.ts +5 -1
- package/dist/testing/fakeTransport.d.ts.map +1 -1
- package/dist/testing/fakeTransport.js +26 -0
- package/dist/testing/fakeTransport.js.map +1 -1
- package/dist/testing/fakeTransport.test.js +15 -0
- package/dist/testing/fakeTransport.test.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +93 -8
- package/src/api/apiError.ts +47 -0
- package/src/api/apiFetch.ts +245 -0
- package/src/api/client.test.ts +711 -0
- package/src/api/client.ts +367 -0
- package/src/app/app.ts +30 -0
- package/src/app/devConsoleLogger.test.ts +246 -0
- package/src/app/devConsoleLogger.ts +173 -0
- package/src/app/mcpTools.ts +101 -0
- package/src/app/permissions.test.ts +44 -0
- package/src/app/permissions.ts +58 -0
- package/src/app/upgradeCheck.ts +177 -0
- package/src/auth/SessionProvider.test.tsx +286 -0
- package/src/auth/SessionProvider.tsx +87 -0
- package/src/auth/TerrenoAccountSecurityScreen.tsx +56 -0
- package/src/auth/TerrenoLoginScreen.tsx +131 -0
- package/src/auth/auth.ts +117 -0
- package/src/auth/betterAuthAdapter.ts +1 -1
- package/src/auth/betterAuthClient.ts +997 -0
- package/src/auth/betterAuthClient.types.test.ts +197 -0
- package/src/auth/betterAuthClientRegistry.test.ts +114 -0
- package/src/auth/betterAuthClientRegistry.ts +99 -0
- package/src/auth/betterAuthTypes.ts +189 -0
- package/src/auth/jwtAuthAdapter.test.ts +754 -0
- package/src/auth/jwtAuthAdapter.ts +420 -0
- package/src/auth/loginErrors.test.ts +97 -0
- package/src/auth/loginErrors.ts +249 -0
- package/src/auth/ownEntry.test.ts +22 -0
- package/src/auth/ownEntry.ts +15 -0
- package/src/auth/platform.ts +4 -0
- package/src/auth/rememberedAccounts.test.ts +844 -0
- package/src/auth/rememberedAccounts.ts +568 -0
- package/src/auth/session.test.ts +976 -0
- package/src/auth/session.ts +509 -0
- package/src/auth/tokenExpiry.ts +185 -0
- package/src/auth/types.ts +1 -1
- package/src/auth/useAccountSecurity.ts +678 -0
- package/src/auth/useAccountSecurity.types.test.ts +28 -0
- package/src/auth/useAuthMethods.test.ts +181 -0
- package/src/auth/useAuthMethods.ts +137 -0
- package/src/auth/useJwtAuth.test.tsx +202 -0
- package/src/auth/useJwtAuth.ts +102 -0
- package/src/auth/useLoginController.ts +1038 -0
- package/src/auth/useLoginController.types.test.ts +26 -0
- package/src/buildNumber.test.ts +139 -0
- package/src/buildNumber.ts +75 -0
- package/src/client.socketEvents.test.ts +77 -0
- package/src/client.test.ts +109 -1
- package/src/client.ts +104 -19
- package/src/codegen/cli.test.ts +66 -0
- package/src/codegen/cli.ts +23 -12
- package/src/codegen/discoverCollections.ts +4 -0
- package/src/codegen/discoverOperations.ts +172 -0
- package/src/codegen/emitApi.test.tsx +445 -0
- package/src/codegen/emitApi.ts +396 -0
- package/src/codegen/emitSdk.ts +2 -2
- package/src/codegen/fixtures/openapi.api.json +840 -0
- package/src/codegen/generate.test.ts +54 -1
- package/src/codegen/generate.ts +20 -1
- package/src/codegen/hookNames.ts +35 -0
- package/src/codegen/safeIdentifiers.test.ts +20 -0
- package/src/codegen/safeIdentifiers.ts +7 -2
- package/src/codegen/types.ts +45 -1
- package/src/config/baseUrl.test.ts +53 -0
- package/src/config/baseUrl.ts +68 -0
- package/src/config/resolveBaseUrls.test.ts +308 -0
- package/src/config/resolveBaseUrls.ts +118 -0
- package/src/crypto/keyProviders.test.ts +23 -0
- package/src/crypto/keyProviders.ts +15 -4
- package/src/crypto/types.ts +5 -0
- package/src/flags/flagTestServer.ts +77 -0
- package/src/flags/useFeatureFlags.test.tsx +146 -0
- package/src/flags/useFeatureFlags.ts +130 -0
- package/src/flags/useTerrenoFeatureFlags.test.tsx +329 -0
- package/src/flags/useTerrenoFeatureFlags.ts +188 -0
- package/src/index.ts +4 -1
- package/src/isolated/TerrenoAccountSecurityScreen.isolated.tsx +123 -0
- package/src/isolated/TerrenoLoginScreen.isolated.tsx +256 -0
- package/src/isolated/betterAuthClient.isolated.ts +2198 -0
- package/src/isolated/betterAuthClient.native.isolated.ts +173 -0
- package/src/isolated/mcpTools.isolated.ts +259 -0
- package/src/isolated/rememberedAccounts.native.isolated.ts +63 -0
- package/src/isolated/sessionLogout.isolated.ts +152 -0
- package/src/isolated/tokenExpiry.isolated.ts +271 -0
- package/src/isolated/upgradeCheck.isolated.tsx +321 -0
- package/src/isolated/useAccountSecurity.isolated.ts +1089 -0
- package/src/isolated/useAccountSecurity.native.isolated.ts +61 -0
- package/src/isolated/useLoginController.isolated.ts +1384 -0
- package/src/mutations/entityIds.test.ts +55 -0
- package/src/mutations/entityIds.ts +50 -0
- package/src/persisters/defaultPersisterFactory.native.ts +7 -1
- package/src/persisters/encryptedIndexedDbPersister.ts +3 -0
- package/src/persisters/types.ts +6 -0
- package/src/query/queryWindows.ts +2 -2
- package/src/react/apiHooks.test.tsx +473 -0
- package/src/react/apiHooks.tsx +336 -0
- package/src/react/index.ts +2 -0
- package/src/react/provider.tsx +3 -0
- package/src/react/useSocketEvent.test.tsx +96 -0
- package/src/react/useSocketEvent.ts +59 -0
- package/src/sync/replayCoordinator.ts +5 -4
- package/src/sync/socketTransport.test.ts +49 -0
- package/src/sync/socketTransport.ts +15 -0
- package/src/sync/transport.ts +25 -0
- package/src/testing/fakeTransport.test.ts +18 -0
- package/src/testing/fakeTransport.ts +36 -5
- package/src/types.ts +9 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_DEV_API_PORT,
|
|
5
|
+
resolveBaseUrls,
|
|
6
|
+
resolveDevApiPort,
|
|
7
|
+
SAME_ORIGIN_SENTINEL,
|
|
8
|
+
} from "./resolveBaseUrls";
|
|
9
|
+
|
|
10
|
+
describe("resolveBaseUrls", () => {
|
|
11
|
+
it("treats an empty envApiUrl as unset and falls back to localhost", () => {
|
|
12
|
+
const urls = resolveBaseUrls({
|
|
13
|
+
envApiUrl: "",
|
|
14
|
+
expoConstants: {expoConfig: {extra: {}}},
|
|
15
|
+
isDev: false,
|
|
16
|
+
});
|
|
17
|
+
expect(urls.baseUrl).toBe(`http://localhost:${DEFAULT_DEV_API_PORT}`);
|
|
18
|
+
expect(urls.baseWebsocketsUrl).toBe(`ws://localhost:${DEFAULT_DEV_API_PORT}/`);
|
|
19
|
+
expect(urls.baseTasksUrl).toBe(`http://localhost:${DEFAULT_DEV_API_PORT}/tasks`);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("treats an empty BASE_URL extra as unset and falls back to localhost in non-dev", () => {
|
|
23
|
+
const urls = resolveBaseUrls({
|
|
24
|
+
expoConstants: {expoConfig: {extra: {BASE_URL: ""}}},
|
|
25
|
+
isDev: false,
|
|
26
|
+
});
|
|
27
|
+
expect(urls.baseUrl).toBe("http://localhost:4000");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("uses env override when provided", () => {
|
|
31
|
+
const urls = resolveBaseUrls({
|
|
32
|
+
envApiUrl: "https://api.example.com",
|
|
33
|
+
expoConstants: {expoConfig: {extra: {}}},
|
|
34
|
+
isDev: false,
|
|
35
|
+
});
|
|
36
|
+
expect(urls.baseUrl).toBe("https://api.example.com");
|
|
37
|
+
expect(urls.baseWebsocketsUrl).toBe("https://ws.example.com/");
|
|
38
|
+
expect(urls.baseTasksUrl).toBe("https://tasks.example.com/tasks");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("uses hostUri in dev mode", () => {
|
|
42
|
+
const urls = resolveBaseUrls({
|
|
43
|
+
expoConstants: {expoConfig: {extra: {}, hostUri: "10.0.0.12:8081"}},
|
|
44
|
+
isDev: true,
|
|
45
|
+
});
|
|
46
|
+
expect(urls.baseUrl).toBe("http://10.0.0.12:4000");
|
|
47
|
+
expect(urls.baseWebsocketsUrl).toBe("ws://10.0.0.12:4000/");
|
|
48
|
+
expect(urls.baseTasksUrl).toBe("http://10.0.0.12:4000/tasks");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("falls back to experienceUrl in dev mode when hostUri missing", () => {
|
|
52
|
+
const urls = resolveBaseUrls({
|
|
53
|
+
expoConstants: {
|
|
54
|
+
experienceUrl: "exp://192.168.1.20:19000",
|
|
55
|
+
expoConfig: {extra: {}},
|
|
56
|
+
},
|
|
57
|
+
isDev: true,
|
|
58
|
+
});
|
|
59
|
+
expect(urls.baseUrl).toBe("http://192.168.1.20:4000");
|
|
60
|
+
expect(urls.baseWebsocketsUrl).toBe("ws://192.168.1.20:4000/");
|
|
61
|
+
expect(urls.baseTasksUrl).toBe("http://192.168.1.20:4000/tasks");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("falls back to localhost in dev mode when nothing else is available", () => {
|
|
65
|
+
const urls = resolveBaseUrls({
|
|
66
|
+
expoConstants: {expoConfig: {extra: {}}},
|
|
67
|
+
isDev: true,
|
|
68
|
+
});
|
|
69
|
+
expect(urls.baseUrl).toBe(`http://localhost:${DEFAULT_DEV_API_PORT}`);
|
|
70
|
+
expect(urls.baseWebsocketsUrl).toBe(`ws://localhost:${DEFAULT_DEV_API_PORT}/`);
|
|
71
|
+
expect(urls.baseTasksUrl).toBe(`http://localhost:${DEFAULT_DEV_API_PORT}/tasks`);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("uses BASE_URL from extra when not in dev mode", () => {
|
|
75
|
+
const urls = resolveBaseUrls({
|
|
76
|
+
expoConstants: {expoConfig: {extra: {BASE_URL: "https://api.prod.com"}}},
|
|
77
|
+
isDev: false,
|
|
78
|
+
});
|
|
79
|
+
expect(urls.baseUrl).toBe("https://api.prod.com");
|
|
80
|
+
expect(urls.baseWebsocketsUrl).toBe("https://ws.prod.com/");
|
|
81
|
+
expect(urls.baseTasksUrl).toBe("https://tasks.prod.com/tasks");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("falls back to hostUri when BASE_URL absent in non-dev", () => {
|
|
85
|
+
const urls = resolveBaseUrls({
|
|
86
|
+
expoConstants: {expoConfig: {extra: {}, hostUri: "172.16.0.3:8081"}},
|
|
87
|
+
isDev: false,
|
|
88
|
+
});
|
|
89
|
+
expect(urls.baseUrl).toBe("http://172.16.0.3:4000");
|
|
90
|
+
expect(urls.baseWebsocketsUrl).toBe("ws://172.16.0.3:4000/");
|
|
91
|
+
expect(urls.baseTasksUrl).toBe("http://172.16.0.3:4000/tasks");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("falls back to experienceUrl in non-dev when hostUri absent", () => {
|
|
95
|
+
const urls = resolveBaseUrls({
|
|
96
|
+
expoConstants: {
|
|
97
|
+
experienceUrl: "exp://10.1.2.3:19000",
|
|
98
|
+
expoConfig: {extra: {}},
|
|
99
|
+
},
|
|
100
|
+
isDev: false,
|
|
101
|
+
});
|
|
102
|
+
expect(urls.baseUrl).toBe("http://10.1.2.3:4000");
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("defaults to localhost in non-dev when nothing is configured", () => {
|
|
106
|
+
const urls = resolveBaseUrls({
|
|
107
|
+
expoConstants: {expoConfig: {extra: {}}},
|
|
108
|
+
isDev: false,
|
|
109
|
+
});
|
|
110
|
+
expect(urls.baseUrl).toBe("http://localhost:4000");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("envApiUrl takes priority over BASE_URL in non-dev", () => {
|
|
114
|
+
const urls = resolveBaseUrls({
|
|
115
|
+
envApiUrl: "https://api.override.com",
|
|
116
|
+
expoConstants: {expoConfig: {extra: {BASE_URL: "https://api.from-extra.com"}}},
|
|
117
|
+
isDev: false,
|
|
118
|
+
});
|
|
119
|
+
expect(urls.baseUrl).toBe("https://api.override.com");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("envApiUrl takes priority over hostUri in dev mode", () => {
|
|
123
|
+
const urls = resolveBaseUrls({
|
|
124
|
+
envApiUrl: "https://api.override.com",
|
|
125
|
+
expoConstants: {expoConfig: {extra: {}, hostUri: "10.0.0.5:8081"}},
|
|
126
|
+
isDev: true,
|
|
127
|
+
});
|
|
128
|
+
expect(urls.baseUrl).toBe("https://api.override.com");
|
|
129
|
+
expect(urls.baseWebsocketsUrl).toBe("https://ws.override.com/");
|
|
130
|
+
expect(urls.baseTasksUrl).toBe("https://tasks.override.com/tasks");
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("falls back to localhost when expoConfig is undefined", () => {
|
|
134
|
+
const urls = resolveBaseUrls({
|
|
135
|
+
expoConstants: {},
|
|
136
|
+
isDev: false,
|
|
137
|
+
});
|
|
138
|
+
expect(urls.baseUrl).toBe("http://localhost:4000");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("ignores BASE_URL from extra in dev mode and uses hostUri instead", () => {
|
|
142
|
+
const urls = resolveBaseUrls({
|
|
143
|
+
expoConstants: {
|
|
144
|
+
expoConfig: {extra: {BASE_URL: "https://api.prod.com"}, hostUri: "192.168.0.10:8081"},
|
|
145
|
+
},
|
|
146
|
+
isDev: true,
|
|
147
|
+
});
|
|
148
|
+
expect(urls.baseUrl).toBe("http://192.168.0.10:4000");
|
|
149
|
+
expect(urls.baseWebsocketsUrl).toBe("ws://192.168.0.10:4000/");
|
|
150
|
+
expect(urls.baseTasksUrl).toBe("http://192.168.0.10:4000/tasks");
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("falls back to experienceUrl when hostUri is empty string", () => {
|
|
154
|
+
const urls = resolveBaseUrls({
|
|
155
|
+
expoConstants: {
|
|
156
|
+
experienceUrl: "exp://10.0.0.5:19000",
|
|
157
|
+
expoConfig: {extra: {}, hostUri: ""},
|
|
158
|
+
},
|
|
159
|
+
isDev: true,
|
|
160
|
+
});
|
|
161
|
+
expect(urls.baseUrl).toBe("http://10.0.0.5:4000");
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("replaces 'api.' subdomain with 'tasks.' and 'ws.' for envApiUrl", () => {
|
|
165
|
+
const urls = resolveBaseUrls({
|
|
166
|
+
envApiUrl: "https://api.staging.example.io",
|
|
167
|
+
expoConstants: {expoConfig: {extra: {}}},
|
|
168
|
+
isDev: false,
|
|
169
|
+
});
|
|
170
|
+
expect(urls.baseUrl).toBe("https://api.staging.example.io");
|
|
171
|
+
expect(urls.baseWebsocketsUrl).toBe("https://ws.staging.example.io/");
|
|
172
|
+
expect(urls.baseTasksUrl).toBe("https://tasks.staging.example.io/tasks");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("handles envApiUrl without 'api.' subdomain gracefully", () => {
|
|
176
|
+
const urls = resolveBaseUrls({
|
|
177
|
+
envApiUrl: "https://backend.example.com",
|
|
178
|
+
expoConstants: {expoConfig: {extra: {}}},
|
|
179
|
+
isDev: false,
|
|
180
|
+
});
|
|
181
|
+
expect(urls.baseUrl).toBe("https://backend.example.com");
|
|
182
|
+
expect(urls.baseWebsocketsUrl).toBe("https://backend.example.com/");
|
|
183
|
+
expect(urls.baseTasksUrl).toBe("https://backend.example.com/tasks");
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("resolves the same-origin sentinel to the window origin (https -> wss)", () => {
|
|
187
|
+
const urls = resolveBaseUrls({
|
|
188
|
+
expoConstants: {expoConfig: {extra: {BASE_URL: SAME_ORIGIN_SENTINEL}}},
|
|
189
|
+
isDev: false,
|
|
190
|
+
windowOrigin: "https://api.example.com",
|
|
191
|
+
});
|
|
192
|
+
expect(urls.baseUrl).toBe("https://api.example.com");
|
|
193
|
+
expect(urls.baseWebsocketsUrl).toBe("wss://api.example.com/");
|
|
194
|
+
expect(urls.baseTasksUrl).toBe("https://api.example.com/tasks");
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("resolves the same-origin sentinel to the window origin (http -> ws)", () => {
|
|
198
|
+
const urls = resolveBaseUrls({
|
|
199
|
+
expoConstants: {expoConfig: {extra: {BASE_URL: SAME_ORIGIN_SENTINEL}}},
|
|
200
|
+
isDev: false,
|
|
201
|
+
windowOrigin: "http://admin.test:8080",
|
|
202
|
+
});
|
|
203
|
+
expect(urls.baseUrl).toBe("http://admin.test:8080");
|
|
204
|
+
expect(urls.baseWebsocketsUrl).toBe("ws://admin.test:8080/");
|
|
205
|
+
expect(urls.baseTasksUrl).toBe("http://admin.test:8080/tasks");
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("resolves the same-origin sentinel even in dev mode when a window origin exists", () => {
|
|
209
|
+
const urls = resolveBaseUrls({
|
|
210
|
+
expoConstants: {
|
|
211
|
+
expoConfig: {extra: {BASE_URL: SAME_ORIGIN_SENTINEL}, hostUri: "10.0.0.5:8081"},
|
|
212
|
+
},
|
|
213
|
+
isDev: true,
|
|
214
|
+
windowOrigin: "https://admin.example.com",
|
|
215
|
+
});
|
|
216
|
+
expect(urls.baseUrl).toBe("https://admin.example.com");
|
|
217
|
+
expect(urls.baseWebsocketsUrl).toBe("wss://admin.example.com/");
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("falls back to existing resolution when the sentinel is set but no window origin", () => {
|
|
221
|
+
const urls = resolveBaseUrls({
|
|
222
|
+
expoConstants: {expoConfig: {extra: {BASE_URL: SAME_ORIGIN_SENTINEL}}},
|
|
223
|
+
isDev: false,
|
|
224
|
+
});
|
|
225
|
+
expect(urls.baseUrl).toBe("http://localhost:4000");
|
|
226
|
+
expect(urls.baseWebsocketsUrl).toBe("ws://localhost:4000/");
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("does not treat the sentinel as a literal base URL when a window origin is absent", () => {
|
|
230
|
+
const urls = resolveBaseUrls({
|
|
231
|
+
expoConstants: {
|
|
232
|
+
expoConfig: {extra: {BASE_URL: SAME_ORIGIN_SENTINEL}, hostUri: "172.16.0.3:8081"},
|
|
233
|
+
},
|
|
234
|
+
isDev: false,
|
|
235
|
+
});
|
|
236
|
+
// Sentinel ignored -> falls through to hostUri resolution, not the literal "__SAME_ORIGIN__".
|
|
237
|
+
expect(urls.baseUrl).toBe("http://172.16.0.3:4000");
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("leaves a non-sentinel BASE_URL unchanged when a window origin is present", () => {
|
|
241
|
+
const urls = resolveBaseUrls({
|
|
242
|
+
expoConstants: {expoConfig: {extra: {BASE_URL: "https://api.prod.com"}}},
|
|
243
|
+
isDev: false,
|
|
244
|
+
windowOrigin: "https://some-other-origin.com",
|
|
245
|
+
});
|
|
246
|
+
expect(urls.baseUrl).toBe("https://api.prod.com");
|
|
247
|
+
expect(urls.baseWebsocketsUrl).toBe("https://ws.prod.com/");
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("uses a custom devApiPort for hostUri resolution in dev mode", () => {
|
|
251
|
+
const urls = resolveBaseUrls({
|
|
252
|
+
devApiPort: 9000,
|
|
253
|
+
expoConstants: {expoConfig: {extra: {}, hostUri: "10.0.0.12:8081"}},
|
|
254
|
+
isDev: true,
|
|
255
|
+
});
|
|
256
|
+
expect(urls.baseUrl).toBe("http://10.0.0.12:9000");
|
|
257
|
+
expect(urls.baseWebsocketsUrl).toBe("ws://10.0.0.12:9000/");
|
|
258
|
+
expect(urls.baseTasksUrl).toBe("http://10.0.0.12:9000/tasks");
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it("uses a custom devApiPort for the localhost fallback", () => {
|
|
262
|
+
const urls = resolveBaseUrls({
|
|
263
|
+
devApiPort: 3000,
|
|
264
|
+
expoConstants: {expoConfig: {extra: {}}},
|
|
265
|
+
isDev: true,
|
|
266
|
+
});
|
|
267
|
+
expect(urls.baseUrl).toBe("http://localhost:3000");
|
|
268
|
+
expect(urls.baseWebsocketsUrl).toBe("ws://localhost:3000/");
|
|
269
|
+
expect(urls.baseTasksUrl).toBe("http://localhost:3000/tasks");
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe("resolveDevApiPort", () => {
|
|
274
|
+
it("defaults to DEFAULT_DEV_API_PORT when nothing is configured", () => {
|
|
275
|
+
expect(resolveDevApiPort({expoConstants: {expoConfig: {extra: {}}}})).toBe(
|
|
276
|
+
DEFAULT_DEV_API_PORT
|
|
277
|
+
);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it("reads the port from expoConfig.extra.DEV_API_PORT", () => {
|
|
281
|
+
expect(resolveDevApiPort({expoConstants: {expoConfig: {extra: {DEV_API_PORT: "3000"}}}})).toBe(
|
|
282
|
+
3000
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it("prefers EXPO_PUBLIC_DEV_API_PORT over extra.DEV_API_PORT", () => {
|
|
287
|
+
expect(
|
|
288
|
+
resolveDevApiPort({
|
|
289
|
+
envDevApiPort: "9000",
|
|
290
|
+
expoConstants: {expoConfig: {extra: {DEV_API_PORT: "3000"}}},
|
|
291
|
+
})
|
|
292
|
+
).toBe(9000);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it("falls back to the default for empty or invalid values", () => {
|
|
296
|
+
expect(resolveDevApiPort({envDevApiPort: "", expoConstants: {}})).toBe(DEFAULT_DEV_API_PORT);
|
|
297
|
+
expect(resolveDevApiPort({envDevApiPort: "not-a-number", expoConstants: {}})).toBe(
|
|
298
|
+
DEFAULT_DEV_API_PORT
|
|
299
|
+
);
|
|
300
|
+
expect(resolveDevApiPort({envDevApiPort: "-5", expoConstants: {}})).toBe(DEFAULT_DEV_API_PORT);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
describe("SAME_ORIGIN_SENTINEL", () => {
|
|
305
|
+
it("is the literal string __SAME_ORIGIN__", () => {
|
|
306
|
+
expect(SAME_ORIGIN_SENTINEL).toBe("__SAME_ORIGIN__");
|
|
307
|
+
});
|
|
308
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure base-URL resolution, decoupled from `expo-constants` so it can be unit
|
|
3
|
+
* tested. `./baseUrl.ts` feeds it the running app's Expo config.
|
|
4
|
+
*/
|
|
5
|
+
export interface ExpoConstantsShape {
|
|
6
|
+
experienceUrl?: string;
|
|
7
|
+
expoConfig?: {
|
|
8
|
+
extra?: Record<string, string | undefined>;
|
|
9
|
+
hostUri?: string;
|
|
10
|
+
};
|
|
11
|
+
expoGoConfig?: {
|
|
12
|
+
debuggerHost?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface BaseUrls {
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
baseWebsocketsUrl: string;
|
|
19
|
+
baseTasksUrl: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Sentinel value for `BASE_URL`. When set in `app.json` `extra.BASE_URL`, the
|
|
24
|
+
* base URL resolves to the runtime page origin (`window.location.origin`).
|
|
25
|
+
* Used by same-origin deployments such as the standalone admin SPA.
|
|
26
|
+
*/
|
|
27
|
+
export const SAME_ORIGIN_SENTINEL = "__SAME_ORIGIN__";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Default local API port used when resolving dev base URLs from the Expo
|
|
31
|
+
* host/experience URL or the localhost fallback. Matches the example backend.
|
|
32
|
+
*/
|
|
33
|
+
export const DEFAULT_DEV_API_PORT = 4000;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the local dev API port. Apps whose backend listens on a non-default
|
|
37
|
+
* port (for example 3000 or 9000) override it via the `EXPO_PUBLIC_DEV_API_PORT`
|
|
38
|
+
* env var or `expoConfig.extra.DEV_API_PORT`, mirroring how `EXPO_PUBLIC_API_URL`
|
|
39
|
+
* and `extra.BASE_URL` are provided. Missing or invalid values fall back to the
|
|
40
|
+
* default port.
|
|
41
|
+
*/
|
|
42
|
+
export const resolveDevApiPort = (args: {
|
|
43
|
+
envDevApiPort?: string;
|
|
44
|
+
expoConstants: ExpoConstantsShape;
|
|
45
|
+
}): number => {
|
|
46
|
+
const raw = args.envDevApiPort ?? args.expoConstants.expoConfig?.extra?.DEV_API_PORT;
|
|
47
|
+
if (raw === undefined || raw === "") {
|
|
48
|
+
return DEFAULT_DEV_API_PORT;
|
|
49
|
+
}
|
|
50
|
+
const parsed = Number(raw);
|
|
51
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
52
|
+
return DEFAULT_DEV_API_PORT;
|
|
53
|
+
}
|
|
54
|
+
return parsed;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const localhostUrls = (port: number): BaseUrls => ({
|
|
58
|
+
baseTasksUrl: `http://localhost:${port}/tasks`,
|
|
59
|
+
baseUrl: `http://localhost:${port}`,
|
|
60
|
+
baseWebsocketsUrl: `ws://localhost:${port}/`,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Pure resolver for the API, websocket, and tasks base URLs.
|
|
65
|
+
* Decoupled from the Expo-constants module so it can be unit tested.
|
|
66
|
+
*/
|
|
67
|
+
export const resolveBaseUrls = (args: {
|
|
68
|
+
// Local dev API port for host/experience/localhost resolution. Defaults to
|
|
69
|
+
// DEFAULT_DEV_API_PORT; callers pass the app-configured port (see resolveDevApiPort).
|
|
70
|
+
devApiPort?: number;
|
|
71
|
+
envApiUrl?: string;
|
|
72
|
+
expoConstants: ExpoConstantsShape;
|
|
73
|
+
isDev: boolean;
|
|
74
|
+
// Defaults to globalThis.location.origin at the module-level call site.
|
|
75
|
+
// Injectable so the sentinel resolution can be unit tested without a DOM.
|
|
76
|
+
windowOrigin?: string;
|
|
77
|
+
}): BaseUrls => {
|
|
78
|
+
const port = args.devApiPort ?? DEFAULT_DEV_API_PORT;
|
|
79
|
+
const hostUriPrefix = args.expoConstants.expoConfig?.hostUri?.split(":").shift();
|
|
80
|
+
const experiencePrefix = args.expoConstants.experienceUrl?.split(":")[1];
|
|
81
|
+
const baseFromExtra = args.expoConstants.expoConfig?.extra?.BASE_URL;
|
|
82
|
+
|
|
83
|
+
// Same-origin sentinel: resolves to the page origin at runtime, regardless of
|
|
84
|
+
// isDev. This check must run before the isDev branching below, otherwise the
|
|
85
|
+
// sentinel would be silently dead in dev mode (which gates baseFromExtra).
|
|
86
|
+
if (baseFromExtra === SAME_ORIGIN_SENTINEL && args.windowOrigin) {
|
|
87
|
+
const origin = args.windowOrigin;
|
|
88
|
+
return {
|
|
89
|
+
baseTasksUrl: `${origin}/tasks`,
|
|
90
|
+
baseUrl: origin,
|
|
91
|
+
baseWebsocketsUrl: `${origin.replace(/^http/, "ws")}/`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
// Never treat the sentinel as a literal base URL in the fallback path.
|
|
95
|
+
const resolvedBaseFromExtra = baseFromExtra === SAME_ORIGIN_SENTINEL ? undefined : baseFromExtra;
|
|
96
|
+
const base = args.envApiUrl || (!args.isDev ? resolvedBaseFromExtra : undefined);
|
|
97
|
+
const host = args.isDev ? hostUriPrefix : !base ? hostUriPrefix : undefined;
|
|
98
|
+
const experience = !base && !host ? experiencePrefix : undefined;
|
|
99
|
+
if (base)
|
|
100
|
+
return {
|
|
101
|
+
baseTasksUrl: `${base.replace("api.", "tasks.")}/tasks`,
|
|
102
|
+
baseUrl: base,
|
|
103
|
+
baseWebsocketsUrl: `${base.replace("api.", "ws.")}/`,
|
|
104
|
+
};
|
|
105
|
+
if (host)
|
|
106
|
+
return {
|
|
107
|
+
baseTasksUrl: `http://${host}:${port}/tasks`,
|
|
108
|
+
baseUrl: `http://${host}:${port}`,
|
|
109
|
+
baseWebsocketsUrl: `ws://${host}:${port}/`,
|
|
110
|
+
};
|
|
111
|
+
if (experience)
|
|
112
|
+
return {
|
|
113
|
+
baseTasksUrl: `http:${experience}:${port}/tasks`,
|
|
114
|
+
baseUrl: `http:${experience}:${port}`,
|
|
115
|
+
baseWebsocketsUrl: `ws:${experience}:${port}/`,
|
|
116
|
+
};
|
|
117
|
+
return localhostUrls(port);
|
|
118
|
+
};
|
|
@@ -225,4 +225,27 @@ describe("createKeyProviderCodec", () => {
|
|
|
225
225
|
expect(getKey).toHaveBeenCalledTimes(1);
|
|
226
226
|
expect(getKey).toHaveBeenCalledWith({userId: "u1"});
|
|
227
227
|
});
|
|
228
|
+
|
|
229
|
+
it("prepare() resolves the key so later encodes need no provider call", async () => {
|
|
230
|
+
const inner = createLocalKeyProvider({cacheDbName: uniqueDbName()});
|
|
231
|
+
const getKey = mock(({userId}: {userId: string}) => inner.getKey({userId}));
|
|
232
|
+
const codec = createKeyProviderCodec({keyProvider: {getKey}, userId: "u1"});
|
|
233
|
+
await codec.prepare?.();
|
|
234
|
+
expect(getKey).toHaveBeenCalledTimes(1);
|
|
235
|
+
await codec.decode(await codec.encode("prepared"));
|
|
236
|
+
expect(getKey).toHaveBeenCalledTimes(1);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("retries key resolution after a failure instead of failing every later call", async () => {
|
|
240
|
+
const inner = createLocalKeyProvider({cacheDbName: uniqueDbName()});
|
|
241
|
+
let isOnline = false;
|
|
242
|
+
const getKey = mock(({userId}: {userId: string}) =>
|
|
243
|
+
isOnline ? inner.getKey({userId}) : Promise.reject(new Error("offline"))
|
|
244
|
+
);
|
|
245
|
+
const codec = createKeyProviderCodec({keyProvider: {getKey}, userId: "u1"});
|
|
246
|
+
await expect(codec.prepare?.()).rejects.toThrow("offline");
|
|
247
|
+
isOnline = true;
|
|
248
|
+
expect(await codec.decode(await codec.encode("after retry"))).toBe("after retry");
|
|
249
|
+
expect(getKey).toHaveBeenCalledTimes(2);
|
|
250
|
+
});
|
|
228
251
|
});
|
|
@@ -51,7 +51,7 @@ const createCachedKeyResolver = ({
|
|
|
51
51
|
|
|
52
52
|
const getKey = ({userId}: {userId: string}): Promise<CryptoKey> => {
|
|
53
53
|
const existing = inFlight.get(userId);
|
|
54
|
-
if (existing) {
|
|
54
|
+
if (existing !== undefined) {
|
|
55
55
|
return existing;
|
|
56
56
|
}
|
|
57
57
|
const promise = resolveKey({userId}).catch((error) => {
|
|
@@ -129,8 +129,8 @@ export const createLocalKeyProvider = ({
|
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* AES-GCM codec whose key is resolved lazily from a {@link KeyProvider} on
|
|
132
|
-
* first use. Lets persister factories stay
|
|
133
|
-
* fetch/derivation happens on the first load/save.
|
|
132
|
+
* first use (or eagerly via `prepare()`). Lets persister factories stay
|
|
133
|
+
* synchronous while key fetch/derivation happens on the first load/save.
|
|
134
134
|
*/
|
|
135
135
|
export const createKeyProviderCodec = ({
|
|
136
136
|
keyProvider,
|
|
@@ -141,7 +141,15 @@ export const createKeyProviderCodec = ({
|
|
|
141
141
|
}): PayloadCodec => {
|
|
142
142
|
let codecPromise: Promise<PayloadCodec> | undefined;
|
|
143
143
|
const resolveCodec = (): Promise<PayloadCodec> => {
|
|
144
|
-
codecPromise ??= keyProvider
|
|
144
|
+
codecPromise ??= keyProvider
|
|
145
|
+
.getKey({userId})
|
|
146
|
+
.then((key) => createAesGcmCodec({key}))
|
|
147
|
+
.catch((error: unknown) => {
|
|
148
|
+
// A failed resolution (offline, signed out) must not fail every later
|
|
149
|
+
// load/save for the life of this codec; retry on the next use.
|
|
150
|
+
codecPromise = undefined;
|
|
151
|
+
throw error;
|
|
152
|
+
});
|
|
145
153
|
return codecPromise;
|
|
146
154
|
};
|
|
147
155
|
|
|
@@ -149,5 +157,8 @@ export const createKeyProviderCodec = ({
|
|
|
149
157
|
decode: async (payload: Uint8Array): Promise<string> => (await resolveCodec()).decode(payload),
|
|
150
158
|
encode: async (plaintext: string): Promise<Uint8Array> =>
|
|
151
159
|
(await resolveCodec()).encode(plaintext),
|
|
160
|
+
prepare: async (): Promise<void> => {
|
|
161
|
+
await resolveCodec();
|
|
162
|
+
},
|
|
152
163
|
};
|
|
153
164
|
};
|
package/src/crypto/types.ts
CHANGED
|
@@ -11,6 +11,11 @@ export interface PayloadCodec {
|
|
|
11
11
|
encode(plaintext: string): Promise<Uint8Array>;
|
|
12
12
|
/** Decrypt/decode a previously encoded binary payload. */
|
|
13
13
|
decode(payload: Uint8Array): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve whatever `encode`/`decode` need (e.g. a key fetched from the server)
|
|
16
|
+
* ahead of the first save, so a later flush never needs the network.
|
|
17
|
+
*/
|
|
18
|
+
prepare?(): Promise<void>;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
/**
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {type ApiClient, createApiClient, type FetchLike} from "../api/client";
|
|
2
|
+
import type {TerrenoFlagConfiguration, TerrenoFlagDefinition} from "./useTerrenoFeatureFlags";
|
|
3
|
+
|
|
4
|
+
export const boolDef = (variant: "on" | "off"): TerrenoFlagDefinition => ({
|
|
5
|
+
defaultVariant: variant,
|
|
6
|
+
disabled: false,
|
|
7
|
+
variants: {off: false, on: true},
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/** Test double for `FeatureFlagsApp`; used by the flags hook tests. */
|
|
11
|
+
export interface FlagTestServer {
|
|
12
|
+
client: ApiClient;
|
|
13
|
+
/** `METHOD /path` of every request, in order. */
|
|
14
|
+
requests: string[];
|
|
15
|
+
/** Replace the configuration later requests return. */
|
|
16
|
+
setConfig: (config: TerrenoFlagConfiguration) => void;
|
|
17
|
+
/** Fail the next request with this status. */
|
|
18
|
+
failNext: (status: number) => void;
|
|
19
|
+
/** Hold every request until `release()` is called. */
|
|
20
|
+
hold: () => void;
|
|
21
|
+
release: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** In-memory `/feature-flags/flagConfiguration` backend reached through the fetch boundary. */
|
|
25
|
+
export const createFlagTestServer = (initial: TerrenoFlagConfiguration = {}): FlagTestServer => {
|
|
26
|
+
let config = initial;
|
|
27
|
+
let failStatus: number | undefined;
|
|
28
|
+
let held: (() => void)[] | undefined;
|
|
29
|
+
const requests: string[] = [];
|
|
30
|
+
|
|
31
|
+
const respond = (): Response => {
|
|
32
|
+
if (failStatus !== undefined) {
|
|
33
|
+
const status = failStatus;
|
|
34
|
+
failStatus = undefined;
|
|
35
|
+
return new Response(JSON.stringify({title: "Flags unavailable"}), {
|
|
36
|
+
headers: {"Content-Type": "application/json"},
|
|
37
|
+
status,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return new Response(JSON.stringify({data: config}), {
|
|
41
|
+
headers: {"Content-Type": "application/json"},
|
|
42
|
+
status: 200,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const fetchImpl: FetchLike = async (input, init) => {
|
|
47
|
+
requests.push(`${init?.method ?? "GET"} ${new URL(input).pathname}`);
|
|
48
|
+
if (held) {
|
|
49
|
+
const queue = held;
|
|
50
|
+
await new Promise<void>((resolve) => {
|
|
51
|
+
queue.push(resolve);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return respond();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
client: createApiClient({baseUrl: "http://flags.test", fetchImpl}),
|
|
59
|
+
failNext: (status: number): void => {
|
|
60
|
+
failStatus = status;
|
|
61
|
+
},
|
|
62
|
+
hold: (): void => {
|
|
63
|
+
held = [];
|
|
64
|
+
},
|
|
65
|
+
release: (): void => {
|
|
66
|
+
const queue = held ?? [];
|
|
67
|
+
held = undefined;
|
|
68
|
+
for (const resolve of queue) {
|
|
69
|
+
resolve();
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
requests,
|
|
73
|
+
setConfig: (next: TerrenoFlagConfiguration): void => {
|
|
74
|
+
config = next;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|