Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from magiclabs/jerryliu-sc-63905-spm-monorepo-i…
Browse files Browse the repository at this point in the history
…nvestigation

iOS MWS
  • Loading branch information
Ethella authored Oct 19, 2022
2 parents f15b2b9 + a6566c4 commit bab1053
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 7 deletions.
10 changes: 5 additions & 5 deletions MagicExt-OAuth.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
27 changes: 27 additions & 0 deletions MagicExt-OIDC.podspec
Original file line number Diff line number Diff line change
@@ -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' => '[email protected]' }
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
15 changes: 13 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import PackageDescription

let package = Package(
name: "MagicExt-OAuth",
name: "MagicExtensions",
platforms: [
.iOS(.v10),
.macOS(.v10_12)
Expand All @@ -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.
Expand All @@ -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"]),
]
)
24 changes: 24 additions & 0 deletions Sources/MagicExt-OIDC/Core/OIDCExtension.swift
Original file line number Diff line number Diff line change
@@ -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<String> ) {
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)
}
}
11 changes: 11 additions & 0 deletions Sources/MagicExt-OIDC/Types/OIDCMethod.swift
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions Sources/MagicExt-OIDC/Types/OpenIdConfiguration.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
7 changes: 7 additions & 0 deletions Tests/MagicExt-OIDCTests/MagicExt_OIDCTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import XCTest
@testable import MagicExt_OIDC

final class MagicExt_OIDCTests: XCTestCase {
func testExample() throws {
}
}

0 comments on commit bab1053

Please sign in to comment.