
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
import * as bcrypt from 'bcrypt-nodejs';
import {
getTSGooseModel,
TSGoose,
TSGooseDocument,
TSGooseDocumentQuery,
TSGooseHook,
TSGooseHookType,
TSGooseMethod,
TSGooseModel,
TSGooseProp,
TSGooseQueryHelper,
TSGooseSchemaOptions
} from 'tsgoose';
export class UserComment extends TSGoose {
@TSGooseProp({
default: Date.now
})
date?: Date;
@TSGooseProp()
message: string;
}
export class Group extends TSGoose {
@TSGooseProp()
title: string;
@TSGooseProp({
arrayType: String
})
roles: string[];
}
export interface IExtraInfo {
bestFriendName: string;
}
@TSGooseSchemaOptions({})
export class User extends TSGoose {
@TSGooseProp({
unique: true
})
email: string;
@TSGooseProp()
firstName: string;
@TSGooseProp()
lastName: string;
@TSGooseProp()
password?: string;
@TSGooseProp({
default: 1
})
loginCount: number;
@TSGooseProp()
get fullName(): string {
return `${this.firstName} ${this.lastName}`;
}
@TSGooseProp({
asRef: true
})
group: Group;
@TSGooseProp({
arrayType: UserComment
})
comments: UserComment[];
@TSGooseProp()
extraInfo: IExtraInfo;
@TSGooseMethod({isStatic: true})
method() {
console.log('static');
}
@TSGooseMethod()
matchPassword(candidatePassword: string): Promise<boolean> {
return new Promise((resolve) => {
bcrypt.compare(String(candidatePassword), this.password, (err, isMatch) => {
if (err || !isMatch) {
return resolve(false);
}
resolve(true);
});
});
}
@TSGooseHook({
type: TSGooseHookType.Pre,
name: 'save'
})
//tslint:disable-next-line
private preSave(next) {
const user: UserDocument = this as any;
if (!user.isModified('password')) {
return next();
}
bcrypt.genSalt(10, (err, salt) => {
if (err) {
return next(err);
}
bcrypt.hash(String(user.password), salt, null, (err, hash) => {
if (err) {
return next(err);
}
user.password = hash;
next();
});
});
}
@TSGooseQueryHelper({name: 'byEmail'})
private queryHelperFindByEmail(email: string) {
const query: UserDocumentQuery = this as any;
return query.find({email});
}
}
export type UserDocument = TSGooseDocument<User>;
export type UserRepository = TSGooseModel<User>;
export type UserDocumentQuery = TSGooseDocumentQuery<User>;
export type GroupDocument = TSGooseDocument<Group>;
export type GroupRepository = TSGooseModel<Group>;
export type GroupDocumentQuery = TSGooseDocumentQuery<Group>;
const userModel: UserRepository = getTSGooseModel<User>(User);
const groupModel: GroupRepository = getTSGooseModel<Group>(Group);
(async function() {
const group = new groupModel();
group.title = 'My group';
group.roles = ['admin', 'root', 'god'];
await group.save();
const user = new userModel({
firstName: 'Roman',
lastName: 'R'
});
user.email = 'myemail@domain.com';
user.password = 'mypasss';
user.group = group;
user.comments = [{message: 'Hello world'}];
user.extraInfo = {
bestFriendName: 'You are'
};
await user.save();
console.log('wehhea');
})();
FAQs
TypeScript decorators for Mongoose
The npm package tsgoose receives a total of 4 weekly downloads. As such, tsgoose popularity was classified as not popular.
We found that tsgoose 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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.