Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.3.25: Add official channels link #172

Merged
merged 1 commit into from
Nov 15, 2024
Merged
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"module": "./dist/index.mjs",
"name": "chameleon-ultra.js",
"type": "commonjs",
"version": "0.3.24",
"version": "0.3.25",
"bugs": {
"url": "https://github.com/taichunmin/chameleon-ultra.js/issues"
},
Expand Down Expand Up @@ -75,6 +75,7 @@
"tsup": "^8.3.5",
"tsx": "^4.19.2",
"typedoc": "^0.26.11",
"typedoc-plugin-ga": "^1.0.4",
"typedoc-plugin-mdn-links": "^3.3.7",
"typedoc-plugin-missing-exports": "^3.0.0",
"typedoc-plugin-rename-defaults": "^0.7.1",
Expand Down
12 changes: 8 additions & 4 deletions pug/src/device-settings.pug
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ block script
},
},
methods: {
async swalFire (args) {
if (_.isPlainObject(args)) args.footer ??= '<a target="_blank" href="https://github.com/RfidResearchGroup/ChameleonUltra?tab=readme-ov-file#official-channels">Have questions? Join Discord!</a>'
return await Swal.fire(args)
},
async btnAdapterTips () {
await Swal.fire({
await this.swalFire({
title: 'Browser & OS',
html: '<strong class="text-success">BLE</strong> is supported in ChromeOS, Chrome for Windows 10, macOS, Android 6.0, Microsoft Edge for Windows and <a class="btn-link" target="_blank" href="https://apps.apple.com/app/bluefy-web-ble-browser/id1492822055">Bluefy</a> for iPhone and iPad.<hr><strong class="text-success">USB</strong> is supported on all desktop platforms (ChromeOS, Linux, macOS, and Windows).',
})
Expand Down Expand Up @@ -205,7 +209,7 @@ block script
Swal.close()
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', text: err.message })
await this.swalFire({ icon: 'error', text: err.message })
}
},
async btnSaveDevice () {
Expand All @@ -223,10 +227,10 @@ block script
await ultra.cmdSetButtonLongPressAction(btn, ss[`longPressBtn${btnName}`])
}
await ultra.cmdSaveSettings()
await Swal.fire({ icon: 'success', text: 'Settings save successfully!' })
await this.swalFire({ icon: 'success', text: 'Settings save successfully!' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', text: err.message })
await this.swalFire({ icon: 'error', text: err.message })
}
},
async btnEnterBootloader () {
Expand Down
14 changes: 9 additions & 5 deletions pug/src/dfu.pug
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ block script
},
},
methods: {
async swalFire (args) {
if (_.isPlainObject(args)) args.footer ??= '<a target="_blank" href="https://github.com/RfidResearchGroup/ChameleonUltra?tab=readme-ov-file#official-channels">Have questions? Join Discord!</a>'
return await Swal.fire(args)
},
async btnAdapterTips () {
await Swal.fire({
await this.swalFire({
title: 'Browser & OS',
html: '<strong class="text-success">BLE</strong> is supported in ChromeOS, Chrome for Windows 10, macOS, Android 6.0, Microsoft Edge for Windows and <a class="btn-link" target="_blank" href="https://apps.apple.com/app/bluefy-web-ble-browser/id1492822055">Bluefy</a> for iPhone and iPad.<hr><strong class="text-success">USB</strong> is supported on all desktop platforms (ChromeOS, Linux, macOS, and Windows).',
})
Expand Down Expand Up @@ -175,10 +179,10 @@ block script
}
}
if (!isUploadSuccess) throw new Error('Upload failed')
await Swal.fire({ icon: 'success', title: 'Upload Success' })
await this.swalFire({ icon: 'success', title: 'Upload Success' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Upload Failed', text: err.message })
await this.swalFire({ icon: 'error', title: 'Upload Failed', text: err.message })
}
ultra.emitter.removeListener('progress', showProgress)
},
Expand Down Expand Up @@ -216,10 +220,10 @@ block script
this.showLoading({ text: 'Uploading Firmware...' })
ultra.emitter.on('progress', showProgress)
await ultra.dfuUpdateImage(image)
await Swal.fire({ icon: 'success', title: 'Upload Success' })
await this.swalFire({ icon: 'success', title: 'Upload Success' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Upload Failed', text: err.message })
await this.swalFire({ icon: 'error', title: 'Upload Failed', text: err.message })
}
ultra.emitter.removeListener('progress', showProgress)
},
Expand Down
10 changes: 7 additions & 3 deletions pug/src/hf14a-scanner.pug
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ block script
},
},
methods: {
async swalFire (args) {
if (_.isPlainObject(args)) args.footer ??= '<a target="_blank" href="https://github.com/RfidResearchGroup/ChameleonUltra?tab=readme-ov-file#official-channels">Have questions? Join Discord!</a>'
return await Swal.fire(args)
},
async btnAdapterTips () {
await Swal.fire({
await this.swalFire({
title: 'Browser & OS',
html: '<strong class="text-success">BLE</strong> is supported in ChromeOS, Chrome for Windows 10, macOS, Android 6.0, Microsoft Edge for Windows and <a class="btn-link" target="_blank" href="https://apps.apple.com/app/bluefy-web-ble-browser/id1492822055">Bluefy</a> for iPhone and iPad.<hr><strong class="text-success">USB</strong> is supported on all desktop platforms (ChromeOS, Linux, macOS, and Windows).',
})
Expand Down Expand Up @@ -140,7 +144,7 @@ block script
Swal.close() // scanning stopped
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Scan failed', text: err.message })
await this.swalFire({ icon: 'error', title: 'Scan failed', text: err.message })
}
},
async btnScanStop () {
Expand All @@ -159,7 +163,7 @@ block script
dom.setSelectionRange(0, 1e6) // For mobile devices
document.execCommand('copy')
container.removeChild(dom)
await Swal.fire({ icon: 'success', title: 'Copied' })
await this.swalFire({ icon: 'success', title: `${text.length} bytes copied.` })
},
async sleep (t) {
await new Promise(resolve => setTimeout(resolve, t))
Expand Down
24 changes: 14 additions & 10 deletions pug/src/lf-em410x.pug
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ block script
},
},
methods: {
async swalFire (args) {
if (_.isPlainObject(args)) args.footer ??= '<a target="_blank" href="https://github.com/RfidResearchGroup/ChameleonUltra?tab=readme-ov-file#official-channels">Have questions? Join Discord!</a>'
return await Swal.fire(args)
},
async btnAdapterTips () {
await Swal.fire({
await this.swalFire({
title: 'Browser & OS',
html: '<strong class="text-success">BLE</strong> is supported in ChromeOS, Chrome for Windows 10, macOS, Android 6.0, Microsoft Edge for Windows and <a class="btn-link" target="_blank" href="https://apps.apple.com/app/bluefy-web-ble-browser/id1492822055">Bluefy</a> for iPhone and iPad.<hr><strong class="text-success">USB</strong> is supported on all desktop platforms (ChromeOS, Linux, macOS, and Windows).',
})
Expand All @@ -130,10 +134,10 @@ block script
name: await ultra.cmdSlotGetFreqName(slot, FreqType.LF),
uid: toHex(await ultra.cmdEm410xGetEmuId()),
})
await Swal.fire({ icon: 'success', title: 'Load success' })
await this.swalFire({ icon: 'success', title: 'Load success' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Load failed', text: err.message })
await this.swalFire({ icon: 'error', title: 'Load failed', text: err.message })
}
},
async btnEmuWrite () {
Expand All @@ -152,10 +156,10 @@ block script
if (_.isString(name) && name.length > 0) await ultra.cmdSlotSetFreqName(slot, FreqType.LF, name)
await ultra.cmdEm410xSetEmuId(uid)
await ultra.cmdSlotSaveSettings()
await Swal.fire({ icon: 'success', title: 'Emulate success' })
await this.swalFire({ icon: 'success', title: 'Emulate success' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Emulate failed', text: err.message })
await this.swalFire({ icon: 'error', title: 'Emulate failed', text: err.message })
}
},
async btnEmuReset () {
Expand All @@ -169,10 +173,10 @@ block script
this.showLoading({ text: 'Resetting...' })
await ultra.cmdChangeDeviceMode(DeviceMode.TAG)
await ultra.slotChangeTagTypeAndActive(slot, null, TagType.EM410X) // reset slot
await Swal.fire({ icon: 'success', title: 'Reset success' })
await this.swalFire({ icon: 'success', title: 'Reset success' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Reset failed', text: err.message })
await this.swalFire({ icon: 'error', title: 'Reset failed', text: err.message })
}
},
async btnScanTag () {
Expand All @@ -183,7 +187,7 @@ block script
Swal.close()
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Scan failed', text: err.message })
await this.swalFire({ icon: 'error', title: 'Scan failed', text: err.message })
}
},
async btnT55xxWrite () {
Expand All @@ -198,10 +202,10 @@ block script
await ultra.cmdEm410xWriteToT55xx(uid, newKey, oldKeys)
const uid2 = await ultra.cmdEm410xScan()
if (!uid.equals(uid2)) throw new Error(`ID mismatch after write, scanned = ${toHex(uid2)}`)
await Swal.fire({ icon: 'success', title: 'Write success' })
await this.swalFire({ icon: 'success', title: 'Write success' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Write failed', text: err.message })
await this.swalFire({ icon: 'error', title: 'Write failed', text: err.message })
}
},
async btnKeysReset () {
Expand Down
30 changes: 15 additions & 15 deletions pug/src/mfkey32.pug
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@ block script
},
},
methods: {
async swalFire (args) {
if (_.isPlainObject(args)) args.footer ??= '<a target="_blank" href="https://github.com/RfidResearchGroup/ChameleonUltra?tab=readme-ov-file#official-channels">Have questions? Join Discord!</a>'
return await Swal.fire(args)
},
async btnAdapterTips () {
await Swal.fire({
await this.swalFire({
title: 'Browser & OS',
html: '<strong class="text-success">BLE</strong> is supported in ChromeOS, Chrome for Windows 10, macOS, Android 6.0, Microsoft Edge for Windows and <a class="btn-link" target="_blank" href="https://apps.apple.com/app/bluefy-web-ble-browser/id1492822055">Bluefy</a> for iPhone and iPad.<hr><strong class="text-success">USB</strong> is supported on all desktop platforms (ChromeOS, Linux, macOS, and Windows).',
})
Expand All @@ -178,7 +182,7 @@ block script
Swal.close()
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Failed to scan tag.', text: err.message })
await this.swalFire({ icon: 'error', title: 'Failed to scan tag.', text: err.message })
}
},
async btnEmulateTag () {
Expand All @@ -201,18 +205,14 @@ block script
await ultra.cmdMf1SetAntiCollMode(false)
await ultra.cmdHf14aSetAntiCollData(tag)
await ultra.cmdMf1SetDetectionEnable(true) // enable detection
const block0 = Buffer.allocUnsafe(16)
tag.uid.copy(block0) // copy uid
block0[tag.uid.length] = tag.uid.xor() // bcc for magic card
block0[tag.uid.length + 1] = tag.sak[0] // sak
tag.atqa.copy(block0, tag.uid.length + 2) // atqa
const block0 = ChameleonUltra.mf1GenMagicBlock0(tag)
ultra.emitter.emit('debug', 'web', `block0 = ${block0.toString('hex')}`)
await ultra.cmdMf1EmuWriteBlock(0, block0) // set block0
await ultra.cmdSlotSaveSettings()
await Swal.fire({ icon: 'success', title: 'Emulate successfully!' })
await this.swalFire({ icon: 'success', title: 'Emulate successfully!' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Failed to emulate tag.', text: err.message })
await this.swalFire({ icon: 'error', title: 'Failed to emulate tag.', text: err.message })
}
},
async btnRecover () {
Expand Down Expand Up @@ -275,10 +275,10 @@ block script
}
}
}
await Swal.fire({ icon: 'success', title: 'Recover successfully!' })
await this.swalFire({ icon: 'success', title: 'Recover successfully!' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Failed to recover key.', text: err.message })
await this.swalFire({ icon: 'error', title: 'Failed to recover key.', text: err.message })
}
},
async btnCheck () {
Expand All @@ -292,11 +292,11 @@ block script
key: Buffer.from(key, 'hex'),
})
await ultra.cmdChangeDeviceMode(DeviceMode.TAG)
if (!isCorrect) return await Swal.fire({ icon: 'error', title: 'Key is incorrect!' })
await Swal.fire({ icon: 'success', title: 'Key is correct!' })
if (!isCorrect) return await this.swalFire({ icon: 'error', title: 'Key is incorrect!' })
await this.swalFire({ icon: 'success', title: 'Key is correct!' })
} catch (err) {
ultra.emitter.emit('error', err)
await Swal.fire({ icon: 'error', title: 'Failed to check key.', text: err.message })
await this.swalFire({ icon: 'error', title: 'Failed to check key.', text: err.message })
}
},
async btnCopy (text, container = null) {
Expand All @@ -308,7 +308,7 @@ block script
dom.setSelectionRange(0, 1e6) // For mobile devices
document.execCommand('copy')
container.removeChild(dom)
await Swal.fire({ icon: 'success', title: 'Copied' })
await this.swalFire({ icon: 'success', title: `${text.length} bytes copied.` })
},
async confirm (text, confirmButtonText, cancelButtonText) {
return await new Promise((resolve, reject) => {
Expand Down
Loading