Skip to content

Commit

Permalink
dep updates! (#224)
Browse files Browse the repository at this point in the history
* Expose WebCryptoService to importers
* Dependency updates
  - notably, fixes an issue that seemed to be breaking web-test-runner on GitHub runners
* Improve types on 
* Fixes PRs building from forks that don't get a 'sonar cloud' token secret
  • Loading branch information
dmihalcik-virtru authored Aug 2, 2023
1 parent 0f02f27 commit 809caca
Show file tree
Hide file tree
Showing 9 changed files with 7,080 additions and 3,995 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
name: opentdf-client-lib
path: ./lib/opentdf-client-*.tgz
- name: SonarCloud Scan
if: >-
!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
7,252 changes: 4,917 additions & 2,335 deletions lib/package-lock.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
"watch": "(trap 'kill 0' SIGINT; npm run build && (npm run build:watch & npm run test -- --watch))"
},
"dependencies": {
"@aws-sdk/abort-controller": "^3.357.0",
"@aws-sdk/client-s3": "^3.367.0",
"@aws-sdk/middleware-endpoint": "^3.365.0",
"@aws-sdk/protocol-http": "^3.357.0",
"@aws-sdk/smithy-client": "^3.360.0",
"ajv": "^6.12.6",
"@aws-sdk/abort-controller": "^3.370.0",
"@aws-sdk/client-s3": "^3.379.1",
"@aws-sdk/middleware-endpoint": "^3.370.0",
"@aws-sdk/protocol-http": "^3.370.0",
"@aws-sdk/smithy-client": "^3.370.0",
"ajv": "^8.12.0",
"axios": "^1.4.0",
"axios-retry": "^3.5.1",
"axios-retry": "^3.6.0",
"browser-fs-access": "^0.34.1",
"buffer": "^6.0.3",
"buffer-crc32": "^0.2.13",
Expand All @@ -74,33 +74,33 @@
"uuid": "~9.0.0"
},
"devDependencies": {
"@aws-sdk/types": "^3.357.0",
"@aws-sdk/types": "^3.378.0",
"@esm-bundle/chai": "~4.3.4-fix.0",
"@types/buffer-crc32": "^0.2.2",
"@types/chai": "~4.3.5",
"@types/jest": "^29.5.3",
"@types/jsonwebtoken": "~9.0.2",
"@types/mocha": "~10.0.1",
"@types/node": "^20.4.1",
"@types/node": "^20.4.5",
"@types/send": "^0.17.1",
"@types/sinon": "~10.0.15",
"@types/streamsaver": "^2.0.1",
"@types/uuid": "~9.0.2",
"@types/wicg-file-system-access": "^2020.9.6",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"@web/dev-server-esbuild": "^0.4.1",
"@web/dev-server-rollup": "^0.5.2",
"@web/test-runner": "~0.16.1",
"@web/test-runner-commands": "~0.7.0",
"@web/test-runner": "~0.17.0",
"@web/test-runner-commands": "~0.8.0",
"audit-ci": "^6.6.1",
"c8": "^8.0.0",
"c8": "^8.0.1",
"chai": "^4.3.7",
"colors": "^1.4.0",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"glob": "^10.3.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-prettier": "^5.0.0",
"glob": "^10.3.3",
"jsdom": "^22.1.0",
"karma": "^6.4.2",
"karma-chrome-launcher": "^3.2.0",
Expand All @@ -110,12 +110,12 @@
"nyc": "^15.1.0",
"prettier": "^3.0.0",
"process": "^0.11.10",
"rollup": "^3.26.2",
"rollup": "^3.27.0",
"sinon": "~15.2.0",
"tsconfig-paths": "^4.2.0",
"typedoc": "^0.24.8",
"typescript": "5.1.6",
"webpack": "^5.88.1",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
}
}
4 changes: 2 additions & 2 deletions lib/src/tdf/AttributeObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export interface AttributeObject {
readonly isDefault?: boolean;
readonly displayName?: string;
/** PEM encoded public key */
readonly pubKey?: string;
readonly kasUrl?: string;
readonly pubKey: string;
readonly kasUrl: string;
/** The most recent version 1.1.0. */
readonly schemaVersion?: string;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/tdf3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ export {
createSessionKeys,
version,
};

export * as WebCryptoService from './src/crypto/index.js';
18 changes: 9 additions & 9 deletions lib/tdf3/src/models/attribute-set.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import Ajv from 'ajv';
import Ajv, { JSONSchemaType } from 'ajv';
import { decodeJwt } from 'jose';

const verbose = false;

export type AttributeObject = {
attribute: string;
kasUrl?: string;
pubKey?: string;
kasUrl: string;
pubKey: string;
displayName?: string;
isDefault?: boolean;
jwt?: string;
};

const ATTRIBUTE_OBJECT_SCHEMA = {
id: '/AttributeObject',
const ATTRIBUTE_OBJECT_SCHEMA: JSONSchemaType<AttributeObject> = {
$id: '/AttributeObject',
type: 'object',
properties: {
attribute: { type: 'string' },
displayName: { type: 'string' },
isDefault: { type: 'boolean' },
displayName: { type: 'string', nullable: true },
isDefault: { type: 'boolean', nullable: true },
pubKey: { type: 'string' },
kasUrl: { type: 'string' },
jwt: { type: 'string' },
jwt: { type: 'string', nullable: true },
},
required: ['attribute', 'pubKey', 'kasUrl'],
additionalProperties: false,
};

const validator = new Ajv();
const validator = new Ajv.default();

export class AttributeSet {
attributes: AttributeObject[];
Expand Down
19 changes: 12 additions & 7 deletions lib/tests/mocha/unit/builders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,42 @@ import { expect, assert } from 'chai';
import { type AttributeObject } from '../../../src/tdf/index.js';
import { EncryptParamsBuilder } from '../../../tdf3/src/client/builders.js';

const aex = {
kasUrl: 'https://kas',
pubKey: 'PUBKEY',
};

describe('EncyptParamsBuilder', () => {
describe('setAttributes', () => {
it('should accept valid attribute', () => {
const paramsBuilder = new EncryptParamsBuilder();
const attribute = { attribute: 'http://example.com/attr/somarrt/value/someval' };
const attribute = { attribute: 'http://example.com/attr/somarrt/value/someval', ...aex };
paramsBuilder.withAttributes([attribute]);
});

it('should accept ip and port host', () => {
const paramsBuilder = new EncryptParamsBuilder();
const attribute = { attribute: 'http://127.0.0.1:4000/attr/sameval/value/otherval' };
const attribute = { attribute: 'http://127.0.0.1:4000/attr/sameval/value/otherval', ...aex };
paramsBuilder.withAttributes([attribute]);
});

it('should accept www host ', () => {
const paramsBuilder = new EncryptParamsBuilder();
const attribute = { attribute: 'http://www.example.com/attr/sameval/value/otherval' };
const attribute = { attribute: 'http://www.example.com/attr/sameval/value/otherval', ...aex };
paramsBuilder.withAttributes([attribute]);
});

it('should not accept empty attributes', () => {
const paramsBuilder = new EncryptParamsBuilder();
const emptyAttribute = {};
const emptyAttribute = { ...aex };
expect(() =>
paramsBuilder.withAttributes([emptyAttribute as AttributeObject]).build()
paramsBuilder.withAttributes([emptyAttribute as unknown as AttributeObject]).build()
).to.throw(Error, /attribute prop should be a string/);
});

it('should check attrName uniq with attrVal', () => {
const paramsBuilder = new EncryptParamsBuilder();
const attribute = { attribute: 'http://example.com/attr/sameval/value/sameval' };
const attribute = { attribute: 'http://example.com/attr/sameval/value/sameval', ...aex };
expect(() => paramsBuilder.withAttributes([attribute])).to.throw(
Error,
/attribute name should be unique/
Expand All @@ -43,7 +48,7 @@ describe('EncyptParamsBuilder', () => {
it('should not accept attribute wrapped with text', () => {
const paramsBuilder = new EncryptParamsBuilder();
const attrUrl = 'http://example.com/attr/sameval/value/sameval';
const attribute = { attribute: `sometext${attrUrl}somemoretext` };
const attribute = { attribute: `sometext${attrUrl}somemoretext`, ...aex };
expect(() => paramsBuilder.withAttributes([attribute])).to.throw(
Error,
/attribute is in invalid format/
Expand Down
Loading

0 comments on commit 809caca

Please sign in to comment.