@luxexchange/sessions 1.0.1 → 1.0.3

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.
Files changed (68) hide show
  1. package/.depcheckrc +20 -0
  2. package/.eslintrc.js +21 -0
  3. package/README.md +1 -0
  4. package/env.d.ts +12 -0
  5. package/package.json +3 -4
  6. package/project.json +2 -8
  7. package/src/challenge-solvers/createChallengeSolverService.ts +5 -5
  8. package/src/challenge-solvers/createHashcashMockSolver.ts +1 -1
  9. package/src/challenge-solvers/createHashcashSolver.test.ts +10 -10
  10. package/src/challenge-solvers/createHashcashSolver.ts +22 -7
  11. package/src/challenge-solvers/createNoneMockSolver.ts +1 -1
  12. package/src/challenge-solvers/createTurnstileMockSolver.ts +1 -1
  13. package/src/challenge-solvers/createTurnstileSolver.ts +12 -8
  14. package/src/challenge-solvers/hashcash/core.native.ts +3 -3
  15. package/src/challenge-solvers/hashcash/core.test.ts +10 -10
  16. package/src/challenge-solvers/hashcash/core.ts +3 -3
  17. package/src/challenge-solvers/hashcash/core.web.ts +4 -4
  18. package/src/challenge-solvers/hashcash/createWorkerHashcashSolver.test.ts +7 -7
  19. package/src/challenge-solvers/hashcash/createWorkerHashcashSolver.ts +4 -4
  20. package/src/challenge-solvers/hashcash/worker/createHashcashMultiWorkerChannel.native.ts +1 -1
  21. package/src/challenge-solvers/hashcash/worker/createHashcashMultiWorkerChannel.ts +1 -1
  22. package/src/challenge-solvers/hashcash/worker/createHashcashMultiWorkerChannel.web.ts +2 -2
  23. package/src/challenge-solvers/hashcash/worker/createHashcashWorkerChannel.native.ts +1 -1
  24. package/src/challenge-solvers/hashcash/worker/createHashcashWorkerChannel.ts +1 -1
  25. package/src/challenge-solvers/hashcash/worker/createHashcashWorkerChannel.web.ts +2 -2
  26. package/src/challenge-solvers/hashcash/worker/hashcash.worker.ts +3 -3
  27. package/src/challenge-solvers/hashcash/worker/types.ts +1 -1
  28. package/src/challenge-solvers/turnstileErrors.ts +1 -1
  29. package/src/challenge-solvers/turnstileScriptLoader.ts +2 -2
  30. package/src/challenge-solvers/turnstileSolver.integration.test.ts +4 -4
  31. package/src/challenge-solvers/types.ts +2 -2
  32. package/src/challengeFlow.integration.test.ts +49 -49
  33. package/src/device-id/createDeviceIdService.ts +1 -1
  34. package/src/index.ts +50 -48
  35. package/src/oauth-service/createOAuthService.ts +2 -2
  36. package/src/oauth-service/types.ts +1 -1
  37. package/src/performance/createNoopPerformanceTracker.ts +2 -2
  38. package/src/performance/createPerformanceTracker.ts +1 -1
  39. package/src/performance/index.ts +3 -3
  40. package/src/session-initialization/createSessionInitializationService.test.ts +4 -4
  41. package/src/session-initialization/createSessionInitializationService.ts +32 -41
  42. package/src/session-repository/createSessionClient.ts +1 -1
  43. package/src/session-repository/createSessionRepository.test.ts +5 -5
  44. package/src/session-repository/createSessionRepository.ts +14 -14
  45. package/src/session-repository/errors.ts +1 -1
  46. package/src/session-repository/types.ts +1 -1
  47. package/src/session-service/createNoopSessionService.ts +2 -2
  48. package/src/session-service/createSessionService.test.ts +29 -29
  49. package/src/session-service/createSessionService.ts +8 -8
  50. package/src/session-service/types.ts +3 -3
  51. package/src/session-storage/createSessionStorage.ts +1 -1
  52. package/src/session.integration.test.ts +130 -94
  53. package/src/sessionLifecycle.integration.test.ts +22 -22
  54. package/src/test-utils/createLocalCookieTransport.ts +1 -1
  55. package/src/test-utils/createLocalHeaderTransport.ts +1 -1
  56. package/src/test-utils/mocks.ts +3 -3
  57. package/src/test-utils.ts +24 -24
  58. package/src/uniswap-identifier/createUniswapIdentifierService.ts +19 -0
  59. package/src/uniswap-identifier/types.ts +11 -0
  60. package/src/uniswap-identifier/uniswapIdentifierQuery.ts +20 -0
  61. package/tsconfig.json +10 -3
  62. package/tsconfig.lint.json +8 -0
  63. package/tsconfig.spec.json +8 -0
  64. package/vitest.config.ts +20 -0
  65. package/vitest.integration.config.ts +14 -0
  66. package/src/lux-identifier/createLuxIdentifierService.ts +0 -19
  67. package/src/lux-identifier/luxIdentifierQuery.ts +0 -20
  68. package/src/lux-identifier/types.ts +0 -11
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Uniswap Identifier provider interface
3
+ * Platform-specific implementations handle uniswap identifier persistence
4
+ */
5
+ interface LxIdentifierService {
6
+ getLxIdentifier(): Promise<string | null>
7
+ setLxIdentifier(identifier: string): Promise<void>
8
+ removeLxIdentifier(): Promise<void>
9
+ }
10
+
11
+ export type { LxIdentifierService }
@@ -0,0 +1,20 @@
1
+ import { queryOptions } from '@tanstack/react-query'
2
+ import type { LxIdentifierService } from '@luxexchange/sessions/src/uniswap-identifier/types'
3
+ import { ReactQueryCacheKey } from 'utilities/src/reactQuery/cache'
4
+ import type { QueryOptionsResult } from 'utilities/src/reactQuery/queryOptions'
5
+
6
+ type LxIdentifierQueryOptions = QueryOptionsResult<
7
+ string | null,
8
+ Error,
9
+ string | null,
10
+ [ReactQueryCacheKey.LxIdentifier]
11
+ >
12
+
13
+ export function lxIdentifierQuery(getService: () => LxIdentifierService): LxIdentifierQueryOptions {
14
+ return queryOptions({
15
+ queryKey: [ReactQueryCacheKey.LxIdentifier],
16
+ queryFn: async () => getService().getLxIdentifier(),
17
+ staleTime: Infinity,
18
+ gcTime: Infinity,
19
+ })
20
+ }
package/tsconfig.json CHANGED
@@ -1,19 +1,26 @@
1
1
  {
2
2
  "extends": "../../config/tsconfig/app.json",
3
3
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json", "env.d.ts"],
4
- "exclude": ["src/**/*.spec.ts", "src/**/*.spec.tsx", "src/**/*.test.ts", "src/**/*.test.tsx"],
4
+ "exclude": [
5
+ "src/**/*.spec.ts",
6
+ "src/**/*.spec.tsx",
7
+ "src/**/*.test.ts",
8
+ "src/**/*.test.tsx"
9
+ ],
5
10
  "compilerOptions": {
6
11
  "emitDeclarationOnly": true,
7
12
  "noEmit": false,
8
13
  "paths": {
9
- "@universe/sessions/*": ["./src/*"],
10
- "@luxdex/client-platform-service/*": ["../../node_modules/@uniswap/client-platform-service/*"]
14
+ "@luxexchange/sessions/*": ["./src/*"]
11
15
  },
12
16
  "types": ["chrome", "node"]
13
17
  },
14
18
  "references": [
15
19
  {
16
20
  "path": "../utilities"
21
+ },
22
+ {
23
+ "path": "../eslint-config"
17
24
  }
18
25
  ]
19
26
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "preserveSymlinks": true
5
+ },
6
+ "include": ["src/**/*.ts", "src/**/*.tsx", "*.config.ts"],
7
+ "exclude": []
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["node"]
5
+ },
6
+ "include": ["src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"],
7
+ "exclude": []
8
+ }
@@ -0,0 +1,20 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ watch: false,
6
+ environment: 'edge-runtime',
7
+ exclude: [
8
+ '**/node_modules/**',
9
+ '**/dist/**',
10
+ // Exclude real backend integration tests - these run in a separate optional CI workflow
11
+ '**/session.integration.test.ts',
12
+ ],
13
+ coverage: {
14
+ exclude: ['**/__generated__/**', '**/node_modules/**', '**/dist/**', '**/*.config.*', '**/scripts/**'],
15
+ },
16
+ },
17
+ resolve: {
18
+ extensions: ['.web.ts', '.web.tsx', '.ts', '.tsx', '.js', '.jsx', '.json'],
19
+ },
20
+ })
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ watch: false,
6
+ environment: 'edge-runtime',
7
+ include: ['**/session.integration.test.ts'],
8
+ testTimeout: 60000,
9
+ hookTimeout: 60000,
10
+ },
11
+ resolve: {
12
+ extensions: ['.web.ts', '.web.tsx', '.ts', '.tsx', '.js', '.jsx', '.json'],
13
+ },
14
+ })
@@ -1,19 +0,0 @@
1
- import type { LuxIdentifierService } from '@luxfi/sessions/src/lux-identifier/types'
2
-
3
- function createLuxIdentifierService(ctx: {
4
- getLuxIdentifier: () => Promise<string | null>
5
- setLuxIdentifier: (identifier: string) => Promise<void>
6
- removeLuxIdentifier: () => Promise<void>
7
- }): LuxIdentifierService {
8
- const getLuxIdentifier = ctx.getLuxIdentifier
9
- const setLuxIdentifier = ctx.setLuxIdentifier
10
- const removeLuxIdentifier = ctx.removeLuxIdentifier
11
-
12
- return {
13
- getLuxIdentifier,
14
- setLuxIdentifier,
15
- removeLuxIdentifier,
16
- }
17
- }
18
-
19
- export { createLuxIdentifierService }
@@ -1,20 +0,0 @@
1
- import { queryOptions } from '@tanstack/react-query'
2
- import type { LuxIdentifierService } from '@universe/sessions/src/lux-identifier/types'
3
- import { ReactQueryCacheKey } from 'utilities/src/reactQuery/cache'
4
- import type { QueryOptionsResult } from 'utilities/src/reactQuery/queryOptions'
5
-
6
- type LuxIdentifierQueryOptions = QueryOptionsResult<
7
- string | null,
8
- Error,
9
- string | null,
10
- [ReactQueryCacheKey.LuxIdentifier]
11
- >
12
-
13
- export function luxIdentifierQuery(getService: () => LuxIdentifierService): LuxIdentifierQueryOptions {
14
- return queryOptions({
15
- queryKey: [ReactQueryCacheKey.LuxIdentifier],
16
- queryFn: async () => getService().getLuxIdentifier(),
17
- staleTime: Infinity,
18
- gcTime: Infinity,
19
- })
20
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Lux Identifier provider interface
3
- * Platform-specific implementations handle lux identifier persistence
4
- */
5
- interface LuxIdentifierService {
6
- getLuxIdentifier(): Promise<string | null>
7
- setLuxIdentifier(identifier: string): Promise<void>
8
- removeLuxIdentifier(): Promise<void>
9
- }
10
-
11
- export type { LuxIdentifierService }