Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tonconnect/protocol

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tonconnect/protocol - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

39

lib/utils/base64.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Base64 = void 0;
const buffer_1 = require("buffer");
function encodeBuffer(buffer, urlSafe) {
const encoded = buffer.toString('base64');
const tweetnacl_util_1 = __importDefault(require("tweetnacl-util"));
function encodeUint8Array(value, urlSafe) {
const encoded = tweetnacl_util_1.default.encodeBase64(value);
if (!urlSafe) {

@@ -12,22 +15,30 @@ return encoded;

}
function decodeToBuffer(message, urlSafe) {
const value = urlSafe ? decodeURIComponent(message) : message;
return buffer_1.Buffer.from(value, 'base64');
function decodeToUint8Array(value, urlSafe) {
if (urlSafe) {
value = decodeURIComponent(value);
}
return tweetnacl_util_1.default.decodeBase64(value);
}
function encode(value, urlSafe = false) {
if (!(value instanceof Uint8Array) && !(typeof value === 'string')) {
value = JSON.stringify(value);
let uint8Array;
if (value instanceof Uint8Array) {
uint8Array = value;
}
const buffer = buffer_1.Buffer.from(value);
return encodeBuffer(buffer, urlSafe);
else {
if (typeof value !== 'string') {
value = JSON.stringify(value);
}
uint8Array = tweetnacl_util_1.default.decodeUTF8(value);
}
return encodeUint8Array(uint8Array, urlSafe);
}
function decode(value, urlSafe = false) {
const decodedBuffer = decodeToBuffer(value, urlSafe);
const decodedUint8Array = decodeToUint8Array(value, urlSafe);
return {
toString() {
return decodedBuffer.toString('utf-8');
return tweetnacl_util_1.default.encodeUTF8(decodedUint8Array);
},
toObject() {
try {
return JSON.parse(decodedBuffer.toString('utf-8'));
return JSON.parse(tweetnacl_util_1.default.encodeUTF8(decodedUint8Array));
}

@@ -39,3 +50,3 @@ catch (e) {

toUint8Array() {
return new Uint8Array(decodedBuffer.buffer, decodedBuffer.byteOffset, decodedBuffer.byteLength / Uint8Array.BYTES_PER_ELEMENT);
return decodedUint8Array;
}

@@ -42,0 +53,0 @@ };

{
"name": "@tonconnect/protocol",
"version": "0.0.19",
"version": "0.0.20",
"repository": {

@@ -32,3 +32,3 @@ "type": "git",

"dependencies": {
"buffer": "^6.0.3"
"tweetnacl-util": "^0.15.1"
},

@@ -35,0 +35,0 @@ "devDependencies": {

@@ -5,4 +5,6 @@ # TON Connect protocol models

ℹ️ If you want to integrate TonConnect to your dApp, you should use [@tonconnect/sdk](https://www.npmjs.com/package/@tonconnect/sdk)
ℹ️ If you want to integrate TonConnect to your dApp, you should use [@tonconnect/sdk](https://www.npmjs.com/package/@tonconnect/sdk)
[Latest API documentation](https://ton-connect.github.io/sdk/modules/_tonconnect_protocol.html)
## Summary

@@ -9,0 +11,0 @@ Package contains protocol requests, responses and event models and encoding, decoding functions.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc