Skip to content

Commit

Permalink
TECH-292 - Update to uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
TYRONEMICHAEL committed Jul 30, 2024
1 parent 07cd3d6 commit 04a0e08
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/civic_sign_frontend_demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function App() {
const [principal, setPrincipal] = useState<Principal | undefined>(undefined);
const [credentialService, setCredentialService] = useState<CredentialService>();
const icpWallet = useMemo(() => ({ principal: principal?.toText() ?? undefined }), [principal]);
const gatekeeperNetwork = "tigoYhp9SpCDoCQmXGj2im5xa3mnjR1zuXrpCJ5ZRmi";
const gatekeeperNetwork = "tunQheuPpHhjjsbrUDp4rikqYez9UXv4SXLRHf9Kzsv";

const [urlCode, setUrlCode] = useState<string | null>(null);

Expand Down
46 changes: 24 additions & 22 deletions src/civic_sign_frontend_demo/src/service/CredentialService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// src/service/CredentialService.ts

import { Actor, HttpAgent } from "@dfinity/agent";
import { idlFactory as civic } from "../declarations/civic_canister_backend/civic_canister_backend.did.js";
import { idlFactory as civic } from "../../../declarations/civic_canister_backend/civic_canister_backend.did.js";
import { Secp256k1KeyIdentity } from "@dfinity/identity-secp256k1";
import { Principal } from "@dfinity/principal";
import { requestVerifiablePresentation } from "@dfinity/verifiable-credentials/request-verifiable-presentation";

Expand All @@ -23,7 +24,7 @@ export class CredentialService {
agent.fetchRootKey();
const actor = Actor.createActor(civic, {
agent,
canisterId: this.config.civicBackendCanisterId,
canisterId: '73ncn-4qaaa-aaaag-alddq-cai',
});
try {
const vc = await actor.get_all_credentials(Principal.fromText(principal));
Expand All @@ -37,10 +38,11 @@ export class CredentialService {

// Retrieve all credentials for a given principal
async getCredentials(principal: Principal): Promise<void> {
const p = 'jptln-iaf7q-52y5h-a374c-rtd4a-j3oby-i7tfm-cuis6-7lsx5-zor6m-aqe';
try {
const issuerData = {
origin: this.config.civicBackendCanisterUrl,
canisterId: Principal.fromText(this.config.civicBackendCanisterId),
origin: 'https://73ncn-4qaaa-aaaag-alddq-cai.icp0.io',
canisterId: Principal.fromText('73ncn-4qaaa-aaaag-alddq-cai'),
};

const credentialData = {
Expand All @@ -51,31 +53,31 @@ export class CredentialService {
credentialSubject: principal
};

console.log('Requesting Verifiable Credentials...', await this.getCredentialsFromCanister(principal.toText()));
console.log('Requesting Verifiable Credentials...', await this.getCredentialsFromCanister(p));

const onSuccess = (response: any) =>
console.log('VC Request Successful:', response);
// const onSuccess = (response: any) =>
// console.log('VC Request Successful:', response);

const onError = (error: any) =>
console.error('VC Request Failed:', error);
// const onError = (error: any) =>
// console.error('VC Request Failed:', error);

const iiUrl = 'https://identity.ic0.app';
const identityProvider = new URL(this.config.internetIdentityUrl);
// const iiUrl = 'https://identity.ic0.app';
// const identityProvider = new URL(this.config.internetIdentityUrl);

const derivationOrigin = undefined;
// const derivationOrigin = undefined;

console.log('Requesting Verifiable Presentation...', derivationOrigin);
// console.log('Requesting Verifiable Presentation...', derivationOrigin);

const requestParams = {
onSuccess,
onError,
credentialData,
issuerData,
identityProvider,
derivationOrigin
};
// const requestParams = {
// onSuccess,
// onError,
// credentialData,
// issuerData,
// identityProvider,
// derivationOrigin
// };

requestVerifiablePresentation(requestParams);
// requestVerifiablePresentation(requestParams);
} catch (error) {
console.error("Error getting credentials:", error);
}
Expand Down
4 changes: 2 additions & 2 deletions src/civic_sign_frontend_demo/src/service/PrincipalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export class PrincipalService implements PrincipalService {

const loginResult = new Promise((resolve, reject) => {
const { identityProvider } = this.config;
const iiUrl = 'https://identity.ic0.app';
this.authClient?.login({
identityProvider,

identityProvider: iiUrl,
onSuccess: resolve,
onError: reject
});
Expand Down

0 comments on commit 04a0e08

Please sign in to comment.