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

@nicheprotocol/darwin-sdk

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nicheprotocol/darwin-sdk - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.eslintrc.js

6

package.json
{
"name": "@nicheprotocol/darwin-sdk",
"version": "0.0.3",
"version": "0.0.4",
"main": "./dist/index.js",

@@ -17,4 +17,6 @@ "types": "./dist/index.d.ts",

"jest": "^29.4.2",
"jest-environment-jsdom": "^29.4.2",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
"typescript": "^4.9.5",
"whatwg-fetch": "^3.6.2"
},

@@ -21,0 +23,0 @@ "dependencies": {

@@ -1,2 +0,6 @@

export { createToken, verifyToken } from './token';
export { init } from './store';
import { createToken, verifyToken } from './token';
import { init } from './store';
export const server = { init, createToken, verifyToken };
export const client = {};

@@ -1,13 +0,35 @@

import { init as initKey, deinit as deinitKey } from './secret';
import { TOKEN_STORAGE_KEY } from './connect';
import { init as initKey, get as getKey } from './secret';
type DarwinInitialization = {
type TStorage = {
getItem(key: string): any;
setItem(key: string, value: any): void;
};
type DarwinState = {
endpointUrl?: string;
key: {
fetchTokenRoute?: string;
key?: {
publicKey: string;
secretKey?: string;
};
storage: TStorage;
};
export const init = ({ key }: DarwinInitialization) => {
initKey(key.publicKey, key.secretKey);
let url = '';
let tokenRoute = '';
let storageStrategy: TStorage;
export const init = ({ endpointUrl, fetchTokenRoute, key, storage }: DarwinState) => {
if (endpointUrl) {
url = endpointUrl;
}
if (fetchTokenRoute) {
tokenRoute = fetchTokenRoute;
}
if (key) {
initKey(key.publicKey, key.secretKey);
}
storageStrategy = storage;
};

@@ -17,4 +39,13 @@

export const get = () => {
return {};
export const get = (): DarwinState => {
return {
endpointUrl: url,
fetchTokenRoute: tokenRoute,
key: getKey(),
storage: storageStrategy,
};
};
export const getToken = async (): Promise<string> => {
return storageStrategy.getItem(TOKEN_STORAGE_KEY);
};
import { sign, verify } from 'jsonwebtoken';
import { get } from './secret';
type DarwinTokenPayload = {
export type DarwinTokenPayload = {
/**
* User id.
*/
id: string;
/**
* User full name.
*/
fullName: string;
/**
* Clubs this user is authorized to manage billing for.
*/
authorizations: string[];

@@ -21,3 +30,5 @@ };

if (!key?.secretKey) {
throw new Error(`Darwin not initialized with private key. Invoke init() first.`);
throw new Error(
`Darwin not initialized with private key. Invoke init() first.`,
);
}

@@ -36,3 +47,5 @@

if (!key?.publicKey) {
throw new Error(`Darwin not initialized with public key. Invoke init() first.`);
throw new Error(
`Darwin not initialized with public key. Invoke init() first.`,
);
}

@@ -39,0 +52,0 @@

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