From 027e9692569d21f0cd557102fb3c930b41a0fbc2 Mon Sep 17 00:00:00 2001 From: ethella Date: Mon, 17 Oct 2022 13:19:45 -0700 Subject: [PATCH 1/2] * refactor Package and folder structure * Create OpenId Extension Entry --- MagicExt-OAuth.podspec | 8 +++--- MagicExt-OIDC.podspec | 27 +++++++++++++++++++ Package.swift | 13 +++++++-- .../MagicExt-OIDC/Core/OIDCExtension.swift | 23 ++++++++++++++++ 4 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 MagicExt-OIDC.podspec create mode 100644 Sources/MagicExt-OIDC/Core/OIDCExtension.swift diff --git a/MagicExt-OAuth.podspec b/MagicExt-OAuth.podspec index 53705f5..4721616 100644 --- a/MagicExt-OAuth.podspec +++ b/MagicExt-OAuth.podspec @@ -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..73f5cad --- /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 = '0.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..ddb0af1 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,13 @@ 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,6 +30,11 @@ 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"]), diff --git a/Sources/MagicExt-OIDC/Core/OIDCExtension.swift b/Sources/MagicExt-OIDC/Core/OIDCExtension.swift new file mode 100644 index 0000000..f96721d --- /dev/null +++ b/Sources/MagicExt-OIDC/Core/OIDCExtension.swift @@ -0,0 +1,23 @@ +// +// OauthModule.swift +// MagicSDK +// +// Created by Wentao Liu on 9/16/20. +// + +import Foundation +import AuthenticationServices +import SafariServices +import MagicSDK_Web3 +import MagicSDK +import PromiseKit + +public class OIDCExtension: BaseModule { + +} + +extension Magic { + public var openid: OIDCExtension { + return OIDCExtension(rpcProvider: self.rpcProvider) + } +} From a6566c4484cc83715885971fff9469a9d5f5ccf0 Mon Sep 17 00:00:00 2001 From: ethella Date: Tue, 18 Oct 2022 22:27:56 -0700 Subject: [PATCH 2/2] * Create OIDC extension * Bump extension package to 1.1.0 --- MagicExt-OAuth.podspec | 2 +- MagicExt-OIDC.podspec | 2 +- Package.swift | 6 ++++-- .../MagicExt-OIDC/Core/OIDCExtension.swift | 11 ++++++----- Sources/MagicExt-OIDC/Types/OIDCMethod.swift | 11 +++++++++++ .../Types/OpenIdConfiguration.swift | 19 +++++++++++++++++++ .../MagicExt_OIDCTests.swift | 7 +++++++ 7 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 Sources/MagicExt-OIDC/Types/OIDCMethod.swift create mode 100644 Sources/MagicExt-OIDC/Types/OpenIdConfiguration.swift create mode 100644 Tests/MagicExt-OIDCTests/MagicExt_OIDCTests.swift diff --git a/MagicExt-OAuth.podspec b/MagicExt-OAuth.podspec index 4721616..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 diff --git a/MagicExt-OIDC.podspec b/MagicExt-OIDC.podspec index 73f5cad..17444c5 100644 --- a/MagicExt-OIDC.podspec +++ b/MagicExt-OIDC.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.name = 'MagicExt-OIDC' - s.version = '0.1.0' + s.version = '1.1.0' s.summary = 'Magic IOS Extension - OIDC' s.description = <<-DESC diff --git a/Package.swift b/Package.swift index ddb0af1..884f257 100644 --- a/Package.swift +++ b/Package.swift @@ -16,8 +16,7 @@ let package = Package( targets: ["MagicExt-OAuth"]), .library( name: "MagicExt-OIDC", - targets: ["MagicExt-OIDC"] - ), + targets: ["MagicExt-OIDC"]), ], dependencies: [ .package(url: "https://github.com/magiclabs/magic-ios.git", from:"4.0.0"), @@ -38,5 +37,8 @@ let package = Package( .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 index f96721d..1e92b32 100644 --- a/Sources/MagicExt-OIDC/Core/OIDCExtension.swift +++ b/Sources/MagicExt-OIDC/Core/OIDCExtension.swift @@ -1,19 +1,20 @@ // -// OauthModule.swift +// OIDCExtension.swift // MagicSDK // -// Created by Wentao Liu on 9/16/20. +// Created by Jerry Liu on 10/16/22. // import Foundation -import AuthenticationServices -import SafariServices import MagicSDK_Web3 import MagicSDK -import PromiseKit 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 { 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 { + } +}