@stacksjs/security 0.57.3 → 0.58.19

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/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@stacksjs/security",
3
3
  "type": "module",
4
- "version": "0.57.3",
5
- "packageManager": "pnpm@8.6.6",
4
+ "version": "0.58.19",
6
5
  "description": "The Stacks framework security.",
7
6
  "author": "Chris Breuer",
8
7
  "license": "MIT",
9
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
10
- "homepage": "https://github.com/stacksjs/stacks/tree/main/.stacks/core/security#readme",
9
+ "homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/src/security#readme",
11
10
  "repository": {
12
11
  "type": "git",
13
12
  "url": "git+https://github.com/stacksjs/stacks.git",
14
- "directory": "./.stacks/core/security"
13
+ "directory": "./storage/framework/core/src/security"
15
14
  },
16
15
  "bugs": {
17
16
  "url": "https://github.com/stacksjs/stacks/issues"
@@ -24,33 +23,43 @@
24
23
  ],
25
24
  "exports": {
26
25
  ".": {
27
- "types": "./dist/index.d.ts",
28
- "import": "./dist/index.mjs"
26
+ "bun": "./src/index.ts",
27
+ "import": "./dist/index.js"
28
+ },
29
+ "./*": {
30
+ "bun": "./src/*",
31
+ "import": "./dist/*"
29
32
  }
30
33
  },
31
- "module": "dist/index.mjs",
34
+ "module": "dist/index.js",
32
35
  "types": "dist/index.d.ts",
33
36
  "contributors": [
34
- "Chris Breuer <chris@ow3.org>"
37
+ "Chris Breuer <chris@stacksjs.org>"
35
38
  ],
36
39
  "files": [
37
- "dist",
38
- "README.md"
40
+ "README.md",
41
+ "dist"
39
42
  ],
43
+ "scripts": {
44
+ "build": "bun --bun build.ts",
45
+ "typecheck": "bun --bun tsc --noEmit",
46
+ "prepublishOnly": "bun --bun run build"
47
+ },
40
48
  "peerDependencies": {
49
+ "@stacksjs/config": "workspace:*",
50
+ "@stacksjs/types": "workspace:*",
51
+ "@stacksjs/validation": "workspace:*"
52
+ },
53
+ "dependencies": {
54
+ "@stacksjs/config": "workspace:*",
55
+ "@stacksjs/env": "workspace:*",
56
+ "@stacksjs/types": "workspace:*",
57
+ "@stacksjs/validation": "workspace:*",
41
58
  "bcryptjs": "^2.4.3",
42
- "crypto-js": "^4.1.1",
43
- "js-base64": "^3.7.5",
44
- "@stacksjs/config": "0.57.3",
45
- "@stacksjs/types": "0.57.3",
46
- "@stacksjs/validation": "0.57.3"
59
+ "crypto-js": "^4.2.0",
60
+ "js-base64": "^3.7.5"
47
61
  },
48
62
  "devDependencies": {
49
- "@stacksjs/development": "0.57.3"
50
- },
51
- "scripts": {
52
- "build": "unbuild",
53
- "dev": "unbuild --stub",
54
- "typecheck": "tsc --noEmit"
63
+ "@stacksjs/development": "workspace:*"
55
64
  }
56
- }
65
+ }
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- # MIT License
2
-
3
- Copyright (c) 2022 Open Web Foundation
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/crypt.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare function encrypt(message: string): string;
2
- declare function decrypt(encrypted: string): string;
3
- export { encrypt, decrypt };
package/dist/crypt.mjs DELETED
@@ -1,16 +0,0 @@
1
- import aes from "crypto-js/aes";
2
- import utf8 from "crypto-js/enc-utf8";
3
- import { env } from "@stacksjs/validation";
4
- function encrypt(message) {
5
- const passphrase = env.APP_KEY;
6
- if (!passphrase)
7
- throw new Error("APP_KEY is not defined");
8
- return aes.encrypt(message, passphrase).toString();
9
- }
10
- function decrypt(encrypted) {
11
- const passphrase = env.APP_KEY;
12
- if (!passphrase)
13
- throw new Error("APP_KEY is not defined");
14
- return aes.decrypt(encrypted, passphrase).toString(utf8);
15
- }
16
- export { encrypt, decrypt };
package/dist/hash.d.ts DELETED
@@ -1,8 +0,0 @@
1
- declare function make(password: string, algorithm?: string): Promise<any>;
2
- declare function verify(password: string, hash: string, algorithm?: string): Promise<any>;
3
- declare function bcryptEncode(password: string): Promise<any>;
4
- declare function bcryptVerify(password: string, hash: string): Promise<any>;
5
- declare function base64Encode(password: string): Promise<string>;
6
- declare function base64Verify(password: string, hash: string): Promise<boolean>;
7
- declare function md5Encode(password: string): Promise<any>;
8
- export { make as makeHash, verify as verifyHash, base64Encode, base64Verify, bcryptEncode, bcryptVerify, md5Encode };
package/dist/hash.mjs DELETED
@@ -1,38 +0,0 @@
1
- import bcryptjs from "bcryptjs";
2
- import { Base64 } from "js-base64";
3
- import md5 from "crypto-js/md5";
4
- import { hashing } from "@stacksjs/config";
5
- async function make(password, algorithm = "bcrypt") {
6
- if (algorithm === "bcrypt")
7
- return bcryptEncode(password);
8
- if (algorithm === "base64")
9
- return base64Encode(password);
10
- throw new Error("Unsupported algorithm");
11
- }
12
- async function verify(password, hash, algorithm = "bcrypt") {
13
- if (algorithm === "bcrypt")
14
- return bcryptVerify(password, hash);
15
- if (algorithm === "base64")
16
- return base64Verify(password, hash);
17
- throw new Error("Unsupported algorithm");
18
- }
19
- async function bcryptEncode(password) {
20
- if (!hashing.bcrypt)
21
- throw new Error("Bcrypt hashing is not configured");
22
- const salt = await bcryptjs.genSaltSync(hashing.bcrypt.rounds);
23
- const hash = await bcryptjs.hash(password, salt);
24
- return hash;
25
- }
26
- async function bcryptVerify(password, hash) {
27
- return await bcryptjs.compare(password, hash);
28
- }
29
- async function base64Encode(password) {
30
- return await Base64.encode(password);
31
- }
32
- async function base64Verify(password, hash) {
33
- return Base64.decode(hash) === password;
34
- }
35
- async function md5Encode(password) {
36
- return md5(password);
37
- }
38
- export { make as makeHash, verify as verifyHash, base64Encode, base64Verify, bcryptEncode, bcryptVerify, md5Encode };
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './key';
2
- export * from './crypt';
3
- export * from './hash';
package/dist/index.mjs DELETED
@@ -1,3 +0,0 @@
1
- export * from "./key.mjs";
2
- export * from "./crypt.mjs";
3
- export * from "./hash.mjs";
package/dist/key.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function generateAppKey(): Promise<string>;
package/dist/key.mjs DELETED
@@ -1,9 +0,0 @@
1
- import { getRandomValues } from "node:crypto";
2
- import utf8 from "crypto-js/enc-utf8";
3
- import base64 from "crypto-js/enc-base64";
4
- export async function generateAppKey() {
5
- const random = getRandomValues(new Uint8Array(32));
6
- const encodedWord = utf8.parse(random.toString());
7
- const key = base64.stringify(encodedWord);
8
- return `base64:${key}`;
9
- }