@memberjunction/core-actions 2.53.0 → 2.55.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/custom/ai/execute-ai-prompt.action.d.ts +94 -0
- package/dist/custom/ai/execute-ai-prompt.action.d.ts.map +1 -0
- package/dist/custom/ai/execute-ai-prompt.action.js +274 -0
- package/dist/custom/ai/execute-ai-prompt.action.js.map +1 -0
- package/dist/custom/communication/slack-webhook.action.d.ts +101 -0
- package/dist/custom/communication/slack-webhook.action.d.ts.map +1 -0
- package/dist/custom/communication/slack-webhook.action.js +269 -0
- package/dist/custom/communication/slack-webhook.action.js.map +1 -0
- package/dist/custom/communication/teams-webhook.action.d.ts +96 -0
- package/dist/custom/communication/teams-webhook.action.d.ts.map +1 -0
- package/dist/custom/communication/teams-webhook.action.js +275 -0
- package/dist/custom/communication/teams-webhook.action.js.map +1 -0
- package/dist/custom/data/aggregate-data.action.d.ts +91 -0
- package/dist/custom/data/aggregate-data.action.d.ts.map +1 -0
- package/dist/custom/data/aggregate-data.action.js +333 -0
- package/dist/custom/data/aggregate-data.action.js.map +1 -0
- package/dist/custom/data/csv-parser.action.d.ts +68 -0
- package/dist/custom/data/csv-parser.action.d.ts.map +1 -0
- package/dist/custom/data/csv-parser.action.js +184 -0
- package/dist/custom/data/csv-parser.action.js.map +1 -0
- package/dist/custom/data/data-mapper.action.d.ts +89 -0
- package/dist/custom/data/data-mapper.action.d.ts.map +1 -0
- package/dist/custom/data/data-mapper.action.js +325 -0
- package/dist/custom/data/data-mapper.action.js.map +1 -0
- package/dist/custom/data/json-transform.action.d.ts +57 -0
- package/dist/custom/data/json-transform.action.d.ts.map +1 -0
- package/dist/custom/data/json-transform.action.js +205 -0
- package/dist/custom/data/json-transform.action.js.map +1 -0
- package/dist/custom/data/xml-parser.action.d.ts +85 -0
- package/dist/custom/data/xml-parser.action.d.ts.map +1 -0
- package/dist/custom/data/xml-parser.action.js +326 -0
- package/dist/custom/data/xml-parser.action.js.map +1 -0
- package/dist/custom/files/excel-reader.action.d.ts +86 -0
- package/dist/custom/files/excel-reader.action.d.ts.map +1 -0
- package/dist/custom/files/excel-reader.action.js +348 -0
- package/dist/custom/files/excel-reader.action.js.map +1 -0
- package/dist/custom/files/excel-writer.action.d.ts +79 -0
- package/dist/custom/files/excel-writer.action.d.ts.map +1 -0
- package/dist/custom/files/excel-writer.action.js +325 -0
- package/dist/custom/files/excel-writer.action.js.map +1 -0
- package/dist/custom/files/file-compress.action.d.ts +90 -0
- package/dist/custom/files/file-compress.action.d.ts.map +1 -0
- package/dist/custom/files/file-compress.action.js +346 -0
- package/dist/custom/files/file-compress.action.js.map +1 -0
- package/dist/custom/files/pdf-extractor.action.d.ts +86 -0
- package/dist/custom/files/pdf-extractor.action.d.ts.map +1 -0
- package/dist/custom/files/pdf-extractor.action.js +247 -0
- package/dist/custom/files/pdf-extractor.action.js.map +1 -0
- package/dist/custom/files/pdf-generator.action.d.ts +70 -0
- package/dist/custom/files/pdf-generator.action.d.ts.map +1 -0
- package/dist/custom/files/pdf-generator.action.js +286 -0
- package/dist/custom/files/pdf-generator.action.js.map +1 -0
- package/dist/custom/integration/api-rate-limiter.action.d.ts +88 -0
- package/dist/custom/integration/api-rate-limiter.action.d.ts.map +1 -0
- package/dist/custom/integration/api-rate-limiter.action.js +363 -0
- package/dist/custom/integration/api-rate-limiter.action.js.map +1 -0
- package/dist/custom/integration/graphql-query.action.d.ts +92 -0
- package/dist/custom/integration/graphql-query.action.d.ts.map +1 -0
- package/dist/custom/integration/graphql-query.action.js +251 -0
- package/dist/custom/integration/graphql-query.action.js.map +1 -0
- package/dist/custom/integration/http-request.action.d.ts +96 -0
- package/dist/custom/integration/http-request.action.d.ts.map +1 -0
- package/dist/custom/integration/http-request.action.js +316 -0
- package/dist/custom/integration/http-request.action.js.map +1 -0
- package/dist/custom/integration/oauth-flow.action.d.ts +130 -0
- package/dist/custom/integration/oauth-flow.action.d.ts.map +1 -0
- package/dist/custom/integration/oauth-flow.action.js +624 -0
- package/dist/custom/integration/oauth-flow.action.js.map +1 -0
- package/dist/custom/security/password-strength.action.d.ts +129 -0
- package/dist/custom/security/password-strength.action.d.ts.map +1 -0
- package/dist/custom/security/password-strength.action.js +463 -0
- package/dist/custom/security/password-strength.action.js.map +1 -0
- package/dist/custom/utilities/base-file-handler.d.ts +54 -0
- package/dist/custom/utilities/base-file-handler.d.ts.map +1 -0
- package/dist/custom/utilities/base-file-handler.js +167 -0
- package/dist/custom/utilities/base-file-handler.js.map +1 -0
- package/dist/custom/utilities/index.d.ts +3 -0
- package/dist/custom/utilities/index.d.ts.map +1 -0
- package/dist/custom/utilities/index.js +19 -0
- package/dist/custom/utilities/index.js.map +1 -0
- package/dist/custom/utilities/json-param-helper.d.ts +33 -0
- package/dist/custom/utilities/json-param-helper.d.ts.map +1 -0
- package/dist/custom/utilities/json-param-helper.js +66 -0
- package/dist/custom/utilities/json-param-helper.js.map +1 -0
- package/dist/custom/web/duckduckgo-rate-limiter.d.ts +72 -0
- package/dist/custom/web/duckduckgo-rate-limiter.d.ts.map +1 -0
- package/dist/custom/web/duckduckgo-rate-limiter.js +175 -0
- package/dist/custom/web/duckduckgo-rate-limiter.js.map +1 -0
- package/dist/custom/web/web-search.action.d.ts +1 -0
- package/dist/custom/web/web-search.action.d.ts.map +1 -1
- package/dist/custom/web/web-search.action.js +48 -20
- package/dist/custom/web/web-search.action.js.map +1 -1
- package/dist/custom/workflow/conditional.action.d.ts +94 -0
- package/dist/custom/workflow/conditional.action.d.ts.map +1 -0
- package/dist/custom/workflow/conditional.action.js +274 -0
- package/dist/custom/workflow/conditional.action.js.map +1 -0
- package/dist/custom/workflow/delay.action.d.ts +76 -0
- package/dist/custom/workflow/delay.action.d.ts.map +1 -0
- package/dist/custom/workflow/delay.action.js +187 -0
- package/dist/custom/workflow/delay.action.js.map +1 -0
- package/dist/custom/workflow/loop.action.d.ts +112 -0
- package/dist/custom/workflow/loop.action.d.ts.map +1 -0
- package/dist/custom/workflow/loop.action.js +380 -0
- package/dist/custom/workflow/loop.action.js.map +1 -0
- package/dist/custom/workflow/parallel-execute.action.d.ts +105 -0
- package/dist/custom/workflow/parallel-execute.action.d.ts.map +1 -0
- package/dist/custom/workflow/parallel-execute.action.js +457 -0
- package/dist/custom/workflow/parallel-execute.action.js.map +1 -0
- package/dist/custom/workflow/retry.action.d.ts +90 -0
- package/dist/custom/workflow/retry.action.d.ts.map +1 -0
- package/dist/custom/workflow/retry.action.js +378 -0
- package/dist/custom/workflow/retry.action.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -1
- package/package.json +25 -10
- package/readme.md +11270 -101
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Action that checks password strength and generates secure passwords
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Check password strength
|
|
9
|
+
* await runAction({
|
|
10
|
+
* ActionName: 'Password Strength',
|
|
11
|
+
* Params: [{
|
|
12
|
+
* Name: 'Operation',
|
|
13
|
+
* Value: 'check'
|
|
14
|
+
* }, {
|
|
15
|
+
* Name: 'Password',
|
|
16
|
+
* Value: 'MyPassword123!'
|
|
17
|
+
* }, {
|
|
18
|
+
* Name: 'UserInputs',
|
|
19
|
+
* Value: ['john', 'doe', 'john.doe@example.com']
|
|
20
|
+
* }]
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Generate secure password
|
|
24
|
+
* await runAction({
|
|
25
|
+
* ActionName: 'Password Strength',
|
|
26
|
+
* Params: [{
|
|
27
|
+
* Name: 'Operation',
|
|
28
|
+
* Value: 'generate'
|
|
29
|
+
* }, {
|
|
30
|
+
* Name: 'Length',
|
|
31
|
+
* Value: 16
|
|
32
|
+
* }, {
|
|
33
|
+
* Name: 'IncludeSymbols',
|
|
34
|
+
* Value: true
|
|
35
|
+
* }, {
|
|
36
|
+
* Name: 'ExcludeAmbiguous',
|
|
37
|
+
* Value: true
|
|
38
|
+
* }]
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Generate with requirements
|
|
42
|
+
* await runAction({
|
|
43
|
+
* ActionName: 'Password Strength',
|
|
44
|
+
* Params: [{
|
|
45
|
+
* Name: 'Operation',
|
|
46
|
+
* Value: 'generate'
|
|
47
|
+
* }, {
|
|
48
|
+
* Name: 'Requirements',
|
|
49
|
+
* Value: {
|
|
50
|
+
* minLength: 12,
|
|
51
|
+
* maxLength: 20,
|
|
52
|
+
* minLowercase: 2,
|
|
53
|
+
* minUppercase: 2,
|
|
54
|
+
* minNumbers: 2,
|
|
55
|
+
* minSymbols: 1
|
|
56
|
+
* }
|
|
57
|
+
* }]
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class PasswordStrengthAction extends BaseAction {
|
|
62
|
+
private readonly lowercase;
|
|
63
|
+
private readonly uppercase;
|
|
64
|
+
private readonly numbers;
|
|
65
|
+
private readonly symbols;
|
|
66
|
+
private readonly ambiguous;
|
|
67
|
+
/**
|
|
68
|
+
* Checks password strength or generates secure passwords
|
|
69
|
+
*
|
|
70
|
+
* @param params - The action parameters containing:
|
|
71
|
+
* - Operation: "check" | "generate" (required)
|
|
72
|
+
* - For check operation:
|
|
73
|
+
* - Password: Password to check (required)
|
|
74
|
+
* - UserInputs: Array of user-related strings to check against (optional)
|
|
75
|
+
* - Requirements: Object with minimum requirements (optional)
|
|
76
|
+
* - For generate operation:
|
|
77
|
+
* - Length: Password length (default: 16)
|
|
78
|
+
* - IncludeUppercase: Include uppercase letters (default: true)
|
|
79
|
+
* - IncludeLowercase: Include lowercase letters (default: true)
|
|
80
|
+
* - IncludeNumbers: Include numbers (default: true)
|
|
81
|
+
* - IncludeSymbols: Include symbols (default: true)
|
|
82
|
+
* - ExcludeAmbiguous: Exclude ambiguous characters (default: false)
|
|
83
|
+
* - Requirements: Object with specific requirements
|
|
84
|
+
*
|
|
85
|
+
* @returns Password strength analysis or generated password
|
|
86
|
+
*/
|
|
87
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
88
|
+
/**
|
|
89
|
+
* Check password strength using zxcvbn
|
|
90
|
+
*/
|
|
91
|
+
private checkPasswordStrength;
|
|
92
|
+
/**
|
|
93
|
+
* Generate a secure password
|
|
94
|
+
*/
|
|
95
|
+
private generatePassword;
|
|
96
|
+
/**
|
|
97
|
+
* Check if password meets requirements
|
|
98
|
+
*/
|
|
99
|
+
private checkRequirements;
|
|
100
|
+
/**
|
|
101
|
+
* Check for sequential characters
|
|
102
|
+
*/
|
|
103
|
+
private hasSequential;
|
|
104
|
+
/**
|
|
105
|
+
* Get random characters from charset
|
|
106
|
+
*/
|
|
107
|
+
private getRandomChars;
|
|
108
|
+
/**
|
|
109
|
+
* Shuffle string using Fisher-Yates algorithm
|
|
110
|
+
*/
|
|
111
|
+
private shuffleString;
|
|
112
|
+
/**
|
|
113
|
+
* Get numeric parameter with default
|
|
114
|
+
*/
|
|
115
|
+
private getNumericParam;
|
|
116
|
+
/**
|
|
117
|
+
* Get boolean parameter with default
|
|
118
|
+
*/
|
|
119
|
+
private getBooleanParam;
|
|
120
|
+
/**
|
|
121
|
+
* Get parameter value by name (case-insensitive)
|
|
122
|
+
*/
|
|
123
|
+
private getParamValue;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Loader function to ensure the PasswordStrengthAction class is included in the bundle
|
|
127
|
+
*/
|
|
128
|
+
export declare function LoadPasswordStrengthAction(): void;
|
|
129
|
+
//# sourceMappingURL=password-strength.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-strength.action.d.ts","sourceRoot":"","sources":["../../../src/custom/security/password-strength.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,qBACa,sBAAuB,SAAQ,UAAU;IAGlD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAC1D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IAEvC;;;;;;;;;;;;;;;;;;;OAmBG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2BvF;;OAEG;YACW,qBAAqB;IAgFnC;;OAEG;YACW,gBAAgB;IA0I9B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA0CzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAsBrB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,aAAa;IAYrB;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACH,OAAO,CAAC,aAAa;CAIxB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,SAEzC"}
|
|
@@ -0,0 +1,463 @@
|
|
|
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.LoadPasswordStrengthAction = exports.PasswordStrengthAction = void 0;
|
|
33
|
+
const global_1 = require("@memberjunction/global");
|
|
34
|
+
const actions_1 = require("@memberjunction/actions");
|
|
35
|
+
const zxcvbn = __importStar(require("zxcvbn"));
|
|
36
|
+
const crypto = __importStar(require("crypto"));
|
|
37
|
+
const json_param_helper_1 = require("../utilities/json-param-helper");
|
|
38
|
+
/**
|
|
39
|
+
* Action that checks password strength and generates secure passwords
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Check password strength
|
|
44
|
+
* await runAction({
|
|
45
|
+
* ActionName: 'Password Strength',
|
|
46
|
+
* Params: [{
|
|
47
|
+
* Name: 'Operation',
|
|
48
|
+
* Value: 'check'
|
|
49
|
+
* }, {
|
|
50
|
+
* Name: 'Password',
|
|
51
|
+
* Value: 'MyPassword123!'
|
|
52
|
+
* }, {
|
|
53
|
+
* Name: 'UserInputs',
|
|
54
|
+
* Value: ['john', 'doe', 'john.doe@example.com']
|
|
55
|
+
* }]
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* // Generate secure password
|
|
59
|
+
* await runAction({
|
|
60
|
+
* ActionName: 'Password Strength',
|
|
61
|
+
* Params: [{
|
|
62
|
+
* Name: 'Operation',
|
|
63
|
+
* Value: 'generate'
|
|
64
|
+
* }, {
|
|
65
|
+
* Name: 'Length',
|
|
66
|
+
* Value: 16
|
|
67
|
+
* }, {
|
|
68
|
+
* Name: 'IncludeSymbols',
|
|
69
|
+
* Value: true
|
|
70
|
+
* }, {
|
|
71
|
+
* Name: 'ExcludeAmbiguous',
|
|
72
|
+
* Value: true
|
|
73
|
+
* }]
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* // Generate with requirements
|
|
77
|
+
* await runAction({
|
|
78
|
+
* ActionName: 'Password Strength',
|
|
79
|
+
* Params: [{
|
|
80
|
+
* Name: 'Operation',
|
|
81
|
+
* Value: 'generate'
|
|
82
|
+
* }, {
|
|
83
|
+
* Name: 'Requirements',
|
|
84
|
+
* Value: {
|
|
85
|
+
* minLength: 12,
|
|
86
|
+
* maxLength: 20,
|
|
87
|
+
* minLowercase: 2,
|
|
88
|
+
* minUppercase: 2,
|
|
89
|
+
* minNumbers: 2,
|
|
90
|
+
* minSymbols: 1
|
|
91
|
+
* }
|
|
92
|
+
* }]
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
let PasswordStrengthAction = class PasswordStrengthAction extends actions_1.BaseAction {
|
|
97
|
+
// Character sets for password generation
|
|
98
|
+
lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
|
99
|
+
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
100
|
+
numbers = '0123456789';
|
|
101
|
+
symbols = '!@#$%^&*()_+-=[]{}|;:,.<>?';
|
|
102
|
+
ambiguous = 'il1Lo0O';
|
|
103
|
+
/**
|
|
104
|
+
* Checks password strength or generates secure passwords
|
|
105
|
+
*
|
|
106
|
+
* @param params - The action parameters containing:
|
|
107
|
+
* - Operation: "check" | "generate" (required)
|
|
108
|
+
* - For check operation:
|
|
109
|
+
* - Password: Password to check (required)
|
|
110
|
+
* - UserInputs: Array of user-related strings to check against (optional)
|
|
111
|
+
* - Requirements: Object with minimum requirements (optional)
|
|
112
|
+
* - For generate operation:
|
|
113
|
+
* - Length: Password length (default: 16)
|
|
114
|
+
* - IncludeUppercase: Include uppercase letters (default: true)
|
|
115
|
+
* - IncludeLowercase: Include lowercase letters (default: true)
|
|
116
|
+
* - IncludeNumbers: Include numbers (default: true)
|
|
117
|
+
* - IncludeSymbols: Include symbols (default: true)
|
|
118
|
+
* - ExcludeAmbiguous: Exclude ambiguous characters (default: false)
|
|
119
|
+
* - Requirements: Object with specific requirements
|
|
120
|
+
*
|
|
121
|
+
* @returns Password strength analysis or generated password
|
|
122
|
+
*/
|
|
123
|
+
async InternalRunAction(params) {
|
|
124
|
+
try {
|
|
125
|
+
const operation = (this.getParamValue(params, 'operation') || '').toLowerCase();
|
|
126
|
+
if (!['check', 'generate'].includes(operation)) {
|
|
127
|
+
return {
|
|
128
|
+
Success: false,
|
|
129
|
+
Message: "Operation must be 'check' or 'generate'",
|
|
130
|
+
ResultCode: "INVALID_OPERATION"
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (operation === 'check') {
|
|
134
|
+
return await this.checkPasswordStrength(params);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return await this.generatePassword(params);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
return {
|
|
142
|
+
Success: false,
|
|
143
|
+
Message: `Password operation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
144
|
+
ResultCode: "OPERATION_FAILED"
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check password strength using zxcvbn
|
|
150
|
+
*/
|
|
151
|
+
async checkPasswordStrength(params) {
|
|
152
|
+
const password = this.getParamValue(params, 'password');
|
|
153
|
+
const userInputs = this.getParamValue(params, 'userinputs') || [];
|
|
154
|
+
const requirements = json_param_helper_1.JSONParamHelper.getJSONParam(params, 'requirements') || {};
|
|
155
|
+
if (!password) {
|
|
156
|
+
return {
|
|
157
|
+
Success: false,
|
|
158
|
+
Message: "Password parameter is required for check operation",
|
|
159
|
+
ResultCode: "MISSING_PASSWORD"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
// Check password with zxcvbn
|
|
163
|
+
const result = zxcvbn(password, userInputs);
|
|
164
|
+
// Check against requirements
|
|
165
|
+
const requirementResults = this.checkRequirements(password, requirements);
|
|
166
|
+
// Determine overall pass/fail
|
|
167
|
+
const meetsRequirements = Object.values(requirementResults).every(r => r === true);
|
|
168
|
+
const isStrong = result.score >= 3 && meetsRequirements;
|
|
169
|
+
// Get feedback
|
|
170
|
+
const feedback = {
|
|
171
|
+
warning: result.feedback.warning || '',
|
|
172
|
+
suggestions: result.feedback.suggestions || []
|
|
173
|
+
};
|
|
174
|
+
// Add output parameters
|
|
175
|
+
params.Params.push({
|
|
176
|
+
Name: 'Score',
|
|
177
|
+
Type: 'Output',
|
|
178
|
+
Value: result.score
|
|
179
|
+
});
|
|
180
|
+
params.Params.push({
|
|
181
|
+
Name: 'CrackTime',
|
|
182
|
+
Type: 'Output',
|
|
183
|
+
Value: result.crack_times_display.offline_slow_hashing_1e4_per_second
|
|
184
|
+
});
|
|
185
|
+
params.Params.push({
|
|
186
|
+
Name: 'Feedback',
|
|
187
|
+
Type: 'Output',
|
|
188
|
+
Value: feedback
|
|
189
|
+
});
|
|
190
|
+
params.Params.push({
|
|
191
|
+
Name: 'RequirementResults',
|
|
192
|
+
Type: 'Output',
|
|
193
|
+
Value: requirementResults
|
|
194
|
+
});
|
|
195
|
+
params.Params.push({
|
|
196
|
+
Name: 'IsStrong',
|
|
197
|
+
Type: 'Output',
|
|
198
|
+
Value: isStrong
|
|
199
|
+
});
|
|
200
|
+
return {
|
|
201
|
+
Success: true,
|
|
202
|
+
ResultCode: isStrong ? "STRONG_PASSWORD" : "WEAK_PASSWORD",
|
|
203
|
+
Message: JSON.stringify({
|
|
204
|
+
score: result.score,
|
|
205
|
+
scoreText: ['Very Weak', 'Weak', 'Fair', 'Good', 'Strong'][result.score],
|
|
206
|
+
crackTime: result.crack_times_display.offline_slow_hashing_1e4_per_second,
|
|
207
|
+
guesses: result.guesses,
|
|
208
|
+
feedback: feedback,
|
|
209
|
+
sequence: result.sequence.map(s => ({
|
|
210
|
+
pattern: s.pattern,
|
|
211
|
+
token: s.token.replace(/./g, '*')
|
|
212
|
+
})),
|
|
213
|
+
requirementResults: requirementResults,
|
|
214
|
+
meetsAllRequirements: meetsRequirements,
|
|
215
|
+
isStrong: isStrong
|
|
216
|
+
}, null, 2)
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Generate a secure password
|
|
221
|
+
*/
|
|
222
|
+
async generatePassword(params) {
|
|
223
|
+
const length = this.getNumericParam(params, 'length', 16);
|
|
224
|
+
const includeUppercase = this.getBooleanParam(params, 'includeuppercase', true);
|
|
225
|
+
const includeLowercase = this.getBooleanParam(params, 'includelowercase', true);
|
|
226
|
+
const includeNumbers = this.getBooleanParam(params, 'includenumbers', true);
|
|
227
|
+
const includeSymbols = this.getBooleanParam(params, 'includesymbols', true);
|
|
228
|
+
const excludeAmbiguous = this.getBooleanParam(params, 'excludeambiguous', false);
|
|
229
|
+
const requirements = json_param_helper_1.JSONParamHelper.getJSONParam(params, 'requirements') || {};
|
|
230
|
+
// Validate length
|
|
231
|
+
const minLength = requirements.minLength || 8;
|
|
232
|
+
const maxLength = requirements.maxLength || 128;
|
|
233
|
+
const finalLength = Math.max(minLength, Math.min(length, maxLength));
|
|
234
|
+
if (finalLength < 4) {
|
|
235
|
+
return {
|
|
236
|
+
Success: false,
|
|
237
|
+
Message: "Password length must be at least 4 characters",
|
|
238
|
+
ResultCode: "INVALID_LENGTH"
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
// Build character set
|
|
242
|
+
let charset = '';
|
|
243
|
+
let requiredChars = '';
|
|
244
|
+
if (includeLowercase) {
|
|
245
|
+
charset += this.lowercase;
|
|
246
|
+
if (requirements.minLowercase > 0) {
|
|
247
|
+
requiredChars += this.getRandomChars(this.lowercase, requirements.minLowercase);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (includeUppercase) {
|
|
251
|
+
charset += this.uppercase;
|
|
252
|
+
if (requirements.minUppercase > 0) {
|
|
253
|
+
requiredChars += this.getRandomChars(this.uppercase, requirements.minUppercase);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (includeNumbers) {
|
|
257
|
+
charset += this.numbers;
|
|
258
|
+
if (requirements.minNumbers > 0) {
|
|
259
|
+
requiredChars += this.getRandomChars(this.numbers, requirements.minNumbers);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (includeSymbols) {
|
|
263
|
+
charset += this.symbols;
|
|
264
|
+
if (requirements.minSymbols > 0) {
|
|
265
|
+
requiredChars += this.getRandomChars(this.symbols, requirements.minSymbols);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (excludeAmbiguous) {
|
|
269
|
+
charset = charset.split('').filter(c => !this.ambiguous.includes(c)).join('');
|
|
270
|
+
}
|
|
271
|
+
if (charset.length === 0) {
|
|
272
|
+
return {
|
|
273
|
+
Success: false,
|
|
274
|
+
Message: "At least one character type must be included",
|
|
275
|
+
ResultCode: "NO_CHARSET"
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
// Generate password
|
|
279
|
+
let password = requiredChars;
|
|
280
|
+
const remainingLength = finalLength - password.length;
|
|
281
|
+
if (remainingLength < 0) {
|
|
282
|
+
return {
|
|
283
|
+
Success: false,
|
|
284
|
+
Message: "Cannot meet all requirements within specified length",
|
|
285
|
+
ResultCode: "REQUIREMENTS_TOO_STRICT"
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
// Add random characters
|
|
289
|
+
password += this.getRandomChars(charset, remainingLength);
|
|
290
|
+
// Shuffle password
|
|
291
|
+
password = this.shuffleString(password);
|
|
292
|
+
// Check the generated password
|
|
293
|
+
const checkResult = zxcvbn(password);
|
|
294
|
+
// Add output parameters
|
|
295
|
+
params.Params.push({
|
|
296
|
+
Name: 'GeneratedPassword',
|
|
297
|
+
Type: 'Output',
|
|
298
|
+
Value: password
|
|
299
|
+
});
|
|
300
|
+
params.Params.push({
|
|
301
|
+
Name: 'PasswordLength',
|
|
302
|
+
Type: 'Output',
|
|
303
|
+
Value: password.length
|
|
304
|
+
});
|
|
305
|
+
params.Params.push({
|
|
306
|
+
Name: 'PasswordScore',
|
|
307
|
+
Type: 'Output',
|
|
308
|
+
Value: checkResult.score
|
|
309
|
+
});
|
|
310
|
+
params.Params.push({
|
|
311
|
+
Name: 'CharacterSet',
|
|
312
|
+
Type: 'Output',
|
|
313
|
+
Value: {
|
|
314
|
+
hasLowercase: includeLowercase,
|
|
315
|
+
hasUppercase: includeUppercase,
|
|
316
|
+
hasNumbers: includeNumbers,
|
|
317
|
+
hasSymbols: includeSymbols,
|
|
318
|
+
excludedAmbiguous: excludeAmbiguous
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
return {
|
|
322
|
+
Success: true,
|
|
323
|
+
ResultCode: "PASSWORD_GENERATED",
|
|
324
|
+
Message: JSON.stringify({
|
|
325
|
+
message: "Secure password generated successfully",
|
|
326
|
+
length: password.length,
|
|
327
|
+
score: checkResult.score,
|
|
328
|
+
scoreText: ['Very Weak', 'Weak', 'Fair', 'Good', 'Strong'][checkResult.score],
|
|
329
|
+
characterSet: {
|
|
330
|
+
hasLowercase: includeLowercase,
|
|
331
|
+
hasUppercase: includeUppercase,
|
|
332
|
+
hasNumbers: includeNumbers,
|
|
333
|
+
hasSymbols: includeSymbols,
|
|
334
|
+
excludedAmbiguous: excludeAmbiguous
|
|
335
|
+
},
|
|
336
|
+
meetsRequirements: this.checkRequirements(password, requirements)
|
|
337
|
+
}, null, 2)
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Check if password meets requirements
|
|
342
|
+
*/
|
|
343
|
+
checkRequirements(password, requirements) {
|
|
344
|
+
const results = {};
|
|
345
|
+
if (requirements.minLength) {
|
|
346
|
+
results.minLength = password.length >= requirements.minLength;
|
|
347
|
+
}
|
|
348
|
+
if (requirements.maxLength) {
|
|
349
|
+
results.maxLength = password.length <= requirements.maxLength;
|
|
350
|
+
}
|
|
351
|
+
if (requirements.minLowercase) {
|
|
352
|
+
const count = (password.match(/[a-z]/g) || []).length;
|
|
353
|
+
results.minLowercase = count >= requirements.minLowercase;
|
|
354
|
+
}
|
|
355
|
+
if (requirements.minUppercase) {
|
|
356
|
+
const count = (password.match(/[A-Z]/g) || []).length;
|
|
357
|
+
results.minUppercase = count >= requirements.minUppercase;
|
|
358
|
+
}
|
|
359
|
+
if (requirements.minNumbers) {
|
|
360
|
+
const count = (password.match(/[0-9]/g) || []).length;
|
|
361
|
+
results.minNumbers = count >= requirements.minNumbers;
|
|
362
|
+
}
|
|
363
|
+
if (requirements.minSymbols) {
|
|
364
|
+
const count = (password.match(/[^a-zA-Z0-9]/g) || []).length;
|
|
365
|
+
results.minSymbols = count >= requirements.minSymbols;
|
|
366
|
+
}
|
|
367
|
+
if (requirements.noRepeating) {
|
|
368
|
+
results.noRepeating = !(/(.)\1{2,}/.test(password));
|
|
369
|
+
}
|
|
370
|
+
if (requirements.noSequential) {
|
|
371
|
+
results.noSequential = !this.hasSequential(password);
|
|
372
|
+
}
|
|
373
|
+
return results;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Check for sequential characters
|
|
377
|
+
*/
|
|
378
|
+
hasSequential(password) {
|
|
379
|
+
const sequences = [
|
|
380
|
+
'abcdefghijklmnopqrstuvwxyz',
|
|
381
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
|
382
|
+
'0123456789',
|
|
383
|
+
'qwertyuiop',
|
|
384
|
+
'asdfghjkl',
|
|
385
|
+
'zxcvbnm'
|
|
386
|
+
];
|
|
387
|
+
for (const seq of sequences) {
|
|
388
|
+
for (let i = 0; i < password.length - 2; i++) {
|
|
389
|
+
const substr = password.substring(i, i + 3);
|
|
390
|
+
if (seq.includes(substr) || seq.includes(substr.split('').reverse().join(''))) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Get random characters from charset
|
|
399
|
+
*/
|
|
400
|
+
getRandomChars(charset, length) {
|
|
401
|
+
let result = '';
|
|
402
|
+
const bytes = crypto.randomBytes(length);
|
|
403
|
+
for (let i = 0; i < length; i++) {
|
|
404
|
+
result += charset[bytes[i] % charset.length];
|
|
405
|
+
}
|
|
406
|
+
return result;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Shuffle string using Fisher-Yates algorithm
|
|
410
|
+
*/
|
|
411
|
+
shuffleString(str) {
|
|
412
|
+
const arr = str.split('');
|
|
413
|
+
const bytes = crypto.randomBytes(arr.length);
|
|
414
|
+
for (let i = arr.length - 1; i > 0; i--) {
|
|
415
|
+
const j = bytes[i] % (i + 1);
|
|
416
|
+
[arr[i], arr[j]] = [arr[j], arr[i]];
|
|
417
|
+
}
|
|
418
|
+
return arr.join('');
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Get numeric parameter with default
|
|
422
|
+
*/
|
|
423
|
+
getNumericParam(params, name, defaultValue) {
|
|
424
|
+
const value = this.getParamValue(params, name);
|
|
425
|
+
if (value === undefined || value === null)
|
|
426
|
+
return defaultValue;
|
|
427
|
+
const num = Number(value);
|
|
428
|
+
return isNaN(num) ? defaultValue : num;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Get boolean parameter with default
|
|
432
|
+
*/
|
|
433
|
+
getBooleanParam(params, name, defaultValue) {
|
|
434
|
+
const value = this.getParamValue(params, name);
|
|
435
|
+
if (value === undefined || value === null)
|
|
436
|
+
return defaultValue;
|
|
437
|
+
if (typeof value === 'boolean')
|
|
438
|
+
return value;
|
|
439
|
+
if (typeof value === 'string') {
|
|
440
|
+
return value.toLowerCase() === 'true';
|
|
441
|
+
}
|
|
442
|
+
return defaultValue;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Get parameter value by name (case-insensitive)
|
|
446
|
+
*/
|
|
447
|
+
getParamValue(params, name) {
|
|
448
|
+
const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
|
|
449
|
+
return param?.Value;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
exports.PasswordStrengthAction = PasswordStrengthAction;
|
|
453
|
+
exports.PasswordStrengthAction = PasswordStrengthAction = __decorate([
|
|
454
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, "Password Strength")
|
|
455
|
+
], PasswordStrengthAction);
|
|
456
|
+
/**
|
|
457
|
+
* Loader function to ensure the PasswordStrengthAction class is included in the bundle
|
|
458
|
+
*/
|
|
459
|
+
function LoadPasswordStrengthAction() {
|
|
460
|
+
// Stub function to prevent tree shaking
|
|
461
|
+
}
|
|
462
|
+
exports.LoadPasswordStrengthAction = LoadPasswordStrengthAction;
|
|
463
|
+
//# sourceMappingURL=password-strength.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-strength.action.js","sourceRoot":"","sources":["../../../src/custom/security/password-strength.action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,+CAAiC;AACjC,+CAAiC;AACjC,sEAAiE;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,oBAAU;IAElD,yCAAyC;IACxB,SAAS,GAAG,4BAA4B,CAAC;IACzC,SAAS,GAAG,4BAA4B,CAAC;IACzC,OAAO,GAAG,YAAY,CAAC;IACvB,OAAO,GAAG,4BAA4B,CAAC;IACvC,SAAS,GAAG,SAAS,CAAC;IAEvC;;;;;;;;;;;;;;;;;;;OAmBG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;YAEhF,IAAI,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC7C,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,yCAAyC;oBAClD,UAAU,EAAE,mBAAmB;iBAClC,CAAC;YACN,CAAC;YAED,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;gBACxB,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACJ,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC/C,CAAC;QAEL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,OAA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KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;QAC1C,CAAC;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAuB,EAAE,IAAY;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACnF,OAAO,KAAK,EAAE,KAAK,CAAC;IACxB,CAAC;CACJ,CAAA;AAvZY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,sBAAa,EAAC,oBAAU,EAAE,mBAAmB,CAAC;GAClC,sBAAsB,CAuZlC;AAED;;GAEG;AACH,SAAgB,0BAA0B;IACtC,wCAAwC;AAC5C,CAAC;AAFD,gEAEC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
4
|
+
import { RunActionParams } from "@memberjunction/actions-base";
|
|
5
|
+
/**
|
|
6
|
+
* Base class for actions that handle file inputs from multiple sources
|
|
7
|
+
* Provides common functionality for loading files from:
|
|
8
|
+
* - MJ Storage (Document Libraries)
|
|
9
|
+
* - URLs
|
|
10
|
+
* - Direct data
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class BaseFileHandlerAction extends BaseAction {
|
|
13
|
+
/**
|
|
14
|
+
* Get file content from various sources based on parameters
|
|
15
|
+
* Priority: FileID > FileURL > Data parameter
|
|
16
|
+
*
|
|
17
|
+
* @param params - Action parameters
|
|
18
|
+
* @param dataParamName - Name of the parameter containing direct data
|
|
19
|
+
* @param fileParamName - Name of the parameter containing file ID (default: 'FileID')
|
|
20
|
+
* @param urlParamName - Name of the parameter containing file URL (default: 'FileURL')
|
|
21
|
+
* @returns Object with content and metadata
|
|
22
|
+
*/
|
|
23
|
+
protected getFileContent(params: RunActionParams, dataParamName: string, fileParamName?: string, urlParamName?: string): Promise<{
|
|
24
|
+
content: string | Buffer;
|
|
25
|
+
fileName?: string;
|
|
26
|
+
mimeType?: string;
|
|
27
|
+
source: 'storage' | 'url' | 'direct';
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Load file from MJ Storage (Document Libraries)
|
|
31
|
+
*/
|
|
32
|
+
private loadFromMJStorage;
|
|
33
|
+
/**
|
|
34
|
+
* Load file from URL
|
|
35
|
+
*/
|
|
36
|
+
private loadFromURL;
|
|
37
|
+
/**
|
|
38
|
+
* Save file to MJ Storage
|
|
39
|
+
*/
|
|
40
|
+
protected saveToMJStorage(content: string | Buffer, fileName: string, mimeType: string, params: RunActionParams): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Extract parameter value by name (case-insensitive)
|
|
43
|
+
*/
|
|
44
|
+
protected getParamValue(params: RunActionParams, paramName: string): any;
|
|
45
|
+
/**
|
|
46
|
+
* Get boolean parameter value with default
|
|
47
|
+
*/
|
|
48
|
+
protected getBooleanParam(params: RunActionParams, paramName: string, defaultValue?: boolean): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get numeric parameter value with default
|
|
51
|
+
*/
|
|
52
|
+
protected getNumericParam(params: RunActionParams, paramName: string, defaultValue?: number): number;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=base-file-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-file-handler.d.ts","sourceRoot":"","sources":["../../../src/custom/utilities/base-file-handler.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;;;;;GAMG;AACH,8BAAsB,qBAAsB,SAAQ,UAAU;IAC1D;;;;;;;;;OASG;cACa,cAAc,CAC1B,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,MAAM,EACrB,aAAa,GAAE,MAAiB,EAChC,YAAY,GAAE,MAAkB,GACjC,OAAO,CAAC;QACP,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,CAAC;KACxC,CAAC;IAyBF;;OAEG;YACW,iBAAiB;IAiC/B;;OAEG;YACW,WAAW;IAgDzB;;OAEG;cACa,eAAe,CAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;IA4BlB;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG;IAKxE;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO;IAM7G;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;CAM1G"}
|