ocremote 1.3.3 → 1.3.4
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/lib/relay.mjs +9 -3
- package/oc-remote.mjs +1 -1
- package/package.json +1 -1
package/lib/relay.mjs
CHANGED
|
@@ -33,7 +33,7 @@ export class RelayClient {
|
|
|
33
33
|
this.identity = identity
|
|
34
34
|
this.adapter = adapter
|
|
35
35
|
this.logger = logger
|
|
36
|
-
this.invites = invites
|
|
36
|
+
this.invites = invites ?? new Map()
|
|
37
37
|
this.onEvent = onEvent || (() => {})
|
|
38
38
|
this.ws = null
|
|
39
39
|
this.sessions = new Map()
|
|
@@ -133,13 +133,19 @@ export class RelayClient {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
async createInvite() {
|
|
136
|
+
const now = Date.now()
|
|
136
137
|
const invite = {
|
|
137
138
|
pairID: `p_${randomBytes(6).toString('hex')}`,
|
|
138
139
|
secret: randomBytes(32),
|
|
139
|
-
createdAt:
|
|
140
|
-
expiresAt:
|
|
140
|
+
createdAt: now,
|
|
141
|
+
expiresAt: now + 15 * 60_000,
|
|
141
142
|
}
|
|
142
143
|
this.invites.set(invite.pairID, invite)
|
|
144
|
+
// Keep the previous invite until it really expires: a QR already on screen
|
|
145
|
+
// must stay valid even if a refresh just happened.
|
|
146
|
+
for (const [id, previous] of [...this.invites]) {
|
|
147
|
+
if (previous.expiresAt <= now) this.invites.delete(id)
|
|
148
|
+
}
|
|
143
149
|
if (this.ws && this.ws.readyState === 1) {
|
|
144
150
|
try {
|
|
145
151
|
await this.registerInvite(invite)
|
package/oc-remote.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { b64 } from './lib/crypto.mjs'
|
|
|
17
17
|
|
|
18
18
|
const require = createRequire(import.meta.url)
|
|
19
19
|
const NAME = 'oc-remote'
|
|
20
|
-
const VERSION = '1.3.
|
|
20
|
+
const VERSION = '1.3.4'
|
|
21
21
|
const LAUNCH_LABEL = 'com.raul.ocremote'
|
|
22
22
|
const LOG_PATH =
|
|
23
23
|
process.platform === 'darwin'
|