38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/app_identity/internal.rb', line 38
def parse_proof!(proof)
return proof if proof.is_a?(Hash)
raise AppIdentity::Error, "proof must be a string or a map" unless proof.is_a?(String)
parts = Base64.decode64(proof).split(":", -1)
case parts.length
when 4
version, id, nonce, padlock = parts
version = validate_version(version)
AppIdentity::Versions.allowed!(version)
{version: version, id: id, nonce: nonce, padlock: padlock}
when 3
id, nonce, padlock = parts
{version: 1, id: id, nonce: nonce, padlock: padlock}
else
raise AppIdentity::Error, "proof must have 3 parts (version 1) or 4 parts (any version)"
end
end
|