diff --git a/MagicExt-OAuth.podspec b/MagicExt-OAuth.podspec index 53705f5..43266e6 100644 --- a/MagicExt-OAuth.podspec +++ b/MagicExt-OAuth.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.name = 'MagicExt-OAuth' - s.version = '1.0.0' + s.version = '1.1.0' s.summary = 'Magic IOS Extension - OAuth' s.description = <<-DESC @@ -18,10 +18,10 @@ TODO: Add long description of the pod here. s.swift_version = '5.0' s.ios.deployment_target = '10.0' # s.osx.deployment_target = '10.12' - + s.source_files = 'Sources/MagicExt-OAuth/**/*' - - s.dependency 'MagicSDK', '~> 3.0' - + + s.dependency 'MagicSDK', '~> 4.0' + s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } end diff --git a/MagicExt-OIDC.podspec b/MagicExt-OIDC.podspec new file mode 100644 index 0000000..17444c5 --- /dev/null +++ b/MagicExt-OIDC.podspec @@ -0,0 +1,27 @@ +# +# Local Podspec for building local target +# + +Pod::Spec.new do |s| + s.name = 'MagicExt-OIDC' + s.version = '1.1.0' + s.summary = 'Magic IOS Extension - OIDC' + + s.description = <<-DESC +TODO: Add long description of the pod here. + DESC + + s.homepage = 'https://github.com/magicLabs/magic-ios-ext' + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.author = { 'Jerry Liu' => 'jerry@magic.link' } + s.source = { :git => 'https://github.com/magicLabs/magic-ios-ext.git', :tag => s.version.to_s } + s.swift_version = '5.0' + s.ios.deployment_target = '10.0' +# s.osx.deployment_target = '10.12' + + s.source_files = 'Sources/MagicExt-OIDC/**/*' + + s.dependency 'MagicSDK', '~> 4.0' + + s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } +end diff --git a/Package.swift b/Package.swift index 160b256..884f257 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( - name: "MagicExt-OAuth", + name: "MagicExtensions", platforms: [ .iOS(.v10), .macOS(.v10_12) @@ -14,9 +14,12 @@ let package = Package( .library( name: "MagicExt-OAuth", targets: ["MagicExt-OAuth"]), + .library( + name: "MagicExt-OIDC", + targets: ["MagicExt-OIDC"]), ], dependencies: [ - .package(url: "https://github.com/magiclabs/magic-ios.git", from:"3.0.0"), + .package(url: "https://github.com/magiclabs/magic-ios.git", from:"4.0.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. @@ -26,8 +29,16 @@ let package = Package( dependencies: [ .product(name: "MagicSDK", package: "magic-ios"), ]), + .target( + name: "MagicExt-OIDC", + dependencies: [ + .product(name: "MagicSDK", package: "magic-ios"), + ]), .testTarget( name: "MagicExt-OAuthTests", dependencies: ["MagicExt-OAuth"]), + .testTarget( + name: "MagicExt-OIDCTests", + dependencies: ["MagicExt-OIDC"]), ] ) diff --git a/Sources/MagicExt-OIDC/Core/OIDCExtension.swift b/Sources/MagicExt-OIDC/Core/OIDCExtension.swift new file mode 100644 index 0000000..1e92b32 --- /dev/null +++ b/Sources/MagicExt-OIDC/Core/OIDCExtension.swift @@ -0,0 +1,24 @@ +// +// OIDCExtension.swift +// MagicSDK +// +// Created by Jerry Liu on 10/16/22. +// + +import Foundation +import MagicSDK_Web3 +import MagicSDK + +public class OIDCExtension: BaseModule { + + public func loginWithOIDC (_ configuration: OpenIdConfiguration, response: @escaping Web3ResponseCompletion ) { + let request = RPCRequest<[OpenIdConfiguration]>(method: OIDCMethod.magic_auth_login_with_oidc.rawValue, params: [configuration]) + self.provider.send(request: request, response: response) + } +} + +extension Magic { + public var openid: OIDCExtension { + return OIDCExtension(rpcProvider: self.rpcProvider) + } +} diff --git a/Sources/MagicExt-OIDC/Types/OIDCMethod.swift b/Sources/MagicExt-OIDC/Types/OIDCMethod.swift new file mode 100644 index 0000000..79ba730 --- /dev/null +++ b/Sources/MagicExt-OIDC/Types/OIDCMethod.swift @@ -0,0 +1,11 @@ +// +// OIDCMethod.swift +// +// +// Created by Jerry Liu on 10/17/22. +// + +import Foundation +internal enum OIDCMethod: String, CaseIterable { + case magic_auth_login_with_oidc +} diff --git a/Sources/MagicExt-OIDC/Types/OpenIdConfiguration.swift b/Sources/MagicExt-OIDC/Types/OpenIdConfiguration.swift new file mode 100644 index 0000000..de9361b --- /dev/null +++ b/Sources/MagicExt-OIDC/Types/OpenIdConfiguration.swift @@ -0,0 +1,19 @@ +// +// OpenIdConfiguration.swift +// +// +// Created by Jerry Liu on 10/17/22. +// + +import Foundation +import MagicSDK + +public struct OpenIdConfiguration: BaseConfiguration { + public var jwt: String + public var providerId: String + + public init(jwt: String, providerId: String) { + self.jwt = jwt + self.providerId = providerId + } +} diff --git a/Tests/MagicExt-OIDCTests/MagicExt_OIDCTests.swift b/Tests/MagicExt-OIDCTests/MagicExt_OIDCTests.swift new file mode 100644 index 0000000..69c320c --- /dev/null +++ b/Tests/MagicExt-OIDCTests/MagicExt_OIDCTests.swift @@ -0,0 +1,7 @@ +import XCTest +@testable import MagicExt_OIDC + +final class MagicExt_OIDCTests: XCTestCase { + func testExample() throws { + } +}