/
wot.js
148 lines (123 loc) · 4.24 KB
/
wot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Generated by IcedCoffeeScript 108.0.12
(function() {
var Base, React, Vouch, constants, json_stringify_sorted, make_esc, pgp_utils, schema, streq_secure, unix_time, _ref,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Base = require('./base').Base;
constants = require('./constants').constants;
make_esc = require('iced-error').make_esc;
pgp_utils = require('pgp-utils');
_ref = pgp_utils.util, json_stringify_sorted = _ref.json_stringify_sorted, unix_time = _ref.unix_time, streq_secure = _ref.streq_secure;
schema = require('./schema3');
exports.Vouch = Vouch = (function(_super) {
__extends(Vouch, _super);
function Vouch(obj) {
this.wot = obj.wot;
Vouch.__super__.constructor.call(this, obj);
}
Vouch.prototype._v_stub_paths = function() {
return ["body.wot_vouch"];
};
Vouch.prototype._type = function() {
return constants.sig_types.wot.vouch;
};
Vouch.prototype._type_v2 = function(revoke_flag) {
if ((this.revoke != null) || revoke_flag) {
return constants.sig_types_v2.wot.vouch_with_revoke;
} else {
return constants.sig_types_v2.wot.vouch;
}
};
Vouch.prototype._v_check = function(_arg, cb) {
var err, json, obj, proof_schema, schm;
json = _arg.json;
obj = json.body.wot_vouch;
if (obj == null) {
return cb(null);
}
proof_schema = schema.or([
schema.dict({
proof_type: schema.int(),
name: schema.string(),
username: schema.string()
}), schema.dict({
proof_type: schema.int(),
protocol: schema.string(),
hostname: schema.string()
}), schema.dict({
proof_type: schema.int(),
protocol: schema.string(),
domain: schema.string()
})
]);
schm = schema.dict({
user: schema.dict({
username: schema.string(),
uid: schema.uid().convert(),
eldest: schema.dict({
seqno: schema.int(),
kid: schema.kid().convert()
}),
seq_tail: schema.dict({
seqno: schema.int(),
sig_id: schema.sig_id().convert(),
payload_hash: schema.hash().convert()
})
}),
confidence: schema.dict({
username_verified_via: schema.string_enum(["in_person", "proofs", "video", "audio", "other_chat", "familiar", "other"]).optional(),
proofs: schema.array(proof_schema).optional(),
other: schema.string({
max_length: 90
}).optional()
}),
failing_proofs: schema.array(proof_schema).optional(),
vouch_text: schema.string({
max_length: 700
})
});
err = schm.check(obj);
return cb(err);
};
Vouch.prototype._v_customize_json = function(ret) {
var t, _ref1;
if ((t = (_ref1 = this.wot) != null ? _ref1.vouch : void 0) != null) {
return ret.body.wot_vouch = t;
}
};
return Vouch;
})(Base);
exports.React = React = (function(_super) {
__extends(React, _super);
function React(obj) {
this.wot = obj.wot;
React.__super__.constructor.call(this, obj);
}
React.prototype._v_stub_paths = function() {
return ["body.wot_react"];
};
React.prototype._type = function() {
return constants.sig_types.wot.react;
};
React.prototype._type_v2 = function(revoke_flag) {
return constants.sig_types_v2.wot.react;
};
React.prototype._v_check = function(_arg, cb) {
var json, obj, schm;
json = _arg.json;
obj = json.body.wot_react;
schm = schema.dict({
sig_id: schema.sig_id().convert(),
reaction: schema.string_enum(["accept", "reject"])
});
return cb(schm.check(obj));
};
React.prototype._v_customize_json = function(ret) {
var t;
if ((t = this.wot.react) != null) {
return ret.body.wot_react = t;
}
};
return React;
})(Base);
}).call(this);