Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@aws-amplify/datastore
Advanced tools
@aws-amplify/datastore is a library that provides a programming model for leveraging shared and distributed data without writing additional code for offline and online scenarios. It is part of the AWS Amplify framework and is designed to work seamlessly with AWS AppSync for real-time and offline-first data access.
Model Definition
Defines the data model schema for the application. This is the first step in setting up DataStore, where you define the structure of your data.
const { initSchema } = require('@aws-amplify/datastore');
const { schema } = require('./schema');
const { Post } = initSchema(schema);
CRUD Operations
Provides basic CRUD (Create, Read, Update, Delete) operations for interacting with the data models. This allows developers to easily manage their data.
const { DataStore } = require('@aws-amplify/datastore');
// Create
await DataStore.save(new Post({ title: 'New Post', content: 'This is a new post' }));
// Read
const posts = await DataStore.query(Post);
// Update
const original = await DataStore.query(Post, '123');
await DataStore.save(Post.copyOf(original, updated => {
updated.title = 'Updated Title';
}));
// Delete
await DataStore.delete(Post, '123');
Real-time and Offline Sync
Enables real-time data synchronization and offline capabilities. DataStore automatically syncs data between the local store and the cloud, ensuring data consistency.
const { DataStore } = require('@aws-amplify/datastore');
DataStore.observe(Post).subscribe(msg => {
console.log(msg.model, msg.opType, msg.element);
});
Conflict Resolution
Handles conflict resolution when data changes occur both locally and in the cloud. Developers can define custom conflict resolution strategies.
const { DataStore, syncExpression } = require('@aws-amplify/datastore');
DataStore.configure({
syncExpressions: [
syncExpression(Post, () => {
return post => post.status('eq', 'published');
})
]
});
redux-persist is a library that allows you to save the Redux store in persistent storage, such as local storage. It provides offline capabilities but lacks the real-time synchronization and conflict resolution features of @aws-amplify/datastore.
Dexie is a wrapper for IndexedDB, providing a more straightforward API for managing local databases. While it offers offline storage, it does not provide built-in real-time synchronization or integration with cloud services like @aws-amplify/datastore.
PouchDB is an open-source JavaScript database that syncs with CouchDB. It offers offline-first capabilities and real-time synchronization, similar to @aws-amplify/datastore, but requires a CouchDB server for cloud synchronization.
INTERNAL USE ONLY
This package contains the AWS Amplify DataStore category and is intended for internal use only. To integrate Amplify into your app, please use aws-amplify.
Amplify DataStore provides a programming model for leveraging shared and distributed data without writing additional code for offline and online scenarios, which makes working with distributed, cross-user data just as simple as working with local-only data.
package | version | open issues | closed issues |
---|---|---|---|
@aws-amplify/datastore |
Please update these docs any time you find something that is incorrect or lacking. In particular, if a line in the docs prompts a question, take a moment to figure out the answer, then update the docs with the necessary detail.
Before you start reading through these docs, take a moment to understand how DataStore works at a high level. Additionally, we recommend first reading through docs.amplify.aws. The purpose of these docs is to dive deep into the codebase itself and understand the inner workings of DataStore for the purpose of contributing. Understanding these docs is not necessary for using DataStore. Lastly, before reading, take a look at the diagrams below.
Note: relationships with dotted lines are explained more in a separate diagram.
flowchart TD
%% API and Storage
api[[DS API]]-- observe -->storage{Storage Engine}
storage-- next -->adapter[[Adapter]]
adapter-->db[[Local DB]]
db-->api
sync[[Sync Engine*]]-.-storage
sync-.-appSync[(AppSync)]
Note: All green nodes belong to the Sync Engine.
* Merger first checks outbox
** Outbox sends outgoing messages to AppSync
flowchart TD
subgraph SyncEngine
index{index.ts}-- observe -->reach[Core reachability]
subgraph processors
mp[Mutation Processor]
sp[Subscription Processor]
syp[Sync Processor]
end
reach--next-->mp[Mutation Processor]
reach--next-->sp[Subscription Processor]
reach--next-->syp[Sync Processor]
subgraph outbox / merger
outbox[Outbox]
merger[Merger]
outbox---merger
end
end
api[DS API]-.->storage
mp-- 1. observe -->storage{Storage Engine}
storage-- 2. next -->merger[merger*]-- next -->storage
sp-- observe -->appsync[(AppSync)]
appsync-- next -->sp
syp---appsync
mp-->outbox[outbox**]
appsync<--->outbox
%% styling
classDef syncEngineClass fill:#8FB,stroke:#333,stroke-width:4px,color:#333;
class index,mp,sp,syp,merger,outbox syncEngineClass;
amplify-js/packages/datastore/src ├── authModeStrategies │ └── defaultAuthStraegy.ts │ └── index.ts │ └── multiAuthStrategy.ts ├── datastore │ └── datastore.ts # Entry point for DataStore ├── predicates │ └── index.ts │ └── sort.ts ├── ssr ├── storage # Storage Engine │ └── adapter # Platform-specific Storage Adapters │ └── getDefaultAdapter │ └── AsyncStorageAdapter.ts │ └── AsyncStorageDatabase.ts │ └── index.ts │ └── IndexedDBAdapter.ts │ └── InMemoryStore.native.ts │ └── InMemoryStore.ts │ └── storage.ts # Entry point for Storage ├── sync # Sync Engine │ └── dataStoreReachability │ └── index.native.ts │ └── index.ts │ └── processors # Sync Engine Processors │ └── mutation.ts │ └── subscription.ts │ └── sync.ts │ └── datastoreConnectivity.ts # Subscribe to reachability monitor │ └── index.ts # Entry point for Sync Engine │ └── merger.ts # doc │ └── outbox.ts # doc
FAQs
AppSyncLocal support for aws-amplify
We found that @aws-amplify/datastore demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.