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.1 to 1.1.1-rc.2

dist/index.cjs

194

dist/index.js

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

"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
var import_sdk = require("@dialectlabs/sdk");
import { UnsupportedOperationError } from "@dialectlabs/sdk";
var DialectSolanaWalletAdapterWrapper = class _DialectSolanaWalletAdapterWrapper {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -230,6 +195,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 import_tweetnacl2.default.sign.detached.verify(
return nacl2.sign.detached.verify(
signingPayload,
token.signature,
new import_sdk2.Ed25519PublicKey(token.body.sub_jwk ?? token.body.sub).toBytes()
new Ed25519PublicKey(token.body.sub_jwk ?? token.body.sub).toBytes()
);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -5,0 +6,0 @@ "author": "dialectlabs",

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