Skip to content

Commit

Permalink
feat(didcore): update for new didcore version and to use didcore jwk
Browse files Browse the repository at this point in the history
  • Loading branch information
beatt83 committed Oct 12, 2023
1 parent 17f4e9c commit 46a29b1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8
// swift-tools-version: 5.7.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -13,7 +13,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/swift-libp2p/swift-multibase.git", .upToNextMajor(from: "0.0.1")),
.package(url: "https://github.com/swift-libp2p/swift-bases.git", .upToNextMajor(from: "0.0.3")),
.package(url: "[email protected]:beatt83/didcore-swift.git", branch: "main")
.package(url: "[email protected]:beatt83/didcore-swift.git", .upToNextMinor(from: "1.0.0"))
],
targets: [
.target(
Expand Down
32 changes: 0 additions & 32 deletions Sources/PeerDID/Models/JWK.swift

This file was deleted.

5 changes: 4 additions & 1 deletion Sources/PeerDID/Models/VerificationMaterialFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ extension PeerDIDVerificationMaterial {
case .jwk:
let decoder = JSONDecoder()
let jwk = try decoder.decode(JWK.self, from: value)
guard let decoded = Data(base64URLEncoded: jwk.x) else {
guard
let x = jwk.x,
let decoded = Data(base64URLEncoded: x)
else {
throw PeerDIDError.invalidBase64URLKey
}
return decoded
Expand Down
2 changes: 2 additions & 0 deletions Tests/PeerDIDTests/CreatePeerDIDAlgo0Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Gonçalo Frade on 12/08/2023.
//

import DIDCore
@testable import PeerDID
import XCTest

Expand Down Expand Up @@ -32,6 +33,7 @@ final class CreatePeerDIDAlgo0Tests: XCTestCase {

func testCreatePeerDIDAlgo0JWKKey() throws {
let jwk = JWK(
kty: "OKP",
crv: "Ed25519",
x: "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA"
)
Expand Down
3 changes: 3 additions & 0 deletions Tests/PeerDIDTests/DecodeEcnumbasisTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Created by Gonçalo Frade on 12/08/2023.
//
import DIDCore
@testable import PeerDID
import XCTest

Expand Down Expand Up @@ -70,6 +71,7 @@ final class DecodeEcnumbasisTest: XCTestCase {

func testDecodeFormatJWKKeyEd25519() throws {
let expectedJWK = JWK(
kty: "OKP",
crv: "Ed25519",
x: "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA"
)
Expand All @@ -92,6 +94,7 @@ final class DecodeEcnumbasisTest: XCTestCase {

func testDecodeFormatJWKKeyX25519() throws {
let expectedJWK = JWK(
kty: "OKP",
crv: "X25519",
x: "BIiFcQEn3dfvB2pjlhOQQour6jXy9d5s2FKEJNTOJik"
)
Expand Down
3 changes: 2 additions & 1 deletion Tests/PeerDIDTests/TestsHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
// Created by Gonçalo Frade on 12/08/2023.
//

import DIDCore
@testable import PeerDID
import Foundation

extension JWK {
static func testable(crv: String = "Ed25519", x: String = "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA") -> JWK {
return JWK(crv: crv, x: x)
return JWK(kty: "OKP", crv: crv, x: x)
}

static func testableData(crv: String = "Ed25519", x: String = "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA") -> Data {
Expand Down

0 comments on commit 46a29b1

Please sign in to comment.