neozipkit 0.1.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 (135) hide show
  1. package/README.md +400 -0
  2. package/contracts/Lock.sol +34 -0
  3. package/contracts/bytecode.txt +1 -0
  4. package/contracts/compile-contract.js +168 -0
  5. package/contracts/deploy/deploy-both-contracts.js +286 -0
  6. package/contracts/deploy/deploy-enhanced-contract.js +197 -0
  7. package/contracts/deploy/deploy-private-contract.js +190 -0
  8. package/contracts/deploy/deploy-public-clean.js +1063 -0
  9. package/contracts/deploy/deploy-public-contract.js +1107 -0
  10. package/contracts/deployment.config.example.js +25 -0
  11. package/contracts/remix-compile.js +222 -0
  12. package/contracts/setup-deployment.js +51 -0
  13. package/contracts/src/NZIP-NFT-Private.sol +350 -0
  14. package/contracts/src/NZIP-NFT.sol +265 -0
  15. package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +260 -0
  16. package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +289 -0
  17. package/dist/browser/CertificateGeneratorBrowser.d.ts +75 -0
  18. package/dist/browser/CertificateGeneratorBrowser.js +433 -0
  19. package/dist/browser/TokenVerifierBrowser.d.ts +76 -0
  20. package/dist/browser/TokenVerifierBrowser.js +299 -0
  21. package/dist/browser/ZipKitBrowser.d.ts +18 -0
  22. package/dist/browser/ZipKitBrowser.js +250 -0
  23. package/dist/browser/ZipKitStampBrowser.d.ts +2 -0
  24. package/dist/browser/ZipKitStampBrowser.js +12 -0
  25. package/dist/browser-index.d.ts +21 -0
  26. package/dist/browser-index.js +58 -0
  27. package/dist/browser.d.ts +21 -0
  28. package/dist/browser.js +58 -0
  29. package/dist/index.d.ts +29 -0
  30. package/dist/index.js +76 -0
  31. package/dist/server/blockchain/CertificateToken.d.ts +48 -0
  32. package/dist/server/blockchain/CertificateToken.js +386 -0
  33. package/dist/server/blockchain/NFTMinter.d.ts +41 -0
  34. package/dist/server/blockchain/NFTMinter.js +323 -0
  35. package/dist/server/blockchain/TokenQuerier.d.ts +31 -0
  36. package/dist/server/blockchain/TokenQuerier.js +259 -0
  37. package/dist/server/blockchain/TokenVerifier.d.ts +20 -0
  38. package/dist/server/blockchain/TokenVerifier.js +395 -0
  39. package/dist/server/blockchain/WalletAnalyzer.d.ts +81 -0
  40. package/dist/server/blockchain/WalletAnalyzer.js +356 -0
  41. package/dist/server/blockchain/WalletFormatter.d.ts +39 -0
  42. package/dist/server/blockchain/WalletFormatter.js +196 -0
  43. package/dist/server/blockchain/WalletManager.d.ts +46 -0
  44. package/dist/server/blockchain/WalletManager.js +294 -0
  45. package/dist/server/blockchain/ZipMetadata.d.ts +27 -0
  46. package/dist/server/blockchain/ZipMetadata.js +131 -0
  47. package/dist/server/blockchain/ZipTokenProcessor.d.ts +44 -0
  48. package/dist/server/blockchain/ZipTokenProcessor.js +204 -0
  49. package/dist/server/blockchain/constants.d.ts +102 -0
  50. package/dist/server/blockchain/constants.js +968 -0
  51. package/dist/server/blockchain/index.d.ts +9 -0
  52. package/dist/server/blockchain/index.js +44 -0
  53. package/dist/server/blockchain/test-certificate.d.ts +8 -0
  54. package/dist/server/blockchain/test-certificate.js +100 -0
  55. package/dist/server/blockchain/types.d.ts +69 -0
  56. package/dist/server/blockchain/types.js +51 -0
  57. package/dist/server/platform/server/ZipKitServer.d.ts +105 -0
  58. package/dist/server/platform/server/ZipKitServer.js +437 -0
  59. package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +91 -0
  60. package/dist/server/platform/servercomponents/ZipKitOTS.js +271 -0
  61. package/dist/shared/ZipEntry.d.ts +131 -0
  62. package/dist/shared/ZipEntry.js +686 -0
  63. package/dist/shared/ZipKit.d.ts +249 -0
  64. package/dist/shared/ZipKit.js +789 -0
  65. package/dist/shared/components/CertificateOTS.d.ts +15 -0
  66. package/dist/shared/components/CertificateOTS.js +116 -0
  67. package/dist/shared/components/FileSys.d.ts +2 -0
  68. package/dist/shared/components/FileSys.js +113 -0
  69. package/dist/shared/components/HashAccumulator.d.ts +55 -0
  70. package/dist/shared/components/HashAccumulator.js +100 -0
  71. package/dist/shared/components/Support.d.ts +63 -0
  72. package/dist/shared/components/Support.js +70 -0
  73. package/dist/shared/components/Util.d.ts +21 -0
  74. package/dist/shared/components/Util.js +115 -0
  75. package/dist/shared/components/ZipCrypto.d.ts +3 -0
  76. package/dist/shared/components/ZipCrypto.js +78 -0
  77. package/dist/shared/components/merkleTree.d.ts +66 -0
  78. package/dist/shared/components/merkleTree.js +136 -0
  79. package/dist/shared/constants/Errors.d.ts +53 -0
  80. package/dist/shared/constants/Errors.js +69 -0
  81. package/dist/shared/constants/Headers.d.ts +167 -0
  82. package/dist/shared/constants/Headers.js +191 -0
  83. package/dist/shared/types/index.d.ts +21 -0
  84. package/dist/shared/types/index.js +3 -0
  85. package/dist/shared/types.d.ts +33 -0
  86. package/dist/shared/types.js +8 -0
  87. package/dist/shared/version.d.ts +4 -0
  88. package/dist/shared/version.js +7 -0
  89. package/dist/types/index.d.ts +21 -0
  90. package/dist/types/index.js +3 -0
  91. package/examples/unzip-token.ts +488 -0
  92. package/examples/zip-token.ts +604 -0
  93. package/package.json +117 -0
  94. package/src/browser/CertificateGeneratorBrowser.ts +498 -0
  95. package/src/browser/TokenVerifierBrowser.ts +344 -0
  96. package/src/browser/ZipKitBrowser.ts +242 -0
  97. package/src/browser/ZipKitStampBrowser.ts +9 -0
  98. package/src/browser-index.ts +36 -0
  99. package/src/index.ts +48 -0
  100. package/src/server/blockchain/CertificateToken.ts +444 -0
  101. package/src/server/blockchain/NFTMinter.ts +357 -0
  102. package/src/server/blockchain/TokenQuerier.ts +287 -0
  103. package/src/server/blockchain/TokenVerifier.ts +453 -0
  104. package/src/server/blockchain/WalletAnalyzer.ts +397 -0
  105. package/src/server/blockchain/WalletFormatter.ts +206 -0
  106. package/src/server/blockchain/WalletManager.ts +294 -0
  107. package/src/server/blockchain/ZipMetadata.ts +117 -0
  108. package/src/server/blockchain/ZipTokenProcessor.ts +234 -0
  109. package/src/server/blockchain/constants.ts +969 -0
  110. package/src/server/blockchain/index.ts +42 -0
  111. package/src/server/blockchain/test-certificate.ts +137 -0
  112. package/src/server/blockchain/types.ts +134 -0
  113. package/src/server/platform/server/ZipKitServer.ts +459 -0
  114. package/src/server/platform/servercomponents/ZipKitOTS.ts +313 -0
  115. package/src/server/platform/servercomponents/opentimestamps.d.ts +23 -0
  116. package/src/shared/ZipEntry.ts +767 -0
  117. package/src/shared/ZipKit.ts +899 -0
  118. package/src/shared/components/CertificateOTS.ts +132 -0
  119. package/src/shared/components/FileSys.ts +87 -0
  120. package/src/shared/components/HashAccumulator.ts +113 -0
  121. package/src/shared/components/Support.ts +77 -0
  122. package/src/shared/components/Util.ts +113 -0
  123. package/src/shared/components/ZipCrypto.ts +91 -0
  124. package/src/shared/components/merkleTree.ts +162 -0
  125. package/src/shared/constants/Errors.ts +82 -0
  126. package/src/shared/constants/Headers.ts +203 -0
  127. package/src/shared/types/index.ts +25 -0
  128. package/src/shared/types/modules.d.ts +22 -0
  129. package/src/shared/types/opentimestamps.d.ts +23 -0
  130. package/src/shared/types.d.ts +8 -0
  131. package/src/shared/types.ts +43 -0
  132. package/src/shared/version.ts +4 -0
  133. package/src/types/index.ts +25 -0
  134. package/src/types/modules.d.ts +22 -0
  135. package/src/types/opentimestamps.d.ts +23 -0
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ // ======================================
3
+ // Headers.ts
4
+ // Copyright (c) 2024 NeoWare, Inc. All rights reserved.
5
+ // ======================================
6
+ // Zip File Format Constants
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.DOS_FILE_ATTR = exports.FILE_SYSTEM = exports.HDR_ID = exports.EXTENSIBLE_DATA_FIELDS = exports.GP_FLAG = exports.CMP_METHOD = exports.ZIP64_CENTRAL_END = exports.ZIP64_CENTRAL_DIR = exports.CENTRAL_END = exports.CENTRAL_DIR = exports.DATA_DESC = exports.ENCRYPT_HDR_SIZE = exports.LOCAL_HDR = exports.TOKENIZED_METADATA = exports.TIMESTAMP_METADATA = exports.TIMESTAMP_SUBMITTED = exports.DATA_DESCRIPTOR = exports.ZIP64_CENTRAL_DIRECTORY_END = exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = exports.CENTRAL_DIRECTORY_END = exports.CENTRAL_FILE_HEADER = exports.LOCAL_FILE_HEADER = void 0;
9
+ exports.LOCAL_FILE_HEADER = 'PK\x03\x04';
10
+ exports.CENTRAL_FILE_HEADER = 'PK\x01\x02';
11
+ exports.CENTRAL_DIRECTORY_END = 'PK\x05\x06';
12
+ exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = 'PK\x06\x07';
13
+ exports.ZIP64_CENTRAL_DIRECTORY_END = 'PK\x06\x06';
14
+ exports.DATA_DESCRIPTOR = 'PK\x07\x08';
15
+ exports.TIMESTAMP_SUBMITTED = 'META-INF/TS-SUBMIT.OTS';
16
+ exports.TIMESTAMP_METADATA = 'META-INF/TIMESTAMP.OTS';
17
+ exports.TOKENIZED_METADATA = 'META-INF/NZIP.TOKEN';
18
+ // Local file header
19
+ exports.LOCAL_HDR = {
20
+ SIZE: 30, // LOC header size in bytes
21
+ SIGNATURE: 0x04034b50, // "PK\003\004"
22
+ VER_EXTRACT: 4, // version needed to extract
23
+ FLAGS: 6, // general purpose bit flag
24
+ COMPRESSION: 8, // compression method
25
+ TIMEDATE_DOS: 10, // modification time (2 bytes time, 2 bytes date)
26
+ CRC: 14, // uncompressed file crc-32 value
27
+ CMP_SIZE: 18, // compressed size
28
+ UNCMP_SIZE: 22, // uncompressed size
29
+ FNAME_LEN: 26, // filename length
30
+ EXTRA_LEN: 28 // extra field length
31
+ };
32
+ exports.ENCRYPT_HDR_SIZE = 12;
33
+ // Data descriptor
34
+ exports.DATA_DESC = {
35
+ SIGNATURE: 0x08074b50, // "PK\007\008"
36
+ SIZE: 16, // EXT header size in bytes
37
+ CRC: 4, // uncompressed file crc-32 value (offset)
38
+ CMP_SIZE: 8, // compressed size (offset)
39
+ UNCMP_SIZE: 12 // uncompressed size
40
+ };
41
+ // The central directory file header
42
+ exports.CENTRAL_DIR = {
43
+ SIZE: 46, // Central directory header size
44
+ SIGNATURE: 0x02014b50, // "PK\001\002"
45
+ VER_MADE: 4, // version made by
46
+ VER_EXT: 6, // version needed to extract
47
+ FLAGS: 8, // encrypt, decrypt flags
48
+ CMP_METHOD: 10, // compression method
49
+ TIMEDATE_DOS: 12, // DOS modification time (2 bytes time, 2 bytes date)
50
+ CRC: 16, // uncompressed file crc-32 value
51
+ CMP_SIZE: 20, // compressed size
52
+ UNCMP_SIZE: 24, // uncompressed size
53
+ FNAME_LEN: 28, // filename length
54
+ EXTRA_LEN: 30, // extra field length
55
+ COMMENT_LEN: 32, // file comment length
56
+ DISK_NUM: 34, // volume number start
57
+ INT_FILE_ATTR: 36, // internal file attributes
58
+ EXT_FILE_ATTR: 38, // external file attributes (host system dependent)
59
+ LOCAL_HDR_OFFSET: 42 // LOC header offset
60
+ };
61
+ // The Zip central directory Locator
62
+ exports.CENTRAL_END = {
63
+ SIZE: 22, // END header size
64
+ SIGNATURE: 0x06054b50, // "PK\005\006"
65
+ VOL_NUM: 4, // number of this disk
66
+ VOLDIR_START: 6, // number of the volume/disk with start of the Central Directory
67
+ VOL_ENTRIES: 8, // number of entries on this volume/disk
68
+ TOTAL_ENTRIES: 10, // total number of entries on this disk
69
+ CENTRAL_DIR_SIZE: 12, // central directory size in bytes
70
+ CENTRAL_DIR_OFFSET: 16, // offset of first CEN header
71
+ ZIP_COMMENT_LEN: 20 // zip file comment length
72
+ };
73
+ // Zip64 Central Directory Entry
74
+ exports.ZIP64_CENTRAL_DIR = {
75
+ SIGNATURE: 0x06064b50, // zip64 signature, "PK\006\006"
76
+ SIZE: 56, // zip64 record minimum size
77
+ LEAD: 12, // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
78
+ SIZE_FIELD: 4, // zip64 size of the central directory record
79
+ VER_MADEBY: 12, // zip64 version made by
80
+ VER_NEEDED: 14, // zip64 version needed to extract
81
+ VOL_NUM: 16, // zip64 number of this disk
82
+ VOLDIR_START: 20, // number of the disk with the start of the record directory
83
+ VOL_ENTRIES: 24, // number of entries on this disk
84
+ TOTAL_ENTRIES: 32, // total number of entries
85
+ CENTRAL_DIR_SIZE: 40, // zip64 central directory size in bytes
86
+ CENTRAL_DIR_OFFSET: 48, // offset of start of central directory with respect to the starting disk number
87
+ EXTRA_FIELD: 56 // extensible data sector
88
+ };
89
+ // Zip64 Central directory locator
90
+ exports.ZIP64_CENTRAL_END = {
91
+ SIZE: 20, // zip64 END header size
92
+ SIGNATURE: 0x07064b50, // zip64 Locator signature, "PK\006\007"
93
+ VOL_NUM: 4, // number of the disk with the start of the zip64
94
+ CENTRAL_DIR_OFFSET: 8, // relative offset of the zip64 end of central directory
95
+ TOTAL_DISKS: 16 // total number of disks
96
+ };
97
+ // Compression methods
98
+ exports.CMP_METHOD = {
99
+ STORED: 0, // no compression
100
+ SHRUNK: 1, // shrunk
101
+ REDUCED1: 2, // reduced with compression factor 1
102
+ REDUCED2: 3, // reduced with compression factor 2
103
+ REDUCED3: 4, // reduced with compression factor 3
104
+ REDUCED4: 5, // reduced with compression factor 4
105
+ IMPLODED: 6, // imploded
106
+ DEFLATED: 8, // deflated
107
+ ENHANCED_DEFLATE: 9, // enhanced deflated
108
+ BZIP2: 12, // compressed using BZIP2
109
+ LZMA: 14, // LZMA
110
+ IBM_TERSE: 18, // compressed using IBM TERSE
111
+ IBM_LZ77: 19, // IBM LZ77
112
+ ZSTD: 93, // Zstandard compression
113
+ AES_ENCRYPT: 99 // WinZIP AES encryption method
114
+ };
115
+ // General purpose bit flag
116
+ exports.GP_FLAG = {
117
+ ENCRYPTED: 1, // Bit 0: encrypted file
118
+ COMPRESSION1: 2, // Bit 1, compression option
119
+ COMPRESSION2: 4, // Bit 2, compression option
120
+ DATA_DESC: 8, // Bit 3, data descriptor
121
+ ENHANCED_DEFLATE: 16, // Bit 4, enhanced deflating
122
+ PATCHED: 32, // Bit 5, indicates that the file is compressed patched data.
123
+ STRONG_ENCRYPT: 64, // Bit 6, strong encryption (patented)
124
+ // Bits 7-10: Currently unused.
125
+ EFS: 2048, // Bit 11: Language encoding flag (EFS)
126
+ // Bit 12: Reserved by PKWARE for enhanced compression.
127
+ // Bit 13: encrypted the Central Directory (patented).
128
+ // Bits 14-15: Reserved by PKWARE.
129
+ MASK: 4096, // mask header values
130
+ };
131
+ // 4.5 Extensible data fields
132
+ exports.EXTENSIBLE_DATA_FIELDS = {
133
+ ID: 0,
134
+ SIZE: 2,
135
+ };
136
+ // Header IDs
137
+ exports.HDR_ID = {
138
+ ZIP64: 0x0001,
139
+ AVINFO: 0x0007,
140
+ PFS: 0x0008,
141
+ OS2: 0x0009,
142
+ NTFS: 0x000a,
143
+ OPENVMS: 0x000c,
144
+ UNIX: 0x000d,
145
+ FORK: 0x000e,
146
+ PATCH: 0x000f,
147
+ x509PKCS7: 0x0014,
148
+ x509CERT_IDF: 0x0015,
149
+ x509CERT_IDC: 0x0016,
150
+ STRONG_ENC: 0x0017,
151
+ RECORD_MGT: 0x0018,
152
+ x509PKCS7RL: 0x0019,
153
+ IBM1: 0x0065,
154
+ IBM2: 0x0066,
155
+ SHA256: 0x014E, // SHA256 "N\01" with 64 bytes (256 bit) of SHA256 hash data
156
+ POSZIP: 0x4690, // POSZIP 4690
157
+ UNV_TIME: 0x5455, // Universal Time (UT) (32-bit) 5 data bytes
158
+ UID_GID: 0x7875, // Unix UID/GID (any size)
159
+ UNICODE_PATH: 0x7075, // Info-ZIP Unicode Path Extra Field
160
+ };
161
+ // File System
162
+ exports.FILE_SYSTEM = {
163
+ MSDOS: 0, // MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)
164
+ AMIGA: 1, // Amiga
165
+ OPENVMS: 2, // OpenVMS
166
+ UNIX: 3, // UNIX
167
+ VM_CMS: 4, // VM/CMS
168
+ ATARI: 5, // Atari ST
169
+ OS2: 6, // OS/2 H.P.F.S.
170
+ MAC: 7, // Macintosh
171
+ CP_M: 9, // CP/M
172
+ NTFS: 10, // Windows NTFS
173
+ MVS: 11, // MVS (OS/390 - Z/OS)
174
+ VSE: 12, // VSE
175
+ ACORN: 13, // Acorn Risc
176
+ VFAT: 14, // VFAT
177
+ ALTMVS: 15, // Alternate MVS
178
+ BEOS: 16, // BeOS
179
+ TANDEM: 17, // Tandem
180
+ OS400: 18, // OS/400
181
+ DARWIN: 19 // Apple OS/X (Darwin)
182
+ };
183
+ // DOS File Attributes
184
+ exports.DOS_FILE_ATTR = {
185
+ READONLY: 0x01,
186
+ HIDDEN: 0x02,
187
+ SYSTEM: 0x04,
188
+ VOLUME: 0x08,
189
+ DIRECTORY: 0x10,
190
+ ARCHIVE: 0x20
191
+ };
@@ -0,0 +1,21 @@
1
+ export interface FileData {
2
+ name: string;
3
+ size: number;
4
+ lastModified: number;
5
+ arrayBuffer(): Promise<ArrayBuffer>;
6
+ }
7
+ export interface ZipFileEntry {
8
+ fileData?: FileData;
9
+ }
10
+ export interface Support {
11
+ base64: boolean;
12
+ array: boolean;
13
+ string: boolean;
14
+ isNode: boolean;
15
+ buffer: boolean;
16
+ uint8array: boolean;
17
+ arrayBuffer: boolean;
18
+ blob: boolean;
19
+ streams: boolean;
20
+ fileReader: boolean;
21
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // External module types are handled by installed @types packages
@@ -0,0 +1,33 @@
1
+ export interface FileData {
2
+ name: string;
3
+ size: number;
4
+ lastModified: number;
5
+ arrayBuffer(): Promise<ArrayBuffer>;
6
+ }
7
+ export interface FileReader extends EventTarget {
8
+ readAsArrayBuffer(blob: Blob): void;
9
+ onload: ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null;
10
+ onerror: ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null;
11
+ result: string | ArrayBuffer | null;
12
+ error: Error | null;
13
+ }
14
+ export interface ZipFileEntry {
15
+ filename: string;
16
+ comment?: string | null;
17
+ fileData?: FileData;
18
+ fileBuffer?: Buffer | null;
19
+ isDirectory: boolean;
20
+ isMetaData: boolean;
21
+ isEncrypted: boolean;
22
+ sha256?: string | null;
23
+ }
24
+ export interface AttestationValue {
25
+ blockHeight: number;
26
+ transactionId: string;
27
+ merkleRoot: string;
28
+ }
29
+ export interface NeoZipKitInfo {
30
+ version: string;
31
+ releaseDate: string;
32
+ }
33
+ export declare const NEOZIPKIT_INFO: NeoZipKitInfo;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NEOZIPKIT_INFO = void 0;
4
+ const version_1 = require("./version");
5
+ exports.NEOZIPKIT_INFO = {
6
+ version: version_1.VERSION.number,
7
+ releaseDate: version_1.VERSION.date
8
+ };
@@ -0,0 +1,4 @@
1
+ export declare const VERSION: {
2
+ number: string;
3
+ date: string;
4
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = void 0;
4
+ exports.VERSION = {
5
+ number: '0.1.51',
6
+ date: '04-17-2025'
7
+ };
@@ -0,0 +1,21 @@
1
+ export interface FileData {
2
+ name: string;
3
+ size: number;
4
+ lastModified: number;
5
+ arrayBuffer(): Promise<ArrayBuffer>;
6
+ }
7
+ export interface ZipFileEntry {
8
+ fileData?: FileData;
9
+ }
10
+ export interface Support {
11
+ base64: boolean;
12
+ array: boolean;
13
+ string: boolean;
14
+ isNode: boolean;
15
+ buffer: boolean;
16
+ uint8array: boolean;
17
+ arrayBuffer: boolean;
18
+ blob: boolean;
19
+ streams: boolean;
20
+ fileReader: boolean;
21
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // External module types are handled by installed @types packages