@@ -13,7 +13,7 @@ use identity_iota::{
13
13
iota:: { IotaDID , IotaDocument , IotaDocumentMetadata } ,
14
14
resolver:: { ErrorCause , Resolver } ,
15
15
} ;
16
- use iota_sdk:: client:: Client ;
16
+ use iota_sdk:: client:: { node_manager :: node :: NodeAuth , Client } ;
17
17
use serde:: { Deserialize , Serialize } ;
18
18
use std:: { env, sync:: Arc } ;
19
19
use tokio:: net:: TcpListener ;
@@ -106,7 +106,7 @@ async fn resolver() -> anyhow::Result<SharedResolver> {
106
106
107
107
if let Ok ( iota_endpoint) = env:: var ( IOTA_NODE_ENDPOINT ) {
108
108
let client: Client = Client :: builder ( )
109
- . with_primary_node ( & iota_endpoint, None )
109
+ . with_primary_node ( & iota_endpoint, auth_token ( "IOTA_NODE" ) )
110
110
. context ( "unable to create a client for the provided endpoint" ) ?
111
111
. finish ( )
112
112
. await
@@ -117,7 +117,7 @@ async fn resolver() -> anyhow::Result<SharedResolver> {
117
117
118
118
if let Ok ( iota_endpoint) = env:: var ( SMR_NODE_ENDPOINT ) {
119
119
let client: Client = Client :: builder ( )
120
- . with_primary_node ( & iota_endpoint, None )
120
+ . with_primary_node ( & iota_endpoint, auth_token ( "IOTA_SMR_NODE" ) )
121
121
. context ( "unable to create a client for the provided endpoint" ) ?
122
122
. finish ( )
123
123
. await
@@ -130,7 +130,7 @@ async fn resolver() -> anyhow::Result<SharedResolver> {
130
130
let custom_endpoint = env:: var ( IOTA_CUSTOM_NODE_ENDPOINT ) . ok ( ) ;
131
131
if let ( Some ( custom_hrp) , Some ( custom_endpoint) ) = ( custom_hrp, custom_endpoint) {
132
132
let client: Client = Client :: builder ( )
133
- . with_primary_node ( & custom_endpoint, None )
133
+ . with_primary_node ( & custom_endpoint, auth_token ( "IOTA_CUSTOM_NODE" ) )
134
134
. expect ( "unable to create a client for the provided endpoint" )
135
135
. finish ( )
136
136
. await
@@ -151,3 +151,11 @@ async fn resolver() -> anyhow::Result<SharedResolver> {
151
151
152
152
Ok ( Arc :: new ( resolver) )
153
153
}
154
+
155
+ fn auth_token ( node_name : & str ) -> Option < NodeAuth > {
156
+ let var_name = format ! ( "{node_name}_AUTH_TOKEN" ) ;
157
+ std:: env:: var ( var_name) . ok ( ) . map ( |auth| NodeAuth {
158
+ jwt : Some ( auth) ,
159
+ basic_auth_name_pwd : None ,
160
+ } )
161
+ }
0 commit comments