New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dialectlabs/blockchain-sdk-solana

Package Overview
Dependencies
Maintainers
5
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dialectlabs/blockchain-sdk-solana - npm Package Compare versions

Comparing version 1.1.1-rc.3 to 1.1.1-rc.4

dist/index.d.mts

194

dist/index.js

@@ -0,3 +1,48 @@

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
DIALECT_BLOCKCHAIN_SDK_TYPE_SOLANA: () => DIALECT_BLOCKCHAIN_SDK_TYPE_SOLANA,
DialectSolanaWalletAdapterWrapper: () => DialectSolanaWalletAdapterWrapper,
DialectWalletAdapterSolanaEd25519TokenSigner: () => DialectWalletAdapterSolanaEd25519TokenSigner,
NodeDialectSolanaWalletAdapter: () => NodeDialectSolanaWalletAdapter,
SOLANA_ED25519_TOKEN_SIGNER_ALG: () => SOLANA_ED25519_TOKEN_SIGNER_ALG,
SOLANA_ED25519_TOKEN_SIGNER_ALG_BACKWARD_COMPATIBLE: () => SOLANA_ED25519_TOKEN_SIGNER_ALG_BACKWARD_COMPATIBLE,
SolanaEd25519AuthenticationFacadeFactory: () => SolanaEd25519AuthenticationFacadeFactory,
SolanaEd25519TokenSigner: () => SolanaEd25519TokenSigner,
SolanaSdkFactory: () => SolanaSdkFactory,
SolanaTxAuthenticationFacadeFactory: () => SolanaTxAuthenticationFacadeFactory
});
module.exports = __toCommonJS(src_exports);
// src/wallet-adapter/dialect-solana-wallet-adapter-wrapper.ts
import { UnsupportedOperationError } from "@dialectlabs/sdk";
var import_sdk = require("@dialectlabs/sdk");
var DialectSolanaWalletAdapterWrapper = class _DialectSolanaWalletAdapterWrapper {

@@ -9,3 +54,3 @@ constructor(delegate) {

if (!this.delegate.publicKey) {
throw new UnsupportedOperationError(
throw new import_sdk.UnsupportedOperationError(
"Public key not available",

@@ -25,3 +70,3 @@ "Wallet does not have public key, please provide a valid public key."

if (!this.delegate.signTransaction) {
throw new UnsupportedOperationError(
throw new import_sdk.UnsupportedOperationError(
"Signing not supported",

@@ -35,3 +80,3 @@ "Wallet does not support signing, please use wallet-adapter that supports signTransaction() operation."

if (!this.delegate.signAllTransactions) {
throw new UnsupportedOperationError(
throw new import_sdk.UnsupportedOperationError(
"Signing not supported",

@@ -45,3 +90,3 @@ "Wallet does not support signing, please use wallet-adapter that supports signAllTransactions() operation."

if (!this.delegate.signMessage) {
throw new UnsupportedOperationError(
throw new import_sdk.UnsupportedOperationError(
"Message signing not supported",

@@ -55,3 +100,3 @@ "Wallet does not support message signing, please use wallet-adapter that supports signMessage() operation."

if (!this.delegate.diffieHellman) {
throw new UnsupportedOperationError(
throw new import_sdk.UnsupportedOperationError(
"Encryption not supported",

@@ -72,8 +117,5 @@ "Wallet does not support encryption, please use wallet-adapter that supports diffieHellman() operation."

// src/wallet-adapter/node-dialect-solana-wallet-adapter.ts
import {
Keypair,
VersionedTransaction
} from "@solana/web3.js";
import nacl from "tweetnacl";
import { convertKeyPair } from "ed2curve";
var import_web3 = require("@solana/web3.js");
var import_tweetnacl = __toESM(require("tweetnacl"));
var import_ed2curve = require("ed2curve");
var NodeDialectSolanaWalletAdapter = class _NodeDialectSolanaWalletAdapter {

@@ -94,3 +136,3 @@ constructor(keypair) {

const privateKey = process.env.DIALECT_SDK_CREDENTIALS;
const keypair2 = Keypair.fromSecretKey(
const keypair2 = import_web3.Keypair.fromSecretKey(
new Uint8Array(JSON.parse(privateKey))

@@ -109,3 +151,3 @@ );

async signTransaction(transaction) {
if (transaction instanceof VersionedTransaction) {
if (transaction instanceof import_web3.VersionedTransaction) {
const signer = {

@@ -126,6 +168,6 @@ publicKey: this.keypair.publicKey,

signMessage(message) {
return Promise.resolve(nacl.sign.detached(message, this.keypair.secretKey));
return Promise.resolve(import_tweetnacl.default.sign.detached(message, this.keypair.secretKey));
}
diffieHellman(publicKey) {
const keypair = convertKeyPair({
const keypair = (0, import_ed2curve.convertKeyPair)({
secretKey: this.keypair.secretKey,

@@ -142,14 +184,7 @@ publicKey

// src/auth/ed25519/solana-ed25519-authentication-facade-factory.ts
import {
AuthenticationFacade,
AuthenticationFacadeFactory,
Authenticator,
DefaultTokenGenerator,
Ed25519TokenBodyParser,
TokenParser
} from "@dialectlabs/sdk";
var import_sdk3 = require("@dialectlabs/sdk");
// src/auth/ed25519/solana-ed25519-token-validator.ts
import { Ed25519PublicKey, TokenValidator } from "@dialectlabs/sdk";
import nacl2 from "tweetnacl";
var import_sdk2 = require("@dialectlabs/sdk");
var import_tweetnacl2 = __toESM(require("tweetnacl"));

@@ -187,3 +222,3 @@ // src/sdk/constants.ts

// src/auth/ed25519/solana-ed25519-token-validator.ts
var SolanaEd25519TokenValidator = class extends TokenValidator {
var SolanaEd25519TokenValidator = class extends import_sdk2.TokenValidator {
canValidate(tokenHeader) {

@@ -195,6 +230,6 @@ return tokenHeader.alg === SOLANA_ED25519_TOKEN_SIGNER_ALG || tokenHeader.alg === SOLANA_ED25519_TOKEN_SIGNER_ALG_BACKWARD_COMPATIBLE;

const signingPayload = new TextEncoder().encode(signedPayload);
return nacl2.sign.detached.verify(
return import_tweetnacl2.default.sign.detached.verify(
signingPayload,
token.signature,
new Ed25519PublicKey(token.body.sub_jwk ?? token.body.sub).toBytes()
new import_sdk2.Ed25519PublicKey(token.body.sub_jwk ?? token.body.sub).toBytes()
);

@@ -211,3 +246,3 @@ }

// src/auth/ed25519/solana-ed25519-authentication-facade-factory.ts
var SolanaEd25519AuthenticationFacadeFactory = class _SolanaEd25519AuthenticationFacadeFactory extends AuthenticationFacadeFactory {
var SolanaEd25519AuthenticationFacadeFactory = class _SolanaEd25519AuthenticationFacadeFactory extends import_sdk3.AuthenticationFacadeFactory {
constructor(tokenSigner) {

@@ -218,4 +253,4 @@ super();

static createAuthenticator() {
return new Authenticator(
new TokenParser(new Ed25519TokenBodyParser()),
return new import_sdk3.Authenticator(
new import_sdk3.TokenParser(new import_sdk3.Ed25519TokenBodyParser()),
new SolanaEd25519TokenValidator()

@@ -225,5 +260,5 @@ );

get() {
return new AuthenticationFacade(
return new import_sdk3.AuthenticationFacade(
this.tokenSigner,
new DefaultTokenGenerator(this.tokenSigner),
new import_sdk3.DefaultTokenGenerator(this.tokenSigner),
_SolanaEd25519AuthenticationFacadeFactory.createAuthenticator()

@@ -235,21 +270,11 @@ );

// src/auth/tx/solana-tx-authentication-facade-factory.ts
import {
AuthenticationFacade as AuthenticationFacade2,
AuthenticationFacadeFactory as AuthenticationFacadeFactory2,
Authenticator as Authenticator2,
TokenParser as TokenParser2
} from "@dialectlabs/sdk";
var import_sdk7 = require("@dialectlabs/sdk");
// src/auth/tx/solana-tx-token-body-parser.ts
import {
bytesFromBase64,
jsonParseFromBase64,
TokenBodyParser,
TokenStructureValidationError
} from "@dialectlabs/sdk";
import { Transaction as Transaction2 } from "@solana/web3.js";
var SolanaTxTokenBodyParser = class extends TokenBodyParser {
var import_sdk4 = require("@dialectlabs/sdk");
var import_web32 = require("@solana/web3.js");
var SolanaTxTokenBodyParser = class extends import_sdk4.TokenBodyParser {
parse(base64Body) {
const byteBody = bytesFromBase64(base64Body);
const tx = Transaction2.from(byteBody);
const byteBody = (0, import_sdk4.bytesFromBase64)(base64Body);
const tx = import_web32.Transaction.from(byteBody);
const dataInstruction = tx.instructions.filter(

@@ -259,9 +284,9 @@ (it) => it.programId === tx.feePayer

if (!dataInstruction) {
throw new TokenStructureValidationError();
throw new import_sdk4.TokenStructureValidationError();
}
const [headerBase64, bodyBase64] = dataInstruction.data.toString().split(".");
if (!headerBase64 || !bodyBase64) {
throw new TokenStructureValidationError();
throw new import_sdk4.TokenStructureValidationError();
}
return jsonParseFromBase64(bodyBase64);
return (0, import_sdk4.jsonParseFromBase64)(bodyBase64);
}

@@ -271,13 +296,9 @@ };

// src/auth/tx/solana-tx-token-generator.ts
import {
bytesToBase64,
jsonStringifyToBase64,
TokenGenerator
} from "@dialectlabs/sdk";
var SolanaTxTokenGenerator = class extends TokenGenerator {
var import_sdk5 = require("@dialectlabs/sdk");
var SolanaTxTokenGenerator = class extends import_sdk5.TokenGenerator {
async generate(ttlSeconds) {
const header = this.header();
const base64Header = jsonStringifyToBase64(header);
const base64Header = (0, import_sdk5.jsonStringifyToBase64)(header);
const body = this.body(ttlSeconds);
const base64Body = jsonStringifyToBase64(body);
const base64Body = (0, import_sdk5.jsonStringifyToBase64)(body);
const { signature, base64Signature, signedPayload } = await this.sign(

@@ -288,3 +309,3 @@ base64Header,

);
const base64SignedBody = bytesToBase64(signedPayload);
const base64SignedBody = (0, import_sdk5.bytesToBase64)(signedPayload);
const rawValue = `${base64Header}.${base64SignedBody}.${base64Signature}`;

@@ -304,12 +325,8 @@ return {

// src/auth/tx/solana-tx-token-validator.ts
import { decodeURLSafe } from "@stablelib/base64";
import { PublicKey as PublicKey2, Transaction as Transaction4 } from "@solana/web3.js";
import { TokenValidator as TokenValidator2 } from "@dialectlabs/sdk";
var import_base64 = require("@stablelib/base64");
var import_web34 = require("@solana/web3.js");
var import_sdk6 = require("@dialectlabs/sdk");
// src/auth/tx/solana-tx-token-signer.ts
import {
PublicKey as SolanaPublicKey,
Transaction as Transaction3,
TransactionInstruction
} from "@solana/web3.js";
var import_web33 = require("@solana/web3.js");
var SOLANA_TX_TOKEN_SIGNER_ALG = `${DIALECT_BLOCKCHAIN_SDK_TYPE_SOLANA}-tx`;

@@ -333,6 +350,6 @@ var SolanaTxTokenSigner = class {

async sign(payload) {
const tx = new Transaction3();
const subjectPublicKey = new SolanaPublicKey(this.subject);
const tx = new import_web33.Transaction();
const subjectPublicKey = new import_web33.PublicKey(this.subject);
tx.add(
new TransactionInstruction({
new import_web33.TransactionInstruction({
keys: [

@@ -349,3 +366,3 @@ {

);
tx.recentBlockhash = SolanaPublicKey.default.toString();
tx.recentBlockhash = import_web33.PublicKey.default.toString();
tx.feePayer = subjectPublicKey;

@@ -361,3 +378,3 @@ const signedTx = await this.dialectWalletAdapter.signTransaction(tx);

// src/auth/tx/solana-tx-token-validator.ts
var SolanaTxTokenValidator = class extends TokenValidator2 {
var SolanaTxTokenValidator = class extends import_sdk6.TokenValidator {
canValidate(tokenHeader) {

@@ -367,5 +384,5 @@ return tokenHeader.alg === SOLANA_TX_TOKEN_SIGNER_ALG;

isSignatureValid(token) {
const byteBody = decodeURLSafe(token.base64Body);
const tx = Transaction4.from(byteBody);
tx.recentBlockhash = PublicKey2.default.toString();
const byteBody = (0, import_base64.decodeURLSafe)(token.base64Body);
const tx = import_web34.Transaction.from(byteBody);
tx.recentBlockhash = import_web34.PublicKey.default.toString();
return tx.verifySignatures();

@@ -382,3 +399,3 @@ }

// src/auth/tx/solana-tx-authentication-facade-factory.ts
var SolanaTxAuthenticationFacadeFactory = class _SolanaTxAuthenticationFacadeFactory extends AuthenticationFacadeFactory2 {
var SolanaTxAuthenticationFacadeFactory = class _SolanaTxAuthenticationFacadeFactory extends import_sdk7.AuthenticationFacadeFactory {
constructor(tokenSigner) {

@@ -389,4 +406,4 @@ super();

static createAuthenticator() {
return new Authenticator2(
new TokenParser2(new SolanaTxTokenBodyParser()),
return new import_sdk7.Authenticator(
new import_sdk7.TokenParser(new SolanaTxTokenBodyParser()),
new SolanaTxTokenValidator()

@@ -396,3 +413,3 @@ );

get() {
return new AuthenticationFacade2(
return new import_sdk7.AuthenticationFacade(
this.tokenSigner,

@@ -406,7 +423,7 @@ new SolanaTxTokenGenerator(this.tokenSigner),

// src/sdk/sdk.ts
import { EncryptionKeysProvider as EncryptionKeysProvider2 } from "@dialectlabs/sdk";
var import_sdk9 = require("@dialectlabs/sdk");
// src/encryption/encryption-keys-provider.ts
import { EncryptionKeysProvider } from "@dialectlabs/sdk";
var DialectSolanaWalletAdapterEncryptionKeysProvider = class extends EncryptionKeysProvider {
var import_sdk8 = require("@dialectlabs/sdk");
var DialectSolanaWalletAdapterEncryptionKeysProvider = class extends import_sdk8.EncryptionKeysProvider {
constructor(dialectWalletAdapter) {

@@ -452,3 +469,3 @@ super();

const walletAdapterEncryptionKeysProvider = new DialectSolanaWalletAdapterEncryptionKeysProvider(wallet);
const encryptionKeysProvider = EncryptionKeysProvider2.create(
const encryptionKeysProvider = import_sdk9.EncryptionKeysProvider.create(
walletAdapterEncryptionKeysProvider,

@@ -482,3 +499,4 @@ config.encryptionKeysStore

};
export {
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DIALECT_BLOCKCHAIN_SDK_TYPE_SOLANA,

@@ -494,3 +512,3 @@ DialectSolanaWalletAdapterWrapper,

SolanaTxAuthenticationFacadeFactory
};
});
//# sourceMappingURL=index.js.map
{
"name": "@dialectlabs/blockchain-sdk-solana",
"version": "1.1.1-rc.3",
"type": "module",
"version": "1.1.1-rc.4",
"repository": "git@github.com:dialectlabs/sdk.git",

@@ -9,9 +8,9 @@ "author": "dialectlabs",

"sideEffects": false,
"main": "dist/index.cjs",
"module": "dist/index.js",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},

@@ -32,3 +31,3 @@ "./index.css": "./dist/index.css"

"devDependencies": {
"@dialectlabs/sdk": "1.7.8-rc.3",
"@dialectlabs/sdk": "1.7.8-rc.4",
"@solana/wallet-adapter-base": "^0.9.15",

@@ -38,3 +37,3 @@ "@solana/web3.js": "^1.78.0"

"peerDependencies": {
"@dialectlabs/sdk": "1.7.8-rc.3",
"@dialectlabs/sdk": "1.7.8-rc.4",
"@solana/wallet-adapter-base": "0.x",

@@ -41,0 +40,0 @@ "@solana/web3.js": "^1.54.x"

Sorry, the diff of this file is not supported yet

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