@supertokens/rownd-react-native 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +554 -0
  3. package/android/build.gradle +153 -0
  4. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  5. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/gradlew +234 -0
  8. package/android/gradlew.bat +89 -0
  9. package/android/src/main/AndroidManifest.xml +4 -0
  10. package/android/src/main/java/com/reactnativerowndplugin/RowndPluginModule.kt +235 -0
  11. package/android/src/main/java/com/reactnativerowndplugin/RowndPluginPackage.kt +25 -0
  12. package/app.plugin.js +3 -0
  13. package/expo/plugin.js +61 -0
  14. package/ios/Rownd.xcodeproj/project.pbxproj +283 -0
  15. package/ios/RowndHelper.swift +62 -0
  16. package/ios/RowndPlugin-Bridging-Header.h +3 -0
  17. package/ios/RowndPlugin.m +31 -0
  18. package/ios/RowndPlugin.swift +233 -0
  19. package/ios/RowndPluginEventEmitter.m +12 -0
  20. package/ios/RowndPluginEventEmitter.swift +19 -0
  21. package/lib/commonjs/components/GlobalContext.js +72 -0
  22. package/lib/commonjs/components/GlobalContext.js.map +1 -0
  23. package/lib/commonjs/components/GlobalContext.types.js +6 -0
  24. package/lib/commonjs/components/GlobalContext.types.js.map +1 -0
  25. package/lib/commonjs/components/GlobalContext.web.js +21 -0
  26. package/lib/commonjs/components/GlobalContext.web.js.map +1 -0
  27. package/lib/commonjs/components/RequireSignIn.js +37 -0
  28. package/lib/commonjs/components/RequireSignIn.js.map +1 -0
  29. package/lib/commonjs/components/SignedIn.js +22 -0
  30. package/lib/commonjs/components/SignedIn.js.map +1 -0
  31. package/lib/commonjs/components/SignedOut.js +22 -0
  32. package/lib/commonjs/components/SignedOut.js.map +1 -0
  33. package/lib/commonjs/constants/action.js +11 -0
  34. package/lib/commonjs/constants/action.js.map +1 -0
  35. package/lib/commonjs/hooks/rownd.js +30 -0
  36. package/lib/commonjs/hooks/rownd.js.map +1 -0
  37. package/lib/commonjs/hooks/rownd.web.js +56 -0
  38. package/lib/commonjs/hooks/rownd.web.js.map +1 -0
  39. package/lib/commonjs/index.js +42 -0
  40. package/lib/commonjs/index.js.map +1 -0
  41. package/lib/commonjs/reducer/rowndReducer.js +67 -0
  42. package/lib/commonjs/reducer/rowndReducer.js.map +1 -0
  43. package/lib/commonjs/types.js +2 -0
  44. package/lib/commonjs/types.js.map +1 -0
  45. package/lib/commonjs/utils/config.js +6 -0
  46. package/lib/commonjs/utils/config.js.map +1 -0
  47. package/lib/commonjs/utils/nativeModule.js +70 -0
  48. package/lib/commonjs/utils/nativeModule.js.map +1 -0
  49. package/lib/module/components/GlobalContext.js +64 -0
  50. package/lib/module/components/GlobalContext.js.map +1 -0
  51. package/lib/module/components/GlobalContext.types.js +2 -0
  52. package/lib/module/components/GlobalContext.types.js.map +1 -0
  53. package/lib/module/components/GlobalContext.web.js +14 -0
  54. package/lib/module/components/GlobalContext.web.js.map +1 -0
  55. package/lib/module/components/RequireSignIn.js +30 -0
  56. package/lib/module/components/RequireSignIn.js.map +1 -0
  57. package/lib/module/components/SignedIn.js +15 -0
  58. package/lib/module/components/SignedIn.js.map +1 -0
  59. package/lib/module/components/SignedOut.js +15 -0
  60. package/lib/module/components/SignedOut.js.map +1 -0
  61. package/lib/module/constants/action.js +5 -0
  62. package/lib/module/constants/action.js.map +1 -0
  63. package/lib/module/hooks/rownd.js +24 -0
  64. package/lib/module/hooks/rownd.js.map +1 -0
  65. package/lib/module/hooks/rownd.web.js +50 -0
  66. package/lib/module/hooks/rownd.web.js.map +1 -0
  67. package/lib/module/index.js +7 -0
  68. package/lib/module/index.js.map +1 -0
  69. package/lib/module/reducer/rowndReducer.js +60 -0
  70. package/lib/module/reducer/rowndReducer.js.map +1 -0
  71. package/lib/module/types.js +2 -0
  72. package/lib/module/types.js.map +1 -0
  73. package/lib/module/utils/config.js +2 -0
  74. package/lib/module/utils/config.js.map +1 -0
  75. package/lib/module/utils/nativeModule.js +55 -0
  76. package/lib/module/utils/nativeModule.js.map +1 -0
  77. package/lib/typescript/components/GlobalContext.d.ts +13 -0
  78. package/lib/typescript/components/GlobalContext.types.d.ts +90 -0
  79. package/lib/typescript/components/GlobalContext.web.d.ts +4 -0
  80. package/lib/typescript/components/RequireSignIn.d.ts +9 -0
  81. package/lib/typescript/components/SignedIn.d.ts +6 -0
  82. package/lib/typescript/components/SignedOut.d.ts +6 -0
  83. package/lib/typescript/constants/action.d.ts +7 -0
  84. package/lib/typescript/hooks/rownd.d.ts +31 -0
  85. package/lib/typescript/hooks/rownd.web.d.ts +2 -0
  86. package/lib/typescript/index.d.ts +6 -0
  87. package/lib/typescript/reducer/rowndReducer.d.ts +4 -0
  88. package/lib/typescript/types.d.ts +21 -0
  89. package/lib/typescript/utils/config.d.ts +7 -0
  90. package/lib/typescript/utils/nativeModule.d.ts +14 -0
  91. package/package.json +167 -0
  92. package/rownd-react-native.podspec +38 -0
  93. package/src/components/GlobalContext.tsx +93 -0
  94. package/src/components/GlobalContext.types.ts +109 -0
  95. package/src/components/GlobalContext.web.tsx +17 -0
  96. package/src/components/RequireSignIn.tsx +35 -0
  97. package/src/components/SignedIn.tsx +17 -0
  98. package/src/components/SignedOut.tsx +17 -0
  99. package/src/constants/action.ts +8 -0
  100. package/src/hooks/rownd.ts +68 -0
  101. package/src/hooks/rownd.web.ts +56 -0
  102. package/src/index.tsx +7 -0
  103. package/src/reducer/rowndReducer.ts +63 -0
  104. package/src/types.ts +32 -0
  105. package/src/utils/config.ts +9 -0
  106. package/src/utils/nativeModule.ts +83 -0
@@ -0,0 +1,31 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ @interface RCT_EXTERN_MODULE(RowndPlugin, NSObject)
4
+
5
+
6
+ RCT_EXTERN_METHOD(setUserDataValue:(NSString *)key withValue:(id)value)
7
+ RCT_EXTERN_METHOD(setUserData:(NSDictionary<NSString *, id>)data)
8
+
9
+ RCT_EXTERN_METHOD(configure:(NSDictionary *)config
10
+ withResolver:(RCTPromiseResolveBlock)resolve
11
+ withRejecter:(RCTPromiseRejectBlock)reject)
12
+
13
+ RCT_EXTERN_METHOD(requestSignIn:(NSDictionary *)signInConfig)
14
+
15
+ RCT_EXTERN_METHOD(customizations:(NSDictionary *)customizations)
16
+
17
+ RCT_EXTERN_METHOD(signOut)
18
+
19
+ RCT_EXTERN_METHOD(manageAccount)
20
+
21
+ RCT_EXTERN_METHOD(getAccessToken:(RCTPromiseResolveBlock)resolve
22
+ rejecter:(RCTPromiseRejectBlock)reject)
23
+
24
+ RCT_EXTERN_METHOD(handleSignInLink:(NSString *)url)
25
+
26
+ + (BOOL)requiresMainQueueSetup
27
+ {
28
+ return NO;
29
+ }
30
+
31
+ @end
@@ -0,0 +1,233 @@
1
+ import AnyCodable
2
+ import Combine
3
+ import Lottie
4
+ import Rownd
5
+ import SwiftUI
6
+
7
+ @objc(RowndPlugin)
8
+ class RowndPlugin: NSObject {
9
+
10
+ private var state: ObservableState<RowndState>? = nil
11
+
12
+ private var stateCancellable: AnyCancellable?
13
+
14
+ override init() {
15
+ super.init()
16
+ }
17
+
18
+ deinit {
19
+ // Cancel the state subscription to prevent memory leaks
20
+ stateCancellable?.cancel()
21
+ }
22
+
23
+ @objc(configure:withResolver:withRejecter:)
24
+ func configure(
25
+ config: NSDictionary, resolve: @escaping RCTPromiseResolveBlock,
26
+ reject: @escaping RCTPromiseRejectBlock
27
+ ) {
28
+
29
+ if let hubUrlOverride = config.value(forKey: "hubUrlOverride") as? String {
30
+ Rownd.config.baseUrl = hubUrlOverride
31
+ }
32
+
33
+ if let deepLinkScheme = config.value(forKey: "deepLinkScheme") as? String {
34
+ Rownd.config.deepLinkScheme = deepLinkScheme
35
+ }
36
+
37
+ guard let appKey = config.value(forKey: "appKey") as? String, !appKey.isEmpty else {
38
+ reject("Error", "config.appKey is required", nil)
39
+ return
40
+ }
41
+
42
+ guard let supertokens = config.value(forKey: "supertokens") as? NSDictionary,
43
+ let appInfo = supertokens.value(forKey: "appInfo") as? NSDictionary,
44
+ let apiDomain = appInfo.value(forKey: "apiDomain") as? String,
45
+ !apiDomain.isEmpty else {
46
+ reject("Error", "config.supertokens.appInfo.apiDomain is required", nil)
47
+ return
48
+ }
49
+
50
+ let apiBasePath = appInfo.value(forKey: "apiBasePath") as? String ?? "/auth"
51
+ let appName = appInfo.value(forKey: "appName") as? String ?? "React Native App"
52
+
53
+ Task {
54
+ await Rownd.configure(
55
+ launchOptions: nil,
56
+ appKey: appKey,
57
+ supertokens: RowndSuperTokensConfig(
58
+ appName: appName,
59
+ apiDomain: apiDomain,
60
+ apiBasePath: apiBasePath
61
+ )
62
+ )
63
+
64
+ resolve(appKey)
65
+
66
+ if self.state == nil {
67
+ let initializedState = Rownd.getInstance().state().subscribe { $0 }
68
+ self.state = initializedState
69
+ self.stateCancellable = initializedState.$current.sink { newState in
70
+ do {
71
+ RowndPluginEventEmitter.emitter.sendEvent(
72
+ withName: "update_state", body: try newState.toDictionary())
73
+ } catch {
74
+ print("Failed to encode Rownd state: \(String(describing: error))")
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ @objc(customizations:)
82
+ func customizations(customizations: NSDictionary) {
83
+ let appCustomizations = AppCustomizations()
84
+
85
+ if let sheetBackgroundColor = customizations.value(forKey: "sheetBackgroundHexColor")
86
+ as? String
87
+ {
88
+ appCustomizations.reactNativeSheetBackgroundColor = colorWithHexString(
89
+ hexString: sheetBackgroundColor)
90
+ }
91
+
92
+ if let sheetCornerBorderRadius = customizations.value(forKey: "sheetCornerBorderRadius")
93
+ as? String
94
+ {
95
+ if let doubleValue = Double(sheetCornerBorderRadius) {
96
+ appCustomizations.sheetCornerBorderRadius = CGFloat(doubleValue)
97
+ }
98
+ }
99
+
100
+ if let loadingAnimation = customizations.value(forKey: "loadingAnimation") as? String {
101
+ let json = loadingAnimation.data(using: .utf8)!
102
+ do {
103
+ let decoder = JSONDecoder()
104
+ let animation = try decoder.decode(LottieAnimation.self, from: json)
105
+ appCustomizations.loadingAnimation = animation
106
+ } catch {
107
+ print("Failed to encode Loading Animation: \(error)")
108
+ }
109
+ }
110
+
111
+ Rownd.config.customizations = appCustomizations
112
+ }
113
+
114
+ @objc(requestSignIn:)
115
+ func requestSignIn(signInConfig: NSDictionary) {
116
+
117
+ var rowndSignInOptions = RowndSignInOptions()
118
+
119
+ if let postSignInRedirect = signInConfig.value(forKey: "postSignInRedirect") as? String {
120
+ rowndSignInOptions.postSignInRedirect = postSignInRedirect
121
+ }
122
+
123
+ if let intentString = signInConfig.value(forKey: "intent") as? String {
124
+ if let intent = RowndSignInIntent(rawValue: intentString) {
125
+ rowndSignInOptions.intent = intent
126
+ } else {
127
+ print("Rownd plugin. An incorrect intent type was used: \(intentString)")
128
+ }
129
+ }
130
+
131
+ func requestSignInHub() {
132
+ DispatchQueue.main.async {
133
+ Rownd.requestSignIn(rowndSignInOptions)
134
+ }
135
+ }
136
+ if let method = signInConfig.value(forKey: "method") as? String {
137
+ switch method {
138
+ case "apple":
139
+ DispatchQueue.main.async {
140
+ Rownd.requestSignIn(
141
+ with: RowndSignInHint.appleId, signInOptions: rowndSignInOptions)
142
+ }
143
+ case "google":
144
+ DispatchQueue.main.async {
145
+ Rownd.requestSignIn(
146
+ with: RowndSignInHint.googleId, signInOptions: rowndSignInOptions)
147
+ }
148
+ case "email":
149
+ DispatchQueue.main.async {
150
+ Rownd.requestSignIn(
151
+ with: RowndSignInHint.email, signInOptions: rowndSignInOptions)
152
+ }
153
+ case "phone":
154
+ DispatchQueue.main.async {
155
+ Rownd.requestSignIn(
156
+ with: RowndSignInHint.phone, signInOptions: rowndSignInOptions)
157
+ }
158
+ case "guest":
159
+ DispatchQueue.main.async {
160
+ Rownd.requestSignIn(
161
+ with: RowndSignInHint.guest, signInOptions: rowndSignInOptions)
162
+ }
163
+ case "anonymous":
164
+ DispatchQueue.main.async {
165
+ Rownd.requestSignIn(
166
+ with: RowndSignInHint.anonymous, signInOptions: rowndSignInOptions)
167
+ }
168
+ default:
169
+ requestSignInHub()
170
+ }
171
+ } else {
172
+ requestSignInHub()
173
+ }
174
+ }
175
+
176
+ @objc
177
+ func signOut() {
178
+ DispatchQueue.main.async {
179
+ Rownd.signOut()
180
+ }
181
+ }
182
+
183
+ @objc
184
+ func manageAccount() {
185
+ DispatchQueue.main.async {
186
+ Rownd.manageAccount()
187
+ }
188
+ }
189
+
190
+ @objc(getAccessToken:rejecter:)
191
+ func getAccessToken(
192
+ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
193
+ ) {
194
+ Task {
195
+ do {
196
+ let accessToken = try await Rownd.getAccessToken()
197
+ resolve(accessToken ?? "")
198
+ } catch {
199
+ reject("Error", "\(error)", error)
200
+ }
201
+ }
202
+ }
203
+
204
+ @objc(setUserData:)
205
+ func setUserData(data: [String: Any]) {
206
+ do {
207
+ // Convert to JSON and back to get proper types
208
+ let jsonData = try JSONSerialization.data(withJSONObject: data, options: [])
209
+ let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options: [])
210
+
211
+ // Try to cast to the expected type
212
+ if let dictionary = jsonObject as? [String: Any] {
213
+ // Convert each value to AnyCodable and set individually
214
+ for (key, value) in dictionary {
215
+ Rownd.user.set(field: key, value: AnyCodable(value))
216
+ }
217
+ }
218
+ } catch {
219
+ print("FAILED TO SET USER DATA: ", error)
220
+ }
221
+ }
222
+
223
+ @objc(setUserDataValue:withValue:)
224
+ func setUserDataValue(key: String, value: Any) {
225
+ // Convert value to AnyCodable
226
+ Rownd.user.set(field: key, value: AnyCodable(value))
227
+ }
228
+
229
+ @objc(handleSignInLink:)
230
+ func handleSignInLink(url: String) {
231
+ Rownd.handleSmartLink(url: URL(string: url))
232
+ }
233
+ }
@@ -0,0 +1,12 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(RowndPluginEventEmitter, RCTEventEmitter)
5
+ RCT_EXTERN_METHOD(supportedEvents)
6
+
7
+ + (BOOL)requiresMainQueueSetup
8
+ {
9
+ return YES;
10
+ }
11
+
12
+ @end
@@ -0,0 +1,19 @@
1
+ import Rownd
2
+ import SwiftUI
3
+ import React
4
+
5
+ @objc(RowndPluginEventEmitter)
6
+ class RowndPluginEventEmitter: RCTEventEmitter {
7
+
8
+ public static var emitter: RCTEventEmitter!
9
+
10
+ override init() {
11
+ super.init()
12
+ RowndPluginEventEmitter.emitter = self
13
+ }
14
+
15
+ open override func supportedEvents() -> [String] {
16
+ ["update_state","onReady", "onPending", "onFailure"] // etc.
17
+ }
18
+ }
19
+
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RowndProvider = exports.GlobalContext = void 0;
7
+ exports.useRowndContext = useRowndContext;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactNative = require("react-native");
10
+ var _rowndReducer = require("../reducer/rowndReducer");
11
+ var _nativeModule = _interopRequireWildcard(require("../utils/nativeModule"));
12
+ var NativeRowndModules = _nativeModule;
13
+ var _action = require("../constants/action");
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
+ _reactNative.LogBox.ignoreLogs(['Sending `update_state` with no listeners registered.']);
16
+ _reactNative.LogBox.ignoreLogs(['YellowBox has been replaced with LogBox.']);
17
+ const GlobalContext = exports.GlobalContext = /*#__PURE__*/(0, _react.createContext)(undefined);
18
+ const eventEmitter = new _reactNative.NativeEventEmitter(_nativeModule.IOSRowndEventEmitter || _nativeModule.Rownd);
19
+ const RowndProvider = ({
20
+ children,
21
+ config,
22
+ customizations
23
+ }) => {
24
+ const [state, dispatch] = (0, _react.useReducer)(_rowndReducer.rowndReducer, _rowndReducer.initialRowndState);
25
+ const value = {
26
+ state,
27
+ dispatch
28
+ };
29
+ (0, _react.useEffect)(() => {
30
+ NativeRowndModules.configure(config);
31
+ if (customizations) {
32
+ NativeRowndModules.customizations(customizations);
33
+ }
34
+ }, [config, customizations]);
35
+ (0, _react.useEffect)(() => {
36
+ const onSessionConnect = event => {
37
+ dispatch({
38
+ type: _action.ActionType.UPDATE_STATE,
39
+ payload: _reactNative.Platform.OS === 'android' ? JSON.parse(event.state) : event
40
+ });
41
+ };
42
+ const subscription = eventEmitter.addListener('update_state', onSessionConnect);
43
+ if (!subscription) return;
44
+ return () => {
45
+ subscription.remove();
46
+ };
47
+ }, []);
48
+
49
+ // Handle deep linking
50
+ (0, _react.useEffect)(() => {
51
+ const subscription = _reactNative.Linking.addEventListener('url', event => NativeRowndModules.handleSignInLink(event.url));
52
+ (async () => {
53
+ const initialUrl = await _reactNative.Linking.getInitialURL();
54
+ if (initialUrl) {
55
+ NativeRowndModules.handleSignInLink(initialUrl);
56
+ }
57
+ })();
58
+ return () => subscription.remove();
59
+ }, []);
60
+ return /*#__PURE__*/_react.default.createElement(GlobalContext.Provider, {
61
+ value: value
62
+ }, children);
63
+ };
64
+ exports.RowndProvider = RowndProvider;
65
+ function useRowndContext() {
66
+ const context = (0, _react.useContext)(GlobalContext);
67
+ if (context === undefined) {
68
+ throw new Error('useGlobalContext must be used within a GlobalContext Provider');
69
+ }
70
+ return context;
71
+ }
72
+ //# sourceMappingURL=GlobalContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_rowndReducer","_nativeModule","NativeRowndModules","_action","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","LogBox","ignoreLogs","GlobalContext","exports","createContext","undefined","eventEmitter","NativeEventEmitter","IOSRowndEventEmitter","Rownd","RowndProvider","children","config","customizations","state","dispatch","useReducer","rowndReducer","initialRowndState","value","useEffect","configure","onSessionConnect","event","type","ActionType","UPDATE_STATE","payload","Platform","OS","JSON","parse","subscription","addListener","remove","Linking","addEventListener","handleSignInLink","url","initialUrl","getInitialURL","createElement","Provider","useRowndContext","context","useContext","Error"],"sources":["GlobalContext.tsx"],"sourcesContent":["import React, {\n useReducer,\n createContext,\n FunctionComponent,\n useEffect,\n useContext,\n} from 'react';\nimport { NativeEventEmitter, LogBox, Platform, Linking } from 'react-native';\nimport { initialRowndState, rowndReducer } from '../reducer/rowndReducer';\n\nimport * as NativeRowndModules from '../utils/nativeModule';\nimport { Rownd, IOSRowndEventEmitter } from '../utils/nativeModule';\nimport type { ContextProps, GlobalState } from './GlobalContext.types';\nimport type { TAction } from '../constants/action';\nimport { ActionType } from '../constants/action';\n\nLogBox.ignoreLogs(['Sending `update_state` with no listeners registered.']);\nLogBox.ignoreLogs(['YellowBox has been replaced with LogBox.']);\n\nexport const GlobalContext = createContext<\n { state: GlobalState; dispatch: React.Dispatch<TAction> } | undefined\n>(undefined);\n\nconst eventEmitter = new NativeEventEmitter(IOSRowndEventEmitter || Rownd);\n\nconst RowndProvider: FunctionComponent<ContextProps> = ({\n children,\n config,\n customizations,\n}) => {\n const [state, dispatch] = useReducer(rowndReducer, initialRowndState);\n const value = { state, dispatch };\n\n useEffect(() => {\n NativeRowndModules.configure(config);\n if (customizations) {\n NativeRowndModules.customizations(customizations);\n }\n }, [config, customizations]);\n\n useEffect(() => {\n const onSessionConnect = (event: any) => {\n dispatch({\n type: ActionType.UPDATE_STATE,\n payload: Platform.OS === 'android' ? JSON.parse(event.state) : event,\n });\n };\n const subscription = eventEmitter.addListener(\n 'update_state',\n onSessionConnect\n );\n\n if (!subscription) return;\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n // Handle deep linking\n useEffect(() => {\n const subscription = Linking.addEventListener('url', (event) =>\n NativeRowndModules.handleSignInLink(event.url)\n );\n\n (async () => {\n const initialUrl = await Linking.getInitialURL();\n if (initialUrl) {\n NativeRowndModules.handleSignInLink(initialUrl);\n }\n })();\n\n return () => subscription.remove();\n }, []);\n\n return (\n <GlobalContext.Provider value={value}>{children}</GlobalContext.Provider>\n );\n};\n\nfunction useRowndContext() {\n const context = useContext(GlobalContext);\n\n if (context === undefined) {\n throw new Error(\n 'useGlobalContext must be used within a GlobalContext Provider'\n );\n }\n\n return context;\n}\n\nexport { RowndProvider, useRowndContext };\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAA4D,IAAAI,kBAAA,GAAAD,aAAA;AAI5D,IAAAE,OAAA,GAAAL,OAAA;AAAiD,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,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AAO;AAChB","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=GlobalContext.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["GlobalContext.types.ts"],"sourcesContent":["import type { TAction } from '../constants/action';\nimport type { Customizations, IConfig } from '../utils/config';\n\nexport type ContextProps = {\n config: IConfig;\n customizations?: Customizations;\n children?: React.ReactNode;\n};\n\nexport type Dispatch = (action: TAction) => void;\n\nexport type GlobalState = {\n // is_initializing: boolean;\n // is_container_visible: boolean;\n // use_modal: boolean;\n // nav: {\n // current_route: string;\n // route_trigger: string;\n // event_id: string;\n // section: string;\n // options?: any;\n // };\n user: {\n data: {\n id?: string;\n email?: string | null;\n [key: string]: any;\n };\n isLoading: boolean;\n // needs_refresh?: boolean;\n // redacted: string[];\n };\n auth: {\n access_token: string | null;\n refresh_token?: string | null;\n app_id: string | null;\n init_data?: Record<string, any>;\n is_verified_user?: boolean;\n auth_level?: string | null;\n };\n app: {\n id?: string;\n icon?: string;\n icon_content_type?: string;\n config: AppConfig | null;\n schema: AppSchema | null;\n user_verification_field?: string;\n user_verification_fields?: string[];\n };\n // local_acls: Record<string, { shared: boolean }> | null;\n // is_saving_user_data: boolean;\n config?: IConfig;\n};\n\ntype AppSchema = Record<string, SchemaField>;\n\nexport interface SchemaField {\n display_name: string;\n type: string;\n data_category: string;\n required: boolean;\n owned_by: string;\n user_visible: boolean;\n revoke_after: string;\n required_retention: string;\n collection_justification: string;\n opt_out_warning: string;\n}\n\nexport interface AppConfig {\n customizations: {\n primary_color: string;\n };\n default_user_id_format?: string;\n hub: {\n auth: {\n allow_unverified_users?: boolean;\n additional_fields: [\n {\n name: string;\n type: string;\n label: string;\n placeholder?: string;\n options: [\n {\n value: string;\n label: string;\n }\n ];\n }\n ];\n email: {\n from_address: string;\n image: string;\n };\n show_app_icon: boolean;\n };\n customizations: HubCustomizations;\n };\n}\n\nexport interface HubCustomizations {\n rounded_corners: boolean;\n primary_color: string;\n placement: 'bottom-left' | 'hidden';\n offset_x: number;\n offset_y: number;\n property_overrides: Record<string, string>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RowndProvider = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _rowndReact = require("@supertokens/rownd-react");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const RowndProvider = ({
11
+ children,
12
+ config
13
+ }) => {
14
+ return /*#__PURE__*/_react.default.createElement(_rowndReact.RowndProvider, {
15
+ appKey: config.appKey,
16
+ supertokens: config.supertokens,
17
+ hubUrlOverride: config.hubUrlOverride
18
+ }, children);
19
+ };
20
+ exports.RowndProvider = RowndProvider;
21
+ //# sourceMappingURL=GlobalContext.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_rowndReact","e","__esModule","default","RowndProvider","children","config","createElement","appKey","supertokens","hubUrlOverride","exports"],"sources":["GlobalContext.web.tsx"],"sourcesContent":["import React from 'react';\nimport type { ContextProps } from './GlobalContext.types';\nimport { RowndProvider as RowndReactProvider } from '@supertokens/rownd-react';\n\nconst RowndProvider: React.FC<ContextProps> = ({ children, config }) => {\n return (\n <RowndReactProvider\n appKey={config.appKey}\n supertokens={config.supertokens}\n hubUrlOverride={config.hubUrlOverride}\n >\n {children}\n </RowndReactProvider>\n );\n};\n\nexport { RowndProvider };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAA+E,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/E,MAAMG,aAAqC,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;AAAO,CAAC,KAAK;EACtE,oBACET,MAAA,CAAAM,OAAA,CAAAI,aAAA,CAACP,WAAA,CAAAI,aAAkB;IACjBI,MAAM,EAAEF,MAAM,CAACE,MAAO;IACtBC,WAAW,EAAEH,MAAM,CAACG,WAAY;IAChCC,cAAc,EAAEJ,MAAM,CAACI;EAAe,GAErCL,QACiB,CAAC;AAEzB,CAAC;AAACM,OAAA,CAAAP,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _rownd = require("../hooks/rownd");
9
+ var _reactNative = require("react-native");
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ const RequireSignIn = ({
12
+ children,
13
+ initializing,
14
+ signInProps
15
+ }) => {
16
+ const {
17
+ is_authenticated,
18
+ is_initializing,
19
+ requestSignIn
20
+ } = (0, _rownd.useRownd)();
21
+ (0, _react.useEffect)(() => {
22
+ if (!is_authenticated && !is_initializing) {
23
+ requestSignIn({
24
+ ...(_reactNative.Platform.OS === 'web' ? {
25
+ prevent_closing: true
26
+ } : undefined),
27
+ ...signInProps
28
+ });
29
+ }
30
+ }, [is_authenticated, is_initializing, signInProps, requestSignIn]);
31
+ if (is_initializing && initializing) {
32
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, initializing);
33
+ }
34
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
35
+ };
36
+ var _default = exports.default = RequireSignIn;
37
+ //# sourceMappingURL=RequireSignIn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_rownd","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RequireSignIn","children","initializing","signInProps","is_authenticated","is_initializing","requestSignIn","useRownd","useEffect","Platform","OS","prevent_closing","undefined","createElement","Fragment","_default","exports"],"sources":["RequireSignIn.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useRownd } from '../hooks/rownd';\nimport type { RequestSignIn } from '../types';\nimport { Platform } from 'react-native';\n\nexport type ContextProps = {\n children?: React.ReactNode;\n initializing?: React.ReactNode;\n signInProps?: RequestSignIn;\n};\n\nconst RequireSignIn: React.FC<ContextProps> = ({\n children,\n initializing,\n signInProps,\n}) => {\n const { is_authenticated, is_initializing, requestSignIn } = useRownd();\n\n useEffect(() => {\n if (!is_authenticated && !is_initializing) {\n requestSignIn({\n ...(Platform.OS === 'web' ? { prevent_closing: true } : undefined),\n ...signInProps,\n });\n }\n }, [is_authenticated, is_initializing, signInProps, requestSignIn]);\n\n if (is_initializing && initializing) {\n return <>{initializing}</>;\n }\n\n return <>{children}</>;\n};\n\nexport default RequireSignIn;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AAAwC,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,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CAAC,CAAC;EAEnE,IAAID,eAAe,IAAIH,YAAY,EAAE;IACnC,oBAAO1B,MAAA,CAAAe,OAAA,CAAAsB,aAAA,CAAArC,MAAA,CAAAe,OAAA,CAAAuB,QAAA,QAAGZ,YAAe,CAAC;EAC5B;EAEA,oBAAO1B,MAAA,CAAAe,OAAA,CAAAsB,aAAA,CAAArC,MAAA,CAAAe,OAAA,CAAAuB,QAAA,QAAGb,QAAW,CAAC;AACxB,CAAC;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAzB,OAAA,GAEaS,aAAa","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _rownd = require("../hooks/rownd");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const SignedIn = ({
11
+ children
12
+ }) => {
13
+ const {
14
+ is_authenticated
15
+ } = (0, _rownd.useRownd)();
16
+ if (!is_authenticated) {
17
+ return null;
18
+ }
19
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
20
+ };
21
+ var _default = exports.default = SignedIn;
22
+ //# sourceMappingURL=SignedIn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_rownd","e","__esModule","default","SignedIn","children","is_authenticated","useRownd","createElement","Fragment","_default","exports"],"sources":["SignedIn.tsx"],"sourcesContent":["import React from 'react';\nimport { useRownd } from '../hooks/rownd';\n\ninterface SignedInProps {\n children: React.ReactNode;\n}\n\nconst SignedIn: React.FC<SignedInProps> = ({ children }) => {\n const { is_authenticated } = useRownd();\n\n if (!is_authenticated) {\n return null;\n }\n return <>{children}</>;\n};\n\nexport default SignedIn;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAM1C,MAAMG,QAAiC,GAAGA,CAAC;EAAEC;AAAS,CAAC,KAAK;EAC1D,MAAM;IAAEC;EAAiB,CAAC,GAAG,IAAAC,eAAQ,EAAC,CAAC;EAEvC,IAAI,CAACD,gBAAgB,EAAE;IACrB,OAAO,IAAI;EACb;EACA,oBAAOT,MAAA,CAAAM,OAAA,CAAAK,aAAA,CAAAX,MAAA,CAAAM,OAAA,CAAAM,QAAA,QAAGJ,QAAW,CAAC;AACxB,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEaC,QAAQ","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _rownd = require("../hooks/rownd");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const SignedOut = ({
11
+ children
12
+ }) => {
13
+ const {
14
+ is_authenticated
15
+ } = (0, _rownd.useRownd)();
16
+ if (is_authenticated) {
17
+ return null;
18
+ }
19
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
20
+ };
21
+ var _default = exports.default = SignedOut;
22
+ //# sourceMappingURL=SignedOut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_rownd","e","__esModule","default","SignedOut","children","is_authenticated","useRownd","createElement","Fragment","_default","exports"],"sources":["SignedOut.tsx"],"sourcesContent":["import React from 'react';\nimport { useRownd } from '../hooks/rownd';\n\ninterface SignedOutProps {\n children: React.ReactNode;\n}\n\nconst SignedOut: React.FC<SignedOutProps> = ({ children }) => {\n const { is_authenticated } = useRownd();\n\n if (is_authenticated) {\n return null;\n }\n return <>{children}</>;\n};\n\nexport default SignedOut;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAM1C,MAAMG,SAAmC,GAAGA,CAAC;EAAEC;AAAS,CAAC,KAAK;EAC5D,MAAM;IAAEC;EAAiB,CAAC,GAAG,IAAAC,eAAQ,EAAC,CAAC;EAEvC,IAAID,gBAAgB,EAAE;IACpB,OAAO,IAAI;EACb;EACA,oBAAOT,MAAA,CAAAM,OAAA,CAAAK,aAAA,CAAAX,MAAA,CAAAM,OAAA,CAAAM,QAAA,QAAGJ,QAAW,CAAC;AACxB,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEaC,SAAS","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ActionType = void 0;
7
+ let ActionType = exports.ActionType = /*#__PURE__*/function (ActionType) {
8
+ ActionType["UPDATE_STATE"] = "UPDATE_STATE";
9
+ return ActionType;
10
+ }({});
11
+ //# sourceMappingURL=action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ActionType","exports"],"sources":["action.ts"],"sourcesContent":["export enum ActionType {\n UPDATE_STATE = 'UPDATE_STATE',\n}\n\nexport type TAction = {\n type: ActionType;\n payload?: any;\n};\n"],"mappings":";;;;;;IAAYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useRownd = useRownd;
7
+ var _nativeModule = require("../utils/nativeModule");
8
+ var _GlobalContext = require("../components/GlobalContext");
9
+ function useRownd() {
10
+ const {
11
+ state
12
+ } = (0, _GlobalContext.useRowndContext)();
13
+ return {
14
+ access_token: state.auth.access_token,
15
+ auth: state.auth,
16
+ getAccessToken: _nativeModule.getAccessToken,
17
+ is_authenticated: !!state.auth.access_token,
18
+ is_initializing: !state.auth.app_id,
19
+ manageAccount: _nativeModule.manageAccount,
20
+ requestSignIn: _nativeModule.requestSignIn,
21
+ signOut: _nativeModule.signOut,
22
+ user: {
23
+ data: state.user.data,
24
+ setValue: _nativeModule.setUserDataValue,
25
+ set: _nativeModule.setUserData,
26
+ isLoading: state.user.isLoading
27
+ }
28
+ };
29
+ }
30
+ //# sourceMappingURL=rownd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_nativeModule","require","_GlobalContext","useRownd","state","useRowndContext","access_token","auth","getAccessToken","is_authenticated","is_initializing","app_id","manageAccount","requestSignIn","signOut","user","data","setValue","setUserDataValue","set","setUserData","isLoading"],"sources":["rownd.ts"],"sourcesContent":["import {\n requestSignIn,\n signOut,\n manageAccount,\n getAccessToken,\n setUserDataValue,\n setUserData,\n} from '../utils/nativeModule';\nimport { useRowndContext } from '../components/GlobalContext';\nimport type {\n RequestSignIn,\n RequestSignInMethods,\n RequestSignInIntent,\n} from '../types';\n\nexport type { RequestSignIn, RequestSignInMethods, RequestSignInIntent };\n\nexport type TRowndContext = {\n access_token: string | null;\n auth: AuthContext;\n is_authenticated: boolean;\n is_initializing: boolean;\n getAccessToken: () => Promise<string>;\n manageAccount: () => void;\n requestSignIn: (e?: RequestSignIn) => void;\n signOut: () => void;\n user: UserContext;\n};\n\ntype UserContext = {\n data: {\n user_id?: string;\n email?: string | null;\n phone?: string | null;\n [key: string]: any;\n };\n set: (data: Record<string, any>) => void;\n setValue: (key: string, value: any) => void;\n isLoading: boolean;\n};\n\ntype AuthContext = {\n access_token: string | null;\n app_id: string | null;\n is_verified_user?: boolean;\n auth_level?: string | null;\n};\n\nexport function useRownd(): TRowndContext {\n const { state } = useRowndContext();\n\n return {\n access_token: state.auth.access_token,\n auth: state.auth,\n getAccessToken,\n is_authenticated: !!state.auth.access_token,\n is_initializing: !state.auth.app_id,\n manageAccount,\n requestSignIn,\n signOut,\n user: {\n data: state.user.data,\n setValue: setUserDataValue,\n set: setUserData,\n isLoading: state.user.isLoading,\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAQA,IAAAC,cAAA,GAAAD,OAAA;AAwCO,SAASE,QAAQA,CAAA,EAAkB;EACxC,MAAM;IAAEC;EAAM,CAAC,GAAG,IAAAC,8BAAe,EAAC,CAAC;EAEnC,OAAO;IACLC,YAAY,EAAEF,KAAK,CAACG,IAAI,CAACD,YAAY;IACrCC,IAAI,EAAEH,KAAK,CAACG,IAAI;IAChBC,cAAc,EAAdA,4BAAc;IACdC,gBAAgB,EAAE,CAAC,CAACL,KAAK,CAACG,IAAI,CAACD,YAAY;IAC3CI,eAAe,EAAE,CAACN,KAAK,CAACG,IAAI,CAACI,MAAM;IACnCC,aAAa,EAAbA,2BAAa;IACbC,aAAa,EAAbA,2BAAa;IACbC,OAAO,EAAPA,qBAAO;IACPC,IAAI,EAAE;MACJC,IAAI,EAAEZ,KAAK,CAACW,IAAI,CAACC,IAAI;MACrBC,QAAQ,EAAEC,8BAAgB;MAC1BC,GAAG,EAAEC,yBAAW;MAChBC,SAAS,EAAEjB,KAAK,CAACW,IAAI,CAACM;IACxB;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useRownd = useRownd;
7
+ var _rowndReact = require("@supertokens/rownd-react");
8
+ function toWebSignInOptions(opts) {
9
+ if (!opts) {
10
+ return undefined;
11
+ }
12
+ const method = opts.method === 'guest' ? 'anonymous' : opts.method;
13
+ return {
14
+ ...opts,
15
+ method,
16
+ post_login_redirect: opts.postSignInRedirect
17
+ };
18
+ }
19
+ function useRownd() {
20
+ const {
21
+ requestSignIn,
22
+ signOut,
23
+ getAccessToken,
24
+ is_authenticated,
25
+ is_initializing,
26
+ auth,
27
+ access_token,
28
+ user,
29
+ manageAccount,
30
+ setUser,
31
+ setUserValue
32
+ } = (0, _rowndReact.useRownd)();
33
+ return {
34
+ access_token,
35
+ auth: {
36
+ access_token,
37
+ app_id: auth.app_id || null,
38
+ is_verified_user: auth.is_verified_user,
39
+ auth_level: auth.auth_level
40
+ },
41
+ // @ts-ignore
42
+ getAccessToken,
43
+ is_authenticated,
44
+ is_initializing,
45
+ manageAccount,
46
+ requestSignIn: opts => requestSignIn(toWebSignInOptions(opts)),
47
+ signOut,
48
+ user: {
49
+ data: user.data,
50
+ setValue: setUserValue,
51
+ set: setUser,
52
+ isLoading: Boolean(user.isLoading ?? user.is_loading)
53
+ }
54
+ };
55
+ }
56
+ //# sourceMappingURL=rownd.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rowndReact","require","toWebSignInOptions","opts","undefined","method","post_login_redirect","postSignInRedirect","useRownd","requestSignIn","signOut","getAccessToken","is_authenticated","is_initializing","auth","access_token","user","manageAccount","setUser","setUserValue","useReactRownd","app_id","is_verified_user","auth_level","data","setValue","set","isLoading","Boolean","is_loading"],"sources":["rownd.web.ts"],"sourcesContent":["import { useRownd as useReactRownd } from '@supertokens/rownd-react';\nimport type { TRowndContext } from './rownd';\nimport type { RequestSignIn } from '../types';\n\nfunction toWebSignInOptions(opts?: RequestSignIn) {\n if (!opts) {\n return undefined;\n }\n\n const method = opts.method === 'guest' ? 'anonymous' : opts.method;\n\n return {\n ...opts,\n method,\n post_login_redirect: opts.postSignInRedirect,\n };\n}\n\nexport function useRownd(): TRowndContext {\n const {\n requestSignIn,\n signOut,\n getAccessToken,\n is_authenticated,\n is_initializing,\n auth,\n access_token,\n user,\n manageAccount,\n setUser,\n setUserValue,\n } = useReactRownd() as any;\n\n return {\n access_token,\n auth: {\n access_token,\n app_id: auth.app_id || null,\n is_verified_user: auth.is_verified_user,\n auth_level: auth.auth_level,\n },\n // @ts-ignore\n getAccessToken,\n is_authenticated,\n is_initializing,\n manageAccount,\n requestSignIn: (opts) => requestSignIn(toWebSignInOptions(opts)),\n signOut,\n user: {\n data: user.data,\n setValue: setUserValue,\n set: setUser,\n isLoading: Boolean(user.isLoading ?? user.is_loading),\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAIA,SAASC,kBAAkBA,CAACC,IAAoB,EAAE;EAChD,IAAI,CAACA,IAAI,EAAE;IACT,OAAOC,SAAS;EAClB;EAEA,MAAMC,MAAM,GAAGF,IAAI,CAACE,MAAM,KAAK,OAAO,GAAG,WAAW,GAAGF,IAAI,CAACE,MAAM;EAElE,OAAO;IACL,GAAGF,IAAI;IACPE,MAAM;IACNC,mBAAmB,EAAEH,IAAI,CAACI;EAC5B,CAAC;AACH;AAEO,SAASC,QAAQA,CAAA,EAAkB;EACxC,MAAM;IACJC,aAAa;IACbC,OAAO;IACPC,cAAc;IACdC,gBAAgB;IAChBC,eAAe;IACfC,IAAI;IACJC,YAAY;IACZC,IAAI;IACJC,aAAa;IACbC,OAAO;IACPC;EACF,CAAC,GAAG,IAAAC,oBAAa,EAAC,CAAQ;EAE1B,OAAO;IACLL,YAAY;IACZD,IAAI,EAAE;MACJC,YAAY;MACZM,MAAM,EAAEP,IAAI,CAACO,MAAM,IAAI,IAAI;MAC3BC,gBAAgB,EAAER,IAAI,CAACQ,gBAAgB;MACvCC,UAAU,EAAET,IAAI,CAACS;IACnB,CAAC;IACD;IACAZ,cAAc;IACdC,gBAAgB;IAChBC,eAAe;IACfI,aAAa;IACbR,aAAa,EAAGN,IAAI,IAAKM,aAAa,CAACP,kBAAkB,CAACC,IAAI,CAAC,CAAC;IAChEO,OAAO;IACPM,IAAI,EAAE;MACJQ,IAAI,EAAER,IAAI,CAACQ,IAAI;MACfC,QAAQ,EAAEN,YAAY;MACtBO,GAAG,EAAER,OAAO;MACZS,SAAS,EAAEC,OAAO,CAACZ,IAAI,CAACW,SAAS,IAAIX,IAAI,CAACa,UAAU;IACtD;EACF,CAAC;AACH","ignoreList":[]}