@stacksjs/security 0.67.0 → 0.68.0

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/crypt.d.ts CHANGED
@@ -1,3 +1,3 @@
1
+ export { decrypt, encrypt }
1
2
  declare function encrypt(message: string): string;
2
- declare function decrypt(encrypted: string): string;
3
- export { decrypt, encrypt };
3
+ declare function decrypt(encrypted: string): string;
package/dist/hash.d.ts CHANGED
@@ -1,15 +1,25 @@
1
- interface MakeOptions {
2
- algorithm?: "bcrypt" | "base64" | "argon2";
3
- type?: "argon2id" | "argon2i" | "argon2d";
1
+ export { make as makeHash, verify as verifyHash }
2
+ declare interface MakeOptions {
3
+ algorithm?: 'bcrypt' | 'base64' | 'argon2'
4
+ type?: 'argon2id' | 'argon2i' | 'argon2d'
4
5
  }
5
6
  declare function make(password: string, options?: MakeOptions): Promise<string>;
6
- type Algorithm = "bcrypt" | "base64" | "argon2";
7
- declare function verify(password: string, hash: string, algorithm?: Algorithm): Promise<boolean>;
7
+ declare type Algorithm = 'bcrypt' | 'base64' | 'argon2'
8
+
9
+ async function verify(password: string, hash: string, algorithm?: Algorithm): Promise<boolean> {
10
+ if (algorithm === 'argon2')
11
+ return await argon2Verify(password, hash)
12
+ if (algorithm === 'bcrypt')
13
+ return await bcryptVerify(password, hash)
14
+ if (algorithm === 'base64')
15
+ return base64Verify(password, hash)
16
+
17
+ throw new Error('Unsupported algorithm')
18
+ }
8
19
  export declare function bcryptEncode(password: string): Promise<string>;
9
- export declare function argon2Encode(password: string, options?: { type: "argon2id" | "argon2i" | "argon2d" }): Promise<string>;
20
+ export declare function argon2Encode(password: string, options?: { type: 'argon2id' | 'argon2i' | 'argon2d' },): Promise<string>;
10
21
  export declare function argon2Verify(password: string, hash: string): Promise<boolean>;
11
22
  export declare function bcryptVerify(password: string, hash: string): Promise<boolean>;
12
23
  export declare function base64Encode(password: string): string;
13
24
  export declare function base64Verify(password: string, hash: string): boolean;
14
- export declare function md5Encode(password: string): CryptoJS.lib.WordArray;
15
- export { make as makeHash, verify as verifyHash };
25
+ export declare function md5Encode(password: string): CryptoJS.lib.WordArray;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./crypt";
2
- export * from "./hash";
3
- export * from "./key";
1
+ export * from './crypt'
2
+ export * from './hash'
3
+ export * from './key'
package/dist/key.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function generateAppKey(): string;
1
+ export declare function generateAppKey(): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/security",
3
3
  "type": "module",
4
- "version": "0.67.0",
4
+ "version": "0.68.0",
5
5
  "description": "The Stacks framework security.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": ["Chris Breuer <chris@stacksjs.org>"],