{"id":28629757,"url":"https://github.com/fibjs/pow-auth","last_synced_at":"2026-03-04T15:01:39.561Z","repository":{"id":281400489,"uuid":"945170653","full_name":"fibjs/pow-auth","owner":"fibjs","description":"A proof-of-work based authentication module using Web Crypto API.","archived":false,"fork":false,"pushed_at":"2025-04-18T19:15:39.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T00:23:08.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fibjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-08T20:22:44.000Z","updated_at":"2025-04-18T19:15:43.000Z","dependencies_parsed_at":"2025-03-08T20:44:49.303Z","dependency_job_id":"44942a6e-40b7-4389-8726-74bf19a31680","html_url":"https://github.com/fibjs/pow-auth","commit_stats":null,"previous_names":["fibjs/pow-auth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fibjs/pow-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Fpow-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Fpow-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Fpow-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Fpow-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibjs","download_url":"https://codeload.github.com/fibjs/pow-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Fpow-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30084685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T13:22:36.021Z","status":"ssl_error","status_checked_at":"2026-03-04T13:20:45.750Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-12T12:13:29.751Z","updated_at":"2026-03-04T15:01:39.529Z","avatar_url":"https://github.com/fibjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pow Auth\n\nA proof-of-work based authentication module using Web Crypto API.\n\n## Features\n\n- Hashcash-style proof of work authentication\n- Configurable difficulty level\n- Replay attack protection using LRU cache\n- Time-based validation with configurable windows\n- Built on Web Crypto API for secure cryptographic operations\n\n## Installation\n\n```bash\nnpm install pow-auth\n```\n\n## Usage\n\n```javascript\nimport { PowAuth } from 'pow-auth';\n\n// Create a new instance with difficulty level 2 (requiring 2 leading zeros)\nconst auth = new PowAuth({ \n  difficulty: 2,\n  timeWindow: 300000,    // 5 minutes\n  timeTolerance: 60000,  // 1 minute\n  maxCacheSize: 10000    // Maximum number of proofs to cache\n});\n\n// Generate a key from username and password\nconst key = await auth.generateKey('username', 'password');\n\n// Generate a proof of work\nconst proof = await auth.generateProof('username', 'password');\n\n// Verify the proof\nconst result = await auth.verifyProof(proof, key);\nif (result.valid) {\n  console.log('Authentication successful');\n} else {\n  console.log(`Authentication failed: ${result.reason}`);\n}\n```\n\n## API\n\n### `new PowAuth(config)`\n\nCreates a new PowAuth instance.\n\n#### Config Options\n\n- `difficulty`: Number of leading zeros required for proof of work\n- `timeWindow`: Time window in milliseconds (default: 300000, 5 minutes)\n- `timeTolerance`: Time tolerance in milliseconds (default: 60000, 1 minute)\n- `maxCacheSize`: Maximum number of used proofs to store (default: 10000)\n\n### `generateKey(name: string, password: string): Promise\u003cstring\u003e`\n\nGenerates a SHA-256 hash key from name and password.\n\n### `generateProof(name: string, password: string): Promise\u003cProof\u003e`\n\nGenerates a proof of work based on the hashcash principle.\n\nReturns a proof object containing:\n- `name`: Username\n- `ts`: Timestamp\n- `nonce`: Nonce value\n- `hash`: Generated hash\n\n### `verifyProof(proof: Proof, key: string): Promise\u003cVerifyResult\u003e`\n\nVerifies a proof against a key.\n\nReturns a result object containing:\n- `valid`: Boolean indicating if proof is valid\n- `code`: Status code ('OK' or error code)\n- `reason`: Description of the result\n\n#### Error Codes\n\n- `EXPIRED`: Proof has expired\n- `FUTURE_TIMESTAMP`: Proof timestamp is too far in the future\n- `REPLAY`: Proof has already been used\n- `INSUFFICIENT_DIFFICULTY`: Hash does not meet difficulty requirement\n- `INVALID_HASH`: Hash verification failed\n\n## Security Considerations\n\n1. The difficulty level should be set based on your security requirements\n2. Time windows should be adjusted based on your network latency expectations\n3. Cache size should be set based on your expected traffic volume\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Fpow-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibjs%2Fpow-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Fpow-auth/lists"}