Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-rings-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@germ-network/atprototypes": patch
---

adopt swift-libp2p/swift-bases.git
24 changes: 12 additions & 12 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
],
Expand All @@ -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"),
Expand Down
8 changes: 2 additions & 6 deletions Sources/AtprotoTypes/Atproto/CID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/AtprotoTypes/Primitives/Blob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension Atproto.Primitive {

/// The size of the blob.
public let size: Int

public init(
ref: Atproto.Primitive.Link,
mimeType: String,
Expand Down
2 changes: 1 addition & 1 deletion Sources/AtprotoTypes/Primitives/Link.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/AtprotoTypes/XRPC/ResponseParsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import Foundation
import GermConvenience
import HTTPTypes

import struct HTTPTypes.HTTPResponse

extension Atproto.XRPC {
public protocol ResponseParsing: Sendable {
Expand Down
Loading