Skip to content

Commit

Permalink
refactor(repo): refactor to multiple packages with isomorphic support
Browse files Browse the repository at this point in the history
  • Loading branch information
jwulf committed Sep 27, 2024
1 parent feaafc7 commit 751f6ce
Show file tree
Hide file tree
Showing 80 changed files with 22,468 additions and 35,806 deletions.
File renamed without changes.
File renamed without changes.
36,432 changes: 19,902 additions & 16,530 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "c8-sdk",
"version": "1.0.0",
"main": "commitlint.config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 0",
"sm:start": "docker compose -f docker/docker-compose-multitenancy.yaml -f docker/docker-compose-modeler.yaml up -d",
"sm:stop": "docker compose -f docker/docker-compose-multitenancy.yaml -f docker/docker-compose-modeler.yaml down"
},
"private": true,
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"workspaces": [
"packages/lossless-json",
"packages/certificates",
"packages/oauth",
"packages/isomorphic-sdk",
"packages/sdk"
],
"devDependencies": {
"@typescript-eslint/parser": "^8.7.0",
"commitizen": "^4.3.0",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^29.7.0",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
"tsconfig-paths": "^4.2.0",
"tsd": "^0.31.2",
"typedoc": "^0.26.7",
"typedoc-plugin-missing-exports": "^3.0.0",
"typescript": "^5.4.5"
}
}
13 changes: 13 additions & 0 deletions packages/certificates/package-lock.json

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

16 changes: 16 additions & 0 deletions packages/certificates/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@camunda8/certificates",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"test": "jest",
"build": "npm run clean && tsc --project tsconfig.json",
"clean": "rm -rf ./dist && rm -f ./tsconfig.tsbuildinfo",
"lint": "eslint 'src/**/*.{ts,tsx}'",
"format": "prettier --write 'src/**/*.ts'"
},
"keywords": [],
"author": "Josh Wulf <[email protected]>",
"license": "ISC",
"description": ""
}
1 change: 1 addition & 0 deletions packages/certificates/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { GetCustomCertificateBuffer } from './lib/GetCustomCertificateBuffer'
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import path from 'path'

import { debug } from 'debug'

import { CamundaPlatform8Configuration } from './Configuration'
import { getSystemCertificates } from './GetSystemCertificates'

const trace = debug('camunda:certificate')

interface Configuration {
CAMUNDA_CUSTOM_ROOT_CERT_PATH?: string
CAMUNDA_CUSTOM_ROOT_CERT_STRING?: string
}

export async function GetCustomCertificateBuffer(
config: CamundaPlatform8Configuration
config: Configuration
): Promise<string | undefined> {
const customRootCertPath = config.CAMUNDA_CUSTOM_ROOT_CERT_PATH
const customRootCert = config.CAMUNDA_CUSTOM_ROOT_CERT_STRING
Expand Down Expand Up @@ -46,7 +50,7 @@ export async function GetCustomCertificateBuffer(
return output
}

function readRootCertificate(certPath) {
function readRootCertificate(certPath: string) {
let cert

try {
Expand All @@ -72,5 +76,5 @@ function readRootCertificate(certPath) {
console.warn('Custom SSL certificate appears to be not a root certificate')
}

return cert
return cert.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import cp from 'child_process'
import fs from 'fs/promises'

let _cachedCertificates
let _cachedCertificates: string[]

/**
* Get certificates from the system keychain.
Expand All @@ -56,7 +56,7 @@ export async function getSystemCertificates(): Promise<string[]> {
return _cachedCertificates
}

async function readCaCertificates() {
async function readCaCertificates(): Promise<string[]> {
if (process.platform === 'win32') {
return readWindowsCaCertificates()
}
Expand Down Expand Up @@ -94,7 +94,9 @@ async function readMacCaCertificates() {
systemRootCertsPath,
])

const certs = new Set(splitCerts(trusted).concat(splitCerts(systemTrusted)))
const certs = new Set<string>(
splitCerts(trusted).concat(splitCerts(systemTrusted))
)

return Array.from(certs)
}
Expand All @@ -108,7 +110,7 @@ async function readLinuxCaCertificates() {
for (const certPath of linuxCaCertificatePaths) {
try {
const content = await fs.readFile(certPath, { encoding: 'utf8' })
const certs = new Set(splitCerts(content))
const certs = new Set<string>(splitCerts(content))
return Array.from(certs)
} catch (err) {
if ((err as { code?: string })?.code !== 'ENOENT') {
Expand All @@ -122,7 +124,7 @@ async function readLinuxCaCertificates() {

// helper /////////////////

function spawnPromise(command, args) {
function spawnPromise(command: string, args: string[]): Promise<string> {
return new Promise((resolve, reject) => {
const child = cp.spawn(command, args)
const stdout: string[] = []
Expand All @@ -143,7 +145,7 @@ function spawnPromise(command, args) {
// return lines.join(os.EOL)
// }

function splitCerts(certs) {
function splitCerts(certs: string) {
return certs
.split(/(?=-----BEGIN CERTIFICATE-----)/g)
.filter((pem) => !!pem.length)
Expand Down
31 changes: 31 additions & 0 deletions packages/certificates/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"composite": true /* Required because referenced by src/tsconfig.json */,
/* Basic Options */
"target": "es2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"types": ["node", "jest"],
"lib": ["es2020"],
"declaration": true /* Generates corresponding '.d.ts' file. */,
"sourceMap": true /* Generates corresponding '.map' file. */,
"outDir": "./dist" /* Redirect output structure to the directory. */,
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
/* Strict Type-Checking Options */
"forceConsistentCasingInFileNames": true,
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"plugins": [
{
"name": "typescript-tslint-plugin"
}
]
},
"exclude": ["node_modules", "src/__tests__/*", "test-d", "dist"]
}
Loading

0 comments on commit 751f6ce

Please sign in to comment.