Module imports function '__wbg_now_2e07eedfb4ac9dbe' from '__wbindgen_placeholder__' that is not exported by the runtime

Hi, @Severin.
Nice to meet you.

I am a new developer fascinated by internet computer.
I’m implementing json-web-token(JWT) in Canister using Rust.

The project compiled successfully, but this error occurred during canister deployment.

Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed while trying to install all canisters.
    Failed to install wasm module to canister 'local_user_index'.
      Failed during wasm installation call: The replica returned a replica error: Replica Error: reject code CanisterError, reject message Wasm module of canister bkyz2-fmaaa-aaaaa-qaaaq-cai is not valid: Wasm module has an invalid import section. Module imports function '__wbg_now_2e07eedfb4ac9dbe' from '__wbindgen_placeholder__' that is not exported by the runtime., error code None

dependencies

jwt-simple = "0.11.6"
getrandom = {version = "0.2.10", features = ["custom"]}

code section

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct JWT {
    pub email: String,
    pub username: String,
}

impl JWT {
    pub fn new(email: String, username: String) -> Self {
        Self {
            email,
            username,
        }
    }

    pub fn get_key_pair() -> Option<Ed25519KeyPair> {
        // --------------------------
    }
    pub fn to_string(&self) -> Option<String> {
        let key_pair = JWT::get_key_pair()?;

        // create claims valid for 1 hour
        let claims = Claims::with_custom_claims(self.clone(), Duration::from_secs(EXP_TIME));

        match key_pair.sign(claims) {
            Ok(ok) => return Some(ok),
            Err(_) => return None,
        }
    }

    pub fn from_string(token: &str) -> Option<Self> {
        let key_pair = JWT::get_key_pair()?;

        // a public key can be extracted from a key pair:
        let public_key = key_pair.public_key();

        match public_key.verify_token::<Self>(&token, None) {
            Ok(ok) => Some(ok.custom),
            Err(_) => return None,
        }
    }
}
1 Like

Suggested reading:

@Wonder0729 Did you find a fix to this problem?

Hi, @iamenochchirima didn’t fix yet.
Could you help me?

Did you resolve this error, I have the same issue :smile: