refactor: add backward compatibility support for extension tokens

This commit is contained in:
nimbold
2026-06-08 05:46:24 +03:30
parent baddf0da6d
commit 72ef99d211
+11 -2
View File
@@ -8,7 +8,15 @@ final class LocalExtensionServer: @unchecked Sendable {
static let maxRequestBytes = 128 * 1024
static let maxURLCount = 200
static let extensionRequestHeader = "x-firelink-extension"
static let extensionRequestToken = "firelink-extension-v1"
// IMPORTANT(Backward Compatibility):
// Extension updates on Mozilla/Chrome stores can take several days to be approved.
// Therefore, we MUST NOT introduce breaking changes to the LocalExtensionServer API
// without maintaining backward compatibility for older extensions.
// If you need to update the API (e.g., changing the payload structure), add the new
// token here and handle both versions in `processRequest`.
static let supportedExtensionTokens = Set(["firelink-extension-v1"])
static let allowedSchemes = Set(["http", "https", "ftp", "sftp"])
}
@@ -138,7 +146,8 @@ final class LocalExtensionServer: @unchecked Sendable {
return .methodNotAllowed
}
guard request.header(named: Constants.extensionRequestHeader) == Constants.extensionRequestToken else {
guard let token = request.header(named: Constants.extensionRequestHeader),
Constants.supportedExtensionTokens.contains(token) else {
return .forbidden
}