From b494bf15c4329a21d1fc7745e06e5035d3a9583d Mon Sep 17 00:00:00 2001 From: "v.snigerev" Date: Sun, 8 Mar 2026 08:57:38 +0300 Subject: [PATCH] chore: add CI/CD, release pipeline, and community files for public repo readiness - GitHub Actions CI (lint/typecheck/test/build on push/PR to main) - GitHub Actions Publish (npm publish with provenance on tag v*) - MIT License, CHANGELOG, CONTRIBUTING, SECURITY - Issue templates, PR template, CODEOWNERS - package.json repository/homepage/bugs metadata --- .github/CODEOWNERS | 1 + .github/ISSUE_TEMPLATE/bug_report.md | 35 ++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 23 ++++++++ .github/PULL_REQUEST_TEMPLATE.md | 18 +++++++ .github/workflows/ci.yml | 23 ++++++++ .github/workflows/publish.yml | 28 ++++++++++ CHANGELOG.md | 27 ++++++++++ CONTRIBUTING.md | 66 +++++++++++++++++++++++ LICENSE | 21 ++++++++ SECURITY.md | 41 ++++++++++++++ package.json | 9 ++++ src/core/idempotency.ts | 4 +- 12 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 SECURITY.md diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f9f4298 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @PrivaraXYZ/maintainers diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..cf14f50 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug Report +about: Report a bug to help us improve +title: '' +labels: bug +assignees: '' +--- + +## Description + + + +## Steps to Reproduce + +1. +2. +3. + +## Expected Behavior + + + +## Actual Behavior + + + +## Environment + +- SDK Version: +- Node.js Version: +- OS: + +## Additional Context + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..2a4db0c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature Request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' +--- + +## Problem + + + +## Proposed Solution + + + +## Alternatives Considered + + + +## Additional Context + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..b92a220 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,18 @@ +## Description + + + +## Type of Change + +- [ ] Bug fix +- [ ] New feature +- [ ] Refactoring +- [ ] Documentation +- [ ] Other (describe) + +## Checklist + +- [ ] Tests pass (`pnpm test`) +- [ ] Lint passes (`pnpm lint`) +- [ ] Type check passes (`pnpm typecheck`) +- [ ] Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e232932 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm lint + - run: pnpm typecheck + - run: pnpm test + - run: pnpm build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0a352ce --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,28 @@ +name: Publish + +on: + push: + tags: ['v*'] + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: pnpm + registry-url: https://registry.npmjs.org + - run: pnpm install --frozen-lockfile + - run: pnpm lint + - run: pnpm typecheck + - run: pnpm test + - run: pnpm build + - run: pnpm publish --no-git-checks --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5260328 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,27 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.0] - 2026-03-07 + +### Added + +- OAuth M2M authentication with auto-refresh (client_credentials grant) +- Invoice management (create, get, list with auto-pagination) +- Withdrawal management (create, get, list with cursor-based auto-pagination) +- Balance retrieval +- Transaction reporting +- Blockchain module for on-chain invoice operations via ZeroDev smart accounts +- Error hierarchy with typed exceptions (validation, auth, rate-limit, not-found, conflict) +- Exponential backoff retry with jitter for 429/5xx +- Request/response interceptors +- Idempotency key support +- Dual ESM/CJS build with TypeScript declarations + +[Unreleased]: https://github.com/PrivaraXYZ/privara-sdk/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/PrivaraXYZ/privara-sdk/releases/tag/v0.1.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6418ea9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,66 @@ +# Contributing + +Thank you for your interest in contributing! + +## Development Setup + +### Prerequisites + +- Node.js 18+ +- pnpm + +### Installation + +```bash +git clone https://github.com/PrivaraXYZ/privara-sdk.git +cd privara-sdk +pnpm install +``` + +### Running Tests + +```bash +pnpm test # Unit tests +pnpm test:coverage # Tests with coverage +pnpm typecheck # Type checking +pnpm build # Build ESM + CJS +``` + +## Code Style + +- [Biome](https://biomejs.dev/) for linting and formatting +- Minimal comments — code should be self-documenting +- Use `snake_case` for API types (matches wire format) +- Prefer explicit types over `any` + +## Commit Messages + +We use [Conventional Commits](https://www.conventionalcommits.org/): + +- `feat:` — New feature +- `fix:` — Bug fix +- `docs:` — Documentation +- `test:` — Tests +- `refactor:` — Code refactoring +- `chore:` — Build/config changes + +## Pull Request Process + +1. Fork the repository +2. Create feature branch (`git checkout -b feat/amazing-feature`) +3. Commit changes (`git commit -m 'feat: add amazing feature'`) +4. Push to branch (`git push origin feat/amazing-feature`) +5. Open Pull Request + +### PR Checklist + +- [ ] Tests pass (`pnpm test`) +- [ ] Lint passes (`pnpm lint`) +- [ ] Type check passes (`pnpm typecheck`) +- [ ] No new warnings +- [ ] Documentation updated if needed +- [ ] Follows existing code patterns + +## Questions? + +Open an issue or start a discussion. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..34e177b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 PrivaraXYZ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..8cdb94b --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,41 @@ +# Security Policy + +## Supported Versions + +| Version | Supported | +| ------- | --------- | +| 0.x.x | ✅ | + +## Reporting a Vulnerability + +We take security vulnerabilities seriously. If you discover a security issue, please report it responsibly. + +### How to Report + +Please report security vulnerabilities through GitHub's Security Advisories: + +**[Report a vulnerability](https://github.com/PrivaraXYZ/privara-sdk/security/advisories/new)** + +### What to Include + +When reporting a vulnerability, please include: + +- A clear description of the vulnerability +- Steps to reproduce the issue +- Potential impact assessment +- Any suggested fixes (optional) + +### Response Timeline + +- **Initial Response**: Within 48 hours +- **Status Update**: Within 5 business days +- **Resolution Target**: Depends on severity + +## Security Best Practices + +When using this SDK: + +1. Always use HTTPS for the Privara API URL +2. Use secrets management for client credentials +3. Keep dependencies up to date +4. Never log or expose OAuth tokens diff --git a/package.json b/package.json index 94753ee..37fe125 100644 --- a/package.json +++ b/package.json @@ -96,5 +96,14 @@ "lint-staged": { "*.{ts,json}": "biome check --write --no-errors-on-unmatched" }, + "repository": { + "type": "git", + "url": "https://github.com/PrivaraXYZ/privara-sdk.git" + }, + "homepage": "https://github.com/PrivaraXYZ/privara-sdk#readme", + "bugs": { + "url": "https://github.com/PrivaraXYZ/privara-sdk/issues" + }, + "packageManager": "pnpm@10.30.3", "license": "MIT" } diff --git a/src/core/idempotency.ts b/src/core/idempotency.ts index d25fb16..763fb37 100644 --- a/src/core/idempotency.ts +++ b/src/core/idempotency.ts @@ -1,3 +1,5 @@ +import { randomUUID } from 'node:crypto'; + export function generateIdempotencyKey(): string { - return crypto.randomUUID(); + return randomUUID(); }