Skip to content

Commit b659d5b

Browse files
authored
Merge pull request #17 from Rajesh-Royal/develop
v2.2.0 Multi‑Format Build & CDN Fix
2 parents fe82a6e + 36b779a commit b659d5b

24 files changed

+3529
-307
lines changed

.github/CODEOWNERS

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CODEOWNERS file
2+
# Lines are matched top-to-bottom; the last matching pattern takes precedence.
3+
# Reference <https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners>
4+
5+
# Default owner(s) for everything in the repo
6+
* @Rajesh-Royal
7+
8+
# Documentation
9+
/docs/ @Rajesh-Royal
10+
11+
# GitHub metadata
12+
/.github/ @Rajesh-Royal
13+
14+
# Library source (TypeScript) and build outputs
15+
/src/ @Rajesh-Royal
16+
/lib/ @Rajesh-Royal

.github/FUNDING.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# These are supported funding model platforms
22

3-
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
3+
github: [Rajesh-Royal]
44
patreon: rajeshroyal
55
open_collective: # Replace with a single Open Collective username
66
ko_fi: # Replace with a single Ko-fi username
@@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
1010
issuehunt: # Replace with a single IssueHunt username
1111
otechie: # Replace with a single Otechie username
1212
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13+
custom: ["https://paypal.me/RajeshRoyal"]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: Bug report
3+
title: "[Bug]: "
4+
about: Report a reproducible problem
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
<!-- Thanks for taking the time to report a bug! Please fill the sections below. -->
10+
11+
## Summary
12+
13+
A clear and concise description of the bug.
14+
15+
## Environment
16+
17+
- Package version: (e.g. 2.1.1)
18+
- Node.js version:
19+
- Browser + version:
20+
- OS:
21+
22+
## Reproduction
23+
24+
Steps to reproduce the behavior:
25+
26+
1.
27+
2.
28+
3.
29+
30+
### Minimal snippet
31+
32+
```js
33+
// Provide the smallest reproducible example.
34+
```
35+
36+
## Expected behavior
37+
38+
What did you expect to happen?
39+
40+
## Actual behavior
41+
42+
What actually happened?
43+
44+
## Screenshots / Logs
45+
46+
If applicable, add screenshots or console logs.
47+
48+
## Additional context
49+
50+
Add any other context or links (PRs, issues, references) here.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Questions / Usage Help
4+
url: https://github.com/Rajesh-Royal/Broprint.js/discussions
5+
about: Ask questions and get help from the community.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Feature request
3+
title: "[Feature]: "
4+
about: Suggest an idea or enhancement
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
<!-- Thanks for suggesting a feature! -->
10+
11+
## Problem
12+
13+
What problem are you trying to solve?
14+
15+
## Proposal
16+
17+
Describe the solution you'd like.
18+
19+
## Alternatives
20+
21+
Describe any alternative solutions or features you've considered.
22+
23+
## Additional context
24+
25+
Add any other context, mockups, or examples here.

.github/copilot-instructions.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# AI Assistant Working Instructions for Broprint.js
2+
3+
These instructions teach AI coding agents how to contribute effectively to this repository. Keep answers concise and pragmatic.
4+
5+
## Project Essence
6+
- Purpose: Generate a stable (not guaranteed globally unique) browser fingerprint combining an AudioContext timing trace + a rendered Canvas data URI hashed with `cyrb53` (custom 53‑bit hash).
7+
- Public API surface (exported): `getCurrentBrowserFingerPrint(): Promise<string>` from `src/index.ts`.
8+
- Build: TypeScript -> JS via `npm run build:npm` (tsc). Published package exposes compiled code in `lib/` with `main` + `types` pointing to `./lib/index.*`.
9+
10+
## Key Files / Flow
11+
1. `src/index.ts` orchestrates fingerprint creation:
12+
- Calls `generateTheAudioFingerPrint.run(cb)` (offline audio render) -> partial numeric string.
13+
- Calls `getCanvasFingerprint()` -> data URI of deterministic canvas drawing (or static fallback if unsupported).
14+
- Concatenates (currently same logic for Brave) then base64 encodes audio part and appends canvas value, then hashes with `cyrb53` (seed 0) -> final number, coerced to string.
15+
2. `src/code/generateTheAudioPrints.ts`: Offline AudioContext rendering 500 frames (indices 4500-4999) summed to produce a floating sum -> stringed.
16+
3. `src/code/GenerateCanvasFingerprint.ts`: Draws layered text & shapes on canvas for entropy; returns `canvas.toDataURL()`.
17+
4. `src/code/EncryptDecrypt.ts`: Contains hash utilities used (murmurhash3_32_gc, javaHashCode, cyrb53). Only `cyrb53` currently used by public API.
18+
19+
## Conventions & Patterns
20+
- No external runtime dependencies (despite README mention of crypto-js in older versions). Keep bundle tiny; avoid adding deps unless essential.
21+
- Hash / fingerprint logic purposely simple & deterministic; avoid introducing time, locale, or network variability unless behind an opt-in flag.
22+
- Use synchronous operations except for audio (asynchronous OfflineAudioContext). Promise composition kept minimal.
23+
- Fallback behavior: If audio fingerprinting fails, fall back to canvas-only hash inside catch.
24+
- Brave browser branch present but currently identical; if modifying, keep Brave privacy differences in mind (possible reduced entropy).
25+
- No test suite yet; if adding tests, prefer lightweight Jest or vitest with jsdom for canvas + mock Web Audio.
26+
- Formatting is minimal; preserve existing style (no semicolons at ends except retained by file, loose var usage inside legacy code—refactors should be incremental, not sweeping).
27+
28+
## Build / Publish Workflow
29+
- Build command: `npm run build:npm` (invokes `tsc`). Ensure `lib/` artifacts updated.
30+
- CI: `.github/workflows/ci.yml` builds on PRs (develop/master) and pushes to develop.
31+
- Publish: Push to `master` triggers `.github/workflows/publish.yml` which publishes if the version in `package.json` is not already on npm. Version bumps are manual.
32+
- Files published: restricted via `package.json#files` (lib, LICENSE, README.MD). Ensure any new public types land in `lib/`.
33+
34+
## When Editing Public API
35+
- Update both TypeScript source (`src/`) and ensure build outputs land in `lib/` (run build locally before committing if repo tracks build output; if not, rely on publish workflow to regenerate—currently repository already contains `lib/`).
36+
- Keep signature of `getCurrentBrowserFingerPrint` stable; if adding options, prefer an optional parameter object with defaults (e.g., `{ includeAudio?: boolean; includeCanvas?: boolean; seed?: number }`).
37+
- Document new options in README and bump minor version.
38+
39+
## Error Handling
40+
- Current API rejects only on total failure (both audio + canvas). Preserve this contract; do not throw synchronous errors—return a rejected Promise.
41+
- If adding new failure modes, ensure they’re caught and degrade gracefully to reduced-entropy fingerprint.
42+
43+
## Performance / Size Considerations
44+
- Avoid heavy libs (crypto, uuid) — custom hashing already present.
45+
- Audio & canvas operations should remain < a few ms; do not add layout thrash or large DOM manipulations.
46+
47+
## Example Usage (keep working)
48+
```ts
49+
import { getCurrentBrowserFingerPrint } from '@rajesh896/broprint.js';
50+
const id = await getCurrentBrowserFingerPrint();
51+
```
52+
53+
## Common Pitfalls for Agents
54+
- Don’t introduce Node-only APIs into browser path (fs, path, etc.). This library is browser-focused.
55+
- Avoid using Date.now randomness in the fingerprint (breaks determinism) unless put behind a clearly documented opt-in.
56+
- Maintain ESM compatibility; entry point currently works via bare import.
57+
- Preserve tree-shake friendliness: avoid side-effectful top-level code.
58+
59+
## Safe Extension Ideas (If Asked)
60+
- Optional config parameter to disable audio or canvas.
61+
- Expose raw (unhashed) components for analytics (`getRawFingerPrintParts()` returning { audio, canvas }).
62+
- Add lightweight tests for deterministic hashing given mocked inputs.
63+
64+
## Security / Privacy Notes
65+
- Fingerprint NOT cryptographically secure or collision-proof; it’s a heuristic identifier. Be explicit if asked.
66+
- Respect user privacy—avoid adding invasive signals (plugins, fonts) without discussion.
67+
68+
## Maintainer Metadata
69+
- CODEOWNERS: @Rajesh-Royal owns all paths.
70+
- Direct questions to issues or discussions; security concerns follow SECURITY.md process.
71+
72+
Respond with changes only; keep explanations short.

.github/pull_request_template.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--
2+
Thank you for contributing! Please fill out the checklist below.
3+
-->
4+
5+
## Summary
6+
7+
Explain the change (what & why).
8+
9+
## Type of change
10+
11+
- [ ] Bug fix
12+
- [ ] New feature
13+
- [ ] Breaking change
14+
- [ ] Chore / Maintenance
15+
- [ ] Docs update
16+
17+
## Checklist
18+
19+
- [ ] Code builds locally (npm run build:npm)
20+
- [ ] Linting/format (if applicable) passes
21+
- [ ] Updated documentation (README / docs) if needed
22+
- [ ] Added tests or explanation why not (project currently lacks tests)
23+
- [ ] Version bump NOT included (handled by release process)
24+
25+
## How to test
26+
27+
Steps or code snippet to verify.
28+
29+
## Screenshots / Logs
30+
31+
If UI or meaningful logs changed.
32+
33+
## Related issues
34+
35+
Link to issues this PR closes (e.g. Closes #123).
36+
37+
## Additional context
38+
39+
Anything else reviewers should know.

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ develop, master ]
6+
push:
7+
branches: [ develop ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 5
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
cache: 'npm'
19+
- name: Install deps
20+
run: npm ci || npm install --no-audit --no-fund
21+
- name: Build
22+
run: npm run build:npm
23+
- name: Package size (approx)
24+
run: du -sh lib || true

.github/workflows/publish.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths-ignore:
7+
- 'docs/**'
8+
- '*.md'
9+
- 'LICENSE'
10+
workflow_dispatch: {}
11+
12+
permissions:
13+
contents: write
14+
15+
concurrency:
16+
group: publish-${{ github.ref }}
17+
cancel-in-progress: false
18+
19+
jobs:
20+
publish:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 10
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
registry-url: https://registry.npmjs.org
30+
always-auth: true
31+
cache: 'npm'
32+
33+
- name: Install dependencies
34+
run: npm ci || npm install --no-audit --no-fund
35+
36+
- name: Build
37+
run: npm run build:npm
38+
39+
- name: Determine version & check registry
40+
id: ver
41+
env:
42+
PKG_NAME: "@rajesh896/broprint.js"
43+
run: |
44+
VERSION=$(node -p "require('./package.json').version")
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
if npm view "$PKG_NAME@$VERSION" >/dev/null 2>&1; then
47+
echo "exists=true" >> $GITHUB_OUTPUT
48+
echo "Version $VERSION already on registry; skipping publish."
49+
else
50+
echo "exists=false" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Publish to npm
54+
if: steps.ver.outputs.exists == 'false'
55+
env:
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57+
run: npm publish --access public
58+
59+
- name: Create git tag
60+
if: steps.ver.outputs.exists == 'false'
61+
run: |
62+
VERSION=${{ steps.ver.outputs.version }}
63+
git tag v$VERSION
64+
git push origin v$VERSION || true

0 commit comments

Comments
 (0)