@@ -258,17 +258,17 @@ export class AssetInterfaceDescriptionUtil {
258258 return "" ; // TODO what is the right value if information cannot be found
259259 }
260260
261- private getSecurityDefinitionsFromEndpointMetadata ( endpointMetadata ?: Record < string , unknown > ) : {
262- [ k : string ] : SecurityScheme ;
263- } {
261+ private updateRootMetadata ( thing : Thing , endpointMetadata ?: Record < string , unknown > ) {
264262 const securityDefinitions : {
265263 [ k : string ] : SecurityScheme ;
266264 } = { } ;
265+ const security : string [ ] = [ ] ;
267266
268267 if ( endpointMetadata ?. value instanceof Array ) {
269268 for ( const v of endpointMetadata . value ) {
270- if ( v . idShort === "securityDefinitions" ) {
271- // const securitySchemes: Array<SecurityScheme> = [];
269+ if ( v . idShort === "base" ) {
270+ thing . base = v . value ;
271+ } else if ( v . idShort === "securityDefinitions" ) {
272272 if ( v . value instanceof Array ) {
273273 for ( const securityDefinitionsValues of v . value ) {
274274 if ( securityDefinitionsValues . idShort != null ) {
@@ -286,19 +286,7 @@ export class AssetInterfaceDescriptionUtil {
286286 }
287287 }
288288 }
289- }
290- }
291- }
292- return securityDefinitions ;
293- }
294-
295- private getSecurityFromEndpointMetadata (
296- endpointMetadata ?: Record < string , unknown >
297- ) : string | [ string , ...string [ ] ] {
298- const security : string [ ] = [ ] ;
299- if ( endpointMetadata ?. value instanceof Array ) {
300- for ( const v of endpointMetadata . value ) {
301- if ( v . idShort === "security" ) {
289+ } else if ( v . idShort === "security" ) {
302290 if ( v . value instanceof Array ) {
303291 for ( const securityValue of v . value ) {
304292 if ( securityValue . value != null ) {
@@ -310,7 +298,8 @@ export class AssetInterfaceDescriptionUtil {
310298 }
311299 }
312300
313- return security as string | [ string , ...string [ ] ] ;
301+ thing . securityDefinitions = securityDefinitions ;
302+ thing . security = security as string | [ string , ...string [ ] ] ;
314303 }
315304
316305 private createInteractionForm ( vi : AASInteraction , addSecurity : boolean ) : TD . Form {
@@ -568,8 +557,8 @@ export class AssetInterfaceDescriptionUtil {
568557 const secNamesForEndpointMetadata = new Map < Record < string , unknown > , string [ ] > ( ) ;
569558 for ( const endpointMetadata of smInformation . endpointMetadataArray ) {
570559 const secNames : Array < string > = [ ] ;
571- thing . securityDefinitions = this . getSecurityDefinitionsFromEndpointMetadata ( endpointMetadata ) ;
572- thing . security = this . getSecurityFromEndpointMetadata ( endpointMetadata ) ;
560+ // update base, securityDefinitions, security, ...
561+ this . updateRootMetadata ( thing , endpointMetadata ) ;
573562 // iterate over securitySchemes
574563 // eslint-disable-next-line unused-imports/no-unused-vars
575564 for ( const [ key , value ] of Object . entries ( thing . securityDefinitions ) ) {
@@ -925,7 +914,20 @@ export class AssetInterfaceDescriptionUtil {
925914
926915 // walk over string values like: "href", "contentType", "htv:methodName", ...
927916 for ( let formTerm in formElementPicked ) {
928- const formValue = formElementPicked [ formTerm ] ;
917+ let formValue = formElementPicked [ formTerm ] ;
918+
919+ // Note: node-wot uses absolute URIs *almost* everywhere but we want to use "base" in AID
920+ // --> try to create relative href's as much as possible
921+ if (
922+ formTerm === "href" &&
923+ td . base != null &&
924+ td . base . length > 0 &&
925+ typeof formValue === "string" &&
926+ formValue . startsWith ( td . base )
927+ ) {
928+ formValue = formValue . substring ( td . base . length ) ;
929+ console . log ( "dsadsa: " + formValue ) ;
930+ }
929931
930932 // Note: AID does not allow idShort to contain values with colon (i.e., ":") --> "_" used instead
931933 // TODO are there more characters we need to deal with?
0 commit comments