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

@tiplink/api

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiplink/api - npm Package Compare versions

Comparing version 0.1.5-beta2 to 0.1.6-beta1

dist/enclave.d.ts

8

dist/client.d.ts
import { TipLink } from './index';
import { decrypt } from './crypto';
export { decrypt };
type ArgT = string | number | boolean | string[] | number[];
declare type ArgT = string | number | boolean | string[] | number[];
export declare class TipLinkClient {

@@ -46,6 +46,6 @@ apiKey: string;

interface AnalyticsSummary {
event_type_counts: number;
event_type_counts: Record<string, number>[];
total: number;
faucets_info: number;
campaign_info: number;
faucets_info: Record<string, number>[];
campaign_info: Record<string, number>[];
}

@@ -52,0 +52,0 @@ declare class CampaignActions extends TipLinkApi {

@@ -57,3 +57,2 @@ "use strict";

}
console.log(url.toString(), params);
try {

@@ -60,0 +59,0 @@ const result = yield fetch(url.toString(), params);

@@ -6,3 +6,3 @@ import { Keypair } from '@solana/web3.js';

private constructor();
static create(): Promise<TipLink>;
static create(version?: number): Promise<TipLink>;
static fromUrl(url: URL): Promise<TipLink>;

@@ -13,1 +13,5 @@ static fromLink(link: string): Promise<TipLink>;

export { TipLinkClient };
import { EscrowTipLink } from './escrow';
export { EscrowTipLink };
import { mail, mailEscrow } from './enclave';
export { mail, mailEscrow };

@@ -15,3 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TipLinkClient = exports.TipLink = void 0;
exports.mailEscrow = exports.mail = exports.EscrowTipLink = exports.TipLinkClient = exports.TipLink = void 0;
const web3_js_1 = require("@solana/web3.js");

@@ -21,4 +21,7 @@ const libsodium_wrappers_sumo_1 = __importDefault(require("libsodium-wrappers-sumo"));

const DEFAULT_TIPLINK_KEYLENGTH = 12;
const DEFAULT_HASHLESS_TIPLINK_KEYLENGTH = 16; // 16 bytes = 128 bits
const TIPLINK_ORIGIN = "https://tiplink.io";
const TIPLINK_PATH = "/i";
const VERSION_DELIMITER = "_";
const VALID_VERSIONS = new Set([0, 1]);
const getSodium = () => __awaiter(void 0, void 0, void 0, function* () {

@@ -44,2 +47,7 @@ yield libsodium_wrappers_sumo_1.default.ready;

const seed = yield kdfz(sodium.crypto_sign_SEEDBYTES, pw);
return web3_js_1.Keypair.fromSeed(seed);
});
const pwToKeypairV1 = (pw) => __awaiter(void 0, void 0, void 0, function* () {
const sodium = yield getSodium();
const seed = sodium.pad(pw, sodium.crypto_sign_SEEDBYTES);
return (web3_js_1.Keypair.fromSeed(seed));

@@ -52,13 +60,28 @@ });

}
static create() {
static create(version = 0) {
return __awaiter(this, void 0, void 0, function* () {
if (!VALID_VERSIONS.has(version)) {
throw Error("invalid version");
}
yield getSodium();
const b = yield randBuf(DEFAULT_TIPLINK_KEYLENGTH);
const keypair = yield pwToKeypair(b);
const hash = (0, bs58_1.encode)(b);
const urlString = `${TIPLINK_ORIGIN}${TIPLINK_PATH}#${hash}`;
// can't assign hash as it causes an error in React Native
const link = new URL(urlString);
const tiplink = new TipLink(link, keypair);
return tiplink;
if (version === 1) {
const b = yield randBuf(DEFAULT_HASHLESS_TIPLINK_KEYLENGTH);
const keypair = yield pwToKeypairV1(b);
const hash = (0, bs58_1.encode)(b);
const urlString = `${TIPLINK_ORIGIN}${TIPLINK_PATH}#${VERSION_DELIMITER}${hash}`;
// can't assign hash as it causes an error in React Native
const link = new URL(urlString);
const tiplink = new TipLink(link, keypair);
return tiplink;
}
else { // version === 0
const b = yield randBuf(DEFAULT_TIPLINK_KEYLENGTH);
const keypair = yield pwToKeypair(b);
const hash = (0, bs58_1.encode)(b);
const urlString = `${TIPLINK_ORIGIN}${TIPLINK_PATH}#${hash}`;
// can't assign hash as it causes an error in React Native
const link = new URL(urlString);
const tiplink = new TipLink(link, keypair);
return tiplink;
}
});

@@ -68,7 +91,24 @@ }

return __awaiter(this, void 0, void 0, function* () {
const slug = url.hash.slice(1);
let slug = url.hash.slice(1);
let version = 0;
if (slug.includes(VERSION_DELIMITER)) {
const versionString = slug.split(VERSION_DELIMITER, 1)[0];
if (versionString.length === 0) {
version = 1;
// } else {
// version = Number(versionString);
}
slug = slug.split(VERSION_DELIMITER).slice(1).join(VERSION_DELIMITER);
}
const pw = Uint8Array.from((0, bs58_1.decode)(slug));
const keypair = yield pwToKeypair(pw);
const tiplink = new TipLink(url, keypair);
return tiplink;
if (version === 1) {
const keypair = yield pwToKeypairV1(pw);
const tiplink = new TipLink(url, keypair);
return tiplink;
}
else {
const keypair = yield pwToKeypair(pw);
const tiplink = new TipLink(url, keypair);
return tiplink;
}
});

@@ -86,1 +126,6 @@ }

Object.defineProperty(exports, "TipLinkClient", { enumerable: true, get: function () { return client_1.TipLinkClient; } });
const escrow_1 = require("./escrow");
Object.defineProperty(exports, "EscrowTipLink", { enumerable: true, get: function () { return escrow_1.EscrowTipLink; } });
const enclave_1 = require("./enclave");
Object.defineProperty(exports, "mail", { enumerable: true, get: function () { return enclave_1.mail; } });
Object.defineProperty(exports, "mailEscrow", { enumerable: true, get: function () { return enclave_1.mailEscrow; } });
{
"name": "@tiplink/api",
"version": "0.1.5-beta2",
"version": "0.1.6-beta1",
"description": "Api for creating and sending TipLinks",

@@ -9,2 +9,3 @@ "main": "dist/index.js",

"test": "jest",
"test:include-onchain-tests": "ONCHAIN_TESTS=true jest",
"build": "tsc",

@@ -18,2 +19,4 @@ "lint": "eslint . --ext .ts",

"dependencies": {
"@coral-xyz/anchor": "^0.29.0",
"@solana/spl-token": "^0.3.10",
"@solana/web3.js": "^1.48.0",

@@ -34,6 +37,9 @@ "bs58": "^5.0.0",

"@typescript-eslint/parser": "^5.30.6",
"@typescript-eslint/typescript-estree": "^6.18.1",
"bip39": "^3.1.0",
"dotenv": "^16.3.1",
"eslint": "^8.19.0",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
"typescript": "^4.9.3"
"typescript": "^4.7.4"
},

@@ -40,0 +46,0 @@ "files": [

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