diff --git a/.changeset/rare-rings-listen.md b/.changeset/rare-rings-listen.md new file mode 100644 index 0000000..da6fa3c --- /dev/null +++ b/.changeset/rare-rings-listen.md @@ -0,0 +1,5 @@ +--- +"@germ-network/atprototypes": patch +--- + +adopt swift-libp2p/swift-bases.git diff --git a/Package.resolved b/Package.resolved index feefb0b..1ef1d9d 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,22 +1,13 @@ { - "originHash" : "1b9b93255aea27c5335c39dcace2ef035821c8d239561e330fbe2d6e158f1dfd", + "originHash" : "8aec742b02f3ededabc54b75e17c53f89b7d0de27eec5cf337c068937f5bc42a", "pins" : [ - { - "identity" : "base32", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Jarema/Base32.git", - "state" : { - "revision" : "7f723a2e55f1c76e7c79263aebf89dbfcd58e77d", - "version" : "0.10.2" - } - }, { "identity" : "germconvenience", "kind" : "remoteSourceControl", "location" : "https://github.com/germ-network/GermConvenience.git", "state" : { - "revision" : "e98a7fc5301e1b1562f18180eb05bcfcdbd7632d", - "version" : "0.1.5" + "revision" : "af36c703ecbf25db5528a9c7c81fa33f04645ad7", + "version" : "0.2.1" } }, { @@ -28,6 +19,15 @@ "version" : "1.6.0" } }, + { + "identity" : "swift-bases", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swift-libp2p/swift-bases.git", + "state" : { + "revision" : "96615d4b582f9f6536d8278304ce2a64c8e5288a", + "version" : "0.2.0" + } + }, { "identity" : "swift-crypto", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index 0ca6fec..4988eec 100644 --- a/Package.swift +++ b/Package.swift @@ -16,14 +16,15 @@ let package = Package( .library(name: "Mockable", targets: ["Mockable"]), ], dependencies: [ - .package(url: "https://github.com/Jarema/Base32.git", from: "0.10.2"), + .package(url: "https://github.com/swift-libp2p/swift-bases.git", from: "0.2.0"), .package( url: "https://github.com/germ-network/GermConvenience.git", - from: "0.1.5" + from: "0.2.1" ), .package( url: "https://github.com/apple/swift-crypto.git", - .upToNextMajor(from: "4.2.0")), + .upToNextMajor(from: "4.2.0") + ), .package(url: "https://github.com/apple/swift-http-types.git", from: "1.5.1"), .package(url: "https://github.com/apple/swift-log", from: "1.6.0"), ], @@ -33,8 +34,8 @@ let package = Package( .target( name: "AtprotoTypes", dependencies: [ - "Base32", "GermConvenience", + .product(name: "Base32", package: "swift-bases"), .product(name: "Crypto", package: "swift-crypto"), .product(name: "HTTPTypes", package: "swift-http-types"), .product(name: "Logging", package: "swift-log"), diff --git a/Sources/AtprotoTypes/Atproto/CID.swift b/Sources/AtprotoTypes/Atproto/CID.swift index d571b82..4da73dc 100644 --- a/Sources/AtprotoTypes/Atproto/CID.swift +++ b/Sources/AtprotoTypes/Atproto/CID.swift @@ -31,17 +31,13 @@ extension Atproto { throw Atproto.Errors.invalidBase32Data } - guard let decoded = body.base32DecodedData else { - throw Atproto.Errors.invalidBase32Data - } - - bytes = decoded + bytes = try Base32.decode(body) } public var string: String { // CID is DASL-compatible (https://atproto.com/specs/data-model) // and DASL CID uses lowercase base-32 (https://dasl.ing/cid.html) - "b" + bytes.base32EncodedStringNoPadding.lowercased() + "b" + Base32.encode(bytes, options: .letterCase(.lower), .pad(false)) } } } diff --git a/Sources/AtprotoTypes/Primitives/Blob.swift b/Sources/AtprotoTypes/Primitives/Blob.swift index dc14a59..3d92ce8 100644 --- a/Sources/AtprotoTypes/Primitives/Blob.swift +++ b/Sources/AtprotoTypes/Primitives/Blob.swift @@ -29,7 +29,7 @@ extension Atproto.Primitive { /// The size of the blob. public let size: Int - + public init( ref: Atproto.Primitive.Link, mimeType: String, diff --git a/Sources/AtprotoTypes/Primitives/Link.swift b/Sources/AtprotoTypes/Primitives/Link.swift index c383fa2..fc60f7e 100644 --- a/Sources/AtprotoTypes/Primitives/Link.swift +++ b/Sources/AtprotoTypes/Primitives/Link.swift @@ -12,7 +12,7 @@ import Foundation extension Atproto.Primitive { public struct Link: Sendable, Codable, Equatable { public let link: Atproto.CID - + public init(link: Atproto.CID) { self.link = link } diff --git a/Sources/AtprotoTypes/XRPC/ResponseParsing.swift b/Sources/AtprotoTypes/XRPC/ResponseParsing.swift index d248530..a14e837 100644 --- a/Sources/AtprotoTypes/XRPC/ResponseParsing.swift +++ b/Sources/AtprotoTypes/XRPC/ResponseParsing.swift @@ -7,7 +7,8 @@ import Foundation import GermConvenience -import HTTPTypes + +import struct HTTPTypes.HTTPResponse extension Atproto.XRPC { public protocol ResponseParsing: Sendable {