Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/assets/js/codeflask.1.4.1.min.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions public/assets/js/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Output an error message
*
* @param {{
* outputElem: HTMLDivElement,
* message: string,
* type: ("info"|"warn"|"error"|"success"),
* overwrite: boolean,
* }} opts opts:
* - `outputElem` - Where to visually display the log message
* - `message` - The log message being captured
* - `type` - The level of the log message. Defaults to `"info"`
* - `overwrite` - Replace all existing log messages in outputElem. Defaults to `false`
*/
export function log(opts) {
const { outputElem, message, type = "info", overwrite = false } = opts;

const line = document.createElement('div');
let colorClass = "text-body";
if (type === "warn") colorClass = "text-warning";
if (type === "error") colorClass = "text-danger";
if (type === "success") colorClass = "text-success";

line.className = `mb-1 ${colorClass}`;
line.innerText = message;

if (overwrite) {
outputElem.replaceChildren(line);
} else {
outputElem.appendChild(line);
}

console.log(`[${type}] ${message}`);
}
2 changes: 2 additions & 0 deletions public/assets/js/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function loadHeader(options) {
const homePath = `${rootPath}/`;
const featureDetectPath = `${basePath}/featuredetect/`;
const relatedOriginsPath = `${basePath}/relatedorigins/`;
const decodeResponsePath = `${basePath}/decoderesponse/`;

const currentPath = window.location.pathname;

Expand Down Expand Up @@ -33,6 +34,7 @@ function loadHeader(options) {
<ul class="dropdown-menu" aria-labelledby="toolSelectDropdown">
<li><a class="dropdown-item ${isActive('featuredetect') ? 'active' : ''}" href="${featureDetectPath}">Feature Detection</a></li>
<li><a class="dropdown-item ${isActive('relatedorigins') ? 'active' : ''}" href="${relatedOriginsPath}">Related Origin Requests Validator</a></li>
<li><a class="dropdown-item ${isActive('decoderesponse') ? 'active' : ''}" href="${decodeResponsePath}">Response Decoder</a></li>
</ul>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions public/assets/js/json-viewer.2.2.0.esm.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/assets/js/json-viewer.2.2.0.esm.min.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions public/assets/js/tiny-cbor.0.3.2.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/assets/js/tiny-cbor.0.3.2.esm.min.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions public/assets/js/tiny-encodings.0.2.11.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/assets/js/tiny-encodings.0.2.11.esm.min.map

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions public/decoderesponse/aaguidToString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { encodeHex } from 'tiny-encodings';

/**
* Convert the aaguid buffer in authData into a UUID string
*
* @param {Uint8Array} aaguid
* @returns {string}
*/
export function aaguidToString(aaguid) {
// Raw Hex: adce000235bcc60a648b0b25f1f05503
const hex = encodeHex(aaguid);

const segments = [
hex.slice(0, 8), // 8
hex.slice(8, 12), // 4
hex.slice(12, 16), // 4
hex.slice(16, 20), // 4
hex.slice(20, 32), // 8
];

// Formatted: adce0002-35bc-c60a-648b-0b25f1f05503
return segments.join('-');
}
11 changes: 11 additions & 0 deletions public/decoderesponse/base64ToBase64URL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Convert a Base64-formatted string to Base64URL
* @param {string} input
* @returns string
*/
export function base64ToBase64URL(input) {
return input
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
}
89 changes: 89 additions & 0 deletions public/decoderesponse/coseAlgToString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* Convert COSE public key alg to a human-friendly value
*
* See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
*
* @param {number} alg A numeric COSE algorithm ID
* @returns {string}
*/
export function coseAlgToString(alg) {
let name = coseAlgNameMap[alg];

if (!name) {
name = 'Unknown';
}

return `${name} (${alg})`;
}

/**
* Pulled from https://www.iana.org/assignments/cose/cose.xhtml#algorithms
*/
const coseAlgNameMap = {
'-65535': 'RS1',
'-259': 'RS512',
'-258': 'RS384',
'-257': 'RS256',
'-50': 'ML-DSA-87',
'-49': 'ML-DSA-65',
'-48': 'ML-DSA-44',
'-47': 'ES256K',
'-46': 'HSS-LMS',
'-45': 'SHAKE256 (TEMPORARY - registered 2019-08-13, extension registered 2020-06-19, expires 2021-08-13)',
'-44': 'SHA-512 (TEMPORARY - registered 2019-08-13, extension registered 2020-06-19, expires 2021-08-13)',
'-43': 'SHA-384 (TEMPORARY - registered 2019-08-13, extension registered 2020-06-19, expires 2021-08-13)',
'-42': 'RSAES-OAEP w/ SHA-512',
'-41': 'RSAES-OAEP w/ SHA-256',
'-40': 'RSAES-OAEP w/ RFC 8017 default parameters',
'-39': 'PS512',
'-38': 'PS384',
'-37': 'PS256',
'-36': 'ES512',
'-35': 'ES384',
'-34': 'ECDH-SS + A256KW',
'-33': 'ECDH-SS + A192KW',
'-32': 'ECDH-SS + A128KW',
'-31': 'ECDH-ES + A256KW',
'-30': 'ECDH-ES + A192KW',
'-29': 'ECDH-ES + A128KW',
'-28': 'ECDH-SS + HKDF-512',
'-27': 'ECDH-SS + HKDF-256',
'-26': 'ECDH-ES + HKDF-512',
'-25': 'ECDH-ES + HKDF-256',
'-18': 'SHAKE128 (TEMPORARY - registered 2019-08-13, extension registered 2020-06-19, expires 2021-08-13)',
'-17': 'SHA-512/256 (TEMPORARY - registered 2019-08-13, extension registered 2020-06-19, expires 2021-08-13)',
'-16': 'SHA-256 (TEMPORARY - registered 2019-08-13, extension registered 2020-06-19, expires 2021-08-13)',
'-15': 'SHA-256/64 (TEMPORARY - registered 2019-08-13, extension registered 2020-06-19, expires 2021-08-13)',
'-14': 'SHA-1 (TEMPORARY - registered 2019-08-13, extension registered 2020-06-19, expires 2021-08-13)',
'-13': 'direct+HKDF-AES-256',
'-12': 'direct+HKDF-AES-128',
'-11': 'direct+HKDF-SHA-512',
'-10': 'direct+HKDF-SHA-256',
'-8': 'EdDSA',
'-7': 'ES256',
'-6': 'direct',
'-5': 'A256KW',
'-4': 'A192KW',
'-3': 'A128KW',
'0': 'Reserved',
'1': 'A128GCM',
'2': 'A192GCM',
'3': 'A256GCM',
'4': 'HMAC 256/64',
'5': 'HMAC 256/256',
'6': 'HMAC 384/384',
'7': 'HMAC 512/512',
'10': 'AES-CCM-16-64-128',
'11': 'AES-CCM-16-64-256',
'12': 'AES-CCM-64-64-128',
'13': 'AES-CCM-64-64-256',
'14': 'AES-MAC 128/64',
'15': 'AES-MAC 256/64',
'24': 'ChaCha20/Poly1305',
'25': 'AES-MAC 128/128',
'26': 'AES-MAC 256/128',
'30': 'AES-CCM-16-128-128',
'31': 'AES-CCM-16-128-256',
'32': 'AES-CCM-64-128-128',
'33': 'AES-CCM-64-128-256',
}
27 changes: 27 additions & 0 deletions public/decoderesponse/coseKeyTypeToString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Convert a COSE public key's key type and convert it to a human value
*
* See https://www.iana.org/assignments/cose/cose.xhtml#key-type
*
* @param {number} kty A numeric COSE key type ID
* @returns {string}
*/
export function coseKeyTypeToString(kty) {
let keyType = `Unknown`;

if (kty === 1) {
keyType = 'OKP';
} else if (kty === 2) {
keyType = 'EC2';
} else if (kty === 3) {
keyType = 'RSA';
} else if (kty === 4) {
keyType = 'Symmetric';
} else if (kty === 5) {
keyType = 'HSS-LMS';
} else if (kty === 7) {
keyType = 'AKP';
}

return `${keyType} (${kty})`;
}
Loading