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

kauth-sdk-node

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kauth-sdk-node - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

dist/common/http/tool/marmot.d.ts

10

dist/common/config/config.d.ts

@@ -5,4 +5,2 @@ export interface KauthConfig {

jwtDuration: number;
kauthOrigin: string;
kflowOrigin: string;
googleTokenUri: string;

@@ -13,2 +11,10 @@ googleAuthorizeUri: string;

loginRedirectUri: string;
marmotAccessKeyId?: string;
marmotAccessKeySecret?: string;
kauthOrigin: string;
kauthServiceName?: string;
kauthServicePort?: string;
kflowOrigin: string;
kflowServiceName?: string;
kflowServicePort?: string;
}

22

dist/common/http/kauth.d.ts

@@ -0,19 +1,21 @@

/// <reference types="node" />
import { ParsedUrlQueryInput } from 'querystring';
import { KauthConfig } from '../config/config';
import { KauthMoziAuthenticationInformation, KauthGoogleAuthenticationInformation, KauthPermission } from './response/kauth';
import { MarmotOptions } from './tool/marmot';
interface AuthenticateParams extends ParsedUrlQueryInput, MarmotOptions {
code: string;
redirect_uri: string;
}
export declare class KauthApi {
private kauthUtil;
constructor({ kauthOrigin }: KauthConfig);
private marmotUtil;
constructor({ kauthOrigin, marmotAccessKeyId, marmotAccessKeySecret, kauthServiceName, kauthServicePort }: KauthConfig);
moziAuthorizeURL(callback: string): Promise<string>;
moziAuthenticate(data: {
code: string;
redirect_uri: string;
}): Promise<KauthMoziAuthenticationInformation>;
moziAuthenticate(data: AuthenticateParams): Promise<KauthMoziAuthenticationInformation>;
getMoziAuthenticationInformation(id: number): Promise<KauthMoziAuthenticationInformation>;
googleAuthorizeURL(callback: string): Promise<string>;
googleAuthenticate(data: {
code: string;
redirect_uri: string;
}): Promise<KauthGoogleAuthenticationInformation>;
googleAuthenticate(data: AuthenticateParams): Promise<KauthGoogleAuthenticationInformation>;
getGoogleAuthenticationInformation(id: number): Promise<KauthGoogleAuthenticationInformation>;
listPermissionsByUserId(id: number): Promise<KauthPermission[]>;
}
export {};
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.KauthApi = void 0;
const axios_1 = __importDefault(require("axios"));
const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
const http_1 = require("../constant/http");
const kauth_1 = require("./response/kauth");
const marmot_1 = require("./tool/marmot");
class KauthApi {
constructor({ kauthOrigin }) {
this.kauthUtil = new KauthUtil(kauthOrigin || '');
constructor({ kauthOrigin, marmotAccessKeyId, marmotAccessKeySecret, kauthServiceName, kauthServicePort }) {
this.marmotUtil = new marmot_1.MarmotUtil(kauthOrigin, marmotAccessKeyId, marmotAccessKeySecret, kauthServiceName, kauthServicePort);
}
async moziAuthorizeURL(callback) {
return this.kauthUtil.get(http_1.MoziAuthorizeUri, { callback });
return this.marmotUtil.get(http_1.MoziAuthorizeUri, { callback });
}
async moziAuthenticate(data) {
return this.kauthUtil.post(http_1.MoziAuthenticateUri, data);
return this.marmotUtil.post(http_1.MoziAuthenticateUri, data);
}
async getMoziAuthenticationInformation(id) {
return this.kauthUtil.get(http_1.MoziAuthenticationInformationUri, { id });
return this.marmotUtil.get(http_1.MoziAuthenticationInformationUri, { id });
}
async googleAuthorizeURL(callback) {
return this.kauthUtil.get(http_1.GoogleAuthorizeUri, { callback });
return this.marmotUtil.get(http_1.GoogleAuthorizeUri, { callback });
}
async googleAuthenticate(data) {
return this.kauthUtil.post(http_1.GoogleAuthenticateUri, data);
return this.marmotUtil.post(http_1.GoogleAuthenticateUri, data);
}
async getGoogleAuthenticationInformation(id) {
return this.kauthUtil.get(http_1.GoogleAuthenticationInformationUri, { id });
return this.marmotUtil.get(http_1.GoogleAuthenticationInformationUri, { id });
}
async listPermissionsByUserId(id) {
return this.kauthUtil.get(http_1.ListPermissionsByUserIdUri, { id });
return this.marmotUtil.get(http_1.ListPermissionsByUserIdUri, { id });
}
}
exports.KauthApi = KauthApi;
class KauthUtil {
constructor(origin) {
this.origin = origin;
}
async get(path, params) {
const response = await axios_1.default.get(this.origin + path, {
params,
});
return this.format(response);
}
async post(path, data) {
const response = await axios_1.default.post(this.origin + path, data);
return this.format(response);
}
async del(path, params) {
const response = await axios_1.default.delete(this.origin + path, {
params,
});
return this.format(response);
}
async format(response) {
if (response.status != 200) {
throw new Error('internal server error');
}
const json = response.data;
if (json.status !== kauth_1.KauthStatus.OK) {
throw new Error(json.message);
}
return camelcase_keys_1.default(json.body, {
deep: true,
});
}
}

@@ -5,5 +5,5 @@ import { KauthConfig } from "../config/config";

export declare class KflowApi {
private kflowUtil;
constructor({ kflowOrigin }: KauthConfig);
startProcessInstanceByKey(userId: string, body: KflowCreateProcessRequest): Promise<string>;
private marmotUtil;
constructor({ kflowOrigin, marmotAccessKeyId, marmotAccessKeySecret, kflowServiceName, kflowServicePort }: KauthConfig);
startProcessInstanceByKey(body: KflowCreateProcessRequest): Promise<string>;
completeTaskService(userId: string, body: KflowCompleteTaskServiceRequest): Promise<void>;

@@ -10,0 +10,0 @@ deleteProcessInstance(userId: string, instanceId: string, reason: string): Promise<void>;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.KflowApi = void 0;
const axios_1 = __importDefault(require("axios"));
const marmot_1 = require("./tool/marmot");
const http_1 = require("../constant/http");
const kflow_1 = require("./response/kflow");
class KflowApi {
constructor({ kflowOrigin }) {
this.kflowUtil = new KflowUtil(kflowOrigin || '');
constructor({ kflowOrigin, marmotAccessKeyId, marmotAccessKeySecret, kflowServiceName, kflowServicePort }) {
this.marmotUtil = new marmot_1.MarmotUtil(kflowOrigin, marmotAccessKeyId, marmotAccessKeySecret, kflowServiceName, kflowServicePort);
}
async startProcessInstanceByKey(userId, body) {
return this.kflowUtil.post(userId, http_1.ProcessUri, body);
async startProcessInstanceByKey(body) {
return this.marmotUtil.post(http_1.ProcessUri, body);
}
async completeTaskService(userId, body) {
return this.kflowUtil.post(userId, http_1.ServiceTaskUri, body);
return this.marmotUtil.post(http_1.ServiceTaskUri, body);
}

@@ -25,49 +21,8 @@ async deleteProcessInstance(userId, instanceId, reason) {

};
return this.kflowUtil.del(userId, http_1.ProcessUri, params);
return this.marmotUtil.del(http_1.ProcessUri, params);
}
async getStateMachineAndNodes(userId, instanceId) {
return this.kflowUtil.get(userId, http_1.InstanceUri + instanceId);
return this.marmotUtil.get(http_1.InstanceUri + instanceId);
}
}
exports.KflowApi = KflowApi;
class KflowUtil {
constructor(origin) {
this.origin = origin;
}
async get(userId, path, params) {
const response = await axios_1.default.get(this.origin + path, {
params,
headers: {
'x-kauth-user-id': userId,
},
});
return this.format(response);
}
async post(userId, path, body) {
const response = await axios_1.default.post(this.origin + path, body, {
headers: {
'x-kauth-user-id': userId,
},
});
return this.format(response);
}
async del(userId, path, params) {
const response = await axios_1.default.delete(this.origin + path, {
params,
headers: {
'x-kauth-user-id': userId,
},
});
return this.format(response);
}
async format(response) {
if (response.status != 200) {
throw new Error('internal server error');
}
const json = response.data;
if (json.status !== kflow_1.KflowStatus.OK) {
throw new Error(json.message);
}
return json.body;
}
}

@@ -1,6 +0,7 @@

export interface KflowCreateProcessRequest {
import { MarmotOptions } from "../tool/marmot";
export interface KflowCreateProcessRequest extends MarmotOptions {
key: string;
map: any;
}
export interface KflowCompleteTaskServiceRequest {
export interface KflowCompleteTaskServiceRequest extends MarmotOptions {
instanceId: string;

@@ -7,0 +8,0 @@ assignee: string;

@@ -1,7 +0,1 @@

export declare enum KauthStatus {
OK = 0,
UnAuthenticated = 10401,
Forbidden = 10403,
InternalServerError = 10500
}
export declare enum KauthPrincipalStatus {

@@ -11,7 +5,2 @@ Normal = 0,

}
export interface BasicReponse<T> {
status: KauthStatus;
body: T;
message: string;
}
export interface KauthPrimaryPrincipal {

@@ -18,0 +7,0 @@ id: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KauthPrincipalStatus = exports.KauthStatus = void 0;
var KauthStatus;
(function (KauthStatus) {
KauthStatus[KauthStatus["OK"] = 0] = "OK";
KauthStatus[KauthStatus["UnAuthenticated"] = 10401] = "UnAuthenticated";
KauthStatus[KauthStatus["Forbidden"] = 10403] = "Forbidden";
KauthStatus[KauthStatus["InternalServerError"] = 10500] = "InternalServerError";
})(KauthStatus = exports.KauthStatus || (exports.KauthStatus = {}));
exports.KauthPrincipalStatus = void 0;
var KauthPrincipalStatus;

@@ -12,0 +5,0 @@ (function (KauthPrincipalStatus) {

@@ -1,10 +0,1 @@

export declare enum KflowStatus {
OK = 0,
InternalServerError = 10500
}
export interface BasicReponse<T> {
status: KflowStatus;
body: T;
message: string;
}
export interface InternalState {

@@ -11,0 +2,0 @@ index: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KflowStatus = void 0;
var KflowStatus;
(function (KflowStatus) {
KflowStatus[KflowStatus["OK"] = 0] = "OK";
KflowStatus[KflowStatus["InternalServerError"] = 10500] = "InternalServerError";
})(KflowStatus = exports.KflowStatus || (exports.KflowStatus = {}));
{
"name": "kauth-sdk-node",
"version": "0.0.10",
"version": "0.0.11",
"description": "",

@@ -11,3 +11,3 @@ "main": "dist/index.js",

"scripts": {
"clean": "rimraf dist coverage",
"clean": "rm -rf dist coverage",
"build": "npm run clean && tsc",

@@ -38,3 +38,2 @@ "type-check": "tsc --noEmit",

"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"sinon": "^9.0.2",

@@ -41,0 +40,0 @@ "ts-node": "^8.10.2",

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