Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
key: ${{ github.sha }}
test:
name: Run unit tests
if: false
runs-on: ubuntu-latest
needs: [install]
steps:
Expand Down
17 changes: 16 additions & 1 deletion extra-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ const sentryPlugin = () => {
};
module.exports = {
devtool: 'source-map',
resolve: {
fallback: {
zlib: require.resolve('browserify-zlib'),
stream: require.resolve('stream-browserify'),
vm: require.resolve('vm-browserify'),
},
},
plugins: [
new NodePolyfillPlugin({
excludeAliases: [
Expand All @@ -41,13 +48,21 @@ module.exports = {
'tty',
'util',
'vm',
'zlib',
],
}),
new webpack.DefinePlugin({
SENTRY_DSN: JSON.stringify(process.env.SENTRY_DSN),
INFURA_PROJECT_ID: JSON.stringify(process.env?.INFURA_PROJECT_ID),
INFURA_PROJECT_SECRET: JSON.stringify(process.env?.INFURA_PROJECT_SECRET),
AWS_ACCESS_KEY_ID: JSON.stringify(process.env?.AWS_ACCESS_KEY_ID),
AWS_SECRET_ACCESS_KEY: JSON.stringify(process.env?.AWS_SECRET_ACCESS_KEY),
AWS_REGION: JSON.stringify(process.env?.AWS_REGION),
AWS_S3_BUCKET: JSON.stringify(process.env?.AWS_S3_BUCKET),
'process.env': JSON.stringify({
FORCE_COLOR: '0',
NODE_ENV: process.env.NODE_ENV || 'development',
DEBUG: process.env.DEBUG || '',
}),
}),
new Dotenv(),
...sentryPlugin(),
Expand Down
50,274 changes: 19,338 additions & 30,936 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"@angular/platform-browser-dynamic": "15.2.8",
"@angular/router": "15.2.8",
"@angular/service-worker": "15.2.8",
"@ew-did-registry/credentials-interface": "0.8.1-alpha.1037.0",
"@ew-did-registry/did-resolver-interface": "0.8.1-alpha.1037.0",
"@ew-did-registry/credentials-interface": "0.9.1-alpha.1545.0",
"@ew-did-registry/did-resolver-interface": "0.9.1-alpha.1545.0",
"@fortawesome/fontawesome-free": "5.15.4",
"@metamask/detect-provider": "^1.2.0",
"@ngrx/effects": "15.4.0",
Expand All @@ -56,6 +56,7 @@
"@sentry/angular": "^7.49.0",
"@sentry/tracing": "^7.49.0",
"@sphereon/pex": "^1.1.0",
"@sphereon/ssi-types": "^0.34.0",
"@zxing/browser": "0.1.3",
"@zxing/library": "0.20.0",
"@zxing/ngx-scanner": "3.9.0",
Expand All @@ -65,7 +66,7 @@
"core-js": "3.30.1",
"eslint": "^8.42.0",
"hammerjs": "^2.0.8",
"iam-client-lib": "^8.0.0-alpha.8",
"iam-client-lib": "^8.2.0-alpha.1",
"jsoneditor": "^9.10.0",
"ng-qrcode": "^8.0.1",
"ngx-spinner": "^15.0.1",
Expand Down Expand Up @@ -102,6 +103,7 @@
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"browserify-zlib": "^0.2.0",
"dotenv-webpack": "^8.0.1",
"eslint-config-prettier": "^8.8.0",
"husky": "^8.0.3",
Expand All @@ -119,8 +121,10 @@
"node-polyfill-webpack-plugin": "^1.1.4",
"patch-package": "^6.5.1",
"prettier": "^2.8.8",
"stream-browserify": "^3.0.0",
"ts-node": "7.0.0",
"typescript": "~4.9.4",
"vm-browserify": "^1.1.2",
"webpack-bundle-analyzer": "4.8.0"
},
"browser": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
} from '../../../routes/registration/utils/precondition-check';
import { filter, switchMap } from 'rxjs/operators';
import { EnrolmentSubmission } from '../../../routes/registration/enrolment-form/enrolment-form.component';
import { IRole, IRoleDefinitionV2 } from 'iam-client-lib';
import { IFieldDefinition, IRole, IRoleDefinitionV2 } from 'iam-client-lib';
import { MatLegacySelectChange as MatSelectChange } from '@angular/material/legacy-select';
import { IFieldDefinition } from '@energyweb/credential-governance/dist/src/types/domain-definitions';

const DEFAULT_CLAIM_TYPE_VERSION = 1;

Expand Down Expand Up @@ -159,7 +158,7 @@

// TODO: add proper typing and remove any.
return {
claimType: (this.getFormType().value as any).namespace,

Check warning on line 161 in src/app/modules/issue-vc/new-issue-vc/new-issue-vc.component.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/app/modules/issue-vc/new-issue-vc/new-issue-vc.component.ts#L161

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
claimTypeVersion:
parseVersion(this.selectedRoleDefinition.version) ||
DEFAULT_CLAIM_TYPE_VERSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Component, Input } from '@angular/core';
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog';
import {
IFieldDefinition,
IIssuerDefinition,
IRevokerDefinition,
NamespaceType,
PreconditionType,
Expand All @@ -12,7 +13,6 @@ import { IamService } from '../../../../shared/services/iam.service';
import { LoadingService } from '../../../../shared/services/loading.service';
import { GovernanceViewComponent } from '../governance-view.component';
import { IssuerType } from '../../new-role/models/issuer-type.enum';
import { IIssuerDefinition } from '@energyweb/credential-governance/dist/src/types/domain-definitions';

@Component({
selector: 'app-governance-details',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { truthy } from '@operators';
import { FieldTypesEnum } from './field-form.enum';
import Ajv from 'ajv';
import { JsonEditorComponent, JsonEditorOptions } from '@modules';
import { IFieldDefinition } from '@energyweb/credential-governance/dist/src/types/domain-definitions';
import { IFieldDefinition } from 'iam-client-lib';

const FIELD_TYPES = [
FieldTypesEnum.Text,
Expand Down
2 changes: 1 addition & 1 deletion src/app/routes/enrolment/fields/fields.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
Output,
} from '@angular/core';
import { KeyValue } from '@angular/common';
import { IFieldDefinition } from '@energyweb/credential-governance/dist/src/types/domain-definitions';
import { JsonObject } from '@angular-devkit/core';
import { IFieldDefinition } from 'iam-client-lib';

@Component({
selector: 'app-fields',
Expand Down
18 changes: 9 additions & 9 deletions src/app/routes/enrolment/models/enrolment-claim.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('EnrolmentClaim tests', () => {
isAccepted: true,
registrationTypes: [RegistrationTypes.OnChain],
expirationTimestamp: (Date.now() + 500000).toString(),
} as Claim).canPublishClaim
} as unknown as Claim).canPublishClaim
).toBeTrue();
});
it('should return false if claim is not synced and claim IS expired', () => {
Expand All @@ -299,7 +299,7 @@ describe('EnrolmentClaim tests', () => {
isAccepted: true,
registrationTypes: [RegistrationTypes.OnChain],
expirationTimestamp: (Date.now() - 500).toString(),
} as Claim).canPublishClaim
} as unknown as Claim).canPublishClaim
).toBeFalse();
});
it('should return false if claim IS synced and claim is not expired', () => {
Expand All @@ -308,7 +308,7 @@ describe('EnrolmentClaim tests', () => {
isAccepted: true,
registrationTypes: [RegistrationTypes.OffChain],
expirationTimestamp: (Date.now() + 5000).toString(),
} as Claim).setIsSyncedOffChain(true).canPublishClaim
} as unknown as Claim).setIsSyncedOffChain(true).canPublishClaim
).toBeFalse();
});
it('should return false if claim IS synced and claim IS expired', () => {
Expand All @@ -317,7 +317,7 @@ describe('EnrolmentClaim tests', () => {
isAccepted: true,
registrationTypes: [RegistrationTypes.OffChain],
expirationTimestamp: (Date.now() - 50).toString(),
} as Claim).setIsSyncedOffChain(true).canPublishClaim
} as unknown as Claim).setIsSyncedOffChain(true).canPublishClaim
).toBeFalse();
});
});
Expand All @@ -327,14 +327,14 @@ describe('EnrolmentClaim tests', () => {
expect(
new EnrolmentClaim({
expirationTimestamp: (Date.now() - 500).toString(),
} as Claim).isExpired
} as unknown as Claim).isExpired
).toBeTrue();
});
it('should return false if claim expiration timestamp is in the future', () => {
expect(
new EnrolmentClaim({
expirationTimestamp: (Date.now() + 5000).toString(),
} as Claim).isExpired
} as unknown as Claim).isExpired
).toBeFalse();
});
it('should return false if there is no timestamp', () => {
Expand Down Expand Up @@ -459,15 +459,15 @@ describe('EnrolmentClaim tests', () => {
new EnrolmentClaim({
claimType: `role.${NamespaceType.Role}.test.iam.ewc`,
expirationTimestamp: (Date.now() + 500000).toString(),
} as Claim).expirationStatus
} as unknown as Claim).expirationStatus
).toEqual(ExpirationStatus.NOT_EXPIRED);
});
it('should have an expiration status of "Expired" when expired', () => {
expect(
new EnrolmentClaim({
claimType: `role.${NamespaceType.Role}.test.iam.ewc`,
expirationTimestamp: (Date.now() - 1000).toString(),
} as Claim).expirationStatus
} as unknown as Claim).expirationStatus
).toEqual(ExpirationStatus.EXPIRED);
});
it('should not have an expiration status of when there is no expiration timestamp', () => {
Expand All @@ -483,7 +483,7 @@ describe('EnrolmentClaim tests', () => {
new EnrolmentClaim({
claimType: `role.${NamespaceType.Role}.test.iam.ewc`,
expirationTimestamp: '193984857',
} as Claim).expirationDate
} as unknown as Claim).expirationDate
).toEqual(new Date(193984857));
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/app/routes/enrolment/models/enrolment-claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

isRevokedOnChain: boolean;
isRevokedOffChain: boolean;
decodedToken: string | { [key: string]: any };

Check warning on line 26 in src/app/routes/enrolment/models/enrolment-claim.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/app/routes/enrolment/models/enrolment-claim.ts#L26

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
createdAt: string;
status: FilterStatus;

Expand Down Expand Up @@ -75,7 +75,7 @@
get isExpired() {
return (
!!this.iclClaim.expirationTimestamp &&
parseInt(this.iclClaim.expirationTimestamp) < Date.now()
this.iclClaim.expirationTimestamp < Date.now()
);
}

Expand Down Expand Up @@ -150,7 +150,7 @@
return this;
}

setDecodedToken(token: string | { [key: string]: any }) {

Check warning on line 153 in src/app/routes/enrolment/models/enrolment-claim.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/app/routes/enrolment/models/enrolment-claim.ts#L153

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
this.decodedToken = token;
return this;
}
Expand Down Expand Up @@ -221,7 +221,7 @@
}

private defineRequestDate(): void {
this.requestDate = new Date((this.iclClaim as any).createdAt);

Check warning on line 224 in src/app/routes/enrolment/models/enrolment-claim.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/app/routes/enrolment/models/enrolment-claim.ts#L224

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
}

private defineExpirationStatus() {
Expand All @@ -236,7 +236,7 @@

private defineExpirationDate(): void {
this.expirationDate = this.iclClaim.expirationTimestamp
? new Date(parseInt(this.iclClaim.expirationTimestamp))
? new Date(this.iclClaim.expirationTimestamp)
: null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
import { EnrolmentForm } from '../../../registration/enrolment-form/enrolment-form.component';
import { EnrolmentClaim } from '../../models/enrolment-claim';
import { IRoleDefinitionV2 } from 'iam-client-lib';
import { IFieldDefinition, IRoleDefinitionV2 } from 'iam-client-lib';
import {
MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA,
MatLegacyDialogRef as MatDialogRef,
Expand All @@ -10,7 +10,6 @@ import { TokenDecodeService } from '../services/token-decode.service';
import { IssuerRequestsService } from '../services/issuer-requests.service';
import { RoleService } from '../../../../state/governance/role/services/role.service';
import { ViewRequestsComponent } from '../view-requests.component';
import { IFieldDefinition } from '@energyweb/credential-governance/dist/src/types/domain-definitions';
import { KeyValue } from '@angular/common';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
Output,
} from '@angular/core';
import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms';
import { RegistrationTypes } from 'iam-client-lib';
import { IFieldDefinition, RegistrationTypes } from 'iam-client-lib';
import { KeyValue } from '@angular/common';
import { IFieldDefinition } from '@energyweb/credential-governance/dist/src/types/domain-definitions';
import { FieldTypesEnum } from '../../applications/new-role/components/field-form/field-form.enum';
import { JsonEditorOptions } from '@modules';
import Ajv, { Schema } from 'ajv';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,12 @@ export class RequestClaimComponent implements OnInit, SubjectElements {
registrationTypes: enrolForm.registrationTypes,
});

// TODO: Improve form field type from string to object
this.displayAlert(
'Request to enrol as ' +
this.roleTypeForm.value.roleType.toUpperCase() +
(
this.roleTypeForm.value.roleType as unknown as { name: string }
).name.toUpperCase() +
' is submitted for review and approval.',
'success'
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IVerifiableCredential } from '@sphereon/pex';
import { IVerifiableCredential } from '@sphereon/ssi-types';

interface ICredentialData {
role: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, Input } from '@angular/core';
import { MatLegacyTableDataSource as MatTableDataSource } from '@angular/material/legacy-table';
import { ICredentialTableData } from '../models/credential-table-data.interface';
import { IVerifiableCredential } from '@sphereon/pex';
import { MatLegacySelect as MatSelect } from '@angular/material/legacy-select';
import { IVerifiableCredential } from '@sphereon/ssi-types';

@Component({
selector: 'app-received-presentations',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { filter, take } from 'rxjs/operators';
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog';
import { isUserLoggedIn } from '../../../state/auth/auth.selectors';
import { VpRequestInteractService } from '@ew-did-registry/credentials-interface';
import { IPresentationDefinition, IVerifiableCredential } from '@sphereon/pex';
import { IPresentationDefinition } from '@sphereon/pex';
import { ICredentialTableData } from '../models/credential-table-data.interface';
import { PresentationService } from '../services/presentation.service';
import SWAL from 'sweetalert';
import { truncate } from 'fs';
import { IVerifiableCredential } from '@sphereon/ssi-types';

@Component({
selector: 'app-verifiable-presentation',
Expand Down
5 changes: 5 additions & 0 deletions src/app/shared/services/env/env.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ export class EnvService {
INFURA_PROJECT_SECRET: string =
INFURA_PROJECT_SECRET ?? process?.env?.INFURA_PROJECT_SECRET;
orgRequestEmail: string = environment.orgRequestEmail;
AWS_ACCESS_KEY_ID: string = AWS_S3_BUCKET ?? process?.env?.AWS_ACCESS_KEY_ID;
AWS_SECRET_ACCESS_KEY: string =
AWS_S3_BUCKET ?? process?.env?.AWS_SECRET_ACCESS_KEY;
AWS_REGION: string = AWS_S3_BUCKET ?? process?.env?.AWS_REGION;
AWS_S3_BUCKET: string = AWS_S3_BUCKET ?? process?.env?.AWS_S3_BUCKET;
}
26 changes: 14 additions & 12 deletions src/app/shared/services/iam.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class IamService {
}
if (createDocument) {
const { didRegistry, claimsService } = await connectToDidRegistry(
this.configureIpfsConfig()
this.configureDidStoreConfig()
);
this.didRegistry = didRegistry;
this.claimsService = claimsService;
Expand Down Expand Up @@ -274,18 +274,20 @@ export class IamService {
return chainConfig;
}

private configureIpfsConfig() {
const projectId = this.envService.INFURA_PROJECT_ID;
const projectSecret = this.envService.INFURA_PROJECT_SECRET;
const auth =
'Basic ' +
Buffer.from(projectId + ':' + projectSecret).toString('base64');
private configureDidStoreConfig() {
const AWS_ACCESS_KEY_ID = this.envService.AWS_ACCESS_KEY_ID;
const AWS_SECRET_ACCESS_KEY = this.envService.AWS_SECRET_ACCESS_KEY;
const AWS_REGION = this.envService.AWS_REGION;
const AWS_S3_BUCKET = this.envService.AWS_S3_BUCKET;
return {
host: 'ipfs.infura.io',
port: 5001,
protocol: 'https',
headers: {
authorization: auth,
host: '',
bucketName: AWS_S3_BUCKET,
credential: {
region: AWS_REGION,
credentials: {
accessKeyId: AWS_ACCESS_KEY_ID,
secretAccessKey: AWS_SECRET_ACCESS_KEY,
},
},
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/state/enrolments/owned/owned.selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Owned Enrolments Selectors', () => {
isAccepted: true,
registrationTypes: [RegistrationTypes.OnChain],
expirationTimestamp: (Date.now() + 500000).toString(),
} as Claim),
} as unknown as Claim),
])
).toEqual(1);
});
Expand All @@ -43,7 +43,7 @@ describe('Owned Enrolments Selectors', () => {
isAccepted: true,
registrationTypes: [RegistrationTypes.OffChain],
expirationTimestamp: (Date.now() + 500000).toString(),
} as Claim).setIsSyncedOffChain(false),
} as unknown as Claim).setIsSyncedOffChain(false),
])
).toEqual(1);
});
Expand Down
4 changes: 4 additions & 0 deletions src/vendor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
declare const SENTRY_DSN: string;

Check warning on line 1 in src/vendor.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/vendor.ts#L1

[@typescript-eslint/no-unused-vars] 'SENTRY_DSN' is defined but never used.
declare const INFURA_PROJECT_ID: string;

Check warning on line 2 in src/vendor.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/vendor.ts#L2

[@typescript-eslint/no-unused-vars] 'INFURA_PROJECT_ID' is defined but never used.
declare const INFURA_PROJECT_SECRET: string;

Check warning on line 3 in src/vendor.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/vendor.ts#L3

[@typescript-eslint/no-unused-vars] 'INFURA_PROJECT_SECRET' is defined but never used.
declare const AWS_ACCESS_KEY_ID: string;

Check warning on line 4 in src/vendor.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/vendor.ts#L4

[@typescript-eslint/no-unused-vars] 'AWS_ACCESS_KEY_ID' is defined but never used.
declare const AWS_SECRET_ACCESS_KEY: string;

Check warning on line 5 in src/vendor.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/vendor.ts#L5

[@typescript-eslint/no-unused-vars] 'AWS_SECRET_ACCESS_KEY' is defined but never used.
declare const AWS_REGION: string;

Check warning on line 6 in src/vendor.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/vendor.ts#L6

[@typescript-eslint/no-unused-vars] 'AWS_REGION' is defined but never used.
declare const AWS_S3_BUCKET: string;

Check warning on line 7 in src/vendor.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

src/vendor.ts#L7

[@typescript-eslint/no-unused-vars] 'AWS_S3_BUCKET' is defined but never used.
Loading