ForkbombEu / signroom

Document and data signing platform
6 stars 0 forks source link

field to set the expiry of the credential #640

Closed andrea-dintino closed 2 months ago

andrea-dintino commented 4 months ago

We need to add a field to set the expiry of the credential, in the credential issuance page that will be saved into: https://github.com/ForkbombEu/DIDroom_microservices/blob/main/credential_issuer/credential.keys.json > "expires_in": 2592000

matteo-cristino commented 3 months ago

The expire can be of two type:

This variable should be add to the custom_code/${credential_name}.keys.json file in the following way:

{
  "other_stuff": "in the keys file",
  "didroom_params": {
    "credential_expiry": {
      "expire_in": 3600,
      "expire_at": 1735603200
    }
  }
}

where only one between expire_in and expire_at should be present. Moreover the filed didroom_params (or maybe we should find a better naming for it) should be not usable by the user in the custom key file.

andrea-dintino commented 3 months ago

If the "expire_at" is hardcoded, for credentials that expire at the end of the month, a redeploy will be required every 1st day of the month.

The credential issuer should calculate when the end of the month/year is.

We could implement this in 2 parts, where initially we take care of "expire_in" and later of "expire_at"

matteo-cristino commented 3 months ago

Your idea is really good, I see just a small problem from a zencode point of view since a dictionary of the type:

{
    "credential_expiry": {
        "expire_in": 10002201,
        "expire_at": "month"
    }
}

can not be taken in input with

Given I have a 'time dictionary' named 'credential_expiry'

and taking it in input as

Given I have a 'string dictionary' named 'credential_expiry'
Then print the data

lead to a lose af information for the expire_in, indeed it return

{
   "credential_expiry": {
      "expire_at": "month",
      "expire_in": 10002200
   }
}

The things that we could do is to make expire_at and expire_in dictionaries (that will end with only one entry) such the one of them that is not defined will end up as empty dictionary, but zenroom will not given any problem on that. Like

{
   "credential_expiry": {
      "expire_at": {"when": "month"},
      "expire_in": {"when": 10002200}
   }
}

So that I just have one type for each dictionary and will loose no information.

P.S. No idea on how much it can be difficult to understand when a day/month/year ends in zencode (we would need for sure some new operations on time)

andrea-dintino commented 3 months ago

P.S. No idea on how much it can be difficult to understand when a day/month/year ends in zencode (we would need for sure some new operations on time)

This doesn't need to be in Zenroom, we could do a system call or write use a microservice in NodeJS

bbtgnn commented 2 months ago

Currently, in the backend, we store:

{
  "duration": {
    "days": 0,
    "months": 6,
    "years": 0
  },
  "mode": "duration"
}

or

{
  "date": 1721477901,
  "mode": "date"
}
andrea-dintino commented 2 months ago

Currently, in the backend, we store:

{
  "duration": {
    "days": 0,
    "months": 6,
    "years": 0
  },
  "mode": "duration"
}

or

{
  "date": 1721477901,
  "mode": "date"
}

@puria and @matteo-cristino you need to figure out how take the current time (epoch or Julian calendar?) and add "6 months" to that - I hope that some npm package can take an epoch, add "6 months" and return an epoch.

puria commented 2 months ago

You just add the number of seconds of you want to. Yes plenty of packages that does calculate how many seconds are from now to 6 months <3 or to next monday, etc

matteo-cristino commented 2 months ago

The expiry/date should be saved in a file in the cutom_code folder following the format of preiovus stuff we saved in custom code, something like:

custom_code/${credential_name}.date.json
bbtgnn commented 2 months ago

@matteo-cristino I added

custom_code/${credential_name}.time.json