generated from nimblehq/git-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from nimblehq/feature/234-secure-storage
- Loading branch information
Showing
16 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
bricks/template/__brick__/{{project_name.snakeCase()}}/lib/data/local/secure_storage.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
|
||
const _keyAccessToken = 'KEY_ACCESS_TOKEN'; | ||
|
||
abstract class SecureStorage { | ||
Future<String?> get accessToken; | ||
|
||
Future<void> storeAccessToken(String accessToken); | ||
|
||
Future<void> clearAll(); | ||
} | ||
|
||
@Singleton(as: SecureStorage) | ||
class SecureStorageImpl extends SecureStorage { | ||
final FlutterSecureStorage _storage; | ||
|
||
SecureStorageImpl(this._storage); | ||
|
||
@override | ||
Future<String?> get accessToken => _storage.read(key: _keyAccessToken); | ||
|
||
@override | ||
Future<void> storeAccessToken(String accessToken) { | ||
return _storage.write(key: _keyAccessToken, value: accessToken); | ||
} | ||
|
||
@override | ||
Future<void> clearAll() { | ||
return _storage.deleteAll(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
bricks/template/__brick__/{{project_name.snakeCase()}}/lib/di/module/storage_module.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
|
||
@module | ||
abstract class StorageModule { | ||
@singleton | ||
FlutterSecureStorage get flutterSecureStorage => const FlutterSecureStorage( | ||
aOptions: AndroidOptions(encryptedSharedPreferences: true)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ jobs: | |
build_and_deploy_android: | ||
name: Build & Deploy Android | ||
runs-on: ubuntu-latest | ||
environment: production | ||
timeout-minutes: 30 | ||
steps: | ||
- name: Check out | ||
|
@@ -34,9 +35,9 @@ jobs: | |
|
||
- name: Set up .env | ||
env: | ||
ENV_PRODUCTION: ${{ secrets.ENV_PRODUCTION }} | ||
ENV: ${{ secrets.ENV }} | ||
run: | | ||
echo $ENV_PRODUCTION > .env | ||
echo "$ENV" > .env | ||
# App Bundle requires Firebase connected to Play Store to upload https://appdistribution.page.link/KPoa | ||
- name: Build Android apk | ||
|
@@ -45,7 +46,7 @@ jobs: | |
- name: Deploy Android Production to Firebase | ||
uses: wzieba/[email protected] | ||
with: | ||
appId: ${{ secrets.FIREBASE_ANDROID_APP_ID_PRODUCTION }} | ||
appId: ${{ vars.FIREBASE_ANDROID_APP_ID }} | ||
serviceCredentialsFileContent: ${{ secrets.FIREBASE_DISTRIBUTION_CREDENTIAL_JSON }} | ||
groups: ${{ vars.FIREBASE_DISTRIBUTION_TESTER_GROUPS }} | ||
file: build/app/outputs/flutter-apk/app-production-debug.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ jobs: | |
build_and_deploy_android: | ||
name: Build & Deploy Android | ||
runs-on: ubuntu-latest | ||
environment: staging | ||
timeout-minutes: 30 | ||
steps: | ||
- name: Check out | ||
|
@@ -34,9 +35,9 @@ jobs: | |
|
||
- name: Set up .env.staging | ||
env: | ||
ENV_STAGING: ${{ secrets.ENV_STAGING }} | ||
ENV: ${{ secrets.ENV }} | ||
run: | | ||
echo $ENV_STAGING > .env.staging | ||
echo "$ENV" > .env.staging | ||
# App Bundle requires Firebase connected to Play Store to upload https://appdistribution.page.link/KPoa | ||
- name: Build Android apk | ||
|
@@ -45,7 +46,7 @@ jobs: | |
- name: Deploy Android Staging to Firebase | ||
uses: wzieba/[email protected] | ||
with: | ||
appId: ${{ secrets.FIREBASE_ANDROID_APP_ID_STAGING }} | ||
appId: ${{ vars.FIREBASE_ANDROID_APP_ID }} | ||
serviceCredentialsFileContent: ${{ secrets.FIREBASE_DISTRIBUTION_CREDENTIAL_JSON }} | ||
groups: ${{ vars.FIREBASE_DISTRIBUTION_TESTER_GROUPS }} | ||
file: build/app/outputs/flutter-apk/app-staging-debug.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
|
||
const _keyAccessToken = 'KEY_ACCESS_TOKEN'; | ||
|
||
abstract class SecureStorage { | ||
Future<String?> get accessToken; | ||
|
||
Future<void> storeAccessToken(String accessToken); | ||
|
||
Future<void> clearAll(); | ||
} | ||
|
||
@Singleton(as: SecureStorage) | ||
class SecureStorageImpl extends SecureStorage { | ||
final FlutterSecureStorage _storage; | ||
|
||
SecureStorageImpl(this._storage); | ||
|
||
@override | ||
Future<String?> get accessToken => _storage.read(key: _keyAccessToken); | ||
|
||
@override | ||
Future<void> storeAccessToken(String accessToken) { | ||
return _storage.write(key: _keyAccessToken, value: accessToken); | ||
} | ||
|
||
@override | ||
Future<void> clearAll() { | ||
return _storage.deleteAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
|
||
@module | ||
abstract class StorageModule { | ||
@singleton | ||
FlutterSecureStorage get flutterSecureStorage => const FlutterSecureStorage( | ||
aOptions: AndroidOptions(encryptedSharedPreferences: true)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters