
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
redline-mobx
Advanced tools
- `4.0.1` - Используется url-join для конкатенации урлов и `endpoint` может больше на заканчиваться обязательно на `/` - `4.0.0` - Теперь все методы у моделей и хранилищ выкидывают ошибки, а не проглатывают их
4.0.1
endpoint
может больше на заканчиваться обязательно на /
4.0.0
Для работы с redline-mobx
вам надо установить следующие пакеты:
mobx
mobx-state-tree
@nestjsx/crud-request
RedlineStores
Аггрегатор всех хранилищ в вашем проекте, схема работы выглядит следующим образом:
Вы создаете модели
Создаете хранилища с помощью createDetailStore
или createListStore
(не обязательно)
Создаете аггрегатор хранилищ
import { RedlineStores } from "redline-mobx";
import { SomeStore } from "./stores";
const stores = new RedlineStores(logger, axios, snapshots);
stores.add({
type: SomeStore,
name: "some_store",
});
RedlineStores.add({name: string, snapshots: {}, type, additional_envs })
- метод для добавления новых хранилищRedlineStores.getStore(name: string)
- найти хранилище по его имениRedlineStores.getStores()
- получить все сторыRedlineStores.toJS()
- Вернуть содержимое(сторы) как js-object
RedlineStores.toJSON()
- Вернуть содержимое как json-string
Создается тип для модели, надо это потому, что сейчас схема такая что у модели есть дополнительные методы:
some_model_instance.delete()
some_model_instance.update(values: any)
Для того чтобы создать новую модель надо сделать что-то такое:
import { createModel } from "redline-mobx";
import { types } from "mobx-state-tree";
PostModel = createModel({
name: "PostModel",
type: types.model({
title: types.string,
author: types.string,
}),
endpoint: "/api/posts/",
});
модели расширяют стандартную модель BaseModel
имеющую следующие поля(она примитивная):
id
created_at
updated_at
Создается тип для хранения одной записи какого-то типа.
const PageStore = createDetailStore({
type: PageModel,
endpoint: urls.PAGES_ENDPOINT,
name: "PageStore",
});
DetailStore.reset()
- Сбросить состояниеDetailStore.getOne(id_slug: string, {qparams?: CreateQueryParams, axios_params?: AxiosRequestConfig })
- Сделать запрос на бэкDetailStore.create(values: any)
- Отправляет запрос на создание новой записи на бэк и из того что бэк вернет попытается получить запись(item
)Создается тип для хранения списка записей
const PagesStore = createListStore({
type: PageModel,
endpoint: urls.PAGES_ENDPOINT,
name: "PagesStore",
mixin_types: [SeoBase],
});
ListStore.reset()
- Сбросить состояниеListStore.getList({qparams?: CreateQueryParams, axios_params?: AxiosRequestConfig, loadmore?: boolean })
- Сделать запрос на бэкПочти бесполезная функция, но всяго удобнее чем каждый раз писать обращение к axios
из контекста и.т.п
FormStore.sendOrder(data, ...)
- Отправить форму с предоставленными данными(data
)Статусы меняются в
sending
|error
|ready
ВАЖНО ошибки при запросе прокидываются выше.
const OrderForm = createFormStore({
name: "OrderForm",
endpoint: "api/forms/order_form",
});
const order_form = OrderForm.create();
order_form.sendOrder({
username: "vl",
product_id: 11,
});
Создает стору для авторизации, ожидает в ответ от сервера, при успешном логине токен, который будет сохранен в Cookies.
const UserModel = types.model("UserModel", {
id: types.maybeNull(types.number),
email: types.maybeNull(types.string),
password: types.maybeNull(types.string),
});
const AuthStore = createAuthStore({
type: UserModel,
name: "AuthStore",
me_endpoint: urls.ME_ENDPOINT, // URL для получения самого пользователя
login_endpoint: urls.LOGIN_ENDPOINT, // URL для логина
});
AuthStore.getMe();
AuthStore.user; // User object
AuthStore.getMe()
- Получит пользователя от сервера и сохранит его в поле user
AuthStore.login(credentials)
- Делает запрос для осуществления логина, credentials
передаются как json в теле POST-запроса на login_endpoint
. Ожидается, что сервер вернет token
, который будет сохранен в куки.AuthStore.logout()
- Удалит запис в куках и почистит поле user
в самом хранилищеAuthStore.setUser()
- Установить объект пользователя или обновить данные о немAuthStore.resetUser()
- Удалить текущего юзера (AuthStore.user
)AuthStore.setToken()
- Установить токен в кукиAuthStore.resetToken()
- Удалить токен из кукAuthStore.isAuthenticated
- Геттер который ожидает статус сторы как is_ready
и проверяет наличие информации о пользователе в поле user
// ....
if (auth_store.isAuthenticated) {
console.log("Я авторизирован!");
}
// ....
FAQs
- `4.0.1` - Используется url-join для конкатенации урлов и `endpoint` может больше на заканчиваться обязательно на `/` - `4.0.0` - Теперь все методы у моделей и хранилищ выкидывают ошибки, а не проглатывают их
We found that redline-mobx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.