@ripwords/myinvois-client 0.0.8 → 0.0.10
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/bun.lock +85 -2
- package/dist/index.cjs +36 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -18
- package/dist/index.js +36 -5
- package/package.json +4 -2
- package/rolldown.config.ts +5 -1
- package/src/api/platform/{taxpayerLogin.ts → platformLogin.ts} +3 -2
- package/src/types/index.d.ts +1 -0
- package/src/utils/MyInvoisClient.ts +10 -6
package/bun.lock
CHANGED
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
"dotenv": "^16.5.0",
|
|
9
9
|
"oxlint": "^0.16.6",
|
|
10
10
|
"prettier": "^3.5.3",
|
|
11
|
+
"rimraf": "^6.0.1",
|
|
11
12
|
"rolldown": "^1.0.0-beta.7",
|
|
12
|
-
"rolldown-plugin-dts": "^0.7.
|
|
13
|
+
"rolldown-plugin-dts": "^0.7.13",
|
|
13
14
|
"vitest": "^3.1.1",
|
|
14
15
|
},
|
|
15
16
|
"peerDependencies": {
|
|
16
|
-
"typescript": "^5",
|
|
17
|
+
"typescript": "^5.8.3",
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
20
|
},
|
|
@@ -74,6 +75,8 @@
|
|
|
74
75
|
|
|
75
76
|
"@esbuild/win32-x64": ["@esbuild/win32-x64@0.25.2", "", { "os": "win32", "cpu": "x64" }, "sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA=="],
|
|
76
77
|
|
|
78
|
+
"@isaacs/cliui": ["@isaacs/cliui@8.0.2", "", { "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", "strip-ansi": "^7.0.1", "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", "wrap-ansi": "^8.1.0", "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" } }, "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA=="],
|
|
79
|
+
|
|
77
80
|
"@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.0", "", {}, "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ=="],
|
|
78
81
|
|
|
79
82
|
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@0.2.9", "", { "dependencies": { "@emnapi/core": "^1.4.0", "@emnapi/runtime": "^1.4.0", "@tybys/wasm-util": "^0.9.0" } }, "sha512-OKRBiajrrxB9ATokgEQoG87Z25c67pCpYcCwmXYX8PBftC9pBfN18gnm/fh1wurSLEKIAt+QRFLFCQISrb66Jg=="],
|
|
@@ -250,8 +253,16 @@
|
|
|
250
253
|
|
|
251
254
|
"@vitest/utils": ["@vitest/utils@3.1.1", "", { "dependencies": { "@vitest/pretty-format": "3.1.1", "loupe": "^3.1.3", "tinyrainbow": "^2.0.0" } }, "sha512-1XIjflyaU2k3HMArJ50bwSh3wKWPD6Q47wz/NUSmRV0zNywPc4w79ARjg/i/aNINHwA+mIALhUVqD9/aUvZNgg=="],
|
|
252
255
|
|
|
256
|
+
"ansi-regex": ["ansi-regex@6.1.0", "", {}, "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA=="],
|
|
257
|
+
|
|
258
|
+
"ansi-styles": ["ansi-styles@6.2.1", "", {}, "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug=="],
|
|
259
|
+
|
|
253
260
|
"assertion-error": ["assertion-error@2.0.1", "", {}, "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA=="],
|
|
254
261
|
|
|
262
|
+
"balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="],
|
|
263
|
+
|
|
264
|
+
"brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
|
|
265
|
+
|
|
255
266
|
"bun-types": ["bun-types@1.2.10", "", { "dependencies": { "@types/node": "*" } }, "sha512-b5ITZMnVdf3m1gMvJHG+gIfeJHiQPJak0f7925Hxu6ZN5VKA8AGy4GZ4lM+Xkn6jtWxg5S3ldWvfmXdvnkp3GQ=="],
|
|
256
267
|
|
|
257
268
|
"cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
|
|
@@ -260,6 +271,12 @@
|
|
|
260
271
|
|
|
261
272
|
"check-error": ["check-error@2.1.1", "", {}, "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw=="],
|
|
262
273
|
|
|
274
|
+
"color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="],
|
|
275
|
+
|
|
276
|
+
"color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="],
|
|
277
|
+
|
|
278
|
+
"cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
|
279
|
+
|
|
263
280
|
"debug": ["debug@4.4.0", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA=="],
|
|
264
281
|
|
|
265
282
|
"deep-eql": ["deep-eql@5.0.2", "", {}, "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q=="],
|
|
@@ -268,6 +285,10 @@
|
|
|
268
285
|
|
|
269
286
|
"dts-resolver": ["dts-resolver@1.0.0", "", { "dependencies": { "oxc-resolver": "^5.2.0", "pathe": "^2.0.3" } }, "sha512-BTW78HXK66TvRHBRkU91a7CGoD5/PWi8ovMXbKVHjhR5xCqt1dgwl6CVk3wxWLzhNVIGXDbGWPBlRKrgSHMzfw=="],
|
|
270
287
|
|
|
288
|
+
"eastasianwidth": ["eastasianwidth@0.2.0", "", {}, "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="],
|
|
289
|
+
|
|
290
|
+
"emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="],
|
|
291
|
+
|
|
271
292
|
"es-module-lexer": ["es-module-lexer@1.6.0", "", {}, "sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ=="],
|
|
272
293
|
|
|
273
294
|
"esbuild": ["esbuild@0.25.2", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.25.2", "@esbuild/android-arm": "0.25.2", "@esbuild/android-arm64": "0.25.2", "@esbuild/android-x64": "0.25.2", "@esbuild/darwin-arm64": "0.25.2", "@esbuild/darwin-x64": "0.25.2", "@esbuild/freebsd-arm64": "0.25.2", "@esbuild/freebsd-x64": "0.25.2", "@esbuild/linux-arm": "0.25.2", "@esbuild/linux-arm64": "0.25.2", "@esbuild/linux-ia32": "0.25.2", "@esbuild/linux-loong64": "0.25.2", "@esbuild/linux-mips64el": "0.25.2", "@esbuild/linux-ppc64": "0.25.2", "@esbuild/linux-riscv64": "0.25.2", "@esbuild/linux-s390x": "0.25.2", "@esbuild/linux-x64": "0.25.2", "@esbuild/netbsd-arm64": "0.25.2", "@esbuild/netbsd-x64": "0.25.2", "@esbuild/openbsd-arm64": "0.25.2", "@esbuild/openbsd-x64": "0.25.2", "@esbuild/sunos-x64": "0.25.2", "@esbuild/win32-arm64": "0.25.2", "@esbuild/win32-ia32": "0.25.2", "@esbuild/win32-x64": "0.25.2" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-16854zccKPnC+toMywC+uKNeYSv+/eXkevRAfwRD/G9Cleq66m8XFIrigkbvauLLlCfDL45Q2cWegSg53gGBnQ=="],
|
|
@@ -278,16 +299,32 @@
|
|
|
278
299
|
|
|
279
300
|
"fdir": ["fdir@6.4.3", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw=="],
|
|
280
301
|
|
|
302
|
+
"foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="],
|
|
303
|
+
|
|
281
304
|
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
|
282
305
|
|
|
283
306
|
"get-tsconfig": ["get-tsconfig@4.10.0", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A=="],
|
|
284
307
|
|
|
308
|
+
"glob": ["glob@11.0.1", "", { "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^4.0.1", "minimatch": "^10.0.0", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^2.0.0" }, "bin": { "glob": "dist/esm/bin.mjs" } }, "sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw=="],
|
|
309
|
+
|
|
310
|
+
"is-fullwidth-code-point": ["is-fullwidth-code-point@3.0.0", "", {}, "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="],
|
|
311
|
+
|
|
312
|
+
"isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
|
|
313
|
+
|
|
314
|
+
"jackspeak": ["jackspeak@4.1.0", "", { "dependencies": { "@isaacs/cliui": "^8.0.2" } }, "sha512-9DDdhb5j6cpeitCbvLO7n7J4IxnbM6hoF6O1g4HQ5TfhvvKN8ywDM7668ZhMHRqVmxqhps/F6syWK2KcPxYlkw=="],
|
|
315
|
+
|
|
285
316
|
"loupe": ["loupe@3.1.3", "", {}, "sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug=="],
|
|
286
317
|
|
|
318
|
+
"lru-cache": ["lru-cache@11.1.0", "", {}, "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A=="],
|
|
319
|
+
|
|
287
320
|
"magic-string": ["magic-string@0.30.17", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0" } }, "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA=="],
|
|
288
321
|
|
|
289
322
|
"magic-string-ast": ["magic-string-ast@0.9.1", "", { "dependencies": { "magic-string": "^0.30.17" } }, "sha512-18dv2ZlSSgJ/jDWlZGKfnDJx56ilNlYq9F7NnwuWTErsmYmqJ2TWE4l1o2zlUHBYUGBy3tIhPCC1gxq8M5HkMA=="],
|
|
290
323
|
|
|
324
|
+
"minimatch": ["minimatch@10.0.1", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ=="],
|
|
325
|
+
|
|
326
|
+
"minipass": ["minipass@7.1.2", "", {}, "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw=="],
|
|
327
|
+
|
|
291
328
|
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
|
292
329
|
|
|
293
330
|
"nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
|
@@ -300,6 +337,12 @@
|
|
|
300
337
|
|
|
301
338
|
"oxlint": ["oxlint@0.16.6", "", { "optionalDependencies": { "@oxlint/darwin-arm64": "0.16.6", "@oxlint/darwin-x64": "0.16.6", "@oxlint/linux-arm64-gnu": "0.16.6", "@oxlint/linux-arm64-musl": "0.16.6", "@oxlint/linux-x64-gnu": "0.16.6", "@oxlint/linux-x64-musl": "0.16.6", "@oxlint/win32-arm64": "0.16.6", "@oxlint/win32-x64": "0.16.6" }, "bin": { "oxlint": "bin/oxlint", "oxc_language_server": "bin/oxc_language_server" } }, "sha512-pesehI0loV2h2k95mFRsUg6uNgGw2RPs1pcuAfPRJUwGehkfraMVCQofwqsMUeufmXygweH734vhKzQ24r3djA=="],
|
|
302
339
|
|
|
340
|
+
"package-json-from-dist": ["package-json-from-dist@1.0.1", "", {}, "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw=="],
|
|
341
|
+
|
|
342
|
+
"path-key": ["path-key@3.1.1", "", {}, "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="],
|
|
343
|
+
|
|
344
|
+
"path-scurry": ["path-scurry@2.0.0", "", { "dependencies": { "lru-cache": "^11.0.0", "minipass": "^7.1.2" } }, "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg=="],
|
|
345
|
+
|
|
303
346
|
"pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
|
304
347
|
|
|
305
348
|
"pathval": ["pathval@2.0.0", "", {}, "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA=="],
|
|
@@ -314,20 +357,36 @@
|
|
|
314
357
|
|
|
315
358
|
"resolve-pkg-maps": ["resolve-pkg-maps@1.0.0", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
|
|
316
359
|
|
|
360
|
+
"rimraf": ["rimraf@6.0.1", "", { "dependencies": { "glob": "^11.0.0", "package-json-from-dist": "^1.0.0" }, "bin": { "rimraf": "dist/esm/bin.mjs" } }, "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A=="],
|
|
361
|
+
|
|
317
362
|
"rolldown": ["rolldown@1.0.0-beta.7", "", { "dependencies": { "@oxc-project/types": "0.61.2", "@valibot/to-json-schema": "1.0.0", "valibot": "1.0.0" }, "optionalDependencies": { "@rolldown/binding-darwin-arm64": "1.0.0-beta.7", "@rolldown/binding-darwin-x64": "1.0.0-beta.7", "@rolldown/binding-freebsd-x64": "1.0.0-beta.7", "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.7", "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.7", "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.7", "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.7", "@rolldown/binding-linux-x64-musl": "1.0.0-beta.7", "@rolldown/binding-wasm32-wasi": "1.0.0-beta.7", "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.7", "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.7", "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.7" }, "peerDependencies": { "@oxc-project/runtime": "0.61.2" }, "optionalPeers": ["@oxc-project/runtime"], "bin": { "rolldown": "bin/cli.js" } }, "sha512-IUa/9lZVqgFilYggiY7jxUbmvU4Q8wVvVqsru+AeMldBccBEhTYZ6/XP6cWsznb8Fv49zfYGaeEpJ5WeVdo6Mg=="],
|
|
318
363
|
|
|
319
364
|
"rolldown-plugin-dts": ["rolldown-plugin-dts@0.7.13", "", { "dependencies": { "debug": "^4.4.0", "dts-resolver": "^1.0.0", "get-tsconfig": "^4.10.0", "magic-string-ast": "^0.9.1", "oxc-parser": "^0.64.0", "oxc-transform": "^0.64.0" }, "peerDependencies": { "rolldown": "^1.0.0-beta.7", "typescript": "^5.0.0" }, "optionalPeers": ["typescript"] }, "sha512-hwFXzOhf/szuUOnEWRIDCKVqQKTVNKzd2EjXxq1tkWRle2+PW5tvQUVVY/cxmTdpNv9fzVTz2UUZHU3pv+iqWA=="],
|
|
320
365
|
|
|
321
366
|
"rollup": ["rollup@4.40.0", "", { "dependencies": { "@types/estree": "1.0.7" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.40.0", "@rollup/rollup-android-arm64": "4.40.0", "@rollup/rollup-darwin-arm64": "4.40.0", "@rollup/rollup-darwin-x64": "4.40.0", "@rollup/rollup-freebsd-arm64": "4.40.0", "@rollup/rollup-freebsd-x64": "4.40.0", "@rollup/rollup-linux-arm-gnueabihf": "4.40.0", "@rollup/rollup-linux-arm-musleabihf": "4.40.0", "@rollup/rollup-linux-arm64-gnu": "4.40.0", "@rollup/rollup-linux-arm64-musl": "4.40.0", "@rollup/rollup-linux-loongarch64-gnu": "4.40.0", "@rollup/rollup-linux-powerpc64le-gnu": "4.40.0", "@rollup/rollup-linux-riscv64-gnu": "4.40.0", "@rollup/rollup-linux-riscv64-musl": "4.40.0", "@rollup/rollup-linux-s390x-gnu": "4.40.0", "@rollup/rollup-linux-x64-gnu": "4.40.0", "@rollup/rollup-linux-x64-musl": "4.40.0", "@rollup/rollup-win32-arm64-msvc": "4.40.0", "@rollup/rollup-win32-ia32-msvc": "4.40.0", "@rollup/rollup-win32-x64-msvc": "4.40.0", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-Noe455xmA96nnqH5piFtLobsGbCij7Tu+tb3c1vYjNbTkfzGqXqQXG3wJaYXkRZuQ0vEYN4bhwg7QnIrqB5B+w=="],
|
|
322
367
|
|
|
368
|
+
"shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],
|
|
369
|
+
|
|
370
|
+
"shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
|
|
371
|
+
|
|
323
372
|
"siginfo": ["siginfo@2.0.0", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="],
|
|
324
373
|
|
|
374
|
+
"signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="],
|
|
375
|
+
|
|
325
376
|
"source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
|
|
326
377
|
|
|
327
378
|
"stackback": ["stackback@0.0.2", "", {}, "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw=="],
|
|
328
379
|
|
|
329
380
|
"std-env": ["std-env@3.9.0", "", {}, "sha512-UGvjygr6F6tpH7o2qyqR6QYpwraIjKSdtzyBdyytFOHmPZY917kwdwLG0RbOjWOnKmnm3PeHjaoLLMie7kPLQw=="],
|
|
330
381
|
|
|
382
|
+
"string-width": ["string-width@5.1.2", "", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="],
|
|
383
|
+
|
|
384
|
+
"string-width-cjs": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
|
|
385
|
+
|
|
386
|
+
"strip-ansi": ["strip-ansi@7.1.0", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ=="],
|
|
387
|
+
|
|
388
|
+
"strip-ansi-cjs": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
|
|
389
|
+
|
|
331
390
|
"tinybench": ["tinybench@2.9.0", "", {}, "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg=="],
|
|
332
391
|
|
|
333
392
|
"tinyexec": ["tinyexec@0.3.2", "", {}, "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA=="],
|
|
@@ -354,8 +413,32 @@
|
|
|
354
413
|
|
|
355
414
|
"vitest": ["vitest@3.1.1", "", { "dependencies": { "@vitest/expect": "3.1.1", "@vitest/mocker": "3.1.1", "@vitest/pretty-format": "^3.1.1", "@vitest/runner": "3.1.1", "@vitest/snapshot": "3.1.1", "@vitest/spy": "3.1.1", "@vitest/utils": "3.1.1", "chai": "^5.2.0", "debug": "^4.4.0", "expect-type": "^1.2.0", "magic-string": "^0.30.17", "pathe": "^2.0.3", "std-env": "^3.8.1", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", "tinypool": "^1.0.2", "tinyrainbow": "^2.0.0", "vite": "^5.0.0 || ^6.0.0", "vite-node": "3.1.1", "why-is-node-running": "^2.3.0" }, "peerDependencies": { "@edge-runtime/vm": "*", "@types/debug": "^4.1.12", "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "@vitest/browser": "3.1.1", "@vitest/ui": "3.1.1", "happy-dom": "*", "jsdom": "*" }, "optionalPeers": ["@edge-runtime/vm", "@types/debug", "@types/node", "@vitest/browser", "@vitest/ui", "happy-dom", "jsdom"], "bin": { "vitest": "vitest.mjs" } }, "sha512-kiZc/IYmKICeBAZr9DQ5rT7/6bD9G7uqQEki4fxazi1jdVl2mWGzedtBs5s6llz59yQhVb7FFY2MbHzHCnT79Q=="],
|
|
356
415
|
|
|
416
|
+
"which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="],
|
|
417
|
+
|
|
357
418
|
"why-is-node-running": ["why-is-node-running@2.3.0", "", { "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" }, "bin": { "why-is-node-running": "cli.js" } }, "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w=="],
|
|
358
419
|
|
|
420
|
+
"wrap-ansi": ["wrap-ansi@8.1.0", "", { "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } }, "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ=="],
|
|
421
|
+
|
|
422
|
+
"wrap-ansi-cjs": ["wrap-ansi@7.0.0", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q=="],
|
|
423
|
+
|
|
359
424
|
"oxc-parser/@oxc-project/types": ["@oxc-project/types@0.64.0", "", {}, "sha512-B0dxuEZFV6M4tXjPFwDSaED5/J55YUhODBaF09xNFNRrEyzQLKZuhKXAw1xYK8bO4K8Jn1d21TZfei3kAIE8dA=="],
|
|
425
|
+
|
|
426
|
+
"string-width-cjs/emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
|
|
427
|
+
|
|
428
|
+
"string-width-cjs/strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
|
|
429
|
+
|
|
430
|
+
"strip-ansi-cjs/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
|
431
|
+
|
|
432
|
+
"wrap-ansi-cjs/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
|
433
|
+
|
|
434
|
+
"wrap-ansi-cjs/string-width": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
|
|
435
|
+
|
|
436
|
+
"wrap-ansi-cjs/strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
|
|
437
|
+
|
|
438
|
+
"string-width-cjs/strip-ansi/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
|
439
|
+
|
|
440
|
+
"wrap-ansi-cjs/string-width/emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
|
|
441
|
+
|
|
442
|
+
"wrap-ansi-cjs/strip-ansi/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
|
360
443
|
}
|
|
361
444
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,54 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//#region rolldown:runtime
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
-
value: mod,
|
|
21
|
-
enumerable: true
|
|
22
|
-
}) : target, mod));
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
const src_api_platform_taxpayerLogin = __toESM(require("src/api/platform/taxpayerLogin"));
|
|
26
2
|
|
|
27
3
|
//#region src/utils/getBaseUrl.ts
|
|
28
4
|
const getBaseUrl = (environment) => {
|
|
29
5
|
return environment === "sandbox" ? "https://preprod-api.myinvois.hasil.gov.my" : "https://api.myinvois.hasil.gov.my";
|
|
30
6
|
};
|
|
31
7
|
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/api/platform/platformLogin.ts
|
|
10
|
+
const platformLogin = async (client) => {
|
|
11
|
+
const { clientId, clientSecret, baseUrl, onBehalfOf, debug } = client;
|
|
12
|
+
try {
|
|
13
|
+
const response = await fetch(`${baseUrl}/connect/token`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
17
|
+
...onBehalfOf ? { onbehalfof: onBehalfOf } : {}
|
|
18
|
+
},
|
|
19
|
+
body: new URLSearchParams({
|
|
20
|
+
grant_type: "client_credentials",
|
|
21
|
+
client_id: clientId,
|
|
22
|
+
client_secret: clientSecret,
|
|
23
|
+
scope: "InvoicingAPI"
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
const tokenResponse = await response.json();
|
|
27
|
+
return {
|
|
28
|
+
token: tokenResponse.access_token,
|
|
29
|
+
tokenExpiration: new Date(Date.now() + tokenResponse.expires_in * 1e3)
|
|
30
|
+
};
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (debug) console.error(error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
32
37
|
//#endregion
|
|
33
38
|
//#region src/utils/MyInvoisClient.ts
|
|
34
39
|
var MyInvoisClient = class {
|
|
35
40
|
baseUrl;
|
|
36
41
|
clientId;
|
|
37
42
|
clientSecret;
|
|
43
|
+
onBehalfOf;
|
|
38
44
|
debug;
|
|
39
45
|
token = "";
|
|
40
46
|
tokenExpiration;
|
|
41
|
-
constructor(clientId, clientSecret, environment, debug
|
|
47
|
+
constructor(clientId, clientSecret, environment, onBehalfOf, debug) {
|
|
42
48
|
this.clientId = clientId;
|
|
43
49
|
this.clientSecret = clientSecret;
|
|
44
50
|
this.baseUrl = getBaseUrl(environment);
|
|
45
|
-
this.debug = debug;
|
|
51
|
+
this.debug = debug ?? process.env.MYINVOIS_DEBUG === "true" ? true : false;
|
|
52
|
+
this.onBehalfOf = onBehalfOf;
|
|
46
53
|
}
|
|
47
54
|
async refreshToken() {
|
|
48
|
-
const tokenResponse = await (
|
|
55
|
+
const tokenResponse = await platformLogin({
|
|
49
56
|
clientId: this.clientId,
|
|
50
57
|
clientSecret: this.clientSecret,
|
|
51
58
|
baseUrl: this.baseUrl,
|
|
59
|
+
onBehalfOf: this.onBehalfOf,
|
|
52
60
|
debug: this.debug
|
|
53
61
|
});
|
|
54
62
|
this.token = tokenResponse.token;
|
|
@@ -76,7 +84,7 @@ var MyInvoisClient = class {
|
|
|
76
84
|
*
|
|
77
85
|
* @param tin
|
|
78
86
|
* @param nric
|
|
79
|
-
* @returns
|
|
87
|
+
* @returns true if the TIN is valid, false otherwise
|
|
80
88
|
*/
|
|
81
89
|
async verifyTin(tin, nric) {
|
|
82
90
|
try {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["environment: 'sandbox' | 'production'","clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","debug
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["environment: 'sandbox' | 'production'","client: ClientCredentials","tokenResponse: TokenResponse","clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","onBehalfOf?: string","debug?: boolean","path: string","options: Parameters<typeof fetch>[1]","tin: string","nric: string"],"sources":["../src/utils/getBaseUrl.ts","../src/api/platform/platformLogin.ts","../src/utils/MyInvoisClient.ts"],"sourcesContent":["export const getBaseUrl = (environment: 'sandbox' | 'production') => {\n return environment === 'sandbox'\n ? 'https://preprod-api.myinvois.hasil.gov.my'\n : 'https://api.myinvois.hasil.gov.my'\n}\n","import type { ClientCredentials, TokenResponse } from 'src/types'\n\nexport const platformLogin = async (client: ClientCredentials) => {\n const { clientId, clientSecret, baseUrl, onBehalfOf, debug } = client\n try {\n const response = await fetch(`${baseUrl}/connect/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...(onBehalfOf ? { onbehalfof: onBehalfOf } : {}),\n },\n body: new URLSearchParams({\n grant_type: 'client_credentials',\n client_id: clientId,\n client_secret: clientSecret,\n scope: 'InvoicingAPI',\n }),\n })\n\n const tokenResponse: TokenResponse = await response.json()\n return {\n token: tokenResponse.access_token,\n tokenExpiration: new Date(Date.now() + tokenResponse.expires_in * 1000),\n }\n } catch (error) {\n if (debug) console.error(error)\n throw error\n }\n}\n","import { getBaseUrl } from './getBaseUrl'\nimport { platformLogin } from '../api/platform/platformLogin'\n\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private readonly onBehalfOf?: string\n private readonly debug: boolean\n private token = ''\n private tokenExpiration: Date | undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n onBehalfOf?: string,\n debug?: boolean,\n ) {\n this.clientId = clientId\n this.clientSecret = clientSecret\n this.baseUrl = getBaseUrl(environment)\n this.debug = (debug ?? process.env.MYINVOIS_DEBUG === 'true') ? true : false\n this.onBehalfOf = onBehalfOf\n }\n\n private async refreshToken() {\n const tokenResponse = await platformLogin({\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n baseUrl: this.baseUrl,\n onBehalfOf: this.onBehalfOf,\n debug: this.debug,\n })\n\n this.token = tokenResponse.token\n this.tokenExpiration = tokenResponse.tokenExpiration\n }\n\n private async getToken() {\n if (!this.tokenExpiration || this.tokenExpiration < new Date()) {\n if (this.debug) {\n console.log('Refreshing token')\n }\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch(path: string, options: Parameters<typeof fetch>[1] = {}) {\n const token = await this.getToken()\n\n return fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n })\n }\n\n /**\n * Validates a TIN against a NRIC\n *\n * @param tin\n * @param nric\n * @returns true if the TIN is valid, false otherwise\n */\n async verifyTin(tin: string, nric: string): Promise<boolean> {\n try {\n const response = await this.fetch(\n `/api/v1.0/taxpayer/validate/${tin}?idType=NRIC&idValue=${nric}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return true\n }\n\n return false\n } catch (error) {\n if (this.debug) {\n console.error(error)\n }\n return false\n }\n }\n}\n"],"mappings":";;;MAAa,aAAa,CAACA,gBAA0C;AACnE,QAAO,gBAAgB,YACnB,8CACA;AACL;;;;MCFY,gBAAgB,OAAOC,WAA8B;CAChE,MAAM,EAAE,UAAU,cAAc,SAAS,YAAY,OAAO,GAAG;AAC/D,KAAI;EACF,MAAM,WAAW,MAAM,OAAO,EAAE,QAAQ,iBAAiB;GACvD,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,GAAI,aAAa,EAAE,YAAY,WAAY,IAAG,CAAE;GACjD;GACD,MAAM,IAAI,gBAAgB;IACxB,YAAY;IACZ,WAAW;IACX,eAAe;IACf,OAAO;GACR;EACF,EAAC;EAEF,MAAMC,gBAA+B,MAAM,SAAS,MAAM;AAC1D,SAAO;GACL,OAAO,cAAc;GACrB,iBAAiB,IAAI,KAAK,KAAK,KAAK,GAAG,cAAc,aAAa;EACnE;CACF,SAAQ,OAAO;AACd,MAAI,MAAO,SAAQ,MAAM,MAAM;AAC/B,QAAM;CACP;AACF;;;;ICzBY,iBAAN,MAAqB;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,QAAQ;CAChB,AAAQ;CAER,YACEC,UACAC,cACAC,aACAC,YACAC,OACA;AACA,OAAK,WAAW;AAChB,OAAK,eAAe;AACpB,OAAK,UAAU,WAAW,YAAY;AACtC,OAAK,QAAS,SAAS,QAAQ,IAAI,mBAAmB,SAAU,OAAO;AACvE,OAAK,aAAa;CACnB;CAED,MAAc,eAAe;EAC3B,MAAM,gBAAgB,MAAM,cAAc;GACxC,UAAU,KAAK;GACf,cAAc,KAAK;GACnB,SAAS,KAAK;GACd,YAAY,KAAK;GACjB,OAAO,KAAK;EACb,EAAC;AAEF,OAAK,QAAQ,cAAc;AAC3B,OAAK,kBAAkB,cAAc;CACtC;CAED,MAAc,WAAW;AACvB,OAAK,KAAK,mBAAmB,KAAK,kBAAkB,IAAI,QAAQ;AAC9D,OAAI,KAAK,MACP,SAAQ,IAAI,mBAAmB;AAEjC,SAAM,KAAK,cAAc;EAC1B;AAED,SAAO,KAAK;CACb;CAED,MAAc,MAAMC,MAAcC,UAAuC,CAAE,GAAE;EAC3E,MAAM,QAAQ,MAAM,KAAK,UAAU;AAEnC,SAAO,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,GAAG;GACrC,GAAG;GACH,SAAS;IAAE,GAAG,QAAQ;IAAS,gBAAgB,SAAS,MAAM;GAAG;EAClE,EAAC;CACH;;;;;;;;CASD,MAAM,UAAUC,KAAaC,MAAgC;AAC3D,MAAI;GACF,MAAM,WAAW,MAAM,KAAK,OACzB,8BAA8B,IAAI,uBAAuB,KAAK,GAC/D,EACE,QAAQ,MACT,EACF;AAED,OAAI,SAAS,WAAW,IACtB,QAAO;AAGT,UAAO;EACR,SAAQ,OAAO;AACd,OAAI,KAAK,MACP,SAAQ,MAAM,MAAM;AAEtB,UAAO;EACR;CACF;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5634,30 +5634,32 @@ interface ClientCredentials {
|
|
|
5634
5634
|
clientId: string
|
|
5635
5635
|
clientSecret: string
|
|
5636
5636
|
baseUrl: string
|
|
5637
|
+
onBehalfOf?: string
|
|
5637
5638
|
debug?: boolean
|
|
5638
5639
|
}
|
|
5639
5640
|
|
|
5640
5641
|
//#endregion
|
|
5641
5642
|
//#region src/utils/MyInvoisClient.d.ts
|
|
5642
5643
|
declare class MyInvoisClient {
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5644
|
+
private readonly baseUrl;
|
|
5645
|
+
private readonly clientId;
|
|
5646
|
+
private readonly clientSecret;
|
|
5647
|
+
private readonly onBehalfOf?;
|
|
5648
|
+
private readonly debug;
|
|
5649
|
+
private token;
|
|
5650
|
+
private tokenExpiration;
|
|
5651
|
+
constructor(clientId: string, clientSecret: string, environment: "sandbox" | "production", onBehalfOf?: string, debug?: boolean);
|
|
5652
|
+
private refreshToken;
|
|
5653
|
+
private getToken;
|
|
5654
|
+
private fetch;
|
|
5655
|
+
/**
|
|
5656
|
+
* Validates a TIN against a NRIC
|
|
5657
|
+
*
|
|
5658
|
+
* @param tin
|
|
5659
|
+
* @param nric
|
|
5660
|
+
* @returns true if the TIN is valid, false otherwise
|
|
5661
|
+
*/
|
|
5662
|
+
verifyTin(tin: string, nric: string): Promise<boolean>;
|
|
5661
5663
|
}
|
|
5662
5664
|
|
|
5663
5665
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,61 @@
|
|
|
1
|
-
import { taxpayerLogin } from "src/api/platform/taxpayerLogin";
|
|
2
1
|
|
|
3
2
|
//#region src/utils/getBaseUrl.ts
|
|
4
3
|
const getBaseUrl = (environment) => {
|
|
5
4
|
return environment === "sandbox" ? "https://preprod-api.myinvois.hasil.gov.my" : "https://api.myinvois.hasil.gov.my";
|
|
6
5
|
};
|
|
7
6
|
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/api/platform/platformLogin.ts
|
|
9
|
+
const platformLogin = async (client) => {
|
|
10
|
+
const { clientId, clientSecret, baseUrl, onBehalfOf, debug } = client;
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch(`${baseUrl}/connect/token`, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
16
|
+
...onBehalfOf ? { onbehalfof: onBehalfOf } : {}
|
|
17
|
+
},
|
|
18
|
+
body: new URLSearchParams({
|
|
19
|
+
grant_type: "client_credentials",
|
|
20
|
+
client_id: clientId,
|
|
21
|
+
client_secret: clientSecret,
|
|
22
|
+
scope: "InvoicingAPI"
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
const tokenResponse = await response.json();
|
|
26
|
+
return {
|
|
27
|
+
token: tokenResponse.access_token,
|
|
28
|
+
tokenExpiration: new Date(Date.now() + tokenResponse.expires_in * 1e3)
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (debug) console.error(error);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
8
36
|
//#endregion
|
|
9
37
|
//#region src/utils/MyInvoisClient.ts
|
|
10
38
|
var MyInvoisClient = class {
|
|
11
39
|
baseUrl;
|
|
12
40
|
clientId;
|
|
13
41
|
clientSecret;
|
|
42
|
+
onBehalfOf;
|
|
14
43
|
debug;
|
|
15
44
|
token = "";
|
|
16
45
|
tokenExpiration;
|
|
17
|
-
constructor(clientId, clientSecret, environment, debug
|
|
46
|
+
constructor(clientId, clientSecret, environment, onBehalfOf, debug) {
|
|
18
47
|
this.clientId = clientId;
|
|
19
48
|
this.clientSecret = clientSecret;
|
|
20
49
|
this.baseUrl = getBaseUrl(environment);
|
|
21
|
-
this.debug = debug;
|
|
50
|
+
this.debug = debug ?? process.env.MYINVOIS_DEBUG === "true" ? true : false;
|
|
51
|
+
this.onBehalfOf = onBehalfOf;
|
|
22
52
|
}
|
|
23
53
|
async refreshToken() {
|
|
24
|
-
const tokenResponse = await
|
|
54
|
+
const tokenResponse = await platformLogin({
|
|
25
55
|
clientId: this.clientId,
|
|
26
56
|
clientSecret: this.clientSecret,
|
|
27
57
|
baseUrl: this.baseUrl,
|
|
58
|
+
onBehalfOf: this.onBehalfOf,
|
|
28
59
|
debug: this.debug
|
|
29
60
|
});
|
|
30
61
|
this.token = tokenResponse.token;
|
|
@@ -52,7 +83,7 @@ var MyInvoisClient = class {
|
|
|
52
83
|
*
|
|
53
84
|
* @param tin
|
|
54
85
|
* @param nric
|
|
55
|
-
* @returns
|
|
86
|
+
* @returns true if the TIN is valid, false otherwise
|
|
56
87
|
*/
|
|
57
88
|
async verifyTin(tin, nric) {
|
|
58
89
|
try {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ripwords/myinvois-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "MyInvois client",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "rolldown -c rolldown.config.ts",
|
|
6
|
+
"build": "bun run clean && rolldown -c rolldown.config.ts",
|
|
7
7
|
"release": "bun run build && npm publish --access public",
|
|
8
|
+
"clean": "rimraf dist",
|
|
8
9
|
"lint": "oxlint",
|
|
9
10
|
"test": "vitest"
|
|
10
11
|
},
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
"dotenv": "^16.5.0",
|
|
22
23
|
"oxlint": "^0.16.6",
|
|
23
24
|
"prettier": "^3.5.3",
|
|
25
|
+
"rimraf": "^6.0.1",
|
|
24
26
|
"rolldown": "^1.0.0-beta.7",
|
|
25
27
|
"rolldown-plugin-dts": "^0.7.13",
|
|
26
28
|
"vitest": "^3.1.1"
|
package/rolldown.config.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ClientCredentials, TokenResponse } from 'src/types'
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
const { clientId, clientSecret, baseUrl, debug } = client
|
|
3
|
+
export const platformLogin = async (client: ClientCredentials) => {
|
|
4
|
+
const { clientId, clientSecret, baseUrl, onBehalfOf, debug } = client
|
|
5
5
|
try {
|
|
6
6
|
const response = await fetch(`${baseUrl}/connect/token`, {
|
|
7
7
|
method: 'POST',
|
|
8
8
|
headers: {
|
|
9
9
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
10
|
+
...(onBehalfOf ? { onbehalfof: onBehalfOf } : {}),
|
|
10
11
|
},
|
|
11
12
|
body: new URLSearchParams({
|
|
12
13
|
grant_type: 'client_credentials',
|
package/src/types/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getBaseUrl } from './getBaseUrl'
|
|
2
|
-
import {
|
|
2
|
+
import { platformLogin } from '../api/platform/platformLogin'
|
|
3
3
|
|
|
4
4
|
export class MyInvoisClient {
|
|
5
5
|
private readonly baseUrl: string
|
|
6
6
|
private readonly clientId: string
|
|
7
7
|
private readonly clientSecret: string
|
|
8
|
+
private readonly onBehalfOf?: string
|
|
8
9
|
private readonly debug: boolean
|
|
9
10
|
private token = ''
|
|
10
11
|
private tokenExpiration: Date | undefined
|
|
@@ -13,19 +14,22 @@ export class MyInvoisClient {
|
|
|
13
14
|
clientId: string,
|
|
14
15
|
clientSecret: string,
|
|
15
16
|
environment: 'sandbox' | 'production',
|
|
16
|
-
|
|
17
|
+
onBehalfOf?: string,
|
|
18
|
+
debug?: boolean,
|
|
17
19
|
) {
|
|
18
20
|
this.clientId = clientId
|
|
19
21
|
this.clientSecret = clientSecret
|
|
20
22
|
this.baseUrl = getBaseUrl(environment)
|
|
21
|
-
this.debug = debug
|
|
23
|
+
this.debug = (debug ?? process.env.MYINVOIS_DEBUG === 'true') ? true : false
|
|
24
|
+
this.onBehalfOf = onBehalfOf
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
private async refreshToken() {
|
|
25
|
-
const tokenResponse = await
|
|
28
|
+
const tokenResponse = await platformLogin({
|
|
26
29
|
clientId: this.clientId,
|
|
27
30
|
clientSecret: this.clientSecret,
|
|
28
31
|
baseUrl: this.baseUrl,
|
|
32
|
+
onBehalfOf: this.onBehalfOf,
|
|
29
33
|
debug: this.debug,
|
|
30
34
|
})
|
|
31
35
|
|
|
@@ -58,9 +62,9 @@ export class MyInvoisClient {
|
|
|
58
62
|
*
|
|
59
63
|
* @param tin
|
|
60
64
|
* @param nric
|
|
61
|
-
* @returns
|
|
65
|
+
* @returns true if the TIN is valid, false otherwise
|
|
62
66
|
*/
|
|
63
|
-
async verifyTin(tin: string, nric: string) {
|
|
67
|
+
async verifyTin(tin: string, nric: string): Promise<boolean> {
|
|
64
68
|
try {
|
|
65
69
|
const response = await this.fetch(
|
|
66
70
|
`/api/v1.0/taxpayer/validate/${tin}?idType=NRIC&idValue=${nric}`,
|