@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,55 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ export const LINKING_ERROR = `The package '@supertokens/rownd-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
+ ios: "- You have run 'pod install'\n",
4
+ default: ''
5
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
6
+ export const Rownd = NativeModules.RowndPlugin ? NativeModules.RowndPlugin : new Proxy({}, {
7
+ get() {
8
+ throw new Error(LINKING_ERROR);
9
+ }
10
+ });
11
+ export const IOSRowndEventEmitter = Platform.OS !== 'ios' ? null : NativeModules.RowndPluginEventEmitter ? NativeModules.RowndPluginEventEmitter : new Proxy({}, {
12
+ get() {
13
+ throw new Error(LINKING_ERROR);
14
+ }
15
+ });
16
+ export function configure(config) {
17
+ return Rownd.configure(config);
18
+ }
19
+ export function customizations(customizationConfig) {
20
+ return Rownd.customizations(customizationConfig);
21
+ }
22
+ export function requestSignIn(config) {
23
+ const method = (config === null || config === void 0 ? void 0 : config.method) === 'guest' ? 'anonymous' : config === null || config === void 0 ? void 0 : config.method;
24
+ if (!config) {
25
+ return Rownd.requestSignIn({
26
+ method: 'default'
27
+ });
28
+ }
29
+ return Rownd.requestSignIn({
30
+ method: method || 'default',
31
+ postSignInRedirect: config === null || config === void 0 ? void 0 : config.postSignInRedirect,
32
+ intent: config === null || config === void 0 ? void 0 : config.intent
33
+ });
34
+ }
35
+ export function signOut() {
36
+ return Rownd.signOut();
37
+ }
38
+ export function manageAccount() {
39
+ return Rownd.manageAccount();
40
+ }
41
+ export function getAccessToken() {
42
+ return Rownd.getAccessToken();
43
+ }
44
+ export function setUserDataValue(key, value) {
45
+ return Rownd.setUserDataValue(key, Platform.OS === 'android' ? {
46
+ value
47
+ } : value);
48
+ }
49
+ export function setUserData(data) {
50
+ return Rownd.setUserData(data);
51
+ }
52
+ export function handleSignInLink(url) {
53
+ return Rownd.handleSignInLink(url);
54
+ }
55
+ //# sourceMappingURL=nativeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Rownd","RowndPlugin","Proxy","get","Error","IOSRowndEventEmitter","OS","RowndPluginEventEmitter","configure","config","customizations","customizationConfig","requestSignIn","method","postSignInRedirect","intent","signOut","manageAccount","getAccessToken","setUserDataValue","key","value","setUserData","data","handleSignInLink","url"],"sources":["nativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport type { RequestSignIn } from '../types';\nimport type { Customizations, IConfig } from './config';\n\nexport const LINKING_ERROR =\n `The package '@supertokens/rownd-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nexport const Rownd = NativeModules.RowndPlugin\n ? NativeModules.RowndPlugin\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const IOSRowndEventEmitter =\n Platform.OS !== 'ios'\n ? null\n : NativeModules.RowndPluginEventEmitter\n ? NativeModules.RowndPluginEventEmitter\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport function configure(config: IConfig): Promise<string> {\n return Rownd.configure(config);\n}\n\nexport function customizations(customizationConfig: Customizations) {\n return Rownd.customizations(customizationConfig);\n}\n\nexport function requestSignIn(config?: RequestSignIn) {\n const method = config?.method === 'guest' ? 'anonymous' : config?.method;\n\n if (!config) {\n return Rownd.requestSignIn({ method: 'default' });\n }\n\n return Rownd.requestSignIn({\n method: method || 'default',\n postSignInRedirect: config?.postSignInRedirect,\n intent: config?.intent,\n });\n}\n\nexport function signOut() {\n return Rownd.signOut();\n}\n\nexport function manageAccount() {\n return Rownd.manageAccount();\n}\n\nexport function getAccessToken(): Promise<string> {\n return Rownd.getAccessToken();\n}\n\nexport function setUserDataValue(key: string, value: any) {\n return Rownd.setUserDataValue(\n key,\n Platform.OS === 'android' ? { value } : value\n );\n}\n\nexport function setUserData(data: Record<string, any>) {\n return Rownd.setUserData(data);\n}\n\nexport function handleSignInLink(url: string) {\n return Rownd.handleSignInLink(url);\n}\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAItD,OAAO,MAAMC,aAAa,GACxB,0FAA0F,GAC1FD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,OAAO,MAAMC,KAAK,GAAGN,aAAa,CAACO,WAAW,GAC1CP,aAAa,CAACO,WAAW,GACzB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMS,oBAAoB,GAC/BV,QAAQ,CAACW,EAAE,KAAK,KAAK,GACjB,IAAI,GACJZ,aAAa,CAACa,uBAAuB,GACrCb,aAAa,CAACa,uBAAuB,GACrC,IAAIL,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEP,OAAO,SAASY,SAASA,CAACC,MAAe,EAAmB;EAC1D,OAAOT,KAAK,CAACQ,SAAS,CAACC,MAAM,CAAC;AAChC;AAEA,OAAO,SAASC,cAAcA,CAACC,mBAAmC,EAAE;EAClE,OAAOX,KAAK,CAACU,cAAc,CAACC,mBAAmB,CAAC;AAClD;AAEA,OAAO,SAASC,aAAaA,CAACH,MAAsB,EAAE;EACpD,MAAMI,MAAM,GAAG,CAAAJ,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEI,MAAM,MAAK,OAAO,GAAG,WAAW,GAAGJ,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEI,MAAM;EAExE,IAAI,CAACJ,MAAM,EAAE;IACX,OAAOT,KAAK,CAACY,aAAa,CAAC;MAAEC,MAAM,EAAE;IAAU,CAAC,CAAC;EACnD;EAEA,OAAOb,KAAK,CAACY,aAAa,CAAC;IACzBC,MAAM,EAAEA,MAAM,IAAI,SAAS;IAC3BC,kBAAkB,EAAEL,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEK,kBAAkB;IAC9CC,MAAM,EAAEN,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEM;EAClB,CAAC,CAAC;AACJ;AAEA,OAAO,SAASC,OAAOA,CAAA,EAAG;EACxB,OAAOhB,KAAK,CAACgB,OAAO,CAAC,CAAC;AACxB;AAEA,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC9B,OAAOjB,KAAK,CAACiB,aAAa,CAAC,CAAC;AAC9B;AAEA,OAAO,SAASC,cAAcA,CAAA,EAAoB;EAChD,OAAOlB,KAAK,CAACkB,cAAc,CAAC,CAAC;AAC/B;AAEA,OAAO,SAASC,gBAAgBA,CAACC,GAAW,EAAEC,KAAU,EAAE;EACxD,OAAOrB,KAAK,CAACmB,gBAAgB,CAC3BC,GAAG,EACHzB,QAAQ,CAACW,EAAE,KAAK,SAAS,GAAG;IAAEe;EAAM,CAAC,GAAGA,KAC1C,CAAC;AACH;AAEA,OAAO,SAASC,WAAWA,CAACC,IAAyB,EAAE;EACrD,OAAOvB,KAAK,CAACsB,WAAW,CAACC,IAAI,CAAC;AAChC;AAEA,OAAO,SAASC,gBAAgBA,CAACC,GAAW,EAAE;EAC5C,OAAOzB,KAAK,CAACwB,gBAAgB,CAACC,GAAG,CAAC;AACpC","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ import React, { FunctionComponent } from 'react';
2
+ import type { ContextProps, GlobalState } from './GlobalContext.types';
3
+ import type { TAction } from '../constants/action';
4
+ export declare const GlobalContext: React.Context<{
5
+ state: GlobalState;
6
+ dispatch: React.Dispatch<TAction>;
7
+ } | undefined>;
8
+ declare const RowndProvider: FunctionComponent<ContextProps>;
9
+ declare function useRowndContext(): {
10
+ state: GlobalState;
11
+ dispatch: React.Dispatch<TAction>;
12
+ };
13
+ export { RowndProvider, useRowndContext };
@@ -0,0 +1,90 @@
1
+ /// <reference types="react" />
2
+ import type { TAction } from '../constants/action';
3
+ import type { Customizations, IConfig } from '../utils/config';
4
+ export declare type ContextProps = {
5
+ config: IConfig;
6
+ customizations?: Customizations;
7
+ children?: React.ReactNode;
8
+ };
9
+ export declare type Dispatch = (action: TAction) => void;
10
+ export declare type GlobalState = {
11
+ user: {
12
+ data: {
13
+ id?: string;
14
+ email?: string | null;
15
+ [key: string]: any;
16
+ };
17
+ isLoading: boolean;
18
+ };
19
+ auth: {
20
+ access_token: string | null;
21
+ refresh_token?: string | null;
22
+ app_id: string | null;
23
+ init_data?: Record<string, any>;
24
+ is_verified_user?: boolean;
25
+ auth_level?: string | null;
26
+ };
27
+ app: {
28
+ id?: string;
29
+ icon?: string;
30
+ icon_content_type?: string;
31
+ config: AppConfig | null;
32
+ schema: AppSchema | null;
33
+ user_verification_field?: string;
34
+ user_verification_fields?: string[];
35
+ };
36
+ config?: IConfig;
37
+ };
38
+ declare type AppSchema = Record<string, SchemaField>;
39
+ export interface SchemaField {
40
+ display_name: string;
41
+ type: string;
42
+ data_category: string;
43
+ required: boolean;
44
+ owned_by: string;
45
+ user_visible: boolean;
46
+ revoke_after: string;
47
+ required_retention: string;
48
+ collection_justification: string;
49
+ opt_out_warning: string;
50
+ }
51
+ export interface AppConfig {
52
+ customizations: {
53
+ primary_color: string;
54
+ };
55
+ default_user_id_format?: string;
56
+ hub: {
57
+ auth: {
58
+ allow_unverified_users?: boolean;
59
+ additional_fields: [
60
+ {
61
+ name: string;
62
+ type: string;
63
+ label: string;
64
+ placeholder?: string;
65
+ options: [
66
+ {
67
+ value: string;
68
+ label: string;
69
+ }
70
+ ];
71
+ }
72
+ ];
73
+ email: {
74
+ from_address: string;
75
+ image: string;
76
+ };
77
+ show_app_icon: boolean;
78
+ };
79
+ customizations: HubCustomizations;
80
+ };
81
+ }
82
+ export interface HubCustomizations {
83
+ rounded_corners: boolean;
84
+ primary_color: string;
85
+ placement: 'bottom-left' | 'hidden';
86
+ offset_x: number;
87
+ offset_y: number;
88
+ property_overrides: Record<string, string>;
89
+ }
90
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { ContextProps } from './GlobalContext.types';
3
+ declare const RowndProvider: React.FC<ContextProps>;
4
+ export { RowndProvider };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { RequestSignIn } from '../types';
3
+ export declare type ContextProps = {
4
+ children?: React.ReactNode;
5
+ initializing?: React.ReactNode;
6
+ signInProps?: RequestSignIn;
7
+ };
8
+ declare const RequireSignIn: React.FC<ContextProps>;
9
+ export default RequireSignIn;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface SignedInProps {
3
+ children: React.ReactNode;
4
+ }
5
+ declare const SignedIn: React.FC<SignedInProps>;
6
+ export default SignedIn;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface SignedOutProps {
3
+ children: React.ReactNode;
4
+ }
5
+ declare const SignedOut: React.FC<SignedOutProps>;
6
+ export default SignedOut;
@@ -0,0 +1,7 @@
1
+ export declare enum ActionType {
2
+ UPDATE_STATE = "UPDATE_STATE"
3
+ }
4
+ export declare type TAction = {
5
+ type: ActionType;
6
+ payload?: any;
7
+ };
@@ -0,0 +1,31 @@
1
+ import type { RequestSignIn, RequestSignInMethods, RequestSignInIntent } from '../types';
2
+ export type { RequestSignIn, RequestSignInMethods, RequestSignInIntent };
3
+ export declare type TRowndContext = {
4
+ access_token: string | null;
5
+ auth: AuthContext;
6
+ is_authenticated: boolean;
7
+ is_initializing: boolean;
8
+ getAccessToken: () => Promise<string>;
9
+ manageAccount: () => void;
10
+ requestSignIn: (e?: RequestSignIn) => void;
11
+ signOut: () => void;
12
+ user: UserContext;
13
+ };
14
+ declare type UserContext = {
15
+ data: {
16
+ user_id?: string;
17
+ email?: string | null;
18
+ phone?: string | null;
19
+ [key: string]: any;
20
+ };
21
+ set: (data: Record<string, any>) => void;
22
+ setValue: (key: string, value: any) => void;
23
+ isLoading: boolean;
24
+ };
25
+ declare type AuthContext = {
26
+ access_token: string | null;
27
+ app_id: string | null;
28
+ is_verified_user?: boolean;
29
+ auth_level?: string | null;
30
+ };
31
+ export declare function useRownd(): TRowndContext;
@@ -0,0 +1,2 @@
1
+ import type { TRowndContext } from './rownd';
2
+ export declare function useRownd(): TRowndContext;
@@ -0,0 +1,6 @@
1
+ import { RowndProvider } from './components/GlobalContext';
2
+ import { useRownd } from './hooks/rownd';
3
+ import RequireSignIn from './components/RequireSignIn';
4
+ import SignedIn from './components/SignedIn';
5
+ import SignedOut from './components/SignedOut';
6
+ export { RowndProvider, useRownd, RequireSignIn, SignedIn, SignedOut };
@@ -0,0 +1,4 @@
1
+ import type { GlobalState } from '../components/GlobalContext.types';
2
+ import { TAction } from '../constants/action';
3
+ export declare const initialRowndState: GlobalState;
4
+ export declare function rowndReducer(state: GlobalState, action: TAction): GlobalState;
@@ -0,0 +1,21 @@
1
+ export declare type SuperTokensConfig = {
2
+ appInfo: {
3
+ appName?: string;
4
+ apiDomain: string;
5
+ apiBasePath?: string;
6
+ };
7
+ };
8
+ export declare type RowndProviderConfig = {
9
+ appKey: string;
10
+ supertokens: SuperTokensConfig;
11
+ hubUrlOverride?: string;
12
+ deepLinkScheme?: string;
13
+ };
14
+ export declare type RequestSignInMethods = 'default' | 'email' | 'phone' | 'google' | 'apple' | 'anonymous' | 'guest';
15
+ export declare type RequestSignInIntent = 'sign_in' | 'sign_up';
16
+ export declare type RequestSignIn = {
17
+ method?: RequestSignInMethods;
18
+ postSignInRedirect?: string;
19
+ intent?: RequestSignInIntent;
20
+ prevent_closing?: boolean;
21
+ };
@@ -0,0 +1,7 @@
1
+ import type { RowndProviderConfig } from '../types';
2
+ export declare type IConfig = RowndProviderConfig;
3
+ export interface Customizations {
4
+ sheetBackgroundHexColor?: string;
5
+ sheetCornerBorderRadius?: string;
6
+ loadingAnimation?: string;
7
+ }
@@ -0,0 +1,14 @@
1
+ import type { RequestSignIn } from '../types';
2
+ import type { Customizations, IConfig } from './config';
3
+ export declare const LINKING_ERROR: string;
4
+ export declare const Rownd: any;
5
+ export declare const IOSRowndEventEmitter: any;
6
+ export declare function configure(config: IConfig): Promise<string>;
7
+ export declare function customizations(customizationConfig: Customizations): any;
8
+ export declare function requestSignIn(config?: RequestSignIn): any;
9
+ export declare function signOut(): any;
10
+ export declare function manageAccount(): any;
11
+ export declare function getAccessToken(): Promise<string>;
12
+ export declare function setUserDataValue(key: string, value: any): any;
13
+ export declare function setUserData(data: Record<string, any>): any;
14
+ export declare function handleSignInLink(url: string): any;
package/package.json ADDED
@@ -0,0 +1,167 @@
1
+ {
2
+ "name": "@supertokens/rownd-react-native",
3
+ "version": "0.1.0",
4
+ "description": "test",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "rownd-react-native.podspec",
17
+ "expo",
18
+ "app.plugin.js",
19
+ "!lib/typescript/example",
20
+ "!android/build",
21
+ "!android/.gradle",
22
+ "!ios/build",
23
+ "!**/__tests__",
24
+ "!**/__fixtures__",
25
+ "!**/__mocks__"
26
+ ],
27
+ "scripts": {
28
+ "test": "jest",
29
+ "typescript": "tsc --noEmit",
30
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
31
+ "prepare": "bob build",
32
+ "release": "release-it",
33
+ "example": "yarn --cwd example",
34
+ "example:server": "node example-server/server.mjs",
35
+ "bootstrap": "yarn example && yarn && yarn example pods",
36
+ "test:integration:harness": "cd ../supertokens-rownd-android && npm run test:integration:harness",
37
+ "test:integration:android:build": "cd example/android && ./gradlew :app:assembleDebugAndroidTest",
38
+ "test:integration:android": "cd ../supertokens-rownd-android && npx tsx ../supertokens-rownd-react-native/test-server/with-harness.ts -- sh -c 'cd ../supertokens-rownd-react-native/example/android && ./gradlew :app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.harnessUrl=$ANDROID_HARNESS_URL'"
39
+ },
40
+ "keywords": [
41
+ "react-native",
42
+ "ios",
43
+ "android"
44
+ ],
45
+ "repository": "https://github.com/rownd/react-native",
46
+ "author": "rownd <michael@rownd.io> (https://github.com/rownd/react-native)",
47
+ "license": "MIT",
48
+ "bugs": {
49
+ "url": "https://github.com/rownd/react-native"
50
+ },
51
+ "homepage": "https://github.com/rownd/react-native",
52
+ "publishConfig": {
53
+ "access": "public",
54
+ "registry": "https://registry.npmjs.org/"
55
+ },
56
+ "devDependencies": {
57
+ "@arkweid/lefthook": "^0.7.7",
58
+ "@babel/eslint-parser": "^7.18.2",
59
+ "@commitlint/config-conventional": "^17.0.2",
60
+ "@react-native-community/eslint-config": "^3.0.2",
61
+ "@release-it/conventional-changelog": "^5.0.0",
62
+ "@supertokens-plugins/rownd-nodejs": "0.5.0",
63
+ "@types/jest": "^28.1.2",
64
+ "@types/react": "17.0.21",
65
+ "@types/react-native": "0.68.0",
66
+ "@types/react-test-renderer": "^17.0.2",
67
+ "commitlint": "^17.0.2",
68
+ "cors": "^2.8.5",
69
+ "eslint": "^8.4.1",
70
+ "eslint-config-prettier": "^8.5.0",
71
+ "eslint-plugin-prettier": "^4.0.0",
72
+ "express": "^5.1.0",
73
+ "expo": "~52.0.0",
74
+ "jest": "^28.1.1",
75
+ "pod-install": "^0.1.0",
76
+ "prettier": "^2.0.5",
77
+ "react": "17.0.2",
78
+ "react-dom": "17.0.2",
79
+ "react-native": "0.68.2",
80
+ "react-native-builder-bob": "^0.18.3",
81
+ "react-test-renderer": "17.0.2",
82
+ "release-it": "^15.0.0",
83
+ "supertokens-node": "^24.0.2",
84
+ "typescript": "^4.5.2"
85
+ },
86
+ "resolutions": {
87
+ "@types/react": "17.0.21"
88
+ },
89
+ "peerDependencies": {
90
+ "react": "*",
91
+ "react-native": "*"
92
+ },
93
+ "commitlint": {
94
+ "extends": [
95
+ "@commitlint/config-conventional"
96
+ ]
97
+ },
98
+ "release-it": {
99
+ "git": {
100
+ "commitMessage": "chore: release ${version}",
101
+ "tagName": "v${version}"
102
+ },
103
+ "npm": {
104
+ "publish": true,
105
+ "publishArgs": [
106
+ "--auth-type=web"
107
+ ]
108
+ },
109
+ "github": {
110
+ "release": true
111
+ },
112
+ "plugins": {
113
+ "@release-it/conventional-changelog": {
114
+ "preset": "angular"
115
+ }
116
+ }
117
+ },
118
+ "eslintConfig": {
119
+ "root": true,
120
+ "parser": "@babel/eslint-parser",
121
+ "extends": [
122
+ "@react-native-community",
123
+ "prettier"
124
+ ],
125
+ "rules": {
126
+ "prettier/prettier": [
127
+ "error",
128
+ {
129
+ "quoteProps": "consistent",
130
+ "singleQuote": true,
131
+ "tabWidth": 2,
132
+ "trailingComma": "es5",
133
+ "useTabs": false
134
+ }
135
+ ],
136
+ "@typescript-eslint/no-unused-vars": "off"
137
+ }
138
+ },
139
+ "eslintIgnore": [
140
+ "node_modules/",
141
+ "lib/"
142
+ ],
143
+ "prettier": {
144
+ "quoteProps": "consistent",
145
+ "singleQuote": true,
146
+ "tabWidth": 2,
147
+ "trailingComma": "es5",
148
+ "useTabs": false
149
+ },
150
+ "react-native-builder-bob": {
151
+ "source": "src",
152
+ "output": "lib",
153
+ "targets": [
154
+ "commonjs",
155
+ "module",
156
+ [
157
+ "typescript",
158
+ {
159
+ "project": "tsconfig.build.json"
160
+ }
161
+ ]
162
+ ]
163
+ },
164
+ "dependencies": {
165
+ "@supertokens/rownd-react": "0.1.0"
166
+ }
167
+ }
@@ -0,0 +1,38 @@
1
+ require "json"
2
+
3
+ unless defined?(install_modules_dependencies)
4
+ absolute_react_native_path = File.dirname(`node --print "require.resolve('react-native/package.json')"`)
5
+ require File.join(absolute_react_native_path, "scripts/react_native_pods")
6
+ end
7
+
8
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
9
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
10
+
11
+ Pod::Spec.new do |s|
12
+ s.name = "rownd-react-native"
13
+ s.version = package["version"]
14
+ s.summary = package["description"]
15
+ s.homepage = package["homepage"]
16
+ s.license = package["license"]
17
+ s.authors = package["author"]
18
+
19
+ s.platforms = { :ios => "14.0" }
20
+ s.source = { :git => "https://rownd.io/.git", :tag => "#{s.version}" }
21
+
22
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
23
+
24
+ s.dependency "React-Core"
25
+ s.dependency "RowndSupertokens", "~> 0.1.1"
26
+ s.dependency "lottie-ios", "~> 4.5.0"
27
+
28
+ # Use install_modules_dependencies to properly handle New Architecture dependencies
29
+ # See: https://github.com/react-native-community/discussions-and-proposals/discussions/912
30
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
31
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
32
+ s.pod_target_xcconfig = {
33
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
34
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
35
+ }
36
+ install_modules_dependencies(s)
37
+ end
38
+ end
@@ -0,0 +1,93 @@
1
+ import React, {
2
+ useReducer,
3
+ createContext,
4
+ FunctionComponent,
5
+ useEffect,
6
+ useContext,
7
+ } from 'react';
8
+ import { NativeEventEmitter, LogBox, Platform, Linking } from 'react-native';
9
+ import { initialRowndState, rowndReducer } from '../reducer/rowndReducer';
10
+
11
+ import * as NativeRowndModules from '../utils/nativeModule';
12
+ import { Rownd, IOSRowndEventEmitter } from '../utils/nativeModule';
13
+ import type { ContextProps, GlobalState } from './GlobalContext.types';
14
+ import type { TAction } from '../constants/action';
15
+ import { ActionType } from '../constants/action';
16
+
17
+ LogBox.ignoreLogs(['Sending `update_state` with no listeners registered.']);
18
+ LogBox.ignoreLogs(['YellowBox has been replaced with LogBox.']);
19
+
20
+ export const GlobalContext = createContext<
21
+ { state: GlobalState; dispatch: React.Dispatch<TAction> } | undefined
22
+ >(undefined);
23
+
24
+ const eventEmitter = new NativeEventEmitter(IOSRowndEventEmitter || Rownd);
25
+
26
+ const RowndProvider: FunctionComponent<ContextProps> = ({
27
+ children,
28
+ config,
29
+ customizations,
30
+ }) => {
31
+ const [state, dispatch] = useReducer(rowndReducer, initialRowndState);
32
+ const value = { state, dispatch };
33
+
34
+ useEffect(() => {
35
+ NativeRowndModules.configure(config);
36
+ if (customizations) {
37
+ NativeRowndModules.customizations(customizations);
38
+ }
39
+ }, [config, customizations]);
40
+
41
+ useEffect(() => {
42
+ const onSessionConnect = (event: any) => {
43
+ dispatch({
44
+ type: ActionType.UPDATE_STATE,
45
+ payload: Platform.OS === 'android' ? JSON.parse(event.state) : event,
46
+ });
47
+ };
48
+ const subscription = eventEmitter.addListener(
49
+ 'update_state',
50
+ onSessionConnect
51
+ );
52
+
53
+ if (!subscription) return;
54
+
55
+ return () => {
56
+ subscription.remove();
57
+ };
58
+ }, []);
59
+
60
+ // Handle deep linking
61
+ useEffect(() => {
62
+ const subscription = Linking.addEventListener('url', (event) =>
63
+ NativeRowndModules.handleSignInLink(event.url)
64
+ );
65
+
66
+ (async () => {
67
+ const initialUrl = await Linking.getInitialURL();
68
+ if (initialUrl) {
69
+ NativeRowndModules.handleSignInLink(initialUrl);
70
+ }
71
+ })();
72
+
73
+ return () => subscription.remove();
74
+ }, []);
75
+
76
+ return (
77
+ <GlobalContext.Provider value={value}>{children}</GlobalContext.Provider>
78
+ );
79
+ };
80
+
81
+ function useRowndContext() {
82
+ const context = useContext(GlobalContext);
83
+
84
+ if (context === undefined) {
85
+ throw new Error(
86
+ 'useGlobalContext must be used within a GlobalContext Provider'
87
+ );
88
+ }
89
+
90
+ return context;
91
+ }
92
+
93
+ export { RowndProvider, useRowndContext };