keybase-proofs 2.3.33 → 2.3.35

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/schema3.iced CHANGED
@@ -1,8 +1,16 @@
1
1
 
2
2
  parse = require './parse3'
3
+ {has_own,get_own} = require './util'
3
4
 
4
5
  mkerr = (path, err) -> new Error "At #{path.toString()}: #{err}"
5
6
 
7
+ # __proto__ is not a data key. `{ __proto__: x }` and `obj["__proto__"] = x`
8
+ # set [[Prototype]] instead of an own property. JSON.parse may store it as an
9
+ # own key; msgpack unpack may throw. Ban it as a schema and payload key.
10
+ # constructor, toString, hasOwnProperty, etc. are allowed; has_own treats them
11
+ # as own keys.
12
+ is_reserved_key_name = (k) -> k is '__proto__'
13
+
6
14
  class Path
7
15
  constructor : (v) ->
8
16
  @_v = v or []
@@ -33,11 +41,13 @@ class Node
33
41
 
34
42
  _check_value : ({checker, path, obj}) ->
35
43
  if not obj? and checker.is_optional() then return null
36
- if not obj? then mkerr path, "value cannot be null"
44
+ if not obj? then return mkerr path, "value cannot be null"
37
45
  return checker._check { path, obj }
38
46
 
39
47
  class Dict extends Node
40
48
  constructor : ({keys}) ->
49
+ for k of keys
50
+ if is_reserved_key_name k then throw new Error "schema key name is not allowed: #{k}"
41
51
  @_keys = keys
42
52
  # do not fail if there are extra keys unknown to schema
43
53
  @_allow_extra_keys = false
@@ -48,22 +58,24 @@ class Dict extends Node
48
58
  return mkerr path, "need a dictionary"
49
59
  for k,v of obj
50
60
  new_path = path.extend(k)
51
- if not (checker = @_keys[k])?
61
+ if is_reserved_key_name k then return mkerr new_path, "key name is not allowed"
62
+ if not (checker = get_own(@_keys, k))?
52
63
  if @_allow_extra_keys then continue
53
64
  return mkerr new_path, "key is not supported"
54
65
  if (err = @_check_value { checker, path : new_path, obj : v }) then return err
55
66
  for k,v of @_keys
56
67
  new_path = path.extend(k)
57
- if not obj[k]? and not v.is_optional() then return mkerr new_path, "key is missing but is mandatory"
68
+ if not has_own(obj, k) and not v.is_optional() then return mkerr new_path, "key is missing but is mandatory"
58
69
  return null
59
70
 
60
71
  debug_localize : (obj) ->
61
72
  ret = {}
62
- for k,v of @_keys when obj[k]?
73
+ for k,v of @_keys when has_own obj, k
63
74
  ret[v._name or k] = v.debug_localize obj[k]
64
75
  ret
65
76
 
66
77
  set_key : (k,v) ->
78
+ if is_reserved_key_name k then throw new Error "schema key name is not allowed: #{k}"
67
79
  @_keys[k] = v
68
80
 
69
81
  allow_extra_keys : () ->
@@ -125,7 +137,7 @@ class Binary extends Node
125
137
 
126
138
  _convert_and_check : ({path, obj}) ->
127
139
  if @_convert and typeof(obj) is 'string'
128
- obj = Buffer.from(obj, 'hex')
140
+ obj = parse.decode_hex(obj)
129
141
  unless Buffer.isBuffer(obj) and obj.length is @_len
130
142
  return [ (mkerr path, "value needs to be buffer of length #{@_len}"), null ]
131
143
  if @_bottom_bytes?
@@ -186,10 +198,11 @@ class StringEnum extends Node
186
198
  constructor : ({values}) ->
187
199
  @_values = {}
188
200
  for v in values
201
+ if is_reserved_key_name v then throw new Error "enum value is not allowed: #{v}"
189
202
  @_values[v] = true
190
203
  _check : ({path, obj}) ->
191
204
  if typeof(obj) isnt 'string' then return mkerr path, "value must be a string"
192
- if not @_values[obj] then return mkerr path, "unknown enum value (#{obj})"
205
+ if not has_own(@_values, obj) then return mkerr path, "unknown enum value (#{obj})"
193
206
  return null
194
207
 
195
208
  class Value extends Node
@@ -218,7 +231,7 @@ class Or extends Node
218
231
  @_terms = terms
219
232
  _check : ({path, obj}) ->
220
233
  ok = false
221
- for t in @_terms when t.check(obj)
234
+ for t in @_terms when not t.check(obj)
222
235
  ok = true
223
236
  break
224
237
  if not ok then return mkerr path, "no structure worked"
@@ -148,12 +148,12 @@ exports.TwitterScraper = class TwitterScraper extends BaseScraper
148
148
 
149
149
  # twitter may not obey our matching request order
150
150
  if responses?.length
151
- dict = {}
151
+ map = new Map
152
152
  key = if ids? then "id_str" else "screen_name"
153
- dict[r[key]] = r for r in responses
153
+ map.set String(r[key]), r for r in responses
154
154
  res = []
155
155
  for identifier, i in input_list
156
- res[i] = dict[identifier] or null
156
+ res[i] = map.get(String(identifier)) or null
157
157
 
158
158
  cb err, res
159
159
 
package/src/subkey.iced CHANGED
@@ -59,10 +59,10 @@ exports.SubkeyBase = class SubkeyBase extends Base
59
59
  err = new Error "Reverse sig json mismatch: #{a} != #{b}"
60
60
  return err
61
61
 
62
- _v_check : ({json, assert_pgp_hash}, cb) ->
62
+ _v_check : ({json, assert_pgp_hash, pgp_max_length}, cb) ->
63
63
  esc = make_esc cb, "SubkeyBase::_v_check"
64
64
  await super { json }, esc defer()
65
- await @reverse_sig_check { json, new_km: @get_new_km(), assert_pgp_hash }, esc defer()
65
+ await @reverse_sig_check { json, new_km: @get_new_km(), assert_pgp_hash, pgp_max_length }, esc defer()
66
66
  cb null
67
67
 
68
68
  _get_reverse_sig : (json) ->
@@ -73,7 +73,7 @@ exports.SubkeyBase = class SubkeyBase extends Base
73
73
  # body.sibkey.reverse_sig should be the only field different between the two
74
74
  outer.body[@get_key_field()].reverse_sig = null
75
75
 
76
- reverse_sig_check : ({json, new_km, subkm, assert_pgp_hash}, cb) ->
76
+ reverse_sig_check : ({json, new_km, subkm, assert_pgp_hash, pgp_max_length}, cb) ->
77
77
 
78
78
  # For historical reasons, some people call 'new_km' 'subkm'
79
79
  new_km or= subkm
@@ -82,7 +82,9 @@ exports.SubkeyBase = class SubkeyBase extends Base
82
82
  err = null
83
83
  if (sig = @_get_reverse_sig(json))? and new_km?
84
84
  eng = new_km.make_sig_eng()
85
- await eng.unbox sig, esc(defer(raw)), { assert_pgp_hash }
85
+ # pgp_max_length only applies to PGP messages since Keybase NaCl
86
+ # does not have a compression feature.
87
+ await eng.unbox sig, esc(defer(raw)), { assert_pgp_hash, pgp_max_length }
86
88
  await a_json_parse raw, esc defer payload
87
89
  rsk = new_km.get_ekid().toString('hex')
88
90
  if (err = @_match_json json, payload)? then # noop
package/src/util.iced CHANGED
@@ -5,6 +5,17 @@ crypto = require 'crypto'
5
5
 
6
6
  #----------
7
7
 
8
+ # Native hasOwnProperty, captured so schema/input keys named
9
+ # "hasOwnProperty" cannot shadow the method. Use instead of obj[k] or
10
+ # obj.hasOwnProperty(k) — those see Object.prototype (constructor, toString, …).
11
+ _has_own = {}.constructor.prototype.hasOwnProperty
12
+ exports.has_own = has_own = (o, k) -> _has_own.call o, k
13
+ exports.get_own = get_own = (o, k) ->
14
+ if _has_own.call(o, k) then o[k]
15
+ else undefined
16
+
17
+ #----------
18
+
8
19
  exports.json_secure_compare = json_secure_compare = (a,b) ->
9
20
  [o1,o2] = (json_stringify_sorted(x) for x in [a,b])
10
21
  err = if bufeq_secure((Buffer.from o1, 'utf8'), (Buffer.from o2, 'utf8')) then null
package/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "node"
4
- notifications:
5
- slack:
6
- rooms:
7
- secure: W5hUm0MPWJ3v2VGRAq9fxgroVvqFOkwnbrxllEX3Zadf3e909fwQzm7KEUvSEd9fhsKrdBxPrphCZd1UCq5cXjCkfokKFojnbgnYPKZYgL4M7GWqiURCfIUY7r0gQCDnFzIIANacIbhT8089IkQva8QWCdfX4zVycTKOvMC0msE=
8
- branches:
9
- only:
10
- - master
package/CONTRIBUTORS.md DELETED
@@ -1,5 +0,0 @@
1
-
2
- ## Contributors
3
-
4
- * Keybase employees
5
- * @mark-adams (bitbucket)
package/Makefile DELETED
@@ -1,70 +0,0 @@
1
- ICED=node_modules/.bin/iced
2
- BUILD_STAMP=build-stamp
3
- TEST_STAMP=test-stamp
4
- UGLIFYJS=node_modules/.bin/uglifyjs
5
- WD=`pwd`
6
- BROWSERIFY=node_modules/.bin/browserify
7
-
8
- default: build
9
- all: build
10
-
11
- lib/%.js: src/%.iced
12
- $(ICED) -I browserify -c -o `dirname $@` $<
13
-
14
- $(BUILD_STAMP): \
15
- lib/alloc.js \
16
- lib/alloc3.js \
17
- lib/announcement.js \
18
- lib/auth.js \
19
- lib/base.js \
20
- lib/b64extract.js \
21
- lib/constants.js \
22
- lib/cryptocurrency.js \
23
- lib/device.js \
24
- lib/eldest.js \
25
- lib/errors.js \
26
- lib/expand.js \
27
- lib/main.js \
28
- lib/parse3.js \
29
- lib/revoke.js \
30
- lib/schema3.js \
31
- lib/sibkey.js \
32
- lib/sig3.js \
33
- lib/subkey.js \
34
- lib/per_user_key.js \
35
- lib/pgp_update.js \
36
- lib/scrapers/base.js \
37
- lib/scrapers/coinbase.js \
38
- lib/scrapers/dns.js \
39
- lib/scrapers/facebook.js \
40
- lib/scrapers/generic_web_site.js \
41
- lib/scrapers/github.js \
42
- lib/scrapers/hackernews.js \
43
- lib/scrapers/reddit.js \
44
- lib/scrapers/twitter.js \
45
- lib/scrapers/generic_social.js \
46
- lib/team.js \
47
- lib/team_hidden.js \
48
- lib/track.js \
49
- lib/wallet.js \
50
- lib/web_service.js \
51
- lib/wot.js \
52
- lib/update_passphrase_hash.js \
53
- lib/update_settings.js \
54
- lib/util.js
55
- date > $@
56
-
57
- build: $(BUILD_STAMP)
58
-
59
- test-server: $(BUILD_STAMP)
60
- $(ICED) test/run.iced
61
-
62
- test: test-server
63
-
64
- clean:
65
- rm -rf lib/* lib/scrapers/* $(BUILD_STAMP) $(TEST_STAMP)
66
-
67
- setup:
68
- npm install -d
69
-
70
- .PHONY: clean setup test test-browser
package/lib/wot.js DELETED
@@ -1,147 +0,0 @@
1
- // Generated by IcedCoffeeScript 108.0.11
2
- (function() {
3
- var Base, React, Vouch, constants, json_stringify_sorted, make_esc, pgp_utils, schema, streq_secure, unix_time, _ref,
4
- __hasProp = {}.hasOwnProperty,
5
- __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; };
6
-
7
- Base = require('./base').Base;
8
-
9
- constants = require('./constants').constants;
10
-
11
- make_esc = require('iced-error').make_esc;
12
-
13
- pgp_utils = require('pgp-utils');
14
-
15
- _ref = pgp_utils.util, json_stringify_sorted = _ref.json_stringify_sorted, unix_time = _ref.unix_time, streq_secure = _ref.streq_secure;
16
-
17
- schema = require('./schema3');
18
-
19
- exports.Vouch = Vouch = (function(_super) {
20
- __extends(Vouch, _super);
21
-
22
- function Vouch(obj) {
23
- this.wot = obj.wot;
24
- Vouch.__super__.constructor.call(this, obj);
25
- }
26
-
27
- Vouch.prototype._v_stub_paths = function() {
28
- return ["body.wot_vouch"];
29
- };
30
-
31
- Vouch.prototype._type = function() {
32
- return constants.sig_types.wot.vouch;
33
- };
34
-
35
- Vouch.prototype._type_v2 = function(revoke_flag) {
36
- if ((this.revoke != null) || revoke_flag) {
37
- return constants.sig_types_v2.wot.vouch_with_revoke;
38
- } else {
39
- return constants.sig_types_v2.wot.vouch;
40
- }
41
- };
42
-
43
- Vouch.prototype._v_check = function(_arg, cb) {
44
- var err, json, obj, proof_schema, schm;
45
- json = _arg.json;
46
- obj = json.body.wot_vouch;
47
- if (obj == null) {
48
- return cb(null);
49
- }
50
- proof_schema = schema.or([
51
- schema.dict({
52
- proof_type: schema.int(),
53
- name: schema.string(),
54
- username: schema.string()
55
- }), schema.dict({
56
- proof_type: schema.int(),
57
- protocol: schema.string(),
58
- hostname: schema.string()
59
- }), schema.dict({
60
- proof_type: schema.int(),
61
- protocol: schema.string(),
62
- domain: schema.string()
63
- })
64
- ]);
65
- schm = schema.dict({
66
- user: schema.dict({
67
- username: schema.string(),
68
- uid: schema.uid().convert(),
69
- eldest: schema.dict({
70
- seqno: schema.int(),
71
- kid: schema.kid().convert()
72
- }),
73
- seq_tail: schema.dict({
74
- seqno: schema.int(),
75
- sig_id: schema.sig_id().convert(),
76
- payload_hash: schema.hash().convert()
77
- })
78
- }),
79
- confidence: schema.dict({
80
- username_verified_via: schema.string_enum(["in_person", "proofs", "video", "audio", "other_chat", "familiar", "other"]).optional(),
81
- proofs: schema.array(proof_schema).optional(),
82
- other: schema.string({
83
- max_length: 90
84
- }).optional()
85
- }),
86
- vouch_text: schema.string({
87
- max_length: 700
88
- })
89
- });
90
- err = schm.check(obj);
91
- return cb(err);
92
- };
93
-
94
- Vouch.prototype._v_customize_json = function(ret) {
95
- var t, _ref1;
96
- if ((t = (_ref1 = this.wot) != null ? _ref1.vouch : void 0) != null) {
97
- return ret.body.wot_vouch = t;
98
- }
99
- };
100
-
101
- return Vouch;
102
-
103
- })(Base);
104
-
105
- exports.React = React = (function(_super) {
106
- __extends(React, _super);
107
-
108
- function React(obj) {
109
- this.wot = obj.wot;
110
- React.__super__.constructor.call(this, obj);
111
- }
112
-
113
- React.prototype._v_stub_paths = function() {
114
- return ["body.wot_react"];
115
- };
116
-
117
- React.prototype._type = function() {
118
- return constants.sig_types.wot.react;
119
- };
120
-
121
- React.prototype._type_v2 = function(revoke_flag) {
122
- return constants.sig_types_v2.wot.react;
123
- };
124
-
125
- React.prototype._v_check = function(_arg, cb) {
126
- var json, obj, schm;
127
- json = _arg.json;
128
- obj = json.body.wot_react;
129
- schm = schema.dict({
130
- sig_id: schema.sig_id().convert(),
131
- reaction: schema.string_enum(["accept", "reject"])
132
- });
133
- return cb(schm.check(obj));
134
- };
135
-
136
- React.prototype._v_customize_json = function(ret) {
137
- var t;
138
- if ((t = this.wot.react) != null) {
139
- return ret.body.wot_react = t;
140
- }
141
- };
142
-
143
- return React;
144
-
145
- })(Base);
146
-
147
- }).call(this);
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
- #==========================================================================