@platform-sec/sensitive-string-testing 0.0.0-stage → 0.2.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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +329 -2
  3. package/dist/assertions.d.ts +81 -0
  4. package/dist/assertions.d.ts.map +1 -0
  5. package/dist/assertions.js +132 -0
  6. package/dist/assertions.js.map +1 -0
  7. package/dist/canary.d.ts +49 -0
  8. package/dist/canary.d.ts.map +1 -0
  9. package/dist/canary.js +116 -0
  10. package/dist/canary.js.map +1 -0
  11. package/dist/create-test-secret.d.ts +78 -0
  12. package/dist/create-test-secret.d.ts.map +1 -0
  13. package/dist/create-test-secret.js +91 -0
  14. package/dist/create-test-secret.js.map +1 -0
  15. package/dist/describe-type.d.ts +16 -0
  16. package/dist/describe-type.d.ts.map +1 -0
  17. package/dist/describe-type.js +35 -0
  18. package/dist/describe-type.js.map +1 -0
  19. package/dist/index.d.ts +51 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +77 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/leak-scan.d.ts +94 -0
  24. package/dist/leak-scan.d.ts.map +1 -0
  25. package/dist/leak-scan.js +309 -0
  26. package/dist/leak-scan.js.map +1 -0
  27. package/dist/matchers.d.ts +93 -0
  28. package/dist/matchers.d.ts.map +1 -0
  29. package/dist/matchers.js +170 -0
  30. package/dist/matchers.js.map +1 -0
  31. package/dist/mocks.d.ts +140 -0
  32. package/dist/mocks.d.ts.map +1 -0
  33. package/dist/mocks.js +146 -0
  34. package/dist/mocks.js.map +1 -0
  35. package/dist/serializer.d.ts +136 -0
  36. package/dist/serializer.d.ts.map +1 -0
  37. package/dist/serializer.js +210 -0
  38. package/dist/serializer.js.map +1 -0
  39. package/dist/vitest.d.ts +59 -0
  40. package/dist/vitest.d.ts.map +1 -0
  41. package/dist/vitest.js +3 -0
  42. package/dist/vitest.js.map +1 -0
  43. package/package.json +55 -3
@@ -0,0 +1,59 @@
1
+ import type { Assertion as VitestAssertion, expect as vitestExpect } from 'vitest';
2
+ import type { SensitiveMatchers } from './matchers.js';
3
+ import type { SnapshotSerializerPlugin } from './serializer.js';
4
+ /**
5
+ * Ready-made Vitest type augmentation.
6
+ *
7
+ * Import it once, from a setup file or from a `.d.ts` in the consuming project:
8
+ *
9
+ * ```ts
10
+ * import '@platform-sec/sensitive-string-testing/vitest';
11
+ * ```
12
+ *
13
+ * Registering the matchers is separate and still required; see
14
+ * `setupSensitiveMatchers`. This module only teaches TypeScript about them, and
15
+ * emits nothing at runtime.
16
+ *
17
+ * The type parameter list has to match Vitest's own declaration exactly for the
18
+ * interfaces to merge, which is where `T = any` comes from.
19
+ *
20
+ * @packageDocumentation
21
+ */
22
+ declare module 'vitest' {
23
+ interface Assertion<T = any> extends SensitiveMatchers<T> {
24
+ }
25
+ interface AsymmetricMatchersContaining extends SensitiveMatchers {
26
+ }
27
+ }
28
+ /**
29
+ * Vitest's assertion type, re-exported.
30
+ *
31
+ * The re-export is what puts Vitest's own declarations into the program. Under
32
+ * CommonJS resolution, `vitest` resolves to a re-export barrel that carries no
33
+ * declarations of its own, and an augmentation of a module nothing else pulls
34
+ * in fails to resolve. A consumer whose project is CommonJS therefore needs
35
+ * this import as much as this package's own build does.
36
+ */
37
+ export type SensitiveAssertion<T> = VitestAssertion<T>;
38
+ /**
39
+ * The plugin type Vitest's `expect.addSnapshotSerializer` accepts, which is
40
+ * `pretty-format`'s own.
41
+ */
42
+ type VitestSnapshotSerializer = Parameters<typeof vitestExpect.addSnapshotSerializer>[0];
43
+ /** Fails to compile unless `T` is `true`. */
44
+ type Assert<T extends true> = T;
45
+ /**
46
+ * A compile-time proof that `sensitiveSerializer` is the shape Vitest accepts.
47
+ *
48
+ * `SnapshotSerializerPlugin` is declared structurally in `serializer.ts` rather
49
+ * than imported from `pretty-format`, which is what keeps this package free of
50
+ * a dependency on a test framework. The cost of writing a type out by hand is
51
+ * that it can drift from the one it is meant to match, and nothing would say
52
+ * so: the test suite runs through esbuild, which strips types without checking
53
+ * them, so a serializer Vitest rejects would still pass every test in this
54
+ * repository. This alias is checked by `tsc` during the build, so the drift is
55
+ * a failed build instead.
56
+ */
57
+ export type SensitiveSerializerFitsVitest = Assert<SnapshotSerializerPlugin extends VitestSnapshotSerializer ? true : false>;
58
+ export {};
59
+ //# sourceMappingURL=vitest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,SAAS,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;KAAG;IAC5D,UAAU,4BAA6B,SAAQ,iBAAiB;KAAG;CACpE;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;AAEvD;;;GAGG;AACH,KAAK,wBAAwB,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzF,6CAA6C;AAC7C,KAAK,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAChD,wBAAwB,SAAS,wBAAwB,GAAG,IAAI,GAAG,KAAK,CACzE,CAAC"}
package/dist/vitest.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@platform-sec/sensitive-string-testing",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.1",
4
+ "description": "Test secrets, leak assertions, matchers, and audit mocks for SensitiveString",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./vitest": {
14
+ "types": "./dist/vitest.d.ts",
15
+ "default": "./dist/vitest.js"
16
+ },
17
+ "./serializer": {
18
+ "types": "./dist/serializer.d.ts",
19
+ "default": "./dist/serializer.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "keywords": [
26
+ "testing",
27
+ "vitest",
28
+ "jest",
29
+ "matchers",
30
+ "snapshot",
31
+ "security",
32
+ "sensitive-data",
33
+ "typescript"
34
+ ],
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/platform-sec/sensitive-string-js.git",
39
+ "directory": "packages/sensitive-testing"
40
+ },
41
+ "engines": {
42
+ "node": ">=22.12.0"
43
+ },
44
+ "peerDependencies": {
45
+ "@platform-sec/sensitive-string-core": "^0.6.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22.20.5",
49
+ "typescript": "^5.9.3",
50
+ "vitest": "^4.1.12",
51
+ "@platform-sec/sensitive-string-core": "0.6.1"
52
+ },
53
+ "scripts": {
54
+ "build": "tsc",
55
+ "test": "vitest run --root ../.. packages/sensitive-testing/",
56
+ "test:watch": "vitest --root ../.. packages/sensitive-testing/"
57
+ }
6
58
  }