Best Python code snippet using localstack_python
decrypt-message-manager.js
Source:decrypt-message-manager.js
1import EventEmitter from 'events';2import { ObservableStore } from '@metamask/obs-store';3import ethUtil from 'ethereumjs-util';4import { ethErrors } from 'eth-rpc-errors';5import log from 'loglevel';6import { MESSAGE_TYPE } from '../../../shared/constants/app';7import { METAMASK_CONTROLLER_EVENTS } from '../metamask-controller';8import { addHexPrefix } from './util';9import createId from './random-id';10const hexRe = /^[0-9A-Fa-f]+$/gu;11/**12 * Represents, and contains data about, an 'eth_decrypt' type decryption request. These are created when a13 * decryption for an eth_decrypt call is requested.14 *15 * @typedef {Object} DecryptMessage16 * @property {number} id An id to track and identify the message object17 * @property {Object} msgParams The parameters to pass to the decryptMessage method once the decryption request is18 * approved.19 * @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.20 * @property {string} msgParams.data A hex string conversion of the raw buffer data of the decryption request21 * @property {number} time The epoch time at which the this message was created22 * @property {string} status Indicates whether the decryption request is 'unapproved', 'approved', 'decrypted' or 'rejected'23 * @property {string} type The json-prc decryption method for which a decryption request has been made. A 'Message' will24 * always have a 'eth_decrypt' type.25 *26 */27export default class DecryptMessageManager extends EventEmitter {28 /**29 * Controller in charge of managing - storing, adding, removing, updating - DecryptMessage.30 *31 * @typedef {Object} DecryptMessageManager32 * @property {Object} memStore The observable store where DecryptMessage are saved.33 * @property {Object} memStore.unapprovedDecryptMsgs A collection of all DecryptMessages in the 'unapproved' state34 * @property {number} memStore.unapprovedDecryptMsgCount The count of all DecryptMessages in this.memStore.unapprovedDecryptMsgs35 * @property {Array} messages Holds all messages that have been created by this DecryptMessageManager36 *37 */38 constructor() {39 super();40 this.memStore = new ObservableStore({41 unapprovedDecryptMsgs: {},42 unapprovedDecryptMsgCount: 0,43 });44 this.messages = [];45 }46 /**47 * A getter for the number of 'unapproved' DecryptMessages in this.messages48 *49 * @returns {number} The number of 'unapproved' DecryptMessages in this.messages50 *51 */52 get unapprovedDecryptMsgCount() {53 return Object.keys(this.getUnapprovedMsgs()).length;54 }55 /**56 * A getter for the 'unapproved' DecryptMessages in this.messages57 *58 * @returns {Object} An index of DecryptMessage ids to DecryptMessages, for all 'unapproved' DecryptMessages in59 * this.messages60 *61 */62 getUnapprovedMsgs() {63 return this.messages64 .filter((msg) => msg.status === 'unapproved')65 .reduce((result, msg) => {66 result[msg.id] = msg;67 return result;68 }, {});69 }70 /**71 * Creates a new DecryptMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add72 * the new DecryptMessage to this.messages, and to save the unapproved DecryptMessages from that list to73 * this.memStore.74 *75 * @param {Object} msgParams - The params for the eth_decrypt call to be made after the message is approved.76 * @param {Object} [req] - The original request object possibly containing the origin77 * @returns {Promise<Buffer>} The raw decrypted message contents78 *79 */80 addUnapprovedMessageAsync(msgParams, req) {81 return new Promise((resolve, reject) => {82 if (!msgParams.from) {83 reject(new Error('MetaMask Decryption: from field is required.'));84 return;85 }86 const msgId = this.addUnapprovedMessage(msgParams, req);87 this.once(`${msgId}:finished`, (data) => {88 switch (data.status) {89 case 'decrypted':90 resolve(data.rawData);91 return;92 case 'rejected':93 reject(94 ethErrors.provider.userRejectedRequest(95 'MetaMask Decryption: User denied message decryption.',96 ),97 );98 return;99 case 'errored':100 reject(new Error('This message cannot be decrypted'));101 return;102 default:103 reject(104 new Error(105 `MetaMask Decryption: Unknown problem: ${JSON.stringify(106 msgParams,107 )}`,108 ),109 );110 }111 });112 });113 }114 /**115 * Creates a new DecryptMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add116 * the new DecryptMessage to this.messages, and to save the unapproved DecryptMessages from that list to117 * this.memStore.118 *119 * @param {Object} msgParams - The params for the eth_decryptMsg call to be made after the message is approved.120 * @param {Object} [req] - The original request object possibly containing the origin121 * @returns {number} The id of the newly created DecryptMessage.122 *123 */124 addUnapprovedMessage(msgParams, req) {125 log.debug(126 `DecryptMessageManager addUnapprovedMessage: ${JSON.stringify(127 msgParams,128 )}`,129 );130 // add origin from request131 if (req) {132 msgParams.origin = req.origin;133 }134 msgParams.data = this.normalizeMsgData(msgParams.data);135 // create txData obj with parameters and meta data136 const time = new Date().getTime();137 const msgId = createId();138 const msgData = {139 id: msgId,140 msgParams,141 time,142 status: 'unapproved',143 type: MESSAGE_TYPE.ETH_DECRYPT,144 };145 this.addMsg(msgData);146 // signal update147 this.emit('update');148 return msgId;149 }150 /**151 * Adds a passed DecryptMessage to this.messages, and calls this._saveMsgList() to save the unapproved DecryptMessages from that152 * list to this.memStore.153 *154 * @param {Message} msg The DecryptMessage to add to this.messages155 *156 */157 addMsg(msg) {158 this.messages.push(msg);159 this._saveMsgList();160 }161 /**162 * Returns a specified DecryptMessage.163 *164 * @param {number} msgId The id of the DecryptMessage to get165 * @returns {DecryptMessage|undefined} The DecryptMessage with the id that matches the passed msgId, or undefined166 * if no DecryptMessage has that id.167 *168 */169 getMsg(msgId) {170 return this.messages.find((msg) => msg.id === msgId);171 }172 /**173 * Approves a DecryptMessage. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise174 * with the message params modified for proper decryption.175 *176 * @param {Object} msgParams The msgParams to be used when eth_decryptMsg is called, plus data added by MetaMask.177 * @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.178 * @returns {Promise<object>} Promises the msgParams object with metamaskId removed.179 *180 */181 approveMessage(msgParams) {182 this.setMsgStatusApproved(msgParams.metamaskId);183 return this.prepMsgForDecryption(msgParams);184 }185 /**186 * Sets a DecryptMessage status to 'approved' via a call to this._setMsgStatus.187 *188 * @param {number} msgId The id of the DecryptMessage to approve.189 *190 */191 setMsgStatusApproved(msgId) {192 this._setMsgStatus(msgId, 'approved');193 }194 /**195 * Sets a DecryptMessage status to 'decrypted' via a call to this._setMsgStatus and updates that DecryptMessage in196 * this.messages by adding the raw decryption data of the decryption request to the DecryptMessage197 *198 * @param {number} msgId The id of the DecryptMessage to decrypt.199 * @param {buffer} rawData The raw data of the message request200 *201 */202 setMsgStatusDecrypted(msgId, rawData) {203 const msg = this.getMsg(msgId);204 msg.rawData = rawData;205 this._updateMsg(msg);206 this._setMsgStatus(msgId, 'decrypted');207 }208 /**209 * Removes the metamaskId property from passed msgParams and returns a promise which resolves the updated msgParams210 *211 * @param {Object} msgParams The msgParams to modify212 * @returns {Promise<object>} Promises the msgParams with the metamaskId property removed213 *214 */215 prepMsgForDecryption(msgParams) {216 delete msgParams.metamaskId;217 return Promise.resolve(msgParams);218 }219 /**220 * Sets a DecryptMessage status to 'rejected' via a call to this._setMsgStatus.221 *222 * @param {number} msgId The id of the DecryptMessage to reject.223 *224 */225 rejectMsg(msgId) {226 this._setMsgStatus(msgId, 'rejected');227 }228 /**229 * Sets a TypedMessage status to 'errored' via a call to this._setMsgStatus.230 *231 * @param {number} msgId The id of the TypedMessage to error232 *233 */234 errorMessage(msgId, error) {235 const msg = this.getMsg(msgId);236 msg.error = error;237 this._updateMsg(msg);238 this._setMsgStatus(msgId, 'errored');239 }240 /**241 * Clears all unapproved messages from memory.242 */243 clearUnapproved() {244 this.messages = this.messages.filter((msg) => msg.status !== 'unapproved');245 this._saveMsgList();246 }247 /**248 * Updates the status of a DecryptMessage in this.messages via a call to this._updateMsg249 *250 * @private251 * @param {number} msgId The id of the DecryptMessage to update.252 * @param {string} status The new status of the DecryptMessage.253 * @throws A 'DecryptMessageManager - DecryptMessage not found for id: "${msgId}".' if there is no DecryptMessage254 * in this.messages with an id equal to the passed msgId255 * @fires An event with a name equal to `${msgId}:${status}`. The DecryptMessage is also fired.256 * @fires If status is 'rejected' or 'decrypted', an event with a name equal to `${msgId}:finished` is fired along257 * with the DecryptMessage258 *259 */260 _setMsgStatus(msgId, status) {261 const msg = this.getMsg(msgId);262 if (!msg) {263 throw new Error(264 `DecryptMessageManager - Message not found for id: "${msgId}".`,265 );266 }267 msg.status = status;268 this._updateMsg(msg);269 this.emit(`${msgId}:${status}`, msg);270 if (271 status === 'rejected' ||272 status === 'decrypted' ||273 status === 'errored'274 ) {275 this.emit(`${msgId}:finished`, msg);276 }277 }278 /**279 * Sets a DecryptMessage in this.messages to the passed DecryptMessage if the ids are equal. Then saves the280 * unapprovedDecryptMsgs index to storage via this._saveMsgList281 *282 * @private283 * @param {DecryptMessage} msg - A DecryptMessage that will replace an existing DecryptMessage (with the same284 * id) in this.messages285 *286 */287 _updateMsg(msg) {288 const index = this.messages.findIndex((message) => message.id === msg.id);289 if (index !== -1) {290 this.messages[index] = msg;291 }292 this._saveMsgList();293 }294 /**295 * Saves the unapproved DecryptMessages, and their count, to this.memStore296 *297 * @private298 * @fires 'updateBadge'299 *300 */301 _saveMsgList() {302 const unapprovedDecryptMsgs = this.getUnapprovedMsgs();303 const unapprovedDecryptMsgCount = Object.keys(unapprovedDecryptMsgs).length;304 this.memStore.updateState({305 unapprovedDecryptMsgs,306 unapprovedDecryptMsgCount,307 });308 this.emit(METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE);309 }310 /**311 * A helper function that converts raw buffer data to a hex, or just returns the data if it is already formatted as a hex.312 *313 * @param {any} data The buffer data to convert to a hex314 * @returns {string} A hex string conversion of the buffer data315 *316 */317 normalizeMsgData(data) {318 try {319 const stripped = ethUtil.stripHexPrefix(data);320 if (stripped.match(hexRe)) {321 return addHexPrefix(stripped);322 }323 } catch (e) {324 log.debug(`Message was not hex encoded, interpreting as utf8.`);325 }326 return ethUtil.bufferToHex(Buffer.from(data, 'utf8'));327 }...
confirm-decrypt-message.component.js
Source:confirm-decrypt-message.component.js
1import React, { Component } from 'react';2import PropTypes from 'prop-types';3import copyToClipboard from 'copy-to-clipboard';4import classnames from 'classnames';5import AccountListItem from '../../components/app/account-list-item';6import Button from '../../components/ui/button';7import Identicon from '../../components/ui/identicon';8import Tooltip from '../../components/ui/tooltip';9import Copy from '../../components/ui/icon/copy-icon.component';10import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../shared/constants/app';11import { getEnvironmentType } from '../../../../app/scripts/lib/util';12import { conversionUtil } from '../../helpers/utils/conversion-util';13export default class ConfirmDecryptMessage extends Component {14 static contextTypes = {15 t: PropTypes.func.isRequired,16 metricsEvent: PropTypes.func.isRequired,17 };18 static propTypes = {19 fromAccount: PropTypes.shape({20 address: PropTypes.string.isRequired,21 balance: PropTypes.string,22 name: PropTypes.string,23 }).isRequired,24 clearConfirmTransaction: PropTypes.func.isRequired,25 cancelDecryptMessage: PropTypes.func.isRequired,26 decryptMessage: PropTypes.func.isRequired,27 decryptMessageInline: PropTypes.func.isRequired,28 conversionRate: PropTypes.number,29 history: PropTypes.object.isRequired,30 mostRecentOverviewPage: PropTypes.string.isRequired,31 requesterAddress: PropTypes.string,32 txData: PropTypes.object,33 domainMetadata: PropTypes.object,34 };35 state = {36 fromAccount: this.props.fromAccount,37 copyToClipboardPressed: false,38 hasCopied: false,39 };40 componentDidMount = () => {41 if (42 getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION43 ) {44 window.addEventListener('beforeunload', this._beforeUnload);45 }46 };47 componentWillUnmount = () => {48 this._removeBeforeUnload();49 };50 _beforeUnload = async (event) => {51 const {52 clearConfirmTransaction,53 cancelDecryptMessage,54 txData,55 } = this.props;56 const { metricsEvent } = this.context;57 await cancelDecryptMessage(txData, event);58 metricsEvent({59 eventOpts: {60 category: 'Messages',61 action: 'Decrypt Message Request',62 name: 'Cancel Via Notification Close',63 },64 });65 clearConfirmTransaction();66 };67 _removeBeforeUnload = () => {68 if (69 getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION70 ) {71 window.removeEventListener('beforeunload', this._beforeUnload);72 }73 };74 copyMessage = () => {75 copyToClipboard(this.state.rawMessage);76 this.context.metricsEvent({77 eventOpts: {78 category: 'Messages',79 action: 'Decrypt Message Copy',80 name: 'Copy',81 },82 });83 this.setState({ hasCopied: true });84 setTimeout(() => this.setState({ hasCopied: false }), 3000);85 };86 renderHeader = () => {87 return (88 <div className="request-decrypt-message__header">89 <div className="request-decrypt-message__header-background" />90 <div className="request-decrypt-message__header__text">91 {this.context.t('decryptRequest')}92 </div>93 <div className="request-decrypt-message__header__tip-container">94 <div className="request-decrypt-message__header__tip" />95 </div>96 </div>97 );98 };99 renderAccount = () => {100 const { fromAccount } = this.state;101 const { t } = this.context;102 return (103 <div className="request-decrypt-message__account">104 <div className="request-decrypt-message__account-text">105 {`${t('account')}:`}106 </div>107 <div className="request-decrypt-message__account-item">108 <AccountListItem account={fromAccount} />109 </div>110 </div>111 );112 };113 renderBalance = () => {114 const { conversionRate } = this.props;115 const {116 fromAccount: { balance },117 } = this.state;118 const { t } = this.context;119 const balanceInEther = conversionUtil(balance, {120 fromNumericBase: 'hex',121 toNumericBase: 'dec',122 fromDenomination: 'WEI',123 numberOfDecimals: 6,124 conversionRate,125 });126 return (127 <div className="request-decrypt-message__balance">128 <div className="request-decrypt-message__balance-text">129 {`${t('balance')}:`}130 </div>131 <div className="request-decrypt-message__balance-value">132 {`${balanceInEther} ETH`}133 </div>134 </div>135 );136 };137 renderRequestIcon = () => {138 const { requesterAddress } = this.props;139 return (140 <div className="request-decrypt-message__request-icon">141 <Identicon diameter={40} address={requesterAddress} />142 </div>143 );144 };145 renderAccountInfo = () => {146 return (147 <div className="request-decrypt-message__account-info">148 {this.renderAccount()}149 {this.renderRequestIcon()}150 {this.renderBalance()}151 </div>152 );153 };154 renderBody = () => {155 const { decryptMessageInline, domainMetadata, txData } = this.props;156 const { t } = this.context;157 const originMetadata = domainMetadata[txData.msgParams.origin];158 const name = originMetadata?.hostname || txData.msgParams.origin;159 const notice = t('decryptMessageNotice', [txData.msgParams.origin]);160 const {161 hasCopied,162 hasDecrypted,163 hasError,164 rawMessage,165 errorMessage,166 copyToClipboardPressed,167 } = this.state;168 return (169 <div className="request-decrypt-message__body">170 {this.renderAccountInfo()}171 <div className="request-decrypt-message__visual">172 <section>173 {originMetadata?.icon ? (174 <img175 className="request-decrypt-message__visual-identicon"176 src={originMetadata.icon}177 alt=""178 />179 ) : (180 <i className="request-decrypt-message__visual-identicon--default">181 {name.charAt(0).toUpperCase()}182 </i>183 )}184 <div className="request-decrypt-message__notice">{notice}</div>185 </section>186 </div>187 <div className="request-decrypt-message__message">188 <div className="request-decrypt-message__message-text">189 {!hasDecrypted && !hasError ? txData.msgParams.data : rawMessage}190 {hasError ? errorMessage : ''}191 </div>192 <div193 className={classnames({194 'request-decrypt-message__message-cover': true,195 'request-decrypt-message__message-lock--pressed':196 hasDecrypted || hasError,197 })}198 />199 <div200 className={classnames({201 'request-decrypt-message__message-lock': true,202 'request-decrypt-message__message-lock--pressed':203 hasDecrypted || hasError,204 })}205 onClick={(event) => {206 decryptMessageInline(txData, event).then((result) => {207 if (result.error) {208 this.setState({209 hasError: true,210 errorMessage: this.context.t('decryptInlineError', [211 result.error,212 ]),213 });214 } else {215 this.setState({216 hasDecrypted: true,217 rawMessage: result.rawData,218 });219 }220 });221 }}222 >223 <img src="images/lock.svg" alt="" />224 <div className="request-decrypt-message__message-lock-text">225 {t('decryptMetamask')}226 </div>227 </div>228 </div>229 {hasDecrypted ? (230 <div231 className={classnames({232 'request-decrypt-message__message-copy': true,233 'request-decrypt-message__message-copy--pressed': copyToClipboardPressed,234 })}235 onClick={() => this.copyMessage()}236 onMouseDown={() => this.setState({ copyToClipboardPressed: true })}237 onMouseUp={() => this.setState({ copyToClipboardPressed: false })}238 >239 <Tooltip240 position="bottom"241 title={hasCopied ? t('copiedExclamation') : t('copyToClipboard')}242 wrapperClassName="request-decrypt-message__message-copy-tooltip"243 style={{ display: 'flex', alignItems: 'center' }}244 >245 <div className="request-decrypt-message__message-copy-text">246 {t('decryptCopy')}247 </div>248 <Copy size={17} color="#3098DC" />249 </Tooltip>250 </div>251 ) : (252 <div></div>253 )}254 </div>255 );256 };257 renderFooter = () => {258 const {259 cancelDecryptMessage,260 clearConfirmTransaction,261 decryptMessage,262 history,263 mostRecentOverviewPage,264 txData,265 } = this.props;266 const { metricsEvent, t } = this.context;267 return (268 <div className="request-decrypt-message__footer">269 <Button270 type="default"271 large272 className="request-decrypt-message__footer__cancel-button"273 onClick={async (event) => {274 this._removeBeforeUnload();275 await cancelDecryptMessage(txData, event);276 metricsEvent({277 eventOpts: {278 category: 'Messages',279 action: 'Decrypt Message Request',280 name: 'Cancel',281 },282 });283 clearConfirmTransaction();284 history.push(mostRecentOverviewPage);285 }}286 >287 {t('cancel')}288 </Button>289 <Button290 type="secondary"291 large292 className="request-decrypt-message__footer__sign-button"293 onClick={async (event) => {294 this._removeBeforeUnload();295 await decryptMessage(txData, event);296 metricsEvent({297 eventOpts: {298 category: 'Messages',299 action: 'Decrypt Message Request',300 name: 'Confirm',301 },302 });303 clearConfirmTransaction();304 history.push(mostRecentOverviewPage);305 }}306 >307 {t('decrypt')}308 </Button>309 </div>310 );311 };312 render = () => {313 return (314 <div className="request-decrypt-message__container">315 {this.renderHeader()}316 {this.renderBody()}317 {this.renderFooter()}318 </div>319 );320 };...
chat.js
Source:chat.js
1 decrypt("&<b>Fox3000%20-%20Foxy:</b> !clear<br>")2 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")3 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")4 decrypt("&<b>Fox3000%20-%20Foxy:</b> lolorf<br>")5 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")6 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")7 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")8 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")9 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")10 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")11 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")12 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")13 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")14 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")15 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")16 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")17 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")18 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")19 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")20 decrypt("&<b>Fox3000%20-%20Foxy:</b> lol<br>")21 decrypt("&<b>Fox3000%20-%20Foxy:</b> !clear<br>")22 decrypt("&<b>Fox3000%20-%20Foxy:</b> lol<br>")23 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")24 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")25 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")26 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")27 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")28 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")29 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")30 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")31 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")32 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")33 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")34 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")35 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")36 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")37 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")38 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")39 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")40 decrypt("&<b>Fox3000%20-%20Foxy:</b> olovlklefkvfdemfdlemflzszz<br>")41 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")42 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")43 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")44 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")45 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")46 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")47 decrypt("&<b>Fox3000%20-%20Foxy:</b> !cear<br>")48 decrypt("&<b>Fox3000%20-%20Foxy:</b> !clear<br>")49 decrypt("&<b>Fox3000%20-%20Foxy:</b> trtvf<br>")50 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")51 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")52 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")53 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")54 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")55 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")56 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")57 decrypt("ll&<b>Fox3000%20-%20Foxy connect</b><br>")58 decrypt("ll&<b>Fox3000%20-%20Foxy disconnect</b><br>")59 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")60 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")61 decrypt("ll&<b>Fox3000%20-%20Foxy connect</b><br>")62 decrypt("ll&<b>Fox3000%20-%20Foxy disconnect</b><br>")63 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")64 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")65 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")66 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")67 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")68 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")69 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")70 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")71 decrypt("&<b>Fox3000%20-%20Foxy connect</b><br>")72 decrypt("&<b>Fox3000%20-%20Foxy disconnect</b><br>")73 decrypt("Abc&<b>Non connect</b><br>")74 decrypt("Abc&<b>Non disconnect</b><br>")75 decrypt("Abc&<b>Non connect</b><br>")76 decrypt("Abc&<b>Non disconnect</b><br>")77 decrypt("Abc&<b>Non connect</b><br>")78 decrypt("Abc&<b>Lucas connect</b><br>")79 decrypt("Abc&<b>Lucas disconnect</b><br>")80 decrypt("Abc&<b>Lucas connect</b><br>")81 decrypt("Abc&<b>Non disconnect</b><br>")82 decrypt("Abc&<b>Lucas disconnect</b><br>")83 decrypt("Abc&<b>Lucas connect</b><br>")84 decrypt("Abc&<b>Non connect</b><br>")85 decrypt("Abc&<b>Lucas disconnect</b><br>")86 decrypt("Abc&<b>Lucas connect</b><br>")87 decrypt("Abc&<b>Non disconnect</b><br>")88 decrypt("Abc&<b>Non connect</b><br>")89 decrypt("Abc&<b>Lucas disconnect</b><br>")90 decrypt("Abc&<b>Lucas connect</b><br>")91 decrypt("Abc&<b>Lucas:</b> lol<br>")92 decrypt("&salon=Abc&<b>&username=Lucas:</b> !clear<br>")93 decrypt("&salon=Abc&<b>&username=Lucas disconnect</b><br>")94 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")95 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")96 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")97 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")98 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")99 decrypt("Abc&<b>Lucas connect</b><br>")100 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")101 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")102 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")103 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")104 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")105 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")106 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")107 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")108 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")109 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")110 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")111 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")112 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")113 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")114 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")115 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")116 decrypt("Abc&<b>Non connect</b><br>")117 decrypt("Abc&<b>Lucas:</b> !clear<br>")118 decrypt("Abc&<b>&username=Lucas disconnect</b><br>")119 decrypt("Abc&<b>Lucas connect</b><br>")120 decrypt("Abc&<b>&username=Non disconnect</b><br>")121 decrypt("Abc&<b>Non connect</b><br>")122 decrypt("&salon=Abc&<b>&username=Lucas disconnect</b><br>")123 decrypt("Abc&<b>Lucas connect</b><br>")124 decrypt("Abc&<b>&username=Lucas disconnect</b><br>")125 decrypt("Abc&<b>&username=Non disconnect</b><br>")126 decrypt("Abc&<b>Lucas connect</b><br>")127 decrypt("Abc&<b>Non connect</b><br>")128 decrypt("Abc&<b>Lucas disconnect</b><br>")129 decrypt("Abc&<b>Lucas connect</b><br>")130 decrypt("Abc&<b>Lucas disconnect</b><br>")131 decrypt("Abc&<b>Lucas connect</b><br>")132 decrypt("Abc&<b>Non disconnect</b><br>")133 decrypt("Abc&<b>Non connect</b><br>")134 decrypt("Abc&<b>Non disconnect</b><br>")135 decrypt("Abc&<b>Non connect</b><br>")136 decrypt("Abc&<b>Non disconnect</b><br>")137 decrypt("Abc&<b>Non connect</b><br>")138 decrypt("Abc&<b>Non disconnect</b><br>")139 decrypt("Abc&<b>Non connect</b><br>")140 decrypt("Abc&<b>Lucas disconnect</b><br>")141 decrypt("Abc&<b>Lucas connect</b><br>")142 decrypt("Abc&<b>Lucas disconnect</b><br>")143 decrypt("Abc&<b>Lucas connect</b><br>")144 decrypt("Abc&<b>Non disconnect</b><br>")145 decrypt("Abc&<b>Non connect</b><br>")146 decrypt("Abc&<b>Non disconnect</b><br>")147 decrypt("Abc&<b>Non connect</b><br>")148 decrypt("Abc&<b>Non disconnect</b><br>")149 decrypt("Abc&<b>Non connect</b><br>")150 decrypt("Abc&<b>Non disconnect</b><br>")151 decrypt("Abc&<b>Non connect</b><br>")152 decrypt("Abc&<b>Non disconnect</b><br>")153 decrypt("Abc&<b>Non connect</b><br>")154 decrypt("&salon=Abc&<b>&username=Lucas disconnect</b><br>")155 decrypt("Abc&<b>Lucas connect</b><br>")156 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")157 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")158 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")159 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")160 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")161 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")162 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")163 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")164 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")165 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")166 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")167 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")168 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")169 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")170 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")171 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")172 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")173 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")174 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")175 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")176 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")177 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")178 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")179 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")180 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")181 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")182 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")183 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")184 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")185 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")186 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")187 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")188 decrypt("&salon=Abc&<b>&username=Non disconnect</b><br>")189 decrypt("Abc&<b>Non connect</b><br>")190 decrypt("Abc&<b>Lucas:</b> !clear<br>")191 decrypt("Abc&<b>Non:</b> Lol<br>")192 decrypt("Abc&<b>Lucas disconnect</b><br>")193 decrypt("Room&<b>Spec connect</b><br>")194 decrypt("Room&<b>Fox3000 connect</b><br>")195 decrypt("Room&<b>&username=Fox3000 disconnect</b><br>")196 decrypt("Room&<b>&username=Spec disconnect</b><br>")197 decrypt("Room&<b>Fox3000 connect</b><br>")198 decrypt("Room&<b>Spec connect</b><br>")199 decrypt("Room&<b>&username=Fox3000 disconnect</b><br>")200 decrypt("Room&<b>&username=Spec disconnect</b><br>")201 decrypt("Room&<b>Fox3000 connect</b><br>")202 decrypt("Room&<b>Spec connect</b><br>")...
common.ts
Source:common.ts
1import {Decrypt as NcmDecrypt} from "@/decrypt/ncm";2import {Decrypt as NcmCacheDecrypt} from "@/decrypt/ncmcache";3import {Decrypt as XmDecrypt} from "@/decrypt/xm";4import {Decrypt as QmcDecrypt} from "@/decrypt/qmc";5import {Decrypt as QmcCacheDecrypt} from "@/decrypt/qmccache";6import {Decrypt as KgmDecrypt} from "@/decrypt/kgm";7import {Decrypt as KwmDecrypt} from "@/decrypt/kwm";8import {Decrypt as RawDecrypt} from "@/decrypt/raw";9import {Decrypt as TmDecrypt} from "@/decrypt/tm";10import {DecryptResult, FileInfo} from "@/decrypt/entity";11import {SplitFilename} from "@/decrypt/utils";12export async function CommonDecrypt(file: FileInfo): Promise<DecryptResult> {13 const raw = SplitFilename(file.name)14 let rt_data: DecryptResult;15 switch (raw.ext) {16 case "ncm":// Netease Mp3/Flac17 rt_data = await NcmDecrypt(file.raw, raw.name, raw.ext);18 break;19 case "uc":// Netease Cache20 rt_data = await NcmCacheDecrypt(file.raw, raw.name, raw.ext);21 break;22 case "kwm":// Kuwo Mp3/Flac23 rt_data = await KwmDecrypt(file.raw, raw.name, raw.ext);24 break25 case "xm": // Xiami Wav/M4a/Mp3/Flac26 case "wav":// Xiami/Raw Wav27 case "mp3":// Xiami/Raw Mp328 case "flac":// Xiami/Raw Flac29 case "m4a":// Xiami/Raw M4a30 rt_data = await XmDecrypt(file.raw, raw.name, raw.ext);31 break;32 case "ogg":// Raw Ogg33 rt_data = await RawDecrypt(file.raw, raw.name, raw.ext);34 break;35 case "tm0":// QQ Music IOS Mp336 case "tm3":// QQ Music IOS Mp337 rt_data = await RawDecrypt(file.raw, raw.name, "mp3");38 break;39 case "qmc3"://QQ Music Android Mp340 case "qmc2"://QQ Music Android Ogg41 case "qmc0"://QQ Music Android Mp342 case "qmcflac"://QQ Music Android Flac43 case "qmcogg"://QQ Music Android Ogg44 case "tkm"://QQ Music Accompaniment M4a45 case "bkcmp3"://Moo Music Mp346 case "bkcflac"://Moo Music Flac47 case "mflac"://QQ Music Desktop Flac48 case "mgg": //QQ Music Desktop Ogg49 case "666c6163"://QQ Music Weiyun Flac50 case "6d7033"://QQ Music Weiyun Mp351 case "6f6767"://QQ Music Weiyun Ogg52 case "6d3461"://QQ Music Weiyun M4a53 case "776176"://QQ Music Weiyun Wav54 rt_data = await QmcDecrypt(file.raw, raw.name, raw.ext);55 break;56 case "tm2":// QQ Music IOS M4a57 case "tm6":// QQ Music IOS M4a58 rt_data = await TmDecrypt(file.raw, raw.name);59 break;60 case "cache"://QQ Music Cache61 rt_data = await QmcCacheDecrypt(file.raw, raw.name, raw.ext);62 break;63 case "vpr":64 case "kgm":65 case "kgma":66 rt_data = await KgmDecrypt(file.raw, raw.name, raw.ext);67 break68 default:69 throw "ä¸æ¯ææ¤æä»¶æ ¼å¼"70 }71 if (!rt_data.rawExt) rt_data.rawExt = raw.ext;72 if (!rt_data.rawFilename) rt_data.rawFilename = raw.name;73 console.log(rt_data);74 return rt_data;...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!