@brightlayer-ui/react-native-template-authentication-typescript 2.1.0 → 3.0.0-alpha.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.
- package/README.md +22 -17
- package/package.json +3 -3
- package/template/.bundle/config +2 -0
- package/template/.eslintrc.js +57 -0
- package/template/.prettierrc.js +7 -0
- package/template/.watchmanconfig +1 -0
- package/template/App.tsx +85 -47
- package/template/Gemfile +9 -0
- package/template/Gemfile.lock +105 -0
- package/template/README.md +79 -0
- package/template/__tests__/App.test.tsx +17 -0
- package/template/android/app/build.gradle +120 -0
- package/template/android/app/debug.keystore +0 -0
- package/template/android/app/proguard-rules.pro +10 -0
- package/template/android/app/src/debug/AndroidManifest.xml +9 -0
- package/template/android/app/src/main/AndroidManifest.xml +25 -0
- package/template/android/app/src/main/java/com/workflow/MainActivity.kt +28 -0
- package/template/android/app/src/main/java/com/workflow/MainApplication.kt +43 -0
- package/template/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/values/strings.xml +3 -0
- package/template/android/app/src/main/res/values/styles.xml +9 -0
- package/template/android/build.gradle +21 -0
- package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/template/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/template/android/gradle.properties +41 -0
- package/template/android/gradlew +249 -0
- package/template/android/gradlew.bat +92 -0
- package/template/android/link-assets-manifest.json +25 -0
- package/template/android/settings.gradle +4 -0
- package/template/app.json +4 -0
- package/template/assets/fonts/OpenSans-Bold.ttf +0 -0
- package/template/assets/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/template/assets/fonts/OpenSans-Light.ttf +0 -0
- package/template/assets/fonts/OpenSans-Regular.ttf +0 -0
- package/template/assets/fonts/OpenSans-SemiBold.ttf +0 -0
- package/template/assets/images/Logo.png +0 -0
- package/template/babel.config.js +1 -2
- package/template/eslint.config.mjs +10 -0
- package/template/index.js +11 -0
- package/template/ios/.xcode.env +11 -0
- package/template/ios/Podfile +40 -0
- package/template/ios/Podfile.lock +1496 -0
- package/template/ios/blankTemplate/AppDelegate.h +6 -0
- package/template/ios/blankTemplate/AppDelegate.mm +31 -0
- package/template/ios/blankTemplate/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/template/ios/blankTemplate/Images.xcassets/Contents.json +6 -0
- package/template/ios/blankTemplate/Info.plist +75 -0
- package/template/ios/blankTemplate/LaunchScreen.storyboard +47 -0
- package/template/ios/blankTemplate/PrivacyInfo.xcprivacy +37 -0
- package/template/ios/blankTemplate/main.m +10 -0
- package/template/ios/blankTemplate.xcodeproj/project.pbxproj +741 -0
- package/template/ios/blankTemplate.xcodeproj/xcshareddata/xcschemes/blankTemplate.xcscheme +88 -0
- package/template/ios/blankTemplate.xcworkspace/contents.xcworkspacedata +10 -0
- package/template/ios/blankTemplate.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/template/ios/blankTemplateTests/Info.plist +24 -0
- package/template/ios/blankTemplateTests/blankTemplateTests.m +66 -0
- package/template/ios/link-assets-manifest.json +25 -0
- package/template/jest.config.js +3 -0
- package/template/metro.config.js +7 -25
- package/template/package.json +70 -0
- package/template/src/actions/AuthUIActions.tsx +10 -11
- package/template/src/actions/RegistrationUIActions.tsx +37 -30
- package/template/src/assets/images/eaton_stacked_logo.png +0 -0
- package/template/src/components/AuthCustomScreen.tsx +50 -0
- package/template/src/components/CustomScreen.tsx +77 -0
- package/template/src/components/DebugComponent.tsx +49 -0
- package/template/src/components/ForgotPasswordScreenBaseExample.tsx +42 -0
- package/template/src/components/ResetPasswordScreenBaseExample.tsx +41 -0
- package/template/src/components/UserMenuExample.tsx +117 -0
- package/template/src/contexts/AppContextProvider.tsx +28 -0
- package/template/src/contexts/ThemeContext.ts +15 -0
- package/template/src/navigation/index.tsx +205 -22
- package/template/src/navigation/navigation-drawer.tsx +38 -25
- package/template/src/screens/ChangePassword.tsx +15 -0
- package/template/src/screens/Dashboard.tsx +137 -0
- package/template/src/screens/Homepage.tsx +135 -0
- package/template/src/screens/Locations.tsx +137 -0
- package/template/src/screens/Login.tsx +17 -0
- package/template/src/screens/Registration.tsx +4 -0
- package/template/src/screens/RegistrationInvite.tsx +5 -0
- package/template/src/screens/index.ts +12 -0
- package/template/src/store/local-storage.ts +4 -4
- package/template/translations/dictionary/chinese.ts +29 -0
- package/template/translations/dictionary/english.ts +29 -0
- package/template/translations/dictionary/french.ts +29 -0
- package/template/translations/dictionary/index.ts +19 -0
- package/template/translations/dictionary/portuguese.ts +29 -0
- package/template/translations/dictionary/spanish.ts +29 -0
- package/template/translations/dictionary/types.ts +27 -0
- package/template/translations/i18n.ts +58 -0
- package/template/tsconfig.json +60 -0
- package/template/yarn.lock +7341 -0
- package/template.config.js +4 -0
- package/CHANGELOG.md +0 -69
- package/dependencies.json +0 -31
- package/images/Logo.svg +0 -11
- package/template/__mocks__/svgMock.js +0 -8
- package/template/jestSetupFile.js +0 -17
- package/template/react-native.config.js +0 -3
- package/template/src/navigation/DeepLinking.ts +0 -62
- package/template/src/screens/home.tsx +0 -198
- package/template/src/screens/index.tsx +0 -3
- package/template/src/screens/pageOne.tsx +0 -91
- package/template/src/screens/pageTwo.tsx +0 -92
- /package/{fonts → template/android/app/src/main/assets/fonts}/OpenSans-Bold.ttf +0 -0
- /package/{fonts → template/android/app/src/main/assets/fonts}/OpenSans-ExtraBold.ttf +0 -0
- /package/{fonts → template/android/app/src/main/assets/fonts}/OpenSans-Light.ttf +0 -0
- /package/{fonts → template/android/app/src/main/assets/fonts}/OpenSans-Regular.ttf +0 -0
- /package/{fonts → template/android/app/src/main/assets/fonts}/OpenSans-SemiBold.ttf +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1210"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
|
|
18
|
+
BuildableName = "blankTemplate.app"
|
|
19
|
+
BlueprintName = "blankTemplate"
|
|
20
|
+
ReferencedContainer = "container:blankTemplate.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
<TestableReference
|
|
32
|
+
skipped = "NO">
|
|
33
|
+
<BuildableReference
|
|
34
|
+
BuildableIdentifier = "primary"
|
|
35
|
+
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
|
|
36
|
+
BuildableName = "blankTemplateTests.xctest"
|
|
37
|
+
BlueprintName = "blankTemplateTests"
|
|
38
|
+
ReferencedContainer = "container:blankTemplate.xcodeproj">
|
|
39
|
+
</BuildableReference>
|
|
40
|
+
</TestableReference>
|
|
41
|
+
</Testables>
|
|
42
|
+
</TestAction>
|
|
43
|
+
<LaunchAction
|
|
44
|
+
buildConfiguration = "Debug"
|
|
45
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
46
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
47
|
+
launchStyle = "0"
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
50
|
+
debugDocumentVersioning = "YES"
|
|
51
|
+
debugServiceExtension = "internal"
|
|
52
|
+
allowLocationSimulation = "YES">
|
|
53
|
+
<BuildableProductRunnable
|
|
54
|
+
runnableDebuggingMode = "0">
|
|
55
|
+
<BuildableReference
|
|
56
|
+
BuildableIdentifier = "primary"
|
|
57
|
+
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
|
|
58
|
+
BuildableName = "blankTemplate.app"
|
|
59
|
+
BlueprintName = "blankTemplate"
|
|
60
|
+
ReferencedContainer = "container:blankTemplate.xcodeproj">
|
|
61
|
+
</BuildableReference>
|
|
62
|
+
</BuildableProductRunnable>
|
|
63
|
+
</LaunchAction>
|
|
64
|
+
<ProfileAction
|
|
65
|
+
buildConfiguration = "Release"
|
|
66
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
67
|
+
savedToolIdentifier = ""
|
|
68
|
+
useCustomWorkingDirectory = "NO"
|
|
69
|
+
debugDocumentVersioning = "YES">
|
|
70
|
+
<BuildableProductRunnable
|
|
71
|
+
runnableDebuggingMode = "0">
|
|
72
|
+
<BuildableReference
|
|
73
|
+
BuildableIdentifier = "primary"
|
|
74
|
+
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
|
|
75
|
+
BuildableName = "blankTemplate.app"
|
|
76
|
+
BlueprintName = "blankTemplate"
|
|
77
|
+
ReferencedContainer = "container:blankTemplate.xcodeproj">
|
|
78
|
+
</BuildableReference>
|
|
79
|
+
</BuildableProductRunnable>
|
|
80
|
+
</ProfileAction>
|
|
81
|
+
<AnalyzeAction
|
|
82
|
+
buildConfiguration = "Debug">
|
|
83
|
+
</AnalyzeAction>
|
|
84
|
+
<ArchiveAction
|
|
85
|
+
buildConfiguration = "Release"
|
|
86
|
+
revealArchiveInOrganizer = "YES">
|
|
87
|
+
</ArchiveAction>
|
|
88
|
+
</Scheme>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>en</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>BNDL</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleSignature</key>
|
|
20
|
+
<string>????</string>
|
|
21
|
+
<key>CFBundleVersion</key>
|
|
22
|
+
<string>1</string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
#import <XCTest/XCTest.h>
|
|
3
|
+
|
|
4
|
+
#import <React/RCTLog.h>
|
|
5
|
+
#import <React/RCTRootView.h>
|
|
6
|
+
|
|
7
|
+
#define TIMEOUT_SECONDS 600
|
|
8
|
+
#define TEXT_TO_LOOK_FOR @"Welcome to React"
|
|
9
|
+
|
|
10
|
+
@interface blankTemplateTests : XCTestCase
|
|
11
|
+
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@implementation blankTemplateTests
|
|
15
|
+
|
|
16
|
+
- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test
|
|
17
|
+
{
|
|
18
|
+
if (test(view)) {
|
|
19
|
+
return YES;
|
|
20
|
+
}
|
|
21
|
+
for (UIView *subview in [view subviews]) {
|
|
22
|
+
if ([self findSubviewInView:subview matching:test]) {
|
|
23
|
+
return YES;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return NO;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (void)testRendersWelcomeScreen
|
|
30
|
+
{
|
|
31
|
+
UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
|
|
32
|
+
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
|
|
33
|
+
BOOL foundElement = NO;
|
|
34
|
+
|
|
35
|
+
__block NSString *redboxError = nil;
|
|
36
|
+
#ifdef DEBUG
|
|
37
|
+
RCTSetLogFunction(
|
|
38
|
+
^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
|
|
39
|
+
if (level >= RCTLogLevelError) {
|
|
40
|
+
redboxError = message;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
|
|
46
|
+
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
|
47
|
+
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
|
48
|
+
|
|
49
|
+
foundElement = [self findSubviewInView:vc.view
|
|
50
|
+
matching:^BOOL(UIView *view) {
|
|
51
|
+
if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
|
|
52
|
+
return YES;
|
|
53
|
+
}
|
|
54
|
+
return NO;
|
|
55
|
+
}];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#ifdef DEBUG
|
|
59
|
+
RCTSetLogFunction(RCTDefaultLogFunction);
|
|
60
|
+
#endif
|
|
61
|
+
|
|
62
|
+
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
|
|
63
|
+
XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"migIndex": 1,
|
|
3
|
+
"data": [
|
|
4
|
+
{
|
|
5
|
+
"path": "assets/fonts/OpenSans-Bold.ttf",
|
|
6
|
+
"sha1": "1e3704ee48b5ff7e582488ead87b05249f14dc1c"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"path": "assets/fonts/OpenSans-ExtraBold.ttf",
|
|
10
|
+
"sha1": "5acb1de2513aca9ce4fcf5d1e1e49aad86f1888c"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"path": "assets/fonts/OpenSans-Light.ttf",
|
|
14
|
+
"sha1": "bf0d133b628259eca01049d30fa6316094d00bcf"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "assets/fonts/OpenSans-Regular.ttf",
|
|
18
|
+
"sha1": "babe8dce93a3e48b6c3c79720a0c048e88dd1fe7"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "assets/fonts/OpenSans-SemiBold.ttf",
|
|
22
|
+
"sha1": "e256f8391718ef61f253dfb4e95bbeb3c5857afc"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
package/template/metro.config.js
CHANGED
|
@@ -1,29 +1,11 @@
|
|
|
1
|
+
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Metro configuration
|
|
3
|
-
* https://
|
|
4
|
+
* Metro configuration
|
|
5
|
+
* https://reactnative.dev/docs/metro
|
|
4
6
|
*
|
|
5
|
-
* @
|
|
7
|
+
* @type {import('metro-config').MetroConfig}
|
|
6
8
|
*/
|
|
9
|
+
const config = {};
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module.exports = (async () => {
|
|
11
|
-
const {
|
|
12
|
-
resolver: { sourceExts, assetExts },
|
|
13
|
-
} = await getDefaultConfig();
|
|
14
|
-
return {
|
|
15
|
-
transformer: {
|
|
16
|
-
babelTransformerPath: require.resolve('react-native-svg-transformer'),
|
|
17
|
-
getTransformOptions: async () => ({
|
|
18
|
-
transform: {
|
|
19
|
-
experimentalImportSupport: false,
|
|
20
|
-
inlineRequires: true,
|
|
21
|
-
},
|
|
22
|
-
}),
|
|
23
|
-
},
|
|
24
|
-
resolver: {
|
|
25
|
-
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
26
|
-
sourceExts: [...sourceExts, 'svg'],
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
})();
|
|
11
|
+
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "blank-template",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"android": "react-native run-android",
|
|
7
|
+
"ios": "react-native run-ios",
|
|
8
|
+
"lint": "eslint ",
|
|
9
|
+
"lint:fix": "eslint \"src/**/**.ts\" --fix",
|
|
10
|
+
"prettier": "prettier \"**/**.{tsx,ts,js,json}\" --write",
|
|
11
|
+
"start": "react-native start",
|
|
12
|
+
"test": "jest"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@brightlayer-ui/react-native-auth-workflow": "6.0.0-alpha.2",
|
|
16
|
+
"@brightlayer-ui/react-native-components": "^8.0.2",
|
|
17
|
+
"@brightlayer-ui/react-native-themes": "^7.0.0",
|
|
18
|
+
"@brightlayer-ui/react-native-vector-icons": "^2.2.0",
|
|
19
|
+
"@react-native-async-storage/async-storage": "^1.23.1",
|
|
20
|
+
"@react-navigation/drawer": "^6.6.15",
|
|
21
|
+
"@react-navigation/native": "^6.1.17",
|
|
22
|
+
"@react-navigation/native-stack": "^6.9.26",
|
|
23
|
+
"i18next": "^23.11.3",
|
|
24
|
+
"intl-pluralrules": "^2.0.1",
|
|
25
|
+
"react": "18.2.0",
|
|
26
|
+
"react-i18next": "^14.1.1",
|
|
27
|
+
"react-native": "0.74.1",
|
|
28
|
+
"react-native-gesture-handler": "^2.16.2",
|
|
29
|
+
"react-native-pager-view": "^6.3.1",
|
|
30
|
+
"react-native-paper": "^5.0.0",
|
|
31
|
+
"react-native-reanimated": "^3.11.0",
|
|
32
|
+
"react-native-restart": "^0.0.27",
|
|
33
|
+
"react-native-safe-area-context": "^4.0.0",
|
|
34
|
+
"react-native-screens": "^3.31.1",
|
|
35
|
+
"react-native-select-dropdown": "^3.4.0",
|
|
36
|
+
"react-native-vector-icons": "^9.2.0",
|
|
37
|
+
"react-native-webview": "^13.10.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@babel/core": "^7.20.0",
|
|
41
|
+
"@babel/preset-env": "^7.20.0",
|
|
42
|
+
"@babel/runtime": "^7.20.0",
|
|
43
|
+
"@brightlayer-ui/eslint-config": "^3.0.1",
|
|
44
|
+
"@brightlayer-ui/prettier-config": "^1.0.3",
|
|
45
|
+
"@eslint/js": "^9.2.0",
|
|
46
|
+
"@react-native/babel-preset": "0.74.83",
|
|
47
|
+
"@react-native/eslint-config": "0.74.83",
|
|
48
|
+
"@react-native/metro-config": "0.74.83",
|
|
49
|
+
"@react-native/typescript-config": "0.74.83",
|
|
50
|
+
"@types/react": "^18.2.6",
|
|
51
|
+
"@types/react-test-renderer": "^18.0.0",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
53
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
54
|
+
"babel-jest": "^29.6.3",
|
|
55
|
+
"eslint": "8.56.0",
|
|
56
|
+
"eslint-config-prettier": "^9.1.0",
|
|
57
|
+
"eslint-plugin-react": "^7.34.1",
|
|
58
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
59
|
+
"globals": "^15.1.0",
|
|
60
|
+
"jest": "^29.6.3",
|
|
61
|
+
"prettier": "2.8.8",
|
|
62
|
+
"react-test-renderer": "18.2.0",
|
|
63
|
+
"typescript": "5.0.4",
|
|
64
|
+
"typescript-eslint": "^7.8.0"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=18"
|
|
68
|
+
},
|
|
69
|
+
"prettier": "@brightlayer-ui/prettier-config"
|
|
70
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import { AuthUIActions
|
|
2
|
+
import { AuthUIActions } from '@brightlayer-ui/react-native-auth-workflow';
|
|
3
|
+
import { AppContextType } from '../contexts/AppContextProvider';
|
|
3
4
|
import { LocalStorage } from '../store/local-storage';
|
|
4
5
|
|
|
5
6
|
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -13,8 +14,7 @@ function isRandomFailure(): boolean {
|
|
|
13
14
|
return false; // randomResponseNumber < 10;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
type
|
|
17
|
-
type AuthUIActionsWithSecurity = (securityHelper: SecurityContextActions) => AuthUIActionsFunction;
|
|
17
|
+
type AuthUIActionsWithApp = (appHelper: AppContextType) => AuthUIActions;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Example implementation of [[AuthUIActions]] to start with during development.
|
|
@@ -23,7 +23,7 @@ type AuthUIActionsWithSecurity = (securityHelper: SecurityContextActions) => Aut
|
|
|
23
23
|
* appropriate actions (often api calls, local network storage, credential updates, etc) and update
|
|
24
24
|
* the global security state based on the actionable needs of the user.
|
|
25
25
|
*/
|
|
26
|
-
export const ProjectAuthUIActions:
|
|
26
|
+
export const ProjectAuthUIActions: AuthUIActionsWithApp = (appHelper) => ({
|
|
27
27
|
/**
|
|
28
28
|
* Initialize the application security state. This will involve reading any local storage,
|
|
29
29
|
* validating existing credentials (token expiration, for example). At the end of validation,
|
|
@@ -48,16 +48,15 @@ export const ProjectAuthUIActions: AuthUIActionsWithSecurity = (securityHelper)
|
|
|
48
48
|
// After restoring token, we may need to validate it in production apps
|
|
49
49
|
// This will switch to the App screen or Auth screen and this loading
|
|
50
50
|
// screen will be unmounted and thrown away.
|
|
51
|
-
// securityHelper.onUserAuthenticated()
|
|
52
51
|
if (authData?.email !== undefined) {
|
|
53
|
-
|
|
52
|
+
appHelper.onUserAuthenticated({
|
|
54
53
|
email: authData?.email,
|
|
55
54
|
userId: authData.userId ?? '',
|
|
56
55
|
rememberMe: authData?.rememberMeData.rememberMe,
|
|
57
56
|
});
|
|
58
57
|
} else {
|
|
59
58
|
const rememberMeEmail = authData?.rememberMeData.rememberMe ? authData?.rememberMeData.user : undefined;
|
|
60
|
-
|
|
59
|
+
appHelper.onUserNotAuthenticated(false, rememberMeEmail);
|
|
61
60
|
}
|
|
62
61
|
},
|
|
63
62
|
/**
|
|
@@ -87,15 +86,17 @@ export const ProjectAuthUIActions: AuthUIActionsWithSecurity = (securityHelper)
|
|
|
87
86
|
logIn: async (email: string, password: string, rememberMe: boolean): Promise<void> => {
|
|
88
87
|
await sleep(1000);
|
|
89
88
|
|
|
89
|
+
// throw new Error('My Custom Error');
|
|
90
|
+
|
|
90
91
|
if (isRandomFailure()) {
|
|
91
92
|
// reject(new Error('LOGIN.GENERIC_ERROR'));
|
|
92
|
-
throw new Error('LOGIN.INVALID_CREDENTIALS');
|
|
93
|
+
throw new Error('bluiAuth:LOGIN.INVALID_CREDENTIALS');
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
LocalStorage.saveAuthCredentials(email, email);
|
|
96
97
|
LocalStorage.saveRememberMeData(email, rememberMe);
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
appHelper.onUserAuthenticated({ email: email, userId: email, rememberMe: rememberMe });
|
|
99
100
|
},
|
|
100
101
|
/**
|
|
101
102
|
* The user has forgotten their password and wants help.
|
|
@@ -130,7 +131,6 @@ export const ProjectAuthUIActions: AuthUIActionsWithSecurity = (securityHelper)
|
|
|
130
131
|
if (isRandomFailure()) {
|
|
131
132
|
throw new Error('Sorry, there was a problem sending your request.');
|
|
132
133
|
}
|
|
133
|
-
|
|
134
134
|
return;
|
|
135
135
|
},
|
|
136
136
|
/**
|
|
@@ -172,7 +172,6 @@ export const ProjectAuthUIActions: AuthUIActionsWithSecurity = (securityHelper)
|
|
|
172
172
|
if (isRandomFailure()) {
|
|
173
173
|
throw new Error('Sorry, there was a problem sending your request.');
|
|
174
174
|
}
|
|
175
|
-
|
|
176
175
|
return;
|
|
177
176
|
},
|
|
178
177
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import { RegistrationUIActions,
|
|
2
|
+
import { RegistrationUIActions, AccountDetails } from '@brightlayer-ui/react-native-auth-workflow';
|
|
3
3
|
|
|
4
4
|
// Constants
|
|
5
5
|
import { SAMPLE_EULA } from '../constants/sampleEula';
|
|
@@ -30,14 +30,14 @@ export const ProjectRegistrationUIActions: () => RegistrationUIActions = () => (
|
|
|
30
30
|
*
|
|
31
31
|
* @returns Resolve with EULA, otherwise reject with an error message.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
loadEula: async (language: string): Promise<string> => {
|
|
34
34
|
await sleep(1000);
|
|
35
35
|
|
|
36
36
|
if (isRandomFailure()) {
|
|
37
37
|
throw new Error('Sorry, there was a problem sending your request.');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
if (language
|
|
40
|
+
if (!language.includes('en')) {
|
|
41
41
|
return 'Other language EULA';
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -45,20 +45,43 @@ export const ProjectRegistrationUIActions: () => RegistrationUIActions = () => (
|
|
|
45
45
|
},
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* The user
|
|
49
|
-
* The API should now
|
|
48
|
+
* The user accepted the EULA.
|
|
49
|
+
* The API should now update accepted EULA.
|
|
50
50
|
*
|
|
51
|
-
* @param email Email for the registering user.
|
|
52
51
|
*
|
|
53
52
|
* @returns Resolve when the server accepted the request.
|
|
54
53
|
*/
|
|
55
|
-
|
|
54
|
+
acceptEula: async (): Promise<void> => {
|
|
56
55
|
await sleep(800);
|
|
57
56
|
if (isRandomFailure()) {
|
|
58
57
|
throw new Error('Sorry, there was a problem sending your request.');
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
|
|
61
|
+
requestRegistrationCode: async (email: string): Promise<string> => {
|
|
62
|
+
await sleep(800);
|
|
63
|
+
if (isRandomFailure()) {
|
|
64
|
+
throw new Error('Sorry, there was a problem sending your request.');
|
|
65
|
+
}
|
|
66
|
+
return 'a1b2c3';
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
createPassword: async (password: string): Promise<boolean> => {
|
|
70
|
+
await sleep(800);
|
|
71
|
+
if (isRandomFailure()) {
|
|
72
|
+
throw new Error('Sorry, there was a problem sending your request.');
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
setAccountDetails: async (details: AccountDetails): Promise<boolean> => {
|
|
78
|
+
await sleep(800);
|
|
79
|
+
if (isRandomFailure()) {
|
|
80
|
+
throw new Error('Sorry, there was a problem sending your request.');
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
},
|
|
84
|
+
|
|
62
85
|
/**
|
|
63
86
|
* The user has tapped on an email link inviting them to register with the application.
|
|
64
87
|
* The application should validate the code provided by the link.
|
|
@@ -69,35 +92,19 @@ export const ProjectRegistrationUIActions: () => RegistrationUIActions = () => (
|
|
|
69
92
|
* @returns Resolves when the code is valid. True if registration is complete, False if account information is needed.
|
|
70
93
|
* If the code is not valid a rejection will occur with an error message.
|
|
71
94
|
*/
|
|
72
|
-
validateUserRegistrationRequest: async (
|
|
95
|
+
validateUserRegistrationRequest: async (
|
|
96
|
+
validationCode: string,
|
|
97
|
+
validationEmail?: string
|
|
98
|
+
): Promise<{ codeValid: boolean | string; accountExists?: boolean }> => {
|
|
73
99
|
await sleep(800);
|
|
74
100
|
|
|
75
101
|
if (isRandomFailure()) {
|
|
76
102
|
throw new Error('Sorry, there was a problem sending your request.');
|
|
77
103
|
}
|
|
78
|
-
return
|
|
104
|
+
return { codeValid: true, accountExists: false };
|
|
79
105
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
* password information.
|
|
83
|
-
* The application should now complete the registration process given the user's data.
|
|
84
|
-
*
|
|
85
|
-
* Note: Upon resolution, the user will be brought back to the Login screen.
|
|
86
|
-
*
|
|
87
|
-
* @param userData Account details and password entered by the user.
|
|
88
|
-
* @param validationCode Registration code provided from the invitation email link.
|
|
89
|
-
* @param validationEmail Email provided from the invitation email link (optional) `?email=addr%40domain.com`.
|
|
90
|
-
*
|
|
91
|
-
* @returns Resolve when account creation succeeds, otherwise reject with an error message.
|
|
92
|
-
*/
|
|
93
|
-
completeRegistration: async (
|
|
94
|
-
userData: {
|
|
95
|
-
password: string;
|
|
96
|
-
accountDetails: AccountDetailInformation;
|
|
97
|
-
},
|
|
98
|
-
validationCode: string,
|
|
99
|
-
validationEmail?: string
|
|
100
|
-
): Promise<{ email: string; organizationName: string }> => {
|
|
106
|
+
|
|
107
|
+
completeRegistration: async (userData: object): Promise<{ email: string; organizationName: string }> => {
|
|
101
108
|
const email = 'example@email.com';
|
|
102
109
|
const organizationName = 'Acme Co.';
|
|
103
110
|
const userInfo = { email, organizationName };
|
|
Binary file
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
WorkflowCard,
|
|
4
|
+
WorkflowCardActions,
|
|
5
|
+
WorkflowCardBody,
|
|
6
|
+
WorkflowCardHeader,
|
|
7
|
+
useAuthContext,
|
|
8
|
+
} from '@brightlayer-ui/react-native-auth-workflow';
|
|
9
|
+
import { Text } from 'react-native-paper';
|
|
10
|
+
import { View } from 'react-native';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
|
|
13
|
+
export const AuthCustomScreen: React.FC = () => {
|
|
14
|
+
const { actions } = useAuthContext();
|
|
15
|
+
|
|
16
|
+
const handleOnNext = useCallback(async () => {
|
|
17
|
+
try {
|
|
18
|
+
await actions.forgotPassword('email@email.email');
|
|
19
|
+
} catch (_error) {
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log('Error ::', _error);
|
|
22
|
+
}
|
|
23
|
+
}, [actions]);
|
|
24
|
+
|
|
25
|
+
const { t } = useTranslation();
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<WorkflowCard>
|
|
29
|
+
<WorkflowCardHeader title="Auth Screen" />
|
|
30
|
+
<WorkflowCardBody>
|
|
31
|
+
<View
|
|
32
|
+
style={{
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
paddingTop: 50,
|
|
36
|
+
paddingBottom: 50,
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<Text variant="headlineSmall">Auth Translations</Text>
|
|
40
|
+
<Text variant="bodyMedium">{`Auth Translations: ${t('bluiAuth:FORGOT_PASSWORD.ERROR')}`}</Text>
|
|
41
|
+
<Text variant="bodyMedium">{`Common Translations: ${t(
|
|
42
|
+
'bluiCommon:ACTIONS.CHANGE_LANGUAGE'
|
|
43
|
+
)}`}</Text>
|
|
44
|
+
<Text variant="bodyMedium">{`App Translations: ${t('app:PAGE_DETAILS.AUTHORISED_MESSAGE')}`}</Text>
|
|
45
|
+
</View>
|
|
46
|
+
</WorkflowCardBody>
|
|
47
|
+
<WorkflowCardActions showNext nextLabel={'Press'} onNext={(): void => void handleOnNext()} />
|
|
48
|
+
</WorkflowCard>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
// import { useRegistrationWorkflowContext } from '../../contexts';
|
|
3
|
+
import {
|
|
4
|
+
WorkflowCard,
|
|
5
|
+
WorkflowCardActions,
|
|
6
|
+
WorkflowCardBody,
|
|
7
|
+
WorkflowCardHeader,
|
|
8
|
+
useRegistrationWorkflowContext,
|
|
9
|
+
useRegistrationContext,
|
|
10
|
+
} from '@brightlayer-ui/react-native-auth-workflow';
|
|
11
|
+
import { TextInput } from 'react-native-paper';
|
|
12
|
+
import { useTranslation } from 'react-i18next';
|
|
13
|
+
|
|
14
|
+
type CustomScreenProps = {
|
|
15
|
+
/**
|
|
16
|
+
* Used to pre-populate the data when the screen loads
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
organisationName?: any;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const CustomScreen: React.FC<CustomScreenProps> = (props) => {
|
|
23
|
+
const regWorkflow = useRegistrationWorkflowContext();
|
|
24
|
+
const { navigate } = useRegistrationContext();
|
|
25
|
+
const { nextScreen, screenData, currentScreen, totalScreens, resetScreenData, previousScreen } = regWorkflow;
|
|
26
|
+
const { organisationName } = props;
|
|
27
|
+
const { t } = useTranslation();
|
|
28
|
+
|
|
29
|
+
const [organisationNameInput, setOrganisationNameInput] = useState(
|
|
30
|
+
organisationName ? organisationName : screenData.Other?.organisationName
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const onNext = useCallback(() => {
|
|
34
|
+
void nextScreen({
|
|
35
|
+
screenId: 'Custom',
|
|
36
|
+
values: { organisationName: organisationNameInput },
|
|
37
|
+
// isAccountExist: true,
|
|
38
|
+
});
|
|
39
|
+
}, [organisationNameInput, nextScreen]);
|
|
40
|
+
|
|
41
|
+
const onIconPress = useCallback(() => {
|
|
42
|
+
navigate(-1);
|
|
43
|
+
resetScreenData();
|
|
44
|
+
}, [navigate, resetScreenData]);
|
|
45
|
+
|
|
46
|
+
const onPrevious = useCallback(() => {
|
|
47
|
+
void previousScreen({
|
|
48
|
+
screenId: 'Custom',
|
|
49
|
+
values: { organisationName: organisationNameInput },
|
|
50
|
+
// isAccountExist: true,
|
|
51
|
+
});
|
|
52
|
+
}, [organisationNameInput, previousScreen]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<WorkflowCard>
|
|
56
|
+
<WorkflowCardHeader title="Custom Screen" onIconPress={onIconPress} icon={{ name: 'arrow-back' }} />
|
|
57
|
+
<WorkflowCardBody>
|
|
58
|
+
<TextInput
|
|
59
|
+
label={t('app:ORGANAIZATION_DETAILS.NAME')}
|
|
60
|
+
mode="flat"
|
|
61
|
+
value={organisationNameInput}
|
|
62
|
+
onChangeText={(value) => setOrganisationNameInput(value)}
|
|
63
|
+
/>
|
|
64
|
+
</WorkflowCardBody>
|
|
65
|
+
<WorkflowCardActions
|
|
66
|
+
showPrevious
|
|
67
|
+
showNext
|
|
68
|
+
previousLabel={t('bluiCommon:ACTIONS.BACK')}
|
|
69
|
+
nextLabel={t('bluiCommon:ACTIONS.OKAY')}
|
|
70
|
+
currentStep={currentScreen}
|
|
71
|
+
totalSteps={totalScreens}
|
|
72
|
+
onNext={onNext}
|
|
73
|
+
onPrevious={onPrevious}
|
|
74
|
+
/>
|
|
75
|
+
</WorkflowCard>
|
|
76
|
+
);
|
|
77
|
+
};
|