@evanp/activitypub-bot 0.39.2 → 0.39.3

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.
@@ -160,15 +160,17 @@ export class ActivityPubClient {
160
160
  }
161
161
  this.#logger.debug({ headers }, 'Sending headers')
162
162
  const method = 'GET'
163
- this.#logger.debug({ url: baseUrl }, 'Signing GET request')
164
163
  let storedPolicy, lastPolicy
165
164
  if (sign) {
165
+ this.#logger.debug({ url: baseUrl }, 'Signing GET request')
166
166
  storedPolicy = await this.#policyStorage.get(parsed.origin)
167
167
  if (!storedPolicy || storedPolicy === SignaturePolicyStorage.RFC9421) {
168
+ this.#logger.debug({ origin: parsed.origin, storedPolicy }, 'Signing with RFC 9421')
168
169
  lastPolicy = SignaturePolicyStorage.RFC9421
169
170
  const sigHeaders = await this.#messageSign({ username, url: baseUrl, method, headers })
170
171
  Object.assign(headers, sigHeaders || {})
171
172
  } else if (storedPolicy === SignaturePolicyStorage.DRAFT_CAVAGE_12) {
173
+ this.#logger.debug({ origin: parsed.origin, storedPolicy }, 'Signing with draft-cavage-12')
172
174
  lastPolicy = SignaturePolicyStorage.DRAFT_CAVAGE_12
173
175
  headers.signature =
174
176
  await this.#sign({ username, url: baseUrl, method, headers })
@@ -190,6 +192,10 @@ export class ActivityPubClient {
190
192
  if ([401, 403].includes(res.status) &&
191
193
  sign &&
192
194
  !storedPolicy) {
195
+ const body = await res.text()
196
+ this.#logger.debug(
197
+ { url, status: res.status, body, headers: res.headers },
198
+ 'Authentication error; retrying with draft-cavage-12 signature')
193
199
  lastPolicy = SignaturePolicyStorage.DRAFT_CAVAGE_12
194
200
  delete headers['signature-input']
195
201
  headers.signature =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.39.2",
3
+ "version": "0.39.3",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",