mirror of
https://github.com/nimbold/Firelink.git
synced 2026-07-26 12:08:27 +00:00
refactor: add backward compatibility support for extension tokens
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user