{"_id":"socialsdk","_rev":"3-2f705efdb9c522ff30dfd5a2a9202cc9","name":"socialsdk","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"socialsdk","version":"1.0.0","description":"A SDK for Social -- The Internet's API","main":"api.js","dependencies":{"asynckit":"^0.4.0","axios":"^1.6.8","combined-stream":"^1.0.8","delayed-stream":"^1.0.0","follow-redirects":"^1.15.6","form-data":"^4.0.0","js-tokens":"^4.0.0","jwt-decode":"^4.0.0","loose-envify":"^1.4.0","mime-db":"^1.52.0","mime-types":"^2.1.35","proxy-from-env":"^1.1.0","react":"^18.2.0"},"devDependencies":{},"scripts":{"test":"jest"},"repository":{"type":"git","url":"git+https://github.com/The-UX-Company/SocialSDK.git"},"keywords":["Social"],"author":{"name":"The UX Company"},"license":"ISC","bugs":{"url":"https://github.com/The-UX-Company/SocialSDK/issues"},"homepage":"https://github.com/The-UX-Company/SocialSDK#readme","_id":"socialsdk@1.0.0","gitHead":"dfd21839d46f88fe2dc1bcdd06c7c3579147e853","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-sre88OpbXMyePxeA1hqKJvUw8P99fpOwDMAndXE1o6/tv+fwwTcXDbETU5VWo9C0rdu4kWjtkVQEvq1GXnGD/Q==","shasum":"9bccc32f48010c9c4420e39fcf6207c00d853438","tarball":"https://registry.npmjs.org/socialsdk/-/socialsdk-1.0.0.tgz","fileCount":11,"unpackedSize":18540,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCOBXpdYfThenz6xKYYPCFNFqwinvzOTbfWVep2bh9lKQIgRTcBq/zmE6MAbBmp3no9TMEc4BLC/ONtqUYizbol3F0="}]},"_npmUser":{"name":"eligrayy","email":"elijahnoussi@icloud.com"},"directories":{},"maintainers":[{"name":"eligrayy","email":"elijahnoussi@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/socialsdk_1.0.0_1713129918932_0.26922284922961404"},"_hasShrinkwrap":false},"1.0.1":{"name":"socialsdk","version":"1.0.1","description":"A SDK for Social -- The Internet's API","main":"api.js","dependencies":{"asynckit":"^0.4.0","axios":"^1.6.8","combined-stream":"^1.0.8","delayed-stream":"^1.0.0","follow-redirects":"^1.15.6","form-data":"^4.0.0","js-tokens":"^4.0.0","jwt-decode":"^4.0.0","loose-envify":"^1.4.0","mime-db":"^1.52.0","mime-types":"^2.1.35","proxy-from-env":"^1.1.0","react":"^18.2.0"},"devDependencies":{},"scripts":{"test":"jest"},"repository":{"type":"git","url":"git+https://github.com/The-UX-Company/SocialSDK.git"},"keywords":["Social"],"author":{"name":"The UX Company"},"license":"ISC","bugs":{"url":"https://github.com/The-UX-Company/SocialSDK/issues"},"homepage":"https://github.com/The-UX-Company/SocialSDK#readme","_id":"socialsdk@1.0.1","gitHead":"cfac8d30b0796969176e432cc3c89932ebaa2de4","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-hTk2b77NIwW+YOIc4IiJ0eKGIiH7LU3cY91qipcNCe5JTOyFqYjcU6QIsJXFXRAVe58jWjsSKkFQJmumHo/+Cw==","shasum":"fe8168bd4a31612b510d10a0bd577c9269ad67a8","tarball":"https://registry.npmjs.org/socialsdk/-/socialsdk-1.0.1.tgz","fileCount":12,"unpackedSize":22299,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCIDFP62TQE2AOzwxCxPaLowrCTsgukKB1seihK5PB3CiTAh9+IaJSxDJpktct1rI1q4xA9FH2D63QkBXYPjoaXzmh"}]},"_npmUser":{"name":"eligrayy","email":"elijahnoussi@icloud.com"},"directories":{},"maintainers":[{"name":"eligrayy","email":"elijahnoussi@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/socialsdk_1.0.1_1713130565771_0.9549826174934608"},"_hasShrinkwrap":false},"1.0.2":{"name":"socialsdk","version":"1.0.2","description":"A SDK for Social -- The Internet's API","main":"api.js","dependencies":{"asynckit":"^0.4.0","axios":"^1.6.8","combined-stream":"^1.0.8","delayed-stream":"^1.0.0","follow-redirects":"^1.15.6","form-data":"^4.0.0","js-tokens":"^4.0.0","jwt-decode":"^4.0.0","loose-envify":"^1.4.0","mime-db":"^1.52.0","mime-types":"^2.1.35","proxy-from-env":"^1.1.0","react":"^18.2.0"},"devDependencies":{},"scripts":{"test":"jest"},"repository":{"type":"git","url":"git+https://github.com/The-UX-Company/SocialSDK.git"},"keywords":["Social"],"author":{"name":"The UX Company"},"license":"ISC","bugs":{"url":"https://github.com/The-UX-Company/SocialSDK/issues"},"homepage":"https://github.com/The-UX-Company/SocialSDK#readme","_id":"socialsdk@1.0.2","gitHead":"b46ab8067526f252badddf10fa34b173245d8631","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-vVu1fDLNDlABo/mVs4p/0IgVdilPdLgZqZ6oR+wiZkuWI21nsCc8xUKJhvRWSigRjhpp1ZYFC4aitpQB6YHl5g==","shasum":"bb7c14eb804d46293f8a89450745c01349b44f40","tarball":"https://registry.npmjs.org/socialsdk/-/socialsdk-1.0.2.tgz","fileCount":12,"unpackedSize":24540,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5fALla82Tk3fW7IYo5RqNaOpcc8VdnQvOkjD4liXCVgIhAPIf+C2N8lAkx5mTqISBiu/nNEjPDaCGeKsXtGdlFGuf"}]},"_npmUser":{"name":"eligrayy","email":"elijahnoussi@icloud.com"},"directories":{},"maintainers":[{"name":"eligrayy","email":"elijahnoussi@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/socialsdk_1.0.2_1713296264777_0.22501395842458405"},"_hasShrinkwrap":false},"1.0.3":{"name":"socialsdk","version":"1.0.3","description":"A SDK for Social -- The Internet's API","main":"api.js","dependencies":{"asynckit":"^0.4.0","axios":"^1.6.8","combined-stream":"^1.0.8","delayed-stream":"^1.0.0","follow-redirects":"^1.15.6","form-data":"^4.0.0","js-tokens":"^4.0.0","jwt-decode":"^4.0.0","loose-envify":"^1.4.0","mime-db":"^1.52.0","mime-types":"^2.1.35","proxy-from-env":"^1.1.0","react":"^18.2.0"},"devDependencies":{},"scripts":{"test":"jest"},"repository":{"type":"git","url":"git+https://github.com/The-UX-Company/SocialSDK.git"},"keywords":["Social"],"author":{"name":"The UX Company"},"license":"ISC","bugs":{"url":"https://github.com/The-UX-Company/SocialSDK/issues"},"homepage":"https://github.com/The-UX-Company/SocialSDK#readme","_id":"socialsdk@1.0.3","gitHead":"918bde839894be234ae0e49bdd56c709d9e44f78","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-ymUf9lLlsMiBxZ00B0/jTn5Am7cm7K8xb/wXHJiZx3jayw9RwoG6ghKG9o/CDMN89UI+li85aUXdaeS1V/bQ7w==","shasum":"3292e9776e2f4dcd97a830371414f6f5f7b522dd","tarball":"https://registry.npmjs.org/socialsdk/-/socialsdk-1.0.3.tgz","fileCount":12,"unpackedSize":28550,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFYNWgnttMaIv+AMdfDKjgceGgLCJV3Z6TQ0cy2sKmV4AiEAmSFzZOAuNS3YPPq0IJ+hvxLP2fJ6sxjoQT8o17jmFec="}]},"_npmUser":{"name":"eligrayy","email":"elijahnoussi@icloud.com"},"directories":{},"maintainers":[{"name":"eligrayy","email":"elijahnoussi@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/socialsdk_1.0.3_1713296727218_0.6647911638603767"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-14T21:25:18.856Z","1.0.0":"2024-04-14T21:25:19.084Z","modified":"2024-04-16T19:45:27.630Z","1.0.1":"2024-04-14T21:36:05.923Z","1.0.2":"2024-04-16T19:37:44.959Z","1.0.3":"2024-04-16T19:45:27.428Z"},"maintainers":[{"name":"eligrayy","email":"elijahnoussi@icloud.com"}],"description":"A SDK for Social -- The Internet's API","homepage":"https://github.com/The-UX-Company/SocialSDK#readme","keywords":["Social"],"repository":{"type":"git","url":"git+https://github.com/The-UX-Company/SocialSDK.git"},"author":{"name":"The UX Company"},"bugs":{"url":"https://github.com/The-UX-Company/SocialSDK/issues"},"license":"ISC","readme":"\n\n# SocialSDK Documentation\n\nSocialSDK enables the rapid development of social platforms by providing a comprehensive set of components and an API for handling common tasks such as user authentication, profile management, posts creation, and file uploads.\n\n## Table of Contents\n- [Getting Started](#getting-started)\n- [Installation](#installation)\n- [Components](#components)\n  - [LogInBox](#loginbox)\n  - [ProfileComponent](#profilecomponent)\n  - [FollowComponent](#followcomponent)\n  - [FeedComponent](#feedcomponent)\n  - [PostCreationForm](#postcreationform)\n  - [UploadComponent](#uploadcomponent)\n  - [RegistrationComponent](#registrationcomponent)\n- [Context](#context)\n  - [AuthProvider](#authprovider)\n- [API Services](#api-services)\n- [Best Practices](#best-practices)\n- [Troubleshooting](#troubleshooting)\n\n## Getting Started\nThis guide assumes that you have a basic understanding of React and its ecosystem. SocialSDK is designed to work within React applications and utilizes state management, context, and hooks extensively.\n\n## Installation\nTo incorporate SocialSDK into your project, clone the repository or copy the desired components directly into your project structure. Ensure that all dependencies, particularly `axios` for API requests and `jwt-decode` for handling JWT tokens, are installed in your project:\n\n```bash\nnpm install axios jwt-decode\n```\n\nIf you're using environment variables (recommended for sensitive information like API keys), ensure they're properly configured in your environment or `.env` file.\n\n## 1. Setting Up Your Development Environment\n\n### 1.1 Install Node.js and npm\nIf you haven't already, download and install Node.js from [nodejs.org](https://nodejs.org/). npm (Node Package Manager) comes bundled with Node.js.\n\n### 1.2 Create a New Project Directory\nOpen your terminal or command prompt, navigate to your desired location, and create a new directory for your project:\n```bash\nmkdir my-social-app\ncd my-social-app\n```\n\n### 1.3 Initialize Your Project\nInitialize a new Node.js project by running:\n```bash\nnpm init -y\n```\n\n## 2. Installing the SocialSDK Package\n\n### 2.1 Install SocialSDK Package\nInstall the SocialSDK package using npm:\n```bash\nnpm install socialsdk\n```\n\n## 3. Obtaining and Setting Up Your API Key\n\n### 3.1 Sign Up for an Account\nIf you haven't already, sign up for an account on the Social platform.\n\n### 3.2 Obtain Your API Key\nAfter signing up, navigate to your account settings or developer dashboard to obtain your API key.\n\n### 3.3 Store Your API Key\nFor security reasons, it's best practice to store your API key in environment variables. Create a new file named `.env` in the root of your project directory and add your API key:\n```\nREACT_APP_API_KEY=your_api_key_here\n```\n\n## 4. Writing Your First Code\n\n### 4.1 Create a JavaScript File\nCreate a new JavaScript file in your project directory. Let's name it `app.js`.\n\n### 4.2 Import SocialSDK Components\nIn your `app.js` file, import the necessary components from the SocialSDK package:\n```javascript\nimport {\n  LogInBox,\n  ProfileComponent,\n  FollowComponent,\n  FeedComponent,\n  PostCreationForm,\n  UploadComponent,\n  RegistrationComponent\n} from 'socialsdk';\n```\n\n### 4.3 Initialize Your API Base URL\nDefine your API base URL and API key:\n```javascript\nconst API_BASE_URL = 'http://[DOMAIN]/api';\nconst API_KEY = process.env.REACT_APP_API_KEY;\n```\n\n### 4.4 Making API Requests\nImplement API requests using the provided functions:\n```javascript\n// Example API call to login\nexport const login = (email, password, platform_id) => makeRequest('/members/login', 'post', {email, password, platform_id});\n// Other API request functions...\n```\n\n### 4.5 Run Your Code\nTo test your setup, run your JavaScript file using Node.js:\n```bash\nnode app.js\n```\n\n## Configuration\n\n- **API Base URL**: All requests are made relative to the `API_BASE_URL`, which should be configured to point to the Social backend server.\n- **API Key**: The module utilizes an `API_KEY` obtained from the environment variables for authorization. Ensure that `REACT_APP_API_KEY` is properly set in your environment.\n\n## Helper Function\n\n- **makeRequest**: A helper function designed to streamline the process of making API calls. It automatically appends the API key to the headers for authorization and handles the construction of the request based on the given endpoint, HTTP method, and data.\n\n## API Functions\n\nThis section describes the key functions provided by the api.js module.\n\n### User Authentication\n\n- **login(email, password, platform_id)**: Authenticates a user against the platform.\n- **registerMember(name, email, user_id, password, platform_id)**: Registers a new member on the platform.\n\n### Content Management\n\n- **createPost(platform_id, memberId, contentType, content)**: Creates a new post on the platform.\n- **getPosts(member_id, platform_id)**: Fetches posts, optionally filtered by `member_id` or `platform_id`.\n- **uploadFile(file, platform_id)**: Uploads a file to the platform.\n    - *Note: The front-end implementation for this method is marked as TODO.*\n\n### Social Interactions\n\n- **followUser(follower_id, followed_id)**: Initiates a follow relationship between two users.\n- **unfollowUser(follower_id, followed_id)**: Removes a follow relationship between two users.\n\nPlatform and Member Management\n\n- **createPlatform(name)**: Creates a new platform within SocialSDK.\n- **addMemberToPlatform(platform_id, userId)**: Adds a member to a specified platform.\n- **getMembersOnPlatform(platform_id)**: Retrieves all members associated with a specific platform.\n- **deletePlatform(platform_id)**: Deletes a specified platform from SocialSDK.\n- **setPermissions(platform_id, contentType, allowed)**: Sets permissions for content posting on the platform.\n\n## Usage Examples\n\n### Logging in a User\n\n```jsx\nimport { login } from './api';\n\nconst userEmail = 'user@example.com';\nconst userPassword = 'password123';\nconst platformId = 'platform1';\n\nlogin(userEmail, userPassword, platformId)\n  .then(response => console.log('Login Successful', response))\n  .catch(error => console.error('Login Failed', error));\n```\n\n### Registering a New Platform Member\n\n```jsx\nimport { registerMember } from './api';\n\nconst memberInfo = {\n  name: 'John Doe',\n  email: 'john.doe@example.com',\n  user_id: '1', // This is optional and to be adjusted based on backend requirements\n  password: 'password123',\n  platform_id: 'platform1'\n};\n\nregisterMember(memberInfo.name, memberInfo.email, memberInfo.user_id, memberInfo.password, memberInfo.platform_id)\n  .then(response => console.log('Registration Successful', response))\n  .catch(error => console.error('Registration Failed', error));\n\n```\n\n## Advanced Topics\n\n- **Error Handling**: All functions are designed to propagate errors to the caller, allowing for sophisticated error handling strategies in the UI layer.\n- **Custom Headers**: While most requests will only require the API key, additional headers can be added to the `makeRequest` function as needed (e.g., content type for file uploads).\n\n## Future Enhancements\n\n- Expanding the API to cover more backend functionalities as they become available.\n- Improving error handling to provide more detailed feedback to the frontend.\n- Adding functionality to support real-time features like notifications or live updates.\n\n**Key API Method Cheatsheet:**\n\n- `login(email, password, platform_id)`\n- `registerMember(name, email, user_id, password, platform_id)`\n- `uploadFile(file, platform_id)`\n- `createPlatform(name)`\n- `addMemberToPlatform(platform_id, userId)`\n- `createPost(platform_id, memberId, contentType, content)`\n- `followUser(follower_id, followed_id)`\n- `unfollowUser(follower_id, followed_id)`\n- `getPosts(member_id, platform_id)`\n- `getMembersOnPlatform(platform_id)`\n\n## Components\n\n### LogInBox\nHandles user login.\n```jsx\n<LogInBox platformId=\"yourPlatformId\" />\n```\n\n### ProfileComponent\nDisplays user profile information, their posts, and followed users.\n```jsx\n<ProfileComponent userId=\"userId\" platformId=\"platformId\" />\n```\n\n### FollowComponent\nAllows current users to follow or unfollow other users.\n```jsx\n<FollowComponent />\n```\n\n### FeedComponent\nRenders a feed of posts, supports infinite scrolling.\n```jsx\n<FeedComponent />\n```\n\n### PostCreationForm\nForm for creating new posts with support for text, photos, and videos.\n```jsx\n<PostCreationForm />\n```\n\n### UploadComponent\nHandles file uploads to the server.\n```jsx\n<UploadComponent platformId=\"platformId\" apiKey=\"apiKey\" />\n```\n\n### RegistrationComponent\nEnables new users to register on the platform.\n```jsx\n<RegistrationComponent platformId=\"yourPlatformId\" />\n```\n\n## Context\n\n### AuthProvider\nManages authentication state and provides login and logout functionalities. Wrap your application's root component with AuthProvider:\n```jsx\nimport { AuthProvider } from './context/AuthContext';\nfunction App() {\n  return (\n    <AuthProvider>\n      <YourApp />\n    </AuthProvider>\n  );\n}\n```\n\n## API Services\nYour backend services should be structured to handle requests for user registration, login, post creation, following users, and managing files. Ensure your API endpoints are secured and validate inputs to prevent unauthorized access and data breaches.\n\nMore detailed information and usage examples for each API service are available in the project's `api.js` file.\n\n## Best Practices\n- Use environment variables for sensitive information like API keys.\n- Secure API endpoints using authentication and validate inputs to prevent SQL injection or other security threats.\n- Utilize AuthProvider context to manage user authentication state across your application.\n\n## Troubleshooting\n- **Issue:** Authentication state does not persist on page reload.\n  **Solution:** Use local storage, session storage, or cookies to store authentication tokens and validate them on the application's mount.\n\nFor further support, consider consulting React documentation or reaching out on platforms like Stack Overflow or GitHub discussions.","readmeFilename":"README.md"}