@live-change/secret-link-service 0.9.203 → 0.9.205

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 (2) hide show
  1. package/index.js +8 -4
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -53,7 +53,8 @@ definition.event({
53
53
  definition.event({
54
54
  name: 'linkExpired',
55
55
  execute({ link }) {
56
- return Link.update(link, { date: new Date(Date.now() - 1000) })
56
+ const past = new Date(Date.now() - 60 * 1000)
57
+ return Link.update(link, { expire: past })
57
58
  }
58
59
  })
59
60
 
@@ -92,9 +93,12 @@ definition.trigger({
92
93
  },
93
94
  waitForEvents: true,
94
95
  async execute({ authentication }, context, emit) {
95
- const currentLink = await Link.indexObjectGet('byAuthentication', authentication)
96
- if(currentLink) {
97
- emit({ type: 'linkExpired', link: currentLink.id })
96
+ const rows = await Link.indexRangeGet('byAuthentication', authentication) || []
97
+ const nowMs = Date.now()
98
+ for (const row of rows) {
99
+ if (new Date(row.expire).getTime() > nowMs) {
100
+ emit({ type: 'linkExpired', link: row.id })
101
+ }
98
102
  }
99
103
  const link = app.generateUid()
100
104
  const secretCode = randomString(config.secretCodeLength || 16)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/secret-link-service",
3
- "version": "0.9.203",
3
+ "version": "0.9.205",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.9.203",
25
+ "@live-change/framework": "^0.9.205",
26
26
  "nodemailer": "^6.7.2"
27
27
  },
28
- "gitHead": "4d4ce413fe747da2c398eb4ad378e37cc81874b3"
28
+ "gitHead": "ef195e51ea283e56d891b11da5d5f586691507db"
29
29
  }