Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add issuer app #2083

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/canister-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,13 @@ jobs:
demos/vc_issuer/target
key: ${{ runner.os }}-cargo-${{ hashFiles('demos/vc_issuer/Cargo.lock', 'rust-toolchain.toml') }}
- uses: ./.github/actions/bootstrap
- uses: ./.github/actions/setup-node

- name: "Build VC issuer canister"
working-directory: demos/vc_issuer
run: ./build.sh
run: |
npm ci
./build.sh
- run: sha256sum vc_issuer.wasm.gz
working-directory: demos/vc_issuer
- name: 'Upload VC issuer'
Expand Down Expand Up @@ -318,7 +322,12 @@ jobs:
./ic-test-state-machine --version
- name: "Run VC issuer canister tests"
working-directory: demos/vc_issuer
run: cargo test
run: |
# create dummy assets
mkdir dist
touch dist/index.{html,css,js}
touch dist/index2.js
cargo test

###########################
# The Rust canister tests #
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/frontend-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ jobs:
run: npm run format-check
- uses: ./.github/actions/setup-didc
- name: Generate type interfaces
run: npm run generate
run: |
npm run generate
cd demos/vc_issuer
npm run generate
- name: Check for dapp logos
run: |
while read -r logo
Expand All @@ -37,7 +40,9 @@ jobs:
# We don't want to commit automatic changes to main
if: ${{ github.ref != 'refs/heads/main' }}
with:
add: src/frontend/generated
add: |
src/frontend/generated
demos/vc_issuer/app/generated
default_author: github_actions
message: "🤖 npm run generate auto-update"

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ jobs:
# `manual_range_contains` is disabled because a >= x && a < y reads more clearly than (x..y).contains(a) and
# there are additional caveats for floating point numbers (https://github.com/rust-lang/rust-clippy/issues/6455)
run: |
# dummy assets
mkdir -p dist
touch dist/index.{html,css,js}
touch dist/index2.js

cargo clippy -- -D clippy::all -D warnings -A clippy::manual_range_contains
cargo clippy --tests --benches -- -D clippy::all -D warnings -A clippy::manual_range_contains

Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ src/frontend/generated/
dist/
.env
lib
demos/vc_issuer/app/generated/

# Cargo build output
target/
1 change: 1 addition & 0 deletions demos/vc_issuer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions demos/vc_issuer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ serde_json = "1"
sha2 = "^0.10" # set bound to match ic-certified-map bound
strfmt = "0.2"
lazy_static = "1.4"
base64 = "0.21"

[dev-dependencies]
assert_matches = "1.5.0"
Expand Down
90 changes: 90 additions & 0 deletions demos/vc_issuer/app/generated/vc_issuer_idl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
export const idlFactory = ({ IDL }) => {
const IssuerConfig = IDL.Record({
'idp_canister_ids' : IDL.Vec(IDL.Principal),
'ic_root_key_der' : IDL.Vec(IDL.Nat8),
});
const SignedIdAlias = IDL.Record({ 'credential_jws' : IDL.Text });
const ArgumentValue = IDL.Variant({ 'Int' : IDL.Int32, 'String' : IDL.Text });
const CredentialSpec = IDL.Record({
'arguments' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, ArgumentValue))),
'credential_type' : IDL.Text,
});
const GetCredentialRequest = IDL.Record({
'signed_id_alias' : SignedIdAlias,
'prepared_context' : IDL.Opt(IDL.Vec(IDL.Nat8)),
'credential_spec' : CredentialSpec,
});
const IssuedCredentialData = IDL.Record({ 'vc_jws' : IDL.Text });
const IssueCredentialError = IDL.Variant({
'Internal' : IDL.Text,
'SignatureNotFound' : IDL.Text,
'InvalidIdAlias' : IDL.Text,
'UnauthorizedSubject' : IDL.Text,
'UnknownSubject' : IDL.Text,
'UnsupportedCredentialSpec' : IDL.Text,
});
const GetCredentialResponse = IDL.Variant({
'Ok' : IssuedCredentialData,
'Err' : IssueCredentialError,
});
const PrepareCredentialRequest = IDL.Record({
'signed_id_alias' : SignedIdAlias,
'credential_spec' : CredentialSpec,
});
const PreparedCredentialData = IDL.Record({
'prepared_context' : IDL.Opt(IDL.Vec(IDL.Nat8)),
});
const PrepareCredentialResponse = IDL.Variant({
'Ok' : PreparedCredentialData,
'Err' : IssueCredentialError,
});
const Icrc21ConsentPreferences = IDL.Record({ 'language' : IDL.Text });
const Icrc21VcConsentMessageRequest = IDL.Record({
'preferences' : Icrc21ConsentPreferences,
'credential_spec' : CredentialSpec,
});
const Icrc21ConsentInfo = IDL.Record({
'consent_message' : IDL.Text,
'language' : IDL.Text,
});
const Icrc21ErrorInfo = IDL.Record({
'description' : IDL.Text,
'error_code' : IDL.Nat64,
});
const Icrc21Error = IDL.Variant({
'GenericError' : Icrc21ErrorInfo,
'UnsupportedCanisterCall' : Icrc21ErrorInfo,
'ConsentMessageUnavailable' : Icrc21ErrorInfo,
});
const Icrc21ConsentMessageResponse = IDL.Variant({
'Ok' : Icrc21ConsentInfo,
'Err' : Icrc21Error,
});
return IDL.Service({
'add_employee' : IDL.Func([IDL.Principal], [IDL.Text], []),
'add_graduate' : IDL.Func([IDL.Principal], [IDL.Text], []),
'configure' : IDL.Func([IssuerConfig], [], []),
'get_credential' : IDL.Func(
[GetCredentialRequest],
[GetCredentialResponse],
['query'],
),
'prepare_credential' : IDL.Func(
[PrepareCredentialRequest],
[PrepareCredentialResponse],
[],
),
'vc_consent_message' : IDL.Func(
[Icrc21VcConsentMessageRequest],
[Icrc21ConsentMessageResponse],
[],
),
});
};
export const init = ({ IDL }) => {
const IssuerConfig = IDL.Record({
'idp_canister_ids' : IDL.Vec(IDL.Principal),
'ic_root_key_der' : IDL.Vec(IDL.Nat8),
});
return [IDL.Opt(IssuerConfig)];
};
71 changes: 71 additions & 0 deletions demos/vc_issuer/app/generated/vc_issuer_types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import type { Principal } from '@dfinity/principal';
import type { ActorMethod } from '@dfinity/agent';
import type { IDL } from '@dfinity/candid';

export type ArgumentValue = { 'Int' : number } |
{ 'String' : string };
export interface CredentialSpec {
'arguments' : [] | [Array<[string, ArgumentValue]>],
'credential_type' : string,
}
export interface GetCredentialRequest {
'signed_id_alias' : SignedIdAlias,
'prepared_context' : [] | [Uint8Array | number[]],
'credential_spec' : CredentialSpec,
}
export type GetCredentialResponse = { 'Ok' : IssuedCredentialData } |
{ 'Err' : IssueCredentialError };
export interface Icrc21ConsentInfo {
'consent_message' : string,
'language' : string,
}
export type Icrc21ConsentMessageResponse = { 'Ok' : Icrc21ConsentInfo } |
{ 'Err' : Icrc21Error };
export interface Icrc21ConsentPreferences { 'language' : string }
export type Icrc21Error = { 'GenericError' : Icrc21ErrorInfo } |
{ 'UnsupportedCanisterCall' : Icrc21ErrorInfo } |
{ 'ConsentMessageUnavailable' : Icrc21ErrorInfo };
export interface Icrc21ErrorInfo {
'description' : string,
'error_code' : bigint,
}
export interface Icrc21VcConsentMessageRequest {
'preferences' : Icrc21ConsentPreferences,
'credential_spec' : CredentialSpec,
}
export type IssueCredentialError = { 'Internal' : string } |
{ 'SignatureNotFound' : string } |
{ 'InvalidIdAlias' : string } |
{ 'UnauthorizedSubject' : string } |
{ 'UnknownSubject' : string } |
{ 'UnsupportedCredentialSpec' : string };
export interface IssuedCredentialData { 'vc_jws' : string }
export interface IssuerConfig {
'idp_canister_ids' : Array<Principal>,
'ic_root_key_der' : Uint8Array | number[],
}
export interface PrepareCredentialRequest {
'signed_id_alias' : SignedIdAlias,
'credential_spec' : CredentialSpec,
}
export type PrepareCredentialResponse = { 'Ok' : PreparedCredentialData } |
{ 'Err' : IssueCredentialError };
export interface PreparedCredentialData {
'prepared_context' : [] | [Uint8Array | number[]],
}
export interface SignedIdAlias { 'credential_jws' : string }
export interface _SERVICE {
'add_employee' : ActorMethod<[Principal], string>,
'add_graduate' : ActorMethod<[Principal], string>,
'configure' : ActorMethod<[IssuerConfig], undefined>,
'get_credential' : ActorMethod<[GetCredentialRequest], GetCredentialResponse>,
'prepare_credential' : ActorMethod<
[PrepareCredentialRequest],
PrepareCredentialResponse
>,
'vc_consent_message' : ActorMethod<
[Icrc21VcConsentMessageRequest],
Icrc21ConsentMessageResponse
>,
}
export declare const idlFactory: IDL.InterfaceFactory;
14 changes: 14 additions & 0 deletions demos/vc_issuer/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>VC Issuer</title>
<link rel="shortcut icon" href="/favicon.ico" />
<script type="module" src="./index.tsx"></script>
</head>
<body>
<div id="root"></div>
</body>
</html>
Loading