Skip to content

Commit

Permalink
feat: add client with services (#4)
Browse files Browse the repository at this point in the history
* feat: implement isHmacValid function to verify HMAC signatures

Signed-off-by: Ilias Elbarnoussi <[email protected]>

* hmac validation with nobles/hashes

* Update package.json

Co-authored-by: Berend Sliedrecht <[email protected]>

* add biomejs and pnpm

Signed-off-by: Ilias Elbarnoussi <[email protected]>

* change license in package.json & add license in root

Signed-off-by: Ilias Elbarnoussi <[email protected]>

* add client with the bundled services

Signed-off-by: Ilias Elbarnoussi <[email protected]>

* resolve comments

Signed-off-by: Ilias Elbarnoussi <[email protected]>

* remove generated from gitignore && yarn style fixes

Signed-off-by: Ilias Elbarnoussi <[email protected]>

* gitignore generated directory

Signed-off-by: Ilias Elbarnoussi <[email protected]>

* delete generated directory

Signed-off-by: Ilias Elbarnoussi <[email protected]>

---------

Signed-off-by: Ilias Elbarnoussi <[email protected]>
Co-authored-by: Ilias Elbarnoussi <[email protected]>
Co-authored-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
3 people authored Jun 4, 2024
1 parent 170f64b commit 571ecdc
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 435 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Continuous Integration

on:
pull_request:
branches: [main]

jobs:
validate:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Validate code (Biome Linting, Biome Formatting, TypeScript)
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Setup Biome CLI
uses: biomejs/setup-biome@v2
with:
version: latest

- name: Run Biome
run: biome ci .

- name: Install dependencies
run: pnpm install

- name: Generate output files
env:
SERVER: https://api.paradym.id
run: pnpm generate

- name: Build packages
run: pnpm build
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
node_modules
.env
src/generated
generated
.idea
build
67 changes: 35 additions & 32 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.2/schema.json",
"formatter": {
"lineWidth": 120,
"indentStyle": "space"
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
},
"formatter": {
"semicolons": "asNeeded",
"quoteStyle": "single",
"trailingComma": "es5",
"lineWidth": 120,
"indentStyle": "space"
}
},
"json": {
"parser": {
"allowComments": true
}
},
"organizeImports": {
"enabled": true
"$schema": "https://biomejs.dev/schemas/1.6.2/schema.json",
"formatter": {
"lineWidth": 120,
"indentStyle": "space"
},
"files": {
"ignore": ["generated"]
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
},
"linter": {
"enabled": true
},
"vcs": {
"useIgnoreFile": true,
"clientKind": "git",
"enabled": true
"formatter": {
"semicolons": "asNeeded",
"quoteStyle": "single",
"trailingComma": "es5",
"lineWidth": 120,
"indentStyle": "space"
}
},
"json": {
"parser": {
"allowComments": true
}
}
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true
},
"vcs": {
"useIgnoreFile": true,
"clientKind": "git",
"enabled": true
}
}
28 changes: 21 additions & 7 deletions openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import "dotenv/config";
import { defineConfig } from "@hey-api/openapi-ts";
import * as process from "node:process";
import type { UserConfig } from '@hey-api/openapi-ts'

export default defineConfig({
input: `${process.env.SERVER}/openapi-docs.json`,
output: "src/generated",
});
// Issues with the configuring through the defineConfig helper function
// Error(TS4082) |
// Default export of the module has or is using private name ClientConfig .
// export default defineConfig({
// input: 'https://api.paradym.id/openapi.json',
// output: 'src/generated',
// services: {
// asClass: true,
// },
// })

const config: UserConfig = {
input: process.env.SERVER ?? 'https://api.paradym.id/openapi.json',
output: 'generated',
services: {
asClass: true,
},
}

export default config
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"name": "paradym-sdk-ts",
"version": "1.0.0",
"type": "module",
"license": "Apache-2.0",
"scripts": {
"generate": "openapi-ts",
"build": "tsc",
"style": "biome check .",
"style:fix": "biome check . --apply-unsafe"
},
"dependencies": {
"@noble/hashes": "^1.4.0",
"dotenv": "^16.4.5"
},
"devDependencies": {
"@biomejs/biome": "1.7.3",
"@hey-api/openapi-ts": "^0.46.3",
"@types/node": "^20.12.6",
"tsx": "^4.7.2",
"typescript": "~5.4.5"
}
"name": "paradym-sdk-ts",
"version": "1.0.0",
"type": "module",
"license": "Apache-2.0",
"scripts": {
"generate": "openapi-ts",
"build": "pnpm generate && tsc",
"style": "biome check .",
"style:fix": "biome check . --apply-unsafe"
},
"dependencies": {
"@noble/hashes": "^1.4.0"
},
"devDependencies": {
"dotenv": "^16.4.5",
"@biomejs/biome": "1.7.3",
"@hey-api/openapi-ts": "^0.46.3",
"@types/node": "^20.12.6",
"tsx": "^4.7.2",
"typescript": "~5.4.5"
}
}
45 changes: 0 additions & 45 deletions src/api.ts

This file was deleted.

45 changes: 45 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
CredentialTemplatesService,
OpenAPI,
OpenId4VcIssuanceService,
OpenId4VcVerificationService,
PresentationTemplatesService,
ProjectProfileService,
ProjectsService,
WebhooksService,
} from '../generated'

export class Client {
projects: typeof ProjectsService
projectProfile: typeof ProjectProfileService
webhooks: typeof WebhooksService
templates: {
credentials: typeof CredentialTemplatesService
presentations: typeof PresentationTemplatesService
}
openId4Vc: {
issuance: typeof OpenId4VcIssuanceService
verification: typeof OpenId4VcVerificationService
}

constructor({ apiKey, baseUrl = 'https://api.paradym.id' }: { apiKey: string; baseUrl?: string }) {
OpenAPI.HEADERS = {
'x-access-token': apiKey,
}

OpenAPI.BASE = baseUrl

this.projects = ProjectsService
this.projectProfile = ProjectProfileService
this.webhooks = WebhooksService

this.templates = {
credentials: CredentialTemplatesService,
presentations: PresentationTemplatesService,
}
this.openId4Vc = {
issuance: OpenId4VcIssuanceService,
verification: OpenId4VcVerificationService,
}
}
}
Loading

0 comments on commit 571ecdc

Please sign in to comment.