Files
Termind/TFM/Infrastructure/Security/MCPUploadToken.swift
T
2026-09-16 19:46:35 +08:00

15 lines
521 B
Swift

import Foundation
import Security
nonisolated enum MCPUploadToken {
static func make() throws -> String {
var bytes = [UInt8](repeating: 0, count: 32)
guard SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes) == errSecSuccess else {
throw MCPUploadError.unavailable
}
return Data(bytes).base64EncodedString()
.replacingOccurrences(of: "+", with: "-").replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "=", with: "")
}
}