Skip to content

Commit

Permalink
WIP: 7c4b4c0 TECH-156 - Add dummy admin principal
Browse files Browse the repository at this point in the history
  • Loading branch information
TYRONEMICHAEL committed May 20, 2024
1 parent 8d9a609 commit b5a401c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions scripts/deploy-civic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ echo "Parsed rootkey: ${rootkey_did:0:20}..." >&2
if [ "$DFX_NETWORK" = "local" ]; then
ALTERNATIVE_ORIGINS="\"http://$CIVIC_FRONTEND_CANISTER_ID.localhost:4943\""
else
ALTERNATIVE_ORIGINS="\"http://$CIVIC_FRONTEND_CANISTER_ID.icp0.io\","
ALTERNATIVE_ORIGINS="\"https://$CIVIC_FRONTEND_CANISTER_ID.icp0.io\","
fi

echo "Using Alternative Origin: $ALTERNATIVE_ORIGINS"
echo "Using Alternative Origin: $ALTERNATIVE_ORIGINS $ISSUER_FRONTEND_HOSTNAME"

# Adjust issuer's .well-known/ii-alternative-origins to contain FE-hostname of local/dev deployments.
# We had a problem with `sed` command in CI. This is a hack to make it work locally and in CI.
Expand Down
4 changes: 0 additions & 4 deletions src/civic_canister_frontend/.env.local

This file was deleted.

4 changes: 4 additions & 0 deletions src/civic_canister_frontend/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VITE_PROD_INTERNET_IDENTITY_CANISTER_ID=rdmx6-jaaaa-aaaaa-aaadq-cai
VITE_PROD_CIVIC_FRONTEND_CANISTER_ID=d7wbq-nyaaa-aaaap-ahgiq-cai
VITE_PROD_CIVIC_BACKEND_CANISTER_ID=dyxhe-aaaaa-aaaap-ahgia-cai
VITE_PROD_HOST=ic
3 changes: 2 additions & 1 deletion src/civic_canister_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"setup": "npm i && dfx canister create icp-civic-canister-backend && dfx generate icp-civic-canister-backend && dfx deploy",
"start": "vite --port 3000",
"test": "vitest run",
"issue-credential": "tsx ./scripts/issue-credential.ts"
"issue-credential": "tsx ./scripts/issue-credential.ts",
"serve": "vite preview"
},
"type": "module",
"version": "0.0.0"
Expand Down
6 changes: 5 additions & 1 deletion src/civic_canister_frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ function App() {
const [principal, setPrincipal] = useState<Principal | undefined>(undefined);
const [credentialService, setCredentialService] = useState<CredentialService>();

useEffect(() => {
console.log('Config:', config);
}, [config]);

useEffect(() => {
const { civicBackendCanisterId, dummyCivicSampleKey } = config;
const service = new CredentialService({
Expand Down Expand Up @@ -39,7 +43,7 @@ function App() {
if (principal && credentialService) {
try {
const result = await credentialService.addCredential(principal, credential);
console.log('Credential stored successfully:', result);
console.log('Credentialss stored successfully:', result);
} catch (error) {
console.error('Error storing credential:', error);
}
Expand Down
10 changes: 5 additions & 5 deletions src/civic_canister_frontend/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const isProduction = import.meta.env.NODE_ENV === "production";
const isProduction = process.env.NODE_ENV === 'production';

const internetIdentityCanisterId = isProduction
? import.meta.env.VITE_PROD_INTERNET_IDENTITY_CANISTER_ID
Expand All @@ -16,9 +16,9 @@ const host = isProduction
? import.meta.env.VITE_PROD_HOST
: import.meta.env.VITE_LOCAL_HOST;

const internetIdentityUrl = `http://${internetIdentityCanisterId}.${host}`;
const civicBackendCanisterUrl = `http://${civicBackendCanisterId}.${host}`;
const civicFrontendCanisterUrl = `http://${civicFrontendCanisterId}.${host}`;
const internetIdentityUrl = `https://identity.ic0.app`;
const civicBackendCanisterUrl = `https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io`;
const civicFrontendCanisterUrl = `https://d7wbq-nyaaa-aaaap-ahgiq-cai.icp0.io/`;

// This is for demo purposes but should be replaced with a more secure method
const dummyCivicSampleKey = new Uint8Array([
Expand All @@ -33,4 +33,4 @@ export const config = {
internetIdentityCanisterId,
civicFrontendCanisterUrl,
dummyCivicSampleKey,
};
};
3 changes: 3 additions & 0 deletions src/civic_canister_frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import dotenv from 'dotenv';
dotenv.config({ path: '../../.env' });

export default defineConfig({
define: {
'process.env.NODE_ENV': JSON.stringify('production')
},
build: {
emptyOutDir: true,
},
Expand Down

0 comments on commit b5a401c

Please sign in to comment.