@push.rocks/smartregistry 1.5.0 → 1.6.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.
- package/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/classes.smartregistry.d.ts +2 -2
- package/dist_ts/classes.smartregistry.js +37 -2
- package/dist_ts/core/classes.registrystorage.d.ts +77 -0
- package/dist_ts/core/classes.registrystorage.js +198 -1
- package/dist_ts/index.d.ts +3 -1
- package/dist_ts/index.js +6 -2
- package/dist_ts/pypi/classes.pypiregistry.js +22 -10
- package/dist_ts/rubygems/classes.rubygemsregistry.d.ts +86 -0
- package/dist_ts/rubygems/classes.rubygemsregistry.js +475 -0
- package/dist_ts/rubygems/helpers.rubygems.d.ts +143 -0
- package/dist_ts/rubygems/helpers.rubygems.js +312 -0
- package/dist_ts/rubygems/index.d.ts +7 -0
- package/dist_ts/rubygems/index.js +8 -0
- package/dist_ts/rubygems/interfaces.rubygems.d.ts +236 -0
- package/dist_ts/rubygems/interfaces.rubygems.js +6 -0
- package/package.json +2 -2
- package/readme.hints.md +108 -4
- package/readme.md +288 -13
- package/ts/00_commitinfo_data.ts +2 -2
- package/ts/classes.smartregistry.ts +41 -2
- package/ts/core/classes.registrystorage.ts +236 -0
- package/ts/index.ts +7 -1
- package/ts/pypi/classes.pypiregistry.ts +24 -8
- package/ts/rubygems/classes.rubygemsregistry.ts +598 -0
- package/ts/rubygems/helpers.rubygems.ts +398 -0
- package/ts/rubygems/index.ts +8 -0
- package/ts/rubygems/interfaces.rubygems.ts +251 -0
|
@@ -828,4 +828,240 @@ export class RegistryStorage implements IStorageBackend {
|
|
|
828
828
|
private getPypiPackageFilePath(packageName: string, filename: string): string {
|
|
829
829
|
return `pypi/packages/${packageName}/${filename}`;
|
|
830
830
|
}
|
|
831
|
+
|
|
832
|
+
// ========================================================================
|
|
833
|
+
// RUBYGEMS STORAGE METHODS
|
|
834
|
+
// ========================================================================
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Get RubyGems versions file (compact index)
|
|
838
|
+
*/
|
|
839
|
+
public async getRubyGemsVersions(): Promise<string | null> {
|
|
840
|
+
const path = this.getRubyGemsVersionsPath();
|
|
841
|
+
const data = await this.getObject(path);
|
|
842
|
+
return data ? data.toString('utf-8') : null;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Store RubyGems versions file (compact index)
|
|
847
|
+
*/
|
|
848
|
+
public async putRubyGemsVersions(content: string): Promise<void> {
|
|
849
|
+
const path = this.getRubyGemsVersionsPath();
|
|
850
|
+
const data = Buffer.from(content, 'utf-8');
|
|
851
|
+
return this.putObject(path, data, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Get RubyGems info file for a gem (compact index)
|
|
856
|
+
*/
|
|
857
|
+
public async getRubyGemsInfo(gemName: string): Promise<string | null> {
|
|
858
|
+
const path = this.getRubyGemsInfoPath(gemName);
|
|
859
|
+
const data = await this.getObject(path);
|
|
860
|
+
return data ? data.toString('utf-8') : null;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Store RubyGems info file for a gem (compact index)
|
|
865
|
+
*/
|
|
866
|
+
public async putRubyGemsInfo(gemName: string, content: string): Promise<void> {
|
|
867
|
+
const path = this.getRubyGemsInfoPath(gemName);
|
|
868
|
+
const data = Buffer.from(content, 'utf-8');
|
|
869
|
+
return this.putObject(path, data, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Get RubyGems names file
|
|
874
|
+
*/
|
|
875
|
+
public async getRubyGemsNames(): Promise<string | null> {
|
|
876
|
+
const path = this.getRubyGemsNamesPath();
|
|
877
|
+
const data = await this.getObject(path);
|
|
878
|
+
return data ? data.toString('utf-8') : null;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Store RubyGems names file
|
|
883
|
+
*/
|
|
884
|
+
public async putRubyGemsNames(content: string): Promise<void> {
|
|
885
|
+
const path = this.getRubyGemsNamesPath();
|
|
886
|
+
const data = Buffer.from(content, 'utf-8');
|
|
887
|
+
return this.putObject(path, data, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Get RubyGems .gem file
|
|
892
|
+
*/
|
|
893
|
+
public async getRubyGemsGem(gemName: string, version: string, platform?: string): Promise<Buffer | null> {
|
|
894
|
+
const path = this.getRubyGemsGemPath(gemName, version, platform);
|
|
895
|
+
return this.getObject(path);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Store RubyGems .gem file
|
|
900
|
+
*/
|
|
901
|
+
public async putRubyGemsGem(
|
|
902
|
+
gemName: string,
|
|
903
|
+
version: string,
|
|
904
|
+
data: Buffer,
|
|
905
|
+
platform?: string
|
|
906
|
+
): Promise<void> {
|
|
907
|
+
const path = this.getRubyGemsGemPath(gemName, version, platform);
|
|
908
|
+
return this.putObject(path, data, { 'Content-Type': 'application/octet-stream' });
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Check if RubyGems .gem file exists
|
|
913
|
+
*/
|
|
914
|
+
public async rubyGemsGemExists(gemName: string, version: string, platform?: string): Promise<boolean> {
|
|
915
|
+
const path = this.getRubyGemsGemPath(gemName, version, platform);
|
|
916
|
+
return this.objectExists(path);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* Delete RubyGems .gem file
|
|
921
|
+
*/
|
|
922
|
+
public async deleteRubyGemsGem(gemName: string, version: string, platform?: string): Promise<void> {
|
|
923
|
+
const path = this.getRubyGemsGemPath(gemName, version, platform);
|
|
924
|
+
return this.deleteObject(path);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Get RubyGems metadata
|
|
929
|
+
*/
|
|
930
|
+
public async getRubyGemsMetadata(gemName: string): Promise<any | null> {
|
|
931
|
+
const path = this.getRubyGemsMetadataPath(gemName);
|
|
932
|
+
const data = await this.getObject(path);
|
|
933
|
+
return data ? JSON.parse(data.toString('utf-8')) : null;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Store RubyGems metadata
|
|
938
|
+
*/
|
|
939
|
+
public async putRubyGemsMetadata(gemName: string, metadata: any): Promise<void> {
|
|
940
|
+
const path = this.getRubyGemsMetadataPath(gemName);
|
|
941
|
+
const data = Buffer.from(JSON.stringify(metadata, null, 2), 'utf-8');
|
|
942
|
+
return this.putObject(path, data, { 'Content-Type': 'application/json' });
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Check if RubyGems metadata exists
|
|
947
|
+
*/
|
|
948
|
+
public async rubyGemsMetadataExists(gemName: string): Promise<boolean> {
|
|
949
|
+
const path = this.getRubyGemsMetadataPath(gemName);
|
|
950
|
+
return this.objectExists(path);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Delete RubyGems metadata
|
|
955
|
+
*/
|
|
956
|
+
public async deleteRubyGemsMetadata(gemName: string): Promise<void> {
|
|
957
|
+
const path = this.getRubyGemsMetadataPath(gemName);
|
|
958
|
+
return this.deleteObject(path);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* List all RubyGems
|
|
963
|
+
*/
|
|
964
|
+
public async listRubyGems(): Promise<string[]> {
|
|
965
|
+
const prefix = 'rubygems/metadata/';
|
|
966
|
+
const objects = await this.listObjects(prefix);
|
|
967
|
+
const gems = new Set<string>();
|
|
968
|
+
|
|
969
|
+
// Extract gem names from paths like: rubygems/metadata/gem-name/metadata.json
|
|
970
|
+
for (const obj of objects) {
|
|
971
|
+
const match = obj.match(/^rubygems\/metadata\/([^\/]+)\/metadata\.json$/);
|
|
972
|
+
if (match) {
|
|
973
|
+
gems.add(match[1]);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
return Array.from(gems).sort();
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* List all versions of a RubyGem
|
|
982
|
+
*/
|
|
983
|
+
public async listRubyGemsVersions(gemName: string): Promise<string[]> {
|
|
984
|
+
const prefix = `rubygems/gems/`;
|
|
985
|
+
const objects = await this.listObjects(prefix);
|
|
986
|
+
const versions = new Set<string>();
|
|
987
|
+
|
|
988
|
+
// Extract versions from filenames: gem-name-version[-platform].gem
|
|
989
|
+
const gemPrefix = `${gemName}-`;
|
|
990
|
+
for (const obj of objects) {
|
|
991
|
+
const filename = obj.split('/').pop();
|
|
992
|
+
if (!filename || !filename.startsWith(gemPrefix) || !filename.endsWith('.gem')) continue;
|
|
993
|
+
|
|
994
|
+
// Remove gem name prefix and .gem suffix
|
|
995
|
+
const versionPart = filename.substring(gemPrefix.length, filename.length - 4);
|
|
996
|
+
|
|
997
|
+
// Split on last hyphen to separate version from platform
|
|
998
|
+
const lastHyphen = versionPart.lastIndexOf('-');
|
|
999
|
+
const version = lastHyphen > 0 ? versionPart.substring(0, lastHyphen) : versionPart;
|
|
1000
|
+
|
|
1001
|
+
versions.add(version);
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
return Array.from(versions).sort();
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Delete entire RubyGem (all versions and files)
|
|
1009
|
+
*/
|
|
1010
|
+
public async deleteRubyGem(gemName: string): Promise<void> {
|
|
1011
|
+
// Delete metadata
|
|
1012
|
+
await this.deleteRubyGemsMetadata(gemName);
|
|
1013
|
+
|
|
1014
|
+
// Delete all gem files
|
|
1015
|
+
const prefix = `rubygems/gems/`;
|
|
1016
|
+
const objects = await this.listObjects(prefix);
|
|
1017
|
+
const gemPrefix = `${gemName}-`;
|
|
1018
|
+
|
|
1019
|
+
for (const obj of objects) {
|
|
1020
|
+
const filename = obj.split('/').pop();
|
|
1021
|
+
if (filename && filename.startsWith(gemPrefix) && filename.endsWith('.gem')) {
|
|
1022
|
+
await this.deleteObject(obj);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Delete specific version of a RubyGem
|
|
1029
|
+
*/
|
|
1030
|
+
public async deleteRubyGemsVersion(gemName: string, version: string, platform?: string): Promise<void> {
|
|
1031
|
+
// Delete gem file
|
|
1032
|
+
await this.deleteRubyGemsGem(gemName, version, platform);
|
|
1033
|
+
|
|
1034
|
+
// Update metadata to remove this version
|
|
1035
|
+
const metadata = await this.getRubyGemsMetadata(gemName);
|
|
1036
|
+
if (metadata && metadata.versions) {
|
|
1037
|
+
const versionKey = platform ? `${version}-${platform}` : version;
|
|
1038
|
+
delete metadata.versions[versionKey];
|
|
1039
|
+
await this.putRubyGemsMetadata(gemName, metadata);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// ========================================================================
|
|
1044
|
+
// RUBYGEMS PATH HELPERS
|
|
1045
|
+
// ========================================================================
|
|
1046
|
+
|
|
1047
|
+
private getRubyGemsVersionsPath(): string {
|
|
1048
|
+
return 'rubygems/versions';
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
private getRubyGemsInfoPath(gemName: string): string {
|
|
1052
|
+
return `rubygems/info/${gemName}`;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
private getRubyGemsNamesPath(): string {
|
|
1056
|
+
return 'rubygems/names';
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
private getRubyGemsGemPath(gemName: string, version: string, platform?: string): string {
|
|
1060
|
+
const filename = platform ? `${gemName}-${version}-${platform}.gem` : `${gemName}-${version}.gem`;
|
|
1061
|
+
return `rubygems/gems/${filename}`;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
private getRubyGemsMetadataPath(gemName: string): string {
|
|
1065
|
+
return `rubygems/metadata/${gemName}/metadata.json`;
|
|
1066
|
+
}
|
|
831
1067
|
}
|
package/ts/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @push.rocks/smartregistry
|
|
3
|
-
* Composable registry supporting OCI, NPM, Maven, Cargo, and
|
|
3
|
+
* Composable registry supporting OCI, NPM, Maven, Cargo, Composer, PyPI, and RubyGems protocols
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Main orchestrator
|
|
@@ -23,3 +23,9 @@ export * from './cargo/index.js';
|
|
|
23
23
|
|
|
24
24
|
// Composer Registry
|
|
25
25
|
export * from './composer/index.js';
|
|
26
|
+
|
|
27
|
+
// PyPI Registry
|
|
28
|
+
export * from './pypi/index.js';
|
|
29
|
+
|
|
30
|
+
// RubyGems Registry
|
|
31
|
+
export * from './rubygems/index.js';
|
|
@@ -351,22 +351,38 @@ export class PypiRegistry extends BaseRegistry {
|
|
|
351
351
|
return this.errorResponse(403, 'Insufficient permissions');
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
// Calculate hashes
|
|
354
|
+
// Calculate and verify hashes
|
|
355
355
|
const hashes: Record<string, string> = {};
|
|
356
356
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
357
|
+
// Always calculate SHA256
|
|
358
|
+
const actualSha256 = await helpers.calculateHash(fileData, 'sha256');
|
|
359
|
+
hashes.sha256 = actualSha256;
|
|
360
|
+
|
|
361
|
+
// Verify client-provided SHA256 if present
|
|
362
|
+
if (formData.sha256_digest && formData.sha256_digest !== actualSha256) {
|
|
363
|
+
return this.errorResponse(400, 'SHA256 hash mismatch');
|
|
361
364
|
}
|
|
362
365
|
|
|
366
|
+
// Calculate MD5 if requested
|
|
363
367
|
if (formData.md5_digest) {
|
|
364
|
-
|
|
365
|
-
hashes.md5 =
|
|
368
|
+
const actualMd5 = await helpers.calculateHash(fileData, 'md5');
|
|
369
|
+
hashes.md5 = actualMd5;
|
|
370
|
+
|
|
371
|
+
// Verify if client provided MD5
|
|
372
|
+
if (formData.md5_digest !== actualMd5) {
|
|
373
|
+
return this.errorResponse(400, 'MD5 hash mismatch');
|
|
374
|
+
}
|
|
366
375
|
}
|
|
367
376
|
|
|
377
|
+
// Calculate Blake2b if requested
|
|
368
378
|
if (formData.blake2_256_digest) {
|
|
369
|
-
|
|
379
|
+
const actualBlake2b = await helpers.calculateHash(fileData, 'blake2b');
|
|
380
|
+
hashes.blake2b = actualBlake2b;
|
|
381
|
+
|
|
382
|
+
// Verify if client provided Blake2b
|
|
383
|
+
if (formData.blake2_256_digest !== actualBlake2b) {
|
|
384
|
+
return this.errorResponse(400, 'Blake2b hash mismatch');
|
|
385
|
+
}
|
|
370
386
|
}
|
|
371
387
|
|
|
372
388
|
// Store file
|