Skip to content

Commit

Permalink
Merge pull request #58 from velocitycareerlabs/VL-7723
Browse files Browse the repository at this point in the history
v0.8.14 proper usage of Nullish
  • Loading branch information
michaelavoyan authored May 6, 2024
2 parents 98e29d4 + 155ec57 commit feed755
Show file tree
Hide file tree
Showing 56 changed files with 64 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/sample-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@fastify/autoload": "~5.7.1",
"env-var": "~7.3.0",
"fastify": "~4.15.0",
"@velocitycareerlabs/vnf-nodejs-wallet-sdk": "^0.8.13"
"@velocitycareerlabs/vnf-nodejs-wallet-sdk": "^0.8.14"
},
"devDependencies": {
"@jest/globals": "~29.5.0",
Expand Down
1 change: 1 addition & 0 deletions packages/sample-server/test/initalization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import VCLJwtSignService from "@velocitycareerlabs/vnf-nodejs-wallet-sdk/src/api
import VCLJwtDescriptor from "@velocitycareerlabs/vnf-nodejs-wallet-sdk/src/api/entities/VCLJwtDescriptor";
import VCLJwt from "@velocitycareerlabs/vnf-nodejs-wallet-sdk/src/api/entities/VCLJwt";
import VCLJwtVerifyService from "@velocitycareerlabs/vnf-nodejs-wallet-sdk/src/api/jwt/VCLJwtVerifyService";
import { Nullish } from "@velocitycareerlabs/vnf-nodejs-wallet-sdk/src/api/Nullish";

describe("initalization flow", () => {
let appInstance: FastifyInstance;
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@velocitycareerlabs/vnf-nodejs-wallet-sdk",
"version": "0.8.13",
"version": "0.8.14",
"description": "VNF Wallet SDK Nodejs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/VCL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import VCLSubmissionResult from "./entities/VCLSubmissionResult";
import VCLToken from "./entities/VCLToken";
import VCLVerifiedProfile from "./entities/VCLVerifiedProfile";
import VCLVerifiedProfileDescriptor from "./entities/VCLVerifiedProfileDescriptor";
import { Nullish } from "../types";

export default interface VCL {
initialize(
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLCountries.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLCountry from "./VCLCountry";

class VCLCountries {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLCountry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLPlace from "./VCLPlace";
import VCLRegions from "./VCLRegions";

Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLCredentialManifest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLJwt from "./VCLJwt";
import VCLVerifiedProfile from "./VCLVerifiedProfile";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLIssuingType from "./VCLIssuingType";
import VCLPushDelegate from "./VCLPushDelegate";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLCredentialManifestDescriptor from "./VCLCredentialManifestDescriptor";
import VCLDeepLink from "./VCLDeepLink";
import VCLIssuingType from "./VCLIssuingType";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLCredentialManifestDescriptor from "./VCLCredentialManifestDescriptor";
import VCLIssuingType from "./VCLIssuingType";
import VCLPushDelegate from "./VCLPushDelegate";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLCredentialManifestDescriptor from "./VCLCredentialManifestDescriptor";
import VCLIssuingType from "./VCLIssuingType";
import VCLService from "./VCLService";
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/src/api/entities/VCLCredentialType.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Nullish } from "../../types";

export default class VCLCredentialType {
constructor(
public payload: JSONObject,
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLCredentialTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLCredentialType from "./VCLCredentialType";

export default class VCLCredentialTypes {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLDeepLink.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "../../impl/extensions/StringExtensions";
import { Nullish } from "../../types";

export default class VCLDeepLink {
public requestUri: Nullish<string>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLCredentialManifest from "./VCLCredentialManifest";
import VCLVerifiableCredential from "./VCLVerifiableCredential";

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/api/entities/VCLJwt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JWK, base64url } from "jose";
import { Nullish } from "../../types";

export default class VCLJwt {
public encodedJwt: Nullish<string>;
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLJwtDescriptor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { randomUUID } from "crypto";
import VCLDidJwk from "./VCLDidJwk";
import { Nullish } from "../../types";

export default class VCLJwtDescriptor {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLServiceTypes from "./VCLServiceTypes";

export default class VCLOrganizationsSearchDescriptor {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLPresentationRequest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLDeepLink from "./VCLDeepLink";
import VCLJwt from "./VCLJwt";
import VCLPushDelegate from "./VCLPushDelegate";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLDeepLink from "./VCLDeepLink";
import VCLPushDelegate from "./VCLPushDelegate";

Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLResult.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLError from "./error/VCLError";

export default class VCLResult<R> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLService from "./VCLService";

export default class VCLServiceCredentialAgentIssuer extends VCLService {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLSubmission.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLJwt from "./VCLJwt";
import VCLPushDelegate from "./VCLPushDelegate";
import VCLVerifiableCredential from "./VCLVerifiableCredential";
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLToken.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import VCLJwt from "./VCLJwt"

export default class VCLToken {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/VCLVerifiedProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ data class VCLVerifiedProfile(val payload: JSONObject) {
}
*/

import { Nullish } from "../../types";
import VCLServiceType from "./VCLServiceType";
import VCLServiceTypes from "./VCLServiceTypes";

Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/entities/error/VCLError.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../types";
import VCLErrorCode from "./VCLErrorCode";

export default class VCLError extends Error {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/jwt/VCLJwtSignService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface VCLJwtSignService {
)
}*/

import { Nullish } from "../../types";
import VCLDidJwk from "../entities/VCLDidJwk";
import VCLJwt from "../entities/VCLJwt";
import VCLJwtDescriptor from "../entities/VCLJwtDescriptor";
Expand Down
4 changes: 1 addition & 3 deletions packages/sdk/src/global.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
declare type Nullish<T> = T | null | undefined;

declare type JSONObject = any;

interface String {
getQueryParameters(): Map<string, string>;
appendQueryParams(queryParams: string): string;
getUrlSubPath(subPathPrefix: string): Nullish<string>;
getUrlSubPath(subPathPrefix: string): string | null | undefined;
randomString(length: number): string;
}

Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/impl/VCLImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import OrganizationsUseCase from "./domain/usecases/OrganizationsUseCase";
import CredentialTypesUIFormSchemaUseCase from "./domain/usecases/CredentialTypesUIFormSchemaUseCase";
import VCLDidJwkDescriptor from "../api/entities/VCLDidJwkDescriptor";
import KeyServiceUseCase from "./domain/usecases/KeyServiceUseCase";
import { Nullish } from "../types";
export class VCLImpl implements VCL {
static TAG = VCLImpl.name;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../../types";
import VCLResult from "../../../../api/entities/VCLResult";
import NetworkService from "../../../domain/infrastructure/network/NetworkService";
import VCLLog from "../../../utils/VCLLog";
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/src/impl/data/infrastructure/network/Request.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Nullish } from "../../../../types";

export enum HttpMethod {
GET = "GET",
POST = "POST",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/impl/data/models/CountriesModelImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import VCLError from "../../../api/entities/error/VCLError";
import VCLResult from "../../../api/entities/VCLResult";
import CountriesModel from "../../domain/models/CountriesModel";
import CountriesUseCase from "../../domain/usecases/CountriesModelUseCase";
import { Nullish } from "../../../types";

export default class CountriesModelImpl implements CountriesModel {
constructor(private readonly countriesUseCase: CountriesUseCase) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import VCLError from "../../../api/entities/error/VCLError";
import VCLResult from "../../../api/entities/VCLResult";
import CredentialTypeSchemasModel from "../../domain/models/CredentialTypeSchemasModel";
import CredentialTypeSchemasUseCase from "../../domain/usecases/CredentialTypeSchemasUseCase";
import { Nullish } from "../../../types";

export default class CredentialTypeSchemasModelImpl
implements CredentialTypeSchemasModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import VCLError from "../../../api/entities/error/VCLError";
import VCLResult from "../../../api/entities/VCLResult";
import CredentialTypesModel from "../../domain/models/CredentialTypesModel";
import { CredentialTypesUseCase } from "../../domain/usecases/CredentialTypesUseCase";
import { Nullish } from "../../../types";

export default class CredentialTypesModelImpl implements CredentialTypesModel {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../types";
import VCLCountries from "../../../api/entities/VCLCountries";
import VCLCountry from "../../../api/entities/VCLCountry";
import VCLRegion from "../../../api/entities/VCLRegion";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../types";
import VCLCountries from "../../../api/entities/VCLCountries";
import VCLCredentialTypesUIFormSchema from "../../../api/entities/VCLCredentialTypesUIFormSchema";
import VCLCredentialTypesUIFormSchemaDescriptor from "../../../api/entities/VCLCredentialTypesUIFormSchemaDescriptor";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../types";
import VCLError from "../../../api/entities/error/VCLError";
import VCLFinalizeOffersDescriptor from "../../../api/entities/VCLFinalizeOffersDescriptor";
import VCLJwt from "../../../api/entities/VCLJwt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import VCLResult from "../../../api/entities/VCLResult";
import JwtServiceRepository from "../../domain/repositories/JwtServiceRepository";
import VCLJwtSignService from "../../../api/jwt/VCLJwtSignService";
import VCLJwtVerifyService from "../../../api/jwt/VCLJwtVerifyService";
import { Nullish } from "../../../types";

export default class JwtServiceRepositoryImpl implements JwtServiceRepository {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../..//types";
import VCLError from "../../../api/entities/error/VCLError";
import VCLOrganization from "../../../api/entities/VCLOrganization";
import VCLOrganizations from "../../../api/entities/VCLOrganizations";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../types";
import VCLError from "../../../api/entities/error/VCLError";
import VCLDidJwk from "../../../api/entities/VCLDidJwk";
import VCLFinalizeOffersDescriptor from "../../../api/entities/VCLFinalizeOffersDescriptor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import VCLJwtDescriptor from "../../../api/entities/VCLJwtDescriptor";
import VCLResult from "../../../api/entities/VCLResult";
import JwtServiceRepository from "../../domain/repositories/JwtServiceRepository";
import JwtServiceUseCase from "../../domain/usecases/JwtServiceUseCase";
import { Nullish } from "../../../types";

export default class JwtServiceUseCaseImpl implements JwtServiceUseCase {
constructor(private readonly jwtServiceRepository: JwtServiceRepository) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../types";
import VCLDidJwk from "../../../api/entities/VCLDidJwk";
import VCLJwt from "../../../api/entities/VCLJwt";
import VCLJwtDescriptor from "../../../api/entities/VCLJwtDescriptor";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { KeyPairKeyObjectResult } from "crypto";
import { JWK } from "jose";
import { Nullish } from "../../../../types";

export default interface SecretStoreService {
storeKey(keyId: string, key: KeyPairKeyObjectResult): void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../../types";
import VCLResult from "../../../../api/entities/VCLResult";
import Request, {
HttpMethod,
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/src/impl/domain/models/Model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Nullish } from "../../../types";

export default interface Model<T> {
data: Nullish<T>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import VCLPublicJwk from "../../../api/entities/VCLPublicJwk";
import VCLJwt from "../../../api/entities/VCLJwt";
import VCLJwtDescriptor from "../../../api/entities/VCLJwtDescriptor";
import VCLResult from "../../../api/entities/VCLResult";
import { Nullish } from "../../../types";

export default interface JwtServiceRepository {
decode(encodedJwt: string): Promise<VCLResult<VCLJwt>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../types";
import VCLDidJwk from "../../../api/entities/VCLDidJwk";
import VCLFinalizeOffersDescriptor from "../../../api/entities/VCLFinalizeOffersDescriptor";
import VCLJwtVerifiableCredentials from "../../../api/entities/VCLJwtVerifiableCredentials";
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/impl/domain/usecases/JwtServiceUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import VCLPublicJwk from "../../../api/entities/VCLPublicJwk";
import VCLJwt from "../../../api/entities/VCLJwt";
import VCLJwtDescriptor from "../../../api/entities/VCLJwtDescriptor";
import VCLResult from "../../../api/entities/VCLResult";
import { Nullish } from "../../../types";

export default interface JwtServiceUseCase {
verifyJwt(
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/impl/domain/usecases/SubmissionUseCase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../../types";
import VCLDidJwk from "../../../api/entities/VCLDidJwk";
import VCLResult from "../../../api/entities/VCLResult";
import VCLSubmission from "../../../api/entities/VCLSubmission";
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/impl/extensions/StringExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ String.prototype.appendQueryParams = function (queryParams: string): string {

String.prototype.getUrlSubPath = function (
subPathPrefix: string
): Nullish<string> {
): string | null | undefined {
return decodeURI(this.valueOf())
.split("/")
.find((item) => item.startsWith(subPathPrefix));
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/impl/utils/VCLLog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Nullish } from "../../types";
import GlobalConfig from "../GlobalConfig";

export default class VCLLog {
Expand Down
4 changes: 4 additions & 0 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import VCLErrorCode from "./api/entities/error/VCLErrorCode";
import VCLKeyService from "./api/keys/VCLKeyService";
import VCLJwtSignService from "./api/jwt/VCLJwtSignService";
import VCLJwtVerifyService from "./api/jwt/VCLJwtVerifyService";
import VCLResult from "./api/entities/VCLResult";
import { Nullish } from "./types";

export {
VCL,
Expand Down Expand Up @@ -111,6 +113,8 @@ export {
VCLKeyService,
VCLJwtSignService,
VCLJwtVerifyService,
VCLResult,
Nullish,
};

// export type {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Nullish<T> = T | null | undefined;
1 change: 1 addition & 0 deletions packages/sdk/test/NetworkServiceSuccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Request, {
HttpMethod,
} from "../src/impl/data/infrastructure/network/Request";
import Response from "../src/impl/data/infrastructure/network/Response";
import { Nullish } from "../src/types";

export default class NetworkServiceSuccess implements NetworkService {
constructor(private readonly validResponse: JSONObject) {}
Expand Down
4 changes: 1 addition & 3 deletions packages/sdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
},
},
"include": [
"./src/**/*",
"global.d.ts",
"index.d.ts"
"./src/**/*"
],
"exclude": [
"node_modules",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3311,9 +3311,9 @@ [email protected], fast-json-stable-stringify@^2.0.0, fast-json-sta
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==

fast-json-stringify@^5.7.0:
version "5.15.0"
resolved "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-5.15.0.tgz#79ea7203c8e541c744e1d59a4fb17133688c181a"
integrity sha512-BUEAAyDKb64u+kmkINYfXUUiKjBKerSmVu/dzotfaWSHBxR44JFrOZgkhMO6VxDhDfiuAoi8mx4drd5nvNdA4Q==
version "5.15.1"
resolved "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-5.15.1.tgz#1348b89c174cd771467e017cf61c75a796154c45"
integrity sha512-JopGtkvvguRqrS4gHXSSA2jf4pDgOZkeBAkLO1LbzOpiOMo7/kugoR+KiWifpLpluaVeYDkAuxCJOj4Gyc6L9A==
dependencies:
"@fastify/merge-json-schemas" "^0.1.0"
ajv "^8.10.0"
Expand Down

0 comments on commit feed755

Please sign in to comment.