purple: switch local testing to staging testing

This commit is contained in:
William Casarin
2024-01-28 17:32:44 -08:00
parent 0c63f2ee26
commit ff6b19578e
8 changed files with 25 additions and 15 deletions

View File

@@ -43,7 +43,7 @@ func make_nip98_authenticated_request(method: HTTPMethod, url: URL, payload: Dat
createdAt: UInt32(Date().timeIntervalSince1970)
)
let auth_note_json_data: Data = try JSONEncoder().encode(auth_note)
let auth_note_json_data: Data = try encode_json_data(auth_note)
let auth_note_base64: String = base64_encode(auth_note_json_data.bytes)
request.setValue("Nostr " + auth_note_base64, forHTTPHeaderField: "Authorization")

View File

@@ -325,7 +325,13 @@ func decode_nostr_event(txt: String) -> NostrResponse? {
func encode_json<T: Encodable>(_ val: T) -> String? {
let encoder = JSONEncoder()
encoder.outputFormatting = .withoutEscapingSlashes
return (try? encoder.encode(val)).map { String(decoding: $0, as: UTF8.self) }
return (try? encode_json_data(val)).map { String(decoding: $0, as: UTF8.self) }
}
func encode_json_data<T: Encodable>(_ val: T) throws -> Data {
let encoder = JSONEncoder()
encoder.outputFormatting = .withoutEscapingSlashes
return try encoder.encode(val)
}
func decode_nostr_event_json(json: String) -> NostrEvent? {