{"_id":"@bananaclip-llc/sdk","name":"@bananaclip-llc/sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@bananaclip-llc/sdk","version":"1.0.0","description":"SDK for communicating with backend services, with support for iframe-parent communication","main":"dist/index.js","types":"dist/index.d.ts","browser":"dist/banana-sdk.browser.js","scripts":{"build":"tsc","build:browser":"webpack","build:browser:simple":"tsc && node browser-bundle.js","copy:browser":"node copy-bundle.js","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","test:manual":"node test.js","prepare":"npm run build && npm run copy:browser","prepublishOnly":"echo 'Skipping tests for now, but you should fix them before publishing to production'"},"keywords":["sdk","iframe","postMessage","api","communication"],"author":{"name":"Ozgur Sallanci"},"license":"MIT","dependencies":{"axios":"^1.8.3"},"devDependencies":{"@babel/core":"^7.22.0","@babel/preset-env":"^7.22.0","@babel/preset-typescript":"^7.22.0","@types/jest":"^29.5.0","babel-jest":"^29.5.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","ts-jest":"^29.1.0","ts-loader":"^9.5.2","typescript":"^5.0.0","webpack":"^5.98.0","webpack-cli":"^5.1.4"},"repository":{"type":"git","url":"git+https://github.com/BananaClip-LLC/bananaclip-sdk.git"},"bugs":{"url":"https://github.com/BananaClip-LLC/bananaclip-sdk/issues"},"homepage":"https://github.com/BananaClip-LLC/bananaclip-sdk#readme","_id":"@bananaclip-llc/sdk@1.0.0","gitHead":"7d21bc264f6f26a075c1bc8dde194896a26a73c2","_nodeVersion":"22.13.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-JizCzvZX22Jqdp9DCB1FialTtLqdF/Pm7Rg99w+MCBEUcIUqyhd3PaTGvv08bgfzepGj86vx6fkOg+kWs4mp+A==","shasum":"29c042478ab97b506d85c8e1d555fb66a0b71b84","tarball":"https://registry.npmjs.org/@bananaclip-llc/sdk/-/sdk-1.0.0.tgz","fileCount":16,"unpackedSize":51026,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH9hb+eNfUpI257JlR21VMsLrTpLc5mTkefjyQw9SssCAiBKMsmTSvV/TU0fED7V6eauI+dM7EmZjRJtXI8F3s9Aqg=="}]},"_npmUser":{"name":"osallanci","email":"ozgur.sallanci@gmail.com"},"directories":{},"maintainers":[{"name":"osallanci","email":"ozgur.sallanci@gmail.com"},{"name":"bananaclip","email":"contact@bananaclip.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_1.0.0_1742560600792_0.38101465850352345"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-21T12:36:40.736Z","1.0.0":"2025-03-21T12:36:40.975Z","modified":"2025-03-21T12:36:41.190Z"},"maintainers":[{"name":"osallanci","email":"ozgur.sallanci@gmail.com"},{"name":"bananaclip","email":"contact@bananaclip.io"}],"description":"SDK for communicating with backend services, with support for iframe-parent communication","homepage":"https://github.com/BananaClip-LLC/bananaclip-sdk#readme","keywords":["sdk","iframe","postMessage","api","communication"],"repository":{"type":"git","url":"git+https://github.com/BananaClip-LLC/bananaclip-sdk.git"},"author":{"name":"Ozgur Sallanci"},"bugs":{"url":"https://github.com/BananaClip-LLC/bananaclip-sdk/issues"},"license":"MIT","readme":"# BananaClip SDK\n\nSDK for communicating with backend services, with support for iframe-parent communication.\n\n## Installation\n\n```bash\nnpm install @bananaclip-llc/sdk\n```\n\n## Usage\n\n### Node.js\n\n```javascript\nconst { BananaSDK } = require(\"@bananaclip-llc/sdk\");\n\n// Initialize the SDK\nconst sdk = new BananaSDK({\n  baseUrl: \"https://api.bananaclip.io\",\n  accessToken: \"your-access-token\",\n});\n\n// Get user profile\nsdk\n  .getMe()\n  .then((profile) => console.log(\"User profile:\", profile))\n  .catch((error) => console.error(\"Error fetching profile:\", error));\n\n// Get user token balance\nsdk\n  .getUserToken()\n  .then((token) => console.log(\"Token balance:\", token))\n  .catch((error) => console.error(\"Error fetching token:\", error));\n```\n\n### TypeScript\n\n```typescript\nimport { BananaSDK } from \"@bananaclip-llc/sdk\";\n\ninterface UserProfile {\n  id: string;\n  username: string;\n  email: string;\n  avatar: string;\n  createdAt: string;\n}\n\n// Initialize the SDK\nconst sdk = new BananaSDK({\n  baseUrl: \"https://api.bananaclip.io\",\n  accessToken: \"your-access-token\",\n});\n\nasync function runExample() {\n  try {\n    // Get user profile\n    const profile = (await sdk.getMe()) as UserProfile;\n    console.log(\"User profile:\", profile);\n\n    // Get user token balance\n    const token = await sdk.getUserToken();\n    console.log(\"Token balance:\", token);\n  } catch (error) {\n    console.error(\"Error:\", error);\n  }\n}\n\nrunExample();\n```\n\n### Browser\n\nInclude the SDK in your HTML:\n\n```html\n<!-- Include axios dependency -->\n<script src=\"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js\"></script>\n<!-- Include BananaSDK -->\n<script src=\"path/to/node_modules/@bananaclip-llc/sdk/dist/banana-sdk.browser.js\"></script>\n\n<script>\n  // Initialize the SDK\n  const sdk = new BananaSDK({\n    baseUrl: \"https://api.bananaclip.io\",\n    accessToken: \"your-access-token\",\n  });\n\n  // Get user profile\n  sdk\n    .getMe()\n    .then((profile) => console.log(\"User profile:\", profile))\n    .catch((error) => console.error(\"Error fetching profile:\", error));\n\n  // Get user token balance\n  sdk\n    .getUserToken()\n    .then((token) => console.log(\"Token balance:\", token))\n    .catch((error) => console.error(\"Error fetching token:\", error));\n</script>\n```\n\n### Parent-iframe Communication\n\nThe SDK supports communication between a parent window and an iframe:\n\n1. In the parent window:\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js\"></script>\n<script src=\"path/to/node_modules/@bananaclip-llc/sdk/dist/banana-sdk.browser.js\"></script>\n<script>\n  window.addEventListener(\"message\", function (event) {\n    // Handle messages from iframe\n    console.log(\"Message from iframe:\", event.data);\n  });\n\n  // Send message to iframe\n  const iframe = document.getElementById(\"myIframe\");\n  iframe.contentWindow.postMessage(\n    { type: \"ACCESS_TOKEN\", payload: \"your-access-token\" },\n    \"*\"\n  );\n</script>\n```\n\n2. In the iframe:\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js\"></script>\n<script src=\"path/to/node_modules/@bananaclip-llc/sdk/dist/banana-sdk.browser.js\"></script>\n<script>\n  const sdk = new BananaSDK({\n    baseUrl: \"https://api.bananaclip.io\",\n    parentWindow: window.parent,\n  });\n\n  // SDK will automatically request access token from parent\n  sdk\n    .getMe()\n    .then((profile) => console.log(\"User profile:\", profile))\n    .catch((error) => console.error(\"Error fetching profile:\", error));\n</script>\n```\n\n## API Reference\n\n### Constructor\n\n```javascript\nconst sdk = new BananaSDK(options);\n```\n\nOptions:\n\n- `baseUrl` (string): API base URL\n- `accessToken` (string, optional): Access token for authentication\n- `parentWindow` (Window, optional): Parent window reference for iframe communication\n\n### Methods\n\n- `getMe()`: Get user profile\n- `getUserToken()`: Get user token balance\n- `getAccessToken()`: Get current access token\n- `setAccessToken(token)`: Set access token\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-aa46dd3c8ccf444a371758d9655fcac8"}