Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nocobase/plugin-auth

Package Overview
Dependencies
Maintainers
1
Versions
371
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nocobase/plugin-auth - npm Package Compare versions

Comparing version 0.12.0-alpha.5 to 0.13.0-alpha.1

dist/swagger/index.d.ts

69

dist/client/index.js

@@ -57,3 +57,3 @@ (function(global, factory) {

type: "string",
title: '{{t("Name")}}',
title: '{{t("Auth UID")}}',
"x-component": "Input",

@@ -69,4 +69,5 @@ required: true

type: "string",
title: '{{t("Auth Type", {ns: "auth"})}}',
title: '{{t("Auth Type")}}',
"x-component": "Select",
dataSource: "{{ types }}",
required: true

@@ -286,2 +287,3 @@ }

authType: {
title: '{{t("Auth Type")}}',
type: "void",

@@ -293,4 +295,5 @@ "x-decorator": "Table.Column.Decorator",

type: "string",
"x-component": "CollectionField",
"x-read-pretty": true
"x-component": "Select",
"x-read-pretty": true,
enum: "{{ types }}"
}

@@ -465,2 +468,6 @@ }

});
const NAMESPACE = "auth";
function useAuthTranslation() {
return reactI18next.useTranslation(NAMESPACE);
}
const useCloseAction = () => {

@@ -500,2 +507,3 @@ const { setVisible } = client.useActionContext();

const Authenticator = () => {
const { t } = useAuthTranslation();
const [types, setTypes] = require$$0.useState([]);

@@ -508,5 +516,5 @@ const api = client.useAPIClient();

return types2.map((type) => ({
key: type,
label: type,
value: type
key: type.name,
label: t(type.title || type.name),
value: type.name
}));

@@ -525,3 +533,3 @@ }),

components: { AddNew, Options: Options$1 },
scope: { types, useValuesFromOptions, useCanNotDelete }
scope: { types, useValuesFromOptions, useCanNotDelete, t }
}

@@ -535,9 +543,19 @@ ) }) });

properties: {
email: {
account: {
type: "string",
required: true,
"x-component": "Input",
"x-validator": "email",
"x-validator": `{{(value) => {
if (!value) {
return t("Please enter your username or email");
}
if (value.includes('@')) {
if (!/^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$/.test(value)) {
return t("Please enter a valid email");
}
} else {
return /^[^@.<>"'/]{2,16}$/.test(value) || t("Please enter a valid username");
}
}}}`,
"x-decorator": "FormItem",
"x-component-props": { placeholder: '{{t("Email")}}', style: {} }
"x-component-props": { placeholder: '{{t("Username/Email")}}', style: {} }
},

@@ -581,2 +599,3 @@ password: {

const SigninPage = (props) => {
const { t } = useAuthTranslation();
const authenticator = props.authenticator;

@@ -590,3 +609,3 @@ const { authType, name, options } = authenticator;

};
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponent, { schema: passwordForm, scope: { useBasicSignIn, allowSignUp, signupLink } });
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponent, { schema: passwordForm, scope: { useBasicSignIn, allowSignUp, signupLink, t } });
};

@@ -599,9 +618,9 @@ const presetAuthType = "Email/Password";

properties: {
email: {
username: {
type: "string",
required: true,
"x-component": "Input",
"x-validator": "email",
"x-validator": { username: true },
"x-decorator": "FormItem",
"x-component-props": { placeholder: '{{t("Email")}}', style: {} }
"x-component-props": { placeholder: '{{t("Username")}}', style: {} }
},

@@ -675,11 +694,8 @@ password: {

const SignupPage = (props) => {
const { t } = useAuthTranslation();
const useBasicSignup = () => {
return client.useSignup({ authenticator: props.name });
};
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponent, { schema: signupPageSchema, scope: { useBasicSignup } });
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponent, { schema: signupPageSchema, scope: { useBasicSignup, t } });
};
const NAMESPACE = "auth";
function useAuthTranslation() {
return reactI18next.useTranslation(NAMESPACE);
}
const Options = () => {

@@ -691,2 +707,3 @@ const { t } = useAuthTranslation();

scope: { t },
components: { Alert: antd.Alert },
schema: {

@@ -708,2 +725,10 @@ type: "object",

}
},
notice: {
type: "void",
"x-component": "Alert",
"x-component-props": {
showIcon: true,
message: '{{t("The authentication allows users to sign in via username or email.")}}'
}
}

@@ -732,3 +757,3 @@ }

},
children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.OptionsComponentProvider, { authType: presetAuthType, component: Options, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SigninPageProvider, { authType: presetAuthType, tabTitle: t("Sign in via email"), component: SigninPage, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SignupPageProvider, { authType: presetAuthType, component: SignupPage, children: props.children }) }) })
children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.OptionsComponentProvider, { authType: presetAuthType, component: Options, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SigninPageProvider, { authType: presetAuthType, tabTitle: t("Sign in via password"), component: SigninPage, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SignupPageProvider, { authType: presetAuthType, component: SignupPage, children: props.children }) }) })
}

@@ -735,0 +760,0 @@ );

@@ -6,6 +6,6 @@ declare const locale: {

'Sign in via email': string;
'Sign in via password': string;
'Not allowed to sign up': string;
'Allow to sign up': string;
'The email is incorrect, please re-enter': string;
'Please fill in your email address': string;
'The username or email is incorrect, please re-enter': string;
'The password is incorrect, please re-enter': string;

@@ -16,3 +16,11 @@ 'Not a valid cellphone number, please re-enter': string;

'Please keep and enable at least one authenticator': string;
'Allow to sign in with': string;
'Please enter a valid username': string;
'Please enter a valid email': string;
'Please enter your username or email': string;
SMS: string;
'Username/Email': string;
'Auth UID': string;
'The authentication allows users to sign in via username or email.': string;
};
export default locale;

@@ -8,6 +8,6 @@ 'use strict';

"Sign in via email": "\u90AE\u7BB1\u767B\u5F55",
"Sign in via password": "\u5BC6\u7801\u767B\u5F55",
"Not allowed to sign up": "\u7981\u6B62\u6CE8\u518C",
"Allow to sign up": "\u5141\u8BB8\u6CE8\u518C",
"The email is incorrect, please re-enter": "\u90AE\u7BB1\u6709\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",
"Please fill in your email address": "\u8BF7\u586B\u5199\u90AE\u7BB1",
"The username or email is incorrect, please re-enter": "\u7528\u6237\u540D\u6216\u90AE\u7BB1\u6709\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",
"The password is incorrect, please re-enter": "\u5BC6\u7801\u6709\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",

@@ -17,3 +17,11 @@ "Not a valid cellphone number, please re-enter": "\u4E0D\u662F\u6709\u6548\u7684\u624B\u673A\u53F7\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",

"The phone number is not registered, please register first": "\u624B\u673A\u53F7\u672A\u6CE8\u518C\uFF0C\u8BF7\u5148\u6CE8\u518C",
"Please keep and enable at least one authenticator": "\u8BF7\u81F3\u5C11\u4FDD\u7559\u5E76\u542F\u7528\u4E00\u4E2A\u8BA4\u8BC1\u5668"
"Please keep and enable at least one authenticator": "\u8BF7\u81F3\u5C11\u4FDD\u7559\u5E76\u542F\u7528\u4E00\u4E2A\u8BA4\u8BC1\u5668",
"Allow to sign in with": "\u5141\u8BB8\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u767B\u5F55",
"Please enter a valid username": "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u7528\u6237\u540D",
"Please enter a valid email": "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1",
"Please enter your username or email": "\u8BF7\u8F93\u5165\u7528\u6237\u540D\u6216\u90AE\u7BB1",
SMS: "\u77ED\u4FE1",
"Username/Email": "\u7528\u6237\u540D/\u90AE\u7BB1",
"Auth UID": "\u8BA4\u8BC1\u6807\u8BC6",
"The authentication allows users to sign in via username or email.": "\u8BE5\u8BA4\u8BC1\u65B9\u5F0F\u652F\u6301\u7528\u6237\u901A\u8FC7\u7528\u6237\u540D\u6216\u90AE\u7BB1\u767B\u5F55\u3002"
};

@@ -20,0 +28,0 @@ var zh_CN_default = locale;

@@ -1,1 +0,1 @@

{"name":"cron","description":"Cron jobs for your node","version":"2.3.1","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage"},"dependencies":{"luxon":"^3.2.1"},"devDependencies":{"chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","jest":"~29.5.x","prettier":"~2.8.x","sinon":"^15.0.x"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2023-08-18T08:35:43.796Z"}
{"name":"cron","description":"Cron jobs for your node","version":"2.3.1","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage"},"dependencies":{"luxon":"^3.2.1"},"devDependencies":{"chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","jest":"~29.5.x","prettier":"~2.8.x","sinon":"^15.0.x"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2023-08-24T10:42:53.408Z"}

@@ -18,16 +18,25 @@ 'use strict';

const ctx = this.ctx;
const { uniqueField = "email", values } = ctx.action.params;
if (!values[uniqueField]) {
ctx.throw(400, ctx.t("Please fill in your email address", { ns: preset.namespace }));
const {
values: {
account,
// Username or email
email,
// Old parameter, compatible with old api
password
}
} = ctx.action.params;
if (!account && !email) {
ctx.throw(400, ctx.t("Please enter your username or email", { ns: preset.namespace }));
}
const filter = email ? { email } : {
$or: [{ username: account }, { email: account }]
};
const user = await this.userRepository.findOne({
where: {
[uniqueField]: values[uniqueField]
}
filter
});
if (!user) {
ctx.throw(401, ctx.t("The email is incorrect, please re-enter", { ns: preset.namespace }));
ctx.throw(401, ctx.t("The username or email is incorrect, please re-enter", { ns: preset.namespace }));
}
const field = this.userCollection.getField("password");
const valid = await field.verify(values.password, user.password);
const valid = await field.verify(password, user.password);
if (!valid) {

@@ -47,2 +56,6 @@ ctx.throw(401, ctx.t("The password is incorrect, please re-enter", { ns: preset.namespace }));

const { values } = ctx.action.params;
const { username } = values;
if (!/^[^@.<>"'/]{2,16}$/.test(username)) {
ctx.throw(400, ctx.t("Please enter a valid username", { ns: preset.namespace }));
}
const user = await User.create({ values });

@@ -49,0 +62,0 @@ return user;

declare const _default: {
'The email is incorrect, please re-enter': string;
'Please fill in your email address': string;
'The username or email is incorrect, please re-enter': string;
'The password is incorrect, please re-enter': string;

@@ -9,3 +8,5 @@ 'Not a valid cellphone number, please re-enter': string;

'Please keep and enable at least one authenticator': string;
'Please enter your username or email': string;
'Please enter a valid username': string;
};
export default _default;
'use strict';
var zh_CN_default = {
"The email is incorrect, please re-enter": "\u90AE\u7BB1\u6709\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",
"Please fill in your email address": "\u8BF7\u586B\u5199\u90AE\u7BB1",
"The username or email is incorrect, please re-enter": "\u7528\u6237\u540D\u6216\u90AE\u7BB1\u6709\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",
"The password is incorrect, please re-enter": "\u5BC6\u7801\u6709\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",

@@ -10,5 +9,7 @@ "Not a valid cellphone number, please re-enter": "\u4E0D\u662F\u6709\u6548\u7684\u624B\u673A\u53F7\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",

"The phone number is not registered, please register first": "\u624B\u673A\u53F7\u672A\u6CE8\u518C\uFF0C\u8BF7\u5148\u6CE8\u518C",
"Please keep and enable at least one authenticator": "\u8BF7\u81F3\u5C11\u4FDD\u7559\u5E76\u542F\u7528\u4E00\u4E2A\u8BA4\u8BC1\u5668"
"Please keep and enable at least one authenticator": "\u8BF7\u81F3\u5C11\u4FDD\u7559\u5E76\u542F\u7528\u4E00\u4E2A\u8BA4\u8BC1\u5668",
"Please enter your username or email": "\u8BF7\u8F93\u5165\u7528\u6237\u540D\u6216\u90AE\u7BB1",
"Please enter a valid username": "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u7528\u6237\u540D"
};
module.exports = zh_CN_default;

@@ -17,3 +17,3 @@ 'use strict';

authType: preset.presetAuthType,
description: "Sign in with email and password.",
description: "Sign in with username/email.",
enabled: true

@@ -20,0 +20,0 @@ }

@@ -51,3 +51,4 @@ 'use strict';

this.app.authManager.registerTypes(preset.presetAuthType, {
auth: basicAuth.BasicAuth
auth: basicAuth.BasicAuth,
title: "Password"
});

@@ -78,3 +79,3 @@ Object.entries(authActions__default.default).forEach(

authType: preset.presetAuthType,
description: "Sign in with email and password.",
description: "Sign in with username/email.",
enabled: true,

@@ -81,0 +82,0 @@ options: {

@@ -11,6 +11,5 @@ import { ITokenBlacklistService } from '@nocobase/auth';

get app(): import("@nocobase/server").default<import("@nocobase/server").DefaultState, import("@nocobase/server").DefaultContext>;
createCronJob(): CronJob;
has(token: string): Promise<boolean>;
add(values: any): Promise<[import("@nocobase/database").Model<any, any>, boolean]>;
deleteByExpiration(): Promise<any>;
deleteExpiredTokens(): Promise<any>;
}
'use strict';
var cron = require('cron');
class TokenBlacklistService {

@@ -9,3 +7,2 @@ constructor(plugin) {

this.repo = plugin.db.getRepository("tokenBlacklist");
this.cronJob = this.createCronJob();
}

@@ -17,22 +14,2 @@ repo;

}
createCronJob() {
const cronJob = new cron.CronJob(
// every day at 03:00
"0 3 * * *",
//
async () => {
this.app.logger.info(`${this.plugin.name}: Start delete expired blacklist token`);
await this.deleteByExpiration();
this.app.logger.info(`${this.plugin.name}: End delete expired blacklist token`);
},
null
);
this.app.once("beforeStart", () => {
cronJob.start();
});
this.app.once("beforeStop", () => {
cronJob.stop();
});
return cronJob;
}
async has(token) {

@@ -46,2 +23,3 @@ return !!await this.repo.findOne({

async add(values) {
await this.deleteExpiredTokens();
return this.repo.model.findOrCreate({

@@ -54,3 +32,3 @@ defaults: values,

}
async deleteByExpiration() {
async deleteExpiredTokens() {
return this.repo.destroy({

@@ -57,0 +35,0 @@ filter: {

{
"name": "@nocobase/plugin-auth",
"version": "0.12.0-alpha.5",
"version": "0.13.0-alpha.1",
"main": "./dist/server/index.js",

@@ -27,3 +27,3 @@ "devDependencies": {

"description.zh-CN": "提供基础认证功能和扩展认证器管理功能",
"gitHead": "689cc16e83361c4d0b91907e0deac30bdb907692"
"gitHead": "0ebd4e85a1b0b0d0943768ab6cb5c3d824562239"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc