Skip to content

Commit

Permalink
use env vars for example
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxtux59 committed Jun 7, 2024
1 parent 0a56c6f commit 8d7017b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ android/keystores/debug.keystore
lib/

example/.yarn

.env
9 changes: 8 additions & 1 deletion example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const path = require('path');
const pak = require('../package.json');

module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
[
'module:react-native-dotenv',
{
envName: 'APP_ENV',
moduleName: '@env',
path: '.env',
},
],
[
'module-resolver',
{
Expand Down
3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"@react-native/babel-preset": "0.74.83",
"@react-native/metro-config": "0.74.83",
"@react-native/typescript-config": "0.74.83",
"babel-plugin-module-resolver": "^5.0.0"
"babel-plugin-module-resolver": "^5.0.0",
"react-native-dotenv": "^3.4.11"
},
"engines": {
"node": ">=18"
Expand Down
30 changes: 22 additions & 8 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,32 @@ import * as React from 'react';
import { CryptrProvider } from '@cryptr/cryptr-react-native';
import type { CryptrConfig } from '../../src/utils/interfaces';
import HomeScreen from './screens/HomeScreen';
import {
REACT_APP_CRYPTR_ACCOUNT_DOMAIN,
REACT_APP_CRYPTR_CLIENT_ID,
REACT_APP_CRYPTR_SERVICE_URL,
REACT_APP_CRYPTR_AUDIENCE,
REACT_APP_CRYPTR_DEFAULT_REDIRECT_URI,
REACT_APP_CRYPTR_DEDICATED_SERVER,
REACT_APP_CRYPTR_NO_POPUP_NO_COOKIE,
REACT_APP_CRYPTR_DEFAULT_LOCALE,
} from '@env';

const config: CryptrConfig = {
accountDomain: 'account-domain',
clientId: 'client-id',
cryptrServiceUrl: 'https://cryptr-service.ul',
audience: 'cryptr://2024-app',
defaultRedirectUri: 'cryptr://2024-app',
dedicatedServer: true,
noPopupNoCookie: true,
defaultLocale: 'en',
accountDomain: REACT_APP_CRYPTR_ACCOUNT_DOMAIN,
clientId: REACT_APP_CRYPTR_CLIENT_ID,
cryptrServiceUrl: REACT_APP_CRYPTR_SERVICE_URL,
audience: REACT_APP_CRYPTR_AUDIENCE,
defaultRedirectUri: REACT_APP_CRYPTR_DEFAULT_REDIRECT_URI,
dedicatedServer: REACT_APP_CRYPTR_DEDICATED_SERVER,
noPopupNoCookie: REACT_APP_CRYPTR_NO_POPUP_NO_COOKIE,
defaultLocale: REACT_APP_CRYPTR_DEFAULT_LOCALE,
};

console.debug(config);
console.debug(REACT_APP_CRYPTR_ACCOUNT_DOMAIN);
console.debug(process.env);

export default function App() {
return (
<CryptrProvider {...config}>
Expand Down
19 changes: 19 additions & 0 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,7 @@ __metadata:
babel-plugin-module-resolver: ^5.0.0
react: 18.2.0
react-native: 0.74.1
react-native-dotenv: ^3.4.11
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -3147,6 +3148,13 @@ __metadata:
languageName: node
linkType: hard

"dotenv@npm:^16.4.5":
version: 16.4.5
resolution: "dotenv@npm:16.4.5"
checksum: 301a12c3d44fd49888b74eb9ccf9f07a1f5df43f489e7fcb89647a2edcd84c42d6bc349dc8df099cd18f07c35c7b04685c1a4f3e6a6a9e6b30f8d48c15b7f49c
languageName: node
linkType: hard

"eastasianwidth@npm:^0.2.0":
version: 0.2.0
resolution: "eastasianwidth@npm:0.2.0"
Expand Down Expand Up @@ -5360,6 +5368,17 @@ __metadata:
languageName: node
linkType: hard

"react-native-dotenv@npm:^3.4.11":
version: 3.4.11
resolution: "react-native-dotenv@npm:3.4.11"
dependencies:
dotenv: ^16.4.5
peerDependencies:
"@babel/runtime": ^7.20.6
checksum: 3ebac2c2ed79dd7e4920fd3fc2da9187413b7190231618e4858b46c47833677838b96d531afe7bd5c4b0a60454dba40cb8708722210df5d522e30aefbf41da05
languageName: node
linkType: hard

"react-native@npm:0.74.1":
version: 0.74.1
resolution: "react-native@npm:0.74.1"
Expand Down

0 comments on commit 8d7017b

Please sign in to comment.