@ttoss/auth-core 0.4.12 → 0.4.14
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/dist/AmazonCognito/index.cjs +11 -0
- package/dist/AmazonCognito/index.d.cts +4 -2
- package/dist/AmazonCognito/index.d.mts +4 -0
- package/dist/{esm/AmazonCognito/index.js → AmazonCognito/index.mjs} +0 -3
- package/dist/index.cjs +71 -0
- package/dist/index.d.cts +6 -3
- package/dist/{index.d.ts → index.d.mts} +6 -3
- package/dist/index.mjs +37 -0
- package/package.json +10 -10
- package/dist/AmazonCognito/index.d.ts +0 -2
- package/dist/AmazonCognito/index.js +0 -37
- package/dist/esm/chunk-V4MHYKRI.js +0 -7
- package/dist/esm/index.js +0 -41
- package/dist/index.js +0 -95
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
3
|
+
value: 'Module'
|
|
4
|
+
});
|
|
5
|
+
let aws_jwt_verify = require("aws-jwt-verify");
|
|
6
|
+
Object.defineProperty(exports, 'CognitoJwtVerifier', {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return aws_jwt_verify.CognitoJwtVerifier;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
import { CognitoJwtVerifier } from "aws-jwt-verify";
|
|
3
|
+
import { CognitoJwtPayload } from "aws-jwt-verify/jwt-model";
|
|
4
|
+
export { type CognitoJwtPayload, CognitoJwtVerifier };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
3
|
+
value: 'Module'
|
|
4
|
+
});
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
var __create = Object.create;
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: (k => from[k]).bind(null, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
27
|
+
value: mod,
|
|
28
|
+
enumerable: true
|
|
29
|
+
}) : target, mod));
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
let node_crypto = require("node:crypto");
|
|
33
|
+
node_crypto = __toESM(node_crypto, 1);
|
|
34
|
+
|
|
35
|
+
//#region src/encodeDecode.ts
|
|
36
|
+
const encode = obj => {
|
|
37
|
+
return Buffer.from(JSON.stringify(obj)).toString("base64");
|
|
38
|
+
};
|
|
39
|
+
const decode = encoded => {
|
|
40
|
+
return JSON.parse(Buffer.from(encoded, "base64").toString("utf8"));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/hash.ts
|
|
45
|
+
const ITERATIONS = 1e3;
|
|
46
|
+
const KEY_LENGTH = 64;
|
|
47
|
+
const DIGEST = "sha256";
|
|
48
|
+
const hashPassword = plainPassword => {
|
|
49
|
+
const salt = node_crypto.default.randomBytes(16).toString("hex");
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
node_crypto.default.pbkdf2(plainPassword, salt, ITERATIONS, KEY_LENGTH, DIGEST, (err, derivedKey) => {
|
|
52
|
+
if (err) reject(err);
|
|
53
|
+
resolve(`${salt}:${derivedKey.toString("hex")}`);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const comparePassword = (plainPassword, storedHash) => {
|
|
58
|
+
const [salt, hash] = storedHash.split(":");
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
node_crypto.default.pbkdf2(plainPassword, salt, ITERATIONS, KEY_LENGTH, DIGEST, (err, derivedKey) => {
|
|
61
|
+
if (err) reject(err);
|
|
62
|
+
resolve(hash === derivedKey.toString("hex"));
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
exports.comparePassword = comparePassword;
|
|
69
|
+
exports.decode = decode;
|
|
70
|
+
exports.encode = encode;
|
|
71
|
+
exports.hashPassword = hashPassword;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/encodeDecode.d.ts
|
|
1
3
|
declare const encode: (obj: unknown) => string;
|
|
2
4
|
declare const decode: (encoded: string) => any;
|
|
3
|
-
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/hash.d.ts
|
|
4
7
|
declare const hashPassword: (plainPassword: string) => Promise<string>;
|
|
5
8
|
declare const comparePassword: (plainPassword: string, storedHash: string) => Promise<boolean>;
|
|
6
|
-
|
|
7
|
-
export { comparePassword, decode, encode, hashPassword };
|
|
9
|
+
//#endregion
|
|
10
|
+
export { comparePassword, decode, encode, hashPassword };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/encodeDecode.d.ts
|
|
1
3
|
declare const encode: (obj: unknown) => string;
|
|
2
4
|
declare const decode: (encoded: string) => any;
|
|
3
|
-
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/hash.d.ts
|
|
4
7
|
declare const hashPassword: (plainPassword: string) => Promise<string>;
|
|
5
8
|
declare const comparePassword: (plainPassword: string, storedHash: string) => Promise<boolean>;
|
|
6
|
-
|
|
7
|
-
export { comparePassword, decode, encode, hashPassword };
|
|
9
|
+
//#endregion
|
|
10
|
+
export { comparePassword, decode, encode, hashPassword };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
|
|
4
|
+
//#region src/encodeDecode.ts
|
|
5
|
+
const encode = obj => {
|
|
6
|
+
return Buffer.from(JSON.stringify(obj)).toString("base64");
|
|
7
|
+
};
|
|
8
|
+
const decode = encoded => {
|
|
9
|
+
return JSON.parse(Buffer.from(encoded, "base64").toString("utf8"));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/hash.ts
|
|
14
|
+
const ITERATIONS = 1e3;
|
|
15
|
+
const KEY_LENGTH = 64;
|
|
16
|
+
const DIGEST = "sha256";
|
|
17
|
+
const hashPassword = plainPassword => {
|
|
18
|
+
const salt = crypto.randomBytes(16).toString("hex");
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
crypto.pbkdf2(plainPassword, salt, ITERATIONS, KEY_LENGTH, DIGEST, (err, derivedKey) => {
|
|
21
|
+
if (err) reject(err);
|
|
22
|
+
resolve(`${salt}:${derivedKey.toString("hex")}`);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const comparePassword = (plainPassword, storedHash) => {
|
|
27
|
+
const [salt, hash] = storedHash.split(":");
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
crypto.pbkdf2(plainPassword, salt, ITERATIONS, KEY_LENGTH, DIGEST, (err, derivedKey) => {
|
|
30
|
+
if (err) reject(err);
|
|
31
|
+
resolve(hash === derivedKey.toString("hex"));
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { comparePassword, decode, encode, hashPassword };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/auth-core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"description": "Core authentication library for ttoss",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"import": "./dist/
|
|
26
|
-
"require": "./dist/index.
|
|
27
|
-
"types": "./dist/index.d.
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"require": "./dist/index.cjs",
|
|
27
|
+
"types": "./dist/index.d.mts"
|
|
28
28
|
},
|
|
29
29
|
"./amazon-cognito": {
|
|
30
|
-
"import": "./dist/
|
|
31
|
-
"require": "./dist/AmazonCognito/index.
|
|
32
|
-
"types": "./dist/AmazonCognito/index.d.
|
|
30
|
+
"import": "./dist/AmazonCognito/index.mjs",
|
|
31
|
+
"require": "./dist/AmazonCognito/index.cjs",
|
|
32
|
+
"types": "./dist/AmazonCognito/index.d.mts"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"jest": "^30.3.0",
|
|
43
|
-
"
|
|
44
|
-
"@ttoss/config": "^1.37.
|
|
43
|
+
"tsdown": "^0.22.0",
|
|
44
|
+
"@ttoss/config": "^1.37.13"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public",
|
|
48
48
|
"provenance": true
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "
|
|
51
|
+
"build": "tsdown",
|
|
52
52
|
"test": "jest --projects tests/unit"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all) __defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
-
get: () => from[key],
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
24
|
-
value: true
|
|
25
|
-
}), mod);
|
|
26
|
-
|
|
27
|
-
// src/AmazonCognito/index.ts
|
|
28
|
-
var AmazonCognito_exports = {};
|
|
29
|
-
__export(AmazonCognito_exports, {
|
|
30
|
-
CognitoJwtVerifier: () => import_aws_jwt_verify.CognitoJwtVerifier
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(AmazonCognito_exports);
|
|
33
|
-
var import_aws_jwt_verify = require("aws-jwt-verify");
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
CognitoJwtVerifier
|
|
37
|
-
});
|
package/dist/esm/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { __name } from "./chunk-V4MHYKRI.js";
|
|
3
|
-
|
|
4
|
-
// src/encodeDecode.ts
|
|
5
|
-
var encode = /* @__PURE__ */__name(obj => {
|
|
6
|
-
return Buffer.from(JSON.stringify(obj)).toString("base64");
|
|
7
|
-
}, "encode");
|
|
8
|
-
var decode = /* @__PURE__ */__name(encoded => {
|
|
9
|
-
return JSON.parse(Buffer.from(encoded, "base64").toString("utf8"));
|
|
10
|
-
}, "decode");
|
|
11
|
-
|
|
12
|
-
// src/hash.ts
|
|
13
|
-
import crypto from "crypto";
|
|
14
|
-
var ITERATIONS = 1e3;
|
|
15
|
-
var KEY_LENGTH = 64;
|
|
16
|
-
var DIGEST = "sha256";
|
|
17
|
-
var hashPassword = /* @__PURE__ */__name(plainPassword => {
|
|
18
|
-
const salt = crypto.randomBytes(16).toString("hex");
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
crypto.pbkdf2(plainPassword, salt, ITERATIONS, KEY_LENGTH, DIGEST, (err, derivedKey) => {
|
|
21
|
-
if (err) {
|
|
22
|
-
reject(err);
|
|
23
|
-
}
|
|
24
|
-
const hash = derivedKey.toString("hex");
|
|
25
|
-
resolve(`${salt}:${hash}`);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}, "hashPassword");
|
|
29
|
-
var comparePassword = /* @__PURE__ */__name((plainPassword, storedHash) => {
|
|
30
|
-
const [salt, hash] = storedHash.split(":");
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
crypto.pbkdf2(plainPassword, salt, ITERATIONS, KEY_LENGTH, DIGEST, (err, derivedKey) => {
|
|
33
|
-
if (err) {
|
|
34
|
-
reject(err);
|
|
35
|
-
}
|
|
36
|
-
const hashToCompare = derivedKey.toString("hex");
|
|
37
|
-
resolve(hash === hashToCompare);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}, "comparePassword");
|
|
41
|
-
export { comparePassword, decode, encode, hashPassword };
|
package/dist/index.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
11
|
-
value,
|
|
12
|
-
configurable: true
|
|
13
|
-
});
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all) __defProp(target, name, {
|
|
16
|
-
get: all[name],
|
|
17
|
-
enumerable: true
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
23
|
-
get: () => from[key],
|
|
24
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
35
|
-
value: mod,
|
|
36
|
-
enumerable: true
|
|
37
|
-
}) : target, mod));
|
|
38
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
39
|
-
value: true
|
|
40
|
-
}), mod);
|
|
41
|
-
|
|
42
|
-
// src/index.ts
|
|
43
|
-
var index_exports = {};
|
|
44
|
-
__export(index_exports, {
|
|
45
|
-
comparePassword: () => comparePassword,
|
|
46
|
-
decode: () => decode,
|
|
47
|
-
encode: () => encode,
|
|
48
|
-
hashPassword: () => hashPassword
|
|
49
|
-
});
|
|
50
|
-
module.exports = __toCommonJS(index_exports);
|
|
51
|
-
|
|
52
|
-
// src/encodeDecode.ts
|
|
53
|
-
var encode = /* @__PURE__ */__name(obj => {
|
|
54
|
-
return Buffer.from(JSON.stringify(obj)).toString("base64");
|
|
55
|
-
}, "encode");
|
|
56
|
-
var decode = /* @__PURE__ */__name(encoded => {
|
|
57
|
-
return JSON.parse(Buffer.from(encoded, "base64").toString("utf8"));
|
|
58
|
-
}, "decode");
|
|
59
|
-
|
|
60
|
-
// src/hash.ts
|
|
61
|
-
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
62
|
-
var ITERATIONS = 1e3;
|
|
63
|
-
var KEY_LENGTH = 64;
|
|
64
|
-
var DIGEST = "sha256";
|
|
65
|
-
var hashPassword = /* @__PURE__ */__name(plainPassword => {
|
|
66
|
-
const salt = import_node_crypto.default.randomBytes(16).toString("hex");
|
|
67
|
-
return new Promise((resolve, reject) => {
|
|
68
|
-
import_node_crypto.default.pbkdf2(plainPassword, salt, ITERATIONS, KEY_LENGTH, DIGEST, (err, derivedKey) => {
|
|
69
|
-
if (err) {
|
|
70
|
-
reject(err);
|
|
71
|
-
}
|
|
72
|
-
const hash = derivedKey.toString("hex");
|
|
73
|
-
resolve(`${salt}:${hash}`);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}, "hashPassword");
|
|
77
|
-
var comparePassword = /* @__PURE__ */__name((plainPassword, storedHash) => {
|
|
78
|
-
const [salt, hash] = storedHash.split(":");
|
|
79
|
-
return new Promise((resolve, reject) => {
|
|
80
|
-
import_node_crypto.default.pbkdf2(plainPassword, salt, ITERATIONS, KEY_LENGTH, DIGEST, (err, derivedKey) => {
|
|
81
|
-
if (err) {
|
|
82
|
-
reject(err);
|
|
83
|
-
}
|
|
84
|
-
const hashToCompare = derivedKey.toString("hex");
|
|
85
|
-
resolve(hash === hashToCompare);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}, "comparePassword");
|
|
89
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
-
0 && (module.exports = {
|
|
91
|
-
comparePassword,
|
|
92
|
-
decode,
|
|
93
|
-
encode,
|
|
94
|
-
hashPassword
|
|
95
|
-
});
|