Skip to content

Commit

Permalink
feat(api): add DeviceJWT
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Jul 18, 2024
1 parent 27964ef commit 3f03ada
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ const baseURL = `https://github.com/hello-nrfcloud/proto-map`
export const Context = {
device: new URL(`${baseURL}/device`),
devices: new URL(`${baseURL}/devices`),
deviceJWT: new URL(`${baseURL}/device-jwt`),
shareDevice: {
request: new URL(`${baseURL}/share-device-request`),
ownershipConfirmed: new URL(`${baseURL}/share-device-ownership-confirmed`),
},
named: (name: string): URL => new URL(`${baseURL}/${name}`),
apiHealth: new URL(`${baseURL}/api/health`),
}
22 changes: 22 additions & 0 deletions api/DeviceJWT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Type } from '@sinclair/typebox'
import { DeviceId, PublicDeviceId } from './DeviceId.js'
import { Model } from './Devices.js'
import { Context } from './Context.js'

export const DeviceJWT = Type.Object(
{
'@context': Type.Literal(Context.deviceJWT.toString()),
id: PublicDeviceId,
deviceId: DeviceId,
model: Model,
jwt: Type.String({
title: 'JWT',
minLength: 5,
description: 'The JWT for a publicly shared device.',
examples: [
'eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCIsImtpZCI6ImEyMGM0NzZkLTVlZjUtNDE1NS1iODllLTdkZWRiMzJjODVhNCJ9.eyJpZCI6ImQ0OThkNzZhLWQ0ZjktNGQ4YS1iMTYwLTNlODA5NGMzOGNmYSIsImRldmljZUlkIjoidGFsbXVkaWMtb3ZlcnJhdGUtcGVuc2l2ZWQiLCJtb2RlbCI6InRoaW5neTkxeCIsImlhdCI6MTcyMTI4NjA1NywiZXhwIjoxNzIxMjg5NjU3LCJhdWQiOiJoZWxsby5ucmZjbG91ZC5jb20ifQ.Afn2Vj7V4boatn3Dwf4yZCTh09lTpfAEfsaX2uTZv0z2EvcWVH3CeVVsEmvCtDb8mnpvxJcj88-l9PlJqShKzZF5AShz6Ps0Igkzm0PueGjK-nq12I8DTgraT6fdSB3v5ALzLC9ozwyuPN7kJDLMHMHkO3j24sveBvFLg2BLsharSRBN',
],
}),
},
{ title: 'DeviceJWT', description: 'The JWT for a publicly shared device.' },
)
1 change: 1 addition & 0 deletions api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './Devices.js'
export * from './ShareDeviceOwnershipConfirmed.js'
export * from './ShareDeviceRequest.js'
export * from './LwM2M.js'
export * from './DeviceJWT.js'

0 comments on commit 3f03ada

Please sign in to comment.