Skip to content

Commit

Permalink
verification flow
Browse files Browse the repository at this point in the history
  • Loading branch information
maycon-mello committed Aug 16, 2023
1 parent 057a930 commit 657d142
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/account-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function createAccountProvider({wallet}: ICreateAccountsProvider) {
walletService: toV1WalletService(wallet),
});

Accounts.instance = accountsModule;
(Accounts as any).instance = accountsModule;

return accountsModule;
}
11 changes: 11 additions & 0 deletions packages/core/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function isURL(str) {
try {
// eslint-disable-next-line no-new
new URL(str);
return true;
} catch (err) {
return false;
}
}

export function getJSONOrUrl(data) {}
2 changes: 1 addition & 1 deletion packages/core/src/v1-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function toV1Wallet(wallet: IWallet): Promise<IWallet> {
...wallet,
};

accounts.wallet = newWallet;
(accounts as any).wallet = newWallet;

return newWallet;
}
Expand Down
25 changes: 25 additions & 0 deletions packages/core/src/verification-provider.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {IWallet} from './types';
import {createVerificationProvider} from './verification-provider';
import {createWallet} from './wallet';

describe('Verification provider', () => {
let verificationProvider;
let wallet: IWallet;

beforeAll(async () => {
wallet = await createWallet({
databasePath: ':memory:',
});
verificationProvider = createVerificationProvider({
wallet,
});
});

it('expect to create verification controller', () => {
const controller = verificationProvider.start({
template: 'https://creds-testnet.dock.io/proof/6de279ba-caf3-4979-a067-553284b40767',
});

console.log(controller);
});
});
51 changes: 51 additions & 0 deletions packages/core/src/verification-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
export function createVerificationController({wallet}) {
let templateJSON = null;
let credentials = [];
let selectedCredentials = [];
let selectedAttributes = [];
let didKeyPair = null;

function setTemplate(template) {
// TODO: fetch URL data
templateJSON = template;
}

function loadCredentials() {
// get wallet credentials and apply pex filter
}

function selectCredential(credentialId: string) {

}

function selectCredentialAttribute(credentialId: string, attributePath: string) {

}

function createPresentation() {
// for the given credential selection
// it will create a presentation
}

return {
setTemplate,
loadCredentials,
selectCredential,
selectCredentialAttribute,
createPresentation,
};
}

export function createVerificationProvider({wallet}) {
return {
start: ({template}) => {
const controller = createVerificationController({
wallet,
});

controller.setTemplate(template);

return controller;
},
};
}

0 comments on commit 657d142

Please sign in to comment.