@meith/subscriptions 0.21.2 → 0.22.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 +3 -3
- package/src/index.ts +1 -0
- package/src/notifier.ts +1 -3
- package/src/tokens.ts +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meith/subscriptions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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.
|
|
23
|
-
"@meith/i18n": "0.
|
|
22
|
+
"@meith/core": "0.22.0",
|
|
23
|
+
"@meith/i18n": "0.22.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/src/index.ts
CHANGED
package/src/notifier.ts
CHANGED
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'
|
|
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 === '
|
|
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)
|