# Migration Guide from v10 to v11 for Custom Auth Swift SDK
This migration guide provides steps for upgrading from version v10 to v11 of the Custom Auth Swift SDK. The guide outlines significant changes and enhancements.
## Web3AuthNetwork Changes
In v11, we have removed the nested enum and refactored the `Web3AuthNetwork`. Please checkout the table below for the changes.
| Old Value | New Value |
| ---------------------------- | ----------------- |
| `.sapphire(.SAPPHIRE_MAINNET)` | `.SAPPHIRE_MAINNET` |
| `.sapphire(.SAPPHIRE_DEVNET)` | `.SAPPHIRE_DEVNET` |
| `.legacy(.MAINNET)` | `.MAINNET` |
| `.legacy(.TESTNET)` | `.TESTNET` |
| `.legacy(.CYAN)` | `.CYAN` |
| `.legacy(.AQUA)` | `.AQUA` |
## CustomAuth Constructor Changes
In v11, the `CustomAuth` constructor instead of taking the configuration parameters, now only takes `CustomAuthArgs` as an input. The `CustomAuthArgs` has the necessary parameters to configure the SDK.
Previous, the `CustomAuth` also used to take the login informations as verifier details, and sub verifier details.
Starting from v11, the constructor doesn't take any login details. This helps developers to only one instance of the `CustomAuth` for multiple logins.
The details about login are now moved to `triggerLogin`, and `triggerAggregateLogin` methods.
### Previous Usage - v10.0.x
```swift
let sub = SubVerifierDetails(
loginType: .web,
loginProvider: .reddit,
clientId: "REDDIT_CLIENT_ID",
verifier: "YOUR_VERIFIER_NAME",
redirectURL: "YOUR_REDIRECT_URL"
)
let customAuth = CustomAuth(
web3AuthClientId: "YOUR_WEB3AUTH_CLIENT_ID",
aggregateVerifierType: .singleLogin,
aggregateVerifier: "reddit-shubs",
subVerifierDetails: [sub],
network: .legacy(.TESTNET)
)
```
### New Usage - v11.0.x
Please check the details for [CustomAuthArgs](#customauthargs) to know more the parameters.
```swift
let customAuthArgs = CustomAuthArgs(
urlScheme: "YOUR_WHITELISTED_URL_SCHEME",
network: .TESTNET,
web3AuthClientId: "YOUR_WEB3AUTH_CLIENT_ID"
)
let customAuth = CustomAuth(config: customAuthArgs)
```
### CustomAuthArgs
| Name | Description |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `urlScheme` | Your custom whitelisted URL scheme defined in your application to redirect the login result back the the application from the `AsWebAuthenticationSession`. [Learn more about URL scheme](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app#Register-your-URL-scheme). |
| `network` | Defines the Web3Auth network to be used. The supported values are `.SAPPHIRE_DEVNET`, `.SAPPHIRE_MAINNET`, `.MAINNET`, `.TESTNET`, `.CYAN`, `.AQUA`. |
| `metadataUrl` | This parameter can be used to define the custom metadata url. The default is `https://metadata.tor.us`. |
| `enableLogging` | Defines whether to enable logging for the SDK or not. Default value is false. |
| `enableOneKey` | If set to true, it allows you to retrive the same key as Single Factor Auth SDK. Please note, if you set to true, and later change it to false, the address would be different. Hence, once set, it shouldn't be changed. |
| `storageServerUrl` | Specifies the storage server URL. The default value is `https://session.web3auth.io`. |
| `web3AuthClientId` | Pass your Web3Auth Client id, you can get it from [Web3Auth Dashboard](https://dashboard.web3auth.io). |
| `serverTimeOffset` | Specifies the server time offset in seconds. This parameter is used to adjust the server time to the local time. The default value is 0 seconds. |
## triggerLogin Method Changes
The triggerLogin method has signicantly changed in v11. Previously, the method was used for both single login verifier, and aggregate login verifier. In v11, the method now only supports the signle login verifier. To use aggregate login verifier, please use the `triggerAggregateLogin` method.
In v11, the method now only takes the `SingleLoginParams` as an input. Please check the details for [SingleLoginParams](#singleloginparams) to know more the parameters. This helps developers to have single instance of the SDK for multiple logins.
In v11, the response of the `triggerLogin` method has changed to `TorusLoginResponse`. Please check the details for [TorusLoginResponse](#torusloginresponse) to know more the response.
### Previous Usage - v10.0.x
```swift
let sub = SubVerifierDetails(
loginType: .installed,
loginProvider: .google,
clientId: "GOOGLE_CLIENT_ID",
verifier: "YOUR_VERIFIER_NAME",
redirectURL: "YOUR_REDIRECT_URL"
)
let customAuth = CustomAuth(
web3AuthClientId: "YOUR_WEB3AUTH_CLIENT_ID",
aggregateVerifierType: .singleLogin,
aggregateVerifier: "YOUR_VERIFIER_NAME",
subVerifierDetails: [sub],
network: .legacy(.TESTNET)
)
// This method will use the reddit verifier to login
// which was defined in the CustomAuth constructor.
let result = try await customAuth.triggerLogin()
```
### New Usage - v11.0.x
```swift
let customAuthArgs = CustomAuthArgs(
urlScheme: "YOUR_WHITELISTED_URL_SCHEME",
network: .TESTNET,
web3AuthClientId: "YOUR_WEB3AUTH_CLIENT_ID"
)
let customAuth = CustomAuth(config: customAuthArgs)
let singleLoginParams = SingleLoginParams(
typeOfLogin: .google,
verifier: "YOUR_VERIFIER_NAME",
clientId: "YOUR_GOOGLE_CLIENT_ID"
)
// This method will use the google verifier to login
// which was defined in the SingleLoginParams.
let result = try await customAuth.triggerLogin(args: singleLoginParams)
```
### SingleLoginParams
| Name | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `typeOfLogin` | Defines the type of social/ OAuth login you want to use. Available values are `.google`, `.facebook`, `.discord`, `.reddit`, `.twitch`, `.apple`, `.github`, `.linkedin`, `.twitter`, `.weibo`, `.line`, `.email_password`, `.email_passwordless`, `.sms_passwordless`, and `.jwt` |
| `verifier` | Your custom verifier name. |
| `clientId` | Your OAuth provider client id. For instance, if you are using `LoginType.google` it'll take the google login id. |
| `redirectURL` | Defines the redirect URL, the default value is `https://scripts.toruswallet.io/redirect.html`. |
| `jwtParams?` | Auth0 login parameters. See [Auth0ClientOptions](https://github.com/torusresearch/customauth-swift-sdk/blob/master/Sources/CustomAuth/Common/LoginParams/Auth0ClientOptions.swift). Explicitly required for login types: `.jwt`, `.email_passwordless`, `.sms_passwordless`. |
| `hash?` | This is the urlfragment part of the url, only use if needed |
### TorusLoginResponse
| Name | Description |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `singleVerifierResponse` | Returns the `TorusSingleVerifierResponse` which has user information, and other verifier details like idToken, accessToken, and more. Check out [TorusSingleVerifierResponse](https://github.com/torusresearch/customauth-swift-sdk/blob/master/Sources/CustomAuth/Common/VerifierResponses/TorusSingleVerifierResponse.swift) for more details. |
| `torusKey` | Returns the `TorusKey` which information regarding private key, evm address for the user and more. Please checkout [TorusKey](https://github.com/torusresearch/torus-utils-swift/blob/master/Sources/TorusUtils/Interfaces/TorusKey.swift) for more details. |
## triggerAggregateLogin Method Addition
Previously, to login with aggregate verifier, you need to use the `triggerLogin` method using `aggregateVerifierType`. Starting from v11, for aggregate verifier, you need to use the `triggerAggregateLogin` method.
Please check the details for [AggregateLoginParams](#aggregateloginparams) to know more the
parameters.
The `triggerAggregateLogin` method returns the `TorusAggregateLoginResponse`, learn more about the [TorusAggregateLoginResponse](#torusaggregateloginresponse).
### Previous Usage - v10.0.x
```swift
let sub = SubVerifierDetails(
// In v11, the loginType has been removed, every request
// goes through AsWebAuthenticationSession now.
loginType: .installed,
// In v11, you need to use the loginType to define the
// the social/ OAuth login you want to use.
loginProvider: .google,
clientId: "YOUR_GOOGLE_CLIENT_ID",
verifier: "YOUR_SUB_VERIFIER_NAME",
redirectURL: "com.googleusercontent.apps.238941746713-vfap8uumijal4ump28p9jd3lbe6onqt4:/oauthredirect"
)
let customAuth = CustomAuth(
web3AuthClientId: "YOUR_WEB3AUTH_CLIENT_ID",
aggregateVerifierType: .singleIdVerifier,
aggregateVerifier: "YOUR_AGGREGATE_VERIFIER_NAME",
subVerifierDetails: [sub],
network: .legacy(.TESTNET)
)
// This method will use the multigoogle aggregate verifier to login
// which was defined in the CustomAuth constructor.
let result = try await customAuth.triggerLogin()
```
### New Usage - v11.0.x
```swift
let customAuthArgs = CustomAuthArgs(
urlScheme: "YOUR_URL_SCHEMA",
network: .TESTNET,
web3AuthClientId: "YOUR_WEB3AUTH_CLIENT_ID"
)
let customAuth = CustomAuth(config: customAuthArgs)
let aggregateLoginParams = AggregateLoginParams(
aggregateVerifierType: AggregateVerifierType.single_id_verifier,
verifierIdentifier: "YOUR_AGGREGATE_VERIFIER_NAME",
subVerifierDetailsArray: [
SingleLoginParams(
typeOfLogin: .google,
verifier: "YOUR_SUB_VERIFIER_NAME",
clientId: "YOUR_GOOGLE_CLIENT_ID"
)
]
)
let torusLoginResponse = try await customAuth.triggerAggregateLogin(args: aggregateLoginParams)
```
### AggregateLoginParams
| Name | Description |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `aggregateVerifierType` | Defines the aggregate verifier type. Supported value is `AggregateVerifierType.single_id_verifier`. This means the aggregate verifier would consider only one verification field to aggregate the different verifiers. |
| `verifierIdentifier` | Pass your aggregate verifier name. |
| `subVerifierDetailsArray` | Takes in a list of sub verifiers for the aggregate login, this is a list of `SingleLoginParams`. |
### TorusAggregateLoginResponse
| Name | Description |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `torusAggregateVerifierResponse` | Returns a list of torus aggregate verifier response. Checkout [TorusAggregateVerifierResponse](https://github.com/torusresearch/customauth-swift-sdk/blob/master/Sources/CustomAuth/Common/VerifierResponses/TorusAggregateVerifierResponse.swift) to learn more. |
| `torusKey` | Returns the `TorusKey` which information regarding private key, evm address for the user and more. Please checkout [TorusKey](https://github.com/torusresearch/torus-utils-swift/blob/master/Sources/TorusUtils/Interfaces/TorusKey.swift) for more details. |
## getTorusKey Method Changes
Starting v11, the `getTorusKey` method no longer accepts `userData` as a parameter. There also have been addition of two new parameters `verifierParams`, and `extraParams` which helps to pass the verifier details, and other necessary parameters respectively.
Please check the details for [VerifierParams](https://github.com/torusresearch/torus-utils-swift/blob/baa822fc67bdb208ed1a2dc5b3c10485cfca15df/Sources/TorusUtils/VerifierParams.swift#L13) and [TorusUtilsExtraParams](https://github.com/torusresearch/torus-utils-swift/blob/master/Sources/TorusUtils/TorusUtilsExtraParams.swift) to know more about the parameters.
### Previous Usage - v10.0.x
```swift
let torusKey = try await customAuth.getTorusKey(
verifier: "YOUR_VERIFIER_NAME",
verifierId: "USER_VERIFIER_ID",
idToken: idToken,
// User data decoded from JWT
userData: data
)
```
### New Usage - v11.0.x
```swift
import TorusUtils
let verifierParams: VerifierParams = VerifierParams(verifier_id: "USER_VERIFIER_ID")
let torusKey = try await customAuth.getTorusKey(
verifier: "YOUR_VERIFIER_NAME",
verifier_id: "USER_VERIFIER_ID",
verifierParams: verifierParams,
idToken: idToken
)
```
## getAggregateTorusKey Method Changes
Starting v11, the `getAggregateTorusKey` method no longer accepts the `verifier_id`,`subVerifierDetails` and `userData`. Instead of `subVerifierDetails`, you need to use the `subVerifierInfoArray` which takes the list of `TorusSubVerifierInfo` as an arguemnt.
For passing the `verifier_id`, you can need to use the `verifierParams`. Please check the details for [VerifierParams](https://github.com/torusresearch/torus-utils-swift/blob/baa822fc67bdb208ed1a2dc5b3c10485cfca15df/Sources/TorusUtils/VerifierParams.swift#L13)
### Previous Usage - v10.0.x
```swift
let sub = SubVerifierDetails(
// In v11, the loginType has been removed, every request
// goes through AsWebAuthenticationSession now.
loginType: .installed,
// In v11, you need to use the loginType to define the
// the social/ OAuth login you want to use.
loginProvider: .google,
clientId: "YOUR_GOOGLE_CLIENT_ID",
verifier: "YOUR_SUB_VERIFIER_NAME",
redirectURL: "com.googleusercontent.apps.238941746713-vfap8uumijal4ump28p9jd3lbe6onqt4:/oauthredirect"
)
let aggTorusKey = try await customAuth.getAggregateTorusKey(
verifier: "YOUR_AGGREGATE_VERIFIER_NAME",
verifierId: "USER_VERIFIER_ID",
idToken: idToken,
subVerifierDetails: subVerifier,
userData: newData
)
```
### New Usage - v11.0.x
```swift
import TorusUtils
let verifierParams: VerifierParams = VerifierParams(verifier_id: "USER_VERIFIER_ID")
let subVerifierList = [
TorusSubVerifierInfo(
verifierId: "USER_VERIFIER_ID",
verifier: "YOUR_SUB_VERIFIER",
)
]
let aggTorusKey = try await customAuth.getAggregateTorusKey(
verifier: "YOUR_AGGREGATE_VERIFIER_NAME",
verifierParams: verifierParams
idToken: idToken,
subVerifierInfoArray: subVerifierList,
)
```
## MacOS Support
Starting v11, the CustomAuth Swift SDK also supports the MacOS. You can now use the SDK to build apps targeting both iOS and MacOS.
Please note, the minimum target version for MacOS is v11.
## iOS Minimum Target Version
Starting v11, the minimum target version for the iOS has changed from `iOS v13` to `iOS v14`.