@pawmaskrelease/psecure 0.1.0-beta → 1.1.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +44 -44
  3. package/README.md +560 -175
  4. package/bin/psecure.mjs +13 -0
  5. package/dist/adapters/desktop.d.ts +26 -26
  6. package/dist/adapters/desktop.js +25 -12
  7. package/dist/adapters/index.js +1 -1
  8. package/dist/adapters/mobile-bridge.d.ts +28 -3
  9. package/dist/adapters/mobile-bridge.js +23 -12
  10. package/dist/adapters/react-native.d.ts +9 -15
  11. package/dist/adapters/react-native.js +15 -9
  12. package/dist/adapters/web-shield.d.ts +1 -1
  13. package/dist/adapters/web-shield.js +13 -11
  14. package/dist/adapters/web-vault.d.ts +58 -6
  15. package/dist/adapters/web-vault.js +97 -21
  16. package/dist/cli/doctor.d.ts +31 -0
  17. package/dist/cli/doctor.js +108 -0
  18. package/dist/client/index.js +1 -1
  19. package/dist/client/psecure-client.d.ts +56 -14
  20. package/dist/client/psecure-client.js +179 -38
  21. package/dist/crypto/block-ciphers.js +1 -1
  22. package/dist/crypto/chacha-cfb.js +33 -33
  23. package/dist/crypto/index.js +1 -1
  24. package/dist/crypto/mba.js +1 -1
  25. package/dist/crypto/primitives.js +1 -1
  26. package/dist/crypto/threefish.js +22 -22
  27. package/dist/crypto/wasm-coprocessor.d.ts +10 -9
  28. package/dist/crypto/wasm-coprocessor.js +40 -35
  29. package/dist/crypto/whitebox-aes.js +32 -32
  30. package/dist/dist-manifest.json +130 -100
  31. package/dist/errors.d.ts +14 -0
  32. package/dist/errors.js +53 -0
  33. package/dist/fetch/index.d.ts +40 -0
  34. package/dist/fetch/index.js +93 -0
  35. package/dist/fetch/load-client.d.ts +1 -0
  36. package/dist/fetch/load-client.js +3 -0
  37. package/dist/index.d.ts +3 -0
  38. package/dist/index.js +4 -1
  39. package/dist/protocol/canonical.d.ts +47 -0
  40. package/dist/protocol/canonical.js +73 -0
  41. package/dist/protocol/codecs.d.ts +1 -0
  42. package/dist/protocol/codecs.js +72 -63
  43. package/dist/protocol/constants.d.ts +1 -1
  44. package/dist/protocol/constants.js +3 -3
  45. package/dist/protocol/dvp-probes.js +51 -51
  46. package/dist/protocol/ed25519.d.ts +3 -8
  47. package/dist/protocol/ed25519.js +59 -46
  48. package/dist/protocol/index.js +1 -1
  49. package/dist/protocol/types.d.ts +8 -2
  50. package/dist/protocol/types.js +1 -1
  51. package/dist/protocol/wire.d.ts +2 -13
  52. package/dist/protocol/wire.js +98 -85
  53. package/dist/rasp/auto-collector.js +29 -27
  54. package/dist/rasp/behavior-stream.js +47 -47
  55. package/dist/rasp/dvp-consistency.js +9 -9
  56. package/dist/rasp/hardware-binding.js +7 -7
  57. package/dist/rasp/index.js +1 -1
  58. package/dist/rasp/klepto-seal.js +1 -1
  59. package/dist/rasp/mobile-native-probes.js +8 -8
  60. package/dist/rasp/probes.js +13 -13
  61. package/dist/rasp/web-integrity-probes.js +47 -44
  62. package/dist/server/authority-types.d.ts +113 -9
  63. package/dist/server/authority-types.js +4 -2
  64. package/dist/server/edge.d.ts +20 -0
  65. package/dist/server/edge.js +54 -0
  66. package/dist/server/express.d.ts +40 -0
  67. package/dist/server/express.js +65 -0
  68. package/dist/server/fastify.d.ts +35 -0
  69. package/dist/server/fastify.js +45 -0
  70. package/dist/server/guard.d.ts +129 -0
  71. package/dist/server/guard.js +121 -0
  72. package/dist/server/index.d.ts +5 -5
  73. package/dist/server/index.js +6 -6
  74. package/dist/server/middleware.d.ts +13 -3
  75. package/dist/server/middleware.js +50 -34
  76. package/dist/server/remote-authority-client.d.ts +4 -4
  77. package/dist/server/remote-authority-client.js +52 -45
  78. package/dist/server/verdicts.d.ts +19 -0
  79. package/dist/server/verdicts.js +49 -0
  80. package/dist/version.d.ts +1 -0
  81. package/dist/version.js +3 -0
  82. package/dist/vm/dynamic-ob.d.ts +2 -2
  83. package/dist/vm/dynamic-ob.js +48 -48
  84. package/dist/vm/env-key.js +5 -5
  85. package/dist/vm/iabc-isa.js +13 -13
  86. package/dist/vm/index.d.ts +0 -1
  87. package/dist/vm/index.js +1 -2
  88. package/dist/vm/psecure-vm.js +54 -58
  89. package/dist/web/psecure-polymorphic-loader.obf.js +5 -3
  90. package/dist/web/psecure-vm-kernel.d.ts +118 -0
  91. package/dist/web/psecure-vm-kernel.js +142 -78
  92. package/dist/web/psecure-web-shield.bundle.js +148 -78
  93. package/package.json +154 -122
  94. package/dist/server/authority.d.ts +0 -42
  95. package/dist/server/authority.js +0 -89
  96. package/dist/server/lease-store.d.ts +0 -25
  97. package/dist/server/lease-store.js +0 -92
  98. package/dist/server/pop-verifier.d.ts +0 -21
  99. package/dist/server/pop-verifier.js +0 -98
  100. package/dist/server/redis-store.d.ts +0 -89
  101. package/dist/server/redis-store.js +0 -111
  102. package/dist/server/store.d.ts +0 -90
  103. package/dist/server/store.js +0 -70
package/CHANGELOG.md ADDED
@@ -0,0 +1,49 @@
1
+ # Changelog: `@pawmaskrelease/psecure`
2
+
3
+ ## 1.1.0
4
+
5
+ Integrations in under an hour: framework adapters, a sealing `fetch`, actionable errors and a `doctor` CLI.
6
+ Backward compatible with 1.0.0: nothing was removed or changed in meaning, and every 1.0.0 import keeps working.
7
+
8
+ ### Added
9
+
10
+ - **Server adapters** on one guard core (`createPSecureGuard`), configured from `PSECURE_*` environment variables:
11
+ - `@pawmaskrelease/psecure/fastify`: `psecureFastify` plugin. It captures the raw body itself, sets `request.psecure`,
12
+ and supports route config `{ psecure: true | false }`.
13
+ - `@pawmaskrelease/psecure/express`: `psecure()` middleware and `psecureRawBody` (for `express.json({ verify })`);
14
+ sets `req.psecure`.
15
+ - `@pawmaskrelease/psecure/edge`: `withPSecure(handler)` and `createPSecureEdge()` for Next.js, Hono, Cloudflare
16
+ Workers, Bun and Deno.
17
+ - `PSECURE_REQUEST_HEADERS` / `PSECURE_EXPOSED_HEADERS` for CORS, `getPSecureDecision(request)`, `onDecision` hook,
18
+ `createPSecureAuditThrottle`, pino-compatible logging that never contains the key, envelope, lease or body.
19
+ - Decision table: Monitor never blocks. Block refuses denied and malformed requests everywhere, and fails closed
20
+ (missing envelope, authority down) only on `protect` routes (default: all guarded routes). A lease reissue is
21
+ answered `401` + `x-psecure-reissued-lease`; any other refusal is `403 { error: 'PSECURE_REJECTED' }`.
22
+ - **The console Monitor/Block switch drives enforcement.** The default mode `auto` follows the app's mode, which the
23
+ authority (>= 1.1) reports on every verdict as `appMode`. The last mode seen is cached for 10 minutes when a request
24
+ carries no verdict; a cold start behaves as Monitor. `PSECURE_MODE=monitor | enforce | off` overrides the switch.
25
+ `PSecureVerificationVerdict.appMode` is typed.
26
+ - **App pinning** (`appKey` / `PSECURE_APP_KEY`, recommended): the guard sends it as `expectedAppKey`. The
27
+ authority then denies a lease of any other application, same organization included, with the new reason
28
+ `app_mismatch`, and the guard only takes a console mode reported for that app (`verdict.appKey`). This closes the
29
+ downgrade where a lease of a Monitor app is replayed against a Block app's backend. In `auto` without it, the guard
30
+ logs a one-time `APP_KEY_NOT_PINNED` warning, and `doctor` warns.
31
+ `PSecureRequestVerificationContext.expectedAppKey`, `PSecureHttpVerifyInput.expectedAppKey`, `verdict.appKey` and
32
+ the `app_mismatch` reason are typed and pass through `PSecureRemoteAuthorityClient`.
33
+ - **`createPSecureFetch`** (`@pawmaskrelease/psecure/fetch`, also from the root): a drop-in sealing `fetch`. It falls
34
+ back gracefully to plain `fetch`, filters origins, never sends a POST twice, provides `setAccount()`, refreshes the
35
+ lease in the background, defaults to `telemetry: 'minimal'` and lazy-loads the client core.
36
+ - **`PSecureConfigError`** with a stable `code`, an English `hint` and a `docsUrl`, for common misconfigurations
37
+ (public key missing, invalid or mismatched; keys swapped; non-https authority; CSP or unreachable authority; origins;
38
+ clock skew; raw body; server key missing or rejected).
39
+ - **`npx @pawmaskrelease/psecure doctor`**: checks that the authority is reachable, the pinned key, the clock, CORS,
40
+ a test lease with the app key and the server key (from `PSECURE_SERVER_KEY` only, never printed). Optionally checks
41
+ your API's CORS.
42
+ - `PSECURE_SDK_VERSION`.
43
+
44
+ ### Changed
45
+
46
+ - The `PSecureClient.connect` lease failure error now carries `status` and the authority's SDK `code`
47
+ (`INVALID_APP_KEY`, `CROSS_TENANT_APP_KEY`, …), and names the code in its message.
48
+ - The `@pawmaskrelease/psecure/server` barrel also exports the guard and the Express and Edge adapters (the Fastify
49
+ plugin uses `node:stream` and has its own subpath, so `/server` stays edge-safe).
package/LICENSE CHANGED
@@ -1,44 +1,44 @@
1
- Paw Mask PSecure SDK — Proprietary Commercial License
2
-
3
- Copyright (c) Paw Mask. All rights reserved.
4
-
5
- This software and its accompanying files (the "Software") are the confidential
6
- and proprietary property of Paw Mask. The Software is licensed, not sold.
7
-
8
- 1. License grant. Subject to your full and ongoing compliance with this
9
- license, Paw Mask grants you a limited, non-exclusive, non-transferable,
10
- non-sublicensable, revocable license to install and use the Software solely
11
- in connection with a valid, active Paw Mask PSecure subscription, or under
12
- the written terms of an authorized Paw Mask evaluation or sandbox agreement.
13
-
14
- 2. Restrictions. Except to the extent expressly permitted by this license or
15
- by mandatory applicable law, you may NOT, and may not permit any third party
16
- to:
17
- (a) copy, redistribute, publish, sublicense, sell, rent, lease, or otherwise
18
- make the Software available to any third party;
19
- (b) reverse engineer, decompile, disassemble, deobfuscate, or otherwise
20
- attempt to derive the source code, internal design, protocols, or
21
- underlying ideas of the Software, or circumvent or disable any of its
22
- security, anti-tamper, or licensing mechanisms;
23
- (c) modify, adapt, or create derivative works of the Software; or
24
- (d) remove, obscure, or alter any proprietary notices.
25
-
26
- 3. Ownership. Paw Mask retains all right, title, and interest in and to the
27
- Software, including all intellectual property rights. No rights are granted
28
- except as expressly set out in this license.
29
-
30
- 4. Termination. This license terminates automatically if your PSecure
31
- subscription or evaluation/sandbox agreement lapses or is terminated, or if
32
- you breach any term of this license. Upon termination you must cease all use
33
- and destroy all copies of the Software.
34
-
35
- 5. No warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
38
-
39
- 6. Limitation of liability. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT
40
- SHALL PAW MASK BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
41
- CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS OR DATA, ARISING
42
- OUT OF OR RELATED TO THE SOFTWARE.
43
-
44
- For licensing inquiries: licensing@pawmask.com — https://pawmask.com/docs/psecure
1
+ Paw Mask PSecure SDK — Proprietary Commercial License
2
+
3
+ Copyright (c) Paw Mask. All rights reserved.
4
+
5
+ This software and its accompanying files (the "Software") are the confidential
6
+ and proprietary property of Paw Mask. The Software is licensed, not sold.
7
+
8
+ 1. License grant. Subject to your full and ongoing compliance with this
9
+ license, Paw Mask grants you a limited, non-exclusive, non-transferable,
10
+ non-sublicensable, revocable license to install and use the Software solely
11
+ in connection with a valid, active Paw Mask PSecure subscription, or under
12
+ the written terms of an authorized Paw Mask evaluation or sandbox agreement.
13
+
14
+ 2. Restrictions. Except to the extent expressly permitted by this license or
15
+ by mandatory applicable law, you may NOT, and may not permit any third party
16
+ to:
17
+ (a) copy, redistribute, publish, sublicense, sell, rent, lease, or otherwise
18
+ make the Software available to any third party;
19
+ (b) reverse engineer, decompile, disassemble, deobfuscate, or otherwise
20
+ attempt to derive the source code, internal design, protocols, or
21
+ underlying ideas of the Software, or circumvent or disable any of its
22
+ security, anti-tamper, or licensing mechanisms;
23
+ (c) modify, adapt, or create derivative works of the Software; or
24
+ (d) remove, obscure, or alter any proprietary notices.
25
+
26
+ 3. Ownership. Paw Mask retains all right, title, and interest in and to the
27
+ Software, including all intellectual property rights. No rights are granted
28
+ except as expressly set out in this license.
29
+
30
+ 4. Termination. This license terminates automatically if your PSecure
31
+ subscription or evaluation/sandbox agreement lapses or is terminated, or if
32
+ you breach any term of this license. Upon termination you must cease all use
33
+ and destroy all copies of the Software.
34
+
35
+ 5. No warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
38
+
39
+ 6. Limitation of liability. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT
40
+ SHALL PAW MASK BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
41
+ CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS OR DATA, ARISING
42
+ OUT OF OR RELATED TO THE SOFTWARE.
43
+
44
+ For licensing inquiries: licensing@pawmask.com — https://pawmask.com/docs/psecure