
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
ngrx-correlation-id
Advanced tools
A ngrx store library to track an asynchronous activity such as a http request, a ngrx effect or anything else.
ngrx/store@13
ngrx/store@12
ngrx/store@11
ngrx/store@10
ngrx/store@9
ngrx/store@8
ngrx/store@7
ngrx/store@6
Please check source code
Import NgrxCorrelationIdModule
in the same module where you import StoreModule.forRoot
.
import {NgrxCorrelationIdModule} from 'ngrx-correlation-id';
@NgModule({
imports: [
StoreModule.forRoot(/* ... */),
NgrxCorrelationIdModule, // <- import it here
],
})
export class AppModule {}
Add cid: string
to props of an action you want to track.
export const loadUsers = createAction(
'[User] Load Users',
props<{cid: string}>(), // <- correlation id
);
Wrap an effect pipe with cidTask
.
The first argument is a cid
of the current task.
The second argument is a stream that should be tracked.
Optionally you can dispatch cidPayload
action with a custom payload.
In this case we want our payload to be an array of ids of users.
import {cidPayload, cidTask} from 'ngrx-correlation-id';
@Injectable()
export class UsersEffects {
@Effect()
public readonly loadUsers$ = this.actions$.pipe(
ofType(loadUsers),
switchMap(({cid}) => cidTask(cid, this.http.get<Array<User>>('v2/api/users').pipe(
switchMap(users => of(
upsertUsers({items: users}),
cidPayload({cid, payload: users.map(user => user.id)}),
)),
))),
);
constructor(
protected readonly actions$: Actions,
private readonly http: HttpClient,
) {}
}
Update a component to use cid
and all the features of the lib.
import {cidRemove, CidTask, cidWait, selectCid} from 'ngrx-correlation-id';
export class EntityComponent implements OnInit, OnDestroy {
public readonly users$: Observable<Array<User>>;
// set here an unique value to distinguish this task from others.
private readonly cid: string = `randomString`;
constructor(private readonly store: Store) {
// selecting the related task that belongs to cid.
this.users$ = this.store.select<CidTask<Array<string>>>(selectCid, this.cid).pipe(
// doesn't emit until the task isn't completed
cidWait(), // waits until the task starts, then waits until the task ends and the task.
map(task => task.payload),
withLatestFrom(this.store.select(selectUsers)),
map(([ids, users]) => users && users.filter(user => ids.indexOf(user.id) !== -1) || []),
);
}
public ngOnInit(): void {
// dispatching an action to load users.
this.store.dispatch(loadUsers({cid: this.cid}));
}
public ngOnDestroy(): void {
// clearing payload and selector
this.store.dispatch(cidRemove({cid: this.cid}));
selectCid.release();
}
}
FAQs
NGRX Store feature to track tasks via correlation id
The npm package ngrx-correlation-id receives a total of 0 weekly downloads. As such, ngrx-correlation-id popularity was classified as not popular.
We found that ngrx-correlation-id 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
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.