{"id":50735371,"url":"https://github.com/wyre-technology/node-spanning","last_synced_at":"2026-06-10T13:01:19.341Z","repository":{"id":355229001,"uuid":"1226756413","full_name":"wyre-technology/node-spanning","owner":"wyre-technology","description":"Comprehensive Node.js/TypeScript client library for the Spanning Cloud Backup REST API","archived":false,"fork":false,"pushed_at":"2026-06-09T02:15:30.000Z","size":329,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-09T03:21:23.338Z","etag":null,"topics":["api-client","kaseya","m365","msp","saas-backup","salesforce","sdk","spanning","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wyre-technology.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-01T19:51:59.000Z","updated_at":"2026-06-09T02:15:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wyre-technology/node-spanning","commit_stats":null,"previous_names":["wyre-technology/node-spanning"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/wyre-technology/node-spanning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyre-technology%2Fnode-spanning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyre-technology%2Fnode-spanning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyre-technology%2Fnode-spanning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyre-technology%2Fnode-spanning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wyre-technology","download_url":"https://codeload.github.com/wyre-technology/node-spanning/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyre-technology%2Fnode-spanning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34153483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","kaseya","m365","msp","saas-backup","salesforce","sdk","spanning","typescript"],"created_at":"2026-06-10T13:01:18.381Z","updated_at":"2026-06-10T13:01:19.331Z","avatar_url":"https://github.com/wyre-technology.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @wyre-technology/node-spanning\n\nComprehensive, fully-typed Node.js / TypeScript client library for the\n[Spanning Cloud Backup REST API](https://www.spanning.com/).\n\n[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)\n\n## Features\n\n- Coverage of Spanning's M365 surface: users, services, backups, restores, audit, license\n- Per-platform base URL routing (`m365` / `gws` / `salesforce`)\n- Bearer-token + admin-email pair authentication\n- Cursor-based pagination via async iterators\n- Rate limiting tuned for the 100 req/min Spanning limit, with concurrency capped at 4\n- Async restore queue + poll helpers (`restores.queue`, `restores.get`, `restores.waitFor`)\n- Typed error hierarchy with a \"verify both fields\" hint baked into 401 messages\n- ESM and CommonJS dual exports, full `.d.ts` types\n- Zero `any` in the public API\n\n## Install\n\n```bash\nnpm install @wyre-technology/node-spanning\n```\n\nThe package is published to GitHub Packages under the `@wyre-technology` scope.\nAdd this to a project-local `.npmrc`:\n\n```\n@wyre-technology:registry=https://npm.pkg.github.com\n```\n\n## Quick start\n\n```typescript\nimport { SpanningClient } from '@wyre-technology/node-spanning';\n\nconst client = new SpanningClient({\n  adminEmail: 'admin@example.com',\n  apiToken: process.env.SPANNING_API_TOKEN!,\n  platform: 'm365', // or 'gws' | 'salesforce'\n});\n\nfor await (const user of client.users.listAll({ limit: 100 })) {\n  console.log(user.id, user.email);\n}\n```\n\n## Configuration\n\n```typescript\nnew SpanningClient({\n  adminEmail: 'admin@example.com',\n  apiToken: 'spanning-api-token',\n\n  // Platform selection — picks the per-platform base URL\n  platform: 'm365', // 'm365' | 'gws' | 'salesforce', default 'm365'\n\n  // Optional — override the base URL entirely (forward-compat / staging)\n  apiUrl: 'https://o365-api.spanningbackup.com/external',\n\n  // Optional — tune client-side rate limiting\n  rateLimit: {\n    enabled: true,\n    maxRequests: 100,\n    windowMs: 60_000,\n    throttleThreshold: 0.8,\n    retryAfterMs: 5_000,\n    maxRetries: 3,\n    maxConcurrency: 4,\n  },\n});\n```\n\n## Platforms\n\nSpanning is purchased and licensed per platform. A token issued for one\nplatform CANNOT call another platform's endpoints.\n\n| Platform     | Base URL                                              |\n| ------------ | ----------------------------------------------------- |\n| `m365`       | `https://o365-api.spanningbackup.com/external`        |\n| `gws`        | `https://api.spanningbackup.com/external`             |\n| `salesforce` | `https://salesforce-api.spanningbackup.com`           |\n\n\u003e **Pair-bound credentials**: Spanning ties API tokens to a specific admin\n\u003e email. If either the email or the token is wrong (or they don't match the\n\u003e pair Spanning has on file), the upstream API returns a generic\n\u003e `401 Unauthorized`. The SDK includes a hint in\n\u003e `SpanningAuthenticationError.message` to verify BOTH fields together AND\n\u003e that they were issued for the configured platform.\n\n## Authentication\n\nEvery request sends two headers:\n\n```\nX-Spanning-Admin: admin@example.com\nX-Spanning-Authorization: Bearer \u003capi_token\u003e\n```\n\n## Pagination\n\nCursor-based:\n\n```\nGET /external/users?limit=100\n→ { items: [...], next: \"abc123\" }\n\nGET /external/users?limit=100\u0026cursor=abc123\n```\n\nDefault `limit` is 50, max is 200. Iteration stops automatically when\n`next` is `null`.\n\n```typescript\nconst page = await client.users.list({ limit: 100 });\n\nfor await (const u of client.users.listAll({ limit: 200 })) { /* ... */ }\n```\n\n## Restores: queue + poll workflow\n\nRestores are asynchronous. Queue with `restores.queue(userId, service, payload)`,\nthen wait for the restore to leave the `queued`/`running` state.\n\n```typescript\nconst { restoreId } = await client.restores.queue('user-123', 'mail', {\n  backupId: 'backup-789',\n});\n\nconst final = await client.restores.waitFor(restoreId, {\n  intervalMs: 30_000,    // default — do not poll faster\n  timeoutMs: 60 * 60_000,\n});\n\nif (final.status === 'failed') {\n  console.error('Restore failed:', final.error);\n}\n```\n\n## API surface\n\n```typescript\nclient.users.list(params)\nclient.users.listAll(params)\nclient.users.get(userId)\n\nclient.services.list(userId)\n\nclient.backups.list(userId, service, params)\nclient.backups.listAll(userId, service, params)\n\nclient.restores.queue(userId, service, payload)\nclient.restores.get(restoreId)\nclient.restores.waitFor(restoreId, { intervalMs?, timeoutMs? })\n\nclient.audit.list({ from?, to?, ...params })\nclient.audit.listAll({ from?, to?, ...params })\n\nclient.license.get()\n```\n\n## GWS / Salesforce support\n\nThe first cut implements the M365 surface fully. The same generic resources\nalso work transparently against the GWS and Salesforce base URLs (just set\n`platform: 'gws' | 'salesforce'`) — Spanning's user/service/backup/restore\nshapes are similar across platforms.\n\nPlatform-specific helpers live on `client.gws` and `client.salesforce`. They\ncurrently throw `NotImplementedError`; full first-class support for those\ntwo platforms is planned.\n\n\u003e **Salesforce object IDs**: Salesforce uses 15- or 18-character,\n\u003e case-sensitive object IDs (e.g. `0051a000001abcdAAA`) — NOT the\n\u003e user-friendly identifiers from M365 / GWS. The `SalesforceObjectId` type\n\u003e is exported as a marker.\n\n## Error handling\n\n```typescript\nimport {\n  SpanningError,\n  SpanningAuthenticationError,\n  SpanningForbiddenError,\n  SpanningNotFoundError,\n  SpanningConflictError,\n  SpanningRateLimitError,\n  SpanningServerError,\n} from '@wyre-technology/node-spanning';\n\ntry {\n  await client.users.get('user-123');\n} catch (err) {\n  if (err instanceof SpanningAuthenticationError) {\n    // Verify the admin email AND the token together — see err.message\n  } else if (err instanceof SpanningConflictError) {\n    // A restore is already in flight for these items\n  } else if (err instanceof SpanningRateLimitError) {\n    await new Promise((r) =\u003e setTimeout(r, err.retryAfter));\n  }\n}\n```\n\n## Development\n\n```bash\nnpm install\nnpm test\nnpm run typecheck\nnpm run lint\nnpm run build\n```\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwyre-technology%2Fnode-spanning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwyre-technology%2Fnode-spanning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwyre-technology%2Fnode-spanning/lists"}