@wemush/wols 0.1.0 → 1.2.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 (58) hide show
  1. package/dist/cjs/compact-url.js +64 -0
  2. package/dist/cjs/compact-url.js.map +1 -1
  3. package/dist/cjs/crypto/decrypt.js +16 -5
  4. package/dist/cjs/crypto/decrypt.js.map +1 -1
  5. package/dist/cjs/crypto/encrypt.js +111 -9
  6. package/dist/cjs/crypto/encrypt.js.map +1 -1
  7. package/dist/cjs/index.js +53 -1
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/parser.js +3 -0
  10. package/dist/cjs/parser.js.map +1 -1
  11. package/dist/cjs/specimen.js +14 -1
  12. package/dist/cjs/specimen.js.map +1 -1
  13. package/dist/cjs/types.js +267 -3
  14. package/dist/cjs/types.js.map +1 -1
  15. package/dist/cjs/utils/environment.js +206 -0
  16. package/dist/cjs/utils/environment.js.map +1 -0
  17. package/dist/cjs/utils/migration.js +248 -0
  18. package/dist/cjs/utils/migration.js.map +1 -0
  19. package/dist/cjs/validator.js +62 -9
  20. package/dist/cjs/validator.js.map +1 -1
  21. package/dist/esm/compact-url.js +62 -0
  22. package/dist/esm/compact-url.js.map +1 -1
  23. package/dist/esm/crypto/decrypt.js +16 -5
  24. package/dist/esm/crypto/decrypt.js.map +1 -1
  25. package/dist/esm/crypto/encrypt.js +111 -9
  26. package/dist/esm/crypto/encrypt.js.map +1 -1
  27. package/dist/esm/index.js +21 -1
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/parser.js +3 -0
  30. package/dist/esm/parser.js.map +1 -1
  31. package/dist/esm/specimen.js +15 -2
  32. package/dist/esm/specimen.js.map +1 -1
  33. package/dist/esm/types.js +258 -2
  34. package/dist/esm/types.js.map +1 -1
  35. package/dist/esm/utils/environment.js +193 -0
  36. package/dist/esm/utils/environment.js.map +1 -0
  37. package/dist/esm/utils/migration.js +237 -0
  38. package/dist/esm/utils/migration.js.map +1 -0
  39. package/dist/esm/validator.js +62 -9
  40. package/dist/esm/validator.js.map +1 -1
  41. package/dist/types/compact-url.d.ts +46 -0
  42. package/dist/types/compact-url.d.ts.map +1 -1
  43. package/dist/types/crypto/decrypt.d.ts +6 -0
  44. package/dist/types/crypto/decrypt.d.ts.map +1 -1
  45. package/dist/types/crypto/encrypt.d.ts +56 -1
  46. package/dist/types/crypto/encrypt.d.ts.map +1 -1
  47. package/dist/types/index.d.ts +10 -2
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/parser.d.ts.map +1 -1
  50. package/dist/types/specimen.d.ts.map +1 -1
  51. package/dist/types/types.d.ts +246 -5
  52. package/dist/types/types.d.ts.map +1 -1
  53. package/dist/types/utils/environment.d.ts +137 -0
  54. package/dist/types/utils/environment.d.ts.map +1 -0
  55. package/dist/types/utils/migration.d.ts +162 -0
  56. package/dist/types/utils/migration.d.ts.map +1 -0
  57. package/dist/types/validator.d.ts.map +1 -1
  58. package/package.json +1 -1
@@ -4,6 +4,12 @@
4
4
  * Provides AES-256-GCM decryption for encrypted specimens using Web Crypto API.
5
5
  * Supports both password-based (PBKDF2) and raw CryptoKey decryption.
6
6
  *
7
+ * ## Self-Describing Payloads
8
+ *
9
+ * Encrypted specimens from v1.2.0+ include `iterations` in the payload, enabling
10
+ * automatic key derivation without caller needing to know encryption parameters.
11
+ * For payloads without `iterations` (pre-1.2.0), the default of 100,000 is used.
12
+ *
7
13
  * @module crypto/decrypt
8
14
  */
9
15
  import type { Specimen, EncryptedSpecimen, DecryptionOptions, ParseResult } from '../types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"decrypt.d.ts","sourceRoot":"","sources":["../../../src/crypto/decrypt.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAqE/F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAqDhC"}
1
+ {"version":3,"file":"decrypt.d.ts","sourceRoot":"","sources":["../../../src/crypto/decrypt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAwE/F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAwDhC"}
@@ -4,6 +4,54 @@
4
4
  * Provides AES-256-GCM encryption for specimens using Web Crypto API.
5
5
  * Supports both password-based (PBKDF2) and raw CryptoKey encryption.
6
6
  *
7
+ * ## Security Model
8
+ *
9
+ * This module implements a **deterministic key derivation** model optimized for:
10
+ * - Cross-environment compatibility (browser + Node.js)
11
+ * - Offline decryption (no external key storage needed)
12
+ * - Self-describing payloads (iterations stored in output)
13
+ *
14
+ * ### Password vs CryptoKey
15
+ *
16
+ * | Input Type | Use Case | Security Level |
17
+ * |------------|----------|----------------|
18
+ * | `string` (password) | Simple sharing, QR codes | Good (depends on password strength) |
19
+ * | `CryptoKey` | Server-side, key management systems | Best (full control over key material) |
20
+ *
21
+ * ### Security Considerations
22
+ *
23
+ * 1. **Fixed Salt**: The PBKDF2 salt is fixed per crypto version. This is intentional
24
+ * for deterministic cross-environment key derivation. Password strength is critical.
25
+ *
26
+ * 2. **Iteration Count**: Default 100,000 iterations. Can be increased via `iterations`
27
+ * option for higher security (at cost of performance).
28
+ *
29
+ * 3. **Random IV**: Each encryption uses a cryptographically random 96-bit IV,
30
+ * ensuring identical plaintexts produce different ciphertexts.
31
+ *
32
+ * 4. **Authenticated Encryption**: AES-256-GCM provides both confidentiality and
33
+ * integrity - tampered ciphertext will fail decryption.
34
+ *
35
+ * ## Future Specification Updates (v1.2.1+)
36
+ *
37
+ * TODO(wols-spec): The following enhancements should be documented in the upstream
38
+ * WOLS specification (wemush/open-standard/SPECIFICATION.md) in a future release:
39
+ *
40
+ * 1. **EncryptedSpecimen schema**: Define the `cryptoVersion` and `iterations` fields
41
+ * in the encrypted payload format section.
42
+ *
43
+ * 2. **Configurable iterations**: Document the `iterations` option in EncryptionOptions
44
+ * with recommended ranges (100k-600k) and minimum floor (10k).
45
+ *
46
+ * 3. **Self-describing payloads**: Explain that v1.2.0+ payloads include derivation
47
+ * parameters for forward-compatible decryption.
48
+ *
49
+ * 4. **Security guidance**: Add a security considerations section covering:
50
+ * - Fixed salt tradeoffs (determinism vs uniqueness)
51
+ * - Password strength requirements
52
+ * - When to use CryptoKey vs password
53
+ * - Optional random salt for high-security scenarios (future v2)
54
+ *
7
55
  * @module crypto/encrypt
8
56
  */
9
57
  import type { Specimen, EncryptedSpecimen, EncryptionOptions } from '../types.js';
@@ -18,10 +66,17 @@ import type { Specimen, EncryptedSpecimen, EncryptionOptions } from '../types.js
18
66
  * ```typescript
19
67
  * import { encryptSpecimen } from '@wemush/wols/crypto';
20
68
  *
69
+ * // Basic encryption with default iterations (100k)
21
70
  * const encrypted = await encryptSpecimen(specimen, {
22
71
  * key: 'my-secret-password',
23
72
  * });
24
- * // Returns: { encrypted: true, payload: "...", iv: "...", algorithm: "AES-256-GCM" }
73
+ *
74
+ * // Higher security with custom iterations
75
+ * const secureEncrypted = await encryptSpecimen(specimen, {
76
+ * key: 'my-secret-password',
77
+ * iterations: 300_000,
78
+ * });
79
+ * // Returns: { encrypted: true, payload: "...", iv: "...", algorithm: "AES-256-GCM", cryptoVersion: "v1", iterations: 300000 }
25
80
  * ```
26
81
  */
27
82
  export declare function encryptSpecimen(specimen: Specimen, options: EncryptionOptions): Promise<EncryptedSpecimen>;
@@ -1 +1 @@
1
- {"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../../src/crypto/encrypt.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAwElF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAgC5B;AA+CD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAStE"}
1
+ {"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../../src/crypto/encrypt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAkHlF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAuC5B;AAoDD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAStE"}
@@ -9,13 +9,21 @@
9
9
  * @version 1.1.0
10
10
  */
11
11
  export { WOLS_VERSION, WOLS_CONTEXT } from './types.js';
12
- export type { Brand, SpecimenId, SpecimenType, GrowthStage, Strain, Specimen, SpecimenInput, ParseResult, ValidationResult, ValidationError, ValidationWarning, ValidationOptions, SpecimenRef, QRCodeOptions, EncryptionOptions, DecryptionOptions, EncryptedSpecimen, } from './types.js';
12
+ export type { Brand, SpecimenId, SpecimenType, GrowthStage, Strain, Specimen, SpecimenInput, SpecimenMeta, ParseResult, ValidationResult, ValidationError, ValidationWarning, ValidationOptions, IdValidationMode, IdValidator, SpecimenRef, QRCodeOptions, EncryptionOptions, DecryptionOptions, EncryptedSpecimen, } from './types.js';
13
13
  export { asSpecimenId, isSpecimenType, isGrowthStage, isStrain, SPECIMEN_TYPES, GROWTH_STAGES, } from './types.js';
14
+ export { registerTypeAlias, resolveTypeAlias, getTypeAliases } from './types.js';
15
+ export { WOLS_TO_PLATFORM_MAP, mapToWolsType, mapFromWolsType, registerPlatformType, } from './types.js';
16
+ export { normalizeGeneration, isValidGeneration } from './types.js';
17
+ export type { GenerationFormat } from './types.js';
14
18
  export { WolsErrorCode, WolsError, WolsParseError, WolsValidationError, WolsEncryptionError, } from './errors.js';
15
19
  export { createSpecimen, serializeSpecimen } from './specimen.js';
16
20
  export { validateSpecimen } from './validator.js';
17
21
  export { parseSpecimen } from './parser.js';
18
- export { toCompactUrl, parseCompactUrl, SPECIES_CODES, getSpeciesFromCode, getCodeFromSpecies, registerSpeciesCode, } from './compact-url.js';
22
+ export { toCompactUrl, parseCompactUrl, parseCompactUrlOrThrow, parseCompactUrlOrNull, SPECIES_CODES, getSpeciesFromCode, getCodeFromSpecies, registerSpeciesCode, } from './compact-url.js';
19
23
  export { encryptSpecimen, isEncrypted, decryptSpecimen } from './crypto/index.js';
20
24
  export { toQRCode, toQRCodeDataURL, toQRCodeSVG, isQRAvailable, isQRAvailableSync, } from './qr/index.js';
25
+ export { isServer, isBrowser, isWebWorker, isDeno, isBun, getRuntimeEnvironment, supportsWebCrypto, supportsNodeCrypto, isCryptoSupported, supportsTextEncoding, supportsURLAPIs, } from './utils/environment.js';
26
+ export type { RuntimeEnvironment } from './utils/environment.js';
27
+ export { compareVersions, isOutdated, isNewer, getCurrentVersion, registerMigration, canMigrate, migrate, getMigrations, clearMigrations, } from './utils/migration.js';
28
+ export type { VersionComparison, MigrationHandler } from './utils/migration.js';
21
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKxD,YAAY,EAEV,KAAK,EACL,UAAU,EAGV,YAAY,EACZ,WAAW,EACX,MAAM,EACN,QAAQ,EACR,aAAa,EAGb,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAGjB,WAAW,EAGX,aAAa,EAGb,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,QAAQ,EACR,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,aAAa,EACb,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKlD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAK5C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKlF,OAAO,EACL,QAAQ,EACR,eAAe,EACf,WAAW,EACX,aAAa,EACb,iBAAiB,GAClB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKxD,YAAY,EAEV,KAAK,EACL,UAAU,EAGV,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AAQ,EACR,SAAS,EACT,WAAW,EACX,MAAM,EACN,KAAK,EACL,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAKjE,OAAO,EACL,eAAe,EACf,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,OAAO,EACP,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAyCpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAoGjE"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAKd,MAAM,YAAY,CAAC;AAyCpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAwGjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"specimen.d.ts","sourceRoot":"","sources":["../../src/specimen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAU,MAAM,YAAY,CAAC;AA2BlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,CAwC7D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CA6C5D"}
1
+ {"version":3,"file":"specimen.d.ts","sourceRoot":"","sources":["../../src/specimen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAU,MAAM,YAAY,CAAC;AAkClE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,CAsD7D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAiD5D"}
@@ -2,7 +2,7 @@
2
2
  * WOLS TypeScript Library - Core Types
3
3
  *
4
4
  * This module defines all the core types, interfaces, and enums
5
- * for the WeMush Open Labeling Standard (WOLS) v1.1.0.
5
+ * for the WeMush Open Labeling Standard (WOLS) v1.2.0.
6
6
  *
7
7
  * @packageDocumentation
8
8
  * @module @wemush/wols
@@ -10,7 +10,7 @@
10
10
  /**
11
11
  * WOLS specification version implemented by this library.
12
12
  */
13
- export declare const WOLS_VERSION = "1.1.0";
13
+ export declare const WOLS_VERSION = "1.2.0";
14
14
  /**
15
15
  * JSON-LD context URL for WOLS specimens.
16
16
  */
@@ -40,14 +40,181 @@ export type SpecimenType = 'CULTURE' | 'SPAWN' | 'SUBSTRATE' | 'FRUITING' | 'HAR
40
40
  * Array of valid specimen types for validation.
41
41
  */
42
42
  export declare const SPECIMEN_TYPES: readonly SpecimenType[];
43
+ /**
44
+ * Register a custom type alias.
45
+ *
46
+ * @param alias - The alias string (case-insensitive, stored uppercase)
47
+ * @param wolsType - The canonical WOLS SpecimenType
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * registerTypeAlias('MYCELIUM_BLOCK', 'SUBSTRATE');
52
+ * ```
53
+ */
54
+ export declare function registerTypeAlias(alias: string, wolsType: SpecimenType): void;
55
+ /**
56
+ * Resolve a type alias to its canonical WOLS type.
57
+ * Returns the input if it's already a valid SpecimenType or no alias exists.
58
+ *
59
+ * @param typeOrAlias - Type string or alias to resolve
60
+ * @returns Canonical SpecimenType or original string if not found
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * resolveTypeAlias('LIQUID_CULTURE') // Returns 'CULTURE'
65
+ * resolveTypeAlias('CULTURE') // Returns 'CULTURE'
66
+ * resolveTypeAlias('unknown') // Returns 'unknown'
67
+ * ```
68
+ */
69
+ export declare function resolveTypeAlias(typeOrAlias: string): SpecimenType | string;
70
+ /**
71
+ * Get all registered type aliases.
72
+ *
73
+ * @returns ReadonlyMap of alias -> SpecimenType mappings
74
+ */
75
+ export declare function getTypeAliases(): ReadonlyMap<string, SpecimenType>;
76
+ /**
77
+ * Mapping from WOLS types to common platform type names.
78
+ *
79
+ * This provides a centralized lookup for integrations that need to
80
+ * display user-friendly type names or map to platform-specific values.
81
+ *
82
+ * @since 1.2.0
83
+ */
84
+ export declare const WOLS_TO_PLATFORM_MAP: Readonly<Record<SpecimenType, readonly string[]>>;
85
+ /**
86
+ * Map a platform-specific type to a WOLS SpecimenType.
87
+ *
88
+ * First checks registered aliases, then falls back to direct lookup.
89
+ *
90
+ * @param platformType - Platform-specific type name
91
+ * @returns Matching SpecimenType or null if not found
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * mapToWolsType('Liquid Culture') // Returns 'CULTURE'
96
+ * mapToWolsType('LC') // Returns 'CULTURE'
97
+ * mapToWolsType('Unknown Type') // Returns null
98
+ * ```
99
+ *
100
+ * @since 1.2.0
101
+ */
102
+ export declare function mapToWolsType(platformType: string): SpecimenType | null;
103
+ /**
104
+ * Get all platform type names for a WOLS SpecimenType.
105
+ *
106
+ * @param wolsType - WOLS SpecimenType
107
+ * @returns Array of platform type names
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * mapFromWolsType('CULTURE')
112
+ * // Returns ['Liquid Culture', 'LC', 'Agar', 'Petri', 'Slant', 'Culture Plate']
113
+ * ```
114
+ *
115
+ * @since 1.2.0
116
+ */
117
+ export declare function mapFromWolsType(wolsType: SpecimenType): readonly string[];
118
+ /**
119
+ * Register a custom platform type mapping.
120
+ *
121
+ * This adds to both the alias registry (for resolveTypeAlias) and
122
+ * can be used for custom platform integrations.
123
+ *
124
+ * @param platformType - Platform-specific type name
125
+ * @param wolsType - WOLS SpecimenType to map to
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * registerPlatformType('Mycelium Block', 'SUBSTRATE');
130
+ * mapToWolsType('Mycelium Block') // Returns 'SUBSTRATE'
131
+ * ```
132
+ *
133
+ * @since 1.2.0
134
+ */
135
+ export declare function registerPlatformType(platformType: string, wolsType: SpecimenType): void;
43
136
  /**
44
137
  * Growth stage enum representing specimen lifecycle.
138
+ *
139
+ * v1.2.0 introduces research-grade lifecycle tracking with 7 stages:
140
+ * - INOCULATION: Initial introduction of spawn/culture to substrate
141
+ * - INCUBATION: Post-inoculation rest period before visible growth (v1.2.0)
142
+ * - COLONIZATION: Active mycelial growth through substrate
143
+ * - PRIMORDIA: Pin initiation and early fruit body formation (v1.2.0)
144
+ * - FRUITING: Active fruit body development and maturation
145
+ * - SENESCENCE: Declining productivity, end-of-life phase (v1.2.0)
146
+ * - HARVEST: Mushrooms harvested and processed
45
147
  */
46
- export type GrowthStage = 'INOCULATION' | 'COLONIZATION' | 'FRUITING' | 'HARVEST';
148
+ export type GrowthStage = 'INOCULATION' | 'INCUBATION' | 'COLONIZATION' | 'PRIMORDIA' | 'FRUITING' | 'SENESCENCE' | 'HARVEST';
47
149
  /**
48
150
  * Array of valid growth stages for validation.
151
+ * Ordered by typical lifecycle progression.
49
152
  */
50
153
  export declare const GROWTH_STAGES: readonly GrowthStage[];
154
+ /**
155
+ * Output format for generation normalization.
156
+ *
157
+ * - 'preserve': Keep original format
158
+ * - 'filial': Normalize to F{n} format (F1, F2, etc.)
159
+ * - 'numeric': Normalize to numeric format (1, 2, etc.)
160
+ *
161
+ * @since 1.2.0
162
+ */
163
+ export type GenerationFormat = 'preserve' | 'filial' | 'numeric';
164
+ /**
165
+ * Normalize a generation string to the specified format.
166
+ *
167
+ * Accepts multiple input formats:
168
+ * - Filial: F1, F2, F3, etc.
169
+ * - Parental: P or P1
170
+ * - Generational: G1, G2, G3, etc.
171
+ * - Numeric: 1, 2, 3, etc.
172
+ *
173
+ * @param generation - The generation string to normalize
174
+ * @param format - Target format (default: 'preserve')
175
+ * @returns Normalized generation string, or original if not parseable
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * normalizeGeneration('G2', 'filial') // Returns 'F2'
180
+ * normalizeGeneration('3', 'filial') // Returns 'F3'
181
+ * normalizeGeneration('F1', 'numeric') // Returns '1'
182
+ * normalizeGeneration('P', 'filial') // Returns 'P'
183
+ * ```
184
+ *
185
+ * @since 1.2.0
186
+ */
187
+ export declare function normalizeGeneration(generation: string, format?: GenerationFormat): string;
188
+ /**
189
+ * Check if a generation string is valid.
190
+ *
191
+ * @param generation - The generation string to validate
192
+ * @returns True if valid, false otherwise
193
+ *
194
+ * @since 1.2.0
195
+ */
196
+ export declare function isValidGeneration(generation: string): boolean;
197
+ /**
198
+ * Metadata for specimen round-trip preservation.
199
+ *
200
+ * The `_meta` namespace is reserved for implementation-specific metadata
201
+ * that should be preserved through import/export operations but is not
202
+ * part of the core WOLS specification.
203
+ *
204
+ * @since 1.2.0
205
+ */
206
+ export interface SpecimenMeta {
207
+ /** Original ID from source system before WOLS normalization */
208
+ sourceId?: string;
209
+ /** ISO 8601 timestamp when specimen was imported */
210
+ importedAt?: string;
211
+ /** Identifier of the source system (e.g., "wemush-platform", "mycology-db") */
212
+ sourceSystem?: string;
213
+ /** Schema version used by source system */
214
+ schemaVersion?: string;
215
+ /** Extensible: additional implementation-specific fields */
216
+ [key: string]: unknown;
217
+ }
51
218
  /**
52
219
  * Strain information for a specimen.
53
220
  */
@@ -95,14 +262,20 @@ export interface Specimen {
95
262
  custom?: Record<string, unknown>;
96
263
  /** Cryptographic signature */
97
264
  signature?: string;
265
+ /**
266
+ * Implementation metadata (preserved through operations).
267
+ * @since 1.2.0
268
+ */
269
+ _meta?: SpecimenMeta;
98
270
  }
99
271
  /**
100
272
  * Input type for createSpecimen().
101
273
  * Strain can be a string (auto-expanded) or full Strain object.
274
+ * Type accepts aliases (e.g., 'LIQUID_CULTURE' -> 'CULTURE') via resolveTypeAlias().
102
275
  */
103
276
  export interface SpecimenInput {
104
- /** Cultivation stage type */
105
- type: SpecimenType;
277
+ /** Cultivation stage type (accepts aliases like 'LIQUID_CULTURE' -> 'CULTURE') */
278
+ type: SpecimenType | string;
106
279
  /** Scientific species name */
107
280
  species: string;
108
281
  /** String shorthand expands to { name: string } */
@@ -117,6 +290,11 @@ export interface SpecimenInput {
117
290
  creator?: string;
118
291
  /** Custom vendor-specific fields */
119
292
  custom?: Record<string, unknown>;
293
+ /**
294
+ * Implementation metadata (preserved through operations).
295
+ * @since 1.2.0
296
+ */
297
+ _meta?: SpecimenMeta;
120
298
  }
121
299
  /**
122
300
  * Import error types for use in ParseResult.
@@ -169,6 +347,18 @@ export interface ValidationResult {
169
347
  /** Validation warnings (informational) */
170
348
  warnings: ValidationWarning[];
171
349
  }
350
+ /**
351
+ * ID validation mode for flexible ID format support.
352
+ *
353
+ * @since 1.2.0
354
+ */
355
+ export type IdValidationMode = 'strict' | 'ulid' | 'uuid' | 'any';
356
+ /**
357
+ * Custom ID validator function signature.
358
+ *
359
+ * @since 1.2.0
360
+ */
361
+ export type IdValidator = (id: string) => boolean;
172
362
  /**
173
363
  * Validation options.
174
364
  */
@@ -177,6 +367,24 @@ export interface ValidationOptions {
177
367
  allowUnknownFields?: boolean;
178
368
  /** Validation strictness level */
179
369
  level?: 'strict' | 'lenient';
370
+ /**
371
+ * ID format validation mode.
372
+ *
373
+ * - 'strict': ID must match `wemush:[a-z0-9]+` (default)
374
+ * - 'ulid': ID must be a valid ULID after wemush: prefix
375
+ * - 'uuid': ID must be a valid UUID v4 after wemush: prefix
376
+ * - 'any': Any non-empty string after wemush: prefix
377
+ *
378
+ * @since 1.2.0
379
+ */
380
+ idMode?: IdValidationMode;
381
+ /**
382
+ * Custom ID validator function.
383
+ * If provided, overrides idMode.
384
+ *
385
+ * @since 1.2.0
386
+ */
387
+ customIdValidator?: IdValidator;
180
388
  }
181
389
  /**
182
390
  * Reference data extracted from a compact URL.
@@ -225,15 +433,32 @@ export interface QRCodeOptions {
225
433
  }
226
434
  /**
227
435
  * Encryption options.
436
+ *
437
+ * @since 1.2.0 Added `iterations` option for configurable PBKDF2 strength
228
438
  */
229
439
  export interface EncryptionOptions {
230
440
  /** CryptoKey or password string for PBKDF2 */
231
441
  key: CryptoKey | string;
232
442
  /** Fields to encrypt (partial encryption) */
233
443
  fields?: string[];
444
+ /**
445
+ * PBKDF2 iteration count for password-based key derivation.
446
+ *
447
+ * Higher values increase security but slow down encryption/decryption.
448
+ * Ignored when `key` is a CryptoKey (already derived).
449
+ *
450
+ * - Default: 100000 (100k)
451
+ * - Minimum: 10000 (10k) - lower values will throw an error
452
+ * - Recommended: 100000-600000 depending on performance requirements
453
+ *
454
+ * @since 1.2.0
455
+ */
456
+ iterations?: number;
234
457
  }
235
458
  /**
236
459
  * Encrypted specimen wrapper.
460
+ *
461
+ * @since 1.2.0 Added `cryptoVersion` and `iterations` fields for migration support
237
462
  */
238
463
  export interface EncryptedSpecimen {
239
464
  /** Flag indicating this is encrypted */
@@ -246,6 +471,22 @@ export interface EncryptedSpecimen {
246
471
  algorithm: 'AES-256-GCM';
247
472
  /** Authentication tag (for GCM) */
248
473
  tag?: string;
474
+ /**
475
+ * Crypto schema version for forward-compatible migrations.
476
+ * Allows future versions to change key derivation while maintaining
477
+ * backward compatibility for decryption.
478
+ *
479
+ * @since 1.2.0
480
+ */
481
+ cryptoVersion?: 'v1';
482
+ /**
483
+ * PBKDF2 iteration count used during encryption.
484
+ * Stored in payload for self-describing decryption (no need to guess).
485
+ * If absent, defaults to 100000 for backward compatibility.
486
+ *
487
+ * @since 1.2.0
488
+ */
489
+ iterations?: number;
249
490
  }
250
491
  /**
251
492
  * Decryption options.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;GAEG;AACH,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,YAAY,+BAA+B,CAAC;AAMzD;;;GAGG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAErD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAEnD;AAMD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAEtF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAMxC,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;AAElF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAKtC,CAAC;AAMX;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mCAAmC;IACnC,OAAO,CAAC,EAAE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G,KAAK,IAAI,MAAM,CAOxD"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Environment Detection Utilities
3
+ *
4
+ * This module provides runtime environment detection for selecting
5
+ * appropriate crypto implementations and other environment-specific behavior.
6
+ *
7
+ * @module utils/environment
8
+ * @since 1.2.0
9
+ */
10
+ /**
11
+ * Runtime environment type.
12
+ *
13
+ * @since 1.2.0
14
+ */
15
+ export type RuntimeEnvironment = 'node' | 'browser' | 'webworker' | 'deno' | 'bun' | 'unknown';
16
+ /**
17
+ * Check if running in a server-side Node.js environment.
18
+ *
19
+ * @returns True if running in Node.js, false otherwise
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * if (isServer()) {
24
+ * // Use Node.js crypto module
25
+ * }
26
+ * ```
27
+ *
28
+ * @since 1.2.0
29
+ */
30
+ export declare function isServer(): boolean;
31
+ /**
32
+ * Check if running in a browser environment.
33
+ *
34
+ * @returns True if running in a browser, false otherwise
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * if (isBrowser()) {
39
+ * // Use Web Crypto API
40
+ * }
41
+ * ```
42
+ *
43
+ * @since 1.2.0
44
+ */
45
+ export declare function isBrowser(): boolean;
46
+ /**
47
+ * Check if running in a Web Worker environment.
48
+ *
49
+ * @returns True if running in a Web Worker, false otherwise
50
+ *
51
+ * @since 1.2.0
52
+ */
53
+ export declare function isWebWorker(): boolean;
54
+ /**
55
+ * Check if running in Deno environment.
56
+ *
57
+ * @returns True if running in Deno, false otherwise
58
+ *
59
+ * @since 1.2.0
60
+ */
61
+ export declare function isDeno(): boolean;
62
+ /**
63
+ * Check if running in Bun environment.
64
+ *
65
+ * @returns True if running in Bun, false otherwise
66
+ *
67
+ * @since 1.2.0
68
+ */
69
+ export declare function isBun(): boolean;
70
+ /**
71
+ * Get the current runtime environment.
72
+ *
73
+ * @returns The detected runtime environment
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const env = getRuntimeEnvironment();
78
+ * console.log(`Running in: ${env}`);
79
+ * ```
80
+ *
81
+ * @since 1.2.0
82
+ */
83
+ export declare function getRuntimeEnvironment(): RuntimeEnvironment;
84
+ /**
85
+ * Check if Web Crypto API is available.
86
+ *
87
+ * @returns True if Web Crypto API is available, false otherwise
88
+ *
89
+ * @since 1.2.0
90
+ */
91
+ export declare function supportsWebCrypto(): boolean;
92
+ /**
93
+ * Check if Node.js crypto module is available.
94
+ *
95
+ * Note: This performs a synchronous check and does not actually import the module.
96
+ *
97
+ * @returns True if likely running in Node.js with crypto support, false otherwise
98
+ *
99
+ * @since 1.2.0
100
+ */
101
+ export declare function supportsNodeCrypto(): boolean;
102
+ /**
103
+ * Check if any cryptographic support is available.
104
+ *
105
+ * This is useful for determining if encryption/decryption features can be used.
106
+ *
107
+ * @returns True if crypto is supported, false otherwise
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * if (isCryptoSupported()) {
112
+ * const encrypted = await encryptSpecimen(specimen, { key: password });
113
+ * } else {
114
+ * console.warn('Crypto not supported in this environment');
115
+ * }
116
+ * ```
117
+ *
118
+ * @since 1.2.0
119
+ */
120
+ export declare function isCryptoSupported(): boolean;
121
+ /**
122
+ * Check if TextEncoder/TextDecoder are available.
123
+ *
124
+ * @returns True if text encoding is supported, false otherwise
125
+ *
126
+ * @since 1.2.0
127
+ */
128
+ export declare function supportsTextEncoding(): boolean;
129
+ /**
130
+ * Check if URL and URLSearchParams are available.
131
+ *
132
+ * @returns True if URL APIs are supported, false otherwise
133
+ *
134
+ * @since 1.2.0
135
+ */
136
+ export declare function supportsURLAPIs(): boolean;
137
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;AAM/F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAMlC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAMnC;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAkBrC;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAKhC;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAK/B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,CAO1D;AAMD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAM3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAMD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAM9C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAMzC"}