
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@dhis2/app-service-datastore
Advanced tools
> **WARNING**: THIS SERVICE IS STILL A WORK-IN-PROGRESS, THE API WILL PROBABLY CHANGE!
WARNING: THIS SERVICE IS STILL A WORK-IN-PROGRESS, THE API WILL PROBABLY CHANGE!
This DataStore app service support persistent user and global application settings as well as saved (and sharable) objects, such as visualization configurations.
This library was bootstrapped with DHIS2 Application Platform.
yarn add @dhis2/app-service-datastore
visualizations
) from a managed key-value store in the dataStore or userDataStoreName | Type | Required | Default | Description |
---|---|---|---|---|
namespace | Boolean | REQUIRED | The namespace to use | |
loadingComponent | React Component | null | A component to render during initial load | |
defaultGlobalSettings | Object | {} | Default settings to save in the dataStore | |
defaultUserSettings | Object | {} | Default settings to save in the userDataStore | |
encryptSettings | boolean | false | If true, encrypt all settings at rest (important if credentials could be stored) |
This library provides four main hooks:
type useSetting = (
id: string,
options?: HookOptions
) => [value: any, { set: (newValue: any) => Promise<void> }];
type useAllSettings = (
options?: HookOptions
) => [
settings: Record<string, any>,
{ set: (key: string, value: any) => Promise<void> }
];
type useSavedObject = (
id: string,
options?: HookOptions
) => [
obj: object,
{
update: (obj: object) => Promise<object>;
replace: (obj: object) => Promise<void>;
remove: () => Promise<void>;
}
];
type useSavedObjectList = (
options?: HookOptions
) => [
list: object[],
{
add: (obj: object) => Promise<void>;
update: (id: string, obj: object) => Promise<object>;
replace: (id: string, obj: object) => Promise<void>;
remove: (id: string) => Promise<void>;
}
];
Each of the hooks accepts an optional options object:
type HookOptions = {
// If true, store this setting or object in the dataStore instead of userDataStore
global: boolean;
// If true, do NOT rerender this component when the value is changed somewhere else in the application
ignoreUpdates: boolean;
};
There is one additional hook which exposes the DataStore controller for imperative access (advanced):
type useDataStore = () => DataStore;
import React from "react";
import { DataStoreProvider } from "@dhis2/app-service-datastore";
import AppRouter from "./AppRouter";
const App = () => (
<DataStoreProvider namespace="myAppName">
<AppRouter />
</DataStoreProvider>
);
export default App;
import React from "react";
import { useSetting, useAllSettings } from "@dhis2/app-service-datastore";
const MyComponent = () => {
// All data-store settings for the current user
const [allUserSettings] = useAllSettings();
// All data-store settings within the namespace
const [allGlobalSettings] = useAllSettings({ global: true });
// A specific setting for the current user
const [aUserSetting] = useSetting("id-1");
// A specific global setting
const [aGlobalSetting] = useSetting("id-1", { global: true });
return "Something";
};
export default MyComponent;
import React from "react";
import {
useSavedObject,
useSavedObjectList,
} from "@dhis2/app-service-datastore";
const MyComponent = () => {
// All saved objects for the current user
const [allUserSavedObjects] = useSavedObjectList();
// All saved objects within the namespace
const [allGlobalSavedObjects] = useSavedObjectList({ global: true });
// A specific saved object for the current user
const [aUserSavedObject] = useSavedObject("id-1");
// A specific global saved object
const [aGlobalSavedObject] = useSavedObject("id-1", { global: true });
return "Something";
};
export default MyComponent;
import React from "react";
import {
useSavedObject,
useSavedObjectList,
useSetting,
useAllSettings,
} from "@dhis2/app-service-datastore";
const MyComponent = () => {
// A setting for the current user
const [userSetting, { set }] = useSetting("id-1");
// All settings for the current user
const [userSettings, { set }] = useAllSettings();
// A saved object for the current user
const [savedObject, { update, replace, remove }] = useSavedObject("id-1");
// All saved objects for the current user
const [
allUserSavedObjects,
{ add, update, replace, remove },
] = useSavedObjectList();
return "Something";
};
The issue tracker can be found in DHIS2 JIRA under the LIBS project.
Deep links:
FAQs
> **WARNING**: THIS SERVICE IS STILL A WORK-IN-PROGRESS, THE API WILL PROBABLY CHANGE!
The npm package @dhis2/app-service-datastore receives a total of 61 weekly downloads. As such, @dhis2/app-service-datastore popularity was classified as not popular.
We found that @dhis2/app-service-datastore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.