@workwell-global/toolkit 1.0.1

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 (38) hide show
  1. package/README.md +20 -0
  2. package/dist/date-and-time/calculate.d.ts +3 -0
  3. package/dist/date-and-time/calculate.d.ts.map +1 -0
  4. package/dist/date-and-time/calculate.js +12 -0
  5. package/dist/date-and-time/calculate.js.map +1 -0
  6. package/dist/date-and-time/format.d.ts +2 -0
  7. package/dist/date-and-time/format.d.ts.map +1 -0
  8. package/dist/date-and-time/format.js +2 -0
  9. package/dist/date-and-time/format.js.map +1 -0
  10. package/dist/date-and-time/index.d.ts +3 -0
  11. package/dist/date-and-time/index.d.ts.map +1 -0
  12. package/dist/date-and-time/index.js +4 -0
  13. package/dist/date-and-time/index.js.map +1 -0
  14. package/dist/encoding/index.d.ts +2 -0
  15. package/dist/encoding/index.d.ts.map +1 -0
  16. package/dist/encoding/index.js +2 -0
  17. package/dist/encoding/index.js.map +1 -0
  18. package/dist/encoding/stringBySecret.d.ts +3 -0
  19. package/dist/encoding/stringBySecret.d.ts.map +1 -0
  20. package/dist/encoding/stringBySecret.js +30 -0
  21. package/dist/encoding/stringBySecret.js.map +1 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +3 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/services/index.d.ts +2 -0
  27. package/dist/services/index.d.ts.map +1 -0
  28. package/dist/services/index.js +5 -0
  29. package/dist/services/index.js.map +1 -0
  30. package/dist/strings/index.d.ts +2 -0
  31. package/dist/strings/index.d.ts.map +1 -0
  32. package/dist/strings/index.js +5 -0
  33. package/dist/strings/index.js.map +1 -0
  34. package/dist/types/index.d.ts +2 -0
  35. package/dist/types/index.d.ts.map +1 -0
  36. package/dist/types/index.js +5 -0
  37. package/dist/types/index.js.map +1 -0
  38. package/package.json +38 -0
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # Introduction
2
+ TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
3
+
4
+ # Getting Started
5
+ TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
6
+ 1. Installation process
7
+ 2. Software dependencies
8
+ 3. Latest releases
9
+ 4. API references
10
+
11
+ # Build and Test
12
+ TODO: Describe and show how to build your code and run the tests.
13
+
14
+ # Contribute
15
+ TODO: Explain how other users and developers can contribute to make your code better.
16
+
17
+ If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
18
+ - [ASP.NET Core](https://github.com/aspnet/Home)
19
+ - [Visual Studio Code](https://github.com/Microsoft/vscode)
20
+ - [Chakra Core](https://github.com/Microsoft/ChakraCore)
@@ -0,0 +1,3 @@
1
+ export declare const yesterday: () => number;
2
+ export declare const tomorrow: () => number;
3
+ //# sourceMappingURL=calculate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate.d.ts","sourceRoot":"","sources":["../../src/date-and-time/calculate.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,cAIrB,CAAA;AAED,eAAO,MAAM,QAAQ,cAIpB,CAAA"}
@@ -0,0 +1,12 @@
1
+ //local timezone by default
2
+ export const yesterday = () => {
3
+ //block scopes current Date
4
+ const currentDate = new Date();
5
+ return currentDate.setDate(currentDate.getDate() - 1);
6
+ };
7
+ export const tomorrow = () => {
8
+ //block scopes current Date
9
+ const currentDate = new Date();
10
+ return currentDate.setDate(currentDate.getDate() + 1);
11
+ };
12
+ //# sourceMappingURL=calculate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate.js","sourceRoot":"","sources":["../../src/date-and-time/calculate.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,2BAA2B;IAC3B,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAA;IAC9B,OAAO,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;AACvD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,2BAA2B;IAC3B,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAA;IAC9B,OAAO,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;AACvD,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/date-and-time/format.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/date-and-time/format.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './format.js';
2
+ export * from './calculate.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date-and-time/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,4 @@
1
+ // imports must be js files, but will auto map to ts files during build
2
+ export * from './format.js';
3
+ export * from './calculate.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/date-and-time/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './stringBySecret.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encoding/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './stringBySecret.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/encoding/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare function encryptString(data: string): string;
2
+ export declare function decryptString(encryptedData: string): string;
3
+ //# sourceMappingURL=stringBySecret.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringBySecret.d.ts","sourceRoot":"","sources":["../../src/encoding/stringBySecret.ts"],"names":[],"mappings":"AAIA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,UAczC;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,UAmBlD"}
@@ -0,0 +1,30 @@
1
+ import CryptoJS from 'crypto-js';
2
+ const secretKey = process.env.URL_ENCODE_SECRET_KEY || '';
3
+ export function encryptString(data) {
4
+ const iv = CryptoJS.lib.WordArray.random(16); // Generate a random IV
5
+ const encrypted = CryptoJS.AES.encrypt(data, CryptoJS.enc.Utf8.parse(secretKey), {
6
+ iv: iv,
7
+ mode: CryptoJS.mode.CBC,
8
+ padding: CryptoJS.pad.Pkcs7,
9
+ });
10
+ // Prepend the IV to the ciphertext
11
+ const result = iv.concat(encrypted.ciphertext);
12
+ return encodeURIComponent(result.toString(CryptoJS.enc.Base64));
13
+ }
14
+ export function decryptString(encryptedData) {
15
+ // First, replace any spaces that might have been converted from + signs
16
+ const fixedEncryptedData = encryptedData.replace(/ /g, '+');
17
+ const decodedData = decodeURIComponent(fixedEncryptedData);
18
+ const bytes = CryptoJS.enc.Base64.parse(decodedData);
19
+ const iv = bytes.clone();
20
+ iv.sigBytes = 16;
21
+ iv.clamp();
22
+ bytes.words.splice(0, 4); // remove IV from the ciphertext
23
+ bytes.sigBytes -= 16;
24
+ // console.log({ encryptedData })
25
+ const decrypted = CryptoJS.AES.decrypt(
26
+ // @ts-expect-error as this works fine
27
+ { ciphertext: bytes, salt: null }, CryptoJS.enc.Utf8.parse(secretKey), { iv: iv });
28
+ return decrypted.toString(CryptoJS.enc.Utf8);
29
+ }
30
+ //# sourceMappingURL=stringBySecret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringBySecret.js","sourceRoot":"","sources":["../../src/encoding/stringBySecret.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAA;AAEzD,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA,CAAC,uBAAuB;IACpE,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CACpC,IAAI,EACJ,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAClC;QACE,EAAE,EAAE,EAAE;QACN,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG;QACvB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK;KAC5B,CACF,CAAA;IACD,mCAAmC;IACnC,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IAC9C,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,aAAqB;IACjD,wEAAwE;IACxE,MAAM,kBAAkB,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAC3D,MAAM,WAAW,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;IAC1D,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IACpD,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;IACxB,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAA;IAChB,EAAE,CAAC,KAAK,EAAE,CAAA;IACV,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAC,gCAAgC;IACzD,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAA;IACpB,iCAAiC;IAEjC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO;IACpC,sCAAsC;IACtC,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EACjC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAClC,EAAE,EAAE,EAAE,EAAE,EAAE,CACX,CAAA;IACD,OAAO,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC9C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * as dateAndTime from './date-and-time/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ // imports must be js files, but will auto map to ts files during build
2
+ export * as dateAndTime from './date-and-time/index.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export {};
2
+ // export * from './format';
3
+ // export * from './parse';
4
+ // export * from './diff';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,2BAA2B;AAC3B,0BAA0B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/strings/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export {};
2
+ // export * from './format';
3
+ // export * from './parse';
4
+ // export * from './diff';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strings/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,2BAA2B;AAC3B,0BAA0B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export {};
2
+ // export * from './format';
3
+ // export * from './parse';
4
+ // export * from './diff';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,2BAA2B;AAC3B,0BAA0B"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "author": "",
3
+ "description": "Shared utilities and helpers for Workwell Global",
4
+ "keywords": [],
5
+ "license": "ISC",
6
+ "main": "dist/index.js",
7
+ "name": "@workwell-global/toolkit",
8
+ "type": "module",
9
+ "types": "dist/index.d.ts",
10
+ "version": "1.0.1",
11
+ "dependencies": {
12
+ "crypto-js": "^4.2.0"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^5.9.3",
16
+ "@types/node": "^22.0.0",
17
+ "@types/crypto-js": "^4.2.2"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://jsaservices@dev.azure.com/jsaservices/Workwell%20Global%20-%20package%20-%20toolkit/_git/Workwell%20Global%20-%20package%20-%20toolkit"
29
+ },
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "prepare": "npm run build",
33
+ "clean": "npm run clean:dist && npm run clean:node_modules",
34
+ "clean:dist": "rimraf dist",
35
+ "clean:node_modules": "find . -name node_modules | xargs rm -rf",
36
+ "typecheck": "tsc --noEmit"
37
+ }
38
+ }