{"_id":"@1money/1money-ts-sdk","name":"@1money/1money-ts-sdk","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@1money/1money-ts-sdk","version":"0.0.1","description":"TypeScript SDK for the 1Money Stablecoin Platform API","type":"module","main":"./dist/cjs/index.cjs","module":"./dist/esm/index.js","types":"./dist/types/index.d.ts","exports":{".":{"import":{"types":"./dist/types/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/types/index.d.cts","default":"./dist/cjs/index.cjs"}}},"repository":{"type":"git","url":"git+https://github.com/1Money-Co/1money-ts-sdk.git"},"scripts":{"build":"npm run clean && npm run build:esm && npm run build:cjs && npm run build:types","build:esm":"tsc -p tsconfig.json","build:cjs":"tsc -p tsconfig.cjs.json","build:types":"tsc -p tsconfig.json --emitDeclarationOnly --outDir dist/types","prepublishOnly":"npm run build","test":"vitest run","test:watch":"vitest","clean":"rm -rf dist","release":"bash scripts/release.sh"},"devDependencies":{"@types/node":"^25.2.0","typescript":"^5.7.0","vitest":"^3.0.0"},"engines":{"node":">=18.0.0"},"license":"MIT","_id":"@1money/1money-ts-sdk@0.0.1","gitHead":"1f06e36f15cb938d194de4ed3941017129688bb7","bugs":{"url":"https://github.com/1Money-Co/1money-ts-sdk/issues"},"homepage":"https://github.com/1Money-Co/1money-ts-sdk#readme","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-kEUD7Ya3gQR73os583G3ZLbm3CZ68kw74WuMfdCZxyylVytE+Ga8pobwqZwT4mgUFXSZwJV0X6j5JvYo1d3b0g==","shasum":"e56508a277147dbaeda237f6dbe39080260925a5","tarball":"https://registry.npmjs.org/@1money/1money-ts-sdk/-/1money-ts-sdk-0.0.1.tgz","fileCount":118,"unpackedSize":106159,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDigr3SOYYZhXpjqaJ4U/m/C017dHUDVXl7PGjK3H2drgIhANWP7wrRK1HQgWYOEM3166Qu7JBQwwdNxIeSTnmGJXmG"}]},"_npmUser":{"name":"bobby-1money","email":"bobby@1money.com"},"directories":{},"maintainers":[{"name":"bobby-1money","email":"bobby@1money.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/1money-ts-sdk_0.0.1_1770002216028_0.22258627580920542"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-02T03:16:55.918Z","0.0.1":"2026-02-02T03:16:56.206Z","modified":"2026-02-02T03:16:56.444Z"},"maintainers":[{"name":"bobby-1money","email":"bobby@1money.com"}],"description":"TypeScript SDK for the 1Money Stablecoin Platform API","homepage":"https://github.com/1Money-Co/1money-ts-sdk#readme","repository":{"type":"git","url":"git+https://github.com/1Money-Co/1money-ts-sdk.git"},"bugs":{"url":"https://github.com/1Money-Co/1money-ts-sdk/issues"},"license":"MIT","readme":"# @1money/1money-ts-sdk\n\nTypeScript SDK for the [1Money Stablecoin Platform API](https://api.1money.com).\n\n## Features\n\n- Full coverage of all 1Money API endpoints\n- ESM and CommonJS dual-package support\n- HMAC-SHA256 request signing for production, Bearer token for sandbox\n- Idempotency key support for critical operations\n- Full TypeScript type definitions\n- Node.js 18+\n\n## Installation\n\n```bash\nnpm install @1money/1money-ts-sdk\n```\n\n## Quick Start\n\n```typescript\nimport { OneMoneySDK } from \"@1money/1money-ts-sdk\";\n\nconst sdk = new OneMoneySDK({\n  accessKey: process.env.ONEMONEY_ACCESS_KEY!,\n  secretKey: process.env.ONEMONEY_SECRET_KEY!,\n  sandbox: true,\n});\n\n// List customers\nconst customers = await sdk.customers.list({ page_size: 10 });\nconsole.log(customers);\n```\n\nOr load configuration from environment variables automatically:\n\n```typescript\nconst sdk = OneMoneySDK.fromConfig();\n```\n\n## Configuration\n\n| Parameter   | Type      | Required | Default                              | Description                  |\n| ----------- | --------- | -------- | ------------------------------------ | ---------------------------- |\n| `accessKey` | `string`  | Yes      | —                                    | API access key               |\n| `secretKey` | `string`  | Yes      | —                                    | API secret key               |\n| `sandbox`   | `boolean` | No       | `true`                               | Use sandbox environment      |\n| `baseUrl`   | `string`  | No       | `https://api.sandbox.1money.com`     | API base URL                 |\n| `timeoutMs` | `number`  | No       | `30000`                              | Request timeout (ms)         |\n\n### Environment Variables\n\n| Variable              | Description       |\n| --------------------- | ----------------- |\n| `ONEMONEY_ACCESS_KEY` | API access key    |\n| `ONEMONEY_SECRET_KEY` | API secret key    |\n| `ONEMONEY_BASE_URL`   | API base URL override |\n\n## Services\n\n### Customers\n\n```typescript\n// List\nconst list = await sdk.customers.list({ page_size: 10, page_num: 1 });\n\n// Create\nconst customer = await sdk.customers.create({\n  business_name: \"Acme Corp\",\n  email: \"acme@example.com\",\n  business_type: \"corporation\",\n  industry: \"technology\",\n});\n\n// Get / Update\nconst detail = await sdk.customers.get(customerId);\nconst updated = await sdk.customers.update(customerId, { business_name: \"New Name\" });\n\n// Associated Persons\nawait sdk.customers.createAssociatedPerson(customerId, { first_name: \"Alice\", last_name: \"Wang\", email: \"alice@example.com\" });\nawait sdk.customers.listAssociatedPersons(customerId);\nawait sdk.customers.getAssociatedPerson(customerId, personId);\nawait sdk.customers.updateAssociatedPerson(customerId, personId, { first_name: \"Bob\" });\nawait sdk.customers.deleteAssociatedPerson(customerId, personId);\n\n// Intermediaries\nawait sdk.customers.createIntermediary(customerId, { name: \"Partner Bank\", type: \"bank\" });\nawait sdk.customers.listIntermediaries(customerId);\nawait sdk.customers.updateIntermediary(customerId, intermediaryId, { name: \"New Name\" });\nawait sdk.customers.deleteIntermediary(customerId, intermediaryId);\n\n// TOS Link\nconst tosLink = await sdk.customers.createTosLink({ customer_id: customerId });\n```\n\n### Assets\n\n```typescript\nconst assets = await sdk.assets.getAll(customerId);\n```\n\n### External Accounts\n\n```typescript\nawait sdk.externalAccounts.list(customerId);\nawait sdk.externalAccounts.create(customerId, { idempotency_key: key, type: \"bank_account\", currency: \"USD\" });\nawait sdk.externalAccounts.getById(customerId, accountId);\nawait sdk.externalAccounts.getByIdempotencyKey(customerId, key);\nawait sdk.externalAccounts.remove(customerId, accountId);\n```\n\n### Recipients\n\n```typescript\n// Recipients\nawait sdk.recipients.list(customerId, { page_size: 10 });\nawait sdk.recipients.create(customerId, { idempotency_key: key, name: \"John Doe\", type: \"individual\" });\nawait sdk.recipients.get(customerId, recipientId);\nawait sdk.recipients.update(customerId, recipientId, { name: \"Jane Doe\" });\nawait sdk.recipients.delete(customerId, recipientId);\n\n// Bank Accounts\nawait sdk.recipients.addBankAccount(customerId, recipientId, { idempotency_key: key, currency: \"USD\", account_number: \"123456789\", routing_number: \"021000021\" });\nawait sdk.recipients.listBankAccounts(customerId, recipientId);\nawait sdk.recipients.updateBankAccount(customerId, recipientId, bankAccountId, { account_number: \"987654321\" });\nawait sdk.recipients.deleteBankAccount(customerId, recipientId, bankAccountId);\n```\n\n### Conversions\n\n```typescript\n// Create a quote\nconst quote = await sdk.conversions.createQuote(customerId, {\n  from_asset: { asset: \"USDC\", network: \"ethereum\", amount: \"100\" },\n  to_asset: { asset: \"USD\", network: \"ach\" },\n});\n\n// Lock in the quote\nconst hedge = await sdk.conversions.createHedge(customerId, { quote_id: quote.quote_id });\n\n// Get conversion order\nconst order = await sdk.conversions.getOrder(customerId, orderId);\n```\n\n### Transfers\n\n```typescript\nconst transfer = await sdk.transfers.create(customerId, {\n  idempotency_key: key,\n  target_customer_id: \"cus_target_id\",\n  asset: \"USDC\",\n  amount: \"10\",\n  description: \"Payment\",\n});\nawait sdk.transfers.get(customerId, transactionId);\nawait sdk.transfers.getByIdempotencyKey(customerId, key);\n```\n\n### Withdrawals\n\n```typescript\nconst withdrawal = await sdk.withdrawals.create(customerId, {\n  idempotency_key: key,\n  target_customer_id: \"cus_target_id\",\n  asset: \"USDC\",\n  amount: \"50\",\n});\nawait sdk.withdrawals.get(customerId, transactionId);\nawait sdk.withdrawals.getByIdempotencyKey(customerId, key);\n```\n\n### Auto Conversion Rules\n\n```typescript\nawait sdk.autoConversionRules.list(customerId, { page_size: 10 });\nawait sdk.autoConversionRules.create(customerId, { idempotency_key: key, from_asset: \"USDC\", to_asset: \"USD\" });\nawait sdk.autoConversionRules.getById(customerId, ruleId);\nawait sdk.autoConversionRules.getByIdempotencyKey(customerId, key);\nawait sdk.autoConversionRules.delete(customerId, ruleId);\n\n// Orders\nawait sdk.autoConversionRules.listOrders(customerId, ruleId);\nawait sdk.autoConversionRules.getOrderById(customerId, ruleId, orderId);\n```\n\n### Deposit Instructions\n\n```typescript\nconst instructions = await sdk.depositInstructions.get(customerId, {\n  asset: \"USDC\",\n  network: \"ethereum\",\n});\n```\n\n### Fees\n\n```typescript\nconst fee = await sdk.fees.estimate(customerId, {\n  action: \"withdrawal\",\n  asset: \"USDC\",\n  network: \"ethereum\",\n  amount: \"100\",\n});\n```\n\n### Transactions\n\n```typescript\nconst transactions = await sdk.transactions.list(customerId, { page_size: 5 });\nconst tx = await sdk.transactions.get(customerId, transactionId);\n```\n\n### Simulations (Sandbox Only)\n\n```typescript\nconst simulation = await sdk.simulations.simulateDeposit(customerId, {\n  asset: \"USDC\",\n  network: \"ethereum\",\n  amount: \"1000\",\n});\n```\n\n## Error Handling\n\nAll API errors are thrown as `ApiError` instances:\n\n```typescript\nimport { OneMoneySDK, ApiError } from \"@1money/1money-ts-sdk\";\n\ntry {\n  await sdk.customers.get(\"cus_nonexistent\");\n} catch (err) {\n  if (err instanceof ApiError) {\n    console.log(err.status);   // HTTP status code (e.g. 404)\n    console.log(err.code);     // Error code string\n    console.log(err.detail);   // Detailed error message\n    console.log(err.instance); // Request instance identifier\n  }\n}\n```\n\n## Examples\n\nRun any example with:\n\n```bash\nONEMONEY_ACCESS_KEY=your_key ONEMONEY_SECRET_KEY=your_secret npx tsx examples/basic-usage.ts\n```\n\n| Example                          | Description                          |\n| -------------------------------- | ------------------------------------ |\n| `basic-usage.ts`                 | SDK initialization and common APIs   |\n| `customers.ts`                   | Customer CRUD, persons, intermediaries |\n| `conversions.ts`                 | Quotes, hedges, conversion orders    |\n| `transfers-and-withdrawals.ts`   | Transfers and withdrawals            |\n| `recipients.ts`                  | Recipients and bank accounts         |\n| `external-accounts.ts`           | External account management          |\n| `auto-conversion-rules.ts`       | Auto conversion rule CRUD            |\n| `deposits-and-simulations.ts`    | Deposit instructions and simulations |\n| `error-handling.ts`              | Error handling patterns              |\n\n## Authentication\n\n- **Sandbox** (`sandbox: true`): Uses Bearer token authentication with `accessKey`.\n- **Production** (`sandbox: false`): Uses HMAC-SHA256 request signing with both `accessKey` and `secretKey`.\n\n## Development\n\n```bash\n# Build\nnpm run build\n\n# Run tests\nnpm test\n\n# Watch mode\nnpm run test:watch\n\n# Clean build output\nnpm run clean\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-9d93ed31a1d01afb7200dccb5372c92e"}