keybase-proofs 2.3.33 → 2.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/wot.iced DELETED
@@ -1,96 +0,0 @@
1
- {Base} = require './base'
2
- {constants} = require './constants'
3
- {make_esc} = require 'iced-error'
4
- pgp_utils = require('pgp-utils')
5
- {json_stringify_sorted,unix_time,streq_secure} = pgp_utils.util
6
- schema = require './schema3'
7
-
8
- #==========================================================================
9
-
10
- exports.Vouch = class Vouch extends Base
11
-
12
- constructor : (obj) ->
13
- @wot = obj.wot
14
- super obj
15
-
16
- _v_stub_paths : () -> [ "body.wot_vouch" ]
17
- _type : () -> constants.sig_types.wot.vouch
18
-
19
- _type_v2 : (revoke_flag) ->
20
- if @revoke? or revoke_flag then constants.sig_types_v2.wot.vouch_with_revoke
21
- else constants.sig_types_v2.wot.vouch
22
-
23
- _v_check : ({json}, cb) ->
24
- obj = json.body.wot_vouch
25
- if not obj? then return cb null
26
-
27
- proof_schema = schema.or([
28
- schema.dict({
29
- proof_type : schema.int(), # keybase1.ProofType
30
- name : schema.string(),
31
- username : schema.string()
32
- }),
33
- schema.dict({
34
- proof_type : schema.int(),
35
- protocol : schema.string(),
36
- hostname : schema.string()
37
- }),
38
- schema.dict({
39
- proof_type : schema.int(),
40
- protocol : schema.string(),
41
- domain : schema.string()
42
- })
43
- ])
44
-
45
- schm = schema.dict({
46
- user : schema.dict({
47
- username : schema.string()
48
- uid : schema.uid().convert()
49
- eldest : schema.dict({
50
- seqno : schema.int()
51
- kid : schema.kid().convert()
52
- })
53
- seq_tail : schema.dict({
54
- seqno : schema.int()
55
- sig_id : schema.sig_id().convert()
56
- payload_hash : schema.hash().convert()
57
- })
58
- })
59
- confidence : schema.dict({
60
- username_verified_via : schema.string_enum(["in_person", "proofs", "video", "audio", "other_chat", "familiar", "other"]).optional()
61
- proofs: schema.array(proof_schema).optional()
62
- other : schema.string({max_length: 90}).optional()
63
- })
64
- vouch_text : schema.string({max_length: 700})
65
- })
66
- err = schm.check(obj)
67
- cb err
68
-
69
- _v_customize_json : (ret) ->
70
- ret.body.wot_vouch = t if (t = @wot?.vouch)?
71
-
72
- #==========================================================================
73
-
74
- exports.React = class React extends Base
75
-
76
- constructor : (obj) ->
77
- @wot = obj.wot
78
- super obj
79
-
80
- _v_stub_paths : () -> [ "body.wot_react" ]
81
- _type : () -> constants.sig_types.wot.react
82
-
83
- _type_v2 : (revoke_flag) -> constants.sig_types_v2.wot.react
84
-
85
- _v_check : ({json}, cb) ->
86
- obj = json.body.wot_react
87
- schm = schema.dict({
88
- sig_id : schema.sig_id().convert()
89
- reaction : schema.string_enum(["accept", "reject"])
90
- })
91
- cb schm.check(obj)
92
-
93
- _v_customize_json : (ret) ->
94
- ret.body.wot_react = t if (t = @wot.react)?
95
-
96
- #==========================================================================
@@ -1,99 +0,0 @@
1
- {alloc,wot,constants} = require '../../'
2
- {EncKeyManager,KeyManager} = require('kbpgp').kb
3
- {make_esc} = require 'iced-error'
4
- {new_uid,new_km_and_sig_arg,new_sig_id,new_payload_hash} = require './util'
5
- pgp_utils = require('pgp-utils')
6
- {json_stringify_sorted} = pgp_utils.util
7
- {unpack} = require 'purepack'
8
-
9
- exports.wot_vouch_happy = (T,cb) ->
10
- esc = make_esc cb
11
- await new_km_and_sig_arg {}, esc defer me
12
- await new_km_and_sig_arg {}, esc defer them
13
- proof1 = { proof_type : 4, name : "reddit", username : "betaveros" }
14
- proof2 = { proof_type : 9, name : "mastodon.social", username : "gammaveros" }
15
- proof3 = { proof_type : 1000, protocol : "https:", hostname : "beta.veros" }
16
- proof4 = { proof_type : 1001, protocol : "dns", hostname : "beta.veros" }
17
- me.wot =
18
- vouch :
19
- user :
20
- username : them.user.local.username
21
- uid : them.user.local.uid
22
- eldest:
23
- kid : them.sig_eng.km.key.ekid().toString('hex')
24
- seqno : 1
25
- seq_tail :
26
- seqno : 20
27
- sig_id : new_sig_id()
28
- payload_hash : new_payload_hash()
29
- confidence :
30
- username_verified_via : "audio"
31
- other : "lorem ipsum"
32
- proofs : [ proof1, proof2]
33
- vouch_text : "darn rootin tootin"
34
- obj = new wot.Vouch me
35
- await obj.generate_v2 esc(defer(out)), {dohash:true}
36
- hsh = out.inner.obj.body.wot_vouch
37
- T.assert hsh?, "hash was there"
38
- T.equal hsh.length, 64, "64-byte hex string"
39
- T.assert out.expansions[hsh]?.obj?, "expansion was there"
40
-
41
- verifier = alloc out.inner.obj.body.type, me
42
- varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str, expansions : out.expansions, require_packet_hash :true}
43
- await verifier.verify_v2 varg, esc defer()
44
-
45
- me.wot =
46
- react :
47
- sig_id : new_sig_id()
48
- reaction : "accept"
49
- obj = new wot.React me
50
- await obj.generate_v2 esc(defer(out)), {dohash:true}
51
- verifier = alloc out.inner.obj.body.type, me
52
- varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str, expansions : out.expansions, require_packet_hash :true}
53
- await verifier.verify_v2 varg, esc defer()
54
-
55
- # try to revoke both with and without a replacement...
56
- me.revoke = { sig_ids : [ new_sig_id() ]}
57
- obj = new wot.Vouch me
58
- await obj.generate_v2 esc(defer(out)), {dohash:true}
59
- outer = unpack out.outer
60
- T.equal outer[4], constants.sig_types_v2.wot.vouch_with_revoke, "revoke picked up"
61
-
62
- me.wot = null
63
- obj = new wot.Vouch me
64
- await obj.generate_v2 esc(defer(out)), {dohash:true}
65
- outer = unpack out.outer
66
- T.equal outer[4], constants.sig_types_v2.wot.vouch_with_revoke, "revoke picked up"
67
-
68
- cb null
69
-
70
- exports.wot_vouch_bad = (T,cb) ->
71
- esc = make_esc cb
72
- await new_km_and_sig_arg {}, esc defer me
73
- await new_km_and_sig_arg {}, esc defer them
74
- me.wot =
75
- vouch :
76
- user :
77
- username : them.user.local.username
78
- uid : them.user.local.uid
79
- eldest:
80
- kid : them.sig_eng.km.key.ekid().toString('hex')
81
- seqno : 1
82
- seq_tail :
83
- seqno : 20
84
- sig_id : new_sig_id()
85
- payload_hash : new_payload_hash()
86
- confidence :
87
- username_verified_via : "audio"
88
- other : "this string is longer than 90 char this string is longer than 90 char this string is longer than 90 char this string is longer than 90 char"
89
- vouch_text : "darn rootin tootin"
90
- obj = new wot.Vouch me
91
- await obj.generate_v2 esc(defer(out)), {dohash:true}
92
-
93
- verifier = alloc out.inner.obj.body.type, me
94
- varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str, expansions : out.expansions, require_packet_hash :true}
95
- await verifier.verify_v2 varg, defer err
96
- T.assert err?, "got an error back"
97
- T.assert (err.message.indexOf(".confidence.other") >= 0), "found right error message"
98
-
99
- cb null
@@ -1,48 +0,0 @@
1
- C = require('iced-runtime').const
2
-
3
- exports.skip = true
4
-
5
- ipush = (e, msg) ->
6
- if msg?
7
- # Note: `e.istack = []` will be a noop if e is a primitive type
8
- # like number or string. We have to check if `e.istack` exists
9
- # before pushing so we don't crash.
10
- e.istack = [] unless e.istack?
11
- e.istack?.push msg
12
-
13
- copy_trace = (src, dst) ->
14
- dst[C.trace] = src[C.trace]
15
- dst
16
-
17
- # Error short-circuit connector with more verbose istack.
18
-
19
- # When resulting `esc` function is called, an istack entry will be constructed
20
- # based on iced trace object. This way istack will be populated by not only esc
21
- # identifiers (usually call site function names) but also filenames and line
22
- # numbers of call sites of individual esc() calls. If an error happens and
23
- # short-circuited back from deep in some test, it should be easier to identify
24
- # where exactly it originates from using the new istack.
25
-
26
- exports.make_esc = make_esc = (gcb, where) ->
27
- # Create "global where" based on make_esc() call site.
28
- where = make_esc.caller?.name unless where?
29
- return (lcb) ->
30
- # Create "local where" based on esc() call site. So every
31
- # esc(defer(...)) will have its own istack entry, if iced
32
- # trace object is available.
33
- sb = [ where ]
34
- if (tr = lcb[C.trace])
35
- sb.push "Trace:"
36
- sb.push tr[C.funcname]
37
- sb.push "(#{tr[C.filename]}:#{tr[C.lineno] + 1})"
38
- local_where = sb.filter((x) -> x).join(' ')
39
- copy_trace lcb, (err, args...) ->
40
- if not err? then lcb args...
41
- else if not gcb.__esc
42
- gcb.__esc = true
43
- ipush err, local_where
44
- gcb err
45
-
46
- exports.patch_make_esc = () ->
47
- iced_error = require 'iced-error'
48
- iced_error.make_esc = make_esc