Skip to main content

PnP IOS SDK - v6 to v7

General

openlogin v5 is supported

With V7, Users can now log in from Sapphire Mainnet and Sapphire Devnet.

import Web3Auth

let web3auth = Web3Auth(W3AInitParams(
clientId: "<your clientId>",
network: .mainnet, // you can use .sapphire_devnet or .sapphire_mainnet
sdkUrl: ...,
redirectUrl: ...,
))

Web3AuthState now has more parameters

In v7, you can configure additional coreKitKey and coreKitEd25519PrivKey fields when you initialize Web3authState.

public struct Web3AuthState: Codable {
public let privKey: String?
public let ed25519PrivKey: String?
public let sessionId: String?
public let userInfo: Web3AuthUserInfo?
public let error: String?
public let coreKitKey: String?
public let coreKitEd25519PrivKey: String?
}

W3AInitParams param configuration changed

In v7, the whiteLabel parameter type and configuration has changed. And, as mentioned earlier, the sapphire network type has been added. Also several parameters have been added to W3AInitParams.

change of WhiteLabel parameter configuration

ParameterTypeDescriptionDefaultMandatory
appNameStringApp name to be displayed in the User Flow Screens.dApp's Website URLNo
logoLightStringApp logo to be shown on the dark background (dark theme)web3auth-logo.svgNo
logoDarkStringApp logo to be shown on the light background (light theme)web3auth-logo.svgNo
defaultLanguageLanguageDefault Language to use.
Choose from:
  • en - English
  • de - German
  • ja - Japanese
  • ko - Korean
  • zh - Mandarin
  • es - Spanish
  • fr - French
  • pt - Portuguese
  • nl - Dutch
en - EnglishNo
modeThemeModesChoose between auto, light or dark modes.autoNo
theme[String: String]Used to customize the theme of the login modal with the following options
'primary' - To customize the primary color of the modal's content
#0364FFNo
appUrlStringApp URL to be displayed in the User Flow Screens.dApp's Website URLNo
useLogoLoaderBoolLoads the logo when loadingfalseNo
Usage
web3Auth = await Web3Auth(
W3AInitParams(
clientId:"YOUR_CLIENT_ID",
network: .testnet,
whiteLabel: W3AWhiteLabelData(
appName: "Web3Auth Stub",
logoLight: "https://images.web3auth.io/web3auth-logo-w.svg",
logoDark: "https://images.web3auth.io/web3auth-logo-w.svg",
defaultLanguage: .en, // en, de, ja, ko, zh, es, fr, pt, nl
mode: .dark
theme: ["primary": "#d53f8c"])
))

change of W3AInitParams object

The Web3Auth constructor takes an object called W3AInitParams as input. Below are the available fields of the W3AInitParams object. With v7, additional 2 parameters, which are MfaSettings and sessionTime can be set.

ParameterTypeMandatoryDescription
clientIdStringYesYour Web3Auth project ID
networkNetworkYesWeb3Auth Network to run the authentication on, either .mainnet,.aqua, .testnet, .cyan, or .sapphire_devnet or .sapphire_mainnet
buildEnvBuildEnvNoOption for auth service, production, staging, testing available
sdkUrlURLNoWeb3Auth sdk frontend to be used. This field is for advanced usage only and should not be changed.
redirectUrlStringNoredirectUrl to be passed to the sdk frontend. This field is for advanced usage only and should not be changed.
whiteLabelW3AWhiteLabelDataNoA configuration optional object to customize UI, branding, and translations for your brand. Refer to the WhiteLabeling section for more info.
loginConfig[String : W3ALoginConfig]NoA configuration optional object to customize login flow.
useCoreKitKeyboolNoUse CoreKit Key to get core kit key.
chainNamespaceChainNamespaceNoChain Namespace [eip155 and solana]
MfaSettingsMfaSettingsNoSettings for Multi factor authentication
sessionTimeIntNoSession maintenance time

Here's the example configuration of Web3AuthOptions.

        let result = try await Web3Auth(.init(
clientId: clientId,
network: network,
loginConfig: [
TypeOfLogin.google.rawValue:
.init(
verifier: "w3a-agg-example",
typeOfLogin: .google,
name: "Web3Auth-Aggregate-Verifier-Google-Example",
clientId: "774338308167-q463s7kpvja16l4l0kko3nb925ikds2p.apps.googleusercontent.com",
verifierSubIdentifier: "w3a-google"
)
],
whiteLabel: W3AWhiteLabelData(
appName: "Web3Auth Stub",
logoLight: "https://images.web3auth.io/web3auth-logo-w.svg",
logoDark: "https://images.web3auth.io/web3auth-logo-w.svg",
defaultLanguage: .en, // en, de, ja, ko, zh, es, fr, pt, nl
mode: .dark,
theme: ["primary": "#d53f8c"]),
mfaSettings: MfaSettings(
deviceShareFactor: MfaSetting(enable: true, priority: 1),
backUpShareFactor: MfaSetting(enable: true, priority: 2),
socialBackupFactor: MfaSetting(enable: true, priority: 3),
passwordFactor: MfaSetting(enable: true, priority: 4)
)
)).login(
W3ALoginParams(
loginProvider: .GOOGLE,
dappShare: nil,
extraLoginOptions: ExtraLoginOptions(display: nil, prompt: nil, max_age: nil, ui_locales: nil, id_token_hint: nil, id_token: nil, login_hint: nil, acr_values: nil, scope: nil, audience: nil, connection: nil, domain: nil, client_id: nil, redirect_uri: nil, leeway: nil, verifierIdField: nil, isVerifierIdCaseSensitive: nil, additionalParams: nil),
mfaLevel: .DEFAULT,
curve: .SECP256K1
))

Using the mfaSettings to configure MFA Order

You can configure the order of MFA or enable/disable MFA type by passing the mfaSettings object in Web3AuthOptions.

MfaSettings

deviceShareFactor | backUpShareFactor | socialBackupFactor | passwordFactor

ParameterTypeMandatoryDescription
enableboolYesEnable/Disable MFA
priorityintNoPriority of MFA
mandatoryboolNoMandatory/Optional MFA

web3.swift version updated to v1.6

With V7, lots of package dependencies have been updated. Among that, version of package web3.swift is updated to v1.6.0. Ethereum-related calls from the client changed lot, so need to care about that.

ExtraLoginOptions

With V7, ExtraLoginOptions now has one more parameter which is additionalParams: [String : String]?

ParameterTypeDescription
domainstringYour Auth0 account domain such as example.auth0.com or example.mycompany.com etc. Use any random string in case of custom JWT login.
client_idstringThe Client ID found on your Auth0 Application settings page. Use web3auth client id in case of custom JWT login.
redirect_uristringThe default URL where Auth0 will redirect your browser to with the authentication result.
leewaynumberThe value in seconds used to account for clock skew in JWT expirations.
verifierIdFieldstringThe field in jwt token which maps to verifier id.
isVerifierIdCaseSensitivebooleanWhether the verifier id field is case sensitive. Defaults to true
public struct ExtraLoginOptions: Codable{
let display: String?
let prompt: String?
let max_age: String?
let ui_locales: String?
let id_token_hint: String?
let id_token: String?
let login_hint: String?
let acr_values: String?
let scope: String?
let audience: String?
let connection: String?
let domain: String?
let client_id: String?
let redirect_uri: String?
let leeway: Int?
let verifierIdField: String?
let isVerifierIdCaseSensitive: Bool?
let additionalParams: [String : String]?
}