Explorer

definy.parse-rpc-authorization

description
Read the Authorization header (trimmed). none if it is not Definy-Ed25519 <account>.<time>.<sig>
type
Fn(header: String) -> Union{#none, #some(@definy.rpc-authorization-credential)}
expression
fn(header$0) =>
  let words$1 = @definy.split-words(text: $0, index: 0, current: "", acc: []);
  let parts$2 = @definy.string-split(text: @definy.string-at(items: $1, index: 1), separator: ".", index: 0, current: "", acc: []);
  let account_id$3 = @definy.string-at(items: $2, index: 0);
  let time$4 = @definy.string-at(items: $2, index: 1);
  let signature$5 = @definy.string-at(items: $2, index: 2);
  match @core.and(
      left: @core.and(
        left: @core.equal(left: @core.list-length(value: $1), right: 2),
        right: @core.equal(left: @definy.string-at(items: $1, index: 0), right: "Definy-Ed25519")
      ),
      right: @core.and(
        left: @core.equal(left: @core.list-length(value: $2), right: 3),
        right: @core.not(
          value: @core.or(
            left: @core.equal(left: $3, right: ""),
            right: @core.or(left: @core.equal(left: $4, right: ""), right: @core.equal(left: $5, right: ""))
          )
        )
      )
    ) {
    false =>
      #none,
    true =>
      match @definy.decimal-of(bytes: @core.string-to-bytes(value: $4), index: 0, acc: 0) {
        #none(_) =>
          #none,
        #some(time_seconds$6) =>
          #some({account_id: $3, time_seconds: $6, signature: $5})
      }
  }
visibility
public
definy.parse-rpc-authorization (project definy, branch release-time-compare, snapshot JJrRgQW_LZN6tN8CbYr1dN7HosqNTuIWWYx7ACbt1n0)
id: FR84_h1Ry4-urv7F9zBs0j867GfzQuMtx8EAxyTuJYI
content hash: uQPpqY4dbALphETs9HkgStC_TpsO88XaF4S1QzIGtmg