@@ -19,6 +19,11 @@ import { metricsForComponent } from '@hello.nrfcloud.com/lambda-helpers/metrics'
1919import { MetricUnit } from '@aws-lambda-powertools/metrics'
2020import { NRF_CLOUD_ACCOUNT } from '../settings/account.js'
2121import { addVersionHeader } from '@hello.nrfcloud.com/lambda-helpers/addVersionHeader'
22+ import {
23+ Context ,
24+ type DeviceCredentials ,
25+ } from '@hello.nrfcloud.com/proto-map/api'
26+ import type { Static } from '@sinclair/typebox'
2227
2328const {
2429 backendStackName,
@@ -103,14 +108,15 @@ const h = async (
103108 ) . Payload ?. transformToString ( ) ?? '' ,
104109 )
105110
106- const registration = await client . register ( [
107- {
108- deviceId,
109- subType : 'map' ,
110- tags : [ 'map' ] ,
111- certPem : certificate ,
112- } ,
113- ] )
111+ const registrationArgs = {
112+ deviceId,
113+ subType : 'map-custom' ,
114+ tags : [ 'map-custom' ] ,
115+ certPem : certificate ,
116+ }
117+ console . debug ( `Registering` , JSON . stringify ( registrationArgs ) )
118+
119+ const registration = await client . register ( [ registrationArgs ] )
114120
115121 if ( 'error' in registration ) {
116122 console . error (
@@ -129,16 +135,21 @@ const h = async (
129135
130136 track ( 'credentialsCreated' , MetricUnit . Count , 1 )
131137
138+ const res : Static < typeof DeviceCredentials > = {
139+ '@context' : Context . deviceCredentials . toString ( ) ,
140+ id : maybePublicDevice . device . id ,
141+ deviceId,
142+ credentials : {
143+ privateKey,
144+ certificate,
145+ } ,
146+ }
147+
132148 return aResponse (
133149 200 ,
134150 {
135- '@context' : new URL (
136- 'https://github.com/hello-nrfcloud/proto-map/device-credentials' ,
137- ) ,
138- credentials : {
139- privateKey,
140- certificate,
141- } ,
151+ ...res ,
152+ '@context' : Context . deviceCredentials ,
142153 } ,
143154 0 ,
144155 {
0 commit comments