diff --git a/.gitignore b/.gitignore index e3b659c7..2f92e8ef 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ *.tsimp *.log packages/siop-oid4vp/lib/schemas/validation/schemaValidation.js +packages/siop-oid4vp/lib/generator/* +!packages/siop-oid4vp/lib/generator/schemaGenerator.ts diff --git a/packages/siop-oid4vp/CHANGELOG.md b/packages/siop-oid4vp/CHANGELOG.md index e6f76b85..f5108f7c 100644 --- a/packages/siop-oid4vp/CHANGELOG.md +++ b/packages/siop-oid4vp/CHANGELOG.md @@ -1,10 +1,10 @@ # Release Notes - The DID Auth SIOP typescript library is still in an beta state at this point. Please note that the interfaces might still change a bit as the software still is in active development. ## 0.6.5 + - Added: - Initial support for OID4VP draft 20 - Removed did-jwt and did-resolver dependencies diff --git a/packages/siop-oid4vp/generator/schemaGenerator.ts b/packages/siop-oid4vp/lib/generator/schemaGenerator.ts similarity index 84% rename from packages/siop-oid4vp/generator/schemaGenerator.ts rename to packages/siop-oid4vp/lib/generator/schemaGenerator.ts index 617da825..7ad79943 100644 --- a/packages/siop-oid4vp/generator/schemaGenerator.ts +++ b/packages/siop-oid4vp/lib/generator/schemaGenerator.ts @@ -50,7 +50,7 @@ function writeSchema(config: any): Schema { let schemaString = JSON.stringify(schema, null, 2) schemaString = correctSchema(schemaString) - fs.writeFile(config.outputPath, `export const ${config.schemaId}Obj = ${schemaString};`, (err) => { + fs.writeFile(path.join(__dirname, config.outputPath), `export const ${config.schemaId}Obj = ${schemaString};`, (err) => { if (err) { throw err } @@ -61,7 +61,7 @@ function writeSchema(config: any): Schema { function generateValidationCode(schemas: Schema[]) { const ajv = new Ajv({ schemas, code: { source: true, lines: true, esm: false }, allowUnionTypes: true, strict: false }) const moduleCode = standaloneCode(ajv) - fs.writeFileSync(path.join(__dirname, '../lib/schemas/validation/schemaValidation.js'), moduleCode) + fs.writeFileSync(path.join(__dirname, '../schemas/validation/schemaValidation.js'), moduleCode) } function correctSchema(schemaString: string) { @@ -111,81 +111,81 @@ function correctSchema(schemaString: string) { } /* const requestOptsConf = { - path: '../lib/authorization-request/types.ts', + path: '../authorization-request/types.ts', tsconfig: 'tsconfig.json', type: 'CreateAuthorizationRequestOpts', // Or if you want to generate schema for that one type only schemaId: 'CreateAuthorizationRequestOptsSchema', - outputPath: 'lib/schemas/AuthorizationRequestOpts.schema.ts', + outputPath: '../../schemas/AuthorizationRequestOpts.schema.ts', // outputConstName: 'AuthorizationRequestOptsSchema', skipTypeCheck: true };*/ const responseOptsConf = { - path: '../lib/authorization-response/types.ts', + path: '../authorization-response/types.ts', tsconfig: 'tsconfig.json', type: 'AuthorizationResponseOpts', // Or if you want to generate schema for that one type only schemaId: 'AuthorizationResponseOptsSchema', - outputPath: 'lib/schemas/AuthorizationResponseOpts.schema.ts', + outputPath: '../schemas/AuthorizationResponseOpts.schema.ts', // outputConstName: 'AuthorizationResponseOptsSchema', skipTypeCheck: true, } const rPRegistrationMetadataPayload = { - path: '../lib/types/SIOP.types.ts', + path: '../types/SIOP.types.ts', tsconfig: 'tsconfig.json', type: 'RPRegistrationMetadataPayload', schemaId: 'RPRegistrationMetadataPayloadSchema', - outputPath: 'lib/schemas/RPRegistrationMetadataPayload.schema.ts', + outputPath: '../schemas/RPRegistrationMetadataPayload.schema.ts', // outputConstName: 'RPRegistrationMetadataPayloadSchema', skipTypeCheck: true, } const discoveryMetadataPayload = { - path: '../lib/types/SIOP.types.ts', + path: '../types/SIOP.types.ts', tsconfig: 'tsconfig.json', type: 'DiscoveryMetadataPayload', schemaId: 'DiscoveryMetadataPayloadSchema', - outputPath: 'lib/schemas/DiscoveryMetadataPayload.schema.ts', + outputPath: '../schemas/DiscoveryMetadataPayload.schema.ts', // outputConstName: 'DiscoveryMetadataPayloadSchema', skipTypeCheck: true, } const authorizationRequestPayloadVID1 = { - path: '../lib/types/SIOP.types.ts', + path: '../types/SIOP.types.ts', tsconfig: 'tsconfig.json', type: 'AuthorizationRequestPayloadVID1', // Or if you want to generate schema for that one type only schemaId: 'AuthorizationRequestPayloadVID1Schema', - outputPath: 'lib/schemas/AuthorizationRequestPayloadVID1.schema.ts', + outputPath: '../schemas/AuthorizationRequestPayloadVID1.schema.ts', // outputConstName: 'AuthorizationRequestPayloadSchemaVID1', skipTypeCheck: true, } const authorizationRequestPayloadVD11 = { - path: '../lib/types/SIOP.types.ts', + path: '../types/SIOP.types.ts', tsconfig: 'tsconfig.json', type: 'AuthorizationRequestPayloadVD11', // Or if you want to generate schema for that one type only schemaId: 'AuthorizationRequestPayloadVD11Schema', - outputPath: 'lib/schemas/AuthorizationRequestPayloadVD11.schema.ts', + outputPath: '../schemas/AuthorizationRequestPayloadVD11.schema.ts', // outputConstName: 'AuthorizationRequestPayloadSchemaVD11', skipTypeCheck: true, } const authorizationRequestPayloadVD12OID4VPD18 = { - path: '../lib/types/SIOP.types.ts', + path: '../types/SIOP.types.ts', tsconfig: 'tsconfig.json', type: 'AuthorizationRequestPayloadVD12OID4VPD18', // Or if you want to generate schema for that one type only schemaId: 'AuthorizationRequestPayloadVD12OID4VPD18Schema', - outputPath: 'lib/schemas/AuthorizationRequestPayloadVD12OID4VPD18.schema.ts', + outputPath: '../schemas/AuthorizationRequestPayloadVD12OID4VPD18.schema.ts', // outputConstName: 'AuthorizationRequestPayloadSchemaVD11', skipTypeCheck: true, } const authorizationRequestPayloadVD12OID4VPD20 = { - path: '../lib/types/SIOP.types.ts', + path: '../types/SIOP.types.ts', tsconfig: 'tsconfig.json', type: 'AuthorizationRequestPayloadVD12OID4VPD20', // Or if you want to generate schema for that one type only schemaId: 'AuthorizationRequestPayloadVD12OID4VPD20Schema', - outputPath: 'lib/schemas/AuthorizationRequestPayloadVD12OID4VPD20.schema.ts', + outputPath: '../schemas/AuthorizationRequestPayloadVD12OID4VPD20.schema.ts', // outputConstName: 'AuthorizationRequestPayloadSchemaVD11', skipTypeCheck: true, } diff --git a/packages/siop-oid4vp/package.json b/packages/siop-oid4vp/package.json index 58dee156..1c5231aa 100644 --- a/packages/siop-oid4vp/package.json +++ b/packages/siop-oid4vp/package.json @@ -8,7 +8,7 @@ "scripts": { "build": "pnpm run-s build:*", "build:main": "tsc -p tsconfig.build.json", - "build:schemaGenerator": "node --loader=tsimp/loader generator/schemaGenerator.ts", + "build:schemaGenerator": "node --loader=tsimp/loader ./lib/generator/schemaGenerator.ts", "clean": "rimraf dist coverage", "uninstall": "rimraf dist coverage node_modules" }, diff --git a/packages/siop-oid4vp/tsconfig.build.json b/packages/siop-oid4vp/tsconfig.build.json index 57c88787..bfffc683 100644 --- a/packages/siop-oid4vp/tsconfig.build.json +++ b/packages/siop-oid4vp/tsconfig.build.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", - "exclude": ["test/**/*.ts", "generator/**/*.ts"], "ts-node": { "esm": false - } + }, + "exclude": ["**/__tests__/**/*", "**/dist/**/*", "**/coverage/**"] }