├── .gitignore
├── docs-conf.json
├── docs
├── 05summary.md
├── 00faq.md
├── 01rationale.md
├── 03schema.md
├── 04engines.md
└── 02overview.md
├── package.json
├── README.md
├── engines
├── some-utils.js
└── secure-scuttlebutt
│ ├── test
│ └── test-engine.js
│ └── engine.js
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | node_modules
3 |
--------------------------------------------------------------------------------
/docs-conf.json:
--------------------------------------------------------------------------------
1 | {
2 | "source": {
3 | "include": ["engines"],
4 | "exclude": ["node_modules"]
5 | },
6 | "plugins": ["plugins/markdown"],
7 | "extensions": ["js"]
8 | }
9 |
--------------------------------------------------------------------------------
/docs/05summary.md:
--------------------------------------------------------------------------------
1 | # summary
2 |
3 | - people (travellers) operate spaceships.
4 | - spaceships encase travellers, protecting their privacy and mediating their
5 | identit[ies] and interaction with cypherspace.
6 | - spaceships have bridges/cockpits that people use to operate them.
7 | - spaceships have engines that are used to control and direct the flow of
8 | information through them from different parts of cypherspace.
9 | - data in cypherspace appears in different galaxies, whose coherence is
10 | maintained by egalitarian and free programs and protocols.
11 | - orbitals are persistent cryptographically bounded spaces within galaxies that
12 | spaceships can visit. they may set (and implement) their own policies as they
13 | choose, according to the respect their residents and visitors pay them.
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "spaceship",
3 | "version": "0.1.0",
4 | "description": "a vehicle for cypherspace travel",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "./test.sh",
8 | "doc": "jsdoc -c docs-conf.json -r --verbose -d docs/jsdoc/"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/du5t/spaceship.git"
13 | },
14 | "keywords": [
15 | "cypherspace",
16 | "swarmlog",
17 | "hyperlog",
18 | "ssb",
19 | "secure-scuttlebutt",
20 | "decentralised"
21 | ],
22 | "author": "du5t",
23 | "license": "AGPL-3.0",
24 | "bugs": {
25 | "url": "https://github.com/du5t/spaceship/issues"
26 | },
27 | "homepage": "https://github.com/du5t/spaceship#readme",
28 | "dependencies": {
29 | "jsonfile": "^2.2.3",
30 | "patchwork-threads": "^2.0.0",
31 | "pull-stream": "^3.4.5",
32 | "run-parallel": "^1.1.4",
33 | "ssb-client": "^3.0.0",
34 | "ssb-keys": "^4.0.10",
35 | "ssb-msgs": "^5.2.0",
36 | "uuid": "^2.0.1",
37 | "verbal-expressions": "^0.2.1",
38 | "xdg-basedir": "^2.0.0"
39 | },
40 | "devDependencies": {
41 | "jsdoc": "^3.4.0",
42 | "tape": "^4.4.0"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # spaceship
2 |
3 |
4 | ## what is this?
5 |
6 | spaceship is a reference design for interaction patterns in decentralised
7 | cryptographically secure network spaces (cypherspaces).
8 |
9 | the goal is to produce a schematic (and reference interface) that yields
10 | affordances that any cypherspace should be able to provide.
11 |
12 | ## contents
13 |
14 | tl;dr: `npm install; npm run doc; open docs/jsdoc/index.html`
15 |
16 | 1. [rationale and motivation](./docs/01rationale.md)
17 | 2. [design overview](./docs/02overview.md)
18 | 4. [prototypical examples](./docs/02overview.md#prototypicals)
19 | 4. [spaceship-schema](./docs/03schema.md): a document describing the basic
20 | building blocks of the design and how they relate.
21 | 3. [spaceship-engines](./docs/04engines.md): a document describing the basic
22 | "API-like" functions needed to realise the schema.
23 | 4. [brief summary](./docs/05summary.md)
24 | 5. roadmap: [engines+bridge](#roadmap)
25 | 6. [answers to questions](./docs/00faq.md)
26 |
27 | ## roadmap
28 |
29 | - [ ] reference engine implementations in:
30 | - [x] scuttlebot
31 | - [ ] hyperdrive/swarmbot
32 | - [ ] onionspace/tor
33 | - [ ] hydra
34 | - [ ] orbit-db/ipfs
35 | - [ ] i2p
36 | - ??
37 | - [ ] a reference visual interface:
38 | [spaceship-bridge](https://github.com/du5t/spaceship-bridge)
39 | - [ ] a complete prototype doc
40 |
--------------------------------------------------------------------------------
/engines/some-utils.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * misc utils
4 | *
5 | */
6 |
7 | var xdgBasedir = require('xdg-basedir')
8 | var ssbref = require('ssb-ref')
9 |
10 | exports.resolveConfigPath = function(configPath, subdirName) {
11 | // configPath is optional
12 | if (arguments.length === 1) {
13 | subdirName = configPath;
14 | configPath = undefined;
15 | }
16 | // subdirName is required
17 | if (typeof subdirName !== 'string') {
18 | throw new Error("app/engine subdirectory is required.")
19 | }
20 |
21 | var path
22 | if (typeof configPath === 'string') path = configPath.concat(subdirName)
23 | else path = xdgBasedir.config
24 | .concat('/')
25 | .concat(subdirName)
26 | .concat('/')
27 | return path
28 | }
29 |
30 | exports.resolveDataPath = function(dataPath, subdirName) {
31 | // configPath is optional
32 | if (arguments.length === 1) {
33 | subdirName = dataPath;
34 | dataPath = undefined;
35 | }
36 | // subdirName is required
37 | if (typeof subdirName !== 'string') {
38 | throw new Error("app/engine subdirectory is required.")
39 | }
40 |
41 | var path
42 | if (typeof dataPath === 'string') path = dataPath
43 | else path = xdgBasedir.data.concat('/').concat(subdirName)
44 | return path
45 | }
46 |
47 | // taken from ssb-msg-schemas
48 | exports.ssbLink = function(l) {
49 | if (typeof l == 'string') {
50 | if (ssbref.isLink(l))
51 | return l
52 | }
53 | if (l && typeof l == 'object') {
54 | if (Object.keys(l).length === 1 && l.link && ssbref.isLink(l))
55 | return l
56 | return mlib.link(l)
57 | }
58 | }
--------------------------------------------------------------------------------
/docs/00faq.md:
--------------------------------------------------------------------------------
1 | # answers to questions
2 |
3 | ## why all this space junk?
4 |
5 | space junk is [a real problem](https://en.wikipedia.org/wiki/Space_debris).
6 |
7 | ok really, it's because deep space is a domain you imagine as drastically
8 | different from where you are (at least at the time of this commit). space is a
9 | new place, with new rules, which is good motivation to rethink things.
10 |
11 | in other words, this is about **engineering safe communication spaces**, as free
12 | from prior context as possible.
13 |
14 | it's easier to imagine such things if you can travel through space. you can
15 | imagine new technologies and modes of interaction compeltely independent from
16 | earthbound structure.
17 |
18 | fiction and fact about space are full of old and new ideas about technologies
19 | and mechanisms. basic communication and interaction over astronomical distances,
20 | without a governing central authority, are also imaginable as the lifeblood of
21 | space-based society.
22 |
23 | it's also a simple metaphor for judging approaches in the long-term. a
24 | centralised communication system that finds ways of locking you and your data in
25 | forever is like a black hole. on the other hand, an endless succession of
26 | non-interoperable alternative networks and secure messaging systems resembles,
27 | in the extreme,
28 | [an expanding universe that eventually renders communication impossible](https://en.wikipedia.org/wiki/Big_Rip).
29 |
30 | and anyway, space is really cool.
31 |
32 | ## the design is abstract and confusing...
33 |
34 | the goal is to design and build something extremely minimal and generic,
35 | independent of underlying network structure. naturally this means something more
36 | abstract than most assumptions brought in from some the everyday life of some
37 | particular set of people.
38 |
39 | saying that, it should be useful--spaceship's design should lead you toward
40 | relatable interactions and experiences. please feel welcome to submit an issue
41 | or pull request if you think something is missing or needs changing.
42 |
--------------------------------------------------------------------------------
/docs/01rationale.md:
--------------------------------------------------------------------------------
1 | # rationale
2 |
3 | ## motivation: the ghost of cyberspace
4 |
5 | the existing internet's not really space. it's not really a place you can
6 | travel.
7 |
8 | "the" internet, the one ruled by ICANN, a host of peering and consumer-facing ISPs who play
9 | resource games with each other, certificate
10 |
11 | this internet that is talked about these days is a small sliver of all of the
12 | other things the initial decentralised network project is and was, even at that
13 | time. that sliver used to be called the "world wide web". it is no longer
14 | worldwide--it is balkanised and corporatised, it is regulated and stratified,
15 | and its hierarchy is incredibly firm. you know that some things will be hidden
16 | and some will be visible when you v
17 |
18 | and that's just it--"the" internet, as it is now, is a collection of
19 | financialised behemoths (not even metaphorically, this is the age of the server
20 | farm) who package up code and content to serve to consumers. sometimes they're
21 | "content creators", but they don't benefit the way an actual "creator"
22 | might. this line was written in 2016 CE and we're *still*
23 | [digital sharecropping](http://bizshifts-trends.com/2014/07/23/digital-sharecropping-vast-majority-online-businesses-sharecroppers-distressing-dont-even-know/).
24 |
25 | even if you're not a marxist (or a
26 | [telekommunist](http://telekommunisten.net/the-telekommunist-manifesto/)), you
27 | would probably like to own what you create, right? this is literally a world
28 | where people work for scraps (or sometimes for nothing at all) doing things like
29 | [completing menial videogame tasks](http://www.nickyee.com/pubs/Yee%20-%20Labor%20of%20Fun%20(2006).pdf),
30 | write
31 | [articles mainly designed to steal attention](http://www.theguardian.com/media/2016/apr/10/twitter-ev-williams-medium-content-fast-food)
32 | (often instead of actually informing), or
33 | [transferring labor directly to machines](http://blog.oddhead.com/2008/08/13/the-seedy-side-of-amazons-mechanical-turk/)
34 | through APIs whose endpoints are actually humans.
35 |
36 | this kind of network is not much of a space, and certainly not a safe space to
37 | be. if it's any sort of space at all, it's like the railsea of
38 | [china mieville's novel](https://en.wikipedia.org/wiki/Railsea): it approximates
39 | an ocean, but all you can do is switch rails (and companies and governments are
40 | out to put a price tag and patrol on every inch of it).
41 |
42 | with the advent of increasingly decentralised, private, independent (in the
43 | sense of capacity) communications, we've been given a chance to revisit the
44 | conception of 'cyberspace' as a separate performative domain.
45 |
46 | actually, you know what--scratch the passive voice. here is what happened: **a
47 | bunch of really thoughtful people did an unbelievable amount of work for free
48 | and gave it away honestly**. that continuing work, in the form of protocol
49 | designs, code, tests, server time, commentary, conversation, and jokes, creates
50 | new spaces the way the internet did before existing social/economic empires and
51 | edifices colonised it.
52 |
53 | we've taken to calling it 'cypherspace', since cryptography is one of the main
54 | pillars on which it rests.
55 |
56 | cypherspace is a place whose entryways and underpinnings lie outside of
57 | monolithic server farms, name authorities, global singletons, or any other
58 | hierarchy dwarfing any of the people who visit or inhabit it. its limits are
59 | defined solely by the choices of those who work within it, and the consent of
60 | those around them.
61 |
62 | while all of this is great news, decentralisation, and the egalitarian agency
63 | that lies beyond it, can't be a purely network layer movement--it needs to
64 | happen at the application layer also. it needs to put people at its center.
65 |
--------------------------------------------------------------------------------
/docs/03schema.md:
--------------------------------------------------------------------------------
1 | # schema
2 |
3 | ## travellers, pilots, residents
4 |
5 | travellers are the people of cypherspace--its performative atoms.
6 |
7 | **key characteristics:**
8 |
9 | - travellers are people (agnostic to their particular embodiment)
10 | - travellers operate spaceships
11 | - travellers are identified by transmitted IDs (e.g. public keys) whose
12 | transmission they control through spaceships
13 |
14 | travellers and residents pilot spaceships. they transmit messages that identify
15 | their crafts uniquely whenever they visit orbitals in different galaxies--but
16 | they choose what to send and where to send it.
17 |
18 | ## spaceships
19 |
20 | a spaceship is any networked device capable of galactic communication.
21 |
22 | **key characteristics:**
23 |
24 | - spaceships are the method by which travellers interact with cypherspace. they
25 | are the embodiment of a traveler as far as the galaxy is concerned.
26 | - spaceships have an obligation to relay or mirror records they receive to other
27 | parts of the galaxy. (for example, a ship that views the ssb galaxy is also
28 | obligated to participate in the gossip protocol that makes it work.)
29 |
30 | **design concepts:**
31 |
32 | - spaceships as vehicles of thought, as in
33 | [the fountain](http://wallpoper.com/images/00/39/23/82/the-fountain_00392382.jpg).
34 | - spaceship as a traveller's creative personal space, as in
35 | [starbound](http://vignette2.wikia.nocookie.net/starboundgame/images/6/6f/Customizedship.png/revision/latest)
36 | (and many others).
37 |
38 | ## records, logs
39 |
40 | a record is a semantically linked, sequenced data set that is useful to
41 | spaceship pilots. it might be a message thread, a folder of data, or media
42 | collection (such as a music album).
43 |
44 | **key characteristics:**
45 |
46 | - created by an orbital resident
47 | - unified by weak ordering
48 | - weak separation from other records in orbitals for ease of ordering/digestion
49 |
50 | **design concepts:**
51 |
52 | - rosters of orbital residents
53 | - votes on orbital policy
54 | - playlists (mixtapes, albums)
55 | - message threads (conversations, diaries, notes)
56 | - stores of treasure (curated files, libraries, source code repositories,
57 | databases in general)
58 | - acts of theater (monologues, dialogues, and so on)
59 | - serialised and one-off productions (webcomics, video dramas, zines)
60 |
61 | ## orbitals
62 |
63 | **key characteristics:**
64 |
65 | - bounded, autonomous spaces of communication
66 | - boundaries established through cryptographic measures
67 | - policies available to modification by residents, if desired
68 | - protocol agnostic
69 | - no barrier to creation by any traveler
70 |
71 | **orbitals** are space colonies. from an social standpoint, they serve as
72 | bounded, autonomous territories. From an engineering standpoint, this simply
73 | means that they are a set of autonomously determined recipients and policies for
74 | communication. in other words, they are implicit stores of records.
75 |
76 | an orbital's boundaries are established through cryptographic measures. by
77 | default, records are encrypted with the public keys of, or keys generated from
78 | the public keys of an orbital's residents.
79 |
80 | these boundaries are under the control of residents--an orbital's creator
81 | establishes the initial policies of an orbital, but may open them to change by
82 | the residents themselves.
83 |
84 | orbitals are protocol agnostic--any decentralised galaxy can support orbitals,
85 | as long as it allows travellers to travel them, participate, and communicate in
86 | the above self-determined manner.
87 |
88 | any traveler can establish an orbital, simply by propagating an identifier and
89 | communicating a roster of invitees or residents. there is no barrier to
90 | creation.
91 |
92 | **design concepts:**
93 |
94 | - orbitals as space of recorded communication to be visited/accessed, from
95 | [analogue: a hate story](http://ahatestory.com/)
96 | - orbitals as nominally independent but communicatively collaborative space
97 | colonies, a la
98 | [iain banks' Culture novels](https://en.wikipedia.org/wiki/Orbital_(The_Culture))
99 | ([image 1](http://r.duckduckgo.com/l/?kh=-1&uddg=http%3A%2F%2Fwww.nss.org%2Fsettlement%2Fcalendar%2F2009%2FGoetzScheuermann-oneillcylinder-650.jpg))
100 | ([image 2](http://settlement.arc.nasa.gov/Kalpana/Kalpana-43-Aa2-1920.jpg))
101 | - IRC channels and their hierarchies of
102 | [user modes](https://www.alien.net.au/irc/usermodes.html)
103 |
104 | ## galaxies
105 |
106 | **key characteristics:**
107 |
108 | - independence from centralised, terrestrial-bound and mapped networks
109 | - structural protections against out-of-galaxy (or universe) attacks, such as
110 | denial-of-service, attacks on protocols
111 | - no essential topographic borders: free entry to any spaceship
112 |
113 | galaxies are the main sources of mass (things that are interacted with by
114 | spaceships) in the decentralised universe.
115 |
116 | galaxies are maintained by decentralised electronic infrastructure (at least
117 | when this draft was produced). it's worth stating clearly what they are not: if
118 | your infrastructure packs users into centralised accounts, centralised activity,
119 | or prevents them from controlling what spaces they inhabit and establish, it's
120 | not a galaxy--it's just a locked chamber.
121 |
122 | **design concepts:**
123 |
124 | - the interlaced cities of
125 | [the city and city](https://en.wikipedia.org/wiki/The_City_%26_the_City)
126 | - the asynchronous interstellar civilisations of
127 | [lockstep](http://boingboing.net/2014/03/27/lockstep-karl-schroeders-fi.html)
128 |
129 | examples of galaxies:
130 |
131 | - ssb networks
132 | - swarmlog rafts
133 | - twister blockchains
134 | - freenet networks
135 |
136 | ## cypherspace
137 |
138 | cypherspace is the observable universe of galaxies that can be traversed by
139 | spaceships.
140 |
141 | **design concepts:**
142 |
143 | - the *kriptosfear* of iain banks'
144 | [feersum endjinn](https://en.wikipedia.org/wiki/Feersum_Endjinn)
145 | - the posthuman editable universe of
146 | [transistor](https://en.wikipedia.org/wiki/Transistor_(video_game))
147 |
148 |
149 | # narratives of communication
150 |
151 | ## orbital
152 |
153 | orbitals are made up of a specific set of recipients. they have many residents,
154 | and each orbital can establish rules about how residency is granted.
155 |
156 | communication on orbitals consists of messages that are threaded into records,
157 | but other models and content-types can always be realised.
158 |
159 | records are encrypted with either the public keys of (or record-specific keys
160 | generated for) each resident.
161 |
162 | ### orbital residency
163 |
164 | the residents of an orbital can read any record posted to an orbital. they have
165 | input to orbital policy, appearance, and can create records.
166 |
167 | #### "inviting-in"
168 |
169 | drawing from
170 | [CE 2010s western queer terminology](http://www.musedmagonline.com/2015/04/coming-semantics-reinforce-heterosexism-queer-people-color/),
171 | a traveller (see below) may be **invited in** to the context or performative
172 | space of an orbital. in other words, they may be invited to some or all of the
173 | past records of an orbital, and those occurring thereafter. this involves one or
174 | more residents re-encrypting a record (up to some quota) with the key of an
175 | invited traveller.
176 |
177 | this matches the human practice of appending-only to memory, keeping past
178 | records invisible to new residents without affirmative consent and contextual
179 | fit.
180 |
181 | an orbital may be set to invite any traveller in automatically; in this case
182 | end-to-end encryption can be established, but the orbital is then simply
183 | socially private, not technologically so.
184 |
185 | ### galaxy
186 |
187 | depending on use, spaceships might only travel one galaxy at a time, or
188 | otherwise limit the amount of traffic they replicate for each galaxy. as a
189 | general rule, terrestrial topology should not be privileged above galactic
190 | topology--every orbital's traffic should be replicated by every other orbital
191 | and spaceship if possible, regardless of stake, interest, or engagement with the
192 | content. in other words, discoverability and replication are coupled, even if
193 | messages are private to (many or all) orbitals.
194 |
195 | saying that, discoverability should also be manageable. orbitals may be
196 | hyperlocal in some space (e.g., a city orbital); a spaceship should be able to
197 | travel from such orbitals to others without committing to replicate all
198 | orbital-local traffic.
199 |
200 | galaxywide broadcasts are of course also possible, but dodgy at
201 | best. experiments in the centralised internet outside of cypherspace have
202 | [shown them to be problematic](http://www.theverge.com/2016/2/6/10926816/twitter-employee-experiences-harassment-on-twitter).
203 |
--------------------------------------------------------------------------------
/docs/04engines.md:
--------------------------------------------------------------------------------
1 | # spaceship engine spec
2 |
3 | following the [schema](./spaceship-schema.md), a spaceship needs an engine to
4 | travel a cypherspace galaxy. an engine is constructed from a set of functions
5 | that realise the spaceship schema. this resembles an API. unlike an API though,
6 | these requirements are not set out by a central server and presented to
7 | clients--spaceships own their engines and technicians/mechanics may customise
8 | them as they like.
9 |
10 | what we present here is a limited set of functions a codebase should provide to
11 | properly function as a spaceship engine. not all of these functions need
12 | implementing on their own--many of them are easily realised as compositions.
13 |
14 | general remarks:
15 |
16 | - spaceship identifiers (public keys) must be signed with the appropriate
17 | private key or similar attestation, for every request.
18 | - where a function returns no output (for example, if it is used to modify
19 | galactic or local state), it's best to return information about the result.
20 |
21 | ## spec details
22 |
23 | ### pilot/spaceship internal functions
24 |
25 | - createIdentifier
26 | - listIdentifiers
27 | - destroyIdentifier
28 | - entombData
29 | - importData
30 |
31 | #### createIdentifier
32 |
33 | - input: null
34 | - output: a struct or hash of `private` and `public` keys
35 |
36 | generates a keypair that can be used to identify the pilot to others.
37 |
38 | #### destroyIdentifier
39 |
40 | - input: a keypair id
41 | - output: null
42 |
43 | permanently destroys a keypair. Naturally, only the private key can actually be
44 | destroyed, if the public key has seen any replication.
45 |
46 | #### listIdentifiers
47 |
48 | - input: null
49 | - output: an enumerable of identifiers
50 |
51 | lists the identifiers available to a spaceship for use.
52 |
53 | #### entombData
54 |
55 | - input: a pointer (or location string) addressing stored identifiers
56 | - output: an encrypted block of data
57 |
58 | encrypts a set of stored identifiers for out-of-universe export, deleting them
59 | from storage.
60 |
61 | #### importData
62 |
63 | - input: a pointer (or location string) addressing an encrypted block of
64 | identifier data
65 | - output: null
66 |
67 | decrypts a set of stored identifiers and places them into the underlying
68 | filesystem, and makes them available to `listIdentifiers()`.
69 |
70 | #### notes
71 |
72 | - assuming the spaceship's hardware substrate is running something like
73 | windows/posix, identifying data should be stored in
74 | [XDG standard directories](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html).
75 | - asymmetric-key cryptography is expected to be the most reliable form of
76 | identifier for the foreseeable future, but any implementation that combines a
77 | pilot's secret knowledge (i.e., a passphrase) with a robust stored secret (a
78 | private key) and a reusable public sigil (a public key) meets this spec.
79 |
80 | ### record functions
81 |
82 | - createRecord
83 | - editRecord
84 | - viewRecord
85 |
86 | #### createRecord
87 |
88 | - input: an enumerable of recipient keys, a record type, an array of record
89 | links, and serialised content.
90 | - output: null
91 |
92 | creates a record. a record is a performative atom for spaceships--it's a single
93 | communication at an experiential level. records are non-ephemeral. they may be
94 | linked to orbitals, encrypted to orbital residents or other recipients, or
95 | broadcast galaxywide. their position in the galaxy is thus expressed by their
96 | linkage.
97 |
98 | #### editRecord
99 |
100 | - input: a link to a record to be edited, and serialised content.
101 | - output: null
102 |
103 | submits a record linked to an already-existing one, with an explicit identifier
104 | indicating that it's an edit.
105 |
106 | throws an error if the existing record is not known to the spaceship.
107 |
108 | #### viewRecord
109 |
110 | - input: an ID referencing a record.
111 | - output: a record object with content, its creator's ID, and recipient IDs if
112 | applicable
113 |
114 | retrieves a record from the space.
115 |
116 | #### notes
117 |
118 | - a record link is just the key of a record, namely, a reference.
119 | - by convention, an edit of zero-length can be interpreted as a record's
120 | deletion.
121 | - edits may be better encoded as diffs, depending on their content type.
122 | - any ship may submit record edits. how they are viewed and processed is up to
123 | interface convention--for example, an orbital may establish itself as a wiki,
124 | and instruct spaceships to accept edits from any pilot. a spaceship may also
125 | unilaterally view different edits according to its own policies.
126 |
127 | ### orbital functions
128 |
129 | - createOrbital
130 | - hailOrbital
131 | - viewOrbital
132 | - inviteTraveller
133 | - emigrateOrbital
134 | - deportResident
135 |
136 | #### createOrbital
137 |
138 | - input: an informal name string, and a security policy descriptor. optionally,
139 | a list of invitees.
140 | - output: an orbital record to be replicated
141 |
142 | creates an orbital, with a unique key, name, and a description of its security
143 | policy.
144 |
145 | security policy descriptors may vary from galaxy to galaxy, but here is a
146 | example set of keys:
147 |
148 | - `announce`: boolean. controls whether or not a galaxywide broadcast of the new
149 | orbital is sent on creation or in response to hails. if this is false,
150 | spaceships will have to infer the existence of the orbital from traffic.
151 | - `openResidency`: boolean. controls whether or not visitors are immediately added
152 | to the list of recipients upon hailing the orbital, or if they must be
153 | invited.
154 | - `governmentType`: one of `"dictatorship"`, `"majority rule"`, or `"anarchy"`.
155 | - `dictator`: keystring or null. if `governmentType` is `dictatorship`, this
156 | identifies the resident who sets policy.
157 |
158 | #### viewOrbital
159 |
160 | - input: an orbital identifier
161 | - output: an enumerable of record keys
162 |
163 | this function performs the task polls the orbital for records
164 |
165 | #### hailOrbital
166 |
167 | - input: a signed spaceship identifier
168 | - output: one of `"welcome"` or `"invitation required"`.
169 |
170 | signals to an orbital that a spaceship and pilot would like to enter the
171 | orbital.
172 |
173 | orbital entry may consist of the following things, in order of increasing
174 | commitment:
175 |
176 | 1. orbital residents involving the entrant in orbital record traffic (only
177 | meaningful if traffic routing in the current galaxy has any
178 | [structural concept of spatial priority](https://en.wikipedia.org/wiki/Net_neutrality)).
179 | 2. orbital residents adding (one of) the entrant's public keys to the list of
180 | orbital recipients, allowing the entrant to read records posted thereafter.
181 | 3. orbital residents doing the computational work of re-encrypting records
182 | reaching into the past with the entrant's public key, allowing the entrant
183 | participation in the orbital's past.
184 | 4. political enfranchisement in the orbital, if there is any to be had
185 | 5. and so on, and so on...
186 |
187 | this function is the intransitive counterpart to `inviteTraveller`
188 |
189 | #### inviteTraveller
190 |
191 | - input: a spaceship identifier signed with the key of a resident.
192 | - output: null
193 |
194 | transitive counterpart to `hailOrbital`; expresses endorsement for entry by an
195 | orbital resident. has similar effects.
196 |
197 | #### emigrateOrbital
198 |
199 | - input: a spaceship identifier signed with its own key.
200 | - output: null
201 |
202 | requests that an orbital's residents roll back the entry steps outlined above.
203 |
204 | intransitive counterpart to `deportResident`.
205 |
206 | #### deportResident
207 |
208 | - input: a resident identifier signed with the key(s) of the policy deciders of
209 | the orbital (see above)
210 | - output: null
211 |
212 | transitive counterpart to `emigrateOrbital`; expresses endorsement for the
213 | expulsion of a resident from an orbital.
214 |
215 | #### notes
216 |
217 | - hailing an orbital is a good way to check for its existence before trying to
218 | create one with similar existential parameters.
219 | - emigrating an orbital is a good way to repudiate a public key, if the
220 | identifier has been compromised.
221 | - orbitals are just implicit collections of records, established by
222 | (cryptographically secured) recipient lists or just a single reference to an
223 | orbital.
224 | - on the other hand, an orbital, like any other part of this schema, could be
225 | backed by (dedicated) replicators with their own policies. we hope that the
226 | space remains as flat as possible, but these structural effects should be
227 | recognised.
228 | - a non-conforming engine build that does not obey `deportResident` calls is
229 | easily imagined. it is best not to rely on these types of functions.
230 | - speaking generally, inviting a traveler to an orbital is implicitly allowing
231 | them to bring stowaways, by virtue of the fact that any spaceship can pass on
232 | messages, disobeying the security policy of the orbital. trust is, as it has
233 | always been, up to the people involved, not the machines they operate.
234 | - orbitals, like IRC channels, rely on their residents to function as a space,
235 | regardless of structural circumstances. we expect communitarian anarchy to be
236 | the most stable form of orbital management.
237 |
238 | ### galaxy functions
239 |
240 | #### enterGalaxy
241 |
242 | - input: galaxy connection information, as a structure
243 | - output: a stateful connection object
244 |
245 | #### leaveGalaxy
246 |
247 | - input: a connection object
248 | - output: null
249 |
250 | dereferences a galaxy connection object and halts replication activity.
251 |
252 | #### notes
253 |
254 | since cypherspace galaxies are nearly or totally topologically independent from
255 | terrestrial space, a terrestrial connection is never needed to see a galaxy's
256 | "past", that is, the store of galaxy data that has already been replicated onto
257 | the local spaceship's hardware. likewise, galaxy data is not expected to be
258 | deleted (at least, not consistently). both the concepts of "entering" and
259 | "leaving" become dubious in this case, but we think they are schematically
260 | useful.
261 |
--------------------------------------------------------------------------------
/engines/secure-scuttlebutt/test/test-engine.js:
--------------------------------------------------------------------------------
1 | var tape = require('tape')
2 | var engine = require('../engine')
3 |
4 | function pluck(prop, arr) {
5 | return arr.map(item => item[prop])
6 | }
7 |
8 | tape.onFinish(function() {
9 | process.exit(0)
10 | })
11 |
12 | tape('createIdentifier creates an ssb keypair', function(t) {
13 | t.plan(3)
14 | engine.createIdentifier(true, function(err, newKey) {
15 | t.ok(newKey)
16 | t.ok(newKey.hasOwnProperty('private'))
17 | t.ok(newKey.hasOwnProperty('public'))
18 | })
19 | })
20 |
21 | tape('createIdentifier creates and saves ssb keypairs', function(t) {
22 | t.plan(3)
23 | engine.createIdentifier(false, '/tmp/', function(err, newKey) {
24 | t.ok(newKey)
25 | t.ok(newKey.hasOwnProperty('private'))
26 | t.ok(newKey.hasOwnProperty('public'))
27 | })
28 | })
29 |
30 | tape('listIdentifiers finds the local keypairs', function(t) {
31 | engine.createIdentifier(false, '/tmp/', function(err, newKey) {
32 | engine.listIdentifiers('/tmp/', function(err, keys) {
33 | t.ok(keys instanceof Array)
34 | keys.map(key => {
35 | t.ok(key.hasOwnProperty('public'))
36 | t.ok(key.hasOwnProperty('private'))
37 | t.ok(key.hasOwnProperty('id'))
38 | })
39 | t.end()
40 | })
41 | })
42 | })
43 |
44 | tape('destroyIdentifier destroys a key when its ID is passed', function(t) {
45 | t.plan(2)
46 | engine.createIdentifier(false, '/tmp/', function(err, newKey) {
47 | engine.destroyIdentifier(newKey.localPath, newKey.id, function(err) {
48 | t.notOk(err)
49 | engine.listIdentifiers('/tmp/', function(err, keys) {
50 | t.notOk(keys.find(key => key.id === newKey.id))
51 | })
52 | })
53 | })
54 | })
55 |
56 | tape('createRecord creates a record and brings it into the tree', function(t) {
57 | t.plan(2)
58 | engine.createRecord(null, 'post', null, { text:'test post' },
59 | function(err, record) {
60 | t.notOk(err)
61 | t.ok(record)
62 | t.end()
63 | })
64 | })
65 |
66 |
67 |
68 | tape('viewRecord finds a record', function(t) {
69 | t.plan(3)
70 | engine.createRecord(null, 'post', null, 'test post', function(err, record) {
71 | engine.viewRecord(record.key, function(err, foundRecord) {
72 | t.notOk(err)
73 | t.ok(foundRecord)
74 | t.equal(foundRecord.id, record.id)
75 | })
76 | })
77 | })
78 |
79 | tape('editRecord takes a recordID and new content, submits a linked rev', function(t) {
80 | t.plan(3)
81 | engine.createRecord(null, 'post', null, 'test post', function(err, record) {
82 | engine.editRecord(record.value.links, record, null, 'test post edit', function(err, editedRecord) {
83 | // TODO: test against schema
84 | t.notOk(err)
85 | t.ok(editedRecord)
86 | t.equal(editedRecord.value.content.content, 'test post edit')
87 | })
88 | })
89 | })
90 |
91 | tape('createOrbital creates a new orbital record, publishes it openly when public', function(t) {
92 | engine.createIdentifier(true, function(err, aliceKeys) {
93 | engine.createIdentifier(true, function(err, bobKeys) {
94 | engine.createIdentifier(true, function(err, cristaKeys) {
95 | const invitees = pluck('public', [aliceKeys, bobKeys, cristaKeys])
96 |
97 | engine.createOrbital('test-orbital', invitees, null, true, function(err, record) {
98 | t.notOk(err)
99 | t.ok(record)
100 | t.equal(record.value.content.type, 'orbital')
101 | t.ok(record.value.content.residents instanceof Array)
102 | // FIXME: this will fail i18n
103 | t.equal(record.value.content.content, 'Orbital test-orbital constructed!')
104 | t.equal(record.value.content.residents.length, 4)
105 | t.end()
106 | })
107 | })
108 | })
109 | })
110 | })
111 |
112 | tape('createOrbital produces an orbital record encrypted to self + invitees when private', function (t) {
113 | engine.createIdentifier(true, function(err, aliceKeys) {
114 | engine.createIdentifier(true, function(err, bobKeys) {
115 | engine.createIdentifier(true, function(err, cristaKeys) {
116 | const invitees = pluck('public', [aliceKeys, bobKeys, cristaKeys])
117 |
118 | engine.createOrbital('test-orbital2', invitees, null, false, function(err, record) {
119 | t.notOk(err)
120 | t.ok(record)
121 | // if encrypted, content will be cyphertext
122 | t.equal(typeof record.value.content, 'string')
123 |
124 | engine.decryptRecord(record, function(err, plaintextRecord) {
125 | t.notOk(err)
126 | t.equal(plaintextRecord.residents.length, 4)
127 | t.end()
128 | })
129 | })
130 | })
131 | })
132 | })
133 | })
134 |
135 | tape('decryptRecord decrypts a record known to be addressed to self', function (t) {
136 | engine.createIdentifier(true, function(err, aliceKeys) {
137 | engine.createIdentifier(true, function(err, bobKeys) {
138 | engine.createIdentifier(true, function(err, cristaKeys) {
139 | const invitees = pluck('public', [aliceKeys, bobKeys, cristaKeys])
140 |
141 | engine.createOrbital('test-orbital2', invitees, null, false, function(err, record) {
142 | t.notOk(err)
143 | t.ok(record)
144 | // if encrypted, content will be cyphertext
145 | t.equal(typeof record.value.content, 'string')
146 |
147 | engine.decryptRecord(record, function(err, plaintextRecord) {
148 | t.notOk(err)
149 |
150 | t.ok(plaintextRecord)
151 | t.equal(plaintextRecord.type, 'orbital')
152 | t.ok(plaintextRecord.residents instanceof Array)
153 | // FIXME: this will fail i18n
154 | t.equal(plaintextRecord.content,
155 | 'Orbital test-orbital2 constructed!')
156 | t.end()
157 | })
158 | })
159 | })
160 | })
161 | })
162 | })
163 |
164 | tape('createRecord with orbital creates a privately addressed record', function(t) {
165 | engine.createIdentifier(true, function(err, aliceKeys) {
166 | t.notOk(err)
167 | engine.createOrbital('test-orbital2', [aliceKeys.public], null, true, function(err, orbitalRecord) {
168 | t.notOk(err)
169 | engine.createRecord(orbitalRecord, 'post', null, { text:'test post' }, function(err, record) {
170 | t.notOk(err)
171 | t.ok(record)
172 | // if encrypted, content will be cyphertext
173 | t.equal(typeof record.value.content, 'string')
174 | t.end()
175 | })
176 | })
177 | })
178 | })
179 |
180 | tape('viewOrbital produces a list of messageRoots', function(t) {
181 | engine.createOrbital('test-orbital3', [], null, true, function(err, orbitalRecord) {
182 | t.notOk(err)
183 | engine.createRecord(orbitalRecord, 'post', null, { text:'test post' }, function(err, postRecord) {
184 | t.notOk(err)
185 |
186 | engine.viewOrbital(orbitalRecord.key, true, function(err, orbitalRecords) {
187 | t.notOk(err)
188 | t.ok(orbitalRecords)
189 |
190 | engine.decryptRecord(orbitalRecords[0], function(err, plaintextRecord) {
191 | t.notOk(err)
192 | var rec = orbitalRecord
193 | t.ok(plaintextRecord.links.map(link => link.link).includes(rec.key))
194 | t.end()
195 | })
196 |
197 | })
198 | })
199 | })
200 | })
201 |
202 | tape('hailOrbital sends a private message to its residents', function(t) {
203 | engine.createIdentifier(true, function(err, aliceKeys) {
204 | t.notOk(err)
205 | engine.createOrbital('test-orbital4', [aliceKeys.public], null, true, function(err, orbitalRecord) {
206 | t.notOk(err)
207 | engine.hailOrbital(orbitalRecord, { text: 'hello' }, function(err, record) {
208 | t.notOk(err)
209 | t.ok(record)
210 | // if encrypted, content will be cyphertext
211 | t.equal(typeof record.value.content, 'string')
212 | engine.decryptRecord(record, function(err, plaintextRecord) {
213 | t.notOk(err)
214 | var rec = orbitalRecord
215 |
216 | t.deepEqual(plaintextRecord.recps, rec.value.content.residents)
217 | t.end()
218 | })
219 | })
220 | })
221 | })
222 | })
223 |
224 | tape('inviteTraveller sends a private message to the inviting orbital\'s residents', function(t) {
225 | engine.createIdentifier(true, function(err, aliceKeys) {
226 | t.notOk(err)
227 | engine.createIdentifier(true, function(err, bobKeys) {
228 | t.notOk(err)
229 | engine.createOrbital('test-orbital4', [aliceKeys.public], null, true, function(err, orbitalRecord) {
230 | t.notOk(err)
231 | engine.inviteTraveller(bobKeys.public, orbitalRecord, { text: 'introducing bob' }, function(err, record) {
232 | t.notOk(err)
233 | t.ok(record)
234 | // if encrypted, content will be cyphertext
235 | t.equal(typeof record.value.content, 'string')
236 | engine.decryptRecord(record, function(err, plaintextRecord) {
237 | t.notOk(err)
238 | var rec = orbitalRecord
239 |
240 | t.deepEqual(plaintextRecord.recps, rec.value.content.residents)
241 | t.end()
242 | })
243 | })
244 | })
245 | })
246 | })
247 | })
248 |
249 | tape('emigrateOrbital sends a private message to the leaving orbital\'s residents', function(t) {
250 | engine.createIdentifier(true, function(err, aliceKeys) {
251 | t.notOk(err)
252 | engine.createOrbital('test-orbital4', [aliceKeys.public], null, true, function(err, orbitalRecord) {
253 | t.notOk(err)
254 | engine.hailOrbital(orbitalRecord, { text: 'bye' }, function(err, record) {
255 | t.notOk(err)
256 | t.ok(record)
257 | // if encrypted, content will be cyphertext
258 | t.equal(typeof record.value.content, 'string')
259 | engine.decryptRecord(record, function(err, plaintextRecord) {
260 | t.notOk(err)
261 | var rec = orbitalRecord
262 |
263 | t.deepEqual(plaintextRecord.recps, rec.value.content.residents)
264 | t.end()
265 | })
266 | })
267 | })
268 | })
269 | })
270 |
271 | tape('deportResident sends a private message to the leaving orbital\'s residents excepting the deportee', function(t) {
272 | engine.createIdentifier(true, function(err, aliceKeys) {
273 | t.notOk(err)
274 |
275 | engine.createIdentifier(true, function(err, bobKeys) {
276 | t.notOk(err)
277 |
278 | engine.createOrbital('test-orbital4', [aliceKeys.public, bobKeys.public], null, true, function(err, orbitalRecord) {
279 | t.notOk(err)
280 | var residentsWithoutBob = orbitalRecord.value.content.residents.slice()
281 | residentsWithoutBob
282 | .splice(residentsWithoutBob.findIndex(recp => recp === bobKeys.public), 1)
283 |
284 | engine.deportResident(bobKeys.public, orbitalRecord, { text: 'bob is mean' }, function(err, record) {
285 | t.notOk(err)
286 | t.ok(record)
287 | // if encrypted, content will be cyphertext
288 | t.equal(typeof record.value.content, 'string')
289 |
290 | engine.decryptRecord(record, function(err, plaintextRecord) {
291 | t.notOk(err)
292 | t.deepEqual(plaintextRecord.recps, residentsWithoutBob)
293 | t.end()
294 | })
295 | })
296 | })
297 | })
298 | })
299 | })
300 |
--------------------------------------------------------------------------------
/docs/02overview.md:
--------------------------------------------------------------------------------
1 | # design overview
2 |
3 | ## prior art comparison
4 |
5 | continuing from the [rationale](./rationale.md)...
6 |
7 | > cypherspace is a place whose entryways and underpinnings lie outside of
8 | > monolithic server farms, name authorities, global singletons, or any other
9 | > hierarchy dwarfing any of the people who visit or inhabit it. its limits are
10 | > defined solely by the choices of those who work within it, and the consent of
11 | > those around them.
12 |
13 | > while all of this is great news, decentralisation, and the egalitarian agency
14 | > that lies beyond it, can't be a purely network layer movement--it needs to
15 | > happen at the application layer also. it needs to put people at its center.
16 |
17 | in order to do this, we need to re-evaluate some old architectural assumptions.
18 |
19 | ### old assumptions: the "client-server" model
20 |
21 | what the "server" has to offer in the client-server model is meaningless in a
22 | decentralised space. basically, a server only gets you a few things:
23 |
24 | - uptime
25 | - processing power
26 | - packaged data (in other words, an API)
27 | - a location (in some field or geography of reputation, throughput, legal
28 | regulation)
29 |
30 | decentralised systems typically provide these to every person within them. the
31 | actual requirements behind uptime (availability, eventual consistency) are
32 | provided by asynchronous and aggressively egalitarian propagation protocols,
33 | like gossip or torrent. processing power is provided by inexpensive
34 | general-purpose hardware (notably, driven by open standards). typically, a
35 | person who has guaranteed access to a computer has more computing power than
36 | they can use.
37 |
38 | the place of APIs, data packaging, and location in a decentralised space is the
39 | exactly what the spaceship design aims to address.
40 |
41 | in a spaceship, the components of the imbalanced client-server model that are
42 | kept out of your control are transformed into components that sit inside your
43 | spaceship.
44 |
45 | - *engines* instead of APIs
46 | - *galaxies* instead of application stacks, server clusters, and other
47 | large-scale structure to provide data
48 | - [*spaceships*](http://theartofanimation.tumblr.com/image/5781428741) (and
49 | their [bridges](https://images4.alphacoders.com/846/84604.jpg) and
50 | [cockpits](http://www.vehiclehi.com/Other_Vehicles/cockpit/black_prophecy_pc_dvd_rom_rkm_screenshot_03_tyi_cockpit_2560x1024_wallpaper_4142/download_1920x1200))
51 | instead of browsers or stack-bound "apps"
52 |
53 | #### engines v. APIs
54 |
55 | recall an API is basically a public commitment by a service provider to do a
56 | certain set of things if you give it the right request. usually this is "package
57 | data", but since the results can range from "update record" to "audit this
58 | human's state of mind" to "kill somebody", the whole "data" thing has gotten
59 | loose from a purely informative conception. (and anyway, physicists recognise
60 | this sort of distinction as purely conventional.)
61 |
62 | but there's no provider in a decentralised space! there's just information in a
63 | space, and you can either see it, or you can't. (and with an async request, you
64 | can just plan to do whatever is needed in the eventuality.) moreover, what you
65 | do with the information that's been shared with is honestly up to you.
66 |
67 | in that case, what you need is some programming that moves you through data (or
68 | moves data thru you ;). that's what an engine is. you may say "get me another
69 | page of this", or you may say "warp 8 to the happening jams"; it's all about the
70 | mechanisms you want to build in.
71 |
72 | saying that, you can expect a fair number of common types and mechanisms to suit
73 | a lot of needs, so, just like other vehicle engines, there will be mostly a
74 | collection of standard configurations (themselves constructed of software
75 | modules as usual), with a host of tweaks to get what you want out of them.
76 |
77 |
78 | #### galaxies v. conventional resource space
79 |
80 | as i mentioned in the motivation section, the network stack that runs "the
81 | internet" is one of many sets of conventions and transmission media, and it is a
82 | centralised one, with very little actual choice or agency, just a collection of
83 | mostly profit-oriented
84 | [dividuations](http://p2pfoundation.net/Dividuation). despite the apparent
85 | quantity of services, the same sorts of betrayals and other abrupt changes occur
86 | from platform to platform:
87 |
88 | - twitter architecture changes such as
89 | ["verified" profiles](http://anildash.com/2013/03/what-its-like-being-verified-on-twitter.html)
90 | and
91 | [algorithmic suggestions](http://www.forbes.com/sites/theopriestley/2016/02/06/twitters-algorithmic-timeline-switch-is-all-your-own-fault/#796e152331b6)
92 | - facebook UI being used for
93 | [large-scale emotion manipulation experiments](https://www.theguardian.com/technology/2014/jun/30/facebook-emotion-study-breached-ethical-guidelines-researchers-say)
94 | - snapchat failing to live up to
95 | [the privacy feature that constituted its sole offering](http://www.networkworld.com/article/2999980/security/snapchat-now-has-the-rights-to-store-and-share-selfies-taken-via-the-app.html)
96 | - CDNs ghettoising requestors by
97 | [forcing them to perform repeated labor to view content if they come from a suspected VPN or Tor exit IP](https://trac.torproject.org/projects/tor/ticket/18361)
98 | - tumblr
99 | [removing LGBT-related material](http://www.gaystarnews.com/article/tumblr-censors-gay-lesbian-and-bisexual-search-tags230713/)
100 | from search indexing
101 | - an overall trend of
102 | "[bullshit minimalism](http://idlewords.com/talks/website_obesity.htm)"
103 | obscuring a swath of heavyweight, throwaway, "single page" javascript, written
104 | for the primary purpose of providing data to markup
105 |
106 | in most of the above cases, basically the only recourse you have is to be a
107 | complaining consumer. you're not even a customer, because you don't have a
108 | paying arrangement (a condition for enfranchisement in a market-controlled
109 | system). and anyway, making a lot of noise in the same chamber controlled by the
110 | authority you're attempting to sway, or making insignificant consumption choices
111 | at the mercy of whatever "app" is trendy at the moment, does nothing to actually
112 | increase your agency in any way. worst of all, it reinforces a frame where
113 | attention, oration, rhetoric, and other tactical expressions are the main tools
114 | of change, where "social capital" is yet another resource to be accumulated.
115 |
116 | it's worth it to mention that "network effects", a supposed driver of monolithic
117 | centralised services, are meaningless at the scale of lived experience. (almost
118 | by definition!) most of the hand-wringing over the market capture implied by
119 | that concept is mostly a neurosis created by capital-dependent, winner-take-all
120 | systems. "[you and yours](https://en.wikipedia.org/wiki/Friend_of_a_friend)" is
121 | a good enough "market share" for a fully-lived experience. the options just
122 | haven't been flexible or satisfying enough yet.
123 |
124 | a healthy variety of interdependent but autonomous and discoverable networks of
125 | communication that decouple global hierarchy and authority from capacity and
126 | structure offers not only this flexibility, but also the recognition and agency
127 | not afforded by centralised networks.
128 |
129 |
130 | #### spacecraft v. browsers
131 |
132 | to be honest, these days a browser is a cross between a
133 | [television](https://thedissolve.com/features/movie-of-the-week/561-kill-your-television-before-it-kills-you/)
134 | and a cold war european border. its default use-case is "consume content", and
135 | getting data out of it for your own purposes (as opposed to transferring it to
136 | another consumer outlet) is
137 | [a complex process of organising scripts to avoid falling afoul of CSP, exfiltrating data through a URI, and parsing it once delivered to you](https://github.com/du5t/capsule). even
138 | though you can see it and hear it through the browser window, you're not allowed
139 | to make it yours (for your own protection).
140 |
141 | sadly, this trend is continuing, with this conception of "browser" informing and
142 | being informed by mobile phone operating systems, which are notoriously
143 | difficult to actually create anything with. the two things they are best at are:
144 |
145 | - spending your money
146 | - feeding you poorly-directed and portioned streams of market-driven content
147 |
148 | this trend leads all the way to "browser OS", most notably exemplified by
149 | [chrome OS](https://en.wikipedia.org/wiki/Chrome_OS), where "local" data is
150 | completely absent: the source of truth and matters of record is all located out
151 | of your grasp. considering that under the current state of governance
152 | [you are at the mercy of your remotely located identifying data](https://medium.com/phase-change/on-being-a-data-puppet-560e095373d5),
153 | this is no way to live.
154 |
155 | the other extreme is to abandon mediation altogether, and just use short,
156 | transparent programs that handle data streams from the minimal interface of a
157 | terminal located in a free operating system, as in the
158 | [unix philosophy](https://en.wikipedia.org/wiki/Unix_philosophy) and its
159 | contemporary form, [suckless](https://www.suckless.org). this is actually less
160 | intimidating than it appears: with tools like
161 | [fish](https://fishshell.com/docs/current/tutorial.html), the "friendly
162 | interactive shell", this kind of interaction is arguably already a
163 | [conversational UI](https://medium.com/@tomazstolfa/the-future-of-conversational-ui-belongs-to-hybrid-interfaces-8a228de0bdb5),
164 | marketing slogans aside.
165 |
166 | but that extreme's just not going to work for everybody. not everyone wants to
167 | [use emacs](http://www.emacsrocks.com), or
168 | [assemble a plane from a kit](http://www.kitplanes.com/), or
169 | [explore life as they would the parts of a motorcycle](https://en.wikipedia.org/wiki/Zen_and_the_Art_of_Motorcycle_Maintenance).
170 |
171 | if data exists in a space, and it can be made navigable and free, then people
172 | need a vehicle to do that safely with. they need a **spaceship**.
173 |
174 | a **spaceship** is a coherent and unified collection of personal affordances
175 | with you as its subject. your ship is code that you control. your ship is an
176 | interface you can understand. your ship travels through a space that doesn't set
177 | you up to win, lose, or control others.
178 |
179 | a **spaceship** has privacy and safety on the inside. yes, outside of it is an
180 | environment hostile to nearly all carbon-based life, with hazardous radiation
181 | permeating it. and yes, if you spring a leak, the privacy goes right out. but
182 | all of that is true already, and we're floating naked at the moment.
183 |
184 | and in a spaceship, you can go *anywhere*.
185 |
186 | ## prototypicals
187 |
188 | ok, so that might have been a little bit abstract. here are some existing
189 | examples that approach the ideas above:
190 |
191 | - [patchwork](https://github.com/ssbc/patchwork)
192 |
193 | patchwork was the original inspiration for this design. it was intended as a
194 | demonstration of the secure-scuttlebutt protocol, with a light amount of
195 | feed-like structure (a la twitter) over the data. patchwork almost corresponds
196 | to the bridge of a spaceship, but it doesn't have good affordances for
197 | persistent group boundaries. its schema and message handling libs are a rough
198 | approximation of an engine. lastly, the "data feed" and "network sync" views
199 | provide an excellent glimpse into the visible galaxy.
200 |
201 | - [git-ssb](https://github.com/clehner/git-ssb)
202 |
203 | this is a very interesting example, because git itself is a tool for producing
204 | different subjective views of a decentralised network of data! both
205 | [patchwork](https://github.com/ssbc/patchwork) and git-ssb actually view
206 | overlapping sets of data provided by scuttlebot, but git-ssb provides
207 | affordances for appending git-compliant records to the scuttlebutt galaxy, as
208 | well as a github-like view with "issues" and "pull requests". issue threads can
209 | actually be viewed and replied to, using patchwork as well.
210 |
211 | the rough architecture of git-ssb is also very close to the spaceship parts i
212 | mentioned:
213 |
214 | > - A command line tool git-ssb for managing SSB git repos
215 | > - A git remote helper git-remote-ssb for using ssb:// URLs with git
216 | > - A web server git-ssb-web for browsing repos locally
217 |
218 | using the spaceship schema, i would label the top two as engine components, and
219 | the bottom one as part of a bridge.
220 |
221 | - [capsule](https://github.com/du5t/capsule)
222 |
223 | capsule is a bare one-way transmitter that exemplifies the spatial boundaries at
224 | play. its interface, installed as a browser plugin, extracts some selected
225 | portion of a WWW page and serialises it into a protocol URI for parsing and
226 | re-transmission into a galaxy (the engine component). this process is necessary
227 | to cross the borders set out by contemporary browsers, whose domain of use is
228 | the [WWW](https://en.wikipedia.org/wiki/World_Wide_Web).
229 |
230 | this results in a permanent record in some galaxy like ssb that now has a
231 | completely separate life from the original web page, and can now be commented
232 | on.
233 |
234 | - [tor browser](https://www.torproject.org/projects/torbrowser.html.en) (thru
235 | hidden services only)
236 |
237 | though they're known for privacy, obfuscation, and censorship resistance, tor
238 | hidden services are also designed to cross NAT (network address translation)
239 | boundaries. they are available at `.onion` addresses, which constitute their own
240 | namespace separate from the central registries (DNS) and authorities (ICANN)
241 | that regulate the WWW or "surface web" (or whatever it is they call it these
242 | days).
243 |
244 | the tor browser bundle contains an aggressively updated and patched copy of the
245 | firefox browser, which serves as its "bridge" or "cockpit". it bundles a copy of
246 | tor which is automatically started in the background to allow connection
247 | through, and to, the namespace of onions. that serves as its
248 | "engine". naturally, the collection of relay, bridge, and hiddens service nodes
249 | (not to be confused with the spaceship bridge) constitute the onion "galaxy".
250 |
--------------------------------------------------------------------------------
/engines/secure-scuttlebutt/engine.js:
--------------------------------------------------------------------------------
1 | /*
2 | * sbot function allows spaceship to travel the secure-scuttlebutt galaxy.
3 | *
4 | */
5 | 'use strict'
6 | var utils = require('../some-utils')
7 | const subdirName = 'spaceship/ssb/'
8 | var fs = require('fs')
9 | var path = require('path')
10 | var jsonfile = require('jsonfile')
11 | var VerEx = require('verbal-expressions')
12 | var parallel = require('run-parallel')
13 | var uuid = require('uuid')
14 | var pull = require('pull-stream')
15 |
16 | var ssbClient = require('ssb-client')
17 | var ssbkeys = require('ssb-keys')
18 | var ssbMsgLib = require('ssb-msgs')
19 | var ssbref = require('ssb-ref')
20 | var patchworkThreadLib = require('patchwork-threads')
21 |
22 |
23 | // set up ssb client so that the main thread doesn't get hit all the time
24 | var appName = process.env.ssb_appname || 'spaceship_test'
25 | var appKeys = ssbkeys.loadOrCreateSync(path.join(process.env.HOME, `.${appName}/secret`))
26 | var appHost = process.env.ssb_host || 'localhost'
27 | var appPort = process.env[`${appName}_port`] || 8009
28 | var appManifest = JSON.parse(fs.readFileSync(path.join(process.env.HOME, `.${appName}/manifest.json`)))
29 | var ssbOpts = { host: appHost, port: appPort, key: appKeys.id, manifest: appManifest }
30 |
31 | /**
32 | * @namespace engine
33 | * @prop {function} clientCall - internal access to sbot
34 | * @prop {function} createIdentifier - creates ship ID
35 | * @prop {function} listIdentifiers - lists available ship IDs
36 | * @prop {function} destroyIdentifier - permanently destroys ship ID
37 | * @prop {function} entombData - NOT IMPLEMENTED
38 | * @prop {function} importData - NOT IMPLEMENTED
39 | * @prop {function} createRecord - creates record
40 | * @prop {function} viewRecord - retrieves record
41 | * @prop {function} editRecord - revises record
42 | * @prop {function} createOrbital - creates **orbital** record
43 | * @prop {function} viewOrbital - retrieves **orbital** record
44 | * @prop {function} hailOrbital - sends greeting message to orbital
45 | * @prop {function} inviteTraveller - invites traveller into orbital subspace
46 | * @prop {function} emigrateOrbital - removes self from orbital subspace
47 | * @prop {function} deportResident - removes other from orbital subspace
48 | * @prop {function} enterGalaxy - NOT IMPLEMENTED
49 | * @prop {function} leaveGalaxy - NOT IMPLEMENTED
50 | */
51 | var engine = {}
52 |
53 | /**
54 | * weird function to call ssbClient more comfortably.
55 | *
56 | * should never be called directly, at least, i don't. here is what i do:
57 | * ```js
58 | * var ssbClientArgs = []
59 | * if (keypair) { ssbClientArgs.push(keypair) }
60 | * ssbClientArgs.push(publish)
61 | *
62 | * engine.clientCall.apply(this, ssbClientArgs)
63 | * ```
64 | *
65 | * i know, weird. but it sort of makes me happy. and isn't that what javascript
66 | * is *really* about? (i joke.)
67 | *
68 | * @param {function} sbotCall - a function with the signature `(Error: err,
69 | * sbot: sbot)` that contains a procedure/call for the sbot client to execute,
70 | * and a callback reference to handle its result.
71 | * @returns {function} - sort of a closure with config params etc. as demanded
72 | * by `ssbClient`.
73 | * @memberof engine
74 | */
75 | engine.clientCall = function(sbotCall) {
76 | return ssbClient(appKeys, ssbOpts, sbotCall)
77 | }
78 |
79 | /*
80 | * pilot/spaceship functions
81 | *
82 | */
83 |
84 | /**
85 | * function creating a spaceship identifier (keypair).
86 | * @param {boolean} ephemeral - should the ID be ephemeral, or should it be
87 | * saved in the app config dir?
88 | * @param {string} path - path to the config directory where the key will be
89 | * located.
90 | * @param {function} callback - err-back called when the creation is done.
91 | * @memberof engine
92 | */
93 | engine.createIdentifier = function(ephemeral, path, callback) {
94 | let basepath = ''
95 | if (typeof ephemeral === 'function') {
96 | callback = ephemeral
97 | ephemeral = false
98 | }
99 | if (typeof path === 'function') {
100 | callback = path
101 | } else if (typeof path === 'string') {
102 | basepath = path.concat(subdirName)
103 | } else {
104 | basepath = utils.resolveConfigPath(null, subdirName)
105 | }
106 |
107 | if (ephemeral) {
108 | callback(null, ssbkeys.generate('ed25519'))
109 | } else {
110 | const someUser = uuid.v4().concat('.json')
111 | const localPath = basepath.concat(someUser)
112 | ssbkeys.create(
113 | localPath, 'ed25519', function(err, newKey) {
114 | if (err) callback (err)
115 | else {
116 | callback(null, Object.assign(
117 | {}, newKey, { localPath }
118 | ))
119 | }
120 | })
121 | }
122 | }
123 |
124 | /**
125 | * function that lists the available local ship IDs.
126 | * @param {string} configPath - path to the application config.
127 | * @param {function} callback - err-back called with the IO result.
128 | * @memberof engine
129 | */
130 | engine.listIdentifiers = function(configPath, callback) {
131 | // callback to do something with them
132 | const path = utils.resolveConfigPath(configPath, subdirName)
133 | const jsonEx = VerEx().find('.json').endOfLine()
134 |
135 | fs.readdir(path, function(err, files) {
136 | if (err) callback(err)
137 | else {
138 | const idFileNames = files
139 | .filter(function(fname) { return jsonEx.test(fname) })
140 | .map(function(jsonFile) {
141 | return function(callback) {
142 | const localPath = path.concat(jsonFile)
143 | return ssbkeys.load(localPath, function(err, newKey) {
144 | if (err) callback (err)
145 | else {
146 | callback(null, Object.assign(
147 | {}, newKey, { localPath }
148 | ))
149 | }
150 | })
151 | }
152 | })
153 | parallel(idFileNames, function(err, keys) {
154 | if (err) callback(err)
155 | else callback(null, keys)
156 | })
157 | }
158 | })
159 | }
160 |
161 | /**
162 | * function for permanently destroying an ID.
163 | * @param {string} pathToKey - the path to the key itself
164 | * @param {number} id - the key's ID.
165 | * @param {function} errCallback - function to call if an IO error occurs
166 | * @throws {Error} - one of two non-IO errors: no key ID, or ID/keyfile
167 | * mismatch.
168 | * @memberof engine
169 | */
170 | engine.destroyIdentifier = function(pathToKey, id, errCallback) {
171 | // be careful testing this one! backup your IDs
172 | // safety function that matches keypath to ID before deleting
173 |
174 | if (!id) throw new Error('no key ID passed.')
175 | ssbkeys.load(pathToKey, function(err, key) {
176 | if (err) errCallback(err)
177 | else if (key.id !== id) {
178 | throw new Error(
179 | 'The keyfile you are trying to delete does not match the ID you gave.'
180 | )
181 | } else {
182 | fs.unlink(pathToKey, errCallback)
183 | }
184 | })
185 | }
186 |
187 | /**
188 | * function for freezing data (i.e., cryptographically). would probably involve
189 | * compression->encryption. **not implemented**
190 | * @memberof engine
191 | */
192 | engine.entombData = function() {
193 | return null
194 | }
195 |
196 | /**
197 | * function for importing frozen data. reverse of `entombData()`. **not
198 | * implemented**
199 | * @memberof engine
200 | */
201 | engine.importData = function() {
202 | return null
203 | }
204 |
205 | /*
206 | * record functions
207 | *
208 | * essentially the job of record functions is to map spaceship schema to galaxy
209 | * schema. see below for what that looks like
210 | *
211 | */
212 |
213 | /**
214 | * function for creating a record in the galaxy.
215 | * @param {string} orbital - The orbital the record belongs to.
216 | * @param {string} type - metadata describing the record type, i.e. "post",
217 | * "vote", etc.
218 | * @param {Array} links - array of ID strings, indicating other records this one
219 | * connects to in some way.
220 | * @param {string} content - the (serialised) content of the record.
221 | * @param {string} keypair - the ID keypair to use as the author of the record.
222 | * @param {function} callback - err-back to call when the record is created.
223 | * @memberof engine
224 | */
225 | engine.createRecord = function(orbital, type, links, content, keypair, callback) {
226 | if (typeof keypair === 'function') {
227 | callback = keypair
228 | keypair = undefined
229 | }
230 |
231 | var ssbRecord = {}
232 | ssbRecord.type = type
233 | ssbRecord.links = links ? links.map(ssbMsgLib.link) : null
234 |
235 | if (orbital) {
236 | var orbitalLink = ssbMsgLib.link(orbital.key)
237 | ssbRecord.links instanceof Array ?
238 | ssbRecord.links.push(orbitalLink) :
239 | ssbRecord.links = [orbitalLink]
240 | }
241 |
242 | ssbRecord.channel = orbital ? orbital.id : undefined
243 | ssbRecord.recps = [appKeys.public]
244 |
245 | if (orbital) {
246 | if (orbital.value && orbital.value.content && orbital.value.content.residents) {
247 | if (orbital.value.content.residents.includes(appKeys.public)) {
248 | ssbRecord.recps = orbital.value.content.residents
249 | } else {
250 | ssbRecord.recps = ssbRecord.recps.concat(orbital.value.content.residents)
251 | }
252 | } else {
253 | callback(
254 | new Error(
255 | `createRecord was passed a malformed orbital record: ${orbital}`))
256 | }
257 | }
258 |
259 | ssbRecord.content = content
260 |
261 | var publish = function (err, sbot) {
262 | if (err) callback(err)
263 |
264 | else if (orbital) {
265 | if (ssbRecord.recps.length === 1) {
266 | console.warn("warning: this orbital has no residents other than you, according to your records.")
267 | }
268 | // publish a message
269 | sbot.private.publish(ssbRecord, ssbRecord.recps, callback)
270 | // msg.key == hash(msg.value)
271 | // msg.value.author == your id
272 | // msg.value.content == { type: 'post', text: 'My First Post!' }
273 | // ...
274 | } else {
275 | sbot.publish(ssbRecord, callback)
276 | }
277 | }
278 | var ssbClientArgs = []
279 | if (keypair) { ssbClientArgs.push(keypair) }
280 | ssbClientArgs.push(publish)
281 |
282 | engine.clientCall.apply(this, ssbClientArgs)
283 | }
284 |
285 | /**
286 | * function to retrieve a record.
287 | * @param {string} recordID - ID of the record to retrieve.
288 | * @param {function} callback - err-back to be called with the result.
289 | * @memberof engine
290 | */
291 | engine.viewRecord = function(recordID, callback) {
292 | // TODO: refactor this
293 | var view = function (err, sbot) {
294 | if (err) callback(err)
295 | else {
296 | sbot.get(recordID, function(err, record) {
297 | if (err) callback(err)
298 | else if (typeof record.content === 'string') {
299 | // private msg case
300 | engine.decryptRecord(record, callback)
301 | } else {
302 | callback(null, record)
303 | }
304 | })
305 | }
306 | }
307 | var ssbClientArgs = []
308 | ssbClientArgs.push(view)
309 |
310 | engine.clientCall.apply(this, ssbClientArgs)
311 | }
312 |
313 | /**
314 | * function to decrypt a record if encrypted.
315 | * @param {object} record - a well-formed scuttlebot record.
316 | * @param {function} callback - err-back to be called with the result.
317 | * @memberof engine
318 | */
319 | engine.decryptRecord = function(record, callback) {
320 | var decrypt = function (err, sbot) {
321 | if (err) callback(err)
322 | else if (record && record.value && record.value.content) {
323 | sbot.private.unbox(record.value.content, callback)
324 | } else if (record && record.content) {
325 | sbot.private.unbox(record.content, callback)
326 | } else {
327 | callback(
328 | new Error(
329 | `decryptRecord was passed a malformed record: ${JSON.stringify(record)}`))
330 | }
331 | }
332 | var ssbClientArgs = []
333 | ssbClientArgs.push(decrypt)
334 |
335 | engine.clientCall.apply(this, ssbClientArgs)
336 | }
337 |
338 | /**
339 | * function to edit a record. produces a new record linking back to the record
340 | * it revises, according to ssb schema.
341 | *
342 | * for the record, here is that schema:
343 | *
344 | * `{ type: 'post-edit', text: String, root: MsgLink, revisionRoot: MsgLink, revisionBranch: MsgLink, mentions: Links }`
345 | *
346 | * @param {array} links - an array of record IDs this record links to, as in a
347 | * usual record.
348 | * @param {object} origMsg - the original record to revise.
349 | * @param {string} revisionID - the ID of the record to revise. can be null.
350 | * @param {string} revisionContent - the revised content
351 | * @param {string} keypair - the ID keypair to use as the author of the record.
352 | * @param {function} callback - err-back to call with the resulting record.
353 | * @memberof engine
354 | */
355 | engine.editRecord = function(links, origMsg, revisionID, revisionContent, keypair, callback) {
356 | if (typeof keypair === 'function') {
357 | callback = keypair
358 | keypair = undefined
359 | }
360 |
361 | var ssbRecord = {}
362 | ssbRecord.type = 'post-edit'
363 | ssbRecord.links = { links }
364 | ssbRecord.revisionBranch |= utils.ssbLink(origMsg.key)
365 | ssbRecord.channel = origMsg.value.channel
366 | ssbRecord.recps = origMsg.value.recps
367 | ssbRecord.content = revisionContent
368 |
369 | if (origMsg.value.content.type === 'post-edit') {
370 | ssbRecord.revisionRoot = origMsg.value.content.revisionRoot
371 | } else {
372 | ssbRecord.revisionRoot = utils.ssbLink(origMsg.key)
373 | }
374 |
375 |
376 | var publish = function (err, sbot) {
377 | if (err) callback(err)
378 |
379 | else sbot.publish(ssbRecord, callback)
380 | // msg.key == hash(msg.value)
381 | // msg.value.author == your id
382 | // msg.value.content == { type: 'post', text: 'My First Post!' }
383 | // ...
384 | }
385 |
386 | var ssbClientArgs = []
387 | if (keypair) { ssbClientArgs.push(keypair) }
388 | ssbClientArgs.push(publish)
389 |
390 | engine.clientCall.apply(this, ssbClientArgs)
391 | }
392 |
393 | /*
394 | * orbital functions
395 | *
396 | */
397 |
398 | /**
399 | * function to create an orbital record.
400 | * @param {string} name - the name of the orbital.
401 | * @param {Array} invitees - an array of invitee ID strings.
402 | * @param {object} agreement - currently unused. points at a policy record which
403 | * indicates what agreements the orbital residents follow.
404 | * @param {boolean} announce - whether to publicly announce orbital creation. if
405 | * false, invitees will receive private messages from the orbital creator only.
406 | * @param {function} callback - err-back to handle the resulting orbital.
407 | * @memberof engine
408 | */
409 | engine.createOrbital = function(name, invitees, agreement, announce, callback) {
410 | // const { announce, openResidency, governmentType, dictator } = agreement
411 | var ssbOrbital = {}
412 | ssbOrbital.content = 'Orbital '.concat(name).concat(' constructed!')
413 | ssbOrbital.channel = name
414 | ssbOrbital.residents = invitees.includes(appKeys.public) ?
415 | invitees : invitees.concat(appKeys.public)
416 |
417 | ssbOrbital.type = 'orbital'
418 | ssbOrbital.agreement = agreement
419 |
420 | var create;
421 |
422 | if (announce === undefined || announce === true) {
423 | // publicly discoverable case--leave a replicable record
424 | create = function (err, sbot) {
425 | if (err) callback(err)
426 |
427 | // publish a message
428 | sbot.publish(ssbOrbital, callback)
429 | }
430 | } else {
431 | // manifest the orbital as a mere list of recipients
432 | ssbOrbital.agreement = agreement
433 |
434 | create = function(err, sbot) {
435 | if (err) callback(err)
436 |
437 | else sbot.private.publish(ssbOrbital, ssbOrbital.residents, callback)
438 | }
439 | }
440 |
441 | // TODO add keypair
442 | engine.clientCall.apply(this, [create])
443 | }
444 |
445 | /**
446 | * function to collect a digest of records rooted in an orbital.
447 | * @param {string} orbitalID - ID of the orbital record.
448 | * @param {boolean} fetchActual - (optional) whether or not to insist on the
449 | * actual record, not just the ID
450 | * @param {function} callback - err-back to handle the result.
451 | * @memberof engine
452 | */
453 | engine.viewOrbital = function(orbitalID, fetchActual, callback) {
454 | /*
455 | * fetches all of the record heads in an orbital for easy viewing
456 | *
457 | */
458 | if (typeof fetchActual === 'function') {
459 | callback = fetchActual
460 | fetchActual = false
461 | }
462 |
463 | engine.clientCall(function(err, sbot) {
464 | var links = sbot.links({dest: orbitalID})
465 |
466 | pull(links, pull.collect(function(err, linkedMsgs) {
467 | if (err) { callback(err) }
468 | else {
469 |
470 | // FIXME: this function is veeeery inefficient, i think. it fetches
471 | // *every* record in an orbital and traverses all of them back to their
472 | // roots, which will probably be not unique at all.
473 | var rootIDGetters = linkedMsgs
474 | .map(function(relatedRecord) {
475 | return function(callback) {
476 | engine.clientCall(function(err, sbot) {
477 | if (err) { callback(err) }
478 | else { patchworkThreadLib.fetchThreadRootID(sbot, relatedRecord.key, callback) }
479 | })
480 | }
481 | })
482 |
483 | parallel(rootIDGetters, function(err, rootIDs) {
484 | if (err) callback(err)
485 | else {
486 | const uniqIDs = new Set(rootIDs.slice())
487 | // get message for each
488 |
489 | if (fetchActual) {
490 | const recordRootGetters = Array.from(uniqIDs).map(function(recordID) {
491 | return function(callback) {
492 | engine.clientCall(function(err, sbot) {
493 | sbot.get(recordID, callback)
494 | })
495 | }
496 | })
497 |
498 | parallel(recordRootGetters, function(err, roots) {
499 | if (err) callback(err)
500 | else {
501 | callback(null, roots.sort(function(msg1, msg2) {
502 | // sort ascending by date
503 | return msg1.value.timestamp < msg2.value.timestamp
504 | }))
505 | }
506 | })
507 | } else {
508 | callback(null, Array.from(uniqIDs))
509 | }
510 | }
511 | })
512 | }
513 | }))
514 | })
515 | }
516 |
517 | /**
518 | * function to contact the orbital 'from the outside'. allows interactions like
519 | * asking for an invite.
520 | * @param {object} orbital - the (ideally) latest record describing the orbital.
521 | * @param {string} intro - the body of the hail.
522 | * @param {function} callback - err-back for the result.
523 | * @memberof engine
524 | */
525 | engine.hailOrbital = function(orbital, intro, callback) {
526 | /* in ssb's case, it seems good enough to hit everyone in the orbital with a
527 | * hail message
528 | *
529 | * only works on discoverable orbitals (for good reason), or orbitals whose id
530 | * you know
531 | */
532 | var hail = {}
533 | hail.type = 'hail'
534 | hail.recps = orbital.value.content.residents
535 | hail.content = intro
536 |
537 | engine.clientCall(function (err, sbot) {
538 | if (err) callback(err)
539 |
540 | else sbot.private.publish(hail, orbital.value.content.residents, callback)
541 | })
542 | }
543 |
544 | /**
545 | * function to invite a traveller to an orbital.
546 | * @param {string} traveller - the ID of the traveller.
547 | * @param {string} orbital - the (ideally) latest record describing the orbital.
548 | * @param {string} intro - a message introducing the traveller.
549 | * @param {function} callback - err-back containing the resulting record or
550 | * error.
551 | * @memberof engine
552 | */
553 | engine.inviteTraveller = function(traveller, orbital, intro, callback) {
554 | var invite = {}
555 | invite.type = 'invite'
556 | invite.recps = orbital.value.content.residents
557 | invite.content = intro
558 |
559 | engine.clientCall(function (err, sbot) {
560 | if (err) callback(err)
561 |
562 | else sbot.private.publish(invite, orbital.value.content.residents, callback)
563 | })
564 | }
565 |
566 | /**
567 | * function announcing permanent exit from an orbital. works like a hail.
568 | * @param {string} orbital - the (ideally) latest record describing the orbital.
569 | * @param {string} outro - body containing a farewell message or such.
570 | * @param {function} callback - err-back called on the resulting record or
571 | * error.
572 | * @memberof engine
573 | */
574 | engine.emigrateOrbital = function(orbital, outro, callback) {
575 | /* leave a message letting all the other ships in the orbital know you're
576 | * leaving, so they can strip your ID from traffic
577 | *
578 | */
579 | var farewell = {}
580 | farewell.type = 'emigration'
581 | farewell.recps = orbital.value.content.residents
582 | farewell.content = outro
583 |
584 | engine.clientCall(function (err, sbot) {
585 | if (err) callback(err)
586 |
587 | else sbot.private.publish(farewell, orbital.value.content.residents, callback)
588 | })
589 | }
590 |
591 | /**
592 | * function [r]ejecting an orbital member from an orbital.
593 | * @param {string} traveller - an ID pointing at a traveller.
594 | * @param {object} orbital - the (ideally) latest record describing the orbital.
595 | * @param {string} justification - body of the [r]ejection record.
596 | * @param {function} callback - err-back called with the resulting record or
597 | * error.
598 | * @memberof engine
599 | */
600 | engine.deportResident = function(traveller, orbital, justification, callback) {
601 | var rejection = {}
602 | rejection.type = 'rejection'
603 | rejection.recps = orbital.value.content.residents
604 | // remove the traveller's ID from message recipient
605 | rejection.recps
606 | .splice(rejection.recps.findIndex(recp => recp === traveller), 1)
607 | rejection.content = justification
608 |
609 | engine.clientCall(function (err, sbot) {
610 | if (err) callback(err)
611 |
612 | else sbot.private.publish(rejection, orbital.value.content.residents, callback)
613 | })
614 | }
615 |
616 | /*
617 | * galaxy functions
618 | *
619 | */
620 |
621 | /**
622 | * **not implemented yet**
623 | *
624 | * ssb-client expects to have a scuttlebot running someplace it can reach. all
625 | * interaction with it is through callbacks.
626 | *
627 | * this function in sbot's case is just for spinning up that child process, if
628 | * there isn't one already.
629 | *
630 | * so we have three cases:
631 | *
632 | * 1) bot not running -> start with with above key location and return process
633 | * ref
634 | *
635 | * 2) bot running, key location is different from running bot -> new identifier,
636 | * so return a partial application (curry) of ssbClient that includes botInfo
637 | *
638 | * 3) bot running, key location is empty -> default identifier; return ok
639 | *
640 | * for type/interface sanity this means we should return an object that
641 | * describes which of these things happened, containing the return of above.
642 | *
643 | * TODO replace all of this with something like RPC on scuttlebot-views
644 | * @param {string} keyLocation - path to spaceship identifier.
645 | * @param {object} botInfo - object containing appropriate info to run sbot.
646 | * @memberof engine
647 | */
648 | engine.enterGalaxy = function(keyLocation, botInfo) {
649 |
650 | // if (botInfo )
651 |
652 | }
653 |
654 | /**
655 | * **not implemented yet**
656 | *
657 | * following after above cases:
658 | *
659 | * 1) bot was started in spaceship -> halt process, return ok
660 | *
661 | * 2) bot running, plural keys -> ?? how does sbot treat this case?
662 | *
663 | * 3) bot running independently, default key -> do nothing, spaceship never had
664 | * control
665 | *
666 | * TODO replace as above with RPC on scuttlebot-views
667 | *
668 | * @param {object} childProc - reference pointing to the child process that
669 | * connects to ssb galaxy.
670 | * @param {string} shipID - ID of the connected ship ID, if there is more than
671 | * one (i.e., multiplexing case)
672 | * @memberof engine
673 | */
674 | engine.leaveGalaxy = function(childProc, shipID) {
675 | if (typeof childProc !== undefined) {
676 |
677 | } else if (typeof shipID !== undefined) {
678 |
679 | } else {
680 |
681 | }
682 | }
683 |
684 | module.exports = engine;
685 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------