@atproto/api 0.20.23 → 0.20.26
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/CHANGELOG.md +34 -0
- package/dist/agent.d.ts +4 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +17 -0
- package/dist/agent.js.map +1 -1
- package/dist/client/lexicons.d.ts +8 -0
- package/dist/client/lexicons.d.ts.map +1 -1
- package/dist/client/lexicons.js +4 -0
- package/dist/client/lexicons.js.map +1 -1
- package/dist/client/types/app/bsky/actor/defs.d.ts +2 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts.map +1 -1
- package/dist/client/types/app/bsky/actor/defs.js.map +1 -1
- package/dist/rich-text/detection.d.ts.map +1 -1
- package/dist/rich-text/detection.js +4 -1
- package/dist/rich-text/detection.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +22 -16
- package/definitions/labels.json +0 -170
- package/docs/moderation.md +0 -260
- package/jest.config.cjs +0 -23
- package/jest.d.ts +0 -20
- package/jest.setup.ts +0 -97
- package/scripts/code/labels.mjs +0 -77
- package/scripts/generate-code.mjs +0 -4
- package/src/age-assurance.test.ts +0 -218
- package/src/age-assurance.ts +0 -137
- package/src/agent.ts +0 -1645
- package/src/atp-agent.ts +0 -570
- package/src/bsky-agent.ts +0 -14
- package/src/const.ts +0 -1
- package/src/index.ts +0 -44
- package/src/mocker.ts +0 -220
- package/src/moderation/decision.ts +0 -389
- package/src/moderation/index.ts +0 -69
- package/src/moderation/mutewords.ts +0 -170
- package/src/moderation/subjects/account.ts +0 -44
- package/src/moderation/subjects/feed-generator.ts +0 -24
- package/src/moderation/subjects/notification.ts +0 -25
- package/src/moderation/subjects/post.ts +0 -433
- package/src/moderation/subjects/profile.ts +0 -26
- package/src/moderation/subjects/status.ts +0 -27
- package/src/moderation/subjects/user-list.ts +0 -48
- package/src/moderation/types.ts +0 -191
- package/src/moderation/ui.ts +0 -21
- package/src/moderation/util.ts +0 -111
- package/src/predicate.ts +0 -52
- package/src/rich-text/detection.ts +0 -146
- package/src/rich-text/rich-text.ts +0 -418
- package/src/rich-text/sanitization.ts +0 -42
- package/src/rich-text/unicode.ts +0 -47
- package/src/rich-text/util.ts +0 -15
- package/src/session-manager.ts +0 -5
- package/src/types.ts +0 -165
- package/src/util.ts +0 -96
- package/tests/atp-agent.test.ts +0 -3863
- package/tests/dispatcher.test.ts +0 -527
- package/tests/errors.test.ts +0 -29
- package/tests/moderation-behaviors.test.ts +0 -951
- package/tests/moderation-custom-labels.test.ts +0 -334
- package/tests/moderation-mutewords.test.ts +0 -1299
- package/tests/moderation-prefs.test.ts +0 -402
- package/tests/moderation-quoteposts.test.ts +0 -277
- package/tests/moderation.test.ts +0 -739
- package/tests/rich-text-detection.test.ts +0 -456
- package/tests/rich-text-sanitization.test.ts +0 -216
- package/tests/rich-text.test.ts +0 -705
- package/tests/util/echo-server.ts +0 -37
- package/tests/util/moderation-behavior.ts +0 -268
- package/tsconfig.build.json +0 -9
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -7
- package/tsconfig.tests.json +0 -10
package/src/age-assurance.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { AppBskyAgeassuranceDefs } from './client/index.js'
|
|
2
|
-
import { ids } from './client/lexicons.js'
|
|
3
|
-
|
|
4
|
-
export type AgeAssuranceRuleID = Exclude<
|
|
5
|
-
| AppBskyAgeassuranceDefs.ConfigRegionRuleDefault['$type']
|
|
6
|
-
| AppBskyAgeassuranceDefs.ConfigRegionRuleIfDeclaredOverAge['$type']
|
|
7
|
-
| AppBskyAgeassuranceDefs.ConfigRegionRuleIfDeclaredUnderAge['$type']
|
|
8
|
-
| AppBskyAgeassuranceDefs.ConfigRegionRuleIfAssuredOverAge['$type']
|
|
9
|
-
| AppBskyAgeassuranceDefs.ConfigRegionRuleIfAssuredUnderAge['$type']
|
|
10
|
-
| AppBskyAgeassuranceDefs.ConfigRegionRuleIfAccountNewerThan['$type']
|
|
11
|
-
| AppBskyAgeassuranceDefs.ConfigRegionRuleIfAccountOlderThan['$type'],
|
|
12
|
-
undefined
|
|
13
|
-
>
|
|
14
|
-
|
|
15
|
-
export const ageAssuranceRuleIDs: Record<string, AgeAssuranceRuleID> = {
|
|
16
|
-
Default: `${ids.AppBskyAgeassuranceDefs}#configRegionRuleDefault`,
|
|
17
|
-
IfDeclaredOverAge: `${ids.AppBskyAgeassuranceDefs}#configRegionRuleIfDeclaredOverAge`,
|
|
18
|
-
IfDeclaredUnderAge: `${ids.AppBskyAgeassuranceDefs}#configRegionRuleIfDeclaredUnderAge`,
|
|
19
|
-
IfAssuredOverAge: `${ids.AppBskyAgeassuranceDefs}#configRegionRuleIfAssuredOverAge`,
|
|
20
|
-
IfAssuredUnderAge: `${ids.AppBskyAgeassuranceDefs}#configRegionRuleIfAssuredUnderAge`,
|
|
21
|
-
IfAccountNewerThan: `${ids.AppBskyAgeassuranceDefs}#configRegionRuleIfAccountNewerThan`,
|
|
22
|
-
IfAccountOlderThan: `${ids.AppBskyAgeassuranceDefs}#configRegionRuleIfAccountOlderThan`,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Returns the first matched region configuration based on the provided geolocation.
|
|
27
|
-
*/
|
|
28
|
-
export function getAgeAssuranceRegionConfig(
|
|
29
|
-
config: AppBskyAgeassuranceDefs.Config,
|
|
30
|
-
geolocation: {
|
|
31
|
-
countryCode: string
|
|
32
|
-
regionCode?: string
|
|
33
|
-
},
|
|
34
|
-
): AppBskyAgeassuranceDefs.ConfigRegion | undefined {
|
|
35
|
-
const { regions } = config
|
|
36
|
-
return regions.find(({ countryCode, regionCode }) => {
|
|
37
|
-
if (countryCode === geolocation.countryCode) {
|
|
38
|
-
return !regionCode || regionCode === geolocation.regionCode
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function computeAgeAssuranceRegionAccess(
|
|
44
|
-
region: AppBskyAgeassuranceDefs.ConfigRegion,
|
|
45
|
-
data:
|
|
46
|
-
| {
|
|
47
|
-
/**
|
|
48
|
-
* The account creation date in ISO 8601 format. Only checked if we
|
|
49
|
-
* don't have an assured age, such as on the client.
|
|
50
|
-
*/
|
|
51
|
-
accountCreatedAt?: string
|
|
52
|
-
/**
|
|
53
|
-
* The user's declared age
|
|
54
|
-
*/
|
|
55
|
-
declaredAge?: number
|
|
56
|
-
/**
|
|
57
|
-
* The user's minimum age as assured by a trusted third party.
|
|
58
|
-
*/
|
|
59
|
-
assuredAge?: number
|
|
60
|
-
}
|
|
61
|
-
| undefined,
|
|
62
|
-
):
|
|
63
|
-
| {
|
|
64
|
-
access: AppBskyAgeassuranceDefs.Access
|
|
65
|
-
reason: AgeAssuranceRuleID
|
|
66
|
-
}
|
|
67
|
-
| undefined {
|
|
68
|
-
// first match wins
|
|
69
|
-
for (const rule of region.rules) {
|
|
70
|
-
if (AppBskyAgeassuranceDefs.isConfigRegionRuleIfAccountNewerThan(rule)) {
|
|
71
|
-
if (data?.accountCreatedAt && !data?.assuredAge) {
|
|
72
|
-
const accountCreatedAt = new Date(data.accountCreatedAt)
|
|
73
|
-
const threshold = new Date(rule.date)
|
|
74
|
-
if (accountCreatedAt >= threshold) {
|
|
75
|
-
return {
|
|
76
|
-
access: rule.access,
|
|
77
|
-
reason: rule.$type,
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} else if (
|
|
82
|
-
AppBskyAgeassuranceDefs.isConfigRegionRuleIfAccountOlderThan(rule)
|
|
83
|
-
) {
|
|
84
|
-
if (data?.accountCreatedAt && !data?.assuredAge) {
|
|
85
|
-
const accountCreatedAt = new Date(data.accountCreatedAt)
|
|
86
|
-
const threshold = new Date(rule.date)
|
|
87
|
-
if (accountCreatedAt < threshold) {
|
|
88
|
-
return {
|
|
89
|
-
access: rule.access,
|
|
90
|
-
reason: rule.$type,
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
} else if (
|
|
95
|
-
AppBskyAgeassuranceDefs.isConfigRegionRuleIfDeclaredOverAge(rule)
|
|
96
|
-
) {
|
|
97
|
-
if (data?.declaredAge !== undefined && data.declaredAge >= rule.age) {
|
|
98
|
-
return {
|
|
99
|
-
access: rule.access,
|
|
100
|
-
reason: rule.$type,
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
} else if (
|
|
104
|
-
AppBskyAgeassuranceDefs.isConfigRegionRuleIfDeclaredUnderAge(rule)
|
|
105
|
-
) {
|
|
106
|
-
if (data?.declaredAge !== undefined && data.declaredAge < rule.age) {
|
|
107
|
-
return {
|
|
108
|
-
access: rule.access,
|
|
109
|
-
reason: rule.$type,
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
} else if (
|
|
113
|
-
AppBskyAgeassuranceDefs.isConfigRegionRuleIfAssuredOverAge(rule)
|
|
114
|
-
) {
|
|
115
|
-
if (data?.assuredAge && data.assuredAge >= rule.age) {
|
|
116
|
-
return {
|
|
117
|
-
access: rule.access,
|
|
118
|
-
reason: rule.$type,
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
} else if (
|
|
122
|
-
AppBskyAgeassuranceDefs.isConfigRegionRuleIfAssuredUnderAge(rule)
|
|
123
|
-
) {
|
|
124
|
-
if (data?.assuredAge && data.assuredAge < rule.age) {
|
|
125
|
-
return {
|
|
126
|
-
access: rule.access,
|
|
127
|
-
reason: rule.$type,
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
} else if (AppBskyAgeassuranceDefs.isConfigRegionRuleDefault(rule)) {
|
|
131
|
-
return {
|
|
132
|
-
access: rule.access,
|
|
133
|
-
reason: rule.$type,
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|