@l.x/sessions 1.0.4 → 1.0.5
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/LICENSE +122 -0
- package/package.json +20 -20
- package/src/challengeFlow.integration.test.ts +3 -3
- package/src/index.ts +3 -3
- package/src/lx-identifier/createLXIdentifierService.ts +1 -0
- package/src/lx-identifier/createUniswapIdentifierService.ts +19 -0
- package/src/lx-identifier/lxIdentifierQuery.ts +1 -0
- package/src/lx-identifier/types.ts +11 -0
- package/src/lx-identifier/uniswapIdentifierQuery.ts +20 -0
- package/src/session-service/createSessionService.test.ts +9 -9
- package/src/session-service/createSessionService.ts +3 -3
- package/src/sessionLifecycle.integration.test.ts +3 -3
- package/src/test-utils.ts +5 -5
- package/src/uniswap-identifier/createUniswapIdentifierService.ts +13 -13
- package/src/uniswap-identifier/types.ts +5 -5
- package/src/uniswap-identifier/uniswapIdentifierQuery.ts +6 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Lux Ecosystem License
|
|
2
|
+
Version 1.2, December 2025
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2020-2025 Lux Industries Inc.
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
TECHNOLOGY PORTFOLIO - PATENT APPLICATIONS PLANNED
|
|
8
|
+
Contact: licensing@lux.network
|
|
9
|
+
|
|
10
|
+
================================================================================
|
|
11
|
+
TERMS AND CONDITIONS
|
|
12
|
+
================================================================================
|
|
13
|
+
|
|
14
|
+
1. DEFINITIONS
|
|
15
|
+
|
|
16
|
+
"Lux Primary Network" means the official Lux blockchain with Network ID=1
|
|
17
|
+
and EVM Chain ID=96369.
|
|
18
|
+
|
|
19
|
+
"Authorized Network" means the Lux Primary Network, official testnets/devnets,
|
|
20
|
+
and any L1/L2/L3 chain descending from the Lux Primary Network.
|
|
21
|
+
|
|
22
|
+
"Descending Chain" means an L1/L2/L3 chain built on, anchored to, or deriving
|
|
23
|
+
security from the Lux Primary Network or its authorized testnets.
|
|
24
|
+
|
|
25
|
+
"Research Use" means non-commercial academic research, education, personal
|
|
26
|
+
study, or evaluation purposes.
|
|
27
|
+
|
|
28
|
+
"Commercial Use" means any use in connection with a product or service
|
|
29
|
+
offered for sale or fee, internal use by a for-profit entity, or any use
|
|
30
|
+
to generate revenue.
|
|
31
|
+
|
|
32
|
+
2. GRANT OF LICENSE
|
|
33
|
+
|
|
34
|
+
Subject to these terms, Lux Industries Inc grants you a non-exclusive,
|
|
35
|
+
royalty-free license to:
|
|
36
|
+
|
|
37
|
+
(a) Use for Research Use without restriction;
|
|
38
|
+
|
|
39
|
+
(b) Operate on the Lux Primary Network (Network ID=1, EVM Chain ID=96369);
|
|
40
|
+
|
|
41
|
+
(c) Operate on official Lux testnets and devnets;
|
|
42
|
+
|
|
43
|
+
(d) Operate L1/L2/L3 chains descending from the Lux Primary Network;
|
|
44
|
+
|
|
45
|
+
(e) Build applications within the Lux ecosystem;
|
|
46
|
+
|
|
47
|
+
(f) Contribute improvements back to the original repositories.
|
|
48
|
+
|
|
49
|
+
3. RESTRICTIONS
|
|
50
|
+
|
|
51
|
+
Without a commercial license from Lux Industries Inc, you may NOT:
|
|
52
|
+
|
|
53
|
+
(a) Fork the Lux Network or any Lux software;
|
|
54
|
+
|
|
55
|
+
(b) Create competing networks not descending from Lux Primary Network;
|
|
56
|
+
|
|
57
|
+
(c) Use for Commercial Use outside the Lux ecosystem;
|
|
58
|
+
|
|
59
|
+
(d) Sublicense or transfer rights outside the Lux ecosystem;
|
|
60
|
+
|
|
61
|
+
(e) Use to create competing blockchain networks, exchanges, custody
|
|
62
|
+
services, or cryptographic systems outside the Lux ecosystem.
|
|
63
|
+
|
|
64
|
+
4. NO FORKS POLICY
|
|
65
|
+
|
|
66
|
+
Lux Industries Inc maintains ZERO TOLERANCE for unauthorized forks.
|
|
67
|
+
Any fork or deployment on an unauthorized network constitutes:
|
|
68
|
+
|
|
69
|
+
(a) Breach of this license;
|
|
70
|
+
(b) Grounds for immediate legal action.
|
|
71
|
+
|
|
72
|
+
5. RIGHTS RESERVATION
|
|
73
|
+
|
|
74
|
+
All rights not explicitly granted are reserved by Lux Industries Inc.
|
|
75
|
+
|
|
76
|
+
We plan to apply for patent protection for the technology in this
|
|
77
|
+
repository. Any implementation outside the Lux ecosystem may require
|
|
78
|
+
a separate commercial license.
|
|
79
|
+
|
|
80
|
+
6. DISCLAIMER OF WARRANTY
|
|
81
|
+
|
|
82
|
+
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
83
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
84
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
85
|
+
|
|
86
|
+
7. LIMITATION OF LIABILITY
|
|
87
|
+
|
|
88
|
+
IN NO EVENT SHALL LUX INDUSTRIES INC BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
89
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
90
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE.
|
|
91
|
+
|
|
92
|
+
8. TERMINATION
|
|
93
|
+
|
|
94
|
+
This license terminates immediately upon any breach, including but not
|
|
95
|
+
limited to deployment on unauthorized networks or creation of forks.
|
|
96
|
+
|
|
97
|
+
9. GOVERNING LAW
|
|
98
|
+
|
|
99
|
+
This License shall be governed by the laws of the State of Delaware.
|
|
100
|
+
|
|
101
|
+
10. COMMERCIAL LICENSING
|
|
102
|
+
|
|
103
|
+
For commercial use outside the Lux ecosystem:
|
|
104
|
+
|
|
105
|
+
Lux Industries Inc.
|
|
106
|
+
Email: licensing@lux.network
|
|
107
|
+
Subject: Commercial License Request
|
|
108
|
+
|
|
109
|
+
================================================================================
|
|
110
|
+
TL;DR
|
|
111
|
+
================================================================================
|
|
112
|
+
|
|
113
|
+
- Research/academic use = OK
|
|
114
|
+
- Lux Primary Network (Network ID=1, Chain ID=96369) = OK
|
|
115
|
+
- L1/L2/L3 chains descending from Lux Primary Network = OK
|
|
116
|
+
- Commercial products outside Lux ecosystem = Contact licensing@lux.network
|
|
117
|
+
- Forks = Absolutely not
|
|
118
|
+
|
|
119
|
+
================================================================================
|
|
120
|
+
|
|
121
|
+
See LP-0012 for full licensing documentation:
|
|
122
|
+
https://github.com/luxfi/lps/blob/main/LPs/lp-0012-ecosystem-licensing.md
|
package/package.json
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@l.x/sessions",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"scripts": {
|
|
5
|
-
"typecheck": "nx typecheck sessions",
|
|
6
|
-
"typecheck:tsgo": "nx typecheck:tsgo sessions",
|
|
7
|
-
"lint": "nx lint sessions",
|
|
8
|
-
"lint:fix": "nx lint:fix sessions",
|
|
9
|
-
"lint:biome": "nx lint:biome sessions",
|
|
10
|
-
"lint:biome:fix": "nx lint:biome:fix sessions",
|
|
11
|
-
"lint:eslint": "nx lint:eslint sessions",
|
|
12
|
-
"lint:eslint:fix": "nx lint:eslint:fix sessions",
|
|
13
|
-
"check:deps:usage": "nx check:deps:usage sessions",
|
|
14
|
-
"test": "nx test sessions",
|
|
15
|
-
"test:integration:backend": "nx test:integration:backend sessions"
|
|
16
|
-
},
|
|
3
|
+
"version": "1.0.5",
|
|
17
4
|
"nx": {
|
|
18
5
|
"includedScripts": []
|
|
19
6
|
},
|
|
@@ -23,10 +10,10 @@
|
|
|
23
10
|
"@noble/hashes": "2.0.1",
|
|
24
11
|
"@scure/base": "2.0.0",
|
|
25
12
|
"@tanstack/react-query": "5.90.20",
|
|
26
|
-
"@luxamm/client-platform-service": "0.0.
|
|
13
|
+
"@luxamm/client-platform-service": "0.0.119",
|
|
27
14
|
"bidc": "0.0.3",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
15
|
+
"zod": "4.3.6",
|
|
16
|
+
"@luxfi/utilities": "^1.0.6"
|
|
30
17
|
},
|
|
31
18
|
"devDependencies": {
|
|
32
19
|
"@edge-runtime/vm": "5.0.0",
|
|
@@ -34,16 +21,29 @@
|
|
|
34
21
|
"@types/node": "22.13.1",
|
|
35
22
|
"@types/react": "19.0.10",
|
|
36
23
|
"@typescript/native-preview": "7.0.0-dev.20260311.1",
|
|
37
|
-
"@luxfi/eslint-config": "workspace:^",
|
|
38
24
|
"@vitest/coverage-v8": "3.2.1",
|
|
39
25
|
"depcheck": "1.4.7",
|
|
40
26
|
"eslint": "8.57.1",
|
|
41
27
|
"happy-dom": "20.0.10",
|
|
42
28
|
"ts-morph": "23.0.0",
|
|
43
29
|
"typescript": "5.8.3",
|
|
44
|
-
"vitest": "3.2.1"
|
|
30
|
+
"vitest": "3.2.1",
|
|
31
|
+
"@luxfi/eslint-config": "^1.0.6"
|
|
45
32
|
},
|
|
46
33
|
"main": "src/index.ts",
|
|
47
34
|
"private": false,
|
|
48
|
-
"sideEffects": false
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"scripts": {
|
|
37
|
+
"typecheck": "nx typecheck sessions",
|
|
38
|
+
"typecheck:tsgo": "nx typecheck:tsgo sessions",
|
|
39
|
+
"lint": "nx lint sessions",
|
|
40
|
+
"lint:fix": "nx lint:fix sessions",
|
|
41
|
+
"lint:biome": "nx lint:biome sessions",
|
|
42
|
+
"lint:biome:fix": "nx lint:biome:fix sessions",
|
|
43
|
+
"lint:eslint": "nx lint:eslint sessions",
|
|
44
|
+
"lint:eslint:fix": "nx lint:eslint:fix sessions",
|
|
45
|
+
"check:deps:usage": "nx check:deps:usage sessions",
|
|
46
|
+
"test": "nx test sessions",
|
|
47
|
+
"test:integration:backend": "nx test:integration:backend sessions"
|
|
48
|
+
}
|
|
49
49
|
}
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
createTestTransport,
|
|
24
24
|
InMemoryDeviceIdService,
|
|
25
25
|
InMemorySessionStorage,
|
|
26
|
-
|
|
26
|
+
InMemoryLXIdentifierService,
|
|
27
27
|
type MockEndpoints,
|
|
28
28
|
} from '@l.x/sessions/src/test-utils'
|
|
29
29
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
@@ -52,7 +52,7 @@ const mockTurnstileSolve = vi.fn()
|
|
|
52
52
|
describe('Challenge Flow Integration Tests', () => {
|
|
53
53
|
let sessionStorage: InMemorySessionStorage
|
|
54
54
|
let deviceIdService: InMemoryDeviceIdService
|
|
55
|
-
let lxIdentifierService:
|
|
55
|
+
let lxIdentifierService: InMemoryLXIdentifierService
|
|
56
56
|
let sessionService: SessionService
|
|
57
57
|
let sessionInitializationService: SessionInitializationService
|
|
58
58
|
let mockEndpoints: MockEndpoints
|
|
@@ -61,7 +61,7 @@ describe('Challenge Flow Integration Tests', () => {
|
|
|
61
61
|
// Initialize in-memory storage
|
|
62
62
|
sessionStorage = new InMemorySessionStorage()
|
|
63
63
|
deviceIdService = new InMemoryDeviceIdService()
|
|
64
|
-
lxIdentifierService = new
|
|
64
|
+
lxIdentifierService = new InMemoryLXIdentifierService()
|
|
65
65
|
|
|
66
66
|
// Set up mock endpoints with default responses
|
|
67
67
|
mockEndpoints = {
|
package/src/index.ts
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
export { createDeviceIdService } from '@l.x/sessions/src/device-id/createDeviceIdService'
|
|
13
13
|
export type { DeviceIdService } from '@l.x/sessions/src/device-id/types'
|
|
14
14
|
// Lx Identifier
|
|
15
|
-
export {
|
|
15
|
+
export { createLXIdentifierService } from '@l.x/sessions/src/lx-identifier/createLXIdentifierService'
|
|
16
16
|
export { lxIdentifierQuery } from '@l.x/sessions/src/lx-identifier/lxIdentifierQuery'
|
|
17
|
-
export type {
|
|
17
|
+
export type { LXIdentifierService } from '@l.x/sessions/src/lx-identifier/types'
|
|
18
18
|
// Session Repository
|
|
19
19
|
export { createSessionRepository } from '@l.x/sessions/src/session-repository/createSessionRepository'
|
|
20
20
|
export { ChallengeRejectedError } from '@l.x/sessions/src/session-repository/errors'
|
|
@@ -129,7 +129,7 @@ export { createNoopPerformanceTracker } from '@l.x/sessions/src/performance/crea
|
|
|
129
129
|
export {
|
|
130
130
|
InMemorySessionStorage,
|
|
131
131
|
InMemoryDeviceIdService,
|
|
132
|
-
|
|
132
|
+
InMemoryLXIdentifierService,
|
|
133
133
|
} from '@l.x/sessions/src/test-utils'
|
|
134
134
|
export {
|
|
135
135
|
createCookieJar,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createLXIdentifierService } from './createUniswapIdentifierService'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LXIdentifierService } from '@l.x/sessions/src/lx-identifier/types'
|
|
2
|
+
|
|
3
|
+
function createLXIdentifierService(ctx: {
|
|
4
|
+
getLXIdentifier: () => Promise<string | null>
|
|
5
|
+
setLXIdentifier: (identifier: string) => Promise<void>
|
|
6
|
+
removeLXIdentifier: () => Promise<void>
|
|
7
|
+
}): LXIdentifierService {
|
|
8
|
+
const getLXIdentifier = ctx.getLXIdentifier
|
|
9
|
+
const setLXIdentifier = ctx.setLXIdentifier
|
|
10
|
+
const removeLXIdentifier = ctx.removeLXIdentifier
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
getLXIdentifier,
|
|
14
|
+
setLXIdentifier,
|
|
15
|
+
removeLXIdentifier,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { createLXIdentifierService }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { lxIdentifierQuery } from './uniswapIdentifierQuery'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lx Identifier provider interface
|
|
3
|
+
* Platform-specific implementations handle lx 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 '@l.x/sessions/src/lx-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
|
+
}
|
|
@@ -3,14 +3,14 @@ import type { SessionRepository } from '@l.x/sessions/src/session-repository/typ
|
|
|
3
3
|
import { createSessionService } from '@l.x/sessions/src/session-service/createSessionService'
|
|
4
4
|
import type { SessionService } from '@l.x/sessions/src/session-service/types'
|
|
5
5
|
import type { SessionStorage } from '@l.x/sessions/src/session-storage/types'
|
|
6
|
-
import type {
|
|
6
|
+
import type { LXIdentifierService } from '@l.x/sessions/src/lx-identifier/types'
|
|
7
7
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
8
8
|
|
|
9
9
|
describe('createSessionService', () => {
|
|
10
10
|
let storage: SessionStorage
|
|
11
11
|
let repository: SessionRepository
|
|
12
12
|
let deviceIdService: DeviceIdService
|
|
13
|
-
let lxIdentifierService:
|
|
13
|
+
let lxIdentifierService: LXIdentifierService
|
|
14
14
|
let service: SessionService
|
|
15
15
|
|
|
16
16
|
beforeEach(() => {
|
|
@@ -39,11 +39,11 @@ describe('createSessionService', () => {
|
|
|
39
39
|
|
|
40
40
|
let lxIdentifierData: string | null = null
|
|
41
41
|
lxIdentifierService = {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
getLXIdentifier: async (): Promise<string | null> => lxIdentifierData,
|
|
43
|
+
setLXIdentifier: async (identifier: string): Promise<void> => {
|
|
44
44
|
lxIdentifierData = identifier
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
removeLXIdentifier: async (): Promise<void> => {
|
|
47
47
|
lxIdentifierData = null
|
|
48
48
|
},
|
|
49
49
|
}
|
|
@@ -339,7 +339,7 @@ describe('createSessionService', () => {
|
|
|
339
339
|
})
|
|
340
340
|
|
|
341
341
|
await service.initSession()
|
|
342
|
-
expect(await lxIdentifierService.
|
|
342
|
+
expect(await lxIdentifierService.getLXIdentifier()).toBe('71cef16f-4d99-4082-987c-a6f810f9ca7f')
|
|
343
343
|
})
|
|
344
344
|
|
|
345
345
|
it('does not persist lxIdentifier when not provided', async () => {
|
|
@@ -354,7 +354,7 @@ describe('createSessionService', () => {
|
|
|
354
354
|
})
|
|
355
355
|
|
|
356
356
|
await service.initSession()
|
|
357
|
-
expect(await lxIdentifierService.
|
|
357
|
+
expect(await lxIdentifierService.getLXIdentifier()).toBeNull()
|
|
358
358
|
})
|
|
359
359
|
|
|
360
360
|
it('updates lxIdentifier on subsequent initSession calls', async () => {
|
|
@@ -369,7 +369,7 @@ describe('createSessionService', () => {
|
|
|
369
369
|
})
|
|
370
370
|
|
|
371
371
|
await service.initSession()
|
|
372
|
-
expect(await lxIdentifierService.
|
|
372
|
+
expect(await lxIdentifierService.getLXIdentifier()).toBe('first-identifier')
|
|
373
373
|
|
|
374
374
|
repository.initSession = async (): Promise<{
|
|
375
375
|
sessionId?: string
|
|
@@ -382,7 +382,7 @@ describe('createSessionService', () => {
|
|
|
382
382
|
})
|
|
383
383
|
|
|
384
384
|
await service.initSession()
|
|
385
|
-
expect(await lxIdentifierService.
|
|
385
|
+
expect(await lxIdentifierService.getLXIdentifier()).toBe('second-identifier')
|
|
386
386
|
})
|
|
387
387
|
})
|
|
388
388
|
})
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
VerifySessionResponse,
|
|
10
10
|
} from '@l.x/sessions/src/session-service/types'
|
|
11
11
|
import type { SessionStorage } from '@l.x/sessions/src/session-storage/types'
|
|
12
|
-
import type {
|
|
12
|
+
import type { LXIdentifierService } from '@l.x/sessions/src/lx-identifier/types'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Creates a Session Service instance.
|
|
@@ -18,7 +18,7 @@ import type { LxIdentifierService } from '@l.x/sessions/src/lx-identifier/types'
|
|
|
18
18
|
export function createSessionService(ctx: {
|
|
19
19
|
sessionStorage: SessionStorage
|
|
20
20
|
deviceIdService: DeviceIdService
|
|
21
|
-
lxIdentifierService:
|
|
21
|
+
lxIdentifierService: LXIdentifierService
|
|
22
22
|
sessionRepository: SessionRepository
|
|
23
23
|
}): SessionService {
|
|
24
24
|
async function initSession(): Promise<InitSessionResponse> {
|
|
@@ -30,7 +30,7 @@ export function createSessionService(ctx: {
|
|
|
30
30
|
await ctx.deviceIdService.setDeviceId(result.deviceId)
|
|
31
31
|
}
|
|
32
32
|
if (result.extra['lxIdentifier']) {
|
|
33
|
-
await ctx.lxIdentifierService.
|
|
33
|
+
await ctx.lxIdentifierService.setLXIdentifier(result.extra['lxIdentifier'])
|
|
34
34
|
}
|
|
35
35
|
return result
|
|
36
36
|
}
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
createMockSessionClient,
|
|
17
17
|
InMemoryDeviceIdService,
|
|
18
18
|
InMemorySessionStorage,
|
|
19
|
-
|
|
19
|
+
InMemoryLXIdentifierService,
|
|
20
20
|
type MockEndpoints,
|
|
21
21
|
} from '@l.x/sessions/src/test-utils'
|
|
22
22
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
@@ -24,7 +24,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
|
24
24
|
describe('Session Lifecycle Integration Tests', () => {
|
|
25
25
|
let sessionStorage: InMemorySessionStorage
|
|
26
26
|
let deviceIdService: InMemoryDeviceIdService
|
|
27
|
-
let lxIdentifierService:
|
|
27
|
+
let lxIdentifierService: InMemoryLXIdentifierService
|
|
28
28
|
let sessionService: SessionService
|
|
29
29
|
let mockEndpoints: MockEndpoints
|
|
30
30
|
|
|
@@ -32,7 +32,7 @@ describe('Session Lifecycle Integration Tests', () => {
|
|
|
32
32
|
// Initialize in-memory storage
|
|
33
33
|
sessionStorage = new InMemorySessionStorage()
|
|
34
34
|
deviceIdService = new InMemoryDeviceIdService()
|
|
35
|
-
lxIdentifierService = new
|
|
35
|
+
lxIdentifierService = new InMemoryLXIdentifierService()
|
|
36
36
|
|
|
37
37
|
// Set up mock endpoints with default responses
|
|
38
38
|
mockEndpoints = {
|
package/src/test-utils.ts
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import type { DeviceIdService } from '@l.x/sessions/src/device-id/types'
|
|
22
22
|
import type { SessionServiceClient } from '@l.x/sessions/src/session-repository/createSessionClient'
|
|
23
23
|
import type { SessionState, SessionStorage } from '@l.x/sessions/src/session-storage/types'
|
|
24
|
-
import type {
|
|
24
|
+
import type { LXIdentifierService } from '@l.x/sessions/src/lx-identifier/types'
|
|
25
25
|
// Types for our test transport
|
|
26
26
|
export interface MockEndpointHandler {
|
|
27
27
|
(request: any, headers: Record<string, string>): Promise<any>
|
|
@@ -109,18 +109,18 @@ export class InMemoryDeviceIdService implements DeviceIdService {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export class
|
|
112
|
+
export class InMemoryLXIdentifierService implements LXIdentifierService {
|
|
113
113
|
private identifier: string | null = null
|
|
114
114
|
|
|
115
|
-
async
|
|
115
|
+
async getLXIdentifier(): Promise<string | null> {
|
|
116
116
|
return this.identifier
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
async
|
|
119
|
+
async setLXIdentifier(id: string): Promise<void> {
|
|
120
120
|
this.identifier = id
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
async
|
|
123
|
+
async removeLXIdentifier(): Promise<void> {
|
|
124
124
|
this.identifier = null
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LXIdentifierService } from '@l.x/sessions/src/lx-identifier/types'
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}):
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
3
|
+
function createLXIdentifierService(ctx: {
|
|
4
|
+
getLXIdentifier: () => Promise<string | null>
|
|
5
|
+
setLXIdentifier: (identifier: string) => Promise<void>
|
|
6
|
+
removeLXIdentifier: () => Promise<void>
|
|
7
|
+
}): LXIdentifierService {
|
|
8
|
+
const getLXIdentifier = ctx.getLXIdentifier
|
|
9
|
+
const setLXIdentifier = ctx.setLXIdentifier
|
|
10
|
+
const removeLXIdentifier = ctx.removeLXIdentifier
|
|
11
11
|
|
|
12
12
|
return {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
getLXIdentifier,
|
|
14
|
+
setLXIdentifier,
|
|
15
|
+
removeLXIdentifier,
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { createLXIdentifierService }
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Lx Identifier provider interface
|
|
3
3
|
* Platform-specific implementations handle lx identifier persistence
|
|
4
4
|
*/
|
|
5
|
-
interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
interface LXIdentifierService {
|
|
6
|
+
getLXIdentifier(): Promise<string | null>
|
|
7
|
+
setLXIdentifier(identifier: string): Promise<void>
|
|
8
|
+
removeLXIdentifier(): Promise<void>
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export type {
|
|
11
|
+
export type { LXIdentifierService }
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { queryOptions } from '@tanstack/react-query'
|
|
2
|
-
import type {
|
|
2
|
+
import type { LXIdentifierService } from '@l.x/sessions/src/lx-identifier/types'
|
|
3
3
|
import { ReactQueryCacheKey } from 'utilities/src/reactQuery/cache'
|
|
4
4
|
import type { QueryOptionsResult } from 'utilities/src/reactQuery/queryOptions'
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type LXIdentifierQueryOptions = QueryOptionsResult<
|
|
7
7
|
string | null,
|
|
8
8
|
Error,
|
|
9
9
|
string | null,
|
|
10
|
-
[ReactQueryCacheKey.
|
|
10
|
+
[ReactQueryCacheKey.LXIdentifier]
|
|
11
11
|
>
|
|
12
12
|
|
|
13
|
-
export function lxIdentifierQuery(getService: () =>
|
|
13
|
+
export function lxIdentifierQuery(getService: () => LXIdentifierService): LXIdentifierQueryOptions {
|
|
14
14
|
return queryOptions({
|
|
15
|
-
queryKey: [ReactQueryCacheKey.
|
|
16
|
-
queryFn: async () => getService().
|
|
15
|
+
queryKey: [ReactQueryCacheKey.LXIdentifier],
|
|
16
|
+
queryFn: async () => getService().getLXIdentifier(),
|
|
17
17
|
staleTime: Infinity,
|
|
18
18
|
gcTime: Infinity,
|
|
19
19
|
})
|