@tiplink/api
Advanced tools
Comparing version 0.1.5-beta2 to 0.1.6-beta1
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": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79115
19
1863
10
12
1
5
+ Added@coral-xyz/anchor@^0.29.0
+ Added@solana/spl-token@^0.3.10
+ Added@coral-xyz/anchor@0.29.0(transitive)
+ Added@coral-xyz/borsh@0.29.0(transitive)
+ Added@solana/buffer-layout-utils@0.2.0(transitive)
+ Added@solana/codecs@2.0.0-rc.1(transitive)
+ Added@solana/codecs-core@2.0.0-rc.1(transitive)
+ Added@solana/codecs-data-structures@2.0.0-rc.1(transitive)
+ Added@solana/codecs-numbers@2.0.0-rc.1(transitive)
+ Added@solana/codecs-strings@2.0.0-rc.1(transitive)
+ Added@solana/errors@2.0.0-rc.1(transitive)
+ Added@solana/options@2.0.0-rc.1(transitive)
+ Added@solana/spl-token@0.3.11(transitive)
+ Added@solana/spl-token-metadata@0.1.6(transitive)
+ Addedbignumber.js@9.1.2(transitive)
+ Addedbuffer-layout@1.2.2(transitive)
+ Addedcamelcase@6.3.0(transitive)
+ Addedchalk@5.3.0(transitive)
+ Addedcommander@12.1.0(transitive)
+ Addedcross-fetch@3.1.8(transitive)
+ Addedcrypto-hash@1.3.0(transitive)
+ Addeddot-case@3.0.4(transitive)
+ Addedeventemitter3@4.0.7(transitive)
+ Addedfastestsmallesttextencoderdecoder@1.0.22(transitive)
+ Addedlower-case@2.0.2(transitive)
+ Addedno-case@3.0.4(transitive)
+ Addedpako@2.1.0(transitive)
+ Addedsnake-case@3.0.4(transitive)
+ Addedsuperstruct@0.15.5(transitive)
+ Addedtoml@3.0.0(transitive)
+ Addedtypescript@5.7.2(transitive)