-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjwt.js
94 lines (67 loc) · 2.07 KB
/
jwt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import Joi from "joi";
const UserSchema = Joi.object({
first_name: Joi.string().required().min(6),
last_name: Joi.string().required(),
email: Joi.string().email().required().regex(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/),
password: Joi.string().required().min(6),
phone_number: Joi.string().required()
});
const result = UserSchema.validate({
first_name: 'Bosdasd',
last_name: 'Bogdan',
email: '[email protected]',
password: '',
phone_number: '+380937777777'
});
console.log(result);
// class ClassWithPrivateField {
// #privateField;
// constructor() {
// this.#privateField = 42;
// }
// }
// class SubClass extends ClassWithPrivateField {
// #subPrivateField = 2211;
// constructor() {
// super();
// this.#subPrivateField = 23;
// console.log(this.#subPrivateField);
// }
// changer() {
// this.#subPrivateField = 235;
// console.log(this.#subPrivateField);
// }
// }
// const sub = new SubClass();
// sub.changer();
// // console.log(sub.#subPrivateField);
// // SubClass {#privateField: 42, #subPrivateField: 23}
// // const bool = true;
// // function ex(a, b) {
// // console.log(a, b);
// // // return a + b;
// // }
// // const obj = {};
// // const a = obj.a?.b;
// // console.log(a);
// // console.log(obj.a);
// // console.log(obj.a?.b);
// // a && console.log(ex(1, 2));
// // if (bool && ex(1, 3)) console.log("Expression evaluated to true");
// // bool && ex(2, 4);
// // import jwt from 'jsonwebtoken';
// // const obj = {
// // _id: 234523452345
// // };
// // const token = jwt.sign(obj, 'shhhhh', {
// // expiresIn: '1h',
// // algorithm: 'HS256'
// // });
// // // log to console the token
// // console.log('token: ', token);
// // // decode the token
// // const decoded = jwt.verify(token, 'shhhhh', {
// // algorithms: ['HS256'],
// // });
// // // log to console the decoded token
// // console.log('decoded: ', decoded);