77
88import Foundation
99
10+
11+ public struct SuperTokensAppInfo : Encodable {
12+ public var appName : String
13+ public var apiDomain : String
14+ public var apiBasePath : String
15+
16+ internal var normalizedApiDomain : String ? {
17+ let domain = apiDomain. trimmingCharacters ( in: . whitespacesAndNewlines)
18+ . trimmingCharacters ( in: CharacterSet ( charactersIn: " / " ) )
19+
20+ guard let url = URL ( string: domain) ,
21+ let scheme = url. scheme? . lowercased ( ) ,
22+ scheme == " http " || scheme == " https " ,
23+ url. host != nil
24+ else {
25+ return nil
26+ }
27+
28+ return url. absoluteString. trimmingCharacters ( in: CharacterSet ( charactersIn: " / " ) )
29+ }
30+
31+ internal var normalizedApiBasePath : String {
32+ let segments = apiBasePath
33+ . trimmingCharacters ( in: . whitespacesAndNewlines)
34+ . split ( separator: " / " )
35+ . map ( String . init)
36+
37+ return segments. isEmpty ? " " : " / " + segments. joined ( separator: " / " )
38+ }
39+
40+ internal var migrationURL : URL ? {
41+ guard let normalizedApiDomain else {
42+ return nil
43+ }
44+
45+ guard var components = URLComponents ( string: normalizedApiDomain) else {
46+ return nil
47+ }
48+
49+ components. path = normalizedApiBasePath + " /plugin/rownd/migrate "
50+ return components. url
51+ }
52+
53+ public init ( appName: String , apiDomain: String , apiBasePath: String = " /auth " ) {
54+ self . appName = appName
55+ self . apiDomain = apiDomain
56+ self . apiBasePath = apiBasePath
57+ }
58+ }
59+
60+ public struct SuperTokensConfig : Encodable {
61+ public var appInfo : SuperTokensAppInfo
62+
63+ public init ( appInfo: SuperTokensAppInfo ) {
64+ self . appInfo = appInfo
65+ }
66+ }
67+
1068public struct RowndConfig : Encodable {
1169 internal init ( ) { }
1270
@@ -21,6 +79,7 @@ public struct RowndConfig: Encodable {
2179 public var customizations : RowndCustomizations = RowndCustomizations ( )
2280
2381 // These will not be encoded
82+ public var supertokens : SuperTokensConfig ? = nil
2483 public var appGroupPrefix : String ?
2584 public var enableSmartLinkPasteBehavior : Bool = true
2685 public var signInLinkPattern : String = " .* \\ .rownd \\ .link$ "
0 commit comments