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

@hydrooj/center

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hydrooj/center - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

28

handler.js

@@ -18,6 +18,4 @@ "use strict";

const server_1 = require("hydrooj/dist/service/server");
const error_1 = require("hydrooj/dist/error");
const crypto_1 = __importDefault(require("crypto"));
const js_yaml_1 = __importDefault(require("js-yaml"));
const superagent_1 = __importDefault(require("superagent"));
function decrypt(encrypted) {

@@ -68,30 +66,4 @@ if (!encrypted)

], DataReportHandler.prototype, "post", null);
class ProxySendRequestHandler extends server_1.Handler {
async post(_d, endpoint, domainId, url, tokenId, expire) {
let res = await superagent_1.default.post(`${url}d/${domainId}/problem/send`)
.send({ operation: 'info', token: tokenId })
.catch((e) => e);
if (res instanceof Error)
throw new error_1.RemoteOnlineJudgeError(`[Post Target/Send/Info] ${res.message}`);
res = await superagent_1.default.post(`${endpoint}/problem/receive`).send({
operation: 'request', url: `${url}d/${domainId}/problem/send`, tokenId, expire,
}).catch((e) => e);
if (res instanceof Error)
throw new error_1.RemoteOnlineJudgeError(`[Post Target/Receive/Request] ${res.message}`);
this.response.body = { code: 0 };
}
}
__decorate([
server_1.param('endpoint', server_1.Types.String),
server_1.param('domainId', server_1.Types.String),
server_1.param('url', server_1.Types.String),
server_1.param('tokenId', server_1.Types.String),
server_1.param('expire', server_1.Types.UnsignedInt),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, String, String, Number]),
__metadata("design:returntype", Promise)
], ProxySendRequestHandler.prototype, "post", null);
function apply() {
server_1.Route('data_report', '/center/report', DataReportHandler);
server_1.Route('proxy_send', '/center/send', ProxySendRequestHandler);
}

@@ -98,0 +70,0 @@ exports.apply = apply;

24

handler.ts
import db from 'hydrooj/dist/service/db';
import {
Handler, param, post, Route, Types,
Handler, post, Route, Types,
} from 'hydrooj/dist/service/server';
import { RemoteOnlineJudgeError } from 'hydrooj/dist/error';
import crypto from 'crypto';
import yaml from 'js-yaml';
import superagent from 'superagent';

@@ -56,26 +54,6 @@ function decrypt(encrypted: string) {

class ProxySendRequestHandler extends Handler {
@param('endpoint', Types.String)
@param('domainId', Types.String)
@param('url', Types.String)
@param('tokenId', Types.String)
@param('expire', Types.UnsignedInt)
async post(_d: string, endpoint: string, domainId: string, url: string, tokenId: string, expire: number) {
let res = await superagent.post(`${url}d/${domainId}/problem/send`)
.send({ operation: 'info', token: tokenId })
.catch((e) => e);
if (res instanceof Error) throw new RemoteOnlineJudgeError(`[Post Target/Send/Info] ${res.message}`);
res = await superagent.post(`${endpoint}/problem/receive`).send({
operation: 'request', url: `${url}d/${domainId}/problem/send`, tokenId, expire,
}).catch((e) => e);
if (res instanceof Error) throw new RemoteOnlineJudgeError(`[Post Target/Receive/Request] ${res.message}`);
this.response.body = { code: 0 };
}
}
export function apply() {
Route('data_report', '/center/report', DataReportHandler);
Route('proxy_send', '/center/send', ProxySendRequestHandler);
}
global.Hydro.handler.center = apply;

2

package.json
{
"name": "@hydrooj/center",
"version": "0.0.3",
"version": "0.0.4",
"main": "package.json",

@@ -5,0 +5,0 @@ "repository": "https://github.com/hydro-dev/Hydro.git",

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