@meith/subscriptions 0.21.2 → 0.23.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meith/subscriptions",
3
- "version": "0.21.2",
3
+ "version": "0.23.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@meith/core": "0.21.2",
23
- "@meith/i18n": "0.21.2"
22
+ "@meith/core": "0.23.0",
23
+ "@meith/i18n": "0.23.0"
24
24
  }
25
25
  }
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ export {
27
27
  mintUnsubscribeToken,
28
28
  readUnsubscribeToken,
29
29
  type UnsubscribeClaim,
30
+ type UnsubscribeScope,
30
31
  } from './tokens'
31
32
  export type {
32
33
  PendingForUser,
package/src/notifier.ts CHANGED
@@ -174,9 +174,7 @@ export class SubscriptionNotifier {
174
174
  watermarks: pending.watermarks,
175
175
  })
176
176
  }
177
- } catch {
178
- /* ignore */
179
- }
177
+ } catch {}
180
178
  }
181
179
 
182
180
  return { notified, considered }
package/src/tokens.ts CHANGED
@@ -4,10 +4,12 @@ import { timingSafeEqualString } from '@meith/core'
4
4
 
5
5
  import type { SubscriptionTarget } from './modes'
6
6
 
7
- export type UnsubscribeScope = SubscriptionTarget | 'email'
7
+ export type UnsubscribeScope = SubscriptionTarget | 'email' | 'mass-mail'
8
8
 
9
9
  export function parseUnsubscribeScope(value: string): UnsubscribeScope | null {
10
- return value === 'thread' || value === 'forum' || value === 'email' ? value : null
10
+ return value === 'thread' || value === 'forum' || value === 'email' || value === 'mass-mail'
11
+ ? value
12
+ : null
11
13
  }
12
14
 
13
15
  export interface UnsubscribeClaim {
@@ -48,7 +50,7 @@ export function readUnsubscribeToken(token: string, secret: string): Unsubscribe
48
50
  const scope = parseUnsubscribeScope(rawScope)
49
51
  if (scope === null) return null
50
52
 
51
- const targetPattern = scope === 'email' ? /^0$/ : /^[1-9]\d*$/
53
+ const targetPattern = scope === 'thread' || scope === 'forum' ? /^[1-9]\d*$/ : /^0$/
52
54
  if (!/^[1-9]\d*$/.test(rawUserId) || !targetPattern.test(rawTargetId)) return null
53
55
  const userId = Number(rawUserId)
54
56
  const targetId = Number(rawTargetId)