15 lines
521 B
Swift
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: "")
|
|
}
|
|
}
|