@rnaga/wp-node 1.2.13 → 1.3.2

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.
Files changed (40) hide show
  1. package/common/index.d.ts +2 -0
  2. package/common/index.d.ts.map +1 -1
  3. package/common/index.js +2 -0
  4. package/common/password.d.ts +3 -0
  5. package/common/password.d.ts.map +1 -1
  6. package/common/password.js +23 -1
  7. package/common/sodium.d.ts +40 -0
  8. package/common/sodium.d.ts.map +1 -0
  9. package/common/sodium.js +172 -0
  10. package/common/uuid.d.ts +2 -0
  11. package/common/uuid.d.ts.map +1 -0
  12. package/common/uuid.js +11 -0
  13. package/config.d.ts +1 -0
  14. package/config.d.ts.map +1 -1
  15. package/core/utils/application-passwords.util.d.ts +53 -0
  16. package/core/utils/application-passwords.util.d.ts.map +1 -0
  17. package/core/utils/application-passwords.util.js +206 -0
  18. package/core/utils/crud.util.d.ts +2 -0
  19. package/core/utils/crud.util.d.ts.map +1 -1
  20. package/core/utils/crud.util.js +4 -0
  21. package/core/utils/site.util.d.ts +1 -0
  22. package/core/utils/site.util.d.ts.map +1 -1
  23. package/core/utils/site.util.js +16 -0
  24. package/core/utils/utils.d.ts +2 -0
  25. package/core/utils/utils.d.ts.map +1 -1
  26. package/core/utils/utils.js +4 -0
  27. package/crud/application-passwords.crud.d.ts +64 -0
  28. package/crud/application-passwords.crud.d.ts.map +1 -0
  29. package/crud/application-passwords.crud.js +90 -0
  30. package/package.json +3 -1
  31. package/types/crud.d.ts +28 -6
  32. package/validators/application-password.d.ts +11 -0
  33. package/validators/application-password.d.ts.map +1 -0
  34. package/validators/application-password.js +35 -0
  35. package/validators/config.d.ts +2 -0
  36. package/validators/config.d.ts.map +1 -1
  37. package/validators/config.js +1 -0
  38. package/validators/index.d.ts +1 -0
  39. package/validators/index.d.ts.map +1 -1
  40. package/validators/index.js +1 -0
package/common/index.d.ts CHANGED
@@ -8,4 +8,6 @@ export * from "./validating";
8
8
  export * from "./config";
9
9
  export * as hierarchy from "./hierarchy";
10
10
  export * from "./define-hooks";
11
+ export * from "./uuid";
12
+ export * from "./sodium";
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
package/common/index.js CHANGED
@@ -47,3 +47,5 @@ __exportStar(require("./validating"), exports);
47
47
  __exportStar(require("./config"), exports);
48
48
  exports.hierarchy = __importStar(require("./hierarchy"));
49
49
  __exportStar(require("./define-hooks"), exports);
50
+ __exportStar(require("./uuid"), exports);
51
+ __exportStar(require("./sodium"), exports);
@@ -1,4 +1,7 @@
1
1
  export declare const hashPassword: (plainText: string) => string;
2
2
  export declare const checkPassword: (plainText: string, storedHash: string) => boolean;
3
+ export declare const cleanupPasswordHash: (hash: string) => string;
4
+ export declare const fastHash: (message: string) => string;
5
+ export declare const verifyFastHash: (message: string, hash: string) => boolean;
3
6
  export declare const generatePassword: (length?: number, specialChars?: boolean, extraSpecialChars?: boolean) => string;
4
7
  //# sourceMappingURL=password.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/common/password.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,GAAI,WAAW,MAAM,WAG7C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,EAAE,YAAY,MAAM,YAGlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,SAAQ,MAAW,EACnB,eAAc,OAAc,EAC5B,oBAAmB,OAAe,KACjC,MAmBF,CAAC"}
1
+ {"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/common/password.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,GAAI,WAAW,MAAM,WAG7C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,EAAE,YAAY,MAAM,YAGlE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,WAG/C,CAAC;AAGF,eAAO,MAAM,QAAQ,GAAI,SAAS,MAAM,KAAG,MAM1C,CAAC;AAGF,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,MAAM,MAAM,KAAG,OAQ9D,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,SAAQ,MAAW,EACnB,eAAc,OAAc,EAC5B,oBAAmB,OAAe,KACjC,MAmBF,CAAC"}
@@ -36,9 +36,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.generatePassword = exports.checkPassword = exports.hashPassword = void 0;
39
+ exports.generatePassword = exports.verifyFastHash = exports.fastHash = exports.cleanupPasswordHash = exports.checkPassword = exports.hashPassword = void 0;
40
40
  const crypto = __importStar(require("crypto"));
41
41
  const bcryptjs_1 = __importDefault(require("bcryptjs"));
42
+ const sodium_1 = require("./sodium");
42
43
  const hashPassword = (plainText) => {
43
44
  const passwordHash = new PasswordHash(8, true);
44
45
  return passwordHash.hashPassword(plainText);
@@ -49,6 +50,27 @@ const checkPassword = (plainText, storedHash) => {
49
50
  return passwordHash.checkPassword(plainText, storedHash);
50
51
  };
51
52
  exports.checkPassword = checkPassword;
53
+ const cleanupPasswordHash = (hash) => {
54
+ // Execute preg_replace( '/[^[a-z\d]i/', '', $hash );
55
+ return hash.replace(/[^a-z\d]/gi, "");
56
+ };
57
+ exports.cleanupPasswordHash = cleanupPasswordHash;
58
+ // wp_fast_hash
59
+ const fastHash = (message) => {
60
+ const hashed = (0, sodium_1.sodiumCryptoGenerichash)(message, "wp_fast_hash_6.8+", 30);
61
+ return ("$generic$" +
62
+ (0, sodium_1.sodiumBin2Base64)(hashed, sodium_1.SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING));
63
+ };
64
+ exports.fastHash = fastHash;
65
+ // wp_verify_fast_hash
66
+ const verifyFastHash = (message, hash) => {
67
+ if (!hash.startsWith("$generic$")) {
68
+ return new PasswordHash(8, true).checkPassword(message, hash);
69
+ }
70
+ const generatedHash = (0, exports.fastHash)(message);
71
+ return hash === generatedHash;
72
+ };
73
+ exports.verifyFastHash = verifyFastHash;
52
74
  const generatePassword = (length = 12, specialChars = true, extraSpecialChars = false) => {
53
75
  let chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
54
76
  if (specialChars) {
@@ -0,0 +1,40 @@
1
+ declare const SODIUM_BASE64_VARIANT_ORIGINAL = 1;
2
+ declare const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = 3;
3
+ declare const SODIUM_BASE64_VARIANT_URLSAFE = 5;
4
+ declare const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = 7;
5
+ export { SODIUM_BASE64_VARIANT_ORIGINAL, SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, SODIUM_BASE64_VARIANT_URLSAFE, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, };
6
+ /**
7
+ * TypeScript equivalent of PHP's sodium_crypto_generichash()
8
+ *
9
+ * @param message - The message to hash
10
+ * @param key - Optional key for keyed hashing
11
+ * @param length - Output length in bytes (default: 32, min: 16, max: 64)
12
+ * @returns Buffer containing the hash
13
+ */
14
+ export declare const sodiumCryptoGenerichash: (message: string | Buffer, key?: string | Buffer | null, length?: number) => Buffer;
15
+ /**
16
+ * TypeScript equivalent of PHP's sodium_bin2base64()
17
+ * Encodes binary data to base64
18
+ *
19
+ * @param data - Binary data to encode
20
+ * @param variant - Base64 variant (SODIUM_BASE64_VARIANT_ORIGINAL, SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, SODIUM_BASE64_VARIANT_URLSAFE, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING)
21
+ * @returns Base64 encoded string
22
+ */
23
+ export declare const sodiumBin2Base64: (data: string | Buffer, variant?: number) => string;
24
+ /**
25
+ * Convert base64 string back to binary data
26
+ * @param base64 - Base64 encoded string
27
+ * @param variant - Base64 variant that was used for encoding
28
+ * @returns Buffer containing the decoded binary data
29
+ */
30
+ export declare const sodiumBase642bin: (base64: string, variant?: number) => Buffer;
31
+ /**
32
+ * TypeScript equivalent of PHP's hash_equals()
33
+ * Timing-safe string comparison to prevent timing attacks
34
+ *
35
+ * @param known - Known string (expected value)
36
+ * @param user - User-provided string to compare
37
+ * @returns true if strings are equal, false otherwise
38
+ */
39
+ export declare const hashEquals: (known: string, user: string) => boolean;
40
+ //# sourceMappingURL=sodium.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sodium.d.ts","sourceRoot":"","sources":["../../src/common/sodium.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,8BAA8B,IAAI,CAAC;AACzC,QAAA,MAAM,yCAAyC,IAAI,CAAC;AACpD,QAAA,MAAM,6BAA6B,IAAI,CAAC;AACxC,QAAA,MAAM,wCAAwC,IAAI,CAAC;AAEnD,OAAO,EACL,8BAA8B,EAC9B,yCAAyC,EACzC,6BAA6B,EAC7B,wCAAwC,GACzC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,MAAM,GAAG,MAAM,EACxB,MAAM,MAAM,GAAG,MAAM,GAAG,IAAI,EAC5B,SAAQ,MAAW,KAClB,MA2BF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,GAAG,MAAM,EACrB,UAAS,MAAuC,KAC/C,MA0BF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,UAAS,MAAuC,KAC/C,MAqCF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,KAAG,OAYxD,CAAC"}
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.hashEquals = exports.sodiumBase642bin = exports.sodiumBin2Base64 = exports.sodiumCryptoGenerichash = exports.SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = exports.SODIUM_BASE64_VARIANT_URLSAFE = exports.SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = exports.SODIUM_BASE64_VARIANT_ORIGINAL = void 0;
37
+ const crypto = __importStar(require("crypto"));
38
+ const sodium = __importStar(require("sodium-native"));
39
+ // Constants for base64 variants (matching PHP sodium constants)
40
+ const SODIUM_BASE64_VARIANT_ORIGINAL = 1;
41
+ exports.SODIUM_BASE64_VARIANT_ORIGINAL = SODIUM_BASE64_VARIANT_ORIGINAL;
42
+ const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = 3;
43
+ exports.SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING;
44
+ const SODIUM_BASE64_VARIANT_URLSAFE = 5;
45
+ exports.SODIUM_BASE64_VARIANT_URLSAFE = SODIUM_BASE64_VARIANT_URLSAFE;
46
+ const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = 7;
47
+ exports.SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING;
48
+ /**
49
+ * TypeScript equivalent of PHP's sodium_crypto_generichash()
50
+ *
51
+ * @param message - The message to hash
52
+ * @param key - Optional key for keyed hashing
53
+ * @param length - Output length in bytes (default: 32, min: 16, max: 64)
54
+ * @returns Buffer containing the hash
55
+ */
56
+ const sodiumCryptoGenerichash = (message, key, length = 32) => {
57
+ // Convert string inputs to Buffer
58
+ const messageBuffer = Buffer.isBuffer(message)
59
+ ? message
60
+ : Buffer.from(message, "utf8");
61
+ const keyBuffer = key
62
+ ? Buffer.isBuffer(key)
63
+ ? key
64
+ : Buffer.from(key, "utf8")
65
+ : null;
66
+ // Validate length parameter
67
+ if (length < 16 || length > 64) {
68
+ throw new Error("Hash length must be between 16 and 64 bytes");
69
+ }
70
+ // Create output buffer
71
+ const output = Buffer.alloc(length);
72
+ // Compute hash using sodium-native
73
+ if (keyBuffer) {
74
+ sodium.crypto_generichash(output, messageBuffer, keyBuffer);
75
+ }
76
+ else {
77
+ sodium.crypto_generichash(output, messageBuffer);
78
+ }
79
+ return output;
80
+ };
81
+ exports.sodiumCryptoGenerichash = sodiumCryptoGenerichash;
82
+ /**
83
+ * TypeScript equivalent of PHP's sodium_bin2base64()
84
+ * Encodes binary data to base64
85
+ *
86
+ * @param data - Binary data to encode
87
+ * @param variant - Base64 variant (SODIUM_BASE64_VARIANT_ORIGINAL, SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, SODIUM_BASE64_VARIANT_URLSAFE, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING)
88
+ * @returns Base64 encoded string
89
+ */
90
+ const sodiumBin2Base64 = (data, variant = SODIUM_BASE64_VARIANT_ORIGINAL) => {
91
+ const dataBuffer = Buffer.isBuffer(data) ? data : Buffer.from(data, "binary");
92
+ switch (variant) {
93
+ case SODIUM_BASE64_VARIANT_ORIGINAL:
94
+ return dataBuffer.toString("base64");
95
+ case SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING:
96
+ return dataBuffer.toString("base64").replace(/=/g, "");
97
+ case SODIUM_BASE64_VARIANT_URLSAFE:
98
+ return dataBuffer
99
+ .toString("base64")
100
+ .replace(/\+/g, "-")
101
+ .replace(/\//g, "_");
102
+ case SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING:
103
+ return dataBuffer
104
+ .toString("base64")
105
+ .replace(/\+/g, "-")
106
+ .replace(/\//g, "_")
107
+ .replace(/=/g, "");
108
+ default:
109
+ throw new Error("Invalid base64 variant");
110
+ }
111
+ };
112
+ exports.sodiumBin2Base64 = sodiumBin2Base64;
113
+ /**
114
+ * Convert base64 string back to binary data
115
+ * @param base64 - Base64 encoded string
116
+ * @param variant - Base64 variant that was used for encoding
117
+ * @returns Buffer containing the decoded binary data
118
+ */
119
+ const sodiumBase642bin = (base64, variant = SODIUM_BASE64_VARIANT_ORIGINAL) => {
120
+ let normalizedBase64 = base64;
121
+ switch (variant) {
122
+ case SODIUM_BASE64_VARIANT_ORIGINAL:
123
+ // Standard base64 with padding (default)
124
+ break;
125
+ case SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING:
126
+ // Standard base64 without padding - add padding back
127
+ while (normalizedBase64.length % 4 !== 0) {
128
+ normalizedBase64 += "=";
129
+ }
130
+ break;
131
+ case SODIUM_BASE64_VARIANT_URLSAFE:
132
+ // URL-safe base64 with padding - convert back to standard
133
+ normalizedBase64 = normalizedBase64.replace(/-/g, "+").replace(/_/g, "/");
134
+ break;
135
+ case SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING:
136
+ // URL-safe base64 without padding - convert and add padding
137
+ normalizedBase64 = normalizedBase64.replace(/-/g, "+").replace(/_/g, "/");
138
+ while (normalizedBase64.length % 4 !== 0) {
139
+ normalizedBase64 += "=";
140
+ }
141
+ break;
142
+ default:
143
+ throw new Error(`Invalid base64 variant: ${variant}`);
144
+ }
145
+ try {
146
+ return Buffer.from(normalizedBase64, "base64");
147
+ }
148
+ catch (error) {
149
+ throw new Error("Invalid base64 string");
150
+ }
151
+ };
152
+ exports.sodiumBase642bin = sodiumBase642bin;
153
+ /**
154
+ * TypeScript equivalent of PHP's hash_equals()
155
+ * Timing-safe string comparison to prevent timing attacks
156
+ *
157
+ * @param known - Known string (expected value)
158
+ * @param user - User-provided string to compare
159
+ * @returns true if strings are equal, false otherwise
160
+ */
161
+ const hashEquals = (known, user) => {
162
+ // Convert to buffers for consistent comparison
163
+ const knownBuffer = Buffer.from(known, "utf8");
164
+ const userBuffer = Buffer.from(user, "utf8");
165
+ // Use Node.js crypto.timingSafeEqual for constant-time comparison
166
+ // First check if lengths are equal (this itself is constant time for same-length inputs)
167
+ if (knownBuffer.length !== userBuffer.length) {
168
+ return false;
169
+ }
170
+ return crypto.timingSafeEqual(knownBuffer, userBuffer);
171
+ };
172
+ exports.hashEquals = hashEquals;
@@ -0,0 +1,2 @@
1
+ export declare const uuid4: () => string;
2
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/common/uuid.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,cAMjB,CAAC"}
package/common/uuid.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uuid4 = void 0;
4
+ const uuid4 = () => {
5
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
6
+ const r = (Math.random() * 16) | 0;
7
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
8
+ return v.toString(16);
9
+ });
10
+ };
11
+ exports.uuid4 = uuid4;
package/config.d.ts CHANGED
@@ -21,6 +21,7 @@ export declare class Config {
21
21
  WP_POST_REVISIONS: number;
22
22
  WP_LOG_LEVEL: "debug" | "info" | "warn" | "error";
23
23
  };
24
+ useApplicationPasswords: boolean;
24
25
  extensions: {
25
26
  misc: string[];
26
27
  audio: string[];
package/config.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AAGtC,qBACa,MAAM;;gBAGL,MAAM,EAAE,KAAK,CAAC,MAAM;IAIhC,WAAW;IAIX,KAAK;IAKL,kBAAkB;IAOlB,IAAI,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAET;IAED,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC;CAG5C"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AAGtC,qBACa,MAAM;;gBAGL,MAAM,EAAE,KAAK,CAAC,MAAM;IAIhC,WAAW;IAIX,KAAK;IAKL,kBAAkB;IAOlB,IAAI,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAET;IAED,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC;CAG5C"}
@@ -0,0 +1,53 @@
1
+ import { Config } from "../../config";
2
+ import { applicationPassword } from "../../validators/application-password";
3
+ import { Components } from "../components";
4
+ import { z } from "zod";
5
+ type ApplicationPassword = z.infer<typeof applicationPassword>;
6
+ export declare class ApplicationPasswordsUtil {
7
+ private config;
8
+ private components;
9
+ constructor(config: Config, components: Components);
10
+ getMetaKey(): string;
11
+ getOptionsKey(): string;
12
+ isAvailable(checkSsl?: boolean): boolean;
13
+ isInUse(): Promise<boolean>;
14
+ createNewPassword(userId: number, options: {
15
+ name: string;
16
+ app_id?: string;
17
+ }): Promise<{
18
+ password: string;
19
+ item: {
20
+ uuid: string;
21
+ app_id: string;
22
+ name: string;
23
+ password: string;
24
+ created: number;
25
+ last_used: number | null;
26
+ last_ip: string | null;
27
+ };
28
+ }>;
29
+ recordPasswordUsage(userId: number, uuid: string, options: {
30
+ ip?: string | null;
31
+ }): Promise<boolean>;
32
+ updatePasswordName(userId: number, uuid: string, newName: string): Promise<boolean>;
33
+ deletePassword(userId: number, uuid: string): Promise<boolean>;
34
+ deleteAllPasswords(userId: number): Promise<boolean>;
35
+ private parsePasswords;
36
+ getUserPasswords(userId: number): Promise<{
37
+ uuid: string;
38
+ app_id: string;
39
+ name: string;
40
+ password: string;
41
+ created: number;
42
+ last_used: number | null;
43
+ last_ip: string | null;
44
+ }[]>;
45
+ getUserPasswordByUuid(userId: number, uuid: string): Promise<ApplicationPassword | null>;
46
+ setUserPasswords(userId: number, passwords: ApplicationPassword[]): Promise<boolean>;
47
+ chunkPassword(password: string): string;
48
+ authenticate(userIdOrName: number | string, rawPassword: string, options?: {
49
+ ip?: string;
50
+ }): Promise<import("../user").User | undefined>;
51
+ }
52
+ export {};
53
+ //# sourceMappingURL=application-passwords.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-passwords.util.d.ts","sourceRoot":"","sources":["../../../src/core/utils/application-passwords.util.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAAS,CAAC,EAAE,MAAM,KAAK,CAAC;AAO/B,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE/D,qBACa,wBAAwB;IACvB,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,UAAU;gBAAlC,MAAM,EAAE,MAAM,EAAU,UAAU,EAAE,UAAU;IAElE,UAAU;IAIV,aAAa;IAIb,WAAW,CAAC,QAAQ,GAAE,OAAc;IAO9B,OAAO;IAiBP,iBAAiB,CACrB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;;;;;;;;;;;;IA0CG,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;IA2B3B,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAoBhE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAQ3C,kBAAkB,CAAC,MAAM,EAAE,MAAM;IAIvC,OAAO,CAAC,cAAc;IAKhB,gBAAgB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;IAe/B,qBAAqB,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAUhC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE;IASvE,aAAa,CAAC,QAAQ,EAAE,MAAM;IAcxB,YAAY,CAChB,YAAY,EAAE,MAAM,GAAG,MAAM,EAC7B,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACR,EAAE,CAAC,EAAE,MAAM,CAAC;KACb;CAmCJ"}
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ApplicationPasswordsUtil = void 0;
13
+ const common_1 = require("../../common");
14
+ const config_1 = require("../../config");
15
+ const component_1 = require("../../decorators/component");
16
+ const transactions_1 = require("../../transactions");
17
+ const application_password_1 = require("../../validators/application-password");
18
+ const components_1 = require("../components");
19
+ const options_1 = require("../options");
20
+ const meta_util_1 = require("./meta.util");
21
+ const site_util_1 = require("./site.util");
22
+ const zod_1 = require("zod");
23
+ const user_util_1 = require("./user.util");
24
+ // Application Passwords should be 24 characters long.
25
+ // https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#application-passwords
26
+ const PW_LENGTH = 24;
27
+ let ApplicationPasswordsUtil = class ApplicationPasswordsUtil {
28
+ config;
29
+ components;
30
+ constructor(config, components) {
31
+ this.config = config;
32
+ this.components = components;
33
+ }
34
+ getMetaKey() {
35
+ return "_application_passwords";
36
+ }
37
+ getOptionsKey() {
38
+ return "using_application_passwords";
39
+ }
40
+ isAvailable(checkSsl = true) {
41
+ return (this.config.config.useApplicationPasswords === true &&
42
+ (checkSsl === false || this.config.isSsl() === true));
43
+ }
44
+ async isInUse() {
45
+ const options = this.components.get(options_1.Options);
46
+ const siteUtil = this.components.get(site_util_1.SiteUtil);
47
+ const mainSiteId = await siteUtil.getMainSiteId();
48
+ const using = !this.config.isMultiSite()
49
+ ? await options.get(this.getOptionsKey())
50
+ : await options.get(this.getOptionsKey(), { siteId: mainSiteId });
51
+ return (using === "1" ||
52
+ parseInt(`${using}`) === 1 ||
53
+ Boolean(`${using}`) === true);
54
+ }
55
+ // create_new_application_password
56
+ async createNewPassword(userId, options) {
57
+ const name = zod_1.z.string().min(2).max(100).parse(options.name);
58
+ const newPassword = (0, common_1.generatePassword)(PW_LENGTH, false);
59
+ const hashedPassword = (0, common_1.fastHash)(newPassword);
60
+ const newItem = {
61
+ uuid: (0, common_1.uuid4)(),
62
+ app_id: options.app_id || "",
63
+ name,
64
+ password: hashedPassword,
65
+ created: Math.floor(Date.now() / 1000),
66
+ last_used: null,
67
+ last_ip: null,
68
+ };
69
+ // Set Option Key
70
+ if (this.config.isMultiSite()) {
71
+ const siteId = await this.components.get(site_util_1.SiteUtil).getMainSiteId();
72
+ const metaTrx = this.components.get(transactions_1.MetaTrx);
73
+ await metaTrx.upsert("site", siteId, this.getOptionsKey(), "1");
74
+ }
75
+ else {
76
+ const optionsTrx = this.components.get(transactions_1.OptionsTrx);
77
+ await optionsTrx.insert(this.getOptionsKey(), "1", { upsert: true });
78
+ }
79
+ const passwords = await this.getUserPasswords(userId);
80
+ passwords.push(newItem);
81
+ const result = await this.setUserPasswords(userId, passwords);
82
+ if (!result) {
83
+ throw new Error("Failed to set user passwords");
84
+ }
85
+ return {
86
+ password: newPassword,
87
+ item: newItem,
88
+ };
89
+ }
90
+ // record_application_password_usage
91
+ async recordPasswordUsage(userId, uuid, options) {
92
+ const passwords = await this.getUserPasswords(userId);
93
+ for (const password of passwords) {
94
+ if (password.uuid !== uuid) {
95
+ continue;
96
+ }
97
+ const lastUsed = password.last_used || 0;
98
+ // Only record activity once a day.
99
+ if (lastUsed > 0 && lastUsed + 86400 > Math.floor(Date.now() / 1000)) {
100
+ return true;
101
+ }
102
+ // Update the password object in the array
103
+ password.last_used = Math.floor(Date.now() / 1000);
104
+ password.last_ip = options.ip || null;
105
+ // Save the updated passwords array
106
+ return await this.setUserPasswords(userId, passwords);
107
+ }
108
+ return false;
109
+ }
110
+ // update_application_password
111
+ async updatePasswordName(userId, uuid, newName) {
112
+ const name = zod_1.z.string().min(2).max(100).parse(newName);
113
+ const passwords = await this.getUserPasswords(userId);
114
+ for (const password of passwords) {
115
+ if (password.uuid !== uuid) {
116
+ continue;
117
+ }
118
+ // Update the password object in the array
119
+ password.name = name;
120
+ // Save the updated passwords array
121
+ return await this.setUserPasswords(userId, passwords);
122
+ }
123
+ return false;
124
+ }
125
+ // delete_application_password
126
+ async deletePassword(userId, uuid) {
127
+ const passwords = await this.getUserPasswords(userId);
128
+ const filtered = passwords.filter((password) => password.uuid !== uuid);
129
+ return await this.setUserPasswords(userId, filtered);
130
+ }
131
+ // delete_all_application_passwords
132
+ async deleteAllPasswords(userId) {
133
+ return await this.setUserPasswords(userId, []);
134
+ }
135
+ parsePasswords(passwords) {
136
+ return zod_1.z.array(application_password_1.applicationPassword).parse(passwords || []);
137
+ }
138
+ // get_user_application_password
139
+ async getUserPasswords(userId) {
140
+ const metaUtil = this.components.get(meta_util_1.MetaUtil);
141
+ const passwords = await metaUtil.getValue("user", userId, this.getMetaKey());
142
+ // Unserialize
143
+ const serialized = (0, common_1.phpUnserialize)(passwords) || [];
144
+ return this.parsePasswords(serialized);
145
+ }
146
+ // get_user_application_password
147
+ async getUserPasswordByUuid(userId, uuid) {
148
+ if (uuid.length !== 36) {
149
+ return null;
150
+ }
151
+ const passwords = await this.getUserPasswords(userId);
152
+ return passwords.find((password) => password.uuid === uuid) || null;
153
+ }
154
+ // set_user_application_passwords
155
+ async setUserPasswords(userId, passwords) {
156
+ const parsed = this.parsePasswords(passwords);
157
+ const metaTrx = this.components.get(transactions_1.MetaTrx);
158
+ return await metaTrx.upsert("user", userId, this.getMetaKey(), parsed, {
159
+ serialize: true,
160
+ });
161
+ }
162
+ chunkPassword(password) {
163
+ // Clean up first with cleanupPasswordHash
164
+ const cleanedUp = (0, common_1.cleanupPasswordHash)(password);
165
+ // trim( chunk_split( $raw_password, 4, ' ' ) );
166
+ return (cleanedUp
167
+ .match(/.{1,4}/g)
168
+ ?.join(" ")
169
+ .trim() || "");
170
+ }
171
+ // wp_authenticate_application_password
172
+ async authenticate(userIdOrName, rawPassword, options) {
173
+ if ((await this.isInUse()) === false) {
174
+ return undefined;
175
+ }
176
+ // Get user
177
+ const userUtil = this.components.get(user_util_1.UserUtil);
178
+ const user = await userUtil.get(userIdOrName);
179
+ if (!user.props) {
180
+ return undefined;
181
+ }
182
+ const userId = user.props.ID;
183
+ const password = (0, common_1.cleanupPasswordHash)(rawPassword);
184
+ if (password.length !== PW_LENGTH) {
185
+ return undefined;
186
+ }
187
+ // Get all password objects
188
+ const passwords = await this.getUserPasswords(userId);
189
+ for (const item of passwords) {
190
+ if (item.password && (0, common_1.verifyFastHash)(password, item.password)) {
191
+ // Record usage
192
+ await this.recordPasswordUsage(userId, item.uuid, {
193
+ ip: options?.ip || null,
194
+ });
195
+ // Return user object
196
+ return user;
197
+ }
198
+ }
199
+ return undefined;
200
+ }
201
+ };
202
+ exports.ApplicationPasswordsUtil = ApplicationPasswordsUtil;
203
+ exports.ApplicationPasswordsUtil = ApplicationPasswordsUtil = __decorate([
204
+ (0, component_1.component)(),
205
+ __metadata("design:paramtypes", [config_1.Config, components_1.Components])
206
+ ], ApplicationPasswordsUtil);
@@ -13,6 +13,7 @@ import { TermCrud } from "../../crud/term.crud";
13
13
  import { UserSelfRegistrationCrud } from "../../crud/user-self-registration.crud";
14
14
  import { UserCrud } from "../../crud/user.crud";
15
15
  import { Components } from "../components";
16
+ import { ApplicationPasswordsCrud } from "../../crud/application-passwords.crud";
16
17
  export declare class CrudUtil {
17
18
  private components;
18
19
  constructor(components: Components);
@@ -36,5 +37,6 @@ export declare class CrudUtil {
36
37
  get term(): TermCrud;
37
38
  get user(): UserCrud;
38
39
  get userSelfRegistration(): UserSelfRegistrationCrud;
40
+ get applicationPasswords(): ApplicationPasswordsCrud;
39
41
  }
40
42
  //# sourceMappingURL=crud.util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crud.util.d.ts","sourceRoot":"","sources":["../../../src/core/utils/crud.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAoB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC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("../../crud/user.crud");
27
27
  const component_1 = require("../../decorators/component");
28
28
  const components_1 = require("../components");
29
+ const application_passwords_crud_1 = require("../../crud/application-passwords.crud");
29
30
  let CrudUtil = class CrudUtil {
30
31
  components;
31
32
  constructor(components) {
@@ -89,6 +90,9 @@ let CrudUtil = class CrudUtil {
89
90
  get userSelfRegistration() {
90
91
  return this.components.get(user_self_registration_crud_1.UserSelfRegistrationCrud);
91
92
  }
93
+ get applicationPasswords() {
94
+ return this.components.get(application_passwords_crud_1.ApplicationPasswordsCrud);
95
+ }
92
96
  };
93
97
  exports.CrudUtil = CrudUtil;
94
98
  exports.CrudUtil = CrudUtil = __decorate([
@@ -9,6 +9,7 @@ export declare class SiteUtil {
9
9
  constructor(components: Components, config: Config);
10
10
  get(siteRef: string | number): Promise<Site>;
11
11
  toSites(sites: types.Tables["site"][], blogId: number): Promise<Site[]>;
12
+ getMainSiteId(): Promise<number>;
12
13
  getBlogs(siteId: number): Promise<Blog[]>;
13
14
  getReservedNames(siteId?: number): Promise<string[]>;
14
15
  private getSiteOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"site.util.d.ts","sourceRoot":"","sources":["../../../src/core/utils/site.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI/B,qBACa,QAAQ;IACP,OAAO,CAAC,UAAU;IAAc,OAAO,CAAC,MAAM;gBAAtC,UAAU,EAAE,UAAU,EAAU,MAAM,EAAE,MAAM;IAE5D,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI5B,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE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AAE;CAsBxE"}
@@ -35,6 +35,22 @@ let SiteUtil = class SiteUtil {
35
35
  }
36
36
  return arr;
37
37
  }
38
+ // get_main_network_id
39
+ async getMainSiteId() {
40
+ if (!this.config.isMultiSite()) {
41
+ return 1;
42
+ }
43
+ const current = this.components.get(current_1.Current);
44
+ const siteId = current.siteId;
45
+ if (siteId === 1) {
46
+ return 1;
47
+ }
48
+ const queryUtil = this.components.get(query_util_1.QueryUtil);
49
+ const sites = await queryUtil.sites((query) => {
50
+ query.builder.limit(1);
51
+ });
52
+ return sites?.[0]?.id ?? 1;
53
+ }
38
54
  // async getList() {
39
55
  // const queryUtil = this.components.get(QueryUtil);
40
56
  // const metaUtil = this.components.get(MetaUtil);
@@ -14,6 +14,7 @@ import { TaxonomyUtil } from "./taxonomy.util";
14
14
  import { TermUtil } from "./term.util";
15
15
  import { TrxUtil } from "./trx.util";
16
16
  import { UserUtil } from "./user.util";
17
+ import { ApplicationPasswordsUtil } from "./application-passwords.util";
17
18
  export declare class Utils {
18
19
  private components;
19
20
  constructor(components: Components);
@@ -32,5 +33,6 @@ export declare class Utils {
32
33
  get site(): SiteUtil;
33
34
  get term(): TermUtil;
34
35
  get crud(): CrudUtil;
36
+ get applicationPasswords(): ApplicationPasswordsUtil;
35
37
  }
36
38
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAA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O,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE,qBACa,KAAK;IACJ,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAE1C,IAAI,IAAI,aAEP;IAED,IAAI,OAAO,gBAEV;IAED,IAAI,QAAQ,iBAEX;IAED,IAAI,IAAI,aAEP;IAED,IAAI,IAAI,aAEP;IAED,IAAI,QAAQ,gBAEX;IAED,IAAI,KAAK,cAER;IAED,IAAI,QAAQ,iBAEX;IAED,IAAI,IAAI,aAEP;IAED,IAAI,GAAG,YAEN;IAED,IAAI,KAAK,cAER;IAED,IAAI,IAAI,aAEP;IAED,IAAI,IAAI,aAEP;IAED,IAAI,IAAI,aAEP;IAED,IAAI,IAAI,aAEP;IAED,IAAI,oBAAoB,6BAEvB;CACF"}
@@ -27,6 +27,7 @@ const taxonomy_util_1 = require("./taxonomy.util");
27
27
  const term_util_1 = require("./term.util");
28
28
  const trx_util_1 = require("./trx.util");
29
29
  const user_util_1 = require("./user.util");
30
+ const application_passwords_util_1 = require("./application-passwords.util");
30
31
  let Utils = class Utils {
31
32
  components;
32
33
  constructor(components) {
@@ -77,6 +78,9 @@ let Utils = class Utils {
77
78
  get crud() {
78
79
  return this.components.get(crud_util_1.CrudUtil);
79
80
  }
81
+ get applicationPasswords() {
82
+ return this.components.get(application_passwords_util_1.ApplicationPasswordsUtil);
83
+ }
80
84
  };
81
85
  exports.Utils = Utils;
82
86
  exports.Utils = Utils = __decorate([
@@ -0,0 +1,64 @@
1
+ import { Components } from "../core/components";
2
+ import { ApplicationPasswordsUtil } from "../core/utils/application-passwords.util";
3
+ import { Crud } from "./crud";
4
+ export declare class ApplicationPasswordsCrud extends Crud {
5
+ private applicationPasswordsUtil;
6
+ constructor(components: Components, applicationPasswordsUtil: ApplicationPasswordsUtil);
7
+ get(uuid: string): Promise<{
8
+ data: {
9
+ uuid: string;
10
+ app_id: string;
11
+ name: string;
12
+ password: string;
13
+ created: number;
14
+ last_used: number | null;
15
+ last_ip: string | null;
16
+ };
17
+ info: undefined;
18
+ }>;
19
+ list(): Promise<{
20
+ data: {
21
+ uuid: string;
22
+ app_id: string;
23
+ name: string;
24
+ password: string;
25
+ created: number;
26
+ last_used: number | null;
27
+ last_ip: string | null;
28
+ }[];
29
+ info: undefined;
30
+ }>;
31
+ create(data: {
32
+ name: string;
33
+ app_id?: string;
34
+ }): Promise<{
35
+ data: {
36
+ password: string;
37
+ item: {
38
+ uuid: string;
39
+ app_id: string;
40
+ name: string;
41
+ password: string;
42
+ created: number;
43
+ last_used: number | null;
44
+ last_ip: string | null;
45
+ };
46
+ };
47
+ info: undefined;
48
+ }>;
49
+ update(uuid: string, data: {
50
+ name: string;
51
+ }): Promise<{
52
+ data: boolean;
53
+ info: undefined;
54
+ }>;
55
+ delete(uuid: string): Promise<{
56
+ data: boolean;
57
+ info: undefined;
58
+ }>;
59
+ deleteAll(): Promise<{
60
+ data: boolean;
61
+ info: undefined;
62
+ }>;
63
+ }
64
+ //# sourceMappingURL=application-passwords.crud.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-passwords.crud.d.ts","sourceRoot":"","sources":["../../src/crud/application-passwords.crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AAEpF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,qBACa,wBAAyB,SAAQ,IAAI;IAG9C,OAAO,CAAC,wBAAwB;gBADhC,UAAU,EAAE,UAAU,EACd,wBAAwB,EAAE,wBAAwB;IAKtD,GAAG,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;IAkBhB,IAAI;;;;;;;;;;;;IAcJ,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;IAe9C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;;;;IAuB3C,MAAM,CAAC,IAAI,EAAE,MAAM;;;;IAsBnB,SAAS;;;;CAgBhB"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ApplicationPasswordsCrud = void 0;
13
+ const components_1 = require("../core/components");
14
+ const application_passwords_util_1 = require("../core/utils/application-passwords.util");
15
+ const component_1 = require("../decorators/component");
16
+ const crud_1 = require("./crud");
17
+ const error_1 = require("./error");
18
+ let ApplicationPasswordsCrud = class ApplicationPasswordsCrud extends crud_1.Crud {
19
+ applicationPasswordsUtil;
20
+ constructor(components, applicationPasswordsUtil) {
21
+ super(components);
22
+ this.applicationPasswordsUtil = applicationPasswordsUtil;
23
+ }
24
+ async get(uuid) {
25
+ const { user: currentUser } = await this.getUser();
26
+ if (!(await currentUser?.can("read_app_password"))) {
27
+ throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
28
+ }
29
+ const password = await this.applicationPasswordsUtil.getUserPasswordByUuid(currentUser.props.ID, uuid);
30
+ if (!password) {
31
+ throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, "Password not found");
32
+ }
33
+ return this.returnValue(password);
34
+ }
35
+ async list() {
36
+ const { user: currentUser } = await this.getUser();
37
+ if (!(await currentUser?.can("list_app_passwords"))) {
38
+ throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
39
+ }
40
+ const passwords = await this.applicationPasswordsUtil.getUserPasswords(currentUser.props.ID);
41
+ return this.returnValue(passwords);
42
+ }
43
+ async create(data) {
44
+ const { user: currentUser } = await this.getUser();
45
+ if (!(await currentUser?.can("create_app_password"))) {
46
+ throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
47
+ }
48
+ const password = await this.applicationPasswordsUtil.createNewPassword(currentUser.props.ID, data);
49
+ return this.returnValue(password);
50
+ }
51
+ async update(uuid, data) {
52
+ const { user: currentUser } = await this.getUser();
53
+ if (!(await currentUser?.can("edit_app_password"))) {
54
+ throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
55
+ }
56
+ const success = await this.applicationPasswordsUtil.updatePasswordName(currentUser.props.ID, uuid, data.name);
57
+ if (!success) {
58
+ throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Failed to update password");
59
+ }
60
+ return this.returnValue(success);
61
+ }
62
+ async delete(uuid) {
63
+ const { user: currentUser } = await this.getUser();
64
+ if (!(await currentUser?.can("delete_app_password"))) {
65
+ throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
66
+ }
67
+ const success = await this.applicationPasswordsUtil.deletePassword(currentUser.props.ID, uuid);
68
+ if (!success) {
69
+ throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Failed to delete password");
70
+ }
71
+ return this.returnValue(success);
72
+ }
73
+ async deleteAll() {
74
+ const { user: currentUser } = await this.getUser();
75
+ if (!(await currentUser?.can("delete_app_passwords"))) {
76
+ throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
77
+ }
78
+ const success = await this.applicationPasswordsUtil.deleteAllPasswords(currentUser.props.ID);
79
+ if (!success) {
80
+ throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Failed to delete passwords");
81
+ }
82
+ return this.returnValue(success);
83
+ }
84
+ };
85
+ exports.ApplicationPasswordsCrud = ApplicationPasswordsCrud;
86
+ exports.ApplicationPasswordsCrud = ApplicationPasswordsCrud = __decorate([
87
+ (0, component_1.component)(),
88
+ __metadata("design:paramtypes", [components_1.Components,
89
+ application_passwords_util_1.ApplicationPasswordsUtil])
90
+ ], ApplicationPasswordsCrud);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnaga/wp-node",
3
- "version": "1.2.13",
3
+ "version": "1.3.2",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && tsc --project tsconfig.build.json && npm run copyfiles && cp package.json ./dist/",
@@ -22,6 +22,7 @@
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
24
  "@types/node": "^22",
25
+ "@types/sodium-native": "^2.3.9",
25
26
  "copyfiles": "^2.4.1",
26
27
  "ts-node": "^10.9.1",
27
28
  "typescript": "^5.9",
@@ -36,6 +37,7 @@
36
37
  "mysql2": "^3.14.0",
37
38
  "php-serialize": "^5",
38
39
  "reflect-metadata": "^0.1.13",
40
+ "sodium-native": "^5.0.8",
39
41
  "zod": "^4.0.5"
40
42
  },
41
43
  "repository": {
package/types/crud.d.ts CHANGED
@@ -1,17 +1,18 @@
1
+ import { CrudUtil } from "../core/utils/crud.util";
2
+ import { ApplicationPasswordsCrud } from "../crud/application-passwords.crud";
1
3
  import { BlogCrud } from "../crud/blog.crud";
2
4
  import { CommentCrud } from "../crud/comment.crud";
5
+ import { Crud } from "../crud/crud";
3
6
  import { MetaCrud } from "../crud/meta.crud";
4
7
  import { OptionsCrud } from "../crud/options.crud";
5
8
  import { PostCrud } from "../crud/post.crud";
6
- import { SiteCrud } from "../crud/site.crud";
7
- import { SettingsCrud } from "../crud/settings.crud";
8
- import { TermCrud } from "../crud/term.crud";
9
- import { UserCrud } from "../crud/user.crud";
10
- import { CrudUtil } from "../core/utils/crud.util";
11
- import { Crud } from "../crud/crud";
12
9
  import { RevisionCrud } from "../crud/revision.crud";
13
10
  import { RolesCrud } from "../crud/roles.crud";
11
+ import { SettingsCrud } from "../crud/settings.crud";
12
+ import { SiteCrud } from "../crud/site.crud";
13
+ import { TermCrud } from "../crud/term.crud";
14
14
  import { UserSelfRegistrationCrud } from "../crud/user-self-registration.crud";
15
+ import { UserCrud } from "../crud/user.crud";
15
16
 
16
17
  export type ParseError = ReturnType<CrudUtil["parseError"]>;
17
18
 
@@ -39,6 +40,7 @@ export type CrudKeys =
39
40
  type Context = "view" | "edit" | "embed";
40
41
 
41
42
  interface CrudComponents {
43
+ applicationPasswords: ApplicationPasswordsCrud;
42
44
  blog: BlogCrud;
43
45
  comment: CommentCrud;
44
46
  meta: MetaCrud;
@@ -97,6 +99,26 @@ export type BlogParams<T extends BlogOperations> = {
97
99
  delete: Parameters<BlogCrud["delete"]>;
98
100
  }[T];
99
101
 
102
+ export type ApplicationPasswordsOperations = Extract<
103
+ Operation,
104
+ "get" | "list" | "update" | "create" | "delete"
105
+ >;
106
+
107
+ export type ApplicationPasswordsParams<
108
+ T extends ApplicationPasswordsOperations
109
+ > = {
110
+ get: Parameters<ApplicationPasswordsCrud["get"]>;
111
+ update: Parameters<ApplicationPasswordsCrud["update"]>;
112
+ list: Parameters<ApplicationPasswordsCrud["list"]>;
113
+ create: Parameters<ApplicationPasswordsCrud["create"]>;
114
+ delete: Parameters<ApplicationPasswordsCrud["delete"]>;
115
+ }[T];
116
+
117
+ export type SettingsParams<T extends SettingsOperations> = {
118
+ get: Parameters<SettingsCrud["get"]>;
119
+ update: Parameters<SettingsCrud["update"]>;
120
+ }[T];
121
+
100
122
  export type CommentOperations = Operation;
101
123
 
102
124
  export type CommentParams<T extends CommentOperations> = {
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ export declare const applicationPassword: z.ZodObject<{
3
+ uuid: z.ZodString;
4
+ app_id: z.ZodString;
5
+ name: z.ZodString;
6
+ password: z.ZodString;
7
+ created: z.ZodNumber;
8
+ last_used: z.ZodNullable<z.ZodNumber>;
9
+ last_ip: z.ZodNullable<z.ZodString>;
10
+ }, z.core.$strip>;
11
+ //# sourceMappingURL=application-password.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-password.d.ts","sourceRoot":"","sources":["../../src/validators/application-password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,eAAO,MAAM,mBAAmB;;;;;;;;iBAc9B,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applicationPassword = void 0;
4
+ const zod_1 = require("zod");
5
+ /*
6
+ * @param array $passwords {
7
+ * The list of application passwords.
8
+ *
9
+ * @type array ...$0 {
10
+ * @type string $uuid The unique identifier for the application password.
11
+ * @type string $app_id A UUID provided by the application to uniquely identify it.
12
+ * @type string $name The name of the application password.
13
+ * @type string $password A one-way hash of the password.
14
+ * @type int $created Unix timestamp of when the password was created.
15
+ * @type int|null $last_used The Unix timestamp of the GMT date the application password was last used.
16
+ * @type string|null $last_ip The IP address the application password was last used by.
17
+ * }
18
+ * }
19
+ *
20
+ */
21
+ exports.applicationPassword = zod_1.z.object({
22
+ uuid: zod_1.z.string(),
23
+ app_id: zod_1.z.string(),
24
+ name: zod_1.z.string().min(2).max(100),
25
+ password: zod_1.z.string().min(8).max(100),
26
+ created: zod_1.z.number().min(0),
27
+ last_used: zod_1.z.number().min(0).nullable(),
28
+ last_ip: zod_1.z
29
+ .string()
30
+ // .regex(
31
+ // /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
32
+ // { message: "Invalid IPv4 address" }
33
+ // )
34
+ .nullable(),
35
+ });
@@ -20,6 +20,7 @@ export declare const config: z.ZodObject<{
20
20
  error: "error";
21
21
  }>>>;
22
22
  }, z.core.$strip>;
23
+ useApplicationPasswords: z.ZodDefault<z.ZodBoolean>;
23
24
  extensions: z.ZodObject<{
24
25
  misc: z.ZodArray<z.ZodString>;
25
26
  audio: z.ZodArray<z.ZodString>;
@@ -168,6 +169,7 @@ export declare const configs: z.ZodRecord<z.ZodString, z.ZodObject<{
168
169
  error: "error";
169
170
  }>>>;
170
171
  }, z.core.$strip>;
172
+ useApplicationPasswords: z.ZodDefault<z.ZodBoolean>;
171
173
  extensions: z.ZodObject<{
172
174
  misc: z.ZodArray<z.ZodString>;
173
175
  audio: z.ZodArray<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/validators/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuHjB,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAA+B,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/validators/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwHjB,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAA+B,CAAC"}
@@ -57,6 +57,7 @@ exports.config = zod_1.z.object({
57
57
  .optional()
58
58
  .default("info"),
59
59
  }),
60
+ useApplicationPasswords: zod_1.z.boolean().default(true),
60
61
  extensions: zod_1.z.object({
61
62
  misc: zod_1.z.array(zod_1.z.string()),
62
63
  audio: zod_1.z.array(zod_1.z.string()),
@@ -7,4 +7,5 @@ export * as crud from "./crud";
7
7
  export * from "./options";
8
8
  export * from "./sitemeta";
9
9
  export * as helpers from "./helpers";
10
+ export * from "./application-password";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,wBAAwB,CAAC"}
@@ -46,3 +46,4 @@ exports.crud = __importStar(require("./crud"));
46
46
  __exportStar(require("./options"), exports);
47
47
  __exportStar(require("./sitemeta"), exports);
48
48
  exports.helpers = __importStar(require("./helpers"));
49
+ __exportStar(require("./application-password"), exports);