Skip to content

Commit

Permalink
feat: adding MIME types as codec types
Browse files Browse the repository at this point in the history
Each MIME type is added as a codec which codec name is prefixed with '/mime/', i.e.:

	/mime/<mime-type-here>

Based on the information at [1] the following ranges are reserved for any mime types/subtypes:

	Range 0x1000 - 0x17ff: (11 bits) reserved for 'application/*' (there currently are ~1,300 subtypes)
	Range 0x1800 - 0x18ff:  (8 bits) reserved for 'audio/*' (there currently are ~150 subtypes)
	Range 0x1900 - 0x190f:  (4 bits) reserved for 'font/*' (there currently are ~8 subtypes)
	Range 0x1910 - 0x197f:  (7 bits) reserved for 'image/*' (there currently are ~60 subtypes)
	Range 0x1980 - 0x19cf:  (5 bits) reserved for 'message/*' (there currently are ~18 subtypes)
	Range 0x19d0 - 0x1a3f:  (6 bits) reserved for 'model/*' (there currently are ~24 subtypes)
	Range 0x1a40 - 0x1a8f:  (5 bits) reserved for 'multipart/*' (there currently are ~13 subtypes)
	Range 0x1a90 - 0x1aff:  (7 bits) reserved for 'text/*' (there currently are ~71 subtypes)
	Range 0x1b00 - 0x1b6f:  (7 bits) reserved for 'video/*' (there currently are ~78 subtypes)

In this PR only the MIME types listed at [2] are declared since these should
be the most relevant for the web, plus a few additional ones useful for the semantic web.

[1]: https://www.iana.org/assignments/media-types/media-types.xhtml
[2]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types
  • Loading branch information
bochaco committed Sep 7, 2018
1 parent 69e2296 commit 09b6652
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions src/base-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,106 @@ exports['stellar-tx'] = Buffer.from('d1', 'hex')
exports['torrent-info'] = Buffer.from('7b', 'hex')
exports['torrent-file'] = Buffer.from('7c', 'hex')
exports['ed25519-pub'] = Buffer.from('ed', 'hex')

/* MIME Types as codecs:
*
* Based on the information at https://www.iana.org/assignments/media-types/media-types.xhtml
* the following ranges can be reserved for the different mime types/subtypes.
* In this implementation we are only declaring the mime types listed in the following article
* since these should be the most relevant for the web, plus a few more useful for the semantic web:
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types
*/
// Range 0x1000 - 0x17ff (11 bits) reserved for 'application/*' (there currently are ~1,300 subtypes)
exports['mime/application/x-abiword'] = Buffer.from('1000', 'hex')
exports['mime/application/octet-stream'] = Buffer.from('1001', 'hex')
exports['mime/application/vnd.amazon.ebook'] = Buffer.from('1002', 'hex')
exports['mime/application/x-bzip'] = Buffer.from('1003', 'hex')
exports['mime/application/x-bzip2'] = Buffer.from('1004', 'hex')
exports['mime/application/x-csh'] = Buffer.from('1005', 'hex')
exports['mime/application/msword'] = Buffer.from('1006', 'hex')
exports['mime/application/vnd.openxmlformats-officedocument.wordprocessingml.document'] = Buffer.from('1007', 'hex')
exports['mime/application/vnd.ms-fontobject'] = Buffer.from('1008', 'hex')
exports['mime/application/epub+zip'] = Buffer.from('1009', 'hex')
exports['mime/application/ecmascript'] = Buffer.from('100a', 'hex')
exports['mime/application/java-archive'] = Buffer.from('100b', 'hex')
exports['mime/application/javascript'] = Buffer.from('100c', 'hex')
exports['mime/application/json'] = Buffer.from('100d', 'hex')
exports['mime/application/vnd.apple.installer+xml'] = Buffer.from('100e', 'hex')
exports['mime/application/vnd.oasis.opendocument.presentation'] = Buffer.from('100f', 'hex')
exports['mime/application/vnd.oasis.opendocument.spreadsheet'] = Buffer.from('1010', 'hex')
exports['mime/application/vnd.oasis.opendocument.text'] = Buffer.from('1011', 'hex')
exports['mime/application/ogg'] = Buffer.from('1012', 'hex')
exports['mime/application/pdf'] = Buffer.from('1013', 'hex')
exports['mime/application/vnd.ms-powerpoint'] = Buffer.from('1014', 'hex')
exports['mime/application/vnd.openxmlformats-officedocument.presentationml.presentation'] = Buffer.from('1015', 'hex')
exports['mime/application/x-rar-compressed'] = Buffer.from('1016', 'hex')
exports['mime/application/rtf'] = Buffer.from('1017', 'hex')
exports['mime/application/x-sh'] = Buffer.from('1018', 'hex')
exports['mime/application/x-shockwave-flash'] = Buffer.from('1019', 'hex')
exports['mime/application/x-tar'] = Buffer.from('101a', 'hex')
exports['mime/application/typescript'] = Buffer.from('101b', 'hex')
exports['mime/application/vnd.visio'] = Buffer.from('101c', 'hex')
exports['mime/application/xhtml+xml'] = Buffer.from('101d', 'hex')
exports['mime/application/vnd.ms-excel'] = Buffer.from('101e', 'hex')
exports['mime/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'] = Buffer.from('101f', 'hex')
exports['mime/application/xml'] = Buffer.from('1020', 'hex')
exports['mime/application/vnd.mozilla.xul+xml'] = Buffer.from('1021', 'hex')
exports['mime/application/zip'] = Buffer.from('1022', 'hex')
exports['mime/application/x-7z-compressed'] = Buffer.from('1023', 'hex')
exports['mime/application/ld+json'] = Buffer.from('1024', 'hex')
exports['mime/application/rdf+xml'] = Buffer.from('1025', 'hex')

// Range 0x1800 - 0x18ff (8 bits) reserved for 'audio/*' (there currently are ~150 subtypes)
exports['mime/audio/aac'] = Buffer.from('1800', 'hex')
exports['mime/audio/midi'] = Buffer.from('1801', 'hex')
exports['mime/audio/x-midi'] = Buffer.from('1802', 'hex')
exports['mime/audio/ogg'] = Buffer.from('1803', 'hex')
exports['mime/audio/wav'] = Buffer.from('1804', 'hex')
exports['mime/audio/webm'] = Buffer.from('1805', 'hex')
exports['mime/audio/3gpp'] = Buffer.from('1806', 'hex')
exports['mime/audio/3gpp2'] = Buffer.from('1807', 'hex')
exports['mime/audio/mp4'] = Buffer.from('1808', 'hex')

// Range 0x1900 - 0x190f (4 bits) reserved for 'font/*' (there currently are ~8 subtypes)
exports['mime/font/otf'] = Buffer.from('1900', 'hex')
exports['mime/font/ttf'] = Buffer.from('1901', 'hex')
exports['mime/font/woff'] = Buffer.from('1902', 'hex')
exports['mime/font/woff2'] = Buffer.from('1903', 'hex')

// Range 0x1910 - 0x197f (7 bits) reserved for 'image/*' (there currently are ~60 subtypes)
exports['mime/image/bmp'] = Buffer.from('1910', 'hex')
exports['mime/image/gif'] = Buffer.from('1911', 'hex')
exports['mime/image/x-icon'] = Buffer.from('1912', 'hex')
exports['mime/image/jpeg'] = Buffer.from('1913', 'hex')
exports['mime/image/png'] = Buffer.from('1914', 'hex')
exports['mime/image/svg+xml'] = Buffer.from('1915', 'hex')
exports['mime/image/tiff'] = Buffer.from('1916', 'hex')
exports['mime/image/webp'] = Buffer.from('1917', 'hex')

// Range 0x1980 - 0x19cf (5 bits) reserved for 'message/*' (there currently are ~18 subtypes)
exports['mime/message/sip'] = Buffer.from('1980', 'hex')

// Range 0x19d0 - 0x1a3f (6 bits) reserved for 'model/*' (there currently are ~24 subtypes)
// exports['mime/model/'] = Buffer.from('19d0', 'hex')

// Range 0x1a40 - 0x1a8f (5 bits) reserved for 'multipart/*' (there currently are ~13 subtypes)
exports['mime/multipart/byteranges'] = Buffer.from('1a40', 'hex')

// Range 0x1a90 - 0x1aff (7 bits) reserved for 'text/*' (there currently are ~71 subtypes)
exports['mime/text/css'] = Buffer.from('1a90', 'hex')
exports['mime/text/csv'] = Buffer.from('1a91', 'hex')
exports['mime/text/html'] = Buffer.from('1a92', 'hex')
exports['mime/text/calendar'] = Buffer.from('1a93', 'hex')
exports['mime/text/plain'] = Buffer.from('1a94', 'hex')
exports['mime/text/turtle'] = Buffer.from('1a95', 'hex')
exports['mime/text/xml'] = Buffer.from('1a96', 'hex')

// Range 0x1b00 - 0x1b6f (7 bits) reserved for 'video/*' (there currently are ~78 subtypes)
exports['mime/video/x-msvideo'] = Buffer.from('1b00', 'hex')
exports['mime/video/mpeg'] = Buffer.from('1b01', 'hex')
exports['mime/video/ogg'] = Buffer.from('1b02', 'hex')
exports['mime/video/webm'] = Buffer.from('1b03', 'hex')
exports['mime/video/3gpp'] = Buffer.from('1b04', 'hex')
exports['mime/video/3gpp2'] = Buffer.from('1b05', 'hex')
exports['mime/video/JPEG'] = Buffer.from('1b06', 'hex')
exports['mime/video/mp4'] = Buffer.from('1b07', 'hex')

0 comments on commit 09b6652

Please sign in to comment.