Skip to content

Commit b79d1ee

Browse files
authored
Merge pull request #85 from ExpressApp/feature/ki/express-disk-auth
CCS-106776 add getAuthCode method for Disk
2 parents 3708406 + 37c5489 commit b79d1ee

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@expressms/smartapp-sdk",
3-
"version": "1.13.0-alpha.9",
3+
"version": "1.13.0-alpha.10",
44
"description": "Smartapp SDK",
55
"main": "build/main/index.js",
66
"typings": "build/main/index.d.ts",

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from './lib/notification'
77
export * from './lib/routing'
88
export * from './lib/proxy'
99
export * from './lib/devices'
10-
1110
import Bridge from '@expressms/smartapp-bridge'
12-
export { Bridge }
11+
import * as ExpressDisk from './lib/express-disk'
12+
13+
export { Bridge, ExpressDisk }

src/lib/express-disk/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import bridge from '@expressms/smartapp-bridge'
2+
import { ERROR_CODES, METHODS } from '../../types'
3+
import { GetAuthCodeResponse } from '../../types/express-disk'
4+
5+
/**
6+
* Get auth code for eXpress Disk
7+
* @returns Promise that'll be fullfilled with `payload.auth` on success, otherwise rejected with reason
8+
*/
9+
export const getAuthCode = (): Promise<GetAuthCodeResponse> => {
10+
if (!bridge) return Promise.reject(ERROR_CODES.NO_BRIDGE)
11+
12+
return bridge
13+
.sendClientEvent({
14+
method: METHODS.GET_EXPRESS_DISK_AUTH_CODE,
15+
params: {},
16+
hide_recv_event_data: true,
17+
})
18+
.then(event => event as GetAuthCodeResponse)
19+
}

src/types/bridge.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export enum METHODS {
5555
WRITE_NFC_TAG = 'write_nfc_tag',
5656
ALLOW_IOS_SWIPE_NAVIGATION = 'allow_ios_swipe_navigation',
5757
HIDE_RECV_DATA = 'hide_recv_data',
58+
GET_EXPRESS_DISK_AUTH_CODE = 'get_express_disk_auth_code',
5859
}
5960

6061
export enum STATUS {

src/types/express-disk.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { EmitterEventPayload } from '@expressms/smartapp-bridge/build/main/types/eventEmitter'
2+
import { STATUS } from './bridge'
3+
4+
export interface GetAuthCodeResponse extends Omit<EmitterEventPayload, 'payload'> {
5+
payload: {
6+
status: STATUS
7+
errorCode?: string | null
8+
auth: {
9+
diskHost: string
10+
code: string
11+
codeChallenge: null | string
12+
codeChallengeMethod: string
13+
expiresIn: number
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)