@verdaccio/auth 7.0.0-next.4 → 7.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/LICENSE +1 -1
- package/build/auth.d.ts +7 -26
- package/build/auth.js +38 -23
- package/build/auth.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +12 -0
- package/build/index.js.map +1 -1
- package/build/signature-legacy.d.ts +5 -0
- package/build/signature-legacy.js +60 -0
- package/build/signature-legacy.js.map +1 -0
- package/build/signature.d.ts +4 -0
- package/build/signature.js +60 -0
- package/build/signature.js.map +1 -0
- package/build/types.d.ts +34 -0
- package/build/types.js +13 -0
- package/build/types.js.map +1 -0
- package/build/utils.d.ts +5 -15
- package/build/utils.js +18 -7
- package/build/utils.js.map +1 -1
- package/package.json +12 -10
- package/src/auth.ts +62 -50
- package/src/index.ts +1 -0
- package/src/signature-legacy.ts +66 -0
- package/src/signature.ts +66 -0
- package/src/types.ts +46 -0
- package/src/utils.ts +37 -31
- package/test/auth.spec.ts +561 -40
- package/test/helper/plugin.ts +8 -0
- package/test/partials/plugin/verdaccio-access-ok/access.js +9 -0
- package/test/partials/plugin/verdaccio-access-ok/package.json +5 -0
- package/test/partials/plugin/verdaccio-adduser/adduser.js +25 -0
- package/test/partials/plugin/verdaccio-adduser/package.json +5 -0
- package/test/partials/plugin/verdaccio-adduser-legacy/adduser.js +25 -0
- package/test/partials/plugin/verdaccio-adduser-legacy/package.json +5 -0
- package/test/partials/plugin/verdaccio-change-password/change.js +32 -0
- package/test/partials/plugin/verdaccio-change-password/package.json +5 -0
- package/test/partials/plugin/verdaccio-fail/fail.js +3 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = function () {
|
|
2
|
+
return {
|
|
3
|
+
authenticate(user, pass, callback) {
|
|
4
|
+
// https://verdaccio.org/docs/en/dev-plugins#onsuccess
|
|
5
|
+
// this is a successful login and return a simple group
|
|
6
|
+
callback(null, ['test']);
|
|
7
|
+
},
|
|
8
|
+
add_user(user, password, cb) {
|
|
9
|
+
if (user === 'fail') {
|
|
10
|
+
return cb(Error('bad username'));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (user === 'password') {
|
|
14
|
+
return cb(Error('bad password'));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (user === 'skip') {
|
|
18
|
+
// if wants to the next plugin
|
|
19
|
+
return cb(null, false);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
cb(null, true);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module.exports = function () {
|
|
2
|
+
return {
|
|
3
|
+
users: [],
|
|
4
|
+
authenticate(user, pass, callback) {
|
|
5
|
+
// https://verdaccio.org/docs/en/dev-plugins#onsuccess
|
|
6
|
+
// this is a successful login and return a simple group
|
|
7
|
+
callback(null, ['test']);
|
|
8
|
+
},
|
|
9
|
+
changePassword(user, password, newPassword, cb) {
|
|
10
|
+
if (password === newPassword) {
|
|
11
|
+
return cb(Error('error password equal'));
|
|
12
|
+
}
|
|
13
|
+
return cb(null, true);
|
|
14
|
+
},
|
|
15
|
+
adduser(user, password, cb) {
|
|
16
|
+
if (user === 'fail') {
|
|
17
|
+
return cb(Error('bad username'));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (user === 'password') {
|
|
21
|
+
return cb(Error('bad password'));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (user === 'skip') {
|
|
25
|
+
// if wants to the next plugin
|
|
26
|
+
return cb(null, false);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
cb(null, true);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|