New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

remote-storage

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remote-storage - npm Package Compare versions

Comparing version 0.0.9 to 1.0.0

2

./dist/index.js

@@ -1,2 +0,2 @@

import a from"cross-fetch";function n(){let s=new Date().getTime(),e=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16;return s>0?(r=(s+r)%16|0,s=Math.floor(s/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),(t=="x"?r:r&7|8).toString(16)})}var i="/entities/",o=class{constructor({serverAddress:e,instanceId:t,userId:r}){this.serverAddress=e,this.instanceId=t??n(),this.userId=r??n()}async getItem(e){return await(await this.call("GET",`${i}${e}`,null)).json()}async setItem(e,t){await this.call("PUT",`${i}${e}`,t)}async removeItem(e){await this.call("DELETE",`${i}${e}`,null)}async call(e,t,r){return a(new URL(t,this.serverAddress).toString(),{method:e,headers:{"Content-Type":"application/json",HEADER_REMOTE_STORAGE_INSTANCE_ID:this.instanceId,HEADER_REMOTE_STORAGE_USER_ID:this.userId},body:r?JSON.stringify(r):void 0})}};var p="x-remote-storage-instance-id",l="x-remote-storage-user-id";export{p as HEADER_REMOTE_STORAGE_INSTANCE_ID,l as HEADER_REMOTE_STORAGE_USER_ID,o as RemoteStorage};
import u from"cross-fetch";function a(){let s=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16;return s>0?(e=(s+e)%16|0,s=Math.floor(s/16)):(e=(t+e)%16|0,t=Math.floor(t/16)),(r=="x"?e:e&7|8).toString(16)})}function n(){return typeof window<"u"}var d="x-remote-storage-instance-id",x="x-remote-storage-user-id";var i="/entities/",o=class{constructor({serverAddress:t,userId:r,instanceId:e}){this.serverAddress=t,this.instanceId=e??"default",this.userId=r??this.getUserId()}async getItem(t){let r=await this.call("GET",`${i}${t}`,null);if(r.status===404)return null;let e=await r.text();return e.startsWith("{")?JSON.parse(e):e==="true"?!0:e==="false"?!1:isNaN(Number(e))?e:Number(e)}async setItem(t,r){await this.call("PUT",`${i}${t}`,r)}async removeItem(t){await this.call("DELETE",`${i}${t}`,null)}async call(t,r,e){return u(new URL(r,this.serverAddress).toString(),{method:t,headers:{"Content-Type":"application/json",[d]:this.instanceId,[x]:this.userId},body:e?JSON.stringify(e):void 0})}getUserId(){let t="rs-user-id";if(n()&&window.localStorage.getItem(t))return window.localStorage.getItem(t);let r=a();return n()&&window.localStorage.setItem(t,r),r}};export{d as HEADER_REMOTE_STORAGE_INSTANCE_ID,x as HEADER_REMOTE_STORAGE_USER_ID,o as RemoteStorage};
//# sourceMappingURL=index.js.map
interface RemoteStorageProps {
serverAddress: string;
userId?: string;
instanceId?: string;
userId?: string;
}

@@ -10,3 +10,3 @@ declare class RemoteStorage {

private readonly userId;
constructor({ serverAddress, instanceId, userId }: RemoteStorageProps);
constructor({ serverAddress, userId, instanceId }: RemoteStorageProps);
getItem<T>(key: string): Promise<T>;

@@ -16,2 +16,3 @@ setItem<T>(key: string, value: T): Promise<void>;

call(method: string, path: string, data?: any): Promise<Response>;
private getUserId;
}

@@ -18,0 +19,0 @@

@@ -1,2 +0,2 @@

import a from"cross-fetch";function n(){let s=new Date().getTime(),e=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16;return s>0?(r=(s+r)%16|0,s=Math.floor(s/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),(t=="x"?r:r&7|8).toString(16)})}var i="/entities/",o=class{constructor({serverAddress:e,instanceId:t,userId:r}){this.serverAddress=e,this.instanceId=t??n(),this.userId=r??n()}async getItem(e){return await(await this.call("GET",`${i}${e}`,null)).json()}async setItem(e,t){await this.call("PUT",`${i}${e}`,t)}async removeItem(e){await this.call("DELETE",`${i}${e}`,null)}async call(e,t,r){return a(new URL(t,this.serverAddress).toString(),{method:e,headers:{"Content-Type":"application/json",HEADER_REMOTE_STORAGE_INSTANCE_ID:this.instanceId,HEADER_REMOTE_STORAGE_USER_ID:this.userId},body:r?JSON.stringify(r):void 0})}};var p="x-remote-storage-instance-id",l="x-remote-storage-user-id";export{p as HEADER_REMOTE_STORAGE_INSTANCE_ID,l as HEADER_REMOTE_STORAGE_USER_ID,o as RemoteStorage};
import u from"cross-fetch";function a(){let s=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16;return s>0?(e=(s+e)%16|0,s=Math.floor(s/16)):(e=(t+e)%16|0,t=Math.floor(t/16)),(r=="x"?e:e&7|8).toString(16)})}function n(){return typeof window<"u"}var d="x-remote-storage-instance-id",x="x-remote-storage-user-id";var i="/entities/",o=class{constructor({serverAddress:t,userId:r,instanceId:e}){this.serverAddress=t,this.instanceId=e??"default",this.userId=r??this.getUserId()}async getItem(t){let r=await this.call("GET",`${i}${t}`,null);if(r.status===404)return null;let e=await r.text();return e.startsWith("{")?JSON.parse(e):e==="true"?!0:e==="false"?!1:isNaN(Number(e))?e:Number(e)}async setItem(t,r){await this.call("PUT",`${i}${t}`,r)}async removeItem(t){await this.call("DELETE",`${i}${t}`,null)}async call(t,r,e){return u(new URL(r,this.serverAddress).toString(),{method:t,headers:{"Content-Type":"application/json",[d]:this.instanceId,[x]:this.userId},body:e?JSON.stringify(e):void 0})}getUserId(){let t="rs-user-id";if(n()&&window.localStorage.getItem(t))return window.localStorage.getItem(t);let r=a();return n()&&window.localStorage.setItem(t,r),r}};export{d as HEADER_REMOTE_STORAGE_INSTANCE_ID,x as HEADER_REMOTE_STORAGE_USER_ID,o as RemoteStorage};
//# sourceMappingURL=index.js.map
{
"name": "remote-storage",
"version": "0.0.9",
"version": "1.0.0",
"description": "remoteStorage is a simple library that combines the localStorage API with a remote server to persist data across browsers and devices.",

@@ -5,0 +5,0 @@ "type": "module",

@@ -110,2 +110,2 @@ [![npm version](https://img.shields.io/npm/v/remote-storage)](https://www.npmjs.com/package/global-storage)

Yes, but that's why you should use a non-iterable UUID for your user IDs. This makes it impossible for users to guess other user IDs and access their data unless they know the user ID.
Yes. For this reason, we recommend using a non-iterable UUID for your user IDs. This makes it nearly impossible for users to guess other user IDs and access their data unless they know the user ID.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc