Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of the orchestrator API and authentication based on payload signature #221

Merged
merged 29 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b5161d6
improve configuration management
antho1404 Apr 5, 2020
eeb4d46
authorize cli for the engine's admin api
antho1404 Apr 5, 2020
c95ff06
update registration of the service
antho1404 Apr 6, 2020
468dc38
update changelog
antho1404 Apr 7, 2020
4156090
fix sign return params in transaction
antho1404 Apr 7, 2020
b14dc3d
create orchestrator lib
antho1404 Apr 7, 2020
062910b
use signature instead of private key
antho1404 Apr 7, 2020
136a88a
use @mesg/orchestrator library for @mesg/service
antho1404 Apr 7, 2020
2e1f7be
use direct proto messages for orchestrator
antho1404 Apr 7, 2020
739c0fe
update service from orchestrator
antho1404 Apr 7, 2020
527d46d
fix types
antho1404 Apr 8, 2020
b044d39
normalize payload for the orchestrator
antho1404 Apr 8, 2020
dd35c70
add token to the user
antho1404 Apr 8, 2020
5c8f494
use orchestrator for streams in the cli
antho1404 Apr 8, 2020
ed306cd
update service based on the orchestrator type
antho1404 Apr 8, 2020
2ba6b2e
calculate runner hash based on engine address
antho1404 Apr 8, 2020
cb3ac89
update runner to delete when stop based on the orchestrator
antho1404 Apr 8, 2020
1852bae
add missing proto file
antho1404 Apr 8, 2020
dca1e95
fix missing dep
antho1404 Apr 8, 2020
242b554
update fetch of proto
antho1404 Apr 8, 2020
15e0f1b
generate pub key from mnemonic for authorized clients
antho1404 Apr 8, 2020
56fe63e
add lcd struct type with convertion
antho1404 Apr 8, 2020
7146126
update execution command based on orchestrator
antho1404 Apr 8, 2020
5fa8958
cleanup
antho1404 Apr 8, 2020
0e067fe
update changelogs
antho1404 Apr 9, 2020
af80055
Apply suggestions from code review
antho1404 Apr 9, 2020
3115b76
fix pending promises
antho1404 Apr 9, 2020
2c985cc
remove api dependency in container
antho1404 Apr 9, 2020
03ad0c2
Merge branch 'master' into feature/cli-mnemonic
antho1404 Apr 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/api/src/execution-lcd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import LCDClient from './util/lcd'
import { IStruct } from './struct'

export enum Status {
Unknown = 0,
Expand All @@ -15,8 +16,8 @@ export type IExecution = {
status: Status;
instanceHash: string;
taskKey: string;
inputs?: any;
outputs?: any;
inputs?: IStruct[];
outputs?: IStruct[];
error?: (string | null);
tags?: (string[] | null);
processHash?: (string | null);
Expand All @@ -33,7 +34,7 @@ export type IExecution = {

export default class Execution extends LCDClient {

async get(hash: string): Promise<IExecution> {
async get(hash: string): Promise<IExecution> {
return (await this.query(`/execution/get/${hash}`)).result
}

Expand Down
33 changes: 5 additions & 28 deletions packages/api/src/process-lcd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as ProcessType from './typedef/process'
import LCDClient from './util/lcd'
import { IMsg } from './transaction'
import { IValueNullType, IValueStringType, IValueNumberType, IValueBoolType } from './struct'

export type IResult = {
instanceHash: string;
Expand Down Expand Up @@ -118,34 +119,10 @@ export const Predicate = {
CONTAINS: FilterPredicate.CONTAINS
}

export type IFilterValueNullType = {
type: 'mesg.types.Value_NullValue';
value: {
null?: 0
}
}

export type IFilterValueStringType = {
type: 'mesg.types.Value_StringValue';
value: {
string_value: string;
}
}

export type IFilterValueNumberType = {
type: 'mesg.types.Value_NumberValue';
value: {
number_value: number;
}
}

export type IFilterValueBoolType = {
type: 'mesg.types.Value_BoolValue';
value: {
bool_value: boolean;
}
}

export type IFilterValueNullType = IValueNullType
export type IFilterValueStringType = IValueStringType
export type IFilterValueNumberType = IValueNumberType
export type IFilterValueBoolType = IValueBoolType

export type IFilterCondition = {
ref: {
Expand Down
104 changes: 104 additions & 0 deletions packages/api/src/struct.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
export type IValueNullType = {
type: 'mesg.types.Value_NullValue';
value: {
null?: 0
}
}

export type IValueStringType = {
type: 'mesg.types.Value_StringValue';
value: {
string_value: string;
}
}

export type IValueNumberType = {
type: 'mesg.types.Value_NumberValue';
value: {
number_value: number;
}
}

export type IValueBoolType = {
type: 'mesg.types.Value_BoolValue';
value: {
bool_value: boolean;
}
}

export type IValueListType = {
type: "mesg.types.Value_ListValue",
value: {
list_value: {
values: IValue[]
}
}
}

export type IValueMapType = {
type: "mesg.types.Value_StructValue",
value: {
struct_value: IStruct[]
}
}

export type IValue = {
Kind: IValueBoolType | IValueNumberType | IValueStringType | IValueNullType | IValueListType | IValueMapType
}

export type IStruct = {
Key: string
Value: IValue
}

export const toValue = (value: any): IValueBoolType | IValueNumberType | IValueStringType | IValueNullType | IValueListType | IValueMapType => {
switch (Object.prototype.toString.call(value)) {
case '[object Null]':
case '[object Undefined]':
return {
type: "mesg.types.Value_NullValue", value: {}
} as IValueNullType
case '[object Object]':
return {
type: "mesg.types.Value_StructValue",
value: {
struct_value: toStruct(value)
}
} as IValueMapType
case '[object Array]':
return {
type: "mesg.types.Value_ListValue",
value: {
list_value: {
values: value.map((x: any) => ({ Kind: toValue(x) }))
}
}
} as IValueListType
case '[object Number]':
return {
type: "mesg.types.Value_NumberValue", value: { number_value: value }
} as IValueNumberType
case '[object Boolean]':
return {
type: "mesg.types.Value_BoolValue", value: { bool_value: value }
} as IValueBoolType
case '[object String]':
return {
type: "mesg.types.Value_StringValue", value: { string_value: value }
} as IValueStringType
default:
throw new Error('not supported')
}
}

export const toStruct = (object: { [key: string]: any }): IStruct[] => {
return Object.keys(object).reduce((prev, x) => [
...prev,
{
Key: x,
Value: {
Kind: toValue(object[x])
}
}
], [] as IStruct[])
}
2 changes: 1 addition & 1 deletion packages/api/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class Transaction {
private _stdTx: IStdTx
public raw: ITx

static sign(message: string, ecpairPriv: Buffer): any {
static sign(message: string, ecpairPriv: Buffer) {
NicolasMahe marked this conversation as resolved.
Show resolved Hide resolved
const hash = createHash('sha256')
.update(message)
.digest('hex')
Expand Down
Loading