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

zkt-sdk

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zkt-sdk - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

5

package.json
{
"name": "zkt-sdk",
"version": "1.0.1",
"version": "1.0.2",
"description": "zkToken | JS SDK",

@@ -32,4 +32,5 @@ "main": "src/index.js",

"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4"
"webpack-dev-server": "^5.0.4",
"zkt-sdk": "^1.0.1"
}
}

28

README.md

@@ -5,4 +5,15 @@ # zkt-sdk-js

### Installation and Running
## Installation and Running
### As a package for node/typescript project
```js
import Auth from "zkt-sdk";
const zkEth = new Auth("<SXT_ENDPOINT>", "<SECRETS_PROXY_ENDPOINT>");
console.log(zkEth);
```
### As a bundled js file for the web
1. Install all dependencies

@@ -29,1 +40,16 @@

A new `index.html` with sample usage code should be available in the `./dist` folder. In your browser open http://localhost:9000 and check the console logs. It watches any changes to the html file
#### Usage
```html
<!DOCTYPE html>
<head>
<script src="./bundle.js"></script>
<script>
// Using the auth
const zkWallet = new zkEth.Auth("<SXT_ENDPOINT>", "<SECRETS_PROXY_ENDPOINT>");
console.log(zkWallet)
</script>
</head>
</html>
```

@@ -5,3 +5,3 @@ import axios from "axios";

* All the Authentication methods using
* Gateway Secrets Proxy APIs
* Gateway Secrets Proxy APIs and Wallet APIs
*/

@@ -11,12 +11,19 @@

private SXT_SECRETS_PROXY_URL: string = "";
private SXT_BASE_URL: string = "";
constructor(baseUrl: string) {
if (typeof baseUrl === "string" && baseUrl !== "") {
this.SXT_SECRETS_PROXY_URL = baseUrl;
constructor(walletBaseUrl: string, spBaseUrl: string) {
if (
typeof walletBaseUrl === "string" &&
walletBaseUrl !== "" &&
typeof spBaseUrl === "string" &&
spBaseUrl !== ""
) {
this.SXT_SECRETS_PROXY_URL = spBaseUrl;
this.SXT_BASE_URL = walletBaseUrl;
} else {
throw new Error("Invalid baseurl input");
throw new Error("Invalid baseurl input provided");
}
}
// Register
// Secrets Proxy Register
register = async (

@@ -51,3 +58,3 @@ userId: string,

// Login
// Secrets Proxy Login
login = async (userId: string, password: string): Promise<any> => {

@@ -77,3 +84,3 @@ const options = {

// Session Refresh
// Secrets Proxy Session Refresh
sessionRefresh = async (sid: string): Promise<any> => {

@@ -98,2 +105,88 @@ const options = {

};
// Wallet Authentication Code
walletAuthCode = async (
walletAddr: string,
userId?: string,
prefix?: string,
joinCode?: string
): Promise<any> => {
const options = {
method: "POST",
url: `${this.SXT_BASE_URL}/v1/auth/wallet/code`,
headers: {
accept: "application/json",
"Content-Type": "application/json",
},
data: {
walletAddr: walletAddr,
userId: userId,
prefix: prefix,
joinCode: joinCode,
},
};
const result = await axios.request(options);
if (result.status !== 200 || result.data.length <= 0) {
throw new Error(
`${result.status}: ${result.data.title}. Detail: ${result.data.detail}`
);
}
return result.data;
};
// Wallet Token Request
tokenRequest = async (
userId: string,
authCode: string,
signature: string,
key: string,
scheme: string
): Promise<any> => {
const options = {
method: "POST",
url: `${this.SXT_BASE_URL}/v1/auth/token`,
headers: {
accept: "application/json",
},
data: {
userId: userId,
authCode: authCode,
signature: signature,
key: key,
scheme: scheme,
},
};
const result = await axios.request(options);
if (result.status !== 200 || result.data.length <= 0) {
throw new Error(
`${result.status}: ${result.data.title}. Detail: ${result.data.detail}`
);
}
return result.data;
};
// Wallet Token Refresh
tokenRefresh = async (bearerToken: string): Promise<any> => {
const options = {
method: "POST",
url: `${this.SXT_BASE_URL}/v1/auth/refresh`,
headers: {
accept: "application/json",
authorization: `Bearer ${bearerToken}`,
},
};
const result = await axios.request(options);
if (result.status !== 200 || result.data.length <= 0) {
throw new Error(
`${result.status}: ${result.data.title}. Detail: ${result.data.detail}`
);
}
return result.data;
};
}

@@ -1,11 +0,4 @@

// import { GwLogin } from "../authentication/auth.js";
// import { WalletAuthCode } from "../authentication/walletauth.js";
import Auth from "zkt-sdk";
// const response = await GwLogin("someuser", "somepass");
// console.log(response);
// const responseWallet = await WalletAuthCode(
// "0xfffA391208F6508af6Ca29AbB43F5436C5530000",
// "someuser"
// );
// console.log(responseWallet);
const zkAuth = new Auth("<SXT_ENDPOINT>", "<SECRETS_PROXY_ENDPOINT>");
console.log(zkAuth);
import Auth from "./authentication/auth";
import WalletAuth from "./authentication/walletauth";
export { Auth, WalletAuth };
export default Auth;

Sorry, the diff of this file is not supported yet

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