edilkamin 1.7.2 → 1.7.4

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 (65) hide show
  1. package/.github/workflows/cli-tests.yml +6 -0
  2. package/.github/workflows/publish.yml +1 -1
  3. package/README.md +1 -1
  4. package/dist/cjs/package.json +84 -0
  5. package/dist/cjs/src/browser-bundle.test.js +64 -0
  6. package/dist/cjs/src/buffer-utils.js +78 -0
  7. package/dist/cjs/src/buffer-utils.test.js +186 -0
  8. package/dist/cjs/src/cli.js +253 -0
  9. package/dist/cjs/src/configureAmplify.test.js +42 -0
  10. package/dist/cjs/src/constants.js +9 -0
  11. package/dist/{esm → cjs/src}/index.d.ts +1 -2
  12. package/dist/cjs/src/index.js +22 -0
  13. package/dist/{esm → cjs/src}/library.d.ts +4 -4
  14. package/dist/cjs/src/library.js +324 -0
  15. package/dist/cjs/src/library.test.js +547 -0
  16. package/dist/cjs/src/serial-utils.js +50 -0
  17. package/dist/cjs/src/serial-utils.test.d.ts +1 -0
  18. package/dist/cjs/src/serial-utils.test.js +50 -0
  19. package/dist/cjs/src/token-storage.js +119 -0
  20. package/dist/cjs/src/types.js +2 -0
  21. package/dist/esm/package.json +84 -0
  22. package/dist/esm/src/browser-bundle.test.d.ts +1 -0
  23. package/dist/esm/src/browser-bundle.test.js +29 -0
  24. package/dist/esm/src/buffer-utils.d.ts +25 -0
  25. package/dist/esm/src/buffer-utils.test.d.ts +1 -0
  26. package/dist/esm/src/cli.d.ts +3 -0
  27. package/dist/esm/src/configureAmplify.test.d.ts +1 -0
  28. package/dist/esm/src/configureAmplify.test.js +37 -0
  29. package/dist/esm/src/constants.d.ts +4 -0
  30. package/dist/esm/src/index.d.ts +6 -0
  31. package/dist/esm/{index.js → src/index.js} +0 -1
  32. package/dist/esm/src/library.d.ts +55 -0
  33. package/dist/esm/{library.js → src/library.js} +59 -51
  34. package/dist/esm/src/library.test.d.ts +1 -0
  35. package/dist/esm/{library.test.js → src/library.test.js} +167 -190
  36. package/dist/esm/src/serial-utils.d.ts +33 -0
  37. package/dist/esm/src/serial-utils.test.d.ts +1 -0
  38. package/dist/esm/src/token-storage.d.ts +14 -0
  39. package/dist/esm/src/types.d.ts +73 -0
  40. package/dist/esm/src/types.js +1 -0
  41. package/package.json +19 -7
  42. package/src/browser-bundle.test.ts +21 -0
  43. package/src/configureAmplify.test.ts +47 -0
  44. package/src/index.ts +0 -1
  45. package/src/library.test.ts +195 -197
  46. package/src/library.ts +76 -62
  47. package/tsconfig.cjs.json +2 -2
  48. package/tsconfig.json +2 -3
  49. /package/dist/{esm/buffer-utils.test.d.ts → cjs/src/browser-bundle.test.d.ts} +0 -0
  50. /package/dist/{esm → cjs/src}/buffer-utils.d.ts +0 -0
  51. /package/dist/{esm/library.test.d.ts → cjs/src/buffer-utils.test.d.ts} +0 -0
  52. /package/dist/{esm → cjs/src}/cli.d.ts +0 -0
  53. /package/dist/{esm/serial-utils.test.d.ts → cjs/src/configureAmplify.test.d.ts} +0 -0
  54. /package/dist/{esm → cjs/src}/constants.d.ts +0 -0
  55. /package/dist/{esm/types.js → cjs/src/library.test.d.ts} +0 -0
  56. /package/dist/{esm → cjs/src}/serial-utils.d.ts +0 -0
  57. /package/dist/{esm → cjs/src}/token-storage.d.ts +0 -0
  58. /package/dist/{esm → cjs/src}/types.d.ts +0 -0
  59. /package/dist/esm/{buffer-utils.js → src/buffer-utils.js} +0 -0
  60. /package/dist/esm/{buffer-utils.test.js → src/buffer-utils.test.js} +0 -0
  61. /package/dist/esm/{cli.js → src/cli.js} +0 -0
  62. /package/dist/esm/{constants.js → src/constants.js} +0 -0
  63. /package/dist/esm/{serial-utils.js → src/serial-utils.js} +0 -0
  64. /package/dist/esm/{serial-utils.test.js → src/serial-utils.test.js} +0 -0
  65. /package/dist/esm/{token-storage.js → src/token-storage.js} +0 -0
package/package.json CHANGED
@@ -1,10 +1,22 @@
1
1
  {
2
2
  "name": "edilkamin",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "types": "dist/esm/index.d.ts",
5
+ "main": "dist/cjs/src/index.js",
6
+ "module": "dist/esm/src/index.js",
7
+ "types": "dist/esm/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/esm/src/index.d.ts",
12
+ "default": "./dist/esm/src/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/cjs/src/index.d.ts",
16
+ "default": "./dist/cjs/src/index.js"
17
+ }
18
+ }
19
+ },
8
20
  "scripts": {
9
21
  "cli": "ts-node src/cli.ts",
10
22
  "cli:debug": "node --inspect --require ts-node/register/transpile-only src/cli.ts",
@@ -31,7 +43,7 @@
31
43
  },
32
44
  "homepage": "https://github.com/AndreMiras/edilkamin.js#readme",
33
45
  "bin": {
34
- "edilkamin": "dist/cjs/cli.js"
46
+ "edilkamin": "dist/cjs/src/cli.js"
35
47
  },
36
48
  "nyc": {
37
49
  "reporter": [
@@ -42,18 +54,18 @@
42
54
  },
43
55
  "dependencies": {
44
56
  "aws-amplify": "^6.10.0",
45
- "axios": "^1.13.2",
46
57
  "pako": "^2.1.0"
47
58
  },
48
59
  "devDependencies": {
49
- "@aws-amplify/cli": "^7.6.21",
50
60
  "@eslint/eslintrc": "^3.2.0",
51
61
  "@eslint/js": "^9.16.0",
52
62
  "@types/mocha": "^10.0.10",
63
+ "@types/node": "^25.0.2",
53
64
  "@types/pako": "^2.0.4",
54
65
  "@types/sinon": "^17.0.3",
55
66
  "@typescript-eslint/eslint-plugin": "^8.17.0",
56
67
  "@typescript-eslint/parser": "^8.17.0",
68
+ "esbuild": "^0.27.1",
57
69
  "eslint": "^9.16.0",
58
70
  "eslint-config-prettier": "^10.1.8",
59
71
  "eslint-plugin-prettier": "^5.2.1",
@@ -0,0 +1,21 @@
1
+ import { strict as assert } from "assert";
2
+ import * as esbuild from "esbuild";
3
+
4
+ describe("browser-bundle", () => {
5
+ it("should bundle for browser without Node.js built-ins", async () => {
6
+ // This test verifies that the library can be bundled for browser environments
7
+ // without requiring Node.js built-in modules (fs, os, path).
8
+ // If this test fails, it means Node.js-only code has leaked into the main exports.
9
+ const result = await esbuild.build({
10
+ entryPoints: ["dist/esm/src/index.js"],
11
+ platform: "browser",
12
+ bundle: true,
13
+ write: false,
14
+ // External dependencies that are expected (real deps + assert which is used for validation)
15
+ external: ["aws-amplify", "aws-amplify/*", "pako", "assert"],
16
+ logLevel: "silent",
17
+ });
18
+ // If we get here without error, the bundle succeeded
19
+ assert.ok(result.outputFiles.length > 0, "Bundle should produce output");
20
+ });
21
+ });
@@ -0,0 +1,47 @@
1
+ import { strict as assert } from "assert";
2
+ import sinon from "sinon";
3
+
4
+ import { configureAmplify } from "../src/library";
5
+
6
+ /**
7
+ * This test file specifically tests the configureAmplify function with custom storage.
8
+ * It tests line 61 in library.ts:
9
+ * cognitoUserPoolsTokenProvider.setKeyValueStorage(storage)
10
+ *
11
+ * IMPORTANT: This file is named to run BEFORE library.test.ts (alphabetically)
12
+ * to ensure amplifyConfigured is still false when these tests run.
13
+ */
14
+
15
+ describe("configureAmplify", () => {
16
+ it("should configure Amplify with custom storage", () => {
17
+ const mockStorage = {
18
+ setItem: sinon.stub().resolves(),
19
+ getItem: sinon.stub().resolves(null),
20
+ removeItem: sinon.stub().resolves(),
21
+ clear: sinon.stub().resolves(),
22
+ };
23
+
24
+ // Call configureAmplify with custom storage
25
+ // This is the first call in the test suite, so amplifyConfigured is false
26
+ // This should trigger line 61 in library.ts
27
+ configureAmplify(mockStorage);
28
+
29
+ // The test passes if no error is thrown
30
+ // Coverage confirms line 61 is executed
31
+ assert.ok(true, "configureAmplify with storage completed without error");
32
+ });
33
+
34
+ it("should only configure Amplify once (idempotent)", () => {
35
+ // Call configureAmplify multiple times without storage
36
+ configureAmplify();
37
+ configureAmplify();
38
+ configureAmplify();
39
+
40
+ // Should not throw or have any side effects
41
+ // The function returns early if already configured (line 58)
42
+ assert.ok(
43
+ true,
44
+ "Multiple calls to configureAmplify completed without error",
45
+ );
46
+ });
47
+ });
package/src/index.ts CHANGED
@@ -8,7 +8,6 @@ export {
8
8
  serialNumberFromHex,
9
9
  serialNumberToHex,
10
10
  } from "./serial-utils";
11
- export { clearSession } from "./token-storage";
12
11
  export {
13
12
  BufferEncodedType,
14
13
  CommandsType,