Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@expressms/smartapp-sdk",
"version": "1.13.0-alpha.9",
"version": "1.13.0-alpha.10",
"description": "Smartapp SDK",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './lib/notification'
export * from './lib/routing'
export * from './lib/proxy'
export * from './lib/devices'

import Bridge from '@expressms/smartapp-bridge'
export { Bridge }
import * as ExpressDisk from './lib/express-disk'

export { Bridge, ExpressDisk }
19 changes: 19 additions & 0 deletions src/lib/express-disk/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import bridge from '@expressms/smartapp-bridge'
import { ERROR_CODES, METHODS } from '../../types'
import { GetAuthCodeResponse } from '../../types/express-disk'

/**
* Get auth code for eXpress Disk
* @returns Promise that'll be fullfilled with `payload.auth` on success, otherwise rejected with reason
*/
export const getAuthCode = (): Promise<GetAuthCodeResponse> => {
if (!bridge) return Promise.reject(ERROR_CODES.NO_BRIDGE)

return bridge
.sendClientEvent({
method: METHODS.GET_EXPRESS_DISK_AUTH_CODE,
params: {},
hide_recv_event_data: true,
})
.then(event => event as GetAuthCodeResponse)
}
1 change: 1 addition & 0 deletions src/types/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export enum METHODS {
WRITE_NFC_TAG = 'write_nfc_tag',
ALLOW_IOS_SWIPE_NAVIGATION = 'allow_ios_swipe_navigation',
HIDE_RECV_DATA = 'hide_recv_data',
GET_EXPRESS_DISK_AUTH_CODE = 'get_express_disk_auth_code',
}

export enum STATUS {
Expand Down
16 changes: 16 additions & 0 deletions src/types/express-disk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { EmitterEventPayload } from '@expressms/smartapp-bridge/build/main/types/eventEmitter'
import { STATUS } from './bridge'

export interface GetAuthCodeResponse extends Omit<EmitterEventPayload, 'payload'> {
payload: {
status: STATUS
errorCode?: string | null
auth: {
diskHost: string
code: string
codeChallenge: null | string
codeChallengeMethod: string
expiresIn: number
}
}
}