@atproto/pds 0.4.39 → 0.4.41
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +25 -0
- package/dist/account-manager/index.d.ts +3 -4
- package/dist/account-manager/index.d.ts.map +1 -1
- package/dist/account-manager/index.js +2 -3
- package/dist/account-manager/index.js.map +1 -1
- package/dist/auth-verifier.d.ts.map +1 -1
- package/dist/auth-verifier.js +11 -9
- package/dist/auth-verifier.js.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +2 -1
- package/dist/config/config.js.map +1 -1
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +2 -1
- package/dist/config/env.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +5 -0
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +9 -0
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/embed/record.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/embed/record.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/embed/record.js.map +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestionsSkeleton.d.ts +2 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestionsSkeleton.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +2 -2
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.js.map +1 -1
- package/dist/logger.d.ts +3 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +9 -76
- package/dist/logger.js.map +1 -1
- package/dist/oauth/detailed-account-store.d.ts +2 -2
- package/dist/oauth/detailed-account-store.d.ts.map +1 -1
- package/dist/oauth/detailed-account-store.js.map +1 -1
- package/package.json +9 -9
- package/src/account-manager/index.ts +4 -5
- package/src/auth-verifier.ts +18 -9
- package/src/config/config.ts +2 -1
- package/src/config/env.ts +4 -2
- package/src/lexicon/lexicons.ts +10 -0
- package/src/lexicon/types/app/bsky/actor/defs.ts +1 -0
- package/src/lexicon/types/app/bsky/embed/record.ts +1 -0
- package/src/lexicon/types/app/bsky/unspecced/getSuggestionsSkeleton.ts +2 -0
- package/src/lexicon/types/tools/ozone/moderation/defs.ts +2 -0
- package/src/logger.ts +11 -81
- package/src/oauth/detailed-account-store.ts +2 -2
package/src/lexicon/lexicons.ts
CHANGED
@@ -4167,6 +4167,7 @@ export const schemaDict = {
|
|
4167
4167
|
'lex:app.bsky.actor.defs#mutedWordsPref',
|
4168
4168
|
'lex:app.bsky.actor.defs#hiddenPostsPref',
|
4169
4169
|
'lex:app.bsky.actor.defs#bskyAppStatePref',
|
4170
|
+
'lex:app.bsky.actor.defs#labelersPref',
|
4170
4171
|
],
|
4171
4172
|
},
|
4172
4173
|
},
|
@@ -4957,6 +4958,7 @@ export const schemaDict = {
|
|
4957
4958
|
'lex:app.bsky.feed.defs#generatorView',
|
4958
4959
|
'lex:app.bsky.graph.defs#listView',
|
4959
4960
|
'lex:app.bsky.labeler.defs#labelerView',
|
4961
|
+
'lex:app.bsky.graph.defs#starterPackViewBasic',
|
4960
4962
|
],
|
4961
4963
|
},
|
4962
4964
|
},
|
@@ -8710,6 +8712,12 @@ export const schemaDict = {
|
|
8710
8712
|
cursor: {
|
8711
8713
|
type: 'string',
|
8712
8714
|
},
|
8715
|
+
relativeToDid: {
|
8716
|
+
type: 'string',
|
8717
|
+
format: 'did',
|
8718
|
+
description:
|
8719
|
+
'DID of the account to get suggestions relative to. If not provided, suggestions will be based on the viewer.',
|
8720
|
+
},
|
8713
8721
|
},
|
8714
8722
|
},
|
8715
8723
|
output: {
|
@@ -10112,6 +10120,7 @@ export const schemaDict = {
|
|
10112
10120
|
'lex:tools.ozone.moderation.defs#modEventEmail',
|
10113
10121
|
'lex:tools.ozone.moderation.defs#modEventResolveAppeal',
|
10114
10122
|
'lex:tools.ozone.moderation.defs#modEventDivert',
|
10123
|
+
'lex:tools.ozone.moderation.defs#modEventTag',
|
10115
10124
|
],
|
10116
10125
|
},
|
10117
10126
|
subject: {
|
@@ -10175,6 +10184,7 @@ export const schemaDict = {
|
|
10175
10184
|
'lex:tools.ozone.moderation.defs#modEventEmail',
|
10176
10185
|
'lex:tools.ozone.moderation.defs#modEventResolveAppeal',
|
10177
10186
|
'lex:tools.ozone.moderation.defs#modEventDivert',
|
10187
|
+
'lex:tools.ozone.moderation.defs#modEventTag',
|
10178
10188
|
],
|
10179
10189
|
},
|
10180
10190
|
subject: {
|
@@ -14,6 +14,8 @@ export interface QueryParams {
|
|
14
14
|
viewer?: string
|
15
15
|
limit: number
|
16
16
|
cursor?: string
|
17
|
+
/** DID of the account to get suggestions relative to. If not provided, suggestions will be based on the viewer. */
|
18
|
+
relativeToDid?: string
|
17
19
|
}
|
18
20
|
|
19
21
|
export type InputSchema = undefined
|
@@ -29,6 +29,7 @@ export interface ModEventView {
|
|
29
29
|
| ModEventEmail
|
30
30
|
| ModEventResolveAppeal
|
31
31
|
| ModEventDivert
|
32
|
+
| ModEventTag
|
32
33
|
| { $type: string; [k: string]: unknown }
|
33
34
|
subject:
|
34
35
|
| ComAtprotoAdminDefs.RepoRef
|
@@ -72,6 +73,7 @@ export interface ModEventViewDetail {
|
|
72
73
|
| ModEventEmail
|
73
74
|
| ModEventResolveAppeal
|
74
75
|
| ModEventDivert
|
76
|
+
| ModEventTag
|
75
77
|
| { $type: string; [k: string]: unknown }
|
76
78
|
subject:
|
77
79
|
| RepoView
|
package/src/logger.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
import { type IncomingMessage } from 'node:http'
|
1
2
|
import { stdSerializers } from 'pino'
|
2
3
|
import pinoHttp from 'pino-http'
|
3
|
-
import { subsystemLogger } from '@atproto/common'
|
4
|
+
import { obfuscateHeaders, subsystemLogger } from '@atproto/common'
|
4
5
|
|
5
6
|
export const dbLogger = subsystemLogger('pds:db')
|
6
7
|
export const didCacheLogger = subsystemLogger('pds:did-cache')
|
@@ -17,85 +18,14 @@ export const oauthLogger = subsystemLogger('pds:oauth')
|
|
17
18
|
export const loggerMiddleware = pinoHttp({
|
18
19
|
logger: httpLogger,
|
19
20
|
serializers: {
|
20
|
-
err:
|
21
|
-
|
21
|
+
err: (err: unknown) => ({
|
22
|
+
code: err?.['code'],
|
23
|
+
message: err?.['message'],
|
24
|
+
}),
|
25
|
+
req: (req: IncomingMessage) => {
|
26
|
+
const serialized = stdSerializers.req(req)
|
27
|
+
const headers = obfuscateHeaders(serialized.headers)
|
28
|
+
return { ...serialized, headers }
|
29
|
+
},
|
22
30
|
},
|
23
31
|
})
|
24
|
-
|
25
|
-
function errSerializer(err: any) {
|
26
|
-
return {
|
27
|
-
code: err?.code,
|
28
|
-
message: err?.message,
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
function reqSerializer(req: any) {
|
33
|
-
const serialized = stdSerializers.req(req)
|
34
|
-
serialized.headers = obfuscateHeaders(serialized.headers)
|
35
|
-
return serialized
|
36
|
-
}
|
37
|
-
|
38
|
-
function obfuscateHeaders(headers: Record<string, string>) {
|
39
|
-
const obfuscatedHeaders: Record<string, string> = {}
|
40
|
-
for (const key in headers) {
|
41
|
-
if (key.toLowerCase() === 'authorization') {
|
42
|
-
obfuscatedHeaders[key] = obfuscateAuthHeader(headers[key])
|
43
|
-
} else if (key.toLowerCase() === 'dpop') {
|
44
|
-
obfuscatedHeaders[key] = obfuscateJws(headers[key]) || 'Invalid'
|
45
|
-
} else {
|
46
|
-
obfuscatedHeaders[key] = headers[key]
|
47
|
-
}
|
48
|
-
}
|
49
|
-
return obfuscatedHeaders
|
50
|
-
}
|
51
|
-
|
52
|
-
function obfuscateAuthHeader(authHeader: string): string {
|
53
|
-
// This is a hot path (runs on every request). Avoid using split() or regex.
|
54
|
-
|
55
|
-
const spaceIdx = authHeader.indexOf(' ')
|
56
|
-
if (spaceIdx === -1) return 'Invalid'
|
57
|
-
|
58
|
-
const type = authHeader.slice(0, spaceIdx)
|
59
|
-
switch (type.toLowerCase()) {
|
60
|
-
case 'bearer':
|
61
|
-
return `${type} ${obfuscateBearer(authHeader.slice(spaceIdx + 1))}`
|
62
|
-
case 'dpop':
|
63
|
-
return `${type} ${obfuscateJws(authHeader.slice(spaceIdx + 1)) || 'Invalid'}`
|
64
|
-
case 'basic':
|
65
|
-
return `${type} ${obfuscateBasic(authHeader.slice(spaceIdx + 1)) || 'Invalid'}`
|
66
|
-
default:
|
67
|
-
return `Invalid`
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
function obfuscateBasic(token: string): null | string {
|
72
|
-
if (!token) return null
|
73
|
-
const buffer = Buffer.from(token, 'base64')
|
74
|
-
if (!buffer.length) return null // Buffer.from will silently ignore invalid base64 chars
|
75
|
-
const authHeader = buffer.toString('utf8')
|
76
|
-
const colIdx = authHeader.indexOf(':')
|
77
|
-
if (colIdx === -1) return null
|
78
|
-
const username = authHeader.slice(0, colIdx)
|
79
|
-
return `${username}:***`
|
80
|
-
}
|
81
|
-
|
82
|
-
function obfuscateBearer(token: string): string {
|
83
|
-
return obfuscateJws(token) || obfuscateToken(token)
|
84
|
-
}
|
85
|
-
|
86
|
-
function obfuscateToken(token: string): string {
|
87
|
-
return token ? '***' : ''
|
88
|
-
}
|
89
|
-
|
90
|
-
function obfuscateJws(token: string): null | string {
|
91
|
-
const firstDot = token.indexOf('.')
|
92
|
-
if (firstDot === -1) return null
|
93
|
-
|
94
|
-
const secondDot = token.indexOf('.', firstDot + 1)
|
95
|
-
if (secondDot === -1) return null
|
96
|
-
|
97
|
-
if (token.indexOf('.', secondDot + 1) !== -1) return null
|
98
|
-
|
99
|
-
// Strip the signature
|
100
|
-
return token.slice(0, secondDot) + '.obfuscated'
|
101
|
-
}
|
@@ -2,7 +2,7 @@ import {
|
|
2
2
|
AccountInfo,
|
3
3
|
AccountStore,
|
4
4
|
DeviceId,
|
5
|
-
|
5
|
+
SignInCredentials,
|
6
6
|
} from '@atproto/oauth-provider'
|
7
7
|
|
8
8
|
import { AccountManager } from '../account-manager/index'
|
@@ -50,7 +50,7 @@ export class DetailedAccountStore implements AccountStore {
|
|
50
50
|
}
|
51
51
|
|
52
52
|
async authenticateAccount(
|
53
|
-
credentials:
|
53
|
+
credentials: SignInCredentials,
|
54
54
|
deviceId: DeviceId,
|
55
55
|
): Promise<AccountInfo | null> {
|
56
56
|
const accountInfo = await this.accountManager.authenticateAccount(
|