@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.
- package/README.md +20 -0
- package/dist/date-and-time/calculate.d.ts +3 -0
- package/dist/date-and-time/calculate.d.ts.map +1 -0
- package/dist/date-and-time/calculate.js +12 -0
- package/dist/date-and-time/calculate.js.map +1 -0
- package/dist/date-and-time/format.d.ts +2 -0
- package/dist/date-and-time/format.d.ts.map +1 -0
- package/dist/date-and-time/format.js +2 -0
- package/dist/date-and-time/format.js.map +1 -0
- package/dist/date-and-time/index.d.ts +3 -0
- package/dist/date-and-time/index.d.ts.map +1 -0
- package/dist/date-and-time/index.js +4 -0
- package/dist/date-and-time/index.js.map +1 -0
- package/dist/encoding/index.d.ts +2 -0
- package/dist/encoding/index.d.ts.map +1 -0
- package/dist/encoding/index.js +2 -0
- package/dist/encoding/index.js.map +1 -0
- package/dist/encoding/stringBySecret.d.ts +3 -0
- package/dist/encoding/stringBySecret.d.ts.map +1 -0
- package/dist/encoding/stringBySecret.js +30 -0
- package/dist/encoding/stringBySecret.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +5 -0
- package/dist/services/index.js.map +1 -0
- package/dist/strings/index.d.ts +2 -0
- package/dist/strings/index.d.ts.map +1 -0
- package/dist/strings/index.js +5 -0
- package/dist/strings/index.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- 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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/date-and-time/format.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/date-and-time/format.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encoding/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/encoding/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
|
@@ -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
|
+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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"}
|
package/dist/index.d.ts
ADDED
|
@@ -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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/strings/index.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -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
|
+
}
|