go back to "input_code" instead of "type_code"

This commit is contained in:
Brian Warner 2017-03-09 11:05:36 +01:00
parent 276fdd3673
commit 4bd9d3579c
3 changed files with 14 additions and 14 deletions

View File

@ -153,7 +153,7 @@ randomly-generated selection from the PGP wordlist, providing a default of 16
bits of entropy. The initiating program should display this code to the user, bits of entropy. The initiating program should display this code to the user,
who should transcribe it to the receiving user, who gives it to their local who should transcribe it to the receiving user, who gives it to their local
Wormhole object by calling `set_code()`. The receiving program can also use Wormhole object by calling `set_code()`. The receiving program can also use
`type_code()` to use a readline-based input function: this offers tab `input_code()` to use a readline-based input function: this offers tab
completion of allocated channel-ids and known codewords. completion of allocated channel-ids and known codewords.
The Wormhole object has three APIs for generating or accepting a code: The Wormhole object has three APIs for generating or accepting a code:
@ -162,7 +162,7 @@ The Wormhole object has three APIs for generating or accepting a code:
a short numeric nameplate, chooses a configurable number of random words, a short numeric nameplate, chooses a configurable number of random words,
then assembles them into the code then assembles them into the code
* `w.set_code(code)`: this accepts the code as an argument * `w.set_code(code)`: this accepts the code as an argument
* `helper = w.type_code()`: this facilitates interactive entry of the code, * `helper = w.input_code()`: this facilitates interactive entry of the code,
with tab-completion. The helper object has methods to return a list of with tab-completion. The helper object has methods to return a list of
viable completions for whatever portion of the code has been entered so viable completions for whatever portion of the code has been entered so
far. A convenience wrapper is provided to attach this to the `rlcompleter` far. A convenience wrapper is provided to attach this to the `rlcompleter`
@ -179,7 +179,7 @@ The code-entry Helper object has the following API:
* `d = h.get_nameplates()`: returns a Deferred that fires with a list of * `d = h.get_nameplates()`: returns a Deferred that fires with a list of
(string) nameplates. These form the first portion of the wormhole code (string) nameplates. These form the first portion of the wormhole code
(e.g. "4" in "4-purple-sausages"). The list is requested from the server (e.g. "4" in "4-purple-sausages"). The list is requested from the server
when `w.type_code()` is first called, and if the response arrives before when `w.input_code()` is first called, and if the response arrives before
`h.get_nameplates()` is called, it will be used without delay. All `h.get_nameplates()` is called, it will be used without delay. All
subsequent calls to `h.get_nameplates()` will provoke a fresh request to subsequent calls to `h.get_nameplates()` will provoke a fresh request to
the server, so hitting Tab too early won't condemn the client to using a the server, so hitting Tab too early won't condemn the client to using a
@ -210,7 +210,7 @@ helper to do tab completion of wormhole codes:
```python ```python
from wormhole import create, rlcompleter_helper from wormhole import create, rlcompleter_helper
w = create(appid, relay_url, reactor) w = create(appid, relay_url, reactor)
rlcompleter_helper("Wormhole code:", w.type_code()) rlcompleter_helper("Wormhole code:", w.input_code())
d = w.when_code() d = w.when_code()
``` ```
@ -229,16 +229,16 @@ In most situations, the "sending" or "initiating" side will call
it and speaks, types, performs charades, or otherwise transmits the code to it and speaks, types, performs charades, or otherwise transmits the code to
the receiving human. The receiving human then types it into the receiving the receiving human. The receiving human then types it into the receiving
computer, where it either calls `w.set_code()` (if the code is passed in via computer, where it either calls `w.set_code()` (if the code is passed in via
argv) or `w.type_code()` (for interactive entry). argv) or `w.input_code()` (for interactive entry).
Usually one machine generates the code, and a pair of humans transcribes it Usually one machine generates the code, and a pair of humans transcribes it
to the second machine (so `w.generate_code()` on one side, and `w.set_code()` to the second machine (so `w.generate_code()` on one side, and `w.set_code()`
or `w.type_code()` on the other). But it is also possible for the humans to or `w.input_code()` on the other). But it is also possible for the humans to
generate the code offline, perhaps at a face-to-face meeting, and then take generate the code offline, perhaps at a face-to-face meeting, and then take
the code back to their computers. In this case, `w.set_code()` will be used the code back to their computers. In this case, `w.set_code()` will be used
on both sides. It is unlikely that the humans will restrict themselves to a on both sides. It is unlikely that the humans will restrict themselves to a
pre-established wordlist when manually generating codes, so the completion pre-established wordlist when manually generating codes, so the completion
feature of `w.type_code()` is not helpful. feature of `w.input_code()` is not helpful.
When the humans create an invitation code out-of-band, they are responsible When the humans create an invitation code out-of-band, they are responsible
for choosing an unused channel-ID (simply picking a random 3-or-more digit for choosing an unused channel-ID (simply picking a random 3-or-more digit
@ -276,7 +276,7 @@ those Deferreds.
* got_code (`yield w.when_code()` / `dg.wormhole_code(code)`): fired when the * got_code (`yield w.when_code()` / `dg.wormhole_code(code)`): fired when the
wormhole code is established, either after `w.generate_code()` finishes the wormhole code is established, either after `w.generate_code()` finishes the
generation process, or when the Input Helper returned by `w.type_code()` generation process, or when the Input Helper returned by `w.input_code()`
has been told `h.set_words()`, or immediately after `w.set_code(code)` is has been told `h.set_words()`, or immediately after `w.set_code(code)` is
called. This is most useful after calling `w.generate_code()`, to show the called. This is most useful after calling `w.generate_code()`, to show the
generated code to the user so they can transcribe it to their peer. generated code to the user so they can transcribe it to their peer.
@ -396,7 +396,7 @@ action | Deferred-Mode | Delegated-Mode
-------------------------- | -------------------- | -------------- -------------------------- | -------------------- | --------------
w.generate_code(length=2) | | w.generate_code(length=2) | |
w.set_code(code) | | w.set_code(code) | |
h=w.type_code() | | h=w.input_code() | |
| d=w.when_code() | dg.wormhole_code(code) | d=w.when_code() | dg.wormhole_code(code)
| d=w.when_verified() | dg.wormhole_verified(verifier) | d=w.when_verified() | dg.wormhole_verified(verifier)
| d=w.when_version() | dg.wormhole_version(version) | d=w.when_version() | dg.wormhole_version(version)

View File

@ -55,7 +55,7 @@ class NoKeyError(WormholeError):
"""w.derive_key() was called before got_verifier() fired""" """w.derive_key() was called before got_verifier() fired"""
class OnlyOneCodeError(WormholeError): class OnlyOneCodeError(WormholeError):
"""Only one w.generate_code/w.set_code/w.type_code may be called""" """Only one w.generate_code/w.set_code/w.input_code may be called"""
class WormholeClosed(Exception): class WormholeClosed(Exception):
"""Deferred-returning API calls errback with WormholeClosed if the """Deferred-returning API calls errback with WormholeClosed if the

View File

@ -311,13 +311,13 @@ def from_serialized(serialized, reactor, delegate,
# should the new Wormhole call got_code? only if it wasn't called before. # should the new Wormhole call got_code? only if it wasn't called before.
# after creating the wormhole object, app must call exactly one of: # after creating the wormhole object, app must call exactly one of:
# set_code(code), generate_code(), helper=type_code(), and then (if they need # set_code(code), generate_code(), helper=input_code(), and then (if they need
# to know the code) wait for delegate.got_code() or d=w.when_code() # to know the code) wait for delegate.got_code() or d=w.when_code()
# the helper for type_code() can be asked for completions: # the helper for input_code() can be asked for completions:
# d=helper.get_completions(text_so_far), which will fire with a list of # d=helper.get_completions(text_so_far), which will fire with a list of
# strings that could usefully be appended to text_so_far. # strings that could usefully be appended to text_so_far.
# wormhole.type_code_readline(w) is a wrapper that knows how to use # wormhole.input_code_readline(w) is a wrapper that knows how to use
# w.type_code() to drive rlcompleter # w.input_code() to drive rlcompleter