{"id":44291711,"url":"https://github.com/legitmark-eng/legitmark-typescript","last_synced_at":"2026-02-11T00:02:33.188Z","repository":{"id":336799975,"uuid":"1150258714","full_name":"legitmark-eng/legitmark-typescript","owner":"legitmark-eng","description":"Official TypeScript SDK for the Legitmark API","archived":false,"fork":false,"pushed_at":"2026-02-06T06:27:21.000Z","size":112,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-06T14:54:01.770Z","etag":null,"topics":["api-client","authentication","legitmark","sdk","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/legitmark","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/legitmark-eng.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-05T04:15:36.000Z","updated_at":"2026-02-06T06:27:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/legitmark-eng/legitmark-typescript","commit_stats":null,"previous_names":["legitmark-eng/legitmark-typescript"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/legitmark-eng/legitmark-typescript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/legitmark-eng%2Flegitmark-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/legitmark-eng%2Flegitmark-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/legitmark-eng%2Flegitmark-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/legitmark-eng%2Flegitmark-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/legitmark-eng","download_url":"https://codeload.github.com/legitmark-eng/legitmark-typescript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/legitmark-eng%2Flegitmark-typescript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29322733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T20:44:44.282Z","status":"ssl_error","status_checked_at":"2026-02-10T20:44:43.393Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["api-client","authentication","legitmark","sdk","typescript"],"created_at":"2026-02-11T00:02:32.835Z","updated_at":"2026-02-11T00:02:33.175Z","avatar_url":"https://github.com/legitmark-eng.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Legitmark TypeScript SDK\n\n[![CI](https://github.com/legitmark-eng/legitmark-typescript/actions/workflows/ci.yml/badge.svg)](https://github.com/legitmark-eng/legitmark-typescript/actions/workflows/ci.yml)\n[![Tests](https://img.shields.io/badge/tests-131%20passing-brightgreen)](https://github.com/legitmark-eng/legitmark-typescript/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/legitmark.svg)](https://www.npmjs.com/package/legitmark)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)\n\nThe official TypeScript SDK for the [Legitmark API](https://docs.legitmark.com). Submit items for authentication, upload photos, and handle webhook events with full type safety.\n\n## Getting Started\n\n1. **Get organization access** — Contact [accounts@legitmark.com](mailto:accounts@legitmark.com) to set up a new organization or be added to an existing one.\n2. **Create an API key** — In [Developer Settings](https://app.legitmark.com/settings/developer), generate a new key.\n3. **Add a webhook destination** (optional) — In [Developer Settings](https://app.legitmark.com/settings/developer), add your HTTPS endpoint for real-time notifications.\n\nSee the [Getting Started guide](https://docs.legitmark.com/partner/getting-started) for the full walkthrough.\n\n## Installation\n\n```bash\nnpm install legitmark\n```\n\n## Quick Start\n\n```typescript\nimport { Legitmark } from 'legitmark';\n\nconst legitmark = new Legitmark('leo_your_api_key');\n\n// 1. Create a service request\nconst { sr } = await legitmark.sr.create({\n  service: 'service-uuid',\n  item: { category: 'category-uuid', type: 'type-uuid', brand: 'brand-uuid' },\n});\n\n// 2. Upload required photos\nawait legitmark.images.uploadForSide(sr.uuid, sideUuid, './photo.jpg');\n\n// 3. Submit for authentication\nawait legitmark.sr.submit(sr.uuid);\n```\n\n## Features\n\n- **Full TypeScript Support** — Complete type definitions for all requests and responses\n- **Resource-Based API** — Clean access via `legitmark.sr`, `legitmark.taxonomy`, `legitmark.images`\n- **Webhook Event Handling** — Typed payloads, parser, and state helpers for consuming webhook events\n- **Built-in Retries** — Automatic retry with exponential backoff via `withRetry()`\n- **Configurable Timeouts** — Per-request timeout customization with `withOptions()`\n- **Debug Logging** — Optional verbose logging for troubleshooting\n\n## API Reference\n\nSee the [Workflow guide](https://docs.legitmark.com/partner/workflow) for the complete step-by-step integration process.\n\n### Service Requests (`legitmark.sr`)\n\n```typescript\nawait legitmark.sr.create(request);              // Create new SR\nawait legitmark.sr.get(uuid);                     // Get SR by UUID\nawait legitmark.sr.getWithRequirements(uuid);     // Get with photo requirements\nawait legitmark.sr.getWithSides(uuid);            // Get with sides and progress\nawait legitmark.sr.getProgress(uuid);             // Check upload progress\nawait legitmark.sr.submit(uuid);                  // Submit for authentication\n```\n\n### Taxonomy (`legitmark.taxonomy`)\n\n```typescript\nawait legitmark.taxonomy.getTree();               // Full category → type tree\nawait legitmark.taxonomy.getCategories();          // List categories (paginated)\nawait legitmark.taxonomy.getBrands({ search });    // Search brands (paginated)\nawait legitmark.taxonomy.getBrandsForType(uuid);   // Brands for a specific type\n```\n\n### Images (`legitmark.images`)\n\n```typescript\nawait legitmark.images.uploadForSide(srUuid, sideUuid, './photo.jpg');\nawait legitmark.images.uploadForSide(srUuid, sideUuid, imageBuffer);\n```\n\n## Handling Webhook Events\n\nWhen authentication completes, images are rejected, or a request is cancelled, your webhook endpoint receives an event. The SDK provides typed payloads and helper functions.\n\n```typescript\nimport { parseWebhookEvent, isAuthentic, isCounterfeit, needsResubmission, isCancelled } from 'legitmark';\n\napp.post('/webhooks/legitmark', express.json(), (req, res) =\u003e {\n  const event = parseWebhookEvent(req.body);\n\n  if (isAuthentic(event)) {\n    markItemAsAuthentic(event.reference_id);\n  } else if (isCounterfeit(event)) {\n    flagItem(event.reference_id);\n  } else if (needsResubmission(event)) {\n    requestNewPhotos(event.reference_id, event.sides);\n  } else if (isCancelled(event)) {\n    closeCase(event.sr_uuid);\n  }\n\n  res.status(200).send('OK');\n});\n```\n\n| Helper | Returns `true` when |\n|--------|---------------------|\n| `isAuthentic(event)` | `COMPLETE + APPROVED` — item is genuine |\n| `isCounterfeit(event)` | `COMPLETE + REJECTED` — item is not authentic |\n| `isCancelled(event)` | `CANCELLED` — SR was cancelled |\n| `needsResubmission(event)` | Images rejected, partner should re-upload |\n| `isQcApproved(event)` | QC passed, proceeding to authentication |\n| `isAuthenticationInProgress(event)` | Authenticator assigned, work underway |\n\nSee the [Webhook Reference](https://docs.legitmark.com/webhook-reference/introduction) for event payload schemas and the [Handling guide](https://docs.legitmark.com/webhook-reference/handling) for best practices.\n\n## Configuration\n\n```typescript\nconst legitmark = new Legitmark('leo_xxx', {\n  debug: true,       // Enable verbose logging (default: false)\n  timeout: 60000,    // Request timeout in ms (default: 30000)\n});\n```\n\n### Environment Variables\n\n```typescript\nimport { createClientFromEnv } from 'legitmark';\n\n// Reads LEGITMARK_API_KEY and LEGITMARK_DEBUG from env\nconst legitmark = createClientFromEnv();\n```\n\n| Variable | Description |\n|----------|-------------|\n| `LEGITMARK_API_KEY` | Your partner API key |\n| `LEGITMARK_DEBUG` | Set to `true` to enable debug logging |\n\n## Error Handling\n\n```typescript\nimport { LegitmarkError, withRetry } from 'legitmark';\n\ntry {\n  await legitmark.sr.submit(srUuid);\n} catch (error) {\n  if (error instanceof LegitmarkError) {\n    console.error(`[${error.code}] ${error.message}`);\n    console.log('Request ID:', error.context.requestId);\n\n    if (error.isRetryable) {\n      // Safe to retry — or use withRetry() for automatic retries\n    }\n  }\n}\n\n// Automatic retries with exponential backoff\nconst result = await withRetry(() =\u003e legitmark.sr.create(request), {\n  attempts: 3,\n  onRetry: (err, attempt) =\u003e console.log(`Retry ${attempt}...`),\n});\n```\n\n| Error Code | Status | Retryable | Description |\n|-----------|--------|-----------|-------------|\n| `VALIDATION_ERROR` | 400 | No | Invalid request parameters |\n| `AUTHENTICATION_ERROR` | 401/403 | No | Invalid or expired API key |\n| `NOT_FOUND_ERROR` | 404 | No | Resource not found |\n| `RATE_LIMIT_ERROR` | 429 | Yes | Too many requests |\n| `SERVER_ERROR` | 500+ | Yes | Server-side error |\n| `TIMEOUT_ERROR` | 504 | Yes | Gateway or request timeout |\n| `NETWORK_ERROR` | — | Yes | Connection failed |\n\n## Requirements\n\n- **Node.js** 18.0+\n- **TypeScript** 5.0+ (if using TypeScript)\n\nCompatible with modern bundlers (webpack, esbuild, vite, etc.).\n\n## Documentation\n\n- [Getting Started](https://docs.legitmark.com/partner/getting-started) — Account setup, API keys, webhook destinations\n- [Workflow Guide](https://docs.legitmark.com/partner/workflow) — Step-by-step integration process\n- [Taxonomy](https://docs.legitmark.com/partner/taxonomy) — Category, type, and brand classification\n- [Webhook Reference](https://docs.legitmark.com/webhook-reference/introduction) — Event types and payload schemas\n- [API Reference](https://docs.legitmark.com/api-reference/introduction) — Full endpoint documentation\n\n## Development\n\n```bash\nnpm run build        # Build (CJS + ESM + DTS)\nnpm run lint         # Lint\nnpm run test:unit    # Unit tests\nnpm run test:e2e     # E2E tests (requires .env with API key)\nnpm run test:all     # All tests\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.\n\n## Security\n\nTo report security vulnerabilities, see [SECURITY.md](SECURITY.md).\n\n## License\n\nMIT — See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flegitmark-eng%2Flegitmark-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flegitmark-eng%2Flegitmark-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flegitmark-eng%2Flegitmark-typescript/lists"}