
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@touchcode/js-touchcode-sdk
Advanced tools
The Touchcode Javascript SDK which enables Touchcode experiences.
This is the Touchcode JavaScript SDK. It is intended for use in a browser environment, and is not designed to work in Node.js.
The library is available on npm. It can be installed with: npm install --save @touchcode/js-touchcode-sdk.
import touchcodeInit from "@touchcode/js-touchcode-sdk";
touchcodeInit(campaignId, touchcodeEnabledDiv, progressCallback,decodeCallback, autoRedirect, decodeUrl, testBandwidth)
const decodeCallback = (event) => {
console.log('decode callback', event)
}
<div id=”touchcode_enabled_div” class="touchcode_content"> </div>
.touchcode_content{
display: block;
width: 100%;
height: 100vh;
}
The following example consists of a touchcodeInit module in an index.js file. The campaignID must be provided by Touchcode.
Touchcode calls back to by the decodeCallback with the value decoded in the argument code.
Note: Touchcode receives touch input. It must be the top most element of the view.
JavaScript
import touchcodeInit from "@touchcode/js-touchcode-sdk";
const decodeCallback = target => console.log(target) // target = https://www.touchcode.com
const progressCallback = touches => console.log(`There are ${touches} touch points`) // use this to give the user progress feedback.
const init = (() => {
let campaignId = 'Provide-Campaign-ID',
touchcodeEnabledDiv = 'touchcode_enabled_div',
autoRedirect = false,
decoderUrl = null,
testBandwidth = true;
touchcodeInit(campaignId, touchcodeEnabledDiv, progressCallback, decodeCallback, autoRedirect, testBandwidth);
})()
HTML
<div class=”touchcode_content” id=”touchcode_enabled_div”> </div>
CSS
.touchcode_content{
display: block;
width: 100%;
height: 100vh;
}
| Name | Type | Default | Description |
|---|---|---|---|
| campaignId | string | REQUIRED | ID of the Touchcode campaign that will be used on this web app. This value must reflect an already created Touchcode campaign. Only codes in the codeset for this campaign will work on the web app. |
| touchcodeEnabledDiv | element object | REQUIRED | Element created in step 2. All touches occurring within this element will be sent to the decoder and if applicable, processed for a decode. |
| decodeCallback | func | (code) => null | Called when a decode is triggered with the decoded text passed as an argument. If no callback is specified the page will auto redirect to the target stored in the campaign. |
| progressCallback | func | (code) => null | Called when a touch event is triggered touchpoint data passed as an argument. |
| autoRedirect | bool | true | Boolean variable to determine whether or not the SDK will automatically redirect to the target URL. The absence of this parameter defaults to “True.” |
| decoderUrl | string | null | By default, the Touchcode SDK utilizes a standard decoder. In very rare circumstances, it may be desired to change the decoder that the webapp is using. In nearly all cases, this parameter should not be supplied. |
| testBandwidth | bool | false | Boolean variable to determine whether or not the SDK will automatically preform a bandwidth test during a session. In certain cases this may not be desirable on slow connections and can be disabled by passing “false”. The absence of this parameter defaults to “true.” |
If your campaign has one-time tokens enabled, each successfully decoded target URL will include a tc_nonce query parameter with a one-time token (a nonce) that can be validated using our SDK. We recommend validating this token via JavaScript code running on the target website, assuming that that website is under your control. This approach pairs well with the autoRedirect option that can be passed to touchcodeInit().
You can validate one-time tokens using the validateTouchcodeToken() function, which returns a Promise that evaluates to either true or false:
// your-target-website.js
import { validateTouchcodeToken } from "@touchcode/js-touchcode-sdk";
validateTouchcodeToken()
.then(isTokenValid => {
// use the validation results here
})
.catch(err => console.error(err.message));
validateTouchcodeToken() will validate against the browser window's current location, and will look for the one-time token in a query parameter called tc_nonce.
If you'd prefer to validate one-time tokens on your own server, you can call our API directly instead of using this SDK.
To validate a token, make a POST request to https://api.touchcode.com/2.0.2/validate_nonce that includes a JSON body with the following format:
{
"targetUrl": "https://example.com",
"nonce": "MiQt_biWT46704NkXsu1JQ"
}
If your token and target URL are valid, then our API will respond with a 200 status code. If they are invalid, the API will respond with a 401 status code.
FAQs
The Touchcode Javascript SDK which enables Touchcode experiences.
We found that @touchcode/js-touchcode-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.