lycheedev 3.1.1 → 3.2.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 +16 -38
- package/THIRD_PARTY_NOTICES +4 -314
- package/bin/lycheedev.mjs +1 -1
- package/bin/update.mjs +26 -32
- package/native/windows-amd64/lycheedev.exe +0 -0
- package/package.json +1 -1
- package/payload/addon/Bindings.xml +12 -0
- package/payload/addon/Bridge/ActivityView.lua +2 -5
- package/payload/addon/Bridge/CaptureWriter.lua +9 -115
- package/payload/addon/Bridge/FocusBindings.lua +71 -0
- package/payload/addon/Bridge/InputProtection.lua +2 -9
- package/payload/addon/Bridge/InputState.lua +15 -19
- package/payload/addon/Bridge/MemoryProtocol.lua +1 -1
- package/payload/addon/Bridge/ProbeExecution.lua +1 -0
- package/payload/addon/Bridge/ReceiverBindings.lua +73 -279
- package/payload/addon/Bridge/SlotProtocol.lua +30 -12
- package/payload/addon/Bridge/SlotRuntime.lua +9 -12
- package/payload/addon/Core/ClientGate.lua +2 -0
- package/payload/addon/Core/Compat.lua +25 -24
- package/payload/addon/Core/Controls.lua +27 -248
- package/payload/addon/Core/Execute.lua +22 -19
- package/payload/addon/Core/Locale.lua +4 -116
- package/payload/addon/Core/Locale_enUS.lua +4 -116
- package/payload/addon/Core/Persistence.lua +2 -2
- package/payload/addon/Core/Runtime.lua +46 -64
- package/payload/addon/Core/Serializer.lua +9 -1
- package/payload/addon/Core/Startup.lua +20 -0
- package/payload/addon/Core/Stores.lua +63 -95
- package/payload/addon/LICENSE +21 -0
- package/payload/addon/Lychee Dev.toc +10 -21
- package/payload/addon/Modules/AutomationView.lua +47 -383
- package/payload/addon/Modules/Diagnostics.lua +0 -4
- package/payload/addon/Modules/Events/Catalog.lua +1 -1
- package/payload/addon/Modules/Events/CatalogData_Anniversary.lua +1489 -0
- package/payload/addon/Modules/Events/CatalogData_Era.lua +1489 -0
- package/payload/addon/Modules/FunctionTrace.lua +17 -6
- package/payload/addon/Modules/ObjectInspector.lua +27 -25
- package/payload/addon/THIRD_PARTY_NOTICES +483 -0
- package/payload/addon/UI/Pages/Automation.lua +7 -64
- package/payload/addon/UI/Pages/Events.lua +0 -4
- package/payload/addon/UI/Pages/ExportRecords.lua +1 -1
- package/payload/addon/UI/Pages/Object.lua +5 -4
- package/payload/addon/UI/Pages/Run.lua +7 -1
- package/payload/addon/UI/TreeView.lua +0 -11
- package/payload/addon/UI/Widgets.lua +0 -102
- package/payload/addon/UI/Window.lua +0 -6
- package/payload/skill/SKILL.md +11 -2
- package/payload/skill/references/commands.md +17 -27
- package/payload/skill/references/data-hotfix.md +6 -3
- package/payload/skill/references/data-investigation.md +5 -2
- package/payload/skill/references/data-tables.md +4 -0
- package/payload/skill/references/data-targets.md +4 -2
- package/payload/skill/references/installation.md +9 -3
- package/payload/skill/references/live-investigation.md +14 -6
- package/payload/skill/references/live-probes.md +9 -8
- package/payload/skill/references/live-recovery.md +75 -42
- package/payload/skill/references/live-startup.md +97 -76
- package/payload/skill/references/runtime-investigations.md +10 -8
- package/payload/skill/references/source-preparation.md +23 -2
- package/payload/skill/references/source-research.md +58 -5
- package/payload/skill/scripts/lycheedev.mjs +16 -12
- package/release.json +136 -176
- package/payload/addon/Bridge/Definitions.lua +0 -3
- package/payload/addon/Bridge/FaultRunner.lua +0 -44
- package/payload/addon/Bridge/Identity.lua +0 -127
- package/payload/addon/Bridge/InputProtocol.lua +0 -76
- package/payload/addon/Bridge/InputSignal.lua +0 -36
- package/payload/addon/Bridge/Investigation.lua +0 -159
- package/payload/addon/Bridge/MatrixSymbol.lua +0 -1169
- package/payload/addon/Bridge/ProbeQueue.lua +0 -205
- package/payload/addon/Bridge/ProbeRunner.lua +0 -349
- package/payload/addon/Bridge/ReceiptView.lua +0 -316
- package/payload/addon/Bridge/Receiver.lua +0 -326
- package/payload/addon/Bridge/Reentry.lua +0 -261
- package/payload/addon/Bridge/ReportStore.lua +0 -224
- package/payload/addon/Bridge/Session.lua +0 -173
- package/payload/addon/Bridge/StartupBeacon.lua +0 -63
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
local waiting, ownedTicket, ownedRoot, ownedBytes, submitted
|
|
4
|
-
local function restricted(value) return issecretvalue and issecretvalue(value) end
|
|
5
|
-
local function plain(value)
|
|
6
|
-
return not restricted(value) and type(value) == "table" and getmetatable(value) == nil
|
|
7
|
-
end
|
|
8
|
-
local fields = { schema=true, requestId=true, sessionNonce=true, reloadNonce=true,
|
|
9
|
-
release=true, product=true, build=true, character=true, realm=true, guid=true,
|
|
10
|
-
runtimeEpoch=true, receipt=true, bodyBytes=true, bodyAdler32=true,
|
|
11
|
-
codeSHA256=true, codeAdler32=true, codeBytes=true, cleanupNonce=true, queueReload=true,
|
|
12
|
-
standalone=true, builtin=true }
|
|
13
|
-
local function valid(ticket)
|
|
14
|
-
if not plain(ticket) then return false end
|
|
15
|
-
-- Encoding traverses all values before comparisons, rejecting secrets,
|
|
16
|
-
-- cycles and metatables. Do not interpret unknown/newer ticket formats.
|
|
17
|
-
if not ns.CaptureWriter.Encode(ticket, 8192) or ticket.schema ~= "lycheedev.reentry.v1" then return false end
|
|
18
|
-
for field in pairs(ticket) do if not fields[field] then return false end end
|
|
19
|
-
for _, field in ipairs({"requestId","release","product","build","character","realm","guid"}) do
|
|
20
|
-
local value=ticket[field]
|
|
21
|
-
if type(value)~="string" or #value==0 or #value>128 or string.find(value,"[%z\1-\31\127]") then return false end
|
|
22
|
-
end
|
|
23
|
-
if not string.match(ticket.requestId,"^[%w_%-]+$") then return false end
|
|
24
|
-
for _, field in ipairs({"sessionNonce","reloadNonce"}) do
|
|
25
|
-
local value=ticket[field]
|
|
26
|
-
if type(value)~="string" or #value~=32 or not string.match(value,"^[0-9a-f]+$") then return false end
|
|
27
|
-
end
|
|
28
|
-
if type(ticket.runtimeEpoch)~="number" or ticket.runtimeEpoch<1
|
|
29
|
-
or ticket.runtimeEpoch>=9007199254740991 or ticket.runtimeEpoch%1~=0 then return false end
|
|
30
|
-
if ticket.standalone~=nil then
|
|
31
|
-
return ticket.standalone==true and ticket.queueReload==nil and ticket.receipt==nil
|
|
32
|
-
and ticket.bodyBytes==nil and ticket.bodyAdler32==nil and ticket.codeSHA256==nil
|
|
33
|
-
and ticket.codeAdler32==nil and ticket.codeBytes==nil and ticket.cleanupNonce==nil
|
|
34
|
-
end
|
|
35
|
-
if ticket.builtin~=nil then
|
|
36
|
-
return ticket.builtin==true and ticket.queueReload==nil and ticket.cleanupNonce==nil
|
|
37
|
-
and type(ticket.receipt)=="string" and #ticket.receipt>0 and #ticket.receipt<=4096
|
|
38
|
-
and type(ticket.bodyBytes)=="number" and ticket.bodyBytes>=1 and ticket.bodyBytes<=512*1024
|
|
39
|
-
and ticket.bodyBytes%1==0 and type(ticket.bodyAdler32)=="string"
|
|
40
|
-
and #ticket.bodyAdler32==8 and string.match(ticket.bodyAdler32,"^[0-9a-f]+$")~=nil
|
|
41
|
-
and ticket.codeSHA256==nil and ticket.codeAdler32==nil and ticket.codeBytes==nil
|
|
42
|
-
end
|
|
43
|
-
if ticket.queueReload~=nil then
|
|
44
|
-
return ticket.queueReload==true and ticket.receipt==nil and ticket.bodyBytes==nil
|
|
45
|
-
and ticket.bodyAdler32==nil and ticket.codeSHA256==nil and ticket.codeAdler32==nil
|
|
46
|
-
and ticket.codeBytes==nil and ticket.cleanupNonce==nil
|
|
47
|
-
end
|
|
48
|
-
for field,size in pairs({codeSHA256=64,codeAdler32=8}) do
|
|
49
|
-
local value=ticket[field]
|
|
50
|
-
if type(value)~="string" or #value~=size or not string.match(value,"^[0-9a-f]+$") then return false end
|
|
51
|
-
end
|
|
52
|
-
if ticket.cleanupNonce~=nil then
|
|
53
|
-
if type(ticket.cleanupNonce)~="string" or #ticket.cleanupNonce~=32
|
|
54
|
-
or not string.match(ticket.cleanupNonce,"^[0-9a-f]+$")
|
|
55
|
-
or ticket.bodyBytes~=nil or ticket.bodyAdler32~=nil then return false end
|
|
56
|
-
elseif not (type(ticket.bodyBytes)=="number" and ticket.bodyBytes>=1 and ticket.bodyBytes<=512*1024 and ticket.bodyBytes%1==0
|
|
57
|
-
and type(ticket.bodyAdler32)=="string" and #ticket.bodyAdler32==8 and string.match(ticket.bodyAdler32,"^[0-9a-f]+$")~=nil) then return false end
|
|
58
|
-
return type(ticket.receipt)=="string" and #ticket.receipt>0 and #ticket.receipt<=4096
|
|
59
|
-
and type(ticket.codeBytes)=="number" and ticket.codeBytes>=1 and ticket.codeBytes<=256*1024 and ticket.codeBytes%1==0
|
|
60
|
-
end
|
|
61
|
-
local function cancel(discard)
|
|
62
|
-
if waiting then waiting:UnregisterAllEvents(); waiting:SetScript("OnEvent",nil); waiting=nil end
|
|
63
|
-
local state=ns.Persistence.Bridge()
|
|
64
|
-
if state and ((discard and valid(state.reentry)) or (state==ownedRoot and rawequal(state.reentry,ownedTicket)
|
|
65
|
-
and ns.CaptureWriter.Encode(state.reentry,8192)==ownedBytes)) then state.reentry=nil end
|
|
66
|
-
ownedTicket,ownedRoot,ownedBytes=nil,nil,nil
|
|
67
|
-
end
|
|
68
|
-
local function receiptFor(ticket)
|
|
69
|
-
if ticket.cleanupNonce then
|
|
70
|
-
local receipt,reason=ns.ProbeQueue.VerifyRetired(ticket.requestId,ticket.cleanupNonce)
|
|
71
|
-
if not receipt then return nil,reason end
|
|
72
|
-
return receipt
|
|
73
|
-
end
|
|
74
|
-
local identity,reason=ns.Session.NextIdentity()
|
|
75
|
-
if not identity then return nil,reason end
|
|
76
|
-
local ready=ns.Platform.ObserveInputState()==true
|
|
77
|
-
local receipt,failure=ns.CaptureWriter.EncodeSignal({
|
|
78
|
-
schema="lycheedev.signal.v1",kind="ready",release=ns.Release,
|
|
79
|
-
sessionNonce=identity.sessionNonce,requestId=ticket.requestId,reloadNonce=ticket.reloadNonce,
|
|
80
|
-
character=identity.character,realm=identity.realm,guid=identity.guid,
|
|
81
|
-
product=ns.Startup.identity.product,build=ns.Startup.identity.build,
|
|
82
|
-
sequence=identity.sequence,runtimeEpoch=identity.runtimeEpoch,inputReady=ready,
|
|
83
|
-
reportScope="character-v1",
|
|
84
|
-
},2048)
|
|
85
|
-
if not receipt then return nil,failure end
|
|
86
|
-
return receipt
|
|
87
|
-
end
|
|
88
|
-
local function show(ticket)
|
|
89
|
-
local receipt, failure=receiptFor(ticket)
|
|
90
|
-
if not receipt then return nil,failure end
|
|
91
|
-
return ns.ReceiptView.Show(receipt,nil,function() return receiptFor(ticket) end)
|
|
92
|
-
end
|
|
93
|
-
local function submit(state,ticket)
|
|
94
|
-
if not valid(ticket) then return nil,"reload_invalid_ticket" end
|
|
95
|
-
if type(C_UI)~="table" or type(C_UI.Reload)~="function" or type(InCombatLockdown)~="function" then return nil,"reload_unavailable" end
|
|
96
|
-
local ok,combat=pcall(InCombatLockdown)
|
|
97
|
-
if not ok or restricted(combat) or combat~=false then return nil,"reload_combat_unavailable" end
|
|
98
|
-
ns.Session.CancelInputWait(); ns.ReceiptView.Hide()
|
|
99
|
-
-- Publish before the one-shot effect. An exception is unresolved, never
|
|
100
|
-
-- permission to retry; opt-out can explicitly discard our own ticket.
|
|
101
|
-
state.reentry=ticket
|
|
102
|
-
ownedTicket,ownedRoot,ownedBytes,submitted=ticket,state,ns.CaptureWriter.Encode(ticket,8192),true
|
|
103
|
-
if not pcall(C_UI.Reload) then return nil,"reload_submission_failed" end
|
|
104
|
-
return "reload_requested"
|
|
105
|
-
end
|
|
106
|
-
ns.Reentry={
|
|
107
|
-
Cancel=cancel,
|
|
108
|
-
-- A pending, submitted or persisted reload ticket means a request-scoped
|
|
109
|
-
-- operation is mid-flight and owns the displayed receipt.
|
|
110
|
-
Busy=function()
|
|
111
|
-
if waiting or submitted then return true end
|
|
112
|
-
local state,failure=ns.Persistence.Bridge()
|
|
113
|
-
if not state then return nil,failure end
|
|
114
|
-
if restricted(state.reentry) then return nil,"reload_invalid_ticket" end
|
|
115
|
-
return state.reentry~=nil
|
|
116
|
-
end,
|
|
117
|
-
Refresh=function(reloadNonce)
|
|
118
|
-
if submitted then return nil,"reload_already_submitted" end
|
|
119
|
-
if type(reloadNonce)~="string" or #reloadNonce~=32 or not string.match(reloadNonce,"^[0-9a-f]+$") then
|
|
120
|
-
return nil,"reload_invalid_nonce"
|
|
121
|
-
end
|
|
122
|
-
local session,reason=ns.Session.Current()
|
|
123
|
-
if not session then return nil,reason end
|
|
124
|
-
local state,failure=ns.Persistence.Bridge()
|
|
125
|
-
if not state then return nil,failure end
|
|
126
|
-
if restricted(state.reentry) or state.reentry~=nil then return nil,"reload_ticket_exists" end
|
|
127
|
-
return submit(state,{schema="lycheedev.reentry.v1",standalone=true,
|
|
128
|
-
requestId="RELOAD-"..reloadNonce,sessionNonce=session.sessionNonce,
|
|
129
|
-
reloadNonce=reloadNonce,runtimeEpoch=session.runtimeEpoch,
|
|
130
|
-
character=session.character,realm=session.realm,guid=session.guid,
|
|
131
|
-
release=ns.Release,product=ns.Startup.identity.product,build=ns.Startup.identity.build})
|
|
132
|
-
end,
|
|
133
|
-
Flush=function(requestId,reloadNonce)
|
|
134
|
-
if submitted then return nil,"reload_already_submitted" end
|
|
135
|
-
if type(requestId)~="string" or #requestId==0 or #requestId>128
|
|
136
|
-
or not string.match(requestId,"^[%w_%-]+$") or type(reloadNonce)~="string"
|
|
137
|
-
or #reloadNonce~=32 or not string.match(reloadNonce,"^[0-9a-f]+$") then
|
|
138
|
-
return nil,"reload_invalid_request"
|
|
139
|
-
end
|
|
140
|
-
local session,reason=ns.Session.Current()
|
|
141
|
-
if not session then return nil,reason end
|
|
142
|
-
local state,failure=ns.Persistence.Bridge()
|
|
143
|
-
if not state then return nil,failure end
|
|
144
|
-
if restricted(state.reentry) or state.reentry~=nil then return nil,"reload_ticket_exists" end
|
|
145
|
-
local receipt,body=ns.ReportStore.Read(requestId)
|
|
146
|
-
if not receipt then return nil,body end
|
|
147
|
-
return submit(state,{schema="lycheedev.reentry.v1",builtin=true,requestId=requestId,
|
|
148
|
-
sessionNonce=session.sessionNonce,reloadNonce=reloadNonce,runtimeEpoch=session.runtimeEpoch,
|
|
149
|
-
character=session.character,realm=session.realm,guid=session.guid,
|
|
150
|
-
release=ns.Release,product=ns.Startup.identity.product,build=ns.Startup.identity.build,
|
|
151
|
-
receipt=receipt,bodyBytes=#body,bodyAdler32=ns.CaptureWriter.DigestBytes(body)})
|
|
152
|
-
end,
|
|
153
|
-
LoadQueue=function(requestId,reloadNonce)
|
|
154
|
-
if submitted then return nil,"reload_already_submitted" end
|
|
155
|
-
local session,reason=ns.Session.Current()
|
|
156
|
-
if not session then return nil,reason end
|
|
157
|
-
local state,failure=ns.Persistence.Bridge()
|
|
158
|
-
if not state then return nil,failure end
|
|
159
|
-
if restricted(state.reentry) or state.reentry~=nil then return nil,"reload_ticket_exists" end
|
|
160
|
-
local ticket={schema="lycheedev.reentry.v1",queueReload=true,requestId=requestId,
|
|
161
|
-
sessionNonce=session.sessionNonce,reloadNonce=reloadNonce,runtimeEpoch=session.runtimeEpoch,
|
|
162
|
-
character=session.character,realm=session.realm,guid=session.guid,
|
|
163
|
-
release=ns.Release,product=ns.Startup.identity.product,build=ns.Startup.identity.build}
|
|
164
|
-
if not valid(ticket) then return nil,"reload_invalid_ticket" end
|
|
165
|
-
local receipt,reportFailure=ns.ReportStore.Read(requestId)
|
|
166
|
-
if receipt or reportFailure~="report_unavailable" then return nil,"report_still_retained" end
|
|
167
|
-
local absent,probeFailure=ns.ProbeRunner.VerifyAbsent(requestId)
|
|
168
|
-
if not absent then return nil,probeFailure end
|
|
169
|
-
return submit(state,ticket)
|
|
170
|
-
end,
|
|
171
|
-
Reload=function(requestId,cleanupNonce)
|
|
172
|
-
if submitted then return nil,"reload_already_submitted" end
|
|
173
|
-
local session,reason=ns.Session.Current()
|
|
174
|
-
if not session then return nil,reason end
|
|
175
|
-
local state,failure=ns.Persistence.Bridge()
|
|
176
|
-
if not state then return nil,failure end
|
|
177
|
-
if restricted(state.reentry) or state.reentry~=nil then return nil,"reload_ticket_exists" end
|
|
178
|
-
local ticket,scopeFailure=ns.ProbeQueue.ReloadScope(requestId)
|
|
179
|
-
if not ticket then return nil,scopeFailure end
|
|
180
|
-
local receipt,body,code
|
|
181
|
-
if cleanupNonce~=nil then
|
|
182
|
-
receipt,body=ns.ReportStore.Acknowledged(requestId)
|
|
183
|
-
ticket.cleanupNonce=cleanupNonce
|
|
184
|
-
else
|
|
185
|
-
receipt,body,code=ns.ProbeRunner.Reported(requestId)
|
|
186
|
-
if receipt then
|
|
187
|
-
if #code~=ticket.codeBytes or ns.CaptureWriter.DigestBytes(code)~=ticket.codeAdler32 then return nil,"reload_code_changed" end
|
|
188
|
-
ticket.bodyBytes,ticket.bodyAdler32=#body,ns.CaptureWriter.DigestBytes(body)
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
if not receipt then return nil,body end
|
|
192
|
-
ticket.schema,ticket.runtimeEpoch,ticket.receipt="lycheedev.reentry.v1",session.runtimeEpoch,receipt
|
|
193
|
-
return submit(state,ticket)
|
|
194
|
-
end,
|
|
195
|
-
Start=function(frame)
|
|
196
|
-
local state=ns.Persistence.Bridge()
|
|
197
|
-
if not state or not ns.Persistence.BridgeEnabled() then return true end
|
|
198
|
-
if restricted(state.reentry) then return nil,"reload_invalid_ticket" end
|
|
199
|
-
if state.reentry==nil then return true end
|
|
200
|
-
local ticket=state.reentry
|
|
201
|
-
if not valid(ticket) then return nil,"reload_invalid_ticket" end
|
|
202
|
-
if waiting or submitted then return nil,"reload_already_submitted" end
|
|
203
|
-
ownedTicket,ownedRoot,ownedBytes=ticket,state,ns.CaptureWriter.Encode(ticket,8192)
|
|
204
|
-
local copy={}
|
|
205
|
-
for key,value in pairs(ticket) do copy[key]=value end
|
|
206
|
-
ticket=copy
|
|
207
|
-
waiting=frame
|
|
208
|
-
local entered,loadingDone=false,false
|
|
209
|
-
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
210
|
-
frame:RegisterEvent("LOADING_SCREEN_DISABLED")
|
|
211
|
-
frame:RegisterEvent("LOADING_SCREEN_ENABLED")
|
|
212
|
-
frame:RegisterEvent("PLAYER_LEAVING_WORLD")
|
|
213
|
-
frame:SetScript("OnEvent",function(_,event,initialLogin,reloading)
|
|
214
|
-
if waiting~=frame then return end
|
|
215
|
-
if event=="PLAYER_LEAVING_WORLD" then cancel();return end
|
|
216
|
-
if event=="LOADING_SCREEN_ENABLED" then loadingDone=false;return end
|
|
217
|
-
if event=="PLAYER_ENTERING_WORLD" then
|
|
218
|
-
if restricted(initialLogin) or restricted(reloading) or initialLogin~=false or reloading~=true then cancel();return end
|
|
219
|
-
entered=true
|
|
220
|
-
elseif event=="LOADING_SCREEN_DISABLED" then loadingDone=true
|
|
221
|
-
else return end
|
|
222
|
-
-- Neither event alone proves the new world is ready. Their order
|
|
223
|
-
-- varies; retain the exact ticket until both have been observed.
|
|
224
|
-
if not entered or not loadingDone then return end
|
|
225
|
-
local unchanged=rawequal(state.reentry,ownedTicket) and ns.CaptureWriter.Encode(state.reentry,8192)==ownedBytes
|
|
226
|
-
cancel()
|
|
227
|
-
if not unchanged then return end
|
|
228
|
-
local current=ns.Persistence.Bridge()
|
|
229
|
-
if current~=state or not ns.Persistence.BridgeEnabled() then return end
|
|
230
|
-
if restricted(state.runtimeEpoch) or state.runtimeEpoch~=ticket.runtimeEpoch then return end
|
|
231
|
-
local actor=ns.Platform.ObserveActor()
|
|
232
|
-
if not actor or actor.character~=ticket.character or actor.realm~=ticket.realm or actor.guid~=ticket.guid
|
|
233
|
-
or ns.Release~=ticket.release or ns.Startup.identity.product~=ticket.product or ns.Startup.identity.build~=ticket.build then return end
|
|
234
|
-
local receipt,body=ns.ReportStore.Read(ticket.requestId)
|
|
235
|
-
if ticket.cleanupNonce or ticket.queueReload or ticket.standalone then
|
|
236
|
-
if receipt~=nil or body~="report_unavailable" then return end
|
|
237
|
-
elseif receipt~=ticket.receipt or type(body)~="string" or #body~=ticket.bodyBytes or ns.CaptureWriter.DigestBytes(body)~=ticket.bodyAdler32 then return end
|
|
238
|
-
local bound=ns.Session.Bind(ticket.sessionNonce)
|
|
239
|
-
if not bound then return end
|
|
240
|
-
if bound.runtimeEpoch~=ticket.runtimeEpoch+1 then ns.Session.Release(); return end
|
|
241
|
-
if not ticket.cleanupNonce and not ticket.standalone and not ticket.builtin then
|
|
242
|
-
local scope=ns.ProbeQueue.ReloadScope(ticket.requestId)
|
|
243
|
-
if not scope then ns.Session.Release(); return end
|
|
244
|
-
for key,value in pairs(scope) do
|
|
245
|
-
if not (ticket.queueReload and (key=="codeSHA256" or key=="codeAdler32" or key=="codeBytes"))
|
|
246
|
-
and ticket[key]~=value then ns.Session.Release(); return end
|
|
247
|
-
end
|
|
248
|
-
end
|
|
249
|
-
local visible=show(ticket)
|
|
250
|
-
if not visible then ns.Session.Release(); ns.ReceiptView.Hide(); return end
|
|
251
|
-
if ticket.cleanupNonce then return end
|
|
252
|
-
ns.Session.WhenInputReady(function(ready)
|
|
253
|
-
if ready then
|
|
254
|
-
local shown=show(ticket)
|
|
255
|
-
if not shown then ns.ReceiptView.Hide() end
|
|
256
|
-
end
|
|
257
|
-
end)
|
|
258
|
-
end)
|
|
259
|
-
return true
|
|
260
|
-
end,
|
|
261
|
-
}
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
local MAX_RECORDS, MAX_BYTES = 100, 16 * 1024 * 1024
|
|
4
|
-
local lastAcknowledgement
|
|
5
|
-
local reservation
|
|
6
|
-
local function restricted(value)
|
|
7
|
-
return issecretvalue and issecretvalue(value)
|
|
8
|
-
end
|
|
9
|
-
local function plain(value)
|
|
10
|
-
return not restricted(value) and type(value) == "table" and getmetatable(value) == nil
|
|
11
|
-
end
|
|
12
|
-
local function label(value, limit)
|
|
13
|
-
return not restricted(value) and type(value) == "string" and #value > 0
|
|
14
|
-
and #value <= limit and not string.find(value, "[%z\1-\31\127]")
|
|
15
|
-
end
|
|
16
|
-
local function requestKey(value)
|
|
17
|
-
return label(value, 128) and string.match(value, "^[%w_%-]+$") ~= nil
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
ns.ReportStore = {
|
|
21
|
-
Reserve = function(requestId)
|
|
22
|
-
if not requestKey(requestId) then return nil,"report_invalid_request" end
|
|
23
|
-
local state,reason=ns.Persistence.Bridge()
|
|
24
|
-
if not state then return nil,reason end
|
|
25
|
-
if not plain(state.reports) then return nil,"report_invalid_store" end
|
|
26
|
-
if reservation and reservation.root==state and reservation.requestId~=requestId then
|
|
27
|
-
return nil,"report_reservation_busy"
|
|
28
|
-
end
|
|
29
|
-
local count,bytes=0,8192
|
|
30
|
-
for id,record in pairs(state.reports) do
|
|
31
|
-
count=count+1
|
|
32
|
-
if count>=MAX_RECORDS then return nil,"report_count_limit" end
|
|
33
|
-
if not requestKey(id) or id==requestId or not plain(record)
|
|
34
|
-
or restricted(record.body) or restricted(record.receipt)
|
|
35
|
-
or type(record.body)~="string" or type(record.receipt)~="string"
|
|
36
|
-
or #record.body==0 or #record.body>512*1024 or #record.receipt==0 or #record.receipt>4096 then
|
|
37
|
-
return nil,"report_invalid_store"
|
|
38
|
-
end
|
|
39
|
-
for field in pairs(record) do
|
|
40
|
-
if restricted(field) or (field~="receipt" and field~="body") then return nil,"report_invalid_store" end
|
|
41
|
-
end
|
|
42
|
-
bytes=bytes+#record.body+#record.receipt
|
|
43
|
-
if bytes>MAX_BYTES then return nil,"report_store_limit" end
|
|
44
|
-
end
|
|
45
|
-
reservation={root=state,requestId=requestId}
|
|
46
|
-
return true
|
|
47
|
-
end,
|
|
48
|
-
Acknowledged = function(requestId, sequence)
|
|
49
|
-
if not requestKey(requestId) then return nil, "report_invalid_request" end
|
|
50
|
-
local state = ns.Persistence.Bridge()
|
|
51
|
-
local session = ns.Session.Current()
|
|
52
|
-
local ack = lastAcknowledgement
|
|
53
|
-
if sequence ~= nil and (restricted(sequence) or type(sequence) ~= "number"
|
|
54
|
-
or not ack or sequence ~= ack.reportSequence) then return nil, "report_invalid_sequence" end
|
|
55
|
-
if not ack or not session or ack.root ~= state or ack.requestId ~= requestId
|
|
56
|
-
or ack.sessionNonce ~= session.sessionNonce or ack.guid ~= session.guid
|
|
57
|
-
or ack.generation ~= session.generation then
|
|
58
|
-
return nil, "report_acknowledgement_unavailable"
|
|
59
|
-
end
|
|
60
|
-
local receipt, reason = ns.ReportStore.Read(requestId)
|
|
61
|
-
if receipt or reason ~= "report_unavailable" then return nil, "report_still_retained" end
|
|
62
|
-
if sequence ~= nil then
|
|
63
|
-
-- Reissue with a fresh sequence: input readiness may have advanced
|
|
64
|
-
-- beyond the original optical ACK. The payload identity is fixed.
|
|
65
|
-
local identity, failure = ns.Session.NextIdentity(ack.signal.sequence)
|
|
66
|
-
if not identity then return nil, failure end
|
|
67
|
-
local signal = {}
|
|
68
|
-
for key, value in pairs(ack.signal) do signal[key] = value end
|
|
69
|
-
signal.sequence = identity.sequence
|
|
70
|
-
local encoded, encodeFailure = ns.CaptureWriter.EncodeSignal(signal, 2048)
|
|
71
|
-
if not encoded then return nil, encodeFailure end
|
|
72
|
-
ack.signal, ack.receipt = signal, encoded
|
|
73
|
-
end
|
|
74
|
-
return ack.receipt
|
|
75
|
-
end,
|
|
76
|
-
Commit = function(requestId, code, value)
|
|
77
|
-
local state, failure = ns.Persistence.Bridge()
|
|
78
|
-
if not state then return nil, failure end
|
|
79
|
-
if not ns.Startup.ready or not ns.Persistence.BridgeEnabled() then
|
|
80
|
-
return nil, "bridge_disabled"
|
|
81
|
-
end
|
|
82
|
-
if not requestKey(requestId) then return nil, "report_invalid_request" end
|
|
83
|
-
local session, sessionFailure = ns.Session.Current()
|
|
84
|
-
if not session then return nil, sessionFailure end
|
|
85
|
-
if restricted(code) or type(code) ~= "string" or #code > 256 * 1024 then
|
|
86
|
-
return nil, "report_invalid_code"
|
|
87
|
-
end
|
|
88
|
-
if not plain(state.reports) then return nil, "report_invalid_store" end
|
|
89
|
-
local previous = state.reports[requestId]
|
|
90
|
-
if restricted(previous) or previous ~= nil then return nil, "report_request_exists" end
|
|
91
|
-
local body, reason = ns.CaptureWriter.Encode(value)
|
|
92
|
-
if not body then return nil, reason end
|
|
93
|
-
local identity, identityFailure = ns.Session.NextIdentity()
|
|
94
|
-
if not identity then return nil, identityFailure end
|
|
95
|
-
local signal = {
|
|
96
|
-
schema = "lycheedev.signal.v1", release = ns.Release, kind = "reported",
|
|
97
|
-
sessionNonce = identity.sessionNonce, requestId = requestId,
|
|
98
|
-
character = identity.character, realm = identity.realm, sequence = identity.sequence,
|
|
99
|
-
product = ns.Startup.identity.product, build = ns.Startup.identity.build,
|
|
100
|
-
inputReady = false, reportBytes = #body,
|
|
101
|
-
reportAdler32 = ns.CaptureWriter.DigestBytes(body),
|
|
102
|
-
}
|
|
103
|
-
if #code > 0 then
|
|
104
|
-
signal.codeBytes = #code
|
|
105
|
-
signal.codeAdler32 = ns.CaptureWriter.DigestBytes(code)
|
|
106
|
-
end
|
|
107
|
-
local receipt, encodeFailure = ns.CaptureWriter.EncodeSignal(signal, 4096)
|
|
108
|
-
if not receipt then return nil, encodeFailure end
|
|
109
|
-
local count, bytes = 0, #receipt + #body
|
|
110
|
-
if reservation and reservation.root==state and reservation.requestId~=requestId then
|
|
111
|
-
count,bytes=1,bytes+8192
|
|
112
|
-
end
|
|
113
|
-
for key, record in pairs(state.reports) do
|
|
114
|
-
count = count + 1
|
|
115
|
-
if count >= MAX_RECORDS then return nil, "report_count_limit" end
|
|
116
|
-
if not requestKey(key) or not plain(record) or restricted(record.receipt)
|
|
117
|
-
or restricted(record.body) or type(record.receipt) ~= "string"
|
|
118
|
-
or type(record.body) ~= "string" then return nil, "report_invalid_store" end
|
|
119
|
-
if #record.receipt == 0 or #record.receipt > 4096 or #record.body == 0
|
|
120
|
-
or #record.body > 512 * 1024 then return nil, "report_invalid_store" end
|
|
121
|
-
for field in pairs(record) do
|
|
122
|
-
if restricted(field) or (field ~= "receipt" and field ~= "body") then
|
|
123
|
-
return nil, "report_invalid_store"
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
bytes = bytes + #record.receipt + #record.body
|
|
127
|
-
if bytes > MAX_BYTES then return nil, "report_store_limit" end
|
|
128
|
-
end
|
|
129
|
-
if bytes > MAX_BYTES then return nil, "report_store_limit" end
|
|
130
|
-
-- No pruning or replacement of unacknowledged reports. One final write
|
|
131
|
-
-- makes failures leave the previous store intact. Disk flush is separate.
|
|
132
|
-
state.reports[requestId] = { receipt = receipt, body = body }
|
|
133
|
-
if reservation and reservation.root==state and reservation.requestId==requestId then reservation=nil end
|
|
134
|
-
return receipt
|
|
135
|
-
end,
|
|
136
|
-
Read = function(requestId)
|
|
137
|
-
if not requestKey(requestId) then return nil, "report_invalid_request" end
|
|
138
|
-
local state, failure = ns.Persistence.Bridge()
|
|
139
|
-
if not state then return nil, failure end
|
|
140
|
-
if not plain(state.reports) then return nil, "report_invalid_store" end
|
|
141
|
-
local record = state.reports[requestId]
|
|
142
|
-
if not restricted(record) and record == nil then return nil, "report_unavailable" end
|
|
143
|
-
if not plain(record) or restricted(record.receipt) or restricted(record.body)
|
|
144
|
-
or type(record.receipt) ~= "string" or type(record.body) ~= "string" then
|
|
145
|
-
return nil, "report_invalid_store"
|
|
146
|
-
end
|
|
147
|
-
return record.receipt, record.body
|
|
148
|
-
end,
|
|
149
|
-
Acknowledge = function(reported)
|
|
150
|
-
local state, failure = ns.Persistence.Bridge()
|
|
151
|
-
if not state then return nil, failure end
|
|
152
|
-
if not ns.Startup.ready or not ns.Persistence.BridgeEnabled() then
|
|
153
|
-
return nil, "bridge_disabled"
|
|
154
|
-
end
|
|
155
|
-
if not plain(reported) then return nil, "report_invalid_acknowledgement" end
|
|
156
|
-
local requestId, bodyBytes, bodyAdler32 = reported.requestId, reported.reportBytes, reported.reportAdler32
|
|
157
|
-
if not requestKey(requestId) or reported.schema ~= "lycheedev.signal.v1" or reported.kind ~= "reported" then
|
|
158
|
-
return nil, "report_invalid_acknowledgement"
|
|
159
|
-
end
|
|
160
|
-
-- Encoding runs before the numeric shape checks: it rejects restricted
|
|
161
|
-
-- values, metatables and cycles, so a secret field reports that it is
|
|
162
|
-
-- secret instead of failing a type comparison it can never satisfy.
|
|
163
|
-
local receipt, encodeFailure = ns.CaptureWriter.EncodeSignal(reported, 4096)
|
|
164
|
-
if not receipt then return nil, encodeFailure end
|
|
165
|
-
if type(reported.sequence) ~= "number" or reported.sequence < 1 or reported.sequence > 9007199254740991
|
|
166
|
-
or reported.sequence % 1 ~= 0 or type(bodyBytes) ~= "number" or bodyBytes < 1 or bodyBytes > 512 * 1024
|
|
167
|
-
or bodyBytes % 1 ~= 0 or type(bodyAdler32) ~= "string" or #bodyAdler32 ~= 8
|
|
168
|
-
or not string.match(bodyAdler32, "^[0-9a-f]+$") then
|
|
169
|
-
return nil, "report_invalid_acknowledgement"
|
|
170
|
-
end
|
|
171
|
-
local session, sessionFailure = ns.Session.Current()
|
|
172
|
-
if not session then return nil, sessionFailure end
|
|
173
|
-
-- The live session is authoritative for the actor and the nonce. The
|
|
174
|
-
-- compact wire form still carries both while a caller can supply them,
|
|
175
|
-
-- so an acknowledgement that contradicts the current session is refused
|
|
176
|
-
-- rather than canonicalized into agreement. The host echoes the fields it
|
|
177
|
-
-- archived, and the archived receipt is the compact form, so a caller
|
|
178
|
-
-- that omits them is consistent and still passes.
|
|
179
|
-
if reported.sessionNonce ~= nil and reported.sessionNonce ~= session.sessionNonce
|
|
180
|
-
or reported.character ~= nil and reported.character ~= session.character
|
|
181
|
-
or reported.realm ~= nil and reported.realm ~= session.realm
|
|
182
|
-
or reported.release ~= nil and reported.release ~= ns.Release
|
|
183
|
-
or reported.product ~= nil and reported.product ~= ns.Startup.identity.product
|
|
184
|
-
or reported.build ~= nil and reported.build ~= ns.Startup.identity.build then
|
|
185
|
-
return nil, "report_acknowledgement_identity"
|
|
186
|
-
end
|
|
187
|
-
-- The stored receipt is the canonical wire form. A caller echoes the
|
|
188
|
-
-- fields the host archived, so both sides are projected the same way and
|
|
189
|
-
-- the session nonce, which the wire omits, never has to be restated.
|
|
190
|
-
local receipt, encodeFailure = ns.CaptureWriter.EncodeSignal(reported, 4096)
|
|
191
|
-
if not receipt then return nil, encodeFailure end
|
|
192
|
-
local storedReceipt, body = ns.ReportStore.Read(requestId)
|
|
193
|
-
if not storedReceipt then return nil, body end
|
|
194
|
-
if storedReceipt ~= receipt or #body ~= bodyBytes
|
|
195
|
-
or ns.CaptureWriter.DigestBytes(body) ~= bodyAdler32 then
|
|
196
|
-
return nil, "report_acknowledgement_mismatch"
|
|
197
|
-
end
|
|
198
|
-
if ns.ProbeRunner and ns.ProbeRunner.ResourcesReleased then
|
|
199
|
-
local released, reason = ns.ProbeRunner.ResourcesReleased(requestId)
|
|
200
|
-
if not released then return nil, reason end
|
|
201
|
-
end
|
|
202
|
-
-- After a reload the private counter starts again. A validated original
|
|
203
|
-
-- receipt provides a floor, never an arbitrary caller-supplied sequence.
|
|
204
|
-
local identity, identityFailure = ns.Session.NextIdentity(reported.sequence)
|
|
205
|
-
if not identity then return nil, identityFailure end
|
|
206
|
-
local signal = {}
|
|
207
|
-
for key, value in pairs(reported) do signal[key] = value end
|
|
208
|
-
signal.kind, signal.sequence, signal.inputReady = "acknowledged", identity.sequence, false
|
|
209
|
-
local acknowledgement, signalFailure = ns.CaptureWriter.EncodeSignal(signal, 2048)
|
|
210
|
-
if not acknowledgement then return nil, signalFailure end
|
|
211
|
-
if ns.Investigation and ns.Investigation.Tracked(requestId) then
|
|
212
|
-
local retained,reason=ns.Investigation.Mark(requestId,"acknowledged",acknowledgement)
|
|
213
|
-
if not retained then return nil,reason end
|
|
214
|
-
end
|
|
215
|
-
-- Prepare the bounded optical receipt before deletion. The executor must
|
|
216
|
-
-- have archived and verified the full original report before this call.
|
|
217
|
-
-- This proves only in-memory cleanup, not a SavedVariables disk flush.
|
|
218
|
-
state.reports[requestId] = nil
|
|
219
|
-
-- One bounded runtime-only handoff, never inherited across reload/login.
|
|
220
|
-
lastAcknowledgement = { root=state, requestId=requestId, receipt=acknowledgement, signal=signal, reportSequence=reported.sequence,
|
|
221
|
-
sessionNonce=session.sessionNonce, guid=session.guid, generation=session.generation }
|
|
222
|
-
return acknowledgement
|
|
223
|
-
end,
|
|
224
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
local binding
|
|
4
|
-
local boundRoot
|
|
5
|
-
local boundOptionsRoot
|
|
6
|
-
local generation = 0
|
|
7
|
-
local runtimeEpoch, epochRoot
|
|
8
|
-
local pendingInput
|
|
9
|
-
local focusEvent = "ChatFrame.OnEditBoxFocusLost"
|
|
10
|
-
local function cancelInput()
|
|
11
|
-
local pending = pendingInput
|
|
12
|
-
pendingInput = nil
|
|
13
|
-
if pending then pending.registry:UnregisterCallback(focusEvent, pending) end
|
|
14
|
-
end
|
|
15
|
-
local function context()
|
|
16
|
-
local state, failure = ns.Persistence.Bridge()
|
|
17
|
-
if not state then return nil, failure end
|
|
18
|
-
if not ns.Startup.ready or not ns.Persistence.BridgeEnabled() then
|
|
19
|
-
return nil, "bridge_disabled"
|
|
20
|
-
end
|
|
21
|
-
local actor, reason = ns.Platform.ObserveActor()
|
|
22
|
-
return actor, reason, state
|
|
23
|
-
end
|
|
24
|
-
local function copy(value)
|
|
25
|
-
return { sessionNonce = value.sessionNonce, character = value.character,
|
|
26
|
-
realm = value.realm, guid = value.guid, sequence = value.sequence, generation = value.generation,
|
|
27
|
-
runtimeEpoch = value.runtimeEpoch }
|
|
28
|
-
end
|
|
29
|
-
local function current()
|
|
30
|
-
local actor, failure, state = context()
|
|
31
|
-
if not actor then cancelInput(); binding, boundRoot = nil, nil; return nil, failure end
|
|
32
|
-
if not binding then return nil, "session_unbound" end
|
|
33
|
-
-- Retain only root identity for invalidation, never read settings through it.
|
|
34
|
-
if state ~= boundRoot or ns.Persistence.Current() ~= boundOptionsRoot then
|
|
35
|
-
cancelInput(); binding, boundRoot = nil, nil; return nil, "session_state_changed"
|
|
36
|
-
end
|
|
37
|
-
if (issecretvalue and issecretvalue(state.runtimeEpoch)) or state.runtimeEpoch ~= runtimeEpoch then
|
|
38
|
-
cancelInput(); binding, boundRoot = nil, nil; return nil, "session_epoch_changed"
|
|
39
|
-
end
|
|
40
|
-
if actor.character ~= binding.character or actor.realm ~= binding.realm or actor.guid ~= binding.guid then
|
|
41
|
-
cancelInput()
|
|
42
|
-
binding, boundRoot = nil, nil
|
|
43
|
-
return nil, "session_actor_changed"
|
|
44
|
-
end
|
|
45
|
-
return copy(binding)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
ns.Session = {
|
|
49
|
-
Current = current,
|
|
50
|
-
CancelInputWait = cancelInput,
|
|
51
|
-
Connect = function()
|
|
52
|
-
local active = current()
|
|
53
|
-
if active then return active end
|
|
54
|
-
local actor, failure = context()
|
|
55
|
-
if not actor then return nil, failure end
|
|
56
|
-
if generation >= 9007199254740991 then return nil, "session_generation_exhausted" end
|
|
57
|
-
-- A visible correlation marker, not a password or input permission.
|
|
58
|
-
-- A counter prevents reuse in this runtime without reseeding WoW's RNG;
|
|
59
|
-
-- native process identity and actor checks distinguish other runtimes.
|
|
60
|
-
local nextGeneration = generation + 1
|
|
61
|
-
local nonce = string.format("%04x%04x%04x%04x%08x%08x",
|
|
62
|
-
math.random(0, 65535), math.random(0, 65535),
|
|
63
|
-
math.random(0, 65535), math.random(0, 65535),
|
|
64
|
-
math.floor(nextGeneration / 4294967296), nextGeneration % 4294967296)
|
|
65
|
-
return ns.Session.Bind(nonce)
|
|
66
|
-
end,
|
|
67
|
-
ReadyReceipt = function()
|
|
68
|
-
local active, failure = current()
|
|
69
|
-
if not active then return nil, failure end
|
|
70
|
-
local eligible = false
|
|
71
|
-
if type(ns.Platform.ObserveInputState) == "function" then
|
|
72
|
-
eligible = ns.Platform.ObserveInputState() == true
|
|
73
|
-
end
|
|
74
|
-
local identity, identityFailure = ns.Session.NextIdentity()
|
|
75
|
-
if not identity then return nil, identityFailure end
|
|
76
|
-
return ns.CaptureWriter.EncodeSignal({
|
|
77
|
-
schema = "lycheedev.signal.v1", release = ns.Release, kind = "ready",
|
|
78
|
-
sessionNonce = identity.sessionNonce, requestId = "",
|
|
79
|
-
character = identity.character, realm = identity.realm, guid = identity.guid,
|
|
80
|
-
product = ns.Startup.identity.product, build = ns.Startup.identity.build,
|
|
81
|
-
sequence = identity.sequence, inputReady = eligible,
|
|
82
|
-
runtimeEpoch = identity.runtimeEpoch,
|
|
83
|
-
reportScope = "character-v1",
|
|
84
|
-
}, 4096)
|
|
85
|
-
end,
|
|
86
|
-
-- One request-scoped callback, never a timer or permanent focus listener.
|
|
87
|
-
-- A focus event only prompts a fresh observation; it is not itself proof.
|
|
88
|
-
WhenInputReady = function(callback)
|
|
89
|
-
if type(callback) ~= "function" then return nil, "input_invalid_callback" end
|
|
90
|
-
local active, failure = current()
|
|
91
|
-
if not active then return nil, failure end
|
|
92
|
-
if pendingInput then return nil, "input_wait_busy" end
|
|
93
|
-
if type(ns.Platform.ObserveInputState) ~= "function" then return nil, "input_observation_unavailable" end
|
|
94
|
-
local ready, reason = ns.Platform.ObserveInputState()
|
|
95
|
-
if ready then callback(true); return true end
|
|
96
|
-
if reason ~= "input_keyboard_focus" then return nil, reason end
|
|
97
|
-
if type(EventRegistry) ~= "table" or type(EventRegistry.RegisterCallback) ~= "function"
|
|
98
|
-
or type(EventRegistry.UnregisterCallback) ~= "function" then
|
|
99
|
-
return nil, "input_events_unavailable"
|
|
100
|
-
end
|
|
101
|
-
local pending = { registry = EventRegistry, generation = active.generation }
|
|
102
|
-
pendingInput = pending
|
|
103
|
-
pending.registry:RegisterCallback(focusEvent, function()
|
|
104
|
-
if pendingInput ~= pending then return end
|
|
105
|
-
cancelInput()
|
|
106
|
-
local now, sessionFailure = current()
|
|
107
|
-
if not now or now.generation ~= pending.generation then
|
|
108
|
-
callback(false, sessionFailure or "input_session_changed")
|
|
109
|
-
return
|
|
110
|
-
end
|
|
111
|
-
local eligible, observeFailure = ns.Platform.ObserveInputState()
|
|
112
|
-
callback(eligible == true, observeFailure)
|
|
113
|
-
end, pending)
|
|
114
|
-
return true
|
|
115
|
-
end,
|
|
116
|
-
NextIdentity = function(afterSequence)
|
|
117
|
-
local active, failure = current()
|
|
118
|
-
if not active then return nil, failure end
|
|
119
|
-
if (issecretvalue and issecretvalue(afterSequence)) then return nil, "session_invalid_sequence" end
|
|
120
|
-
if afterSequence == nil then afterSequence = 0 end
|
|
121
|
-
if type(afterSequence) ~= "number" or afterSequence < 0 or afterSequence > 9007199254740991
|
|
122
|
-
or afterSequence % 1 ~= 0 then return nil, "session_invalid_sequence" end
|
|
123
|
-
local previous = math.max(binding.sequence, afterSequence)
|
|
124
|
-
if previous >= 9007199254740991 then return nil, "session_sequence_exhausted" end
|
|
125
|
-
binding.sequence = previous + 1
|
|
126
|
-
return copy(binding)
|
|
127
|
-
end,
|
|
128
|
-
Bind = function(nonce)
|
|
129
|
-
if (issecretvalue and issecretvalue(nonce)) or type(nonce) ~= "string"
|
|
130
|
-
or #nonce ~= 32 or not string.match(nonce, "^[0-9a-f]+$") then
|
|
131
|
-
return nil, "session_invalid_nonce"
|
|
132
|
-
end
|
|
133
|
-
local actor, failure, state = context()
|
|
134
|
-
if not actor then cancelInput(); binding, boundRoot = nil, nil; return nil, failure end
|
|
135
|
-
local previousEpoch = state.runtimeEpoch
|
|
136
|
-
if previousEpoch == nil then previousEpoch = 0 end
|
|
137
|
-
if (issecretvalue and issecretvalue(previousEpoch)) or type(previousEpoch) ~= "number"
|
|
138
|
-
or previousEpoch < 0 or previousEpoch % 1 ~= 0 or previousEpoch >= 9007199254740991 then
|
|
139
|
-
return nil, "session_invalid_epoch"
|
|
140
|
-
end
|
|
141
|
-
-- Allocate once per Lua runtime, only after opt-in and actor validation.
|
|
142
|
-
-- Persist a monotonic marker, never the binding nonce or input permission.
|
|
143
|
-
-- A profile re-root must not silently reuse another root's epoch.
|
|
144
|
-
if state == epochRoot and previousEpoch ~= runtimeEpoch then return nil, "session_epoch_changed" end
|
|
145
|
-
if binding and state == boundRoot and actor.character == binding.character and actor.realm == binding.realm and actor.guid == binding.guid then
|
|
146
|
-
if binding.sessionNonce ~= nonce then return nil, "session_busy" end
|
|
147
|
-
return copy(binding)
|
|
148
|
-
end
|
|
149
|
-
if generation >= 9007199254740991 then return nil, "session_generation_exhausted" end
|
|
150
|
-
if state ~= epochRoot then
|
|
151
|
-
local last = math.max(previousEpoch, runtimeEpoch or 0)
|
|
152
|
-
if last >= 9007199254740991 then return nil, "session_invalid_epoch" end
|
|
153
|
-
runtimeEpoch = last + 1
|
|
154
|
-
state.runtimeEpoch = runtimeEpoch
|
|
155
|
-
epochRoot = state
|
|
156
|
-
end
|
|
157
|
-
cancelInput()
|
|
158
|
-
generation = generation + 1
|
|
159
|
-
binding = { sessionNonce = nonce, character = actor.character, realm = actor.realm, guid = actor.guid, sequence = 0, generation = generation, runtimeEpoch = runtimeEpoch }
|
|
160
|
-
boundRoot = state
|
|
161
|
-
boundOptionsRoot = ns.Persistence.Current()
|
|
162
|
-
if ns.ActivityView and ns.Investigation then
|
|
163
|
-
local pending = ns.Investigation.ActivityRequest()
|
|
164
|
-
if pending then ns.ActivityView.Begin(pending) end
|
|
165
|
-
end
|
|
166
|
-
return copy(binding)
|
|
167
|
-
end,
|
|
168
|
-
Release = function()
|
|
169
|
-
cancelInput()
|
|
170
|
-
if ns.ActivityView then ns.ActivityView.Stop() end
|
|
171
|
-
binding, boundRoot = nil, nil
|
|
172
|
-
end,
|
|
173
|
-
}
|