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

chore(workflow): action to create pr in rnj #130

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
23 changes: 23 additions & 0 deletions .github/workflows/create-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Creating PR in "react-native-jolocom" repo'
on:
push:
branches:
- master

jobs:
pull-request:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Create pull request
uses: SBub/[email protected]

env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every devs must have such key with all exposed rights to pass this job? can it be impersonated as well? for example with jolocom dev acc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the API_TOKEN_GITHUB is a secret of the jolocom-sdk the action reads it from there

with:
destination_repo: 'jolocom/react-native-jolocom'
destination_base_branch: 'master'
user_name: 'SBub'
user_email: '[email protected]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this must be impersonated somehow...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100%, i.e. we have jolocom-dev user that can serve such a purpose

2 changes: 2 additions & 0 deletions src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ export class Agent {
// JWTs
await interxn.processInteractionToken(token)
await this.storage.store.interactionToken(token)
} else if (interxn.lastMessage.encode() === jwt) {
this.interactionManager.emit('interactionResumed', interxn)
}

return interxn
Expand Down
1 change: 1 addition & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum ErrorCode {
SaveExternalCredentialFailed = 'SaveExtCred',
SaveCredentialMetadataFailed = 'SaveCredMetadata',
TransportNotSupported = 'UnsuportedTransport',
TransportSubscriptionNotSuported = 'TransportSubscriptionNotSuported',

TokenExpired = 'TokenExpired',
InvalidSignature = 'InvalidSignature',
Expand Down
1 change: 1 addition & 0 deletions src/interactionManager/interactionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ flows.forEach((f) => {
export interface InteractionEvents {
interactionCreated: (interxn: Interaction) => void
interactionUpdated: (interxn: Interaction) => void
interactionResumed: (interxn: Interaction) => void
}

/**
Expand Down
34 changes: 24 additions & 10 deletions src/transports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { SDKError, ErrorCode } from './errors'
import { HTTPTransport } from './http'
import { TransportHandler, TransportDesc, TransportMessageHandler, TransportAPI } from './types'
import {
TransportHandler,
TransportDesc,
TransportMessageHandler,
TransportAPI,
} from './types'
import { WebSocketTransport } from './websocket'

export class Transportable {
Expand All @@ -18,7 +23,6 @@ export class Transportable {
set transportAPI(api: TransportAPI) {
this._transportAPI = api
}

}

export class TransportKeeper {
Expand All @@ -36,10 +40,22 @@ export class TransportKeeper {
}
}

public register(
typeName: string,
handler: TransportHandler
) {
private getTransportHandler(typeName: string) {
const transportHandler = this._transportHandlers[typeName]
if (!transportHandler) throw new SDKError(ErrorCode.TransportNotSupported)

return transportHandler
}

public subscribe(typeName: string, onMessage: TransportMessageHandler) {
const transportHandler = this.getTransportHandler(typeName)
if (!transportHandler.subscribe)
throw new SDKError(ErrorCode.TransportSubscriptionNotSuported)

transportHandler.subscribe(onMessage)
}

public register(typeName: string, handler: TransportHandler) {
this._transportHandlers[typeName] = handler
}

Expand All @@ -49,11 +65,9 @@ export class TransportKeeper {
*/
public async start(
transport: TransportDesc,
onMessage?: TransportMessageHandler
onMessage?: TransportMessageHandler,
): Promise<TransportAPI> {
const transportHandler = this._transportHandlers[transport.type]
if (!transportHandler) throw new SDKError(ErrorCode.TransportNotSupported)

const transportHandler = this.getTransportHandler(transport.type)
const transportAPI = transportHandler.start(transport, onMessage)
transportAPI.desc = transport
return transportAPI
Expand Down
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ export interface TransportDesc {
/**
* @category Transports
*/
export type TransportMessageHandler = (msg: string) => Promise<void>
export type TransportMessageHandler = (
msg: string,
error?: Error,
) => Promise<void>

/**
* @category Transports
*/
export interface TransportHandler {
configure?(...args: any[]): void
subscribe?(onMessage: TransportMessageHandler): void
start(d: TransportDesc, cb?: TransportMessageHandler): TransportAPI
}

Expand Down